@helia/interface 4.0.1 → 4.1.0-329652a
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 +1 -1
- package/dist/src/blocks.d.ts +61 -9
- package/dist/src/blocks.d.ts.map +1 -1
- package/dist/src/blocks.js +4 -1
- package/dist/src/blocks.js.map +1 -1
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/package.json +2 -1
- package/src/blocks.ts +67 -9
- package/src/index.ts +7 -0
- package/dist/typedoc-urls.json +0 -59
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
|
|
2
|
+
"use strict";var HeliaInterface=(()=>{var t=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var e=(E,o)=>{for(var _ in o)t(E,_,{get:o[_],enumerable:!0})},p=(E,o,_,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let S of I(o))!O.call(E,S)&&S!==_&&t(E,S,{get:()=>o[S],enumerable:!(r=R(o,S))||r.enumerable});return E};var x=E=>p(t({},"__esModule",{value:!0}),E);var D={};e(D,{DEFAULT_SESSION_MAX_PROVIDERS:()=>T,DEFAULT_SESSION_MIN_PROVIDERS:()=>N,DEFAULT_SESSION_PROVIDER_QUERY_CONCURRENCY:()=>A,DEFAULT_SESSION_PROVIDER_QUERY_TIMEOUT:()=>c});var N=1,T=5,A=5,c=5e3;return x(D);})();
|
|
3
3
|
return HeliaInterface}));
|
package/dist/src/blocks.d.ts
CHANGED
|
@@ -16,13 +16,25 @@ 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
|
|
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
|
+
/**
|
|
27
|
+
* A session blockstore is a special blockstore that only pulls content from a
|
|
28
|
+
* subset of network peers which respond as having the block for the initial
|
|
29
|
+
* root CID.
|
|
30
|
+
*
|
|
31
|
+
* Any blocks written to the blockstore as part of the session will propagate
|
|
32
|
+
* to the blockstore the session was created from.
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
createSession(root: CID, options?: CreateSessionOptions<GetBlockProgressEvents>): Promise<Blockstore>;
|
|
24
36
|
}
|
|
25
|
-
export
|
|
37
|
+
export interface BlockRetrievalOptions<ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {
|
|
26
38
|
/**
|
|
27
39
|
* A function that blockBrokers should call prior to returning a block to ensure it can maintain control
|
|
28
40
|
* of the block request flow. e.g. TrustedGatewayBlockBroker will use this to ensure that the block
|
|
@@ -30,18 +42,58 @@ export type BlockRetrievalOptions<GetProgressOptions extends ProgressOptions = P
|
|
|
30
42
|
* and WILL consider the gateway that returned the invalid blocks completely unreliable.
|
|
31
43
|
*/
|
|
32
44
|
validateFn?(block: Uint8Array): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
export interface
|
|
45
|
+
}
|
|
46
|
+
export interface BlockAnnounceOptions<ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {
|
|
47
|
+
}
|
|
48
|
+
export interface CreateSessionOptions<ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {
|
|
35
49
|
/**
|
|
36
|
-
*
|
|
50
|
+
* The minimum number of providers for the root CID that are required for
|
|
51
|
+
* successful session creation.
|
|
52
|
+
*
|
|
53
|
+
* The session will become usable once this many providers have been
|
|
54
|
+
* discovered, up to `maxProviders` providers will continue to be added.
|
|
55
|
+
*
|
|
56
|
+
* @default 1
|
|
57
|
+
*/
|
|
58
|
+
minProviders?: number;
|
|
59
|
+
/**
|
|
60
|
+
* The maximum number of providers for the root CID to be added to a session.
|
|
61
|
+
*
|
|
62
|
+
* @default 5
|
|
63
|
+
*/
|
|
64
|
+
maxProviders?: number;
|
|
65
|
+
/**
|
|
66
|
+
* When searching for providers of the root CID, implementations can check
|
|
67
|
+
* that providers are still online and have the requested block. This setting
|
|
68
|
+
* controls how many peers to query at the same time.
|
|
69
|
+
*
|
|
70
|
+
* @default 5
|
|
71
|
+
*/
|
|
72
|
+
providerQueryConcurrency?: number;
|
|
73
|
+
/**
|
|
74
|
+
* How long each queried provider has to respond either that they have the
|
|
75
|
+
* root block or to send it to us.
|
|
76
|
+
*
|
|
77
|
+
* @default 5000
|
|
37
78
|
*/
|
|
38
|
-
|
|
79
|
+
providerQueryTimeout?: number;
|
|
39
80
|
}
|
|
40
|
-
export interface
|
|
81
|
+
export interface BlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> {
|
|
82
|
+
/**
|
|
83
|
+
* Retrieve a block from a source
|
|
84
|
+
*/
|
|
85
|
+
retrieve?(cid: CID, options?: BlockRetrievalOptions<RetrieveProgressEvents>): Promise<Uint8Array>;
|
|
41
86
|
/**
|
|
42
87
|
* Make a new block available to peers
|
|
43
88
|
*/
|
|
44
|
-
announce(cid: CID, block: Uint8Array, options?:
|
|
89
|
+
announce?(cid: CID, block: Uint8Array, options?: BlockAnnounceOptions<AnnounceProgressEvents>): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Create a new session
|
|
92
|
+
*/
|
|
93
|
+
createSession?(root: CID, options?: CreateSessionOptions<RetrieveProgressEvents>): Promise<BlockBroker<RetrieveProgressEvents, AnnounceProgressEvents>>;
|
|
45
94
|
}
|
|
46
|
-
export
|
|
95
|
+
export declare const DEFAULT_SESSION_MIN_PROVIDERS = 1;
|
|
96
|
+
export declare const DEFAULT_SESSION_MAX_PROVIDERS = 5;
|
|
97
|
+
export declare const DEFAULT_SESSION_PROVIDER_QUERY_CONCURRENCY = 5;
|
|
98
|
+
export declare const DEFAULT_SESSION_PROVIDER_QUERY_TIMEOUT = 5000;
|
|
47
99
|
//# sourceMappingURL=blocks.d.ts.map
|
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,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,GAA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RENCY = 5;
|
|
4
|
+
export const DEFAULT_SESSION_PROVIDER_QUERY_TIMEOUT = 5000;
|
|
2
5
|
//# sourceMappingURL=blocks.js.map
|
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":"AA0IA,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAC9C,MAAM,CAAC,MAAM,0CAA0C,GAAG,CAAC,CAAA;AAC3D,MAAM,CAAC,MAAM,sCAAsC,GAAG,IAAI,CAAA"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { Blocks } from './blocks.js';
|
|
|
17
17
|
import type { Pins } from './pins.js';
|
|
18
18
|
import type { Routing } from './routing.js';
|
|
19
19
|
import type { AbortOptions, ComponentLogger } from '@libp2p/interface';
|
|
20
|
+
import type { DNS } from '@multiformats/dns';
|
|
20
21
|
import type { Datastore } from 'interface-datastore';
|
|
21
22
|
import type { MultihashHasher } from 'multiformats';
|
|
22
23
|
import type { CID } from 'multiformats/cid';
|
|
@@ -57,6 +58,11 @@ export interface Helia {
|
|
|
57
58
|
* algorithm.
|
|
58
59
|
*/
|
|
59
60
|
hashers: Record<number, MultihashHasher>;
|
|
61
|
+
/**
|
|
62
|
+
* The DNS property can be used to perform lookups of various record types and
|
|
63
|
+
* will use a resolver appropriate to the current platform.
|
|
64
|
+
*/
|
|
65
|
+
dns: DNS;
|
|
60
66
|
/**
|
|
61
67
|
* Starts the Helia node
|
|
62
68
|
*/
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],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AAI,CAAA;IAEV;;OAEG;IACH,MAAM,EAAE,eAAe,CAAA;IAEvB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAA;IAEhB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAErC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAExC;;;OAGG;IACH,GAAG,EAAE,GAAG,CAAA;IAER;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtB;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAErB;;OAEG;IACH,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACvC;AAED,MAAM,MAAM,QAAQ,GAClB,aAAa,CAAC,kBAAkB,EAAE,GAAG,CAAC,GACtC,aAAa,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;AAExC,MAAM,WAAW,SAAU,SAAQ,YAAY,EAAE,eAAe,CAAC,QAAQ,CAAC;CAEzE;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;CACzD;AAED,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA"}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA8FH,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/interface",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0-329652a",
|
|
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",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@libp2p/interface": "^1.1.4",
|
|
74
|
+
"@multiformats/dns": "^1.0.1",
|
|
74
75
|
"interface-blockstore": "^5.2.10",
|
|
75
76
|
"interface-datastore": "^8.2.11",
|
|
76
77
|
"interface-store": "^5.1.8",
|
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
|
|
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
|
}
|
|
@@ -54,10 +56,19 @@ ProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEv
|
|
|
54
56
|
GetOfflineOptions & ProgressOptions<GetBlockProgressEvents>, GetOfflineOptions & ProgressOptions<GetManyBlocksProgressEvents>, ProgressOptions<GetAllBlocksProgressEvents>,
|
|
55
57
|
ProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>
|
|
56
58
|
> {
|
|
57
|
-
|
|
59
|
+
/**
|
|
60
|
+
* A session blockstore is a special blockstore that only pulls content from a
|
|
61
|
+
* subset of network peers which respond as having the block for the initial
|
|
62
|
+
* root CID.
|
|
63
|
+
*
|
|
64
|
+
* Any blocks written to the blockstore as part of the session will propagate
|
|
65
|
+
* to the blockstore the session was created from.
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
createSession(root: CID, options?: CreateSessionOptions<GetBlockProgressEvents>): Promise<Blockstore>
|
|
58
69
|
}
|
|
59
70
|
|
|
60
|
-
export
|
|
71
|
+
export interface BlockRetrievalOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {
|
|
61
72
|
/**
|
|
62
73
|
* A function that blockBrokers should call prior to returning a block to ensure it can maintain control
|
|
63
74
|
* of the block request flow. e.g. TrustedGatewayBlockBroker will use this to ensure that the block
|
|
@@ -67,18 +78,65 @@ export type BlockRetrievalOptions<GetProgressOptions extends ProgressOptions = P
|
|
|
67
78
|
validateFn?(block: Uint8Array): Promise<void>
|
|
68
79
|
}
|
|
69
80
|
|
|
70
|
-
export interface
|
|
81
|
+
export interface BlockAnnounceOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface CreateSessionOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {
|
|
71
86
|
/**
|
|
72
|
-
*
|
|
87
|
+
* The minimum number of providers for the root CID that are required for
|
|
88
|
+
* successful session creation.
|
|
89
|
+
*
|
|
90
|
+
* The session will become usable once this many providers have been
|
|
91
|
+
* discovered, up to `maxProviders` providers will continue to be added.
|
|
92
|
+
*
|
|
93
|
+
* @default 1
|
|
94
|
+
*/
|
|
95
|
+
minProviders?: number
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The maximum number of providers for the root CID to be added to a session.
|
|
99
|
+
*
|
|
100
|
+
* @default 5
|
|
73
101
|
*/
|
|
74
|
-
|
|
102
|
+
maxProviders?: number
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* When searching for providers of the root CID, implementations can check
|
|
106
|
+
* that providers are still online and have the requested block. This setting
|
|
107
|
+
* controls how many peers to query at the same time.
|
|
108
|
+
*
|
|
109
|
+
* @default 5
|
|
110
|
+
*/
|
|
111
|
+
providerQueryConcurrency?: number
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* How long each queried provider has to respond either that they have the
|
|
115
|
+
* root block or to send it to us.
|
|
116
|
+
*
|
|
117
|
+
* @default 5000
|
|
118
|
+
*/
|
|
119
|
+
providerQueryTimeout?: number
|
|
75
120
|
}
|
|
76
121
|
|
|
77
|
-
export interface
|
|
122
|
+
export interface BlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> {
|
|
123
|
+
/**
|
|
124
|
+
* Retrieve a block from a source
|
|
125
|
+
*/
|
|
126
|
+
retrieve?(cid: CID, options?: BlockRetrievalOptions<RetrieveProgressEvents>): Promise<Uint8Array>
|
|
127
|
+
|
|
78
128
|
/**
|
|
79
129
|
* Make a new block available to peers
|
|
80
130
|
*/
|
|
81
|
-
announce(cid: CID, block: Uint8Array, options?:
|
|
131
|
+
announce?(cid: CID, block: Uint8Array, options?: BlockAnnounceOptions<AnnounceProgressEvents>): Promise<void>
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Create a new session
|
|
135
|
+
*/
|
|
136
|
+
createSession?(root: CID, options?: CreateSessionOptions<RetrieveProgressEvents>): Promise<BlockBroker<RetrieveProgressEvents, AnnounceProgressEvents>>
|
|
82
137
|
}
|
|
83
138
|
|
|
84
|
-
export
|
|
139
|
+
export const DEFAULT_SESSION_MIN_PROVIDERS = 1
|
|
140
|
+
export const DEFAULT_SESSION_MAX_PROVIDERS = 5
|
|
141
|
+
export const DEFAULT_SESSION_PROVIDER_QUERY_CONCURRENCY = 5
|
|
142
|
+
export const DEFAULT_SESSION_PROVIDER_QUERY_TIMEOUT = 5000
|
package/src/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type { Blocks } from './blocks.js'
|
|
|
18
18
|
import type { Pins } from './pins.js'
|
|
19
19
|
import type { Routing } from './routing.js'
|
|
20
20
|
import type { AbortOptions, ComponentLogger } from '@libp2p/interface'
|
|
21
|
+
import type { DNS } from '@multiformats/dns'
|
|
21
22
|
import type { Datastore } from 'interface-datastore'
|
|
22
23
|
import type { MultihashHasher } from 'multiformats'
|
|
23
24
|
import type { CID } from 'multiformats/cid'
|
|
@@ -67,6 +68,12 @@ export interface Helia {
|
|
|
67
68
|
*/
|
|
68
69
|
hashers: Record<number, MultihashHasher>
|
|
69
70
|
|
|
71
|
+
/**
|
|
72
|
+
* The DNS property can be used to perform lookups of various record types and
|
|
73
|
+
* will use a resolver appropriate to the current platform.
|
|
74
|
+
*/
|
|
75
|
+
dns: DNS
|
|
76
|
+
|
|
70
77
|
/**
|
|
71
78
|
* Starts the Helia node
|
|
72
79
|
*/
|
package/dist/typedoc-urls.json
DELETED
|
@@ -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
|
-
}
|