@helia/interface 0.0.0-031ca73 → 0.0.0-202b966

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.
@@ -0,0 +1,117 @@
1
+ import type { AbortOptions } from '@libp2p/interfaces';
2
+ import type { ProgressEvent, ProgressOptions } from 'progress-events';
3
+ import type { CID } from 'multiformats/cid';
4
+ import type { BitswapNotifyProgressEvents, BitswapWantProgressEvents } from 'ipfs-bitswap';
5
+ import type { AwaitIterable } from './index.js';
6
+ export interface Pair {
7
+ cid: CID;
8
+ block: Uint8Array;
9
+ }
10
+ export type PutBlockProgressEvents = ProgressEvent<'blocks:put:duplicate', CID> | ProgressEvent<'blocks:put:bitswap:notify', CID> | ProgressEvent<'blocks:put:blockstore:put', CID> | BitswapNotifyProgressEvents;
11
+ export type PutManyBlocksProgressEvents = ProgressEvent<'blocks:put-many:duplicate', CID> | ProgressEvent<'blocks:put-many:bitswap:notify', CID> | ProgressEvent<'blocks:put-many:blockstore:put-many'> | BitswapNotifyProgressEvents;
12
+ export type GetBlockProgressEvents = ProgressEvent<'blocks:get:bitswap:want', CID> | ProgressEvent<'blocks:get:blockstore:get', CID> | ProgressEvent<'blocks:get:blockstore:put', CID> | BitswapWantProgressEvents;
13
+ export type GetManyBlocksProgressEvents = ProgressEvent<'blocks:get-many:blockstore:get-many'> | ProgressEvent<'blocks:get-many:bitswap:want', CID> | ProgressEvent<'blocks:get-many:blockstore:put', CID> | BitswapWantProgressEvents;
14
+ export type GetAllBlocksProgressEvents = ProgressEvent<'blocks:get-all:blockstore:get-many'>;
15
+ export type DeleteBlockProgressEvents = ProgressEvent<'blocks:delete:blockstore:delete', CID>;
16
+ export type DeleteManyBlocksProgressEvents = ProgressEvent<'blocks:delete-many:blockstore:delete-many'>;
17
+ export interface Blocks {
18
+ /**
19
+ * Check for the existence of a value for the passed key
20
+ *
21
+ * @example
22
+ * ```js
23
+ * const exists = await store.has(CID('bafyfoo'))
24
+ *
25
+ * if (exists) {
26
+ * console.log('it is there')
27
+ * } else {
28
+ * console.log('it is not there')
29
+ * }
30
+ *```
31
+ */
32
+ has: (key: CID, options?: AbortOptions) => Promise<boolean>;
33
+ /**
34
+ * Store the passed block under the passed CID
35
+ *
36
+ * @example
37
+ *
38
+ * ```js
39
+ * await store.put(CID('bafyfoo'), new Uint8Array([0, 1, 2, 3]))
40
+ * ```
41
+ */
42
+ put: (key: CID, val: Uint8Array, options?: AbortOptions & ProgressOptions<PutBlockProgressEvents>) => Promise<void>;
43
+ /**
44
+ * Store the given key/value pairs
45
+ *
46
+ * @example
47
+ * ```js
48
+ * const source = [{ cid: CID('bafyfoo'), block: new Uint8Array([0, 1, 2, 3]) }]
49
+ *
50
+ * for await (const { key, value } of store.putMany(source)) {
51
+ * console.info(`put content for key ${key}`)
52
+ * }
53
+ * ```
54
+ */
55
+ putMany: (source: AwaitIterable<Pair>, options?: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents>) => AsyncIterable<Pair>;
56
+ /**
57
+ * Retrieve the value stored under the given key
58
+ *
59
+ * @example
60
+ * ```js
61
+ * const value = await store.get(CID('bafyfoo'))
62
+ * console.log('got content: %s', value.toString('utf8'))
63
+ * // => got content: datastore
64
+ * ```
65
+ */
66
+ get: (key: CID, options?: AbortOptions & ProgressOptions<GetBlockProgressEvents>) => Promise<Uint8Array>;
67
+ /**
68
+ * Retrieve values for the passed keys
69
+ *
70
+ * @example
71
+ * ```js
72
+ * for await (const value of store.getMany([CID('bafyfoo')])) {
73
+ * console.log('got content:', new TextDecoder('utf8').decode(value))
74
+ * // => got content: datastore
75
+ * }
76
+ * ```
77
+ */
78
+ getMany: (source: AwaitIterable<CID>, options?: AbortOptions & ProgressOptions<GetManyBlocksProgressEvents>) => AsyncIterable<Uint8Array>;
79
+ /**
80
+ * Retrieve all blocks in the blockstore
81
+ *
82
+ * @example
83
+ * ```js
84
+ * for await (const value of store.getAll()) {
85
+ * console.log('got content:', new TextDecoder('utf8').decode(value))
86
+ * // => got content: datastore
87
+ * }
88
+ * ```
89
+ */
90
+ getAll: (options?: AbortOptions & ProgressOptions<GetAllBlocksProgressEvents>) => AsyncIterable<Pair>;
91
+ /**
92
+ * Remove the record for the passed key
93
+ *
94
+ * @example
95
+ *
96
+ * ```js
97
+ * await store.delete(CID('bafyfoo'))
98
+ * console.log('deleted awesome content :(')
99
+ * ```
100
+ */
101
+ delete: (key: CID, options?: AbortOptions & ProgressOptions<DeleteBlockProgressEvents>) => Promise<void>;
102
+ /**
103
+ * Remove values for the passed keys
104
+ *
105
+ * @example
106
+ *
107
+ * ```js
108
+ * const source = [CID('bafyfoo')]
109
+ *
110
+ * for await (const key of store.deleteMany(source)) {
111
+ * console.log(`deleted content with key ${key}`)
112
+ * }
113
+ * ```
114
+ */
115
+ deleteMany: (source: AwaitIterable<CID>, options?: AbortOptions & ProgressOptions<DeleteManyBlocksProgressEvents>) => AsyncIterable<CID>;
116
+ }
117
+ //# sourceMappingURL=blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,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,2BAA2B,EAAE,GAAG,CAAC,GAC/C,aAAa,CAAC,2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E,YAAY,GAAG,eAAe,CAAC,2BAA2B,CAAC,KAClE,aAAa,CAAC,IAAI,CAAC,CAAA;IAExB;;;;;;;;;OASG;IACH,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,sBAAsB,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IAExG;;;;;;;;;;OAUG;IACH,OAAO,EAAE,CACP,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,EAC1B,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,2BAA2B,CAAC,KAClE,aAAa,CAAC,UAAU,CAAC,CAAA;IAE9B;;;;;;;;;;OAUG;IACH,MAAM,EAAE,CACN,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,0BAA0B,CAAC,KACjE,aAAa,CAAC,IAAI,CAAC,CAAA;IAExB;;;;;;;;;OASG;IACH,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,yBAAyB,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAExG;;;;;;;;;;;;OAYG;IACH,UAAU,EAAE,CACV,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,EAC1B,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,8BAA8B,CAAC,KACrE,aAAa,CAAC,GAAG,CAAC,CAAA;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":""}
@@ -14,13 +14,14 @@
14
14
  * ```
15
15
  */
16
16
  import type { Libp2p } from '@libp2p/interface-libp2p';
17
- import type { Blockstore } from 'interface-blockstore';
18
17
  import type { AbortOptions } from '@libp2p/interfaces';
19
18
  import type { PeerId } from '@libp2p/interface-peer-id';
20
19
  import type { Datastore } from 'interface-datastore';
21
20
  import type { Pins } from './pins.js';
22
21
  import type { ProgressEvent, ProgressOptions } from 'progress-events';
23
22
  import type { CID } from 'multiformats/cid';
23
+ import type { Blocks } from './blocks.js';
24
+ export type AwaitIterable<T> = Iterable<T> | AsyncIterable<T>;
24
25
  /**
25
26
  * The API presented by a Helia node.
26
27
  */
@@ -32,7 +33,7 @@ export interface Helia {
32
33
  /**
33
34
  * Where the blocks are stored
34
35
  */
35
- blockstore: Blockstore;
36
+ blockstore: Blocks;
36
37
  /**
37
38
  * A key/value store
38
39
  */
@@ -54,7 +55,7 @@ export interface Helia {
54
55
  */
55
56
  gc: (options?: GCOptions) => Promise<void>;
56
57
  }
57
- export type GcEvents = ProgressEvent<'helia:gc:deleted', CID>;
58
+ export type GcEvents = ProgressEvent<'helia:gc:deleted', CID> | ProgressEvent<'helia:gc:error', Error>;
58
59
  export interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {
59
60
  }
60
61
  export interface InfoOptions extends AbortOptions {
@@ -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,0BAA0B,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C;;GAEG;AACH,MAAM,WAAW,K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,aAAa,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;AAE7D;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,EAAE,SAAS,CAAA;IAEpB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAE1B;;OAEG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAEzB;;OAEG;IACH,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3C;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,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/interface",
3
- "version": "0.0.0-031ca73",
3
+ "version": "0.0.0-202b966",
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,6 +47,10 @@
47
47
  "types": "./dist/src/index.d.ts",
48
48
  "import": "./dist/src/index.js"
49
49
  },
50
+ "./blocks": {
51
+ "types": "./dist/src/blocks.d.ts",
52
+ "import": "./dist/src/blocks.js"
53
+ },
50
54
  "./pins": {
51
55
  "types": "./dist/src/pins.d.ts",
52
56
  "import": "./dist/src/pins.js"
@@ -154,9 +158,8 @@
154
158
  "@libp2p/interface-libp2p": "^1.1.0",
155
159
  "@libp2p/interface-peer-id": "^2.0.1",
156
160
  "@libp2p/interfaces": "^3.3.1",
157
- "@multiformats/multiaddr": "^11.1.5",
158
- "interface-blockstore": "^4.0.1",
159
- "interface-datastore": "^7.0.3",
161
+ "interface-datastore": "^8.0.0",
162
+ "ipfs-bitswap": "^17.0.0",
160
163
  "multiformats": "^11.0.1",
161
164
  "progress-events": "^1.0.0"
162
165
  },
package/src/blocks.ts ADDED
@@ -0,0 +1,162 @@
1
+ import type { AbortOptions } from '@libp2p/interfaces'
2
+ import type { ProgressEvent, ProgressOptions } from 'progress-events'
3
+ import type { CID } from 'multiformats/cid'
4
+ import type { BitswapNotifyProgressEvents, BitswapWantProgressEvents } from 'ipfs-bitswap'
5
+ import type { AwaitIterable } from './index.js'
6
+
7
+ export interface Pair {
8
+ cid: CID
9
+ block: Uint8Array
10
+ }
11
+
12
+ export type PutBlockProgressEvents =
13
+ ProgressEvent<'blocks:put:duplicate', CID> |
14
+ ProgressEvent<'blocks:put:bitswap:notify', CID> |
15
+ ProgressEvent<'blocks:put:blockstore:put', CID> |
16
+ BitswapNotifyProgressEvents
17
+
18
+ export type PutManyBlocksProgressEvents =
19
+ ProgressEvent<'blocks:put-many:duplicate', CID> |
20
+ ProgressEvent<'blocks:put-many:bitswap:notify', CID> |
21
+ ProgressEvent<'blocks:put-many:blockstore:put-many'> |
22
+ BitswapNotifyProgressEvents
23
+
24
+ export type GetBlockProgressEvents =
25
+ ProgressEvent<'blocks:get:bitswap:want', CID> |
26
+ ProgressEvent<'blocks:get:blockstore:get', CID> |
27
+ ProgressEvent<'blocks:get:blockstore:put', CID> |
28
+ BitswapWantProgressEvents
29
+
30
+ export type GetManyBlocksProgressEvents =
31
+ ProgressEvent<'blocks:get-many:blockstore:get-many'> |
32
+ ProgressEvent<'blocks:get-many:bitswap:want', CID> |
33
+ ProgressEvent<'blocks:get-many:blockstore:put', CID> |
34
+ BitswapWantProgressEvents
35
+
36
+ export type GetAllBlocksProgressEvents =
37
+ ProgressEvent<'blocks:get-all:blockstore:get-many'>
38
+
39
+ export type DeleteBlockProgressEvents =
40
+ ProgressEvent<'blocks:delete:blockstore:delete', CID>
41
+
42
+ export type DeleteManyBlocksProgressEvents =
43
+ ProgressEvent<'blocks:delete-many:blockstore:delete-many'>
44
+
45
+ export interface Blocks {
46
+ /**
47
+ * Check for the existence of a value for the passed key
48
+ *
49
+ * @example
50
+ * ```js
51
+ * const exists = await store.has(CID('bafyfoo'))
52
+ *
53
+ * if (exists) {
54
+ * console.log('it is there')
55
+ * } else {
56
+ * console.log('it is not there')
57
+ * }
58
+ *```
59
+ */
60
+ has: (key: CID, options?: AbortOptions) => Promise<boolean>
61
+
62
+ /**
63
+ * Store the passed block under the passed CID
64
+ *
65
+ * @example
66
+ *
67
+ * ```js
68
+ * await store.put(CID('bafyfoo'), new Uint8Array([0, 1, 2, 3]))
69
+ * ```
70
+ */
71
+ put: (key: CID, val: Uint8Array, options?: AbortOptions & ProgressOptions<PutBlockProgressEvents>) => Promise<void>
72
+
73
+ /**
74
+ * Store the given key/value pairs
75
+ *
76
+ * @example
77
+ * ```js
78
+ * const source = [{ cid: CID('bafyfoo'), block: new Uint8Array([0, 1, 2, 3]) }]
79
+ *
80
+ * for await (const { key, value } of store.putMany(source)) {
81
+ * console.info(`put content for key ${key}`)
82
+ * }
83
+ * ```
84
+ */
85
+ putMany: (
86
+ source: AwaitIterable<Pair>,
87
+ options?: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents>
88
+ ) => AsyncIterable<Pair>
89
+
90
+ /**
91
+ * Retrieve the value stored under the given key
92
+ *
93
+ * @example
94
+ * ```js
95
+ * const value = await store.get(CID('bafyfoo'))
96
+ * console.log('got content: %s', value.toString('utf8'))
97
+ * // => got content: datastore
98
+ * ```
99
+ */
100
+ get: (key: CID, options?: AbortOptions & ProgressOptions<GetBlockProgressEvents>) => Promise<Uint8Array>
101
+
102
+ /**
103
+ * Retrieve values for the passed keys
104
+ *
105
+ * @example
106
+ * ```js
107
+ * for await (const value of store.getMany([CID('bafyfoo')])) {
108
+ * console.log('got content:', new TextDecoder('utf8').decode(value))
109
+ * // => got content: datastore
110
+ * }
111
+ * ```
112
+ */
113
+ getMany: (
114
+ source: AwaitIterable<CID>,
115
+ options?: AbortOptions & ProgressOptions<GetManyBlocksProgressEvents>
116
+ ) => AsyncIterable<Uint8Array>
117
+
118
+ /**
119
+ * Retrieve all blocks in the blockstore
120
+ *
121
+ * @example
122
+ * ```js
123
+ * for await (const value of store.getAll()) {
124
+ * console.log('got content:', new TextDecoder('utf8').decode(value))
125
+ * // => got content: datastore
126
+ * }
127
+ * ```
128
+ */
129
+ getAll: (
130
+ options?: AbortOptions & ProgressOptions<GetAllBlocksProgressEvents>
131
+ ) => AsyncIterable<Pair>
132
+
133
+ /**
134
+ * Remove the record for the passed key
135
+ *
136
+ * @example
137
+ *
138
+ * ```js
139
+ * await store.delete(CID('bafyfoo'))
140
+ * console.log('deleted awesome content :(')
141
+ * ```
142
+ */
143
+ delete: (key: CID, options?: AbortOptions & ProgressOptions<DeleteBlockProgressEvents>) => Promise<void>
144
+
145
+ /**
146
+ * Remove values for the passed keys
147
+ *
148
+ * @example
149
+ *
150
+ * ```js
151
+ * const source = [CID('bafyfoo')]
152
+ *
153
+ * for await (const key of store.deleteMany(source)) {
154
+ * console.log(`deleted content with key ${key}`)
155
+ * }
156
+ * ```
157
+ */
158
+ deleteMany: (
159
+ source: AwaitIterable<CID>,
160
+ options?: AbortOptions & ProgressOptions<DeleteManyBlocksProgressEvents>
161
+ ) => AsyncIterable<CID>
162
+ }
package/src/index.ts CHANGED
@@ -15,13 +15,15 @@
15
15
  */
16
16
 
17
17
  import type { Libp2p } from '@libp2p/interface-libp2p'
18
- import type { Blockstore } from 'interface-blockstore'
19
18
  import type { AbortOptions } from '@libp2p/interfaces'
20
19
  import type { PeerId } from '@libp2p/interface-peer-id'
21
20
  import type { Datastore } from 'interface-datastore'
22
21
  import type { Pins } from './pins.js'
23
22
  import type { ProgressEvent, ProgressOptions } from 'progress-events'
24
23
  import type { CID } from 'multiformats/cid'
24
+ import type { Blocks } from './blocks.js'
25
+
26
+ export type AwaitIterable<T> = Iterable<T> | AsyncIterable<T>
25
27
 
26
28
  /**
27
29
  * The API presented by a Helia node.
@@ -35,7 +37,7 @@ export interface Helia {
35
37
  /**
36
38
  * Where the blocks are stored
37
39
  */
38
- blockstore: Blockstore
40
+ blockstore: Blocks
39
41
 
40
42
  /**
41
43
  * A key/value store
@@ -64,7 +66,8 @@ export interface Helia {
64
66
  }
65
67
 
66
68
  export type GcEvents =
67
- ProgressEvent<'helia:gc:deleted', CID>
69
+ ProgressEvent<'helia:gc:deleted', CID> |
70
+ ProgressEvent<'helia:gc:error', Error>
68
71
 
69
72
  export interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {
70
73