From 04216e4d76ea0bd00a8483fcddb8d4bea6d13255 Mon Sep 17 00:00:00 2001 From: Aniketh Varma Date: Wed, 16 Oct 2024 23:21:07 +0530 Subject: [PATCH] Explicitly export types not referenced by exported types (#822) Fixes #686 --- package-lock.json | 2 +- package.json | 2 +- src/event-log/event-log-level.ts | 2 +- src/index.ts | 36 ++++++++++++++----------- src/store/blockstore-level.ts | 2 +- src/store/data-store-level.ts | 2 +- src/store/index-level.ts | 2 +- src/store/level-wrapper.ts | 2 +- src/store/message-store-level.ts | 2 +- src/store/resumable-task-store-level.ts | 2 +- src/types/message-types.ts | 4 +-- 11 files changed, 32 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index 713c5625a..03042227d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "@types/flat": "^5.0.2", "@types/karma": "^6.3.3", "@types/lodash": "4.14.179", - "@types/mocha": "9.1.0", + "@types/mocha": "^9.1.0", "@types/ms": "0.7.31", "@types/node": "^18.13.0", "@types/randombytes": "2.0.0", diff --git a/package.json b/package.json index 15980fde5..d6351693b 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "@types/flat": "^5.0.2", "@types/karma": "^6.3.3", "@types/lodash": "4.14.179", - "@types/mocha": "9.1.0", + "@types/mocha": "^9.1.0", "@types/ms": "0.7.31", "@types/node": "^18.13.0", "@types/randombytes": "2.0.0", diff --git a/src/event-log/event-log-level.ts b/src/event-log/event-log-level.ts index 581b1bc46..e52d74dcf 100644 --- a/src/event-log/event-log-level.ts +++ b/src/event-log/event-log-level.ts @@ -7,7 +7,7 @@ import { createLevelDatabase } from '../store/level-wrapper.js'; import { IndexLevel } from '../store/index-level.js'; import { monotonicFactory } from 'ulidx'; -type EventLogLevelConfig = { +export type EventLogLevelConfig = { /** * must be a directory path (relative or absolute) where * LevelDB will store its files, or in browsers, the name of the diff --git a/src/index.ts b/src/index.ts index 5cb4faa9a..40db61c53 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,10 +2,12 @@ export type { DwnConfig } from './dwn.js'; export type { EventLog } from './types/event-log.js'; export type { EventListener, EventStream, EventSubscription, MessageEvent, SubscriptionReply } from './types/subscriptions.js'; -export type { GenericMessage, GenericMessageReply, MessageSort, MessageSubscription, Pagination, QueryResultEntry } from './types/message-types.js'; -export type { MessagesFilter, MessagesReadMessage as MessagesReadMessage, MessagesReadReply as MessagesReadReply, MessagesReadReplyEntry as MessagesReadReplyEntry, MessagesQueryMessage, MessagesQueryReply, MessagesSubscribeDescriptor, MessagesSubscribeMessage, MessagesSubscribeReply, MessageSubscriptionHandler } from './types/messages-types.js'; -export type { Filter, EqualFilter, OneOfFilter, RangeFilter, RangeCriterion, PaginationCursor, QueryOptions } from './types/query-types.js'; -export type { ProtocolsConfigureDescriptor, ProtocolDefinition, ProtocolTypes, ProtocolRuleSet, ProtocolsQueryFilter, ProtocolsConfigureMessage, ProtocolsQueryMessage, ProtocolsQueryReply } from './types/protocols-types.js'; +export type { AuthorizationModel, Descriptor, DelegatedGrantRecordsWriteMessage, GenericMessage, GenericMessageReply, GenericSignaturePayload, MessageSort, MessageSubscription, Pagination, QueryResultEntry, Status } from './types/message-types.js'; +export type { MessagesFilter, MessagesReadMessage as MessagesReadMessage, MessagesReadReply as MessagesReadReply, MessagesReadReplyEntry as MessagesReadReplyEntry, MessagesReadDescriptor, MessagesQueryDescriptor, MessagesQueryMessage, MessagesQueryReply, MessagesSubscribeDescriptor, MessagesSubscribeMessage, MessagesSubscribeReply, MessageSubscriptionHandler, MessagesSubscribeMessageOptions } from './types/messages-types.js'; +export type { GT, LT, Filter, FilterValue, KeyValues, EqualFilter, OneOfFilter, RangeFilter, RangeCriterion, PaginationCursor, QueryOptions, RangeValue, StartsWithFilter } from './types/query-types.js'; +export type { ProtocolsConfigureDescriptor, ProtocolDefinition, ProtocolTypes, ProtocolRuleSet, ProtocolsQueryFilter, ProtocolsConfigureMessage, ProtocolsQueryMessage, ProtocolsQueryReply, ProtocolActionRule, ProtocolPathEncryption, ProtocolsQueryDescriptor, ProtocolType } from './types/protocols-types.js'; +export type { DataEncodedRecordsWriteMessage, EncryptedKey, EncryptionProperty, RecordsDeleteMessage, RecordsFilter, RecordsQueryMessage, RecordsQueryReply, RecordsQueryReplyEntry, RecordsReadMessage, RecordsReadReply, RecordsSubscribeDescriptor, RecordsSubscribeMessage, RecordsSubscribeReply, RecordSubscriptionHandler, RecordsWriteDescriptor, RecordsWriteTags, RecordsWriteTagValue, RecordsWriteMessage, RecordsWriteSignaturePayload, RecordsDeleteDescriptor, RecordsQueryDescriptor, RecordsReadDescriptor, RecordsSubscribeMessageOptions, RecordsWriteMessageOptions, InternalRecordsWriteMessage, RecordEvent, RecordsWriteTagsFilter } from './types/records-types.js'; +export type { GeneralJws, SignatureEntry } from './types/jws-types.js'; export { authenticate } from './core/auth.js'; export { ActiveTenantCheckResult, AllowAllTenantGate, TenantGate } from './core/tenant-gate.js'; export { Cid } from './utils/cid.js'; @@ -14,26 +16,27 @@ export { DataStore, DataStorePutResult, DataStoreGetResult } from './types/data- export { ResumableTaskStore, ManagedResumableTask } from './types/resumable-task-store.js'; export { DataStream } from './utils/data-stream.js'; export { DerivedPrivateJwk, HdKey, KeyDerivationScheme } from './utils/hd-key.js'; -export { Dwn } from './dwn.js'; +export { Dwn, MessageOptions } from './dwn.js'; export { DwnConstant } from './core/dwn-constant.js'; export { DwnError, DwnErrorCode } from './core/dwn-error.js'; export { DwnInterfaceName, DwnMethodName } from './enums/dwn-interface-method.js'; export { Encoder } from './utils/encoder.js'; export { MessagesSubscribe as MessagesSubscribe, MessagesSubscribeOptions as MessagesSubscribeOptions } from './interfaces/messages-subscribe.js'; -export { Encryption, EncryptionAlgorithm } from './utils/encryption.js'; +export { Encryption, EncryptionAlgorithm, EciesEncryptionOutput, EciesEncryptionInput } from './utils/encryption.js'; export { EncryptionInput, KeyEncryptionInput, RecordsWrite, RecordsWriteOptions, CreateFromOptions } from './interfaces/records-write.js'; export { executeUnlessAborted } from './utils/abort.js'; export { Jws } from './utils/jws.js'; -export { KeyMaterial, PrivateJwk, PublicJwk } from './types/jose-types.js'; +export { KeyMaterial, PrivateJwk, PublicJwk, Jwk } from './types/jose-types.js'; export { Message } from './core/message.js'; export { MessagesRead as MessagesRead, MessagesReadOptions as MessagesReadOptions } from './interfaces/messages-read.js'; export { MessagesQuery, MessagesQueryOptions } from './interfaces/messages-query.js'; export { UnionMessageReply } from './core/message-reply.js'; export { MessageStore, MessageStoreOptions } from './types/message-store.js'; +export { MessageInterface } from './types/message-interface.js'; export { PermissionGrant } from './protocols/permission-grant.js'; export { PermissionRequest } from './protocols/permission-request.js'; -export { PermissionsProtocol } from './protocols/permissions.js'; -export { PrivateKeySigner } from './utils/private-key-signer.js'; +export { PermissionsProtocol, PermissionGrantCreateOptions, PermissionRequestCreateOptions, PermissionRevocationCreateOptions } from './protocols/permissions.js'; +export { PrivateKeySigner, PrivateKeySignerOptions } from './utils/private-key-signer.js'; export { Protocols } from './utils/protocols.js'; export { ProtocolsConfigure, ProtocolsConfigureOptions } from './interfaces/protocols-configure.js'; export { ProtocolsQuery, ProtocolsQueryOptions } from './interfaces/protocols-query.js'; @@ -50,12 +53,15 @@ export * from './types/permission-types.js'; export * from './types/records-types.js'; // concrete implementations of stores and event stream -export { DataStoreLevel } from './store/data-store-level.js'; -export { EventLogLevel } from './event-log/event-log-level.js'; -export { MessageStoreLevel } from './store/message-store-level.js'; -export { ResumableTaskStoreLevel } from './store/resumable-task-store-level.js'; -export { EventEmitterStream } from './event-log/event-emitter-stream.js'; +export { BlockstoreLevel, BlockstoreLevelConfig } from './store/blockstore-level.js'; +export { DataStoreLevel, DataStoreLevelConfig } from './store/data-store-level.js'; +export { EventLogLevel, EventLogLevelConfig } from './event-log/event-log-level.js'; +export { IndexLevel, IndexLevelConfig, IndexedItem, IndexLevelOptions } from './store/index-level.js'; +export { createLevelDatabase, CreateLevelDatabaseOptions, LevelDatabase, LevelWrapper, LevelWrapperConfig, LevelWrapperBatchOperation, LevelWrapperOptions, LevelWrapperIteratorOptions } from './store/level-wrapper.js'; +export { MessageStoreLevel, MessageStoreLevelConfig } from './store/message-store-level.js'; +export { ResumableTaskStoreLevel, ResumableTaskStoreLevelConfig } from './store/resumable-task-store-level.js'; +export { EventEmitterStream, EventEmitterStreamConfig } from './event-log/event-emitter-stream.js'; // test library exports -export { Persona, TestDataGenerator } from '../tests/utils/test-data-generator.js'; +export { GenerateFromRecordsWriteOut, GenerateGrantCreateOutput, GenerateMessagesQueryOutput, GenerateMessagesReadOutput, GenerateMessagesSubscribeOutput, GenerateProtocolsConfigureOutput, GenerateProtocolsQueryOutput, GenerateRecordsDeleteOutput, GenerateRecordsQueryOutput, GenerateRecordsSubscribeOutput, GenerateRecordsWriteOutput, Persona, TestDataGenerator, GenerateFromRecordsWriteInput, GenerateGrantCreateInput, GenerateMessagesQueryInput, GenerateMessagesReadInput, GenerateMessagesSubscribeInput, GenerateProtocolsConfigureInput, GenerateProtocolsQueryInput, GenerateRecordsDeleteInput, GenerateRecordsQueryInput, GenerateRecordsSubscribeInput, GenerateRecordsWriteInput } from '../tests/utils/test-data-generator.js'; export { Poller } from '../tests/utils/poller.js'; \ No newline at end of file diff --git a/src/store/blockstore-level.ts b/src/store/blockstore-level.ts index 8965391b8..2ca7e76b9 100644 --- a/src/store/blockstore-level.ts +++ b/src/store/blockstore-level.ts @@ -107,7 +107,7 @@ export class BlockstoreLevel implements Blockstore { } } -type BlockstoreLevelConfig = { +export type BlockstoreLevelConfig = { location: string, createLevelDatabase?: typeof createLevelDatabase, }; \ No newline at end of file diff --git a/src/store/data-store-level.ts b/src/store/data-store-level.ts index 79350f762..3174257cf 100644 --- a/src/store/data-store-level.ts +++ b/src/store/data-store-level.ts @@ -114,7 +114,7 @@ export class DataStoreLevel implements DataStore { } } -type DataStoreLevelConfig = { +export type DataStoreLevelConfig = { blockstoreLocation?: string, createLevelDatabase?: typeof createLevelDatabase, }; \ No newline at end of file diff --git a/src/store/index-level.ts b/src/store/index-level.ts index ac2ae5edc..7a33bfb15 100644 --- a/src/store/index-level.ts +++ b/src/store/index-level.ts @@ -8,7 +8,7 @@ import { createLevelDatabase, LevelWrapper } from './level-wrapper.js'; import { DwnError, DwnErrorCode } from '../core/dwn-error.js'; import { FilterSelector, FilterUtility } from '../utils/filter.js'; -type IndexLevelConfig = { +export type IndexLevelConfig = { location: string, createLevelDatabase?: typeof createLevelDatabase }; diff --git a/src/store/level-wrapper.ts b/src/store/level-wrapper.ts index 4da51a3eb..4a7b696a4 100644 --- a/src/store/level-wrapper.ts +++ b/src/store/level-wrapper.ts @@ -266,7 +266,7 @@ export class LevelWrapper { } } -type LevelWrapperConfig = CreateLevelDatabaseOptions & { +export type LevelWrapperConfig = CreateLevelDatabaseOptions & { location: string, createLevelDatabase?: typeof createLevelDatabase, }; \ No newline at end of file diff --git a/src/store/message-store-level.ts b/src/store/message-store-level.ts index 59289fdc7..969445999 100644 --- a/src/store/message-store-level.ts +++ b/src/store/message-store-level.ts @@ -188,7 +188,7 @@ export class MessageStoreLevel implements MessageStore { } } -type MessageStoreLevelConfig = { +export type MessageStoreLevelConfig = { blockstoreLocation?: string, indexLocation?: string, createLevelDatabase?: typeof createLevelDatabase, diff --git a/src/store/resumable-task-store-level.ts b/src/store/resumable-task-store-level.ts index fed122869..2e008f5d9 100644 --- a/src/store/resumable-task-store-level.ts +++ b/src/store/resumable-task-store-level.ts @@ -3,7 +3,7 @@ import type { ManagedResumableTask, ResumableTaskStore } from '../types/resumabl import { Cid } from '../utils/cid.js'; import { createLevelDatabase, LevelWrapper } from './level-wrapper.js'; -type ResumableTaskStoreLevelConfig = { +export type ResumableTaskStoreLevelConfig = { location?: string, createLevelDatabase?: typeof createLevelDatabase }; diff --git a/src/types/message-types.ts b/src/types/message-types.ts index 43cfb6d91..3409964a7 100644 --- a/src/types/message-types.ts +++ b/src/types/message-types.ts @@ -36,7 +36,7 @@ export type AuthorizationModel = { ownerDelegatedGrant?: DelegatedGrantRecordsWriteMessage; }; -type DelegatedGrantRecordsWriteMessage = { +export type DelegatedGrantRecordsWriteMessage = { authorization: { /** * The signature of the author. @@ -116,7 +116,7 @@ export type Pagination = { limit?: number; }; -type Status = { +export type Status = { code: number detail: string };