@helia/interface 4.1.0 → 4.2.0-0ecb529

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 CHANGED
@@ -1,3 +1,3 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaInterface = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaInterface=(()=>{var t=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,o,x,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of m(o))!a.call(r,e)&&e!==x&&t(r,e,{get:()=>o[e],enumerable:!(p=f(o,e))||p.enumerable});return r};var c=r=>b(t({},"__esModule",{value:!0}),r);var d={};return c(d);})();
2
+ "use strict";var HeliaInterface=(()=>{var E=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var I=(r,o)=>{for(var t in o)E(r,t,{get:o[t],enumerable:!0})},D=(r,o,t,_)=>{if(o&&typeof o=="object"||typeof o=="function")for(let S of p(o))!x.call(r,S)&&S!==t&&E(r,S,{get:()=>o[S],enumerable:!(_=e(o,S))||_.enumerable});return r};var O=r=>D(E({},"__esModule",{value:!0}),r);var R={};I(R,{DEFAULT_SESSION_MAX_PROVIDERS:()=>A,DEFAULT_SESSION_MIN_PROVIDERS:()=>m});var m=1,A=5;return O(R);})();
3
3
  return HeliaInterface}));
@@ -16,13 +16,31 @@ export type DeleteBlockProgressEvents = ProgressEvent<'blocks:delete:blockstore:
16
16
  export type DeleteManyBlocksProgressEvents = ProgressEvent<'blocks:delete-many:blockstore:delete-many'>;
17
17
  export interface GetOfflineOptions {
18
18
  /**
19
- * If true, do not attempt to fetch any missing blocks from the network (default: false)
19
+ * If true, do not attempt to fetch any missing blocks from the network
20
+ *
21
+ * @default false
20
22
  */
21
23
  offline?: boolean;
22
24
  }
23
25
  export interface Blocks extends Blockstore<ProgressOptions<HasBlockProgressEvents>, ProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>, GetOfflineOptions & ProgressOptions<GetBlockProgressEvents>, GetOfflineOptions & ProgressOptions<GetManyBlocksProgressEvents>, ProgressOptions<GetAllBlocksProgressEvents>, ProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>> {
26
+ createSession(root: CID, options?: CreateSessionOptions<GetBlockProgressEvents>): SessionBlockstore;
24
27
  }
