@helia/interface 0.0.0-ab0a451 → 0.0.0-d15d76c
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/src/index.d.ts +12 -40
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/pins.d.ts +48 -0
- package/dist/src/pins.d.ts.map +1 -0
- package/dist/src/pins.js +2 -0
- package/dist/src/pins.js.map +1 -0
- package/package.json +7 -5
- package/src/index.ts +15 -44
- package/src/pins.ts +62 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -17,8 +17,10 @@ import type { Libp2p } from '@libp2p/interface-libp2p';
|
|
|
17
17
|
import type { Blockstore } from 'interface-blockstore';
|
|
18
18
|
import type { AbortOptions } from '@libp2p/interfaces';
|
|
19
19
|
import type { PeerId } from '@libp2p/interface-peer-id';
|
|
20
|
-
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
21
20
|
import type { Datastore } from 'interface-datastore';
|
|
21
|
+
import type { Pins } from './pins.js';
|
|
22
|
+
import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
23
|
+
import type { CID } from 'multiformats/cid';
|
|
22
24
|
/**
|
|
23
25
|
* The API presented by a Helia node.
|
|
24
26
|
*/
|
|
@@ -36,20 +38,9 @@ export interface Helia {
|
|
|
36
38
|
*/
|
|
37
39
|
datastore: Datastore;
|
|
38
40
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
*
|
|
43
|
-
* ```typescript
|
|
44
|
-
* import { createHelia } from 'helia'
|
|
45
|
-
*
|
|
46
|
-
* const node = await createHelia()
|
|
47
|
-
* const id = await node.info()
|
|
48
|
-
* console.info(id)
|
|
49
|
-
* // { peerId: PeerId(12D3Foo), ... }
|
|
50
|
-
* ```
|
|
41
|
+
* Pinning operations for blocks in the blockstore
|
|
51
42
|
*/
|
|
52
|
-
|
|
43
|
+
pins: Pins;
|
|
53
44
|
/**
|
|
54
45
|
* Starts the Helia node
|
|
55
46
|
*/
|
|
@@ -58,6 +49,13 @@ export interface Helia {
|
|
|
58
49
|
* Stops the Helia node
|
|
59
50
|
*/
|
|
60
51
|
stop: () => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Remove any unpinned blocks from the blockstore
|
|
54
|
+
*/
|
|
55
|
+
gc: (options?: GCOptions) => Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
export type GcEvents = ProgressEvent<'helia:gc:deleted', CID>;
|
|
58
|
+
export interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {
|
|
61
59
|
}
|
|
62
60
|
export interface InfoOptions extends AbortOptions {
|
|
63
61
|
/**
|
|
@@ -66,30 +64,4 @@ export interface InfoOptions extends AbortOptions {
|
|
|
66
64
|
*/
|
|
67
65
|
peerId?: PeerId;
|
|
68
66
|
}
|
|
69
|
-
export interface InfoResponse {
|
|
70
|
-
/**
|
|
71
|
-
* The ID of the peer this info is about
|
|
72
|
-
*/
|
|
73
|
-
peerId: PeerId;
|
|
74
|
-
/**
|
|
75
|
-
* The multiaddrs the peer is listening on
|
|
76
|
-
*/
|
|
77
|
-
multiaddrs: Multiaddr[];
|
|
78
|
-
/**
|
|
79
|
-
* The peer's reported agent version
|
|
80
|
-
*/
|
|
81
|
-
agentVersion: string;
|
|
82
|
-
/**
|
|
83
|
-
* The peer's reported protocol version
|
|
84
|
-
*/
|
|
85
|
-
protocolVersion: string;
|
|
86
|
-
/**
|
|
87
|
-
* The protocols the peer supports
|
|
88
|
-
*/
|
|
89
|
-
protocols: string[];
|
|
90
|
-
/**
|
|
91
|
-
* The status of the node
|
|
92
|
-
*/
|
|
93
|
-
status: 'running' | 'stopped';
|
|
94
|
-
}
|
|
95
67
|
//# 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;;;;;;;;;;;;;;GA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,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3C;AAED,MAAM,MAAM,QAAQ,GAClB,aAAa,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAA;AAExC,MAAM,WAAW,SAAU,SAAQ,YAAY,EAAE,eAAe,CAAC,QAAQ,CAAC;CAEzE;AAED,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AbortOptions } from '@libp2p/interfaces';
|
|
2
|
+
import type { CID } from 'multiformats/cid';
|
|
3
|
+
import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
4
|
+
export type PinType = 'recursive' | 'direct' | 'indirect';
|
|
5
|
+
export interface Pin {
|
|
6
|
+
cid: CID;
|
|
7
|
+
depth: number;
|
|
8
|
+
metadata: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
export type AddPinEvents = ProgressEvent<'helia:pin:add', unknown>;
|
|
11
|
+
export interface AddOptions extends AbortOptions, ProgressOptions<AddPinEvents> {
|
|
12
|
+
/**
|
|
13
|
+
* How deeply to pin the DAG, defaults to Infinity
|
|
14
|
+
*/
|
|
15
|
+
depth?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Optional user-defined metadata to store with the pin
|
|
18
|
+
*/
|
|
19
|
+
metadata?: Record<string, string | number | boolean>;
|
|
20
|
+
}
|
|
21
|
+
export interface RmOptions extends AbortOptions {
|
|
22
|
+
}
|
|
23
|
+
export interface LsOptions extends AbortOptions {
|
|
24
|
+
cid?: CID;
|
|
25
|
+
}
|
|
26
|
+
export interface IsPinnedOptions extends AbortOptions {
|
|
27
|
+
}
|
|
28
|
+
export interface Pins {
|
|
29
|
+
/**
|
|
30
|
+
* Pin a block in the blockstore. It will not be deleted
|
|
31
|
+
* when garbage collection is run.
|
|
32
|
+
*/
|
|
33
|
+
add: (cid: CID, options?: AddOptions) => Promise<Pin>;
|
|
34
|
+
/**
|
|
35
|
+
* Unpin the block that corresponds to the passed CID. The block will
|
|
36
|
+
* be deleted when garbage collection is run.
|
|
37
|
+
*/
|
|
38
|
+
rm: (cid: CID, options?: RmOptions) => Promise<Pin>;
|
|
39
|
+
/**
|
|
40
|
+
* List all blocks that have been pinned.
|
|
41
|
+
*/
|
|
42
|
+
ls: (options?: LsOptions) => AsyncGenerator<Pin, void, undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* Return true if the passed CID is pinned
|
|
45
|
+
*/
|
|
46
|
+
isPinned: (cid: CID, options?: IsPinnedOptions) => Promise<boolean>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=pins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pins.d.ts","sourceRoot":"","sources":["../../src/pins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,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;CAC9B;AAED,MAAM,MAAM,YAAY,GACtB,aAAa,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;AAEzC,MAAM,WAAW,UAAW,SAAQ,YAAY,EAAE,eAAe,CAAC,YAAY,CAAC;IAC7E;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;CACrD;AAED,MAAM,WAAW,SAAU,SAAQ,YAAY;CAE9C;AAED,MAAM,WAAW,SAAU,SAAQ,YAAY;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAA;CACV;AAED,MAAM,WAAW,eAAgB,SAAQ,YAAY;CAEpD;AAED,MAAM,WAAW,IAAI;IACnB;;;OAGG;IACH,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,UAAU,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAErD;;;OAGG;IACH,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAEnD;;OAEG;IACH,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,KAAK,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;IAEjE;;OAEG;IACH,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CACpE"}
|
package/dist/src/pins.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pins.js","sourceRoot":"","sources":["../../src/pins.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/interface",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-d15d76c",
|
|
4
4
|
"description": "The Helia API",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/master/packages/interface#readme",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"types": "./dist/src/index.d.ts",
|
|
48
48
|
"import": "./dist/src/index.js"
|
|
49
49
|
},
|
|
50
|
-
"./
|
|
51
|
-
"types": "./dist/src/
|
|
52
|
-
"import": "./dist/src/
|
|
50
|
+
"./pins": {
|
|
51
|
+
"types": "./dist/src/pins.d.ts",
|
|
52
|
+
"import": "./dist/src/pins.js"
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"eslintConfig": {
|
|
@@ -156,7 +156,9 @@
|
|
|
156
156
|
"@libp2p/interfaces": "^3.3.1",
|
|
157
157
|
"@multiformats/multiaddr": "^11.1.5",
|
|
158
158
|
"interface-blockstore": "^4.0.1",
|
|
159
|
-
"interface-datastore": "^7.0.3"
|
|
159
|
+
"interface-datastore": "^7.0.3",
|
|
160
|
+
"multiformats": "^11.0.1",
|
|
161
|
+
"progress-events": "^1.0.0"
|
|
160
162
|
},
|
|
161
163
|
"devDependencies": {
|
|
162
164
|
"aegir": "^38.1.0"
|
package/src/index.ts
CHANGED
|
@@ -18,8 +18,10 @@ import type { Libp2p } from '@libp2p/interface-libp2p'
|
|
|
18
18
|
import type { Blockstore } from 'interface-blockstore'
|
|
19
19
|
import type { AbortOptions } from '@libp2p/interfaces'
|
|
20
20
|
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
21
|
-
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
22
21
|
import type { Datastore } from 'interface-datastore'
|
|
22
|
+
import type { Pins } from './pins.js'
|
|
23
|
+
import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
24
|
+
import type { CID } from 'multiformats/cid'
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* The API presented by a Helia node.
|
|
@@ -41,20 +43,9 @@ export interface Helia {
|
|
|
41
43
|
datastore: Datastore
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
*
|
|
48
|
-
* ```typescript
|
|
49
|
-
* import { createHelia } from 'helia'
|
|
50
|
-
*
|
|
51
|
-
* const node = await createHelia()
|
|
52
|
-
* const id = await node.info()
|
|
53
|
-
* console.info(id)
|
|
54
|
-
* // { peerId: PeerId(12D3Foo), ... }
|
|
55
|
-
* ```
|
|
46
|
+
* Pinning operations for blocks in the blockstore
|
|
56
47
|
*/
|
|
57
|
-
|
|
48
|
+
pins: Pins
|
|
58
49
|
|
|
59
50
|
/**
|
|
60
51
|
* Starts the Helia node
|
|
@@ -65,44 +56,24 @@ export interface Helia {
|
|
|
65
56
|
* Stops the Helia node
|
|
66
57
|
*/
|
|
67
58
|
stop: () => Promise<void>
|
|
68
|
-
}
|
|
69
59
|
|
|
70
|
-
export interface InfoOptions extends AbortOptions {
|
|
71
60
|
/**
|
|
72
|
-
*
|
|
73
|
-
* to the ID of the current node.
|
|
61
|
+
* Remove any unpinned blocks from the blockstore
|
|
74
62
|
*/
|
|
75
|
-
|
|
63
|
+
gc: (options?: GCOptions) => Promise<void>
|
|
76
64
|
}
|
|
77
65
|
|
|
78
|
-
export
|
|
79
|
-
|
|
80
|
-
* The ID of the peer this info is about
|
|
81
|
-
*/
|
|
82
|
-
peerId: PeerId
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* The multiaddrs the peer is listening on
|
|
86
|
-
*/
|
|
87
|
-
multiaddrs: Multiaddr[]
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The peer's reported agent version
|
|
91
|
-
*/
|
|
92
|
-
agentVersion: string
|
|
66
|
+
export type GcEvents =
|
|
67
|
+
ProgressEvent<'helia:gc:deleted', CID>
|
|
93
68
|
|
|
94
|
-
|
|
95
|
-
* The peer's reported protocol version
|
|
96
|
-
*/
|
|
97
|
-
protocolVersion: string
|
|
69
|
+
export interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {
|
|
98
70
|
|
|
99
|
-
|
|
100
|
-
* The protocols the peer supports
|
|
101
|
-
*/
|
|
102
|
-
protocols: string[]
|
|
71
|
+
}
|
|
103
72
|
|
|
73
|
+
export interface InfoOptions extends AbortOptions {
|
|
104
74
|
/**
|
|
105
|
-
*
|
|
75
|
+
* If passed, return information about this PeerId, defaults
|
|
76
|
+
* to the ID of the current node.
|
|
106
77
|
*/
|
|
107
|
-
|
|
78
|
+
peerId?: PeerId
|
|
108
79
|
}
|
package/src/pins.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { AbortOptions } from '@libp2p/interfaces'
|
|
2
|
+
import type { CID } from 'multiformats/cid'
|
|
3
|
+
import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
4
|
+
|
|
5
|
+
export type PinType = 'recursive' | 'direct' | 'indirect'
|
|
6
|
+
|
|
7
|
+
export interface Pin {
|
|
8
|
+
cid: CID
|
|
9
|
+
depth: number
|
|
10
|
+
metadata: Record<string, any>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type AddPinEvents =
|
|
14
|
+
ProgressEvent<'helia:pin:add', unknown>
|
|
15
|
+
|
|
16
|
+
export interface AddOptions extends AbortOptions, ProgressOptions<AddPinEvents> {
|
|
17
|
+
/**
|
|
18
|
+
* How deeply to pin the DAG, defaults to Infinity
|
|
19
|
+
*/
|
|
20
|
+
depth?: number
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Optional user-defined metadata to store with the pin
|
|
24
|
+
*/
|
|
25
|
+
metadata?: Record<string, string | number | boolean>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface RmOptions extends AbortOptions {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface LsOptions extends AbortOptions {
|
|
33
|
+
cid?: CID
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface IsPinnedOptions extends AbortOptions {
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface Pins {
|
|
41
|
+
/**
|
|
42
|
+
* Pin a block in the blockstore. It will not be deleted
|
|
43
|
+
* when garbage collection is run.
|
|
44
|
+
*/
|
|
45
|
+
add: (cid: CID, options?: AddOptions) => Promise<Pin>
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Unpin the block that corresponds to the passed CID. The block will
|
|
49
|
+
* be deleted when garbage collection is run.
|
|
50
|
+
*/
|
|
51
|
+
rm: (cid: CID, options?: RmOptions) => Promise<Pin>
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* List all blocks that have been pinned.
|
|
55
|
+
*/
|
|
56
|
+
ls: (options?: LsOptions) => AsyncGenerator<Pin, void, undefined>
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Return true if the passed CID is pinned
|
|
60
|
+
*/
|
|
61
|
+
isPinned: (cid: CID, options?: IsPinnedOptions) => Promise<boolean>
|
|
62
|
+
}
|