@helia/interface 6.0.3 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js.map +2 -2
- package/dist/src/blocks.d.ts +17 -1
- package/dist/src/blocks.d.ts.map +1 -1
- package/dist/src/blocks.js.map +1 -1
- package/dist/typedoc-urls.json +2 -0
- package/package.json +1 -1
- package/src/blocks.ts +20 -1
package/dist/index.min.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/blocks.ts", "../src/errors.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @packageDocumentation\n *\n * The API defined by a {@link Helia} node\n *\n * @example\n *\n * ```typescript\n * import type { Helia } from '@helia/interface'\n *\n * export function doSomething(helia: Helia) {\n * // use helia node functions here\n * }\n * ```\n */\n\nimport type { Blocks } from './blocks.js'\nimport type { Pins } from './pins.js'\nimport type { Routing } from './routing.js'\nimport type { AbortOptions, ComponentLogger, Libp2p, Metrics, TypedEventEmitter } from '@libp2p/interface'\nimport type { DNS } from '@multiformats/dns'\nimport type { Datastore } from 'interface-datastore'\nimport type { Await } from 'interface-store'\nimport type { BlockCodec, MultihashHasher } from 'multiformats'\nimport type { CID } from 'multiformats/cid'\nimport type { ProgressEvent, ProgressOptions } from 'progress-events'\n\nexport type { Await, AwaitIterable } from 'interface-store'\n\nexport interface CodecLoader {\n <T = any, Code extends number = any>(code: Code): Await<BlockCodec<Code, T>>\n}\n\nexport interface HasherLoader {\n (code: number): Await<MultihashHasher>\n}\n\n/**\n * The API presented by a Helia node\n */\nexport interface Helia<T extends Libp2p = Libp2p> {\n /**\n * The libp2p instance\n */\n libp2p: T\n\n /**\n * Where the blocks are stored\n */\n blockstore: Blocks\n\n /**\n * A key/value store\n */\n datastore: Datastore\n\n /**\n * Event emitter for Helia start and stop events\n */\n events: TypedEventEmitter<HeliaEvents<T>>\n\n /**\n * Pinning operations for blocks in the blockstore\n */\n pins: Pins\n\n /**\n * A logging component that can be reused by consumers\n */\n logger: ComponentLogger\n\n /**\n * The routing component allows performing operations such as looking up\n * content providers, information about peers, etc.\n */\n routing: Routing\n\n /**\n * The DNS property can be used to perform lookups of various record types and\n * will use a resolver appropriate to the current platform.\n */\n dns: DNS\n\n /**\n * A metrics object that can be used to collected arbitrary stats about node\n * usage.\n */\n metrics?: Metrics\n\n /**\n * Starts the Helia node\n */\n start(): Promise<void>\n\n /**\n * Stops the Helia node\n */\n stop(): Promise<void>\n\n /**\n * Remove any unpinned blocks from the blockstore\n */\n gc(options?: GCOptions): Promise<void>\n\n /**\n * Load an IPLD codec. Implementations may return a promise if, for example,\n * the codec is being fetched from the network.\n */\n getCodec: CodecLoader\n\n /**\n * Hashers can be used to hash a piece of data with the specified hashing\n * algorithm. Implementations may return a promise if, for example,\n * the hasher is being fetched from the network.\n */\n getHasher: HasherLoader\n}\n\nexport type GcEvents =\n ProgressEvent<'helia:gc:deleted', CID> |\n ProgressEvent<'helia:gc:error', Error>\n\nexport interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {\n\n}\n\nexport interface HeliaEvents<T extends Libp2p = Libp2p> {\n /**\n * This event notifies listeners that the node has started\n *\n * ```TypeScript\n * helia.addEventListener('start', (event) => {\n * console.info(event.detail.libp2p.isStarted()) // true\n * })\n * ```\n */\n start: CustomEvent<Helia<T>>\n\n /**\n * This event notifies listeners that the node has stopped\n *\n * ```TypeScript\n * helia.addEventListener('stop', (event) => {\n * console.info(event.detail.libp2p.isStarted()) // false\n * })\n * ```\n */\n stop: CustomEvent<Helia<T>>\n}\n\nexport * from './blocks.js'\nexport * from './errors.js'\nexport * from './pins.js'\nexport * from './routing.js'\n", "import type { PeerId } from '@libp2p/interface'\nimport type { Multiaddr } from '@multiformats/multiaddr'\nimport type { Blockstore } from 'interface-blockstore'\nimport type { AbortOptions } from 'interface-store'\nimport type { CID } from 'multiformats/cid'\nimport type { ProgressEvent, ProgressOptions } from 'progress-events'\n\nexport type { Pair, InputPair } from 'interface-blockstore'\n\nexport interface ProviderOptions {\n /**\n * An optional list of peers known to host at least the root block of the DAG\n * that will be fetched.\n *\n * If this list is omitted, or if the peers cannot supply the root or any\n * child blocks, a `findProviders` routing query will be run to find peers\n * that can supply the blocks.\n */\n providers?: Array<PeerId | Multiaddr | Multiaddr[]>\n}\n\nexport type HasBlockProgressEvents =\n ProgressEvent<'blocks:put:duplicate', CID> |\n ProgressEvent<'blocks:put:providers:notify', CID> |\n ProgressEvent<'blocks:put:blockstore:put', CID>\n\nexport type PutBlockProgressEvents =\n ProgressEvent<'blocks:put:duplicate', CID> |\n ProgressEvent<'blocks:put:providers:notify', CID> |\n ProgressEvent<'blocks:put:blockstore:put', CID>\n\nexport type PutManyBlocksProgressEvents =\n ProgressEvent<'blocks:put-many:duplicate', CID> |\n ProgressEvent<'blocks:put-many:providers:notify', CID> |\n ProgressEvent<'blocks:put-many:blockstore:put-many'>\n\nexport type GetBlockProgressEvents =\n ProgressEvent<'blocks:get:providers:want', CID> |\n ProgressEvent<'blocks:get:blockstore:get', CID> |\n ProgressEvent<'blocks:get:blockstore:put', CID>\n\nexport type GetManyBlocksProgressEvents =\n ProgressEvent<'blocks:get-many:blockstore:get-many'> |\n ProgressEvent<'blocks:get-many:providers:want', CID> |\n ProgressEvent<'blocks:get-many:blockstore:put', CID>\n\nexport type GetAllBlocksProgressEvents =\n ProgressEvent<'blocks:get-all:blockstore:get-many'>\n\nexport type DeleteBlockProgressEvents =\n ProgressEvent<'blocks:delete:blockstore:delete', CID>\n\nexport type DeleteManyBlocksProgressEvents =\n ProgressEvent<'blocks:delete-many:blockstore:delete-many'>\n\nexport interface GetOfflineOptions {\n /**\n * If true, do not attempt to fetch any missing blocks from the network\n *\n * @default false\n */\n offline?: boolean\n}\n\nexport interface Blocks extends Blockstore<ProgressOptions<HasBlockProgressEvents>,\nProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>,\nGetOfflineOptions & ProviderOptions & ProgressOptions<GetBlockProgressEvents>,\nGetOfflineOptions & ProviderOptions & ProgressOptions<GetManyBlocksProgressEvents>,\nProgressOptions<GetAllBlocksProgressEvents>,\nProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>\n> {\n /**\n * A blockstore session only fetches blocks from a subset of network peers to\n * reduce network traffic and improve performance.\n *\n * The initial set of peers can be specified, alternatively a `findProviders`\n * routing query will occur to populate the set instead.\n */\n createSession(root: CID, options?: CreateSessionOptions<GetBlockProgressEvents>): SessionBlockstore\n}\n\n/**\n * A session blockstore is a special blockstore that only pulls content from a\n * subset of network peers which respond as having the block for the initial\n * root CID.\n *\n * Any blocks written to the blockstore as part of the session will propagate\n * to the blockstore the session was created from.\n *\n */\nexport interface SessionBlockstore extends Blockstore<ProgressOptions<HasBlockProgressEvents>,\nProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>,\nGetOfflineOptions & ProgressOptions<GetBlockProgressEvents>, GetOfflineOptions & ProgressOptions<GetManyBlocksProgressEvents>, ProgressOptions<GetAllBlocksProgressEvents>,\nProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>\n> {\n /**\n * Any in-progress operations will be aborted.\n */\n close(): void\n}\n\nexport interface BlockRetrievalOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents>, ProviderOptions {\n /**\n * A function that blockBrokers should call prior to returning a block to ensure it can maintain control\n * of the block request flow. e.g. TrustedGatewayBlockBroker will use this to ensure that the block\n * is valid from one of the gateways before assuming its work is done. If the block is not valid, it should try another gateway\n * and WILL consider the gateway that returned the invalid blocks completely unreliable.\n */\n validateFn?(block: Uint8Array): Promise<void>\n\n /**\n * The maximum size a block can be in bytes.\n *\n * Attempts to retrieve a block larger than this will cause an error to be thrown.\n *\n * @default 2_097_152\n */\n maxSize?: number\n}\n\nexport interface BlockAnnounceOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {\n\n}\n\nexport interface CreateSessionOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents>, ProviderOptions, GetOfflineOptions {\n /**\n * The minimum number of providers for the root CID that are required for\n * successful session creation.\n *\n * The session will become usable once this many providers have been\n * discovered, up to `maxProviders` providers will continue to be added.\n *\n * @default 1\n */\n minProviders?: number\n\n /**\n * The maximum number of providers for the root CID to be added to a session.\n *\n * @default 5\n */\n maxProviders?: number\n}\n\nexport interface BlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> {\n /**\n * Retrieve a block from a source\n */\n retrieve?(cid: CID, options?: BlockRetrievalOptions<RetrieveProgressEvents>): Promise<Uint8Array>\n\n /**\n * Make a new block available to peers\n */\n announce?(cid: CID, options?: BlockAnnounceOptions<AnnounceProgressEvents>): Promise<void>\n\n /**\n * Create a new session\n */\n createSession?(options?: CreateSessionOptions<RetrieveProgressEvents>): BlockBroker<RetrieveProgressEvents, AnnounceProgressEvents>\n}\n\nexport const DEFAULT_SESSION_MIN_PROVIDERS = 1\nexport const DEFAULT_SESSION_MAX_PROVIDERS = 5\n", "export class InsufficientProvidersError extends Error {\n static name = 'InsufficientProvidersError'\n\n constructor (message = 'Insufficient providers found') {\n super(message)\n this.name = 'InsufficientProvidersError'\n }\n}\n\nexport class NoRoutersAvailableError extends Error {\n static name = 'NoRoutersAvailableError'\n\n constructor (message = 'No routers available') {\n super(message)\n this.name = 'NoRoutersAvailableError'\n }\n}\n\nexport class UnknownHashAlgorithmError extends Error {\n static name = 'UnknownHashAlgorithmError'\n\n constructor (message = 'Unknown hash algorithm') {\n super(message)\n this.name = 'UnknownHashAlgorithmError'\n }\n}\n\nexport class UnknownCodecError extends Error {\n static name = 'UnknownCodecError'\n\n constructor (message = 'Unknown codec') {\n super(message)\n this.name = 'UnknownCodecError'\n }\n}\n\nexport class InvalidCodecError extends Error {\n static name = 'InvalidCodecError'\n\n constructor (message = 'Invalid codec') {\n super(message)\n this.name = 'InvalidCodecError'\n }\n}\n"],
|
|
5
|
-
"mappings": ";kcAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,EAAA,kCAAAC,EAAA,+BAAAC,EAAA,sBAAAC,EAAA,4BAAAC,EAAA,sBAAAC,EAAA,8BAAAC,
|
|
4
|
+
"sourcesContent": ["/**\n * @packageDocumentation\n *\n * The API defined by a {@link Helia} node\n *\n * @example\n *\n * ```typescript\n * import type { Helia } from '@helia/interface'\n *\n * export function doSomething(helia: Helia) {\n * // use helia node functions here\n * }\n * ```\n */\n\nimport type { Blocks } from './blocks.js'\nimport type { Pins } from './pins.js'\nimport type { Routing } from './routing.js'\nimport type { AbortOptions, ComponentLogger, Libp2p, Metrics, TypedEventEmitter } from '@libp2p/interface'\nimport type { DNS } from '@multiformats/dns'\nimport type { Datastore } from 'interface-datastore'\nimport type { Await } from 'interface-store'\nimport type { BlockCodec, MultihashHasher } from 'multiformats'\nimport type { CID } from 'multiformats/cid'\nimport type { ProgressEvent, ProgressOptions } from 'progress-events'\n\nexport type { Await, AwaitIterable } from 'interface-store'\n\nexport interface CodecLoader {\n <T = any, Code extends number = any>(code: Code): Await<BlockCodec<Code, T>>\n}\n\nexport interface HasherLoader {\n (code: number): Await<MultihashHasher>\n}\n\n/**\n * The API presented by a Helia node\n */\nexport interface Helia<T extends Libp2p = Libp2p> {\n /**\n * The libp2p instance\n */\n libp2p: T\n\n /**\n * Where the blocks are stored\n */\n blockstore: Blocks\n\n /**\n * A key/value store\n */\n datastore: Datastore\n\n /**\n * Event emitter for Helia start and stop events\n */\n events: TypedEventEmitter<HeliaEvents<T>>\n\n /**\n * Pinning operations for blocks in the blockstore\n */\n pins: Pins\n\n /**\n * A logging component that can be reused by consumers\n */\n logger: ComponentLogger\n\n /**\n * The routing component allows performing operations such as looking up\n * content providers, information about peers, etc.\n */\n routing: Routing\n\n /**\n * The DNS property can be used to perform lookups of various record types and\n * will use a resolver appropriate to the current platform.\n */\n dns: DNS\n\n /**\n * A metrics object that can be used to collected arbitrary stats about node\n * usage.\n */\n metrics?: Metrics\n\n /**\n * Starts the Helia node\n */\n start(): Promise<void>\n\n /**\n * Stops the Helia node\n */\n stop(): Promise<void>\n\n /**\n * Remove any unpinned blocks from the blockstore\n */\n gc(options?: GCOptions): Promise<void>\n\n /**\n * Load an IPLD codec. Implementations may return a promise if, for example,\n * the codec is being fetched from the network.\n */\n getCodec: CodecLoader\n\n /**\n * Hashers can be used to hash a piece of data with the specified hashing\n * algorithm. Implementations may return a promise if, for example,\n * the hasher is being fetched from the network.\n */\n getHasher: HasherLoader\n}\n\nexport type GcEvents =\n ProgressEvent<'helia:gc:deleted', CID> |\n ProgressEvent<'helia:gc:error', Error>\n\nexport interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {\n\n}\n\nexport interface HeliaEvents<T extends Libp2p = Libp2p> {\n /**\n * This event notifies listeners that the node has started\n *\n * ```TypeScript\n * helia.addEventListener('start', (event) => {\n * console.info(event.detail.libp2p.isStarted()) // true\n * })\n * ```\n */\n start: CustomEvent<Helia<T>>\n\n /**\n * This event notifies listeners that the node has stopped\n *\n * ```TypeScript\n * helia.addEventListener('stop', (event) => {\n * console.info(event.detail.libp2p.isStarted()) // false\n * })\n * ```\n */\n stop: CustomEvent<Helia<T>>\n}\n\nexport * from './blocks.js'\nexport * from './errors.js'\nexport * from './pins.js'\nexport * from './routing.js'\n", "import type { PeerId } from '@libp2p/interface'\nimport type { Multiaddr } from '@multiformats/multiaddr'\nimport type { Blockstore } from 'interface-blockstore'\nimport type { AbortOptions } from 'interface-store'\nimport type { CID } from 'multiformats/cid'\nimport type { ProgressEvent, ProgressOptions } from 'progress-events'\n\nexport type { Pair, InputPair } from 'interface-blockstore'\n\nexport interface ProviderOptions {\n /**\n * An optional list of peers known to host at least the root block of the DAG\n * that will be fetched.\n *\n * If this list is omitted, or if the peers cannot supply the root or any\n * child blocks, a `findProviders` routing query will be run to find peers\n * that can supply the blocks.\n */\n providers?: Array<PeerId | Multiaddr | Multiaddr[]>\n}\n\nexport type HasBlockProgressEvents =\n ProgressEvent<'blocks:put:duplicate', CID> |\n ProgressEvent<'blocks:put:providers:notify', CID> |\n ProgressEvent<'blocks:put:blockstore:put', CID>\n\nexport type PutBlockProgressEvents =\n ProgressEvent<'blocks:put:duplicate', CID> |\n ProgressEvent<'blocks:put:providers:notify', CID> |\n ProgressEvent<'blocks:put:blockstore:put', CID>\n\nexport type PutManyBlocksProgressEvents =\n ProgressEvent<'blocks:put-many:duplicate', CID> |\n ProgressEvent<'blocks:put-many:providers:notify', CID> |\n ProgressEvent<'blocks:put-many:blockstore:put-many'>\n\nexport type GetBlockProgressEvents =\n ProgressEvent<'blocks:get:providers:want', CID> |\n ProgressEvent<'blocks:get:blockstore:get', CID> |\n ProgressEvent<'blocks:get:blockstore:put', CID>\n\nexport type GetManyBlocksProgressEvents =\n ProgressEvent<'blocks:get-many:blockstore:get-many'> |\n ProgressEvent<'blocks:get-many:providers:want', CID> |\n ProgressEvent<'blocks:get-many:blockstore:put', CID>\n\nexport type GetAllBlocksProgressEvents =\n ProgressEvent<'blocks:get-all:blockstore:get-many'>\n\nexport type DeleteBlockProgressEvents =\n ProgressEvent<'blocks:delete:blockstore:delete', CID>\n\nexport type DeleteManyBlocksProgressEvents =\n ProgressEvent<'blocks:delete-many:blockstore:delete-many'>\n\nexport interface GetOfflineOptions {\n /**\n * If true, do not attempt to fetch any missing blocks from the network\n *\n * @default false\n */\n offline?: boolean\n}\n\nexport interface Blocks extends Blockstore<ProgressOptions<HasBlockProgressEvents>,\nProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>,\nGetOfflineOptions & ProviderOptions & ProgressOptions<GetBlockProgressEvents>,\nGetOfflineOptions & ProviderOptions & ProgressOptions<GetManyBlocksProgressEvents>,\nProgressOptions<GetAllBlocksProgressEvents>,\nProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>\n> {\n /**\n * A blockstore session only fetches blocks from a subset of network peers to\n * reduce network traffic and improve performance.\n *\n * The initial set of peers can be specified, alternatively a `findProviders`\n * routing query will occur to populate the set instead.\n */\n createSession(root: CID, options?: CreateSessionOptions<GetBlockProgressEvents>): SessionBlockstore\n}\n\n/**\n * A session blockstore is a special blockstore that only pulls content from a\n * subset of network peers which respond as having the block for the initial\n * root CID.\n *\n * Any blocks written to the blockstore as part of the session will propagate\n * to the blockstore the session was created from.\n *\n */\nexport interface SessionBlockstore extends Blockstore<ProgressOptions<HasBlockProgressEvents>,\nProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>,\nGetOfflineOptions & ProgressOptions<GetBlockProgressEvents>, GetOfflineOptions & ProgressOptions<GetManyBlocksProgressEvents>, ProgressOptions<GetAllBlocksProgressEvents>,\nProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>\n> {\n /**\n * Any in-progress operations will be aborted.\n */\n close(): void\n\n /**\n * Adds a new peer to the session if they are supported and are either\n * not already in the session and have not been evicted previously.\n */\n addPeer (peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>\n}\n\nexport interface BlockRetrievalOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents>, ProviderOptions {\n /**\n * A function that blockBrokers should call prior to returning a block to ensure it can maintain control\n * of the block request flow. e.g. TrustedGatewayBlockBroker will use this to ensure that the block\n * is valid from one of the gateways before assuming its work is done. If the block is not valid, it should try another gateway\n * and WILL consider the gateway that returned the invalid blocks completely unreliable.\n */\n validateFn?(block: Uint8Array): Promise<void>\n\n /**\n * The maximum size a block can be in bytes.\n *\n * Attempts to retrieve a block larger than this will cause an error to be thrown.\n *\n * @default 2_097_152\n */\n maxSize?: number\n}\n\nexport interface BlockAnnounceOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {\n\n}\n\nexport interface CreateSessionOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents>, ProviderOptions, GetOfflineOptions {\n /**\n * The minimum number of providers for the root CID that are required for\n * successful session creation.\n *\n * The session will become usable once this many providers have been\n * discovered, up to `maxProviders` providers will continue to be added.\n *\n * @default 1\n */\n minProviders?: number\n\n /**\n * The maximum number of providers for the root CID to be added to a session.\n *\n * @default 5\n */\n maxProviders?: number\n}\n\nexport interface BlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> {\n /**\n * The name of the block broker, used for logging purposes\n */\n name: string\n\n /**\n * Retrieve a block from a source\n */\n retrieve?(cid: CID, options?: BlockRetrievalOptions<RetrieveProgressEvents>): Promise<Uint8Array>\n\n /**\n * Make a new block available to peers\n */\n announce?(cid: CID, options?: BlockAnnounceOptions<AnnounceProgressEvents>): Promise<void>\n\n /**\n * Create a new session\n */\n createSession?(options?: CreateSessionOptions<RetrieveProgressEvents>): SessionBlockBroker<RetrieveProgressEvents, AnnounceProgressEvents>\n}\n\nexport interface SessionBlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends BlockBroker<RetrieveProgressEvents, AnnounceProgressEvents> {\n /**\n * Adds a new peer to the session if they are supported and are either\n * not already in the session and have not been evicted previously.\n */\n addPeer (peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>\n}\n\nexport const DEFAULT_SESSION_MIN_PROVIDERS = 1\nexport const DEFAULT_SESSION_MAX_PROVIDERS = 5\n", "export class InsufficientProvidersError extends Error {\n static name = 'InsufficientProvidersError'\n\n constructor (message = 'Insufficient providers found') {\n super(message)\n this.name = 'InsufficientProvidersError'\n }\n}\n\nexport class NoRoutersAvailableError extends Error {\n static name = 'NoRoutersAvailableError'\n\n constructor (message = 'No routers available') {\n super(message)\n this.name = 'NoRoutersAvailableError'\n }\n}\n\nexport class UnknownHashAlgorithmError extends Error {\n static name = 'UnknownHashAlgorithmError'\n\n constructor (message = 'Unknown hash algorithm') {\n super(message)\n this.name = 'UnknownHashAlgorithmError'\n }\n}\n\nexport class UnknownCodecError extends Error {\n static name = 'UnknownCodecError'\n\n constructor (message = 'Unknown codec') {\n super(message)\n this.name = 'UnknownCodecError'\n }\n}\n\nexport class InvalidCodecError extends Error {\n static name = 'InvalidCodecError'\n\n constructor (message = 'Invalid codec') {\n super(message)\n this.name = 'InvalidCodecError'\n }\n}\n"],
|
|
5
|
+
"mappings": ";kcAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,EAAA,kCAAAC,EAAA,+BAAAC,EAAA,sBAAAC,EAAA,4BAAAC,EAAA,sBAAAC,EAAA,8BAAAC,ICoLO,IAAMC,EAAgC,EAChCC,EAAgC,ECrLvC,IAAOC,EAAP,cAA0C,KAAK,CACnD,OAAO,KAAO,6BAEd,YAAaC,EAAU,+BAA8B,CACnD,MAAMA,CAAO,EACb,KAAK,KAAO,4BACd,GAGWC,EAAP,cAAuC,KAAK,CAChD,OAAO,KAAO,0BAEd,YAAaD,EAAU,uBAAsB,CAC3C,MAAMA,CAAO,EACb,KAAK,KAAO,yBACd,GAGWE,EAAP,cAAyC,KAAK,CAClD,OAAO,KAAO,4BAEd,YAAaF,EAAU,yBAAwB,CAC7C,MAAMA,CAAO,EACb,KAAK,KAAO,2BACd,GAGWG,EAAP,cAAiC,KAAK,CAC1C,OAAO,KAAO,oBAEd,YAAaH,EAAU,gBAAe,CACpC,MAAMA,CAAO,EACb,KAAK,KAAO,mBACd,GAGWI,EAAP,cAAiC,KAAK,CAC1C,OAAO,KAAO,oBAEd,YAAaJ,EAAU,gBAAe,CACpC,MAAMA,CAAO,EACb,KAAK,KAAO,mBACd",
|
|
6
6
|
"names": ["index_exports", "__export", "DEFAULT_SESSION_MAX_PROVIDERS", "DEFAULT_SESSION_MIN_PROVIDERS", "InsufficientProvidersError", "InvalidCodecError", "NoRoutersAvailableError", "UnknownCodecError", "UnknownHashAlgorithmError", "DEFAULT_SESSION_MIN_PROVIDERS", "DEFAULT_SESSION_MAX_PROVIDERS", "InsufficientProvidersError", "message", "NoRoutersAvailableError", "UnknownHashAlgorithmError", "UnknownCodecError", "InvalidCodecError"]
|
|
7
7
|
}
|
package/dist/src/blocks.d.ts
CHANGED
|
@@ -56,6 +56,11 @@ export interface SessionBlockstore extends Blockstore<ProgressOptions<HasBlockPr
|
|
|
56
56
|
* Any in-progress operations will be aborted.
|
|
57
57
|
*/
|
|
58
58
|
close(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Adds a new peer to the session if they are supported and are either
|
|
61
|
+
* not already in the session and have not been evicted previously.
|
|
62
|
+
*/
|
|
63
|
+
addPeer(peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>;
|
|
59
64
|
}
|
|
60
65
|
export interface BlockRetrievalOptions<ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents>, ProviderOptions {
|
|
61
66
|
/**
|
|
@@ -95,6 +100,10 @@ export interface CreateSessionOptions<ProgressEvents extends ProgressEvent<any,
|
|
|
95
100
|
maxProviders?: number;
|
|
96
101
|
}
|
|
97
102
|
export interface BlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> {
|
|
103
|
+
/**
|
|
104
|
+
* The name of the block broker, used for logging purposes
|
|
105
|
+
*/
|
|
106
|
+
name: string;
|
|
98
107
|
/**
|
|
99
108
|
* Retrieve a block from a source
|
|
100
109
|
*/
|
|
@@ -106,7 +115,14 @@ export interface BlockBroker<RetrieveProgressEvents extends ProgressEvent<any, a
|
|
|
106
115
|
/**
|
|
107
116
|
* Create a new session
|
|
108
117
|
*/
|
|
109
|
-
createSession?(options?: CreateSessionOptions<RetrieveProgressEvents>):
|
|
118
|
+
createSession?(options?: CreateSessionOptions<RetrieveProgressEvents>): SessionBlockBroker<RetrieveProgressEvents, AnnounceProgressEvents>;
|
|
119
|
+
}
|
|
120
|
+
export interface SessionBlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends BlockBroker<RetrieveProgressEvents, AnnounceProgressEvents> {
|
|
121
|
+
/**
|
|
122
|
+
* Adds a new peer to the session if they are supported and are either
|
|
123
|
+
* not already in the session and have not been evicted previously.
|
|
124
|
+
*/
|
|
125
|
+
addPeer(peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>;
|
|
110
126
|
}
|
|
111
127
|
export declare const DEFAULT_SESSION_MIN_PROVIDERS = 1;
|
|
112
128
|
export declare const DEFAULT_SESSION_MAX_PROVIDERS = 5;
|
package/dist/src/blocks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEr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AC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAEjG;;OAEG;IACH,QAAQ,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE1F;;OAEG;IACH,aAAa,CAAC,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,GAAG,kBAAkB,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,CAAA;CAC3I;AAED,MAAM,WAAW,kBAAkB,CAAC,sBAAsB,SAAS,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,sBAAsB,SAAS,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAE,SAAQ,WAAW,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IACzQ;;;OAGG;IACH,OAAO,CAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACxF;AAED,eAAO,MAAM,6BAA6B,IAAI,CAAA;AAC9C,eAAO,MAAM,6BAA6B,IAAI,CAAA"}
|
package/dist/src/blocks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAoLA,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAA"}
|
package/dist/typedoc-urls.json
CHANGED
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
"./routing:Routing": "https://ipfs.github.io/helia/interfaces/helia.Routing.html",
|
|
47
47
|
"RoutingOptions": "https://ipfs.github.io/helia/interfaces/_helia_http.RoutingOptions.html",
|
|
48
48
|
"./routing:RoutingOptions": "https://ipfs.github.io/helia/interfaces/helia.RoutingOptions.html",
|
|
49
|
+
"SessionBlockBroker": "https://ipfs.github.io/helia/interfaces/_helia_http.SessionBlockBroker.html",
|
|
50
|
+
"./blocks:SessionBlockBroker": "https://ipfs.github.io/helia/interfaces/helia.SessionBlockBroker.html",
|
|
49
51
|
"SessionBlockstore": "https://ipfs.github.io/helia/interfaces/_helia_http.SessionBlockstore.html",
|
|
50
52
|
"./blocks:SessionBlockstore": "https://ipfs.github.io/helia/interfaces/helia.SessionBlockstore.html",
|
|
51
53
|
"AddPinEvents": "https://ipfs.github.io/helia/types/_helia_http.AddPinEvents.html",
|
package/package.json
CHANGED
package/src/blocks.ts
CHANGED
|
@@ -97,6 +97,12 @@ ProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProg
|
|
|
97
97
|
* Any in-progress operations will be aborted.
|
|
98
98
|
*/
|
|
99
99
|
close(): void
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Adds a new peer to the session if they are supported and are either
|
|
103
|
+
* not already in the session and have not been evicted previously.
|
|
104
|
+
*/
|
|
105
|
+
addPeer (peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
export interface BlockRetrievalOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents>, ProviderOptions {
|
|
@@ -143,6 +149,11 @@ export interface CreateSessionOptions <ProgressEvents extends ProgressEvent<any,
|
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
export interface BlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> {
|
|
152
|
+
/**
|
|
153
|
+
* The name of the block broker, used for logging purposes
|
|
154
|
+
*/
|
|
155
|
+
name: string
|
|
156
|
+
|
|
146
157
|
/**
|
|
147
158
|
* Retrieve a block from a source
|
|
148
159
|
*/
|
|
@@ -156,7 +167,15 @@ export interface BlockBroker<RetrieveProgressEvents extends ProgressEvent<any, a
|
|
|
156
167
|
/**
|
|
157
168
|
* Create a new session
|
|
158
169
|
*/
|
|
159
|
-
createSession?(options?: CreateSessionOptions<RetrieveProgressEvents>):
|
|
170
|
+
createSession?(options?: CreateSessionOptions<RetrieveProgressEvents>): SessionBlockBroker<RetrieveProgressEvents, AnnounceProgressEvents>
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface SessionBlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends BlockBroker<RetrieveProgressEvents, AnnounceProgressEvents> {
|
|
174
|
+
/**
|
|
175
|
+
* Adds a new peer to the session if they are supported and are either
|
|
176
|
+
* not already in the session and have not been evicted previously.
|
|
177
|
+
*/
|
|
178
|
+
addPeer (peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>
|
|
160
179
|
}
|
|
161
180
|
|
|
162
181
|
export const DEFAULT_SESSION_MIN_PROVIDERS = 1
|