25
- export type BlockRetrievalOptions<GetProgressOptions extends ProgressOptions = ProgressOptions> = AbortOptions & GetProgressOptions & {
28
+ /**
29
+ * A session blockstore is a special blockstore that only pulls content from a
30
+ * subset of network peers which respond as having the block for the initial
31
+ * root CID.
32
+ *
33
+ * Any blocks written to the blockstore as part of the session will propagate
34
+ * to the blockstore the session was created from.
35
+ *
36
+ */
37
+ export interface SessionBlockstore extends Blockstore<ProgressOptions<HasBlockProgressEvents>, ProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>, GetOfflineOptions & ProgressOptions<GetBlockProgressEvents>, GetOfflineOptions & ProgressOptions<GetManyBlocksProgressEvents>, ProgressOptions<GetAllBlocksProgressEvents>, ProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>> {
38
+ /**
39
+ * Any in-progress operations will be aborted.
40
+ */
41
+ close(): void;
42
+ }
43
+ export interface BlockRetrievalOptions<ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {
26
44
  /**
27
45
  * A function that blockBrokers should call prior to returning a block to ensure it can maintain control
28
46
  * of the block request flow. e.g. TrustedGatewayBlockBroker will use this to ensure that the block
@@ -30,18 +48,41 @@ export type BlockRetrievalOptions<GetProgressOptions extends ProgressOptions = P
30
48
  * and WILL consider the gateway that returned the invalid blocks completely unreliable.
31
49
  */
32
50
  validateFn?(block: Uint8Array): Promise<void>;
33
- };
34
- export interface BlockRetriever<GetProgressOptions extends ProgressOptions = ProgressOptions> {
51
+ }
52
+ export interface BlockAnnounceOptions<ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {
53
+ }
54
+ export interface CreateSessionOptions<ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {
35
55
  /**
36
- * Retrieve a block from a source
56
+ * The minimum number of providers for the root CID that are required for
57
+ * successful session creation.
58
+ *
59
+ * The session will become usable once this many providers have been
60
+ * discovered, up to `maxProviders` providers will continue to be added.
61
+ *
62
+ * @default 1
37
63
  */
38
- retrieve(cid: CID, options?: BlockRetrievalOptions<GetProgressOptions>): Promise<Uint8Array>;
64
+ minProviders?: number;
65
+ /**
66
+ * The maximum number of providers for the root CID to be added to a session.
67
+ *
68
+ * @default 5
69
+ */
70
+ maxProviders?: number;
39
71
  }
40
- export interface BlockAnnouncer<NotifyProgressOptions extends ProgressOptions = ProgressOptions> {
72
+ export interface BlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> {
73
+ /**
74
+ * Retrieve a block from a source
75
+ */
76
+ retrieve?(cid: CID, options?: BlockRetrievalOptions<RetrieveProgressEvents>): Promise<Uint8Array>;
41
77
  /**
42
78
  * Make a new block available to peers
43
79
  */
44
- announce(cid: CID, block: Uint8Array, options?: NotifyProgressOptions): void;
80
+ announce?(cid: CID, block: Uint8Array, options?: BlockAnnounceOptions<AnnounceProgressEvents>): Promise<void>;
81
+ /**
82
+ * Create a new session
83
+ */
84
+ createSession?(options?: CreateSessionOptions<RetrieveProgressEvents>): BlockBroker<RetrieveProgressEvents, AnnounceProgressEvents>;
45
85
  }
46
- export type BlockBroker = BlockRetriever | BlockAnnouncer;
86
+ export declare const DEFAULT_SESSION_MIN_PROVIDERS = 1;
87
+ export declare const DEFAULT_SESSION_MAX_PROVIDERS = 5;
47
88
  //# sourceMappingURL=blocks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAAA,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;AAErE,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,GAAG,CAAA;IACR,KAAK,EAAE,UAAU,CAAA;CAClB;AAED,MAAM,MAAM,sBAAsB,GAChC,aAAa,CAAC,sBAAsB,EAAE,GAAG,CAAC,GAC1C,aAAa,CAAC,6BAA6B,EAAE,GAAG,CAAC,GACjD,aAAa,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAA;AAEjD,MAAM,MAAM,sBAAsB,GAChC,aAAa,CAAC,sBAAsB,EAAE,GAAG,CAAC,GAC1C,aAAa,CAAC,6BAA6B,EAAE,GAAG,CAAC,GACjD,aAAa,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAA;AAEjD,MAAM,MAAM,2BAA2B,GACrC,aAAa,CAAC,2BAA2B,EAAE,GAAG,CAAC,GAC/C,aAAa,CAAC,kCAAkC,EAAE,GAAG,CAAC,GACtD,aAAa,CAAC,qCAAqC,CAAC,CAAA;AAEtD,MAAM,MAAM,sBAAsB,GAChC,aAAa,CAAC,2BAA2B,EAAE,GAAG,CAAC,GAC/C,aAAa,CAAC,2BAA2B,EAAE,GAAG,CAAC,GAC/C,aAAa,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAA;AAEjD,MAAM,MAAM,2BAA2B,GACrC,aAAa,CAAC,qCAAqC,CAAC,GACp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AO,CAAC,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE7G;;OAEG;IACH,aAAa,CAAC,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,GAAG,WAAW,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,CAAA;CACpI;AAED,eAAO,MAAM,6BAA6B,IAAI,CAAA;AAC9C,eAAO,MAAM,6BAA6B,IAAI,CAAA"}
@@ -1,2 +1,3 @@
1
- export {};
1
+ export const DEFAULT_SESSION_MIN_PROVIDERS = 1;
2
+ export const DEFAULT_SESSION_MAX_PROVIDERS = 5;
2
3
  //# sourceMappingURL=blocks.js.map
@@ -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":"AAqIA,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/interface",
3
- "version": "4.1.0",
3
+ "version": "4.2.0-0ecb529",
4
4
  "description": "The Helia API",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/ipfs/helia/tree/main/packages/interface#readme",
@@ -80,5 +80,6 @@
80
80
  },
81
81
  "devDependencies": {
82
82
  "aegir": "^42.2.5"
83
- }
83
+ },
84
+ "sideEffects": false
84
85
  }
package/src/blocks.ts CHANGED
@@ -44,7 +44,9 @@ export type DeleteManyBlocksProgressEvents =
44
44
 
45
45
  export interface GetOfflineOptions {
46
46
  /**
47
- * If true, do not attempt to fetch any missing blocks from the network (default: false)
47
+ * If true, do not attempt to fetch any missing blocks from the network
48
+ *
49
+ * @default false
48
50
  */
49
51
  offline?: boolean
50
52
  }
@@ -55,9 +57,30 @@ GetOfflineOptions & ProgressOptions<GetBlockProgressEvents>, GetOfflineOptions &
55
57
  ProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>
56
58
  > {
57
59
 
60
+ createSession(root: CID, options?: CreateSessionOptions<GetBlockProgressEvents>): SessionBlockstore
58
61
  }
