@helia/unixfs 5.0.4 → 5.1.0
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/index.min.js.map +4 -4
- package/dist/src/commands/ls.d.ts +4 -1
- package/dist/src/commands/ls.d.ts.map +1 -1
- package/dist/src/commands/ls.js +16 -6
- package/dist/src/commands/ls.js.map +1 -1
- package/dist/src/index.d.ts +18 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/package.json +4 -4
- package/src/commands/ls.ts +21 -8
- package/src/index.ts +17 -8
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { LsOptions } from '../index.js';
|
|
2
2
|
import type { GetStore } from '../unixfs.js';
|
|
3
|
-
import type { UnixFSEntry } from 'ipfs-unixfs-exporter';
|
|
3
|
+
import type { UnixFSEntry, UnixFSBasicEntry } from 'ipfs-unixfs-exporter';
|
|
4
4
|
import type { CID } from 'multiformats/cid';
|
|
5
|
+
export declare function ls(cid: CID, blockstore: GetStore, options: Partial<LsOptions & {
|
|
6
|
+
extended: false;
|
|
7
|
+
}>): AsyncIterable<UnixFSBasicEntry>;
|
|
5
8
|
export declare function ls(cid: CID, blockstore: GetStore, options?: Partial<LsOptions>): AsyncIterable<UnixFSEntry>;
|
|
6
9
|
//# sourceMappingURL=ls.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../../src/commands/ls.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../../src/commands/ls.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAQ3C,wBAAgB,EAAE,CAAE,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,SAAS,GAAG;IAAE,QAAQ,EAAE,KAAK,CAAA;CAAE,CAAC,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAA;AACvI,wBAAgB,EAAE,CAAE,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,CAAA"}
|
package/dist/src/commands/ls.js
CHANGED
|
@@ -7,9 +7,22 @@ const defaultOptions = {};
|
|
|
7
7
|
export async function* ls(cid, blockstore, options = {}) {
|
|
8
8
|
const opts = mergeOptions(defaultOptions, options);
|
|
9
9
|
const resolved = await resolve(cid, opts.path, blockstore, opts);
|
|
10
|
-
const result = await exporter(resolved.cid, blockstore
|
|
10
|
+
const result = await exporter(resolved.cid, blockstore, {
|
|
11
|
+
...options,
|
|
12
|
+
extended: true
|
|
13
|
+
});
|
|
11
14
|
if (result.type === 'file' || result.type === 'raw') {
|
|
12
|
-
|
|
15
|
+
if (options.extended === false) {
|
|
16
|
+
const basic = {
|
|
17
|
+
name: result.name,
|
|
18
|
+
path: result.path,
|
|
19
|
+
cid: result.cid
|
|
20
|
+
};
|
|
21
|
+
yield basic;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
yield result;
|
|
25
|
+
}
|
|
13
26
|
return;
|
|
14
27
|
}
|
|
15
28
|
if (result.content == null) {
|
|
@@ -18,9 +31,6 @@ export async function* ls(cid, blockstore, options = {}) {
|
|
|
18
31
|
if (result.type !== 'directory') {
|
|
19
32
|
throw new NotADirectoryError();
|
|
20
33
|
}
|
|
21
|
-
yield* result.content(
|
|
22
|
-
offset: options.offset,
|
|
23
|
-
length: options.length
|
|
24
|
-
});
|
|
34
|
+
yield* result.content(options);
|
|
25
35
|
}
|
|
26
36
|
//# sourceMappingURL=ls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls.js","sourceRoot":"","sources":["../../../src/commands/ls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAM5C,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAA;AAE9D,MAAM,cAAc,GAAc,EAEjC,CAAA;
|
|
1
|
+
{"version":3,"file":"ls.js","sourceRoot":"","sources":["../../../src/commands/ls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAM5C,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAA;AAE9D,MAAM,cAAc,GAAc,EAEjC,CAAA;AAID,MAAM,CAAC,KAAK,SAAU,CAAC,CAAC,EAAE,CAAE,GAAQ,EAAE,UAAoB,EAAE,UAA8B,EAAE;IAC1F,MAAM,IAAI,GAAc,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;IAC7D,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;IAChE,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE;QACtD,GAAG,OAAO;QACV,QAAQ,EAAE,IAAI;KACf,CAAC,CAAA;IAEF,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACpD,IAAI,OAAO,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;YAC/B,MAAM,KAAK,GAAqB;gBAC9B,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,GAAG,EAAE,MAAM,CAAC,GAAG;aAChB,CAAA;YAED,MAAM,KAAK,CAAA;QACb,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,CAAA;QACd,CAAC;QAED,OAAM;IACR,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;QAC3B,MAAM,IAAI,cAAc,EAAE,CAAA;IAC5B,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAChC,MAAM,IAAI,kBAAkB,EAAE,CAAA;IAChC,CAAC;IAED,KAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;AACjC,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -74,12 +74,12 @@
|
|
|
74
74
|
* }
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
77
|
-
import type { GetBlockProgressEvents, PutBlockProgressEvents } from '@helia/interface/blocks';
|
|
77
|
+
import type { GetBlockProgressEvents, ProviderOptions, PutBlockProgressEvents } from '@helia/interface/blocks';
|
|
78
78
|
import type { AbortOptions } from '@libp2p/interface';
|
|
79
79
|
import type { Filter } from '@libp2p/utils/filters';
|
|
80
80
|
import type { Blockstore } from 'interface-blockstore';
|
|
81
81
|
import type { Mtime, UnixFS as IPFSUnixFS } from 'ipfs-unixfs';
|
|
82
|
-
import type { ExporterProgressEvents, UnixFSEntry } from 'ipfs-unixfs-exporter';
|
|
82
|
+
import type { ExporterProgressEvents, UnixFSEntry, UnixFSBasicEntry } from 'ipfs-unixfs-exporter';
|
|
83
83
|
import type { ByteStream, DirectoryCandidate, ImportCandidateStream, ImporterOptions, ImporterProgressEvents, ImportResult, ImportContent } from 'ipfs-unixfs-importer';
|
|
84
84
|
import type { CID, Version } from 'multiformats/cid';
|
|
85
85
|
import type { ProgressOptions } from 'progress-events';
|
|
@@ -100,7 +100,7 @@ export type GetEvents = GetBlockProgressEvents | ExporterProgressEvents;
|
|
|
100
100
|
/**
|
|
101
101
|
* Options to pass to the cat command
|
|
102
102
|
*/
|
|
103
|
-
export interface CatOptions extends AbortOptions, ProgressOptions<GetEvents
|
|
103
|
+
export interface CatOptions extends AbortOptions, ProgressOptions<GetEvents>, ProviderOptions {
|
|
104
104
|
/**
|
|
105
105
|
* Start reading the file at this offset
|
|
106
106
|
*/
|
|
@@ -122,7 +122,7 @@ export interface CatOptions extends AbortOptions, ProgressOptions<GetEvents> {
|
|
|
122
122
|
/**
|
|
123
123
|
* Options to pass to the chmod command
|
|
124
124
|
*/
|
|
125
|
-
export interface ChmodOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents
|
|
125
|
+
export interface ChmodOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions {
|
|
126
126
|
/**
|
|
127
127
|
* If the target of the operation is a directory and this is true,
|
|
128
128
|
* apply the new mode to all directory contents
|
|
@@ -146,7 +146,7 @@ export interface ChmodOptions extends AbortOptions, ProgressOptions<GetEvents |
|
|
|
146
146
|
/**
|
|
147
147
|
* Options to pass to the cp command
|
|
148
148
|
*/
|
|
149
|
-
export interface CpOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents
|
|
149
|
+
export interface CpOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions {
|
|
150
150
|
/**
|
|
151
151
|
* If true, allow overwriting existing directory entries (default: false)
|
|
152
152
|
*/
|
|
@@ -184,11 +184,18 @@ export interface LsOptions extends AbortOptions, ProgressOptions<GetEvents> {
|
|
|
184
184
|
* missing from the local store. (default: false)
|
|
185
185
|
*/
|
|
186
186
|
offline?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* If true, including UnixFS metadata in the output - nb. this will resolve
|
|
189
|
+
* the root node of every encountered filesystem entry
|
|
190
|
+
*
|
|
191
|
+
* @default true
|
|
192
|
+
*/
|
|
193
|
+
extended?: boolean;
|
|
187
194
|
}
|
|
188
195
|
/**
|
|
189
196
|
* Options to pass to the mkdir command
|
|
190
197
|
*/
|
|
191
|
-
export interface MkdirOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents
|
|
198
|
+
export interface MkdirOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions {
|
|
192
199
|
/**
|
|
193
200
|
* The CID version to create the new directory with - defaults to the same
|
|
194
201
|
* version as the containing directory
|
|
@@ -220,7 +227,7 @@ export interface MkdirOptions extends AbortOptions, ProgressOptions<GetEvents |
|
|
|
220
227
|
/**
|
|
221
228
|
* Options to pass to the rm command
|
|
222
229
|
*/
|
|
223
|
-
export interface RmOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents
|
|
230
|
+
export interface RmOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions {
|
|
224
231
|
/**
|
|
225
232
|
* DAGs with a root block larger than this value will be sharded. Blocks
|
|
226
233
|
* smaller than this value will be regular UnixFS directories.
|
|
@@ -235,7 +242,7 @@ export interface RmOptions extends AbortOptions, ProgressOptions<GetEvents | Put
|
|
|
235
242
|
/**
|
|
236
243
|
* Options to pass to the stat command
|
|
237
244
|
*/
|
|
238
|
-
export interface StatOptions extends AbortOptions, ProgressOptions<GetEvents
|
|
245
|
+
export interface StatOptions extends AbortOptions, ProgressOptions<GetEvents>, ProviderOptions {
|
|
239
246
|
/**
|
|
240
247
|
* An optional path to allow getting stats of paths inside directories
|
|
241
248
|
*/
|
|
@@ -575,6 +582,9 @@ export interface UnixFS {
|
|
|
575
582
|
* ```
|
|
576
583
|
*/
|
|
577
584
|
ls(cid: CID, options?: Partial<LsOptions>): AsyncIterable<UnixFSEntry>;
|
|
585
|
+
ls(cid: CID, options: Partial<LsOptions> & {
|
|
586
|
+
extended: false;
|
|
587
|
+
}): AsyncIterable<UnixFSBasicEntry>;
|
|
578
588
|
/**
|
|
579
589
|
* Make a new directory under an existing directory.
|
|
580
590
|
*
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAC9G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE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AAED,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA"}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AAEH,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AAEH,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,aAAa,CAAA;AAqoBnD;;GAEG;AACH,MAAM,UAAU,MAAM,CAAE,KAA8D;IACpF,OAAO,IAAI,WAAW,CAAC,KAAK,CAAC,CAAA;AAC/B,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/unixfs",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "A Helia-compatible wrapper for UnixFS",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/unixfs#readme",
|
|
@@ -82,9 +82,9 @@
|
|
|
82
82
|
"@multiformats/murmur3": "^2.1.8",
|
|
83
83
|
"hamt-sharding": "^3.0.6",
|
|
84
84
|
"interface-blockstore": "^5.3.1",
|
|
85
|
-
"ipfs-unixfs": "^11.2.
|
|
86
|
-
"ipfs-unixfs-exporter": "^13.
|
|
87
|
-
"ipfs-unixfs-importer": "^15.
|
|
85
|
+
"ipfs-unixfs": "^11.2.5",
|
|
86
|
+
"ipfs-unixfs-exporter": "^13.7.2",
|
|
87
|
+
"ipfs-unixfs-importer": "^15.4.0",
|
|
88
88
|
"it-all": "^3.0.6",
|
|
89
89
|
"it-first": "^3.0.6",
|
|
90
90
|
"it-glob": "^3.0.1",
|
package/src/commands/ls.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { NoContentError, NotADirectoryError } from '../errors.js'
|
|
|
4
4
|
import { resolve } from './utils/resolve.js'
|
|
5
5
|
import type { LsOptions } from '../index.js'
|
|
6
6
|
import type { GetStore } from '../unixfs.js'
|
|
7
|
-
import type { UnixFSEntry } from 'ipfs-unixfs-exporter'
|
|
7
|
+
import type { UnixFSEntry, UnixFSBasicEntry } from 'ipfs-unixfs-exporter'
|
|
8
8
|
import type { CID } from 'multiformats/cid'
|
|
9
9
|
|
|
10
10
|
const mergeOptions = mergeOpts.bind({ ignoreUndefined: true })
|
|
@@ -13,13 +13,29 @@ const defaultOptions: LsOptions = {
|
|
|
13
13
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export function ls (cid: CID, blockstore: GetStore, options: Partial<LsOptions & { extended: false }>): AsyncIterable<UnixFSBasicEntry>
|
|
17
|
+
export function ls (cid: CID, blockstore: GetStore, options?: Partial<LsOptions>): AsyncIterable<UnixFSEntry>
|
|
18
|
+
export async function * ls (cid: CID, blockstore: GetStore, options: Partial<LsOptions> = {}): AsyncIterable<any> {
|
|
17
19
|
const opts: LsOptions = mergeOptions(defaultOptions, options)
|
|
18
20
|
const resolved = await resolve(cid, opts.path, blockstore, opts)
|
|
19
|
-
const result = await exporter(resolved.cid, blockstore
|
|
21
|
+
const result = await exporter(resolved.cid, blockstore, {
|
|
22
|
+
...options,
|
|
23
|
+
extended: true
|
|
24
|
+
})
|
|
20
25
|
|
|
21
26
|
if (result.type === 'file' || result.type === 'raw') {
|
|
22
|
-
|
|
27
|
+
if (options.extended === false) {
|
|
28
|
+
const basic: UnixFSBasicEntry = {
|
|
29
|
+
name: result.name,
|
|
30
|
+
path: result.path,
|
|
31
|
+
cid: result.cid
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
yield basic
|
|
35
|
+
} else {
|
|
36
|
+
yield result
|
|
37
|
+
}
|
|
38
|
+
|
|
23
39
|
return
|
|
24
40
|
}
|
|
25
41
|
|
|
@@ -31,8 +47,5 @@ export async function * ls (cid: CID, blockstore: GetStore, options: Partial<LsO
|
|
|
31
47
|
throw new NotADirectoryError()
|
|
32
48
|
}
|
|
33
49
|
|
|
34
|
-
yield * result.content(
|
|
35
|
-
offset: options.offset,
|
|
36
|
-
length: options.length
|
|
37
|
-
})
|
|
50
|
+
yield * result.content(options)
|
|
38
51
|
}
|
package/src/index.ts
CHANGED
|
@@ -76,12 +76,12 @@
|
|
|
76
76
|
*/
|
|
77
77
|
|
|
78
78
|
import { UnixFS as UnixFSClass } from './unixfs.js'
|
|
79
|
-
import type { GetBlockProgressEvents, PutBlockProgressEvents } from '@helia/interface/blocks'
|
|
79
|
+
import type { GetBlockProgressEvents, ProviderOptions, PutBlockProgressEvents } from '@helia/interface/blocks'
|
|
80
80
|
import type { AbortOptions } from '@libp2p/interface'
|
|
81
81
|
import type { Filter } from '@libp2p/utils/filters'
|
|
82
82
|
import type { Blockstore } from 'interface-blockstore'
|
|
83
83
|
import type { Mtime, UnixFS as IPFSUnixFS } from 'ipfs-unixfs'
|
|
84
|
-
import type { ExporterProgressEvents, UnixFSEntry } from 'ipfs-unixfs-exporter'
|
|
84
|
+
import type { ExporterProgressEvents, UnixFSEntry, UnixFSBasicEntry } from 'ipfs-unixfs-exporter'
|
|
85
85
|
import type { ByteStream, DirectoryCandidate, ImportCandidateStream, ImporterOptions, ImporterProgressEvents, ImportResult, ImportContent } from 'ipfs-unixfs-importer'
|
|
86
86
|
import type { CID, Version } from 'multiformats/cid'
|
|
87
87
|
import type { ProgressOptions } from 'progress-events'
|
|
@@ -112,7 +112,7 @@ export type GetEvents = GetBlockProgressEvents
|
|
|
112
112
|
/**
|
|
113
113
|
* Options to pass to the cat command
|
|
114
114
|
*/
|
|
115
|
-
export interface CatOptions extends AbortOptions, ProgressOptions<GetEvents
|
|
115
|
+
export interface CatOptions extends AbortOptions, ProgressOptions<GetEvents>, ProviderOptions {
|
|
116
116
|
/**
|
|
117
117
|
* Start reading the file at this offset
|
|
118
118
|
*/
|
|
@@ -138,7 +138,7 @@ export interface CatOptions extends AbortOptions, ProgressOptions<GetEvents> {
|
|
|
138
138
|
/**
|
|
139
139
|
* Options to pass to the chmod command
|
|
140
140
|
*/
|
|
141
|
-
export interface ChmodOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents
|
|
141
|
+
export interface ChmodOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions {
|
|
142
142
|
/**
|
|
143
143
|
* If the target of the operation is a directory and this is true,
|
|
144
144
|
* apply the new mode to all directory contents
|
|
@@ -166,7 +166,7 @@ export interface ChmodOptions extends AbortOptions, ProgressOptions<GetEvents |
|
|
|
166
166
|
/**
|
|
167
167
|
* Options to pass to the cp command
|
|
168
168
|
*/
|
|
169
|
-
export interface CpOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents
|
|
169
|
+
export interface CpOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions {
|
|
170
170
|
/**
|
|
171
171
|
* If true, allow overwriting existing directory entries (default: false)
|
|
172
172
|
*/
|
|
@@ -210,12 +210,20 @@ export interface LsOptions extends AbortOptions, ProgressOptions<GetEvents> {
|
|
|
210
210
|
* missing from the local store. (default: false)
|
|
211
211
|
*/
|
|
212
212
|
offline?: boolean
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* If true, including UnixFS metadata in the output - nb. this will resolve
|
|
216
|
+
* the root node of every encountered filesystem entry
|
|
217
|
+
*
|
|
218
|
+
* @default true
|
|
219
|
+
*/
|
|
220
|
+
extended?: boolean
|
|
213
221
|
}
|
|
214
222
|
|
|
215
223
|
/**
|
|
216
224
|
* Options to pass to the mkdir command
|
|
217
225
|
*/
|
|
218
|
-
export interface MkdirOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents
|
|
226
|
+
export interface MkdirOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions {
|
|
219
227
|
/**
|
|
220
228
|
* The CID version to create the new directory with - defaults to the same
|
|
221
229
|
* version as the containing directory
|
|
@@ -253,7 +261,7 @@ export interface MkdirOptions extends AbortOptions, ProgressOptions<GetEvents |
|
|
|
253
261
|
/**
|
|
254
262
|
* Options to pass to the rm command
|
|
255
263
|
*/
|
|
256
|
-
export interface RmOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents
|
|
264
|
+
export interface RmOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions {
|
|
257
265
|
/**
|
|
258
266
|
* DAGs with a root block larger than this value will be sharded. Blocks
|
|
259
267
|
* smaller than this value will be regular UnixFS directories.
|
|
@@ -270,7 +278,7 @@ export interface RmOptions extends AbortOptions, ProgressOptions<GetEvents | Put
|
|
|
270
278
|
/**
|
|
271
279
|
* Options to pass to the stat command
|
|
272
280
|
*/
|
|
273
|
-
export interface StatOptions extends AbortOptions, ProgressOptions<GetEvents
|
|
281
|
+
export interface StatOptions extends AbortOptions, ProgressOptions<GetEvents>, ProviderOptions {
|
|
274
282
|
/**
|
|
275
283
|
* An optional path to allow getting stats of paths inside directories
|
|
276
284
|
*/
|
|
@@ -644,6 +652,7 @@ export interface UnixFS {
|
|
|
644
652
|
* ```
|
|
645
653
|
*/
|
|
646
654
|
ls(cid: CID, options?: Partial<LsOptions>): AsyncIterable<UnixFSEntry>
|
|
655
|
+
ls(cid: CID, options: Partial<LsOptions> & { extended: false }): AsyncIterable<UnixFSBasicEntry>
|
|
647
656
|
|
|
648
657
|
/**
|
|
649
658
|
* Make a new directory under an existing directory.
|