@helia/interface 0.0.0-f8f35b7 → 0.0.0-f9ff5de
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/blocks.d.ts +4 -89
- package/dist/src/blocks.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +4 -88
- package/src/blocks.ts +15 -103
- package/src/index.ts +1 -1
package/dist/src/blocks.d.ts
CHANGED
|
@@ -1,104 +1,19 @@
|
|
|
1
|
-
import type { AbortOptions } from '@libp2p/interfaces';
|
|
2
1
|
import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
3
2
|
import type { CID } from 'multiformats/cid';
|
|
4
3
|
import type { BitswapNotifyProgressEvents, BitswapWantProgressEvents } from 'ipfs-bitswap';
|
|
5
|
-
import type {
|
|
4
|
+
import type { Blockstore } from 'interface-blockstore';
|
|
6
5
|
export interface Pair {
|
|
7
6
|
cid: CID;
|
|
8
7
|
block: Uint8Array;
|
|
9
8
|
}
|
|
9
|
+
export type HasBlockProgressEvents = ProgressEvent<'blocks:put:duplicate', CID> | ProgressEvent<'blocks:put:bitswap:notify', CID> | ProgressEvent<'blocks:put:blockstore:put', CID> | BitswapNotifyProgressEvents;
|
|
10
10
|
export type PutBlockProgressEvents = ProgressEvent<'blocks:put:duplicate', CID> | ProgressEvent<'blocks:put:bitswap:notify', CID> | ProgressEvent<'blocks:put:blockstore:put', CID> | BitswapNotifyProgressEvents;
|
|
11
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
12
|
export type GetBlockProgressEvents = ProgressEvent<'blocks:get:bitswap:want', CID> | ProgressEvent<'blocks:get:blockstore:get', CID> | ProgressEvent<'blocks:get:blockstore:put', CID> | BitswapWantProgressEvents;
|
|
13
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'>;
|
|
14
15
|
export type DeleteBlockProgressEvents = ProgressEvent<'blocks:delete:blockstore:delete', CID>;
|
|
15
16
|
export type DeleteManyBlocksProgressEvents = ProgressEvent<'blocks:delete-many:blockstore:delete-many'>;
|
|
16
|
-
export interface Blocks {
|
|
17
|
-
/**
|
|
18
|
-
* Store the passed block under the passed CID
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
*
|
|
22
|
-
* ```js
|
|
23
|
-
* await store.put([{ key: new Key('awesome'), value: new Uint8Array([0, 1, 2, 3]) }])
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
put: (key: CID, val: Uint8Array, options?: AbortOptions & ProgressOptions<PutBlockProgressEvents>) => Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Retrieve the value stored under the given key
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```js
|
|
32
|
-
* const value = await store.get(new Key('awesome'))
|
|
33
|
-
* console.log('got content: %s', value.toString('utf8'))
|
|
34
|
-
* // => got content: datastore
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
get: (key: CID, options?: AbortOptions & ProgressOptions<GetBlockProgressEvents>) => Promise<Uint8Array>;
|
|
38
|
-
/**
|
|
39
|
-
* Check for the existence of a value for the passed key
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```js
|
|
43
|
-
*const exists = await store.has(new Key('awesome'))
|
|
44
|
-
*
|
|
45
|
-
*if (exists) {
|
|
46
|
-
* console.log('it is there')
|
|
47
|
-
*} else {
|
|
48
|
-
* console.log('it is not there')
|
|
49
|
-
*}
|
|
50
|
-
*```
|
|
51
|
-
*/
|
|
52
|
-
has: (key: CID, options?: AbortOptions) => Promise<boolean>;
|
|
53
|
-
/**
|
|
54
|
-
* Remove the record for the passed key
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
*
|
|
58
|
-
* ```js
|
|
59
|
-
* await store.delete(new Key('awesome'))
|
|
60
|
-
* console.log('deleted awesome content :(')
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
delete: (key: CID, options?: AbortOptions & ProgressOptions<DeleteBlockProgressEvents>) => Promise<void>;
|
|
64
|
-
/**
|
|
65
|
-
* Store the given key/value pairs
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```js
|
|
69
|
-
* const source = [{ key: new Key('awesome'), value: new Uint8Array([0, 1, 2, 3]) }]
|
|
70
|
-
*
|
|
71
|
-
* for await (const { key, value } of store.putMany(source)) {
|
|
72
|
-
* console.info(`put content for key ${key}`)
|
|
73
|
-
* }
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
putMany: (source: AwaitIterable<Pair>, options?: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents>) => AsyncIterable<Pair>;
|
|
77
|
-
/**
|
|
78
|
-
* Retrieve values for the passed keys
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```js
|
|
82
|
-
* for await (const value of store.getMany([new Key('awesome')])) {
|
|
83
|
-
* console.log('got content:', new TextDecoder('utf8').decode(value))
|
|
84
|
-
* // => got content: datastore
|
|
85
|
-
* }
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
getMany: (source: AwaitIterable<CID>, options?: AbortOptions & ProgressOptions<GetManyBlocksProgressEvents>) => AsyncIterable<Uint8Array>;
|
|
89
|
-
/**
|
|
90
|
-
* Remove values for the passed keys
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
*
|
|
94
|
-
* ```js
|
|
95
|
-
* const source = [new Key('awesome')]
|
|
96
|
-
*
|
|
97
|
-
* for await (const key of store.deleteMany(source)) {
|
|
98
|
-
* console.log(`deleted content with key ${key}`)
|
|
99
|
-
* }
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
deleteMany: (source: AwaitIterable<CID>, options?: AbortOptions & ProgressOptions<DeleteManyBlocksProgressEvents>) => AsyncIterable<CID>;
|
|
17
|
+
export interface Blocks extends Blockstore<ProgressOptions<HasBlockProgressEvents>, ProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>, ProgressOptions<GetBlockProgressEvents>, ProgressOptions<GetManyBlocksProgressEvents>, ProgressOptions<GetAllBlocksProgressEvents>, ProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>> {
|
|
103
18
|
}
|
|
104
19
|
//# 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,
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAAA,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,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtD,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,2BAA2B,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eAAe,CAAC,8BAA8B,CAAC,CAC1F;CAEA"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ import type { Pins } from './pins.js';
|
|
|
21
21
|
import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
22
22
|
import type { CID } from 'multiformats/cid';
|
|
23
23
|
import type { Blocks } from './blocks.js';
|
|
24
|
-
export type AwaitIterable
|
|
24
|
+
export type { Await, AwaitIterable } from 'interface-store';
|
|
25
25
|
/**
|
|
26
26
|
* The API presented by a Helia node.
|
|
27
27
|
*/
|
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,0BAA0B,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;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,
|
|
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,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAA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
|
|
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",
|
|
@@ -62,103 +62,19 @@
|
|
|
62
62
|
"sourceType": "module"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
-
"release": {
|
|
66
|
-
"branches": [
|
|
67
|
-
"main"
|
|
68
|
-
],
|
|
69
|
-
"plugins": [
|
|
70
|
-
[
|
|
71
|
-
"@semantic-release/commit-analyzer",
|
|
72
|
-
{
|
|
73
|
-
"preset": "conventionalcommits",
|
|
74
|
-
"releaseRules": [
|
|
75
|
-
{
|
|
76
|
-
"breaking": true,
|
|
77
|
-
"release": "major"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"revert": true,
|
|
81
|
-
"release": "patch"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"type": "feat",
|
|
85
|
-
"release": "minor"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"type": "fix",
|
|
89
|
-
"release": "patch"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"type": "docs",
|
|
93
|
-
"release": "patch"
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
"type": "test",
|
|
97
|
-
"release": "patch"
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
"type": "deps",
|
|
101
|
-
"release": "patch"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"scope": "no-release",
|
|
105
|
-
"release": false
|
|
106
|
-
}
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
],
|
|
110
|
-
[
|
|
111
|
-
"@semantic-release/release-notes-generator",
|
|
112
|
-
{
|
|
113
|
-
"preset": "conventionalcommits",
|
|
114
|
-
"presetConfig": {
|
|
115
|
-
"types": [
|
|
116
|
-
{
|
|
117
|
-
"type": "feat",
|
|
118
|
-
"section": "Features"
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
"type": "fix",
|
|
122
|
-
"section": "Bug Fixes"
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
"type": "chore",
|
|
126
|
-
"section": "Trivial Changes"
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
"type": "docs",
|
|
130
|
-
"section": "Documentation"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"type": "deps",
|
|
134
|
-
"section": "Dependencies"
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
"type": "test",
|
|
138
|
-
"section": "Tests"
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
],
|
|
144
|
-
"@semantic-release/changelog",
|
|
145
|
-
"@semantic-release/npm",
|
|
146
|
-
"@semantic-release/github",
|
|
147
|
-
"@semantic-release/git"
|
|
148
|
-
]
|
|
149
|
-
},
|
|
150
65
|
"scripts": {
|
|
151
66
|
"clean": "aegir clean",
|
|
152
67
|
"lint": "aegir lint",
|
|
153
68
|
"dep-check": "aegir dep-check",
|
|
154
|
-
"build": "aegir build"
|
|
155
|
-
"release": "aegir release"
|
|
69
|
+
"build": "aegir build"
|
|
156
70
|
},
|
|
157
71
|
"dependencies": {
|
|
158
72
|
"@libp2p/interface-libp2p": "^1.1.0",
|
|
159
73
|
"@libp2p/interface-peer-id": "^2.0.1",
|
|
160
74
|
"@libp2p/interfaces": "^3.3.1",
|
|
75
|
+
"interface-blockstore": "^5.0.0",
|
|
161
76
|
"interface-datastore": "^8.0.0",
|
|
77
|
+
"interface-store": "^4.0.0",
|
|
162
78
|
"ipfs-bitswap": "^17.0.0",
|
|
163
79
|
"multiformats": "^11.0.1",
|
|
164
80
|
"progress-events": "^1.0.0"
|
package/src/blocks.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import type { AbortOptions } from '@libp2p/interfaces'
|
|
2
1
|
import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
3
2
|
import type { CID } from 'multiformats/cid'
|
|
4
3
|
import type { BitswapNotifyProgressEvents, BitswapWantProgressEvents } from 'ipfs-bitswap'
|
|
5
|
-
import type {
|
|
4
|
+
import type { Blockstore } from 'interface-blockstore'
|
|
6
5
|
|
|
7
6
|
export interface Pair {
|
|
8
7
|
cid: CID
|
|
9
8
|
block: Uint8Array
|
|
10
9
|
}
|
|
11
10
|
|
|
11
|
+
export type HasBlockProgressEvents =
|
|
12
|
+
ProgressEvent<'blocks:put:duplicate', CID> |
|
|
13
|
+
ProgressEvent<'blocks:put:bitswap:notify', CID> |
|
|
14
|
+
ProgressEvent<'blocks:put:blockstore:put', CID> |
|
|
15
|
+
BitswapNotifyProgressEvents
|
|
16
|
+
|
|
12
17
|
export type PutBlockProgressEvents =
|
|
13
18
|
ProgressEvent<'blocks:put:duplicate', CID> |
|
|
14
19
|
ProgressEvent<'blocks:put:bitswap:notify', CID> |
|
|
@@ -33,112 +38,19 @@ export type GetManyBlocksProgressEvents =
|
|
|
33
38
|
ProgressEvent<'blocks:get-many:blockstore:put', CID> |
|
|
34
39
|
BitswapWantProgressEvents
|
|
35
40
|
|
|
41
|
+
export type GetAllBlocksProgressEvents =
|
|
42
|
+
ProgressEvent<'blocks:get-all:blockstore:get-many'>
|
|
43
|
+
|
|
36
44
|
export type DeleteBlockProgressEvents =
|
|
37
45
|
ProgressEvent<'blocks:delete:blockstore:delete', CID>
|
|
38
46
|
|
|
39
47
|
export type DeleteManyBlocksProgressEvents =
|
|
40
48
|
ProgressEvent<'blocks:delete-many:blockstore:delete-many'>
|
|
41
49
|
|
|
42
|
-
export interface Blocks
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
* ```js
|
|
49
|
-
* await store.put([{ key: new Key('awesome'), value: new Uint8Array([0, 1, 2, 3]) }])
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
put: (key: CID, val: Uint8Array, options?: AbortOptions & ProgressOptions<PutBlockProgressEvents>) => Promise<void>
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Retrieve the value stored under the given key
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```js
|
|
59
|
-
* const value = await store.get(new Key('awesome'))
|
|
60
|
-
* console.log('got content: %s', value.toString('utf8'))
|
|
61
|
-
* // => got content: datastore
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
get: (key: CID, options?: AbortOptions & ProgressOptions<GetBlockProgressEvents>) => Promise<Uint8Array>
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Check for the existence of a value for the passed key
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```js
|
|
71
|
-
*const exists = await store.has(new Key('awesome'))
|
|
72
|
-
*
|
|
73
|
-
*if (exists) {
|
|
74
|
-
* console.log('it is there')
|
|
75
|
-
*} else {
|
|
76
|
-
* console.log('it is not there')
|
|
77
|
-
*}
|
|
78
|
-
*```
|
|
79
|
-
*/
|
|
80
|
-
has: (key: CID, options?: AbortOptions) => Promise<boolean>
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Remove the record for the passed key
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
*
|
|
87
|
-
* ```js
|
|
88
|
-
* await store.delete(new Key('awesome'))
|
|
89
|
-
* console.log('deleted awesome content :(')
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
delete: (key: CID, options?: AbortOptions & ProgressOptions<DeleteBlockProgressEvents>) => Promise<void>
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Store the given key/value pairs
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```js
|
|
99
|
-
* const source = [{ key: new Key('awesome'), value: new Uint8Array([0, 1, 2, 3]) }]
|
|
100
|
-
*
|
|
101
|
-
* for await (const { key, value } of store.putMany(source)) {
|
|
102
|
-
* console.info(`put content for key ${key}`)
|
|
103
|
-
* }
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
putMany: (
|
|
107
|
-
source: AwaitIterable<Pair>,
|
|
108
|
-
options?: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents>
|
|
109
|
-
) => AsyncIterable<Pair>
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Retrieve values for the passed keys
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* ```js
|
|
116
|
-
* for await (const value of store.getMany([new Key('awesome')])) {
|
|
117
|
-
* console.log('got content:', new TextDecoder('utf8').decode(value))
|
|
118
|
-
* // => got content: datastore
|
|
119
|
-
* }
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
getMany: (
|
|
123
|
-
source: AwaitIterable<CID>,
|
|
124
|
-
options?: AbortOptions & ProgressOptions<GetManyBlocksProgressEvents>
|
|
125
|
-
) => AsyncIterable<Uint8Array>
|
|
50
|
+
export interface Blocks extends Blockstore<ProgressOptions<HasBlockProgressEvents>,
|
|
51
|
+
ProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>,
|
|
52
|
+
ProgressOptions<GetBlockProgressEvents>, ProgressOptions<GetManyBlocksProgressEvents>, ProgressOptions<GetAllBlocksProgressEvents>,
|
|
53
|
+
ProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>
|
|
54
|
+
> {
|
|
126
55
|
|
|
127
|
-
/**
|
|
128
|
-
* Remove values for the passed keys
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
*
|
|
132
|
-
* ```js
|
|
133
|
-
* const source = [new Key('awesome')]
|
|
134
|
-
*
|
|
135
|
-
* for await (const key of store.deleteMany(source)) {
|
|
136
|
-
* console.log(`deleted content with key ${key}`)
|
|
137
|
-
* }
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
deleteMany: (
|
|
141
|
-
source: AwaitIterable<CID>,
|
|
142
|
-
options?: AbortOptions & ProgressOptions<DeleteManyBlocksProgressEvents>
|
|
143
|
-
) => AsyncIterable<CID>
|
|
144
56
|
}
|
package/src/index.ts
CHANGED
|
@@ -23,7 +23,7 @@ import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
|
23
23
|
import type { CID } from 'multiformats/cid'
|
|
24
24
|
import type { Blocks } from './blocks.js'
|
|
25
25
|
|
|
26
|
-
export type AwaitIterable
|
|
26
|
+
export type { Await, AwaitIterable } from 'interface-store'
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* The API presented by a Helia node.
|