59
62
 
60
- export type BlockRetrievalOptions<GetProgressOptions extends ProgressOptions = ProgressOptions> = AbortOptions & GetProgressOptions & {
63
+ /**
64
+ * A session blockstore is a special blockstore that only pulls content from a
65
+ * subset of network peers which respond as having the block for the initial
66
+ * root CID.
67
+ *
68
+ * Any blocks written to the blockstore as part of the session will propagate
69
+ * to the blockstore the session was created from.
70
+ *
71
+ */
72
+ export interface SessionBlockstore extends Blockstore<ProgressOptions<HasBlockProgressEvents>,
73
+ ProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>,
74
+ GetOfflineOptions & ProgressOptions<GetBlockProgressEvents>, GetOfflineOptions & ProgressOptions<GetManyBlocksProgressEvents>, ProgressOptions<GetAllBlocksProgressEvents>,
75
+ ProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>
76
+ > {
77
+ /**
78
+ * Any in-progress operations will be aborted.
79
+ */
80
+ close(): void
81
+ }
82
+
83
+ export interface BlockRetrievalOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {
61
84
  /**
62
85
  * A function that blockBrokers should call prior to returning a block to ensure it can maintain control
63
86
  * of the block request flow. e.g. TrustedGatewayBlockBroker will use this to ensure that the block
@@ -67,18 +90,46 @@ export type BlockRetrievalOptions<GetProgressOptions extends ProgressOptions = P
67
90
  validateFn?(block: Uint8Array): Promise<void>
68
91
  }
69
92
 
70
- export interface BlockRetriever<GetProgressOptions extends ProgressOptions = ProgressOptions> {
93
+ export interface BlockAnnounceOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {
94
+
95
+ }
96
+
97
+ export interface CreateSessionOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {
71
98
  /**
72
- * Retrieve a block from a source
99
+ * The minimum number of providers for the root CID that are required for
100
+ * successful session creation.
101
+ *
102
+ * The session will become usable once this many providers have been
103
+ * discovered, up to `maxProviders` providers will continue to be added.
104
+ *
105
+ * @default 1
106
+ */
107
+ minProviders?: number
108
+
109
+ /**
110
+ * The maximum number of providers for the root CID to be added to a session.
111
+ *
112
+ * @default 5
73
113
  */
74
- retrieve(cid: CID, options?: BlockRetrievalOptions<GetProgressOptions>): Promise<Uint8Array>
114
+ maxProviders?: number
75
115
  }
76
116
 
77
- export interface BlockAnnouncer<NotifyProgressOptions extends ProgressOptions = ProgressOptions> {
117
+ export interface BlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> {
118
+ /**
119
+ * Retrieve a block from a source
120
+ */
121
+ retrieve?(cid: CID, options?: BlockRetrievalOptions<RetrieveProgressEvents>): Promise<Uint8Array>
122
+
78
123
  /**
79
124
  * Make a new block available to peers
80
125
  */
81
- announce(cid: CID, block: Uint8Array, options?: NotifyProgressOptions): void
126
+ announce?(cid: CID, block: Uint8Array, options?: BlockAnnounceOptions<AnnounceProgressEvents>): Promise<void>
127
+
128
+ /**
129
+ * Create a new session
130
+ */
131
+ createSession?(options?: CreateSessionOptions<RetrieveProgressEvents>): BlockBroker<RetrieveProgressEvents, AnnounceProgressEvents>
82
132
  }
83
133
 
84
- export type BlockBroker = BlockRetriever | BlockAnnouncer
134
+ export const DEFAULT_SESSION_MIN_PROVIDERS = 1
135
+ export const DEFAULT_SESSION_MAX_PROVIDERS = 5
@@ -1,59 +0,0 @@
1
- {
2
- "AddOptions": "https://ipfs.github.io/helia/interfaces/helia.AddOptions.html",
3
- "./pins:AddOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.AddOptions.html",
4
- "BlockAnnouncer": "https://ipfs.github.io/helia/interfaces/helia.BlockAnnouncer.html",
5
- "./blocks:BlockAnnouncer": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.BlockAnnouncer.html",
6
- "BlockRetriever": "https://ipfs.github.io/helia/interfaces/helia.BlockRetriever.html",
7
- "./blocks:BlockRetriever": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.BlockRetriever.html",
8
- "Blocks": "https://ipfs.github.io/helia/interfaces/helia.Blocks.html",
9
- "./blocks:Blocks": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.Blocks.html",
10
- "GCOptions": "https://ipfs.github.io/helia/interfaces/helia.GCOptions.html",
11
- ".:GCOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.index.GCOptions.html",
12
- "GetOfflineOptions": "https://ipfs.github.io/helia/interfaces/helia.GetOfflineOptions.html",
13
- "./blocks:GetOfflineOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.GetOfflineOptions.html",
14
- "Helia": "https://ipfs.github.io/helia/interfaces/helia.Helia.html",
15
- ".:Helia": "https://ipfs.github.io/helia/interfaces/_helia_interface.index.Helia.html",
16
- "IsPinnedOptions": "https://ipfs.github.io/helia/interfaces/helia.IsPinnedOptions.html",
17
- "./pins:IsPinnedOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.IsPinnedOptions.html",
18
- "LsOptions": "https://ipfs.github.io/helia/interfaces/helia.LsOptions.html",
19
- "./pins:LsOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.LsOptions.html",
20
- "Pair": "https://ipfs.github.io/helia/interfaces/helia.Pair.html",
21
- "./blocks:Pair": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.Pair.html",
22
- "Pin": "https://ipfs.github.io/helia/interfaces/helia.Pin.html",
23
- "./pins:Pin": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.Pin.html",
24
- "Pins": "https://ipfs.github.io/helia/interfaces/helia.Pins.html",
25
- "./pins:Pins": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.Pins.html",
26
- "Provider": "https://ipfs.github.io/helia/interfaces/helia.Provider.html",
27
- "RmOptions": "https://ipfs.github.io/helia/interfaces/helia.RmOptions.html",
28
- "./pins:RmOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.RmOptions.html",
29
- "Routing": "https://ipfs.github.io/helia/interfaces/helia.Routing.html",
30
- "RoutingOptions": "https://ipfs.github.io/helia/interfaces/helia.RoutingOptions.html",
31
- "AddPinEvents": "https://ipfs.github.io/helia/types/helia.AddPinEvents.html",
32
- "./pins:AddPinEvents": "https://ipfs.github.io/helia/types/_helia_interface.pins.AddPinEvents.html",
33
- "BlockBroker": "https://ipfs.github.io/helia/types/helia.BlockBroker.html",
34
- "./blocks:BlockBroker": "https://ipfs.github.io/helia/types/_helia_interface.blocks.BlockBroker.html",
35
- "BlockRetrievalOptions": "https://ipfs.github.io/helia/types/helia.BlockRetrievalOptions.html",
36
- "./blocks:BlockRetrievalOptions": "https://ipfs.github.io/helia/types/_helia_interface.blocks.BlockRetrievalOptions.html",
37
- "DeleteBlockProgressEvents": "https://ipfs.github.io/helia/types/helia.DeleteBlockProgressEvents.html",
38
- "./blocks:DeleteBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.DeleteBlockProgressEvents.html",
39
- "DeleteManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/helia.DeleteManyBlocksProgressEvents.html",
40
- "./blocks:DeleteManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.DeleteManyBlocksProgressEvents.html",
41
- "GcEvents": "https://ipfs.github.io/helia/types/helia.GcEvents.html",
42
- ".:GcEvents": "https://ipfs.github.io/helia/types/_helia_interface.index.GcEvents.html",
43
- "GetAllBlocksProgressEvents": "https://ipfs.github.io/helia/types/helia.GetAllBlocksProgressEvents.html",
44
- "./blocks:GetAllBlocksProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.GetAllBlocksProgressEvents.html",
45
- "GetBlockProgressEvents": "https://ipfs.github.io/helia/types/helia.GetBlockProgressEvents.html",
46
- "./blocks:GetBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.GetBlockProgressEvents.html",
47
- "GetManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/helia.GetManyBlocksProgressEvents.html",
48
- "./blocks:GetManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.GetManyBlocksProgressEvents.html",
49
- "HasBlockProgressEvents": "https://ipfs.github.io/helia/types/helia.HasBlockProgressEvents.html",
50
- "./blocks:HasBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.HasBlockProgressEvents.html",
51
- "PinType": "https://ipfs.github.io/helia/types/helia.PinType.html",
52
- "./pins:PinType": "https://ipfs.github.io/helia/types/_helia_interface.pins.PinType.html",
53
- "PutBlockProgressEvents": "https://ipfs.github.io/helia/types/helia.PutBlockProgressEvents.html",
54
- "./blocks:PutBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.PutBlockProgressEvents.html",
55
- "PutManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/helia.PutManyBlocksProgressEvents.html",
56
- "./blocks:PutManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.PutManyBlocksProgressEvents.html",
57
- "DAGWalker": "https://ipfs.github.io/helia/interfaces/_helia_http.DAGWalker.html",
58
- ".:DAGWalker": "https://ipfs.github.io/helia/interfaces/_helia_interface.index.DAGWalker.html"
59
- }