@helia/interface 4.3.1 → 5.0.0-0238ed4
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/errors.d.ts +17 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +29 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.d.ts +20 -18
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/pins.d.ts +14 -5
- package/dist/src/pins.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/errors.ts +35 -0
- package/src/index.ts +24 -21
- package/src/pins.ts +16 -5
- package/dist/typedoc-urls.json +0 -65
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
|
|
2
|
+
"use strict";var HeliaInterface=(()=>{var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var u=(o,r)=>{for(var e in r)s(o,e,{get:r[e],enumerable:!0})},l=(o,r,e,p)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of x(r))!E.call(o,t)&&t!==e&&s(o,t,{get:()=>r[t],enumerable:!(p=m(r,t))||p.enumerable});return o};var d=o=>l(s({},"__esModule",{value:!0}),o);var f={};u(f,{DEFAULT_SESSION_MAX_PROVIDERS:()=>I,DEFAULT_SESSION_MIN_PROVIDERS:()=>S,InsufficientProvidersError:()=>n,NoRoutersAvailableError:()=>a,UnknownCodecError:()=>i,UnknownHashAlgorithmError:()=>c});var S=1,I=5;var n=class extends Error{static name="InsufficientProvidersError";constructor(r="Insufficient providers found"){super(r),this.name="InsufficientProvidersError"}},a=class extends Error{static name="NoRoutersAvailableError";constructor(r="No routers available"){super(r),this.name="NoRoutersAvailableError"}},c=class extends Error{static name="UnknownHashAlgorithmError";constructor(r="Unknown hash algorithm"){super(r),this.name="UnknownHashAlgorithmError"}},i=class extends Error{static name="UnknownCodecError";constructor(r="Unknown codec"){super(r),this.name="UnknownCodecError"}};return d(f);})();
|
|
3
3
|
return HeliaInterface}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class InsufficientProvidersError extends Error {
|
|
2
|
+
static name: string;
|
|
3
|
+
constructor(message?: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class NoRoutersAvailableError extends Error {
|
|
6
|
+
static name: string;
|
|
7
|
+
constructor(message?: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class UnknownHashAlgorithmError extends Error {
|
|
10
|
+
static name: string;
|
|
11
|
+
constructor(message?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class UnknownCodecError extends Error {
|
|
14
|
+
static name: string;
|
|
15
|
+
constructor(message?: string);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,MAAM,CAAC,IAAI,SAA+B;gBAE7B,OAAO,SAAiC;CAItD;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,MAAM,CAAC,IAAI,SAA4B;gBAE1B,OAAO,SAAyB;CAI9C;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,MAAM,CAAC,IAAI,SAA8B;gBAE5B,OAAO,SAA2B;CAIhD;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,SAAsB;gBAEpB,OAAO,SAAkB;CAIvC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class InsufficientProvidersError extends Error {
|
|
2
|
+
static name = 'InsufficientProvidersError';
|
|
3
|
+
constructor(message = 'Insufficient providers found') {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = 'InsufficientProvidersError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class NoRoutersAvailableError extends Error {
|
|
9
|
+
static name = 'NoRoutersAvailableError';
|
|
10
|
+
constructor(message = 'No routers available') {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'NoRoutersAvailableError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class UnknownHashAlgorithmError extends Error {
|
|
16
|
+
static name = 'UnknownHashAlgorithmError';
|
|
17
|
+
constructor(message = 'Unknown hash algorithm') {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = 'UnknownHashAlgorithmError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class UnknownCodecError extends Error {
|
|
23
|
+
static name = 'UnknownCodecError';
|
|
24
|
+
constructor(message = 'Unknown codec') {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = 'UnknownCodecError';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACnD,MAAM,CAAC,IAAI,GAAG,4BAA4B,CAAA;IAE1C,YAAa,OAAO,GAAG,8BAA8B;QACnD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAA;IAC1C,CAAC;;AAGH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,MAAM,CAAC,IAAI,GAAG,yBAAyB,CAAA;IAEvC,YAAa,OAAO,GAAG,sBAAsB;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;IACvC,CAAC;;AAGH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAClD,MAAM,CAAC,IAAI,GAAG,2BAA2B,CAAA;IAEzC,YAAa,OAAO,GAAG,wBAAwB;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;IACzC,CAAC;;AAGH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,GAAG,mBAAmB,CAAA;IAEjC,YAAa,OAAO,GAAG,eAAe;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -19,10 +19,17 @@ import type { Routing } from './routing.js';
|
|
|
19
19
|
import type { AbortOptions, ComponentLogger, Metrics } from '@libp2p/interface';
|
|
20
20
|
import type { DNS } from '@multiformats/dns';
|
|
21
21
|
import type { Datastore } from 'interface-datastore';
|
|
22
|
-
import type {
|
|
22
|
+
import type { Await } from 'interface-store';
|
|
23
|
+
import type { BlockCodec, MultihashHasher } from 'multiformats';
|
|
23
24
|
import type { CID } from 'multiformats/cid';
|
|
24
25
|
import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
25
26
|
export type { Await, AwaitIterable } from 'interface-store';
|
|
27
|
+
export interface CodecLoader {
|
|
28
|
+
<T = any, Code extends number = any>(code: Code): Await<BlockCodec<Code, T>>;
|
|
29
|
+
}
|
|
30
|
+
export interface HasherLoader {
|
|
31
|
+
(code: number): Await<MultihashHasher>;
|
|
32
|
+
}
|
|
26
33
|
/**
|
|
27
34
|
* The API presented by a Helia node
|
|
28
35
|
*/
|
|
@@ -48,16 +55,6 @@ export interface Helia {
|
|
|
48
55
|
* content providers, information about peers, etc.
|
|
49
56
|
*/
|
|
50
57
|
routing: Routing;
|
|
51
|
-
/**
|
|
52
|
-
* DAGWalkers are codec-specific implementations that know how to yield all
|
|
53
|
-
* CIDs contained within a block that corresponds to that codec.
|
|
54
|
-
*/
|
|
55
|
-
dagWalkers: Record<number, DAGWalker>;
|
|
56
|
-
/**
|
|
57
|
-
* Hashers can be used to hash a piece of data with the specified hashing
|
|
58
|
-
* algorithm.
|
|
59
|
-
*/
|
|
60
|
-
hashers: Record<number, MultihashHasher>;
|
|
61
58
|
/**
|
|
62
59
|
* The DNS property can be used to perform lookups of various record types and
|
|
63
60
|
* will use a resolver appropriate to the current platform.
|
|
@@ -80,18 +77,23 @@ export interface Helia {
|
|
|
80
77
|
* Remove any unpinned blocks from the blockstore
|
|
81
78
|
*/
|
|
82
79
|
gc(options?: GCOptions): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Load an IPLD codec. Implementations may return a promise if, for example,
|
|
82
|
+
* the codec is being fetched from the network.
|
|
83
|
+
*/
|
|
84
|
+
getCodec: CodecLoader;
|
|
85
|
+
/**
|
|
86
|
+
* Hashers can be used to hash a piece of data with the specified hashing
|
|
87
|
+
* algorithm. Implementations may return a promise if, for example,
|
|
88
|
+
* the hasher is being fetched from the network.
|
|
89
|
+
*/
|
|
90
|
+
getHasher: HasherLoader;
|
|
83
91
|
}
|
|
84
92
|
export type GcEvents = ProgressEvent<'helia:gc:deleted', CID> | ProgressEvent<'helia:gc:error', Error>;
|
|
85
93
|
export interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {
|
|
86
94
|
}
|
|
87
|
-
/**
|
|
88
|
-
* DAGWalkers take a block and yield CIDs encoded in that block
|
|
89
|
-
*/
|
|
90
|
-
export interface DAGWalker {
|
|
91
|
-
codec: number;
|
|
92
|
-
walk(block: Uint8Array): Generator<CID, void, undefined>;
|
|
93
|
-
}
|
|
94
95
|
export * from './blocks.js';
|
|
96
|
+
export * from './errors.js';
|
|
95
97
|
export * from './pins.js';
|
|
96
98
|
export * from './routing.js';
|
|
97
99
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC/E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC/E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAErE,YAA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;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA"}
|
package/dist/src/index.js
CHANGED
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;AAsGH,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA"}
|
package/dist/src/pins.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type PinType = 'recursive' | 'direct' | 'indirect';
|
|
|
6
6
|
export interface Pin {
|
|
7
7
|
cid: CID;
|
|
8
8
|
depth: number;
|
|
9
|
-
metadata: Record<string,
|
|
9
|
+
metadata: Record<string, string | number | boolean>;
|
|
10
10
|
}
|
|
11
11
|
export type AddPinEvents = ProgressEvent<'helia:pin:add', CID>;
|
|
12
12
|
export interface AddOptions extends AbortOptions, ProgressOptions<AddPinEvents | GetBlockProgressEvents> {
|
|
@@ -28,22 +28,31 @@ export interface IsPinnedOptions extends AbortOptions {
|
|
|
28
28
|
}
|
|
29
29
|
export interface Pins {
|
|
30
30
|
/**
|
|
31
|
-
* Pin a block in the blockstore. It will not be deleted
|
|
32
|
-
*
|
|
31
|
+
* Pin a block in the blockstore. It will not be deleted when garbage
|
|
32
|
+
* collection is run.
|
|
33
33
|
*/
|
|
34
34
|
add(cid: CID, options?: AddOptions): AsyncGenerator<CID, void, undefined>;
|
|
35
35
|
/**
|
|
36
|
-
* Unpin the block that corresponds to the passed CID. The block will
|
|
37
|
-
*
|
|
36
|
+
* Unpin the block that corresponds to the passed CID. The block will be
|
|
37
|
+
* deleted when garbage collection is run.
|
|
38
38
|
*/
|
|
39
39
|
rm(cid: CID, options?: RmOptions): AsyncGenerator<CID, void, undefined>;
|
|
40
40
|
/**
|
|
41
41
|
* List all blocks that have been pinned.
|
|
42
42
|
*/
|
|
43
43
|
ls(options?: LsOptions): AsyncGenerator<Pin, void, undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* If the CID is pinned, return details of the pin, otherwise throw an error
|
|
46
|
+
*/
|
|
47
|
+
get(cid: CID, options?: AbortOptions): Promise<Pin>;
|
|
44
48
|
/**
|
|
45
49
|
* Return true if the passed CID is pinned
|
|
46
50
|
*/
|
|
47
51
|
isPinned(cid: CID, options?: IsPinnedOptions): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* If the CID is pinned, update the metadata associated with the pin,
|
|
54
|
+
* otherwise throw an error
|
|
55
|
+
*/
|
|
56
|
+
setMetadata(cid: CID, metadata: Record<string, string | number | boolean> | undefined, options?: AbortOptions): Promise<void>;
|
|
48
57
|
}
|
|
49
58
|
//# sourceMappingURL=pins.d.ts.map
|
package/dist/src/pins.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pins.d.ts","sourceRoot":"","sources":["../../src/pins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAErE,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAA;AAEzD,MAAM,WAAW,GAAG;IAClB,GAAG,EAAE,GAAG,CAAA;IACR,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"pins.d.ts","sourceRoot":"","sources":["../../src/pins.ts"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,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;IAEvE;;OAEG;IACH,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;IAE7D;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;IAEnD;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAE/D;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9H"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/interface",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-0238ed4",
|
|
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",
|
|
@@ -67,14 +67,15 @@
|
|
|
67
67
|
"clean": "aegir clean",
|
|
68
68
|
"lint": "aegir lint",
|
|
69
69
|
"dep-check": "aegir dep-check",
|
|
70
|
+
"doc-check": "aegir doc-check",
|
|
70
71
|
"build": "aegir build"
|
|
71
72
|
},
|
|
72
73
|
"dependencies": {
|
|
73
|
-
"@libp2p/interface": "^
|
|
74
|
+
"@libp2p/interface": "^2.0.0",
|
|
74
75
|
"@multiformats/dns": "^1.0.1",
|
|
75
76
|
"interface-blockstore": "^5.2.10",
|
|
76
77
|
"interface-datastore": "^8.2.11",
|
|
77
|
-
"interface-store": "^
|
|
78
|
+
"interface-store": "^6.0.0",
|
|
78
79
|
"multiformats": "^13.1.0",
|
|
79
80
|
"progress-events": "^1.0.0"
|
|
80
81
|
},
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export class InsufficientProvidersError extends Error {
|
|
2
|
+
static name = 'InsufficientProvidersError'
|
|
3
|
+
|
|
4
|
+
constructor (message = 'Insufficient providers found') {
|
|
5
|
+
super(message)
|
|
6
|
+
this.name = 'InsufficientProvidersError'
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class NoRoutersAvailableError extends Error {
|
|
11
|
+
static name = 'NoRoutersAvailableError'
|
|
12
|
+
|
|
13
|
+
constructor (message = 'No routers available') {
|
|
14
|
+
super(message)
|
|
15
|
+
this.name = 'NoRoutersAvailableError'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class UnknownHashAlgorithmError extends Error {
|
|
20
|
+
static name = 'UnknownHashAlgorithmError'
|
|
21
|
+
|
|
22
|
+
constructor (message = 'Unknown hash algorithm') {
|
|
23
|
+
super(message)
|
|
24
|
+
this.name = 'UnknownHashAlgorithmError'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class UnknownCodecError extends Error {
|
|
29
|
+
static name = 'UnknownCodecError'
|
|
30
|
+
|
|
31
|
+
constructor (message = 'Unknown codec') {
|
|
32
|
+
super(message)
|
|
33
|
+
this.name = 'UnknownCodecError'
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -20,12 +20,21 @@ import type { Routing } from './routing.js'
|
|
|
20
20
|
import type { AbortOptions, ComponentLogger, Metrics } from '@libp2p/interface'
|
|
21
21
|
import type { DNS } from '@multiformats/dns'
|
|
22
22
|
import type { Datastore } from 'interface-datastore'
|
|
23
|
-
import type {
|
|
23
|
+
import type { Await } from 'interface-store'
|
|
24
|
+
import type { BlockCodec, MultihashHasher } from 'multiformats'
|
|
24
25
|
import type { CID } from 'multiformats/cid'
|
|
25
26
|
import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
26
27
|
|
|
27
28
|
export type { Await, AwaitIterable } from 'interface-store'
|
|
28
29
|
|
|
30
|
+
export interface CodecLoader {
|
|
31
|
+
<T = any, Code extends number = any>(code: Code): Await<BlockCodec<Code, T>>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface HasherLoader {
|
|
35
|
+
(code: number): Await<MultihashHasher>
|
|
36
|
+
}
|
|
37
|
+
|
|
29
38
|
/**
|
|
30
39
|
* The API presented by a Helia node
|
|
31
40
|
*/
|
|
@@ -56,18 +65,6 @@ export interface Helia {
|
|
|
56
65
|
*/
|
|
57
66
|
routing: Routing
|
|
58
67
|
|
|
59
|
-
/**
|
|
60
|
-
* DAGWalkers are codec-specific implementations that know how to yield all
|
|
61
|
-
* CIDs contained within a block that corresponds to that codec.
|
|
62
|
-
*/
|
|
63
|
-
dagWalkers: Record<number, DAGWalker>
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Hashers can be used to hash a piece of data with the specified hashing
|
|
67
|
-
* algorithm.
|
|
68
|
-
*/
|
|
69
|
-
hashers: Record<number, MultihashHasher>
|
|
70
|
-
|
|
71
68
|
/**
|
|
72
69
|
* The DNS property can be used to perform lookups of various record types and
|
|
73
70
|
* will use a resolver appropriate to the current platform.
|
|
@@ -94,6 +91,19 @@ export interface Helia {
|
|
|
94
91
|
* Remove any unpinned blocks from the blockstore
|
|
95
92
|
*/
|
|
96
93
|
gc(options?: GCOptions): Promise<void>
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Load an IPLD codec. Implementations may return a promise if, for example,
|
|
97
|
+
* the codec is being fetched from the network.
|
|
98
|
+
*/
|
|
99
|
+
getCodec: CodecLoader
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Hashers can be used to hash a piece of data with the specified hashing
|
|
103
|
+
* algorithm. Implementations may return a promise if, for example,
|
|
104
|
+
* the hasher is being fetched from the network.
|
|
105
|
+
*/
|
|
106
|
+
getHasher: HasherLoader
|
|
97
107
|
}
|
|
98
108
|
|
|
99
109
|
export type GcEvents =
|
|
@@ -104,14 +114,7 @@ export interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {
|
|
|
104
114
|
|
|
105
115
|
}
|
|
106
116
|
|
|
107
|
-
/**
|
|
108
|
-
* DAGWalkers take a block and yield CIDs encoded in that block
|
|
109
|
-
*/
|
|
110
|
-
export interface DAGWalker {
|
|
111
|
-
codec: number
|
|
112
|
-
walk(block: Uint8Array): Generator<CID, void, undefined>
|
|
113
|
-
}
|
|
114
|
-
|
|
115
117
|
export * from './blocks.js'
|
|
118
|
+
export * from './errors.js'
|
|
116
119
|
export * from './pins.js'
|
|
117
120
|
export * from './routing.js'
|
package/src/pins.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type PinType = 'recursive' | 'direct' | 'indirect'
|
|
|
8
8
|
export interface Pin {
|
|
9
9
|
cid: CID
|
|
10
10
|
depth: number
|
|
11
|
-
metadata: Record<string,
|
|
11
|
+
metadata: Record<string, string | number | boolean>
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export type AddPinEvents =
|
|
@@ -40,14 +40,14 @@ export interface IsPinnedOptions extends AbortOptions {
|
|
|
40
40
|
|
|
41
41
|
export interface Pins {
|
|
42
42
|
/**
|
|
43
|
-
* Pin a block in the blockstore. It will not be deleted
|
|
44
|
-
*
|
|
43
|
+
* Pin a block in the blockstore. It will not be deleted when garbage
|
|
44
|
+
* collection is run.
|
|
45
45
|
*/
|
|
46
46
|
add(cid: CID, options?: AddOptions): AsyncGenerator<CID, void, undefined>
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* Unpin the block that corresponds to the passed CID. The block will
|
|
50
|
-
*
|
|
49
|
+
* Unpin the block that corresponds to the passed CID. The block will be
|
|
50
|
+
* deleted when garbage collection is run.
|
|
51
51
|
*/
|
|
52
52
|
rm(cid: CID, options?: RmOptions): AsyncGenerator<CID, void, undefined>
|
|
53
53
|
|
|
@@ -56,8 +56,19 @@ export interface Pins {
|
|
|
56
56
|
*/
|
|
57
57
|
ls(options?: LsOptions): AsyncGenerator<Pin, void, undefined>
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* If the CID is pinned, return details of the pin, otherwise throw an error
|
|
61
|
+
*/
|
|
62
|
+
get(cid: CID, options?: AbortOptions): Promise<Pin>
|
|
63
|
+
|
|
59
64
|
/**
|
|
60
65
|
* Return true if the passed CID is pinned
|
|
61
66
|
*/
|
|
62
67
|
isPinned(cid: CID, options?: IsPinnedOptions): Promise<boolean>
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* If the CID is pinned, update the metadata associated with the pin,
|
|
71
|
+
* otherwise throw an error
|
|
72
|
+
*/
|
|
73
|
+
setMetadata(cid: CID, metadata: Record<string, string | number | boolean> | undefined, options?: AbortOptions): Promise<void>
|
|
63
74
|
}
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,65 +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
|
-
"BlockAnnounceOptions": "https://ipfs.github.io/helia/interfaces/helia.BlockAnnounceOptions.html",
|
|
5
|
-
"./blocks:BlockAnnounceOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.BlockAnnounceOptions.html",
|
|
6
|
-
"BlockBroker": "https://ipfs.github.io/helia/interfaces/helia.BlockBroker.html",
|
|
7
|
-
"./blocks:BlockBroker": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.BlockBroker.html",
|
|
8
|
-
"BlockRetrievalOptions": "https://ipfs.github.io/helia/interfaces/helia.BlockRetrievalOptions.html",
|
|
9
|
-
"./blocks:BlockRetrievalOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.BlockRetrievalOptions.html",
|
|
10
|
-
"Blocks": "https://ipfs.github.io/helia/interfaces/helia.Blocks.html",
|
|
11
|
-
"./blocks:Blocks": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.Blocks.html",
|
|
12
|
-
"CreateSessionOptions": "https://ipfs.github.io/helia/interfaces/helia.CreateSessionOptions.html",
|
|
13
|
-
"./blocks:CreateSessionOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.CreateSessionOptions.html",
|
|
14
|
-
"GCOptions": "https://ipfs.github.io/helia/interfaces/helia.GCOptions.html",
|
|
15
|
-
".:GCOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.index.GCOptions.html",
|
|
16
|
-
"GetOfflineOptions": "https://ipfs.github.io/helia/interfaces/helia.GetOfflineOptions.html",
|
|
17
|
-
"./blocks:GetOfflineOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.GetOfflineOptions.html",
|
|
18
|
-
"Helia": "https://ipfs.github.io/helia/interfaces/helia.Helia.html",
|
|
19
|
-
".:Helia": "https://ipfs.github.io/helia/interfaces/_helia_interface.index.Helia.html",
|
|
20
|
-
"IsPinnedOptions": "https://ipfs.github.io/helia/interfaces/helia.IsPinnedOptions.html",
|
|
21
|
-
"./pins:IsPinnedOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.IsPinnedOptions.html",
|
|
22
|
-
"LsOptions": "https://ipfs.github.io/helia/interfaces/helia.LsOptions.html",
|
|
23
|
-
"./pins:LsOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.LsOptions.html",
|
|
24
|
-
"Pair": "https://ipfs.github.io/helia/interfaces/helia.Pair.html",
|
|
25
|
-
"./blocks:Pair": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.Pair.html",
|
|
26
|
-
"Pin": "https://ipfs.github.io/helia/interfaces/helia.Pin.html",
|
|
27
|
-
"./pins:Pin": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.Pin.html",
|
|
28
|
-
"Pins": "https://ipfs.github.io/helia/interfaces/helia.Pins.html",
|
|
29
|
-
"./pins:Pins": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.Pins.html",
|
|
30
|
-
"Provider": "https://ipfs.github.io/helia/interfaces/helia.Provider.html",
|
|
31
|
-
"RmOptions": "https://ipfs.github.io/helia/interfaces/helia.RmOptions.html",
|
|
32
|
-
"./pins:RmOptions": "https://ipfs.github.io/helia/interfaces/_helia_interface.pins.RmOptions.html",
|
|
33
|
-
"Routing": "https://ipfs.github.io/helia/interfaces/helia.Routing.html",
|
|
34
|
-
"RoutingOptions": "https://ipfs.github.io/helia/interfaces/helia.RoutingOptions.html",
|
|
35
|
-
"SessionBlockstore": "https://ipfs.github.io/helia/interfaces/helia.SessionBlockstore.html",
|
|
36
|
-
"./blocks:SessionBlockstore": "https://ipfs.github.io/helia/interfaces/_helia_interface.blocks.SessionBlockstore.html",
|
|
37
|
-
"AddPinEvents": "https://ipfs.github.io/helia/types/helia.AddPinEvents.html",
|
|
38
|
-
"./pins:AddPinEvents": "https://ipfs.github.io/helia/types/_helia_interface.pins.AddPinEvents.html",
|
|
39
|
-
"DeleteBlockProgressEvents": "https://ipfs.github.io/helia/types/helia.DeleteBlockProgressEvents.html",
|
|
40
|
-
"./blocks:DeleteBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.DeleteBlockProgressEvents.html",
|
|
41
|
-
"DeleteManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/helia.DeleteManyBlocksProgressEvents.html",
|
|
42
|
-
"./blocks:DeleteManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.DeleteManyBlocksProgressEvents.html",
|
|
43
|
-
"GcEvents": "https://ipfs.github.io/helia/types/helia.GcEvents.html",
|
|
44
|
-
".:GcEvents": "https://ipfs.github.io/helia/types/_helia_interface.index.GcEvents.html",
|
|
45
|
-
"GetAllBlocksProgressEvents": "https://ipfs.github.io/helia/types/helia.GetAllBlocksProgressEvents.html",
|
|
46
|
-
"./blocks:GetAllBlocksProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.GetAllBlocksProgressEvents.html",
|
|
47
|
-
"GetBlockProgressEvents": "https://ipfs.github.io/helia/types/helia.GetBlockProgressEvents.html",
|
|
48
|
-
"./blocks:GetBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.GetBlockProgressEvents.html",
|
|
49
|
-
"GetManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/helia.GetManyBlocksProgressEvents.html",
|
|
50
|
-
"./blocks:GetManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.GetManyBlocksProgressEvents.html",
|
|
51
|
-
"HasBlockProgressEvents": "https://ipfs.github.io/helia/types/helia.HasBlockProgressEvents.html",
|
|
52
|
-
"./blocks:HasBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.HasBlockProgressEvents.html",
|
|
53
|
-
"PinType": "https://ipfs.github.io/helia/types/helia.PinType.html",
|
|
54
|
-
"./pins:PinType": "https://ipfs.github.io/helia/types/_helia_interface.pins.PinType.html",
|
|
55
|
-
"PutBlockProgressEvents": "https://ipfs.github.io/helia/types/helia.PutBlockProgressEvents.html",
|
|
56
|
-
"./blocks:PutBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.PutBlockProgressEvents.html",
|
|
57
|
-
"PutManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/helia.PutManyBlocksProgressEvents.html",
|
|
58
|
-
"./blocks:PutManyBlocksProgressEvents": "https://ipfs.github.io/helia/types/_helia_interface.blocks.PutManyBlocksProgressEvents.html",
|
|
59
|
-
"DEFAULT_SESSION_MAX_PROVIDERS": "https://ipfs.github.io/helia/variables/helia.DEFAULT_SESSION_MAX_PROVIDERS.html",
|
|
60
|
-
"./blocks:DEFAULT_SESSION_MAX_PROVIDERS": "https://ipfs.github.io/helia/variables/_helia_interface.blocks.DEFAULT_SESSION_MAX_PROVIDERS.html",
|
|
61
|
-
"DEFAULT_SESSION_MIN_PROVIDERS": "https://ipfs.github.io/helia/variables/helia.DEFAULT_SESSION_MIN_PROVIDERS.html",
|
|
62
|
-
"./blocks:DEFAULT_SESSION_MIN_PROVIDERS": "https://ipfs.github.io/helia/variables/_helia_interface.blocks.DEFAULT_SESSION_MIN_PROVIDERS.html",
|
|
63
|
-
"DAGWalker": "https://ipfs.github.io/helia/interfaces/_helia_http.DAGWalker.html",
|
|
64
|
-
".:DAGWalker": "https://ipfs.github.io/helia/interfaces/_helia_interface.index.DAGWalker.html"
|
|
65
|
-
}
|