@helia/unixfs 7.0.4 → 7.1.0-080e4f91
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 +4 -4
- package/dist/index.min.js.map +4 -4
- package/dist/src/commands/add.d.ts +7 -7
- package/dist/src/commands/add.d.ts.map +1 -1
- package/dist/src/commands/add.js +12 -4
- package/dist/src/commands/add.js.map +1 -1
- package/dist/src/commands/cat.d.ts +3 -3
- package/dist/src/commands/cat.d.ts.map +1 -1
- package/dist/src/commands/cat.js +2 -2
- package/dist/src/commands/cat.js.map +1 -1
- package/dist/src/commands/chmod.d.ts +3 -3
- package/dist/src/commands/chmod.d.ts.map +1 -1
- package/dist/src/commands/chmod.js +3 -3
- package/dist/src/commands/chmod.js.map +1 -1
- package/dist/src/commands/cp.d.ts +3 -3
- package/dist/src/commands/cp.d.ts.map +1 -1
- package/dist/src/commands/cp.js +4 -4
- package/dist/src/commands/cp.js.map +1 -1
- package/dist/src/commands/ls.d.ts +3 -3
- package/dist/src/commands/ls.d.ts.map +1 -1
- package/dist/src/commands/ls.js +1 -1
- package/dist/src/commands/ls.js.map +1 -1
- package/dist/src/commands/mkdir.d.ts +3 -3
- package/dist/src/commands/mkdir.d.ts.map +1 -1
- package/dist/src/commands/mkdir.js +4 -4
- package/dist/src/commands/mkdir.js.map +1 -1
- package/dist/src/commands/rm.d.ts +3 -3
- package/dist/src/commands/rm.d.ts.map +1 -1
- package/dist/src/commands/rm.js +3 -3
- package/dist/src/commands/rm.js.map +1 -1
- package/dist/src/commands/stat.d.ts +2 -2
- package/dist/src/commands/stat.js +2 -2
- package/dist/src/commands/touch.d.ts +3 -3
- package/dist/src/commands/touch.d.ts.map +1 -1
- package/dist/src/commands/touch.js +3 -3
- package/dist/src/commands/touch.js.map +1 -1
- package/dist/src/commands/utils/add-link.d.ts +4 -6
- package/dist/src/commands/utils/add-link.d.ts.map +1 -1
- package/dist/src/commands/utils/add-link.js +23 -17
- package/dist/src/commands/utils/add-link.js.map +1 -1
- package/dist/src/commands/utils/cid-to-directory.d.ts +1 -1
- package/dist/src/commands/utils/cid-to-directory.js +1 -1
- package/dist/src/commands/utils/cid-to-pblink.d.ts +1 -1
- package/dist/src/commands/utils/cid-to-pblink.js +1 -1
- package/dist/src/commands/utils/hamt-utils.d.ts +9 -8
- package/dist/src/commands/utils/hamt-utils.d.ts.map +1 -1
- package/dist/src/commands/utils/hamt-utils.js +18 -16
- package/dist/src/commands/utils/hamt-utils.js.map +1 -1
- package/dist/src/commands/utils/is-over-shard-threshold.d.ts +6 -2
- package/dist/src/commands/utils/is-over-shard-threshold.d.ts.map +1 -1
- package/dist/src/commands/utils/is-over-shard-threshold.js +58 -13
- package/dist/src/commands/utils/is-over-shard-threshold.js.map +1 -1
- package/dist/src/commands/utils/persist.d.ts +3 -3
- package/dist/src/commands/utils/persist.d.ts.map +1 -1
- package/dist/src/commands/utils/remove-link.d.ts +5 -6
- package/dist/src/commands/utils/remove-link.d.ts.map +1 -1
- package/dist/src/commands/utils/remove-link.js +10 -9
- package/dist/src/commands/utils/remove-link.js.map +1 -1
- package/dist/src/commands/utils/resolve.d.ts +1 -1
- package/dist/src/commands/utils/resolve.js +4 -4
- package/dist/src/index.d.ts +24 -54
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/unixfs.d.ts +1 -1
- package/dist/src/unixfs.js +9 -9
- package/dist/src/utils/glob-source.js +2 -2
- package/dist/src/utils/url-source.d.ts +1 -1
- package/dist/src/utils/url-source.js +1 -1
- package/package.json +5 -6
- package/src/commands/add.ts +19 -11
- package/src/commands/cat.ts +5 -5
- package/src/commands/chmod.ts +6 -6
- package/src/commands/cp.ts +7 -7
- package/src/commands/ls.ts +4 -4
- package/src/commands/mkdir.ts +7 -7
- package/src/commands/rm.ts +6 -6
- package/src/commands/stat.ts +4 -4
- package/src/commands/touch.ts +6 -6
- package/src/commands/utils/add-link.ts +30 -24
- package/src/commands/utils/cid-to-directory.ts +2 -2
- package/src/commands/utils/cid-to-pblink.ts +2 -2
- package/src/commands/utils/hamt-utils.ts +29 -23
- package/src/commands/utils/is-over-shard-threshold.ts +88 -13
- package/src/commands/utils/persist.ts +3 -3
- package/src/commands/utils/remove-link.ts +17 -17
- package/src/commands/utils/resolve.ts +5 -5
- package/src/index.ts +25 -61
- package/src/unixfs.ts +10 -10
- package/src/utils/glob-source.ts +2 -2
- package/src/utils/url-source.ts +2 -2
- package/dist/src/commands/utils/dir-sharded.d.ts +0 -74
- package/dist/src/commands/utils/dir-sharded.d.ts.map +0 -1
- package/dist/src/commands/utils/dir-sharded.js +0 -235
- package/dist/src/commands/utils/dir-sharded.js.map +0 -1
- package/dist/typedoc-urls.json +0 -76
- package/src/commands/utils/dir-sharded.ts +0 -321
package/dist/src/index.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ import type { Blockstore } from 'interface-blockstore';
|
|
|
88
88
|
import type { Mtime, UnixFS as IPFSUnixFS } from 'ipfs-unixfs';
|
|
89
89
|
import type { ExporterProgressEvents, UnixFSDirectoryEntry } from 'ipfs-unixfs-exporter';
|
|
90
90
|
import type { ByteStream, DirectoryCandidate, ImportCandidateStream, ImporterOptions, ImporterProgressEvents, ImportResult, ImportContent } from 'ipfs-unixfs-importer';
|
|
91
|
-
import type { CID
|
|
91
|
+
import type { CID } from 'multiformats/cid';
|
|
92
92
|
import type { ProgressOptions } from 'progress-events';
|
|
93
93
|
export interface UnixFSComponents {
|
|
94
94
|
blockstore: Pick<Blockstore, 'get' | 'put' | 'has'>;
|
|
@@ -102,7 +102,7 @@ export interface FileCandidate<T extends ImportContent = ImportContent> {
|
|
|
102
102
|
export type AddEvents = PutBlockProgressEvents | ImporterProgressEvents;
|
|
103
103
|
export interface AddOptions extends AbortOptions, Omit<ImporterOptions, 'onProgress'>, ProgressOptions<AddEvents> {
|
|
104
104
|
}
|
|
105
|
-
export type AddFileOptions = Omit<AddOptions, 'wrapWithDirectory'>;
|
|
105
|
+
export type AddFileOptions = Omit<AddOptions, 'wrapWithDirectory'> & Pick<FileCandidate, 'mode' | 'mtime'>;
|
|
106
106
|
export type GetEvents = GetBlockProgressEvents | ExporterProgressEvents;
|
|
107
107
|
/**
|
|
108
108
|
* Options to pass to the cat command
|
|
@@ -134,16 +134,11 @@ export interface ChmodOptions extends AbortOptions, ProgressOptions<GetEvents |
|
|
|
134
134
|
* If the target of the operation is a directory and this is true,
|
|
135
135
|
* apply the new mode to all directory contents
|
|
136
136
|
*/
|
|
137
|
-
recursive
|
|
137
|
+
recursive?: boolean;
|
|
138
138
|
/**
|
|
139
139
|
* Optional path to set the mode on directory contents
|
|
140
140
|
*/
|
|
141
141
|
path?: string;
|
|
142
|
-
/**
|
|
143
|
-
* DAGs with a root block larger than this value will be sharded. Blocks
|
|
144
|
-
* smaller than this value will be regular UnixFS directories.
|
|
145
|
-
*/
|
|
146
|
-
shardSplitThresholdBytes: number;
|
|
147
142
|
/**
|
|
148
143
|
* If true, do not perform any network operations and throw if blocks are
|
|
149
144
|
* missing from the local store. (default: false)
|
|
@@ -153,16 +148,11 @@ export interface ChmodOptions extends AbortOptions, ProgressOptions<GetEvents |
|
|
|
153
148
|
/**
|
|
154
149
|
* Options to pass to the cp command
|
|
155
150
|
*/
|
|
156
|
-
export interface CpOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions {
|
|
151
|
+
export interface CpOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions, Pick<ImporterOptions, 'shardFanoutBits' | 'shardSplitStrategy' | 'shardSplitThresholdBytes'> {
|
|
157
152
|
/**
|
|
158
153
|
* If true, allow overwriting existing directory entries (default: false)
|
|
159
154
|
*/
|
|
160
|
-
force
|
|
161
|
-
/**
|
|
162
|
-
* DAGs with a root block larger than this value will be sharded. Blocks
|
|
163
|
-
* smaller than this value will be regular UnixFS directories.
|
|
164
|
-
*/
|
|
165
|
-
shardSplitThresholdBytes: number;
|
|
155
|
+
force?: boolean;
|
|
166
156
|
/**
|
|
167
157
|
* If true, do not perform any network operations and throw if blocks are
|
|
168
158
|
* missing from the local store. (default: false)
|
|
@@ -195,16 +185,11 @@ export interface LsOptions extends AbortOptions, ProgressOptions<GetEvents> {
|
|
|
195
185
|
/**
|
|
196
186
|
* Options to pass to the mkdir command
|
|
197
187
|
*/
|
|
198
|
-
export interface MkdirOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions {
|
|
199
|
-
/**
|
|
200
|
-
* The CID version to create the new directory with - defaults to the same
|
|
201
|
-
* version as the containing directory
|
|
202
|
-
*/
|
|
203
|
-
cidVersion: Version;
|
|
188
|
+
export interface MkdirOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions, Pick<ImporterOptions, 'profile' | 'shardFanoutBits' | 'shardSplitStrategy' | 'shardSplitThresholdBytes' | 'cidVersion'> {
|
|
204
189
|
/**
|
|
205
190
|
* If true, allow overwriting existing directory entries (default: false)
|
|
206
191
|
*/
|
|
207
|
-
force
|
|
192
|
+
force?: boolean;
|
|
208
193
|
/**
|
|
209
194
|
* An optional mode to set on the new directory
|
|
210
195
|
*/
|
|
@@ -213,11 +198,6 @@ export interface MkdirOptions extends AbortOptions, ProgressOptions<GetEvents |
|
|
|
213
198
|
* An optional mtime to set on the new directory
|
|
214
199
|
*/
|
|
215
200
|
mtime?: Mtime;
|
|
216
|
-
/**
|
|
217
|
-
* DAGs with a root block larger than this value will be sharded. Blocks
|
|
218
|
-
* smaller than this value will be regular UnixFS directories.
|
|
219
|
-
*/
|
|
220
|
-
shardSplitThresholdBytes: number;
|
|
221
201
|
/**
|
|
222
202
|
* If true, do not perform any network operations and throw if blocks are
|
|
223
203
|
* missing from the local store. (default: false)
|
|
@@ -227,12 +207,7 @@ export interface MkdirOptions extends AbortOptions, ProgressOptions<GetEvents |
|
|
|
227
207
|
/**
|
|
228
208
|
* Options to pass to the rm command
|
|
229
209
|
*/
|
|
230
|
-
export interface RmOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions {
|
|
231
|
-
/**
|
|
232
|
-
* DAGs with a root block larger than this value will be sharded. Blocks
|
|
233
|
-
* smaller than this value will be regular UnixFS directories.
|
|
234
|
-
*/
|
|
235
|
-
shardSplitThresholdBytes: number;
|
|
210
|
+
export interface RmOptions extends AbortOptions, ProgressOptions<GetEvents | PutBlockProgressEvents>, ProviderOptions, Pick<ImporterOptions, 'shardFanoutBits' | 'shardSplitStrategy' | 'shardSplitThresholdBytes'> {
|
|
236
211
|
/**
|
|
237
212
|
* If true, do not perform any network operations and throw if blocks are
|
|
238
213
|
* missing from the local store. (default: false)
|
|
@@ -394,12 +369,7 @@ export interface TouchOptions extends AbortOptions, ProgressOptions<GetEvents |
|
|
|
394
369
|
/**
|
|
395
370
|
* If the DAG is a directory and this is true, update the mtime on all contents
|
|
396
371
|
*/
|
|
397
|
-
recursive
|
|
398
|
-
/**
|
|
399
|
-
* DAGs with a root block larger than this value will be sharded. Blocks
|
|
400
|
-
* smaller than this value will be regular UnixFS directories.
|
|
401
|
-
*/
|
|
402
|
-
shardSplitThresholdBytes: number;
|
|
372
|
+
recursive?: boolean;
|
|
403
373
|
/**
|
|
404
374
|
* If true, do not perform any network operations and throw if blocks are
|
|
405
375
|
* missing from the local store. (default: false)
|
|
@@ -432,7 +402,7 @@ export interface UnixFS {
|
|
|
432
402
|
* }
|
|
433
403
|
* ```
|
|
434
404
|
*/
|
|
435
|
-
addAll(source: ImportCandidateStream, options?:
|
|
405
|
+
addAll(source: ImportCandidateStream, options?: Omit<AddOptions, 'mtime' | 'mode'>): AsyncIterable<ImportResult>;
|
|
436
406
|
/**
|
|
437
407
|
* Add a single `Uint8Array` to your Helia node and receive a CID that will
|
|
438
408
|
* resolve to it.
|
|
@@ -448,7 +418,7 @@ export interface UnixFS {
|
|
|
448
418
|
* console.info(cid)
|
|
449
419
|
* ```
|
|
450
420
|
*/
|
|
451
|
-
addBytes(bytes: Uint8Array, options?:
|
|
421
|
+
addBytes(bytes: Uint8Array, options?: AddFileOptions): Promise<CID>;
|
|
452
422
|
/**
|
|
453
423
|
* Add a stream of `Uint8Array`s to your Helia node and receive a CID that
|
|
454
424
|
* will resolve to them.
|
|
@@ -467,7 +437,7 @@ export interface UnixFS {
|
|
|
467
437
|
* console.info(cid)
|
|
468
438
|
* ```
|
|
469
439
|
*/
|
|
470
|
-
addByteStream(bytes: ByteStream, options?:
|
|
440
|
+
addByteStream(bytes: ByteStream, options?: AddFileOptions): Promise<CID>;
|
|
471
441
|
/**
|
|
472
442
|
* Add a file to your Helia node with metadata. The returned CID will resolve
|
|
473
443
|
* to a directory with one file entry.
|
|
@@ -491,7 +461,7 @@ export interface UnixFS {
|
|
|
491
461
|
* console.info(cid)
|
|
492
462
|
* ```
|
|
493
463
|
*/
|
|
494
|
-
addFile(file: FileCandidate, options?:
|
|
464
|
+
addFile(file: FileCandidate, options?: AddFileOptions): Promise<CID>;
|
|
495
465
|
/**
|
|
496
466
|
* Add a directory to your Helia node.
|
|
497
467
|
*
|
|
@@ -525,7 +495,7 @@ export interface UnixFS {
|
|
|
525
495
|
* console.info(stat.cid) // empty directory CID
|
|
526
496
|
* ```
|
|
527
497
|
*/
|
|
528
|
-
addDirectory(dir?: Partial<DirectoryCandidate>, options?:
|
|
498
|
+
addDirectory(dir?: Partial<DirectoryCandidate>, options?: AddFileOptions): Promise<CID>;
|
|
529
499
|
/**
|
|
530
500
|
* Retrieve the contents of a file from your Helia node.
|
|
531
501
|
*
|
|
@@ -537,7 +507,7 @@ export interface UnixFS {
|
|
|
537
507
|
* }
|
|
538
508
|
* ```
|
|
539
509
|
*/
|
|
540
|
-
cat(cid: CID, options?:
|
|
510
|
+
cat(cid: CID, options?: CatOptions): AsyncIterable<Uint8Array>;
|
|
541
511
|
/**
|
|
542
512
|
* Change the permissions on a file or directory in a DAG
|
|
543
513
|
*
|
|
@@ -554,7 +524,7 @@ export interface UnixFS {
|
|
|
554
524
|
* console.info(afterCid, afterStats)
|
|
555
525
|
* ```
|
|
556
526
|
*/
|
|
557
|
-
chmod(cid: CID, mode: number, options?:
|
|
527
|
+
chmod(cid: CID, mode: number, options?: ChmodOptions): Promise<CID>;
|
|
558
528
|
/**
|
|
559
529
|
* Add a file or directory to a target directory.
|
|
560
530
|
*
|
|
@@ -569,7 +539,7 @@ export interface UnixFS {
|
|
|
569
539
|
* console.info(updatedCid)
|
|
570
540
|
* ```
|
|
571
541
|
*/
|
|
572
|
-
cp(source: CID, target: CID, name: string, options?:
|
|
542
|
+
cp(source: CID, target: CID, name: string, options?: CpOptions): Promise<CID>;
|
|
573
543
|
/**
|
|
574
544
|
* List directory contents.
|
|
575
545
|
*
|
|
@@ -581,7 +551,7 @@ export interface UnixFS {
|
|
|
581
551
|
* }
|
|
582
552
|
* ```
|
|
583
553
|
*/
|
|
584
|
-
ls(cid: CID, options?:
|
|
554
|
+
ls(cid: CID, options?: LsOptions): AsyncIterable<UnixFSDirectoryEntry>;
|
|
585
555
|
/**
|
|
586
556
|
* Make a new directory under an existing directory.
|
|
587
557
|
*
|
|
@@ -595,7 +565,7 @@ export interface UnixFS {
|
|
|
595
565
|
* console.info(updatedCid)
|
|
596
566
|
* ```
|
|
597
567
|
*/
|
|
598
|
-
mkdir(cid: CID, dirname: string, options?:
|
|
568
|
+
mkdir(cid: CID, dirname: string, options?: MkdirOptions): Promise<CID>;
|
|
599
569
|
/**
|
|
600
570
|
* Remove a file or directory from an existing directory.
|
|
601
571
|
*
|
|
@@ -610,7 +580,7 @@ export interface UnixFS {
|
|
|
610
580
|
* console.info(finalCid)
|
|
611
581
|
* ```
|
|
612
582
|
*/
|
|
613
|
-
rm(cid: CID, path: string, options?:
|
|
583
|
+
rm(cid: CID, path: string, options?: RmOptions): Promise<CID>;
|
|
614
584
|
/**
|
|
615
585
|
* Return statistics about a UnixFS DAG.
|
|
616
586
|
*
|
|
@@ -642,7 +612,7 @@ export interface UnixFS {
|
|
|
642
612
|
* console.info(afterCid, afterStats)
|
|
643
613
|
* ```
|
|
644
614
|
*/
|
|
645
|
-
touch(cid: CID, options?:
|
|
615
|
+
touch(cid: CID, options?: TouchOptions): Promise<CID>;
|
|
646
616
|
}
|
|
647
617
|
/**
|
|
648
618
|
* Create a {@link UnixFS} instance for use with {@link https://github.com/ipfs/helia Helia}
|
|
@@ -650,7 +620,7 @@ export interface UnixFS {
|
|
|
650
620
|
export declare function unixfs(helia: {
|
|
651
621
|
blockstore: Pick<Blockstore, 'get' | 'put' | 'has'>;
|
|
652
622
|
}): UnixFS;
|
|
653
|
-
export { globSource } from './utils/glob-source.
|
|
654
|
-
export type { GlobSourceResult, GlobSourceOptions } from './utils/glob-source.
|
|
655
|
-
export { urlSource } from './utils/url-source.
|
|
623
|
+
export { globSource } from './utils/glob-source.ts';
|
|
624
|
+
export type { GlobSourceResult, GlobSourceOptions } from './utils/glob-source.ts';
|
|
625
|
+
export { urlSource } from './utils/url-source.ts';
|
|
656
626
|
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;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,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa,CAAA;AAC9D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;;;;;;;;;;OAeG;IACH,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;CACtD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAE,KAAK,EAAE;IAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,CAAA;CAAE,GAAG,MAAM,CAE9F;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
CHANGED
|
@@ -81,13 +81,13 @@
|
|
|
81
81
|
* }
|
|
82
82
|
* ```
|
|
83
83
|
*/
|
|
84
|
-
import { UnixFS as UnixFSClass } from
|
|
84
|
+
import { UnixFS as UnixFSClass } from "./unixfs.js";
|
|
85
85
|
/**
|
|
86
86
|
* Create a {@link UnixFS} instance for use with {@link https://github.com/ipfs/helia Helia}
|
|
87
87
|
*/
|
|
88
88
|
export function unixfs(helia) {
|
|
89
89
|
return new UnixFSClass(helia);
|
|
90
90
|
}
|
|
91
|
-
export { globSource } from
|
|
92
|
-
export { urlSource } from
|
|
91
|
+
export { globSource } from "./utils/glob-source.js";
|
|
92
|
+
export { urlSource } from "./utils/url-source.js";
|
|
93
93
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AAEH,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AAEH,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,aAAa,CAAA;AAwlBnD;;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/dist/src/unixfs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AddOptions, CatOptions, ChmodOptions, CpOptions, ExtendedStatOptions, ExtendedDirectoryStats, ExtendedFileStats, FileCandidate, LsOptions, MkdirOptions, RmOptions, StatOptions, TouchOptions, UnixFSComponents, DirectoryStats, FileStats, UnixFS as UnixFSInterface, RawStats, ExtendedRawStats } from './index.
|
|
1
|
+
import type { AddOptions, CatOptions, ChmodOptions, CpOptions, ExtendedStatOptions, ExtendedDirectoryStats, ExtendedFileStats, FileCandidate, LsOptions, MkdirOptions, RmOptions, StatOptions, TouchOptions, UnixFSComponents, DirectoryStats, FileStats, UnixFS as UnixFSInterface, RawStats, ExtendedRawStats } from './index.ts';
|
|
2
2
|
import type { Blockstore } from 'interface-blockstore';
|
|
3
3
|
import type { UnixFSDirectoryEntry } from 'ipfs-unixfs-exporter';
|
|
4
4
|
import type { ByteStream, DirectoryCandidate, ImportCandidateStream, ImportResult } from 'ipfs-unixfs-importer';
|
package/dist/src/unixfs.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { addAll, addBytes, addByteStream, addDirectory, addFile } from
|
|
2
|
-
import { cat } from
|
|
3
|
-
import { chmod } from
|
|
4
|
-
import { cp } from
|
|
5
|
-
import { ls } from
|
|
6
|
-
import { mkdir } from
|
|
7
|
-
import { rm } from
|
|
8
|
-
import { stat } from
|
|
9
|
-
import { touch } from
|
|
1
|
+
import { addAll, addBytes, addByteStream, addDirectory, addFile } from "./commands/add.js";
|
|
2
|
+
import { cat } from "./commands/cat.js";
|
|
3
|
+
import { chmod } from "./commands/chmod.js";
|
|
4
|
+
import { cp } from "./commands/cp.js";
|
|
5
|
+
import { ls } from "./commands/ls.js";
|
|
6
|
+
import { mkdir } from "./commands/mkdir.js";
|
|
7
|
+
import { rm } from "./commands/rm.js";
|
|
8
|
+
import { stat } from "./commands/stat.js";
|
|
9
|
+
import { touch } from "./commands/touch.js";
|
|
10
10
|
export class UnixFS {
|
|
11
11
|
components;
|
|
12
12
|
constructor(components) {
|
|
@@ -3,8 +3,8 @@ import fsp from 'node:fs/promises';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import Path from 'path';
|
|
5
5
|
import glob from 'it-glob';
|
|
6
|
-
import { InvalidParametersError } from
|
|
7
|
-
import { toMtime } from
|
|
6
|
+
import { InvalidParametersError } from "../errors.js";
|
|
7
|
+
import { toMtime } from "./to-mtime.js";
|
|
8
8
|
/**
|
|
9
9
|
* Create an async iterator that yields paths that match requested glob pattern
|
|
10
10
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/unixfs",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.1.0-080e4f91",
|
|
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",
|
|
@@ -67,17 +67,16 @@
|
|
|
67
67
|
"test:electron-main": "aegir test -t electron-main"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@helia/interface": "
|
|
70
|
+
"@helia/interface": "6.1.1-080e4f91",
|
|
71
71
|
"@ipld/dag-pb": "^4.1.5",
|
|
72
72
|
"@libp2p/interface": "^3.1.0",
|
|
73
73
|
"@libp2p/logger": "^6.0.5",
|
|
74
74
|
"@libp2p/utils": "^7.0.5",
|
|
75
75
|
"@multiformats/murmur3": "^2.1.8",
|
|
76
|
-
"hamt-sharding": "^3.0.6",
|
|
77
76
|
"interface-blockstore": "^6.0.1",
|
|
78
|
-
"ipfs-unixfs": "^12.0.
|
|
79
|
-
"ipfs-unixfs-exporter": "^15.0.
|
|
80
|
-
"ipfs-unixfs-importer": "^16.
|
|
77
|
+
"ipfs-unixfs": "^12.0.1",
|
|
78
|
+
"ipfs-unixfs-exporter": "^15.0.3",
|
|
79
|
+
"ipfs-unixfs-importer": "^16.1.4",
|
|
81
80
|
"it-all": "^3.0.9",
|
|
82
81
|
"it-first": "^3.0.9",
|
|
83
82
|
"it-glob": "^3.0.4",
|
package/src/commands/add.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { importer, importFile } from 'ipfs-unixfs-importer'
|
|
2
2
|
import { fixedSize } from 'ipfs-unixfs-importer/chunker'
|
|
3
3
|
import { balanced } from 'ipfs-unixfs-importer/layout'
|
|
4
4
|
import first from 'it-first'
|
|
5
5
|
import last from 'it-last'
|
|
6
|
-
import { InvalidParametersError } from '../errors.
|
|
7
|
-
import type { FileCandidate, AddOptions, AddFileOptions } from '../index.
|
|
8
|
-
import type { PutStore } from '../unixfs.
|
|
6
|
+
import { InvalidParametersError } from '../errors.ts'
|
|
7
|
+
import type { FileCandidate, AddOptions, AddFileOptions } from '../index.ts'
|
|
8
|
+
import type { PutStore } from '../unixfs.ts'
|
|
9
9
|
import type { ByteStream, DirectoryCandidate, ImportCandidateStream, ImportResult } from 'ipfs-unixfs-importer'
|
|
10
10
|
import type { CID } from 'multiformats/cid'
|
|
11
11
|
|
|
@@ -23,15 +23,19 @@ const defaultImporterSettings: AddOptions = {
|
|
|
23
23
|
})
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export async function * addAll (source: ImportCandidateStream, blockstore: PutStore, options:
|
|
26
|
+
export async function * addAll (source: ImportCandidateStream, blockstore: PutStore, options: AddOptions = {}): AsyncGenerator<ImportResult, void, unknown> {
|
|
27
27
|
yield * importer(source, blockstore, {
|
|
28
28
|
...defaultImporterSettings,
|
|
29
29
|
...options
|
|
30
30
|
})
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export async function addBytes (bytes: Uint8Array, blockstore: PutStore, options:
|
|
34
|
-
const { cid } = await
|
|
33
|
+
export async function addBytes (bytes: Uint8Array, blockstore: PutStore, options: AddFileOptions = {}): Promise<CID> {
|
|
34
|
+
const { cid } = await importFile({
|
|
35
|
+
content: bytes,
|
|
36
|
+
mode: options.mode,
|
|
37
|
+
mtime: options.mtime
|
|
38
|
+
}, blockstore, {
|
|
35
39
|
...defaultImporterSettings,
|
|
36
40
|
...options
|
|
37
41
|
})
|
|
@@ -39,8 +43,12 @@ export async function addBytes (bytes: Uint8Array, blockstore: PutStore, options
|
|
|
39
43
|
return cid
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
export async function addByteStream (bytes: ByteStream, blockstore: PutStore, options:
|
|
43
|
-
const { cid } = await
|
|
46
|
+
export async function addByteStream (bytes: ByteStream, blockstore: PutStore, options: AddFileOptions = {}): Promise<CID> {
|
|
47
|
+
const { cid } = await importFile({
|
|
48
|
+
content: bytes,
|
|
49
|
+
mode: options.mode,
|
|
50
|
+
mtime: options.mtime
|
|
51
|
+
}, blockstore, {
|
|
44
52
|
...defaultImporterSettings,
|
|
45
53
|
...options
|
|
46
54
|
})
|
|
@@ -48,7 +56,7 @@ export async function addByteStream (bytes: ByteStream, blockstore: PutStore, op
|
|
|
48
56
|
return cid
|
|
49
57
|
}
|
|
50
58
|
|
|
51
|
-
export async function addFile (file: FileCandidate, blockstore: PutStore, options:
|
|
59
|
+
export async function addFile (file: FileCandidate, blockstore: PutStore, options: AddFileOptions = {}): Promise<CID> {
|
|
52
60
|
if (file.path == null) {
|
|
53
61
|
throw new InvalidParametersError('path is required')
|
|
54
62
|
}
|
|
@@ -70,7 +78,7 @@ export async function addFile (file: FileCandidate, blockstore: PutStore, option
|
|
|
70
78
|
return result.cid
|
|
71
79
|
}
|
|
72
80
|
|
|
73
|
-
export async function addDirectory (dir: Partial<DirectoryCandidate>, blockstore: PutStore, options:
|
|
81
|
+
export async function addDirectory (dir: Partial<DirectoryCandidate>, blockstore: PutStore, options: AddFileOptions = {}): Promise<CID> {
|
|
74
82
|
// @ts-expect-error field is not in the types
|
|
75
83
|
if (dir.content != null) {
|
|
76
84
|
throw new InvalidParametersError('Directories cannot have content, use addFile instead')
|
package/src/commands/cat.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { exporter } from 'ipfs-unixfs-exporter'
|
|
2
|
-
import { NoContentError, NotAFileError } from '../errors.
|
|
3
|
-
import { resolve } from './utils/resolve.
|
|
4
|
-
import type { CatOptions } from '../index.
|
|
5
|
-
import type { GetStore } from '../unixfs.
|
|
2
|
+
import { NoContentError, NotAFileError } from '../errors.ts'
|
|
3
|
+
import { resolve } from './utils/resolve.ts'
|
|
4
|
+
import type { CatOptions } from '../index.ts'
|
|
5
|
+
import type { GetStore } from '../unixfs.ts'
|
|
6
6
|
import type { CID } from 'multiformats/cid'
|
|
7
7
|
|
|
8
|
-
export async function * cat (cid: CID, blockstore: GetStore, options:
|
|
8
|
+
export async function * cat (cid: CID, blockstore: GetStore, options: CatOptions = {}): AsyncIterable<Uint8Array> {
|
|
9
9
|
const resolved = await resolve(cid, options.path, blockstore, options)
|
|
10
10
|
const result = await exporter(resolved.cid, blockstore, options)
|
|
11
11
|
|
package/src/commands/chmod.ts
CHANGED
|
@@ -9,16 +9,16 @@ import toBuffer from 'it-to-buffer'
|
|
|
9
9
|
import { CID } from 'multiformats/cid'
|
|
10
10
|
import * as raw from 'multiformats/codecs/raw'
|
|
11
11
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
12
|
-
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from '../errors.
|
|
13
|
-
import { persist } from './utils/persist.
|
|
14
|
-
import { resolve, updatePathCids } from './utils/resolve.
|
|
15
|
-
import type { ChmodOptions } from '../index.
|
|
16
|
-
import type { GetStore, PutStore } from '../unixfs.
|
|
12
|
+
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from '../errors.ts'
|
|
13
|
+
import { persist } from './utils/persist.ts'
|
|
14
|
+
import { resolve, updatePathCids } from './utils/resolve.ts'
|
|
15
|
+
import type { ChmodOptions } from '../index.ts'
|
|
16
|
+
import type { GetStore, PutStore } from '../unixfs.ts'
|
|
17
17
|
import type { PBNode, PBLink } from '@ipld/dag-pb'
|
|
18
18
|
|
|
19
19
|
const log = logger('helia:unixfs:chmod')
|
|
20
20
|
|
|
21
|
-
export async function chmod (cid: CID, mode: number, blockstore: PutStore & GetStore, options:
|
|
21
|
+
export async function chmod (cid: CID, mode: number, blockstore: PutStore & GetStore, options: ChmodOptions = {}): Promise<CID> {
|
|
22
22
|
const resolved = await resolve(cid, options.path, blockstore, options)
|
|
23
23
|
|
|
24
24
|
log('chmod %c %d', resolved.cid, mode)
|
package/src/commands/cp.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { logger } from '@libp2p/logger'
|
|
2
|
-
import { InvalidParametersError } from '../errors.
|
|
3
|
-
import { addLink } from './utils/add-link.
|
|
4
|
-
import { cidToDirectory } from './utils/cid-to-directory.
|
|
5
|
-
import { cidToPBLink } from './utils/cid-to-pblink.
|
|
6
|
-
import type { CpOptions } from '../index.
|
|
7
|
-
import type { GetStore, PutStore } from '../unixfs.
|
|
2
|
+
import { InvalidParametersError } from '../errors.ts'
|
|
3
|
+
import { addLink } from './utils/add-link.ts'
|
|
4
|
+
import { cidToDirectory } from './utils/cid-to-directory.ts'
|
|
5
|
+
import { cidToPBLink } from './utils/cid-to-pblink.ts'
|
|
6
|
+
import type { CpOptions } from '../index.ts'
|
|
7
|
+
import type { GetStore, PutStore } from '../unixfs.ts'
|
|
8
8
|
import type { CID } from 'multiformats/cid'
|
|
9
9
|
|
|
10
10
|
const log = logger('helia:unixfs:cp')
|
|
11
11
|
|
|
12
|
-
export async function cp (source: CID, target: CID, name: string, blockstore: GetStore & PutStore, options:
|
|
12
|
+
export async function cp (source: CID, target: CID, name: string, blockstore: GetStore & PutStore, options: CpOptions = {}): Promise<CID> {
|
|
13
13
|
if (name.includes('/')) {
|
|
14
14
|
throw new InvalidParametersError('Name must not have slashes')
|
|
15
15
|
}
|
package/src/commands/ls.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { exporter } from 'ipfs-unixfs-exporter'
|
|
2
|
-
import { resolve } from './utils/resolve.
|
|
3
|
-
import type { LsOptions } from '../index.
|
|
4
|
-
import type { GetStore } from '../unixfs.
|
|
2
|
+
import { resolve } from './utils/resolve.ts'
|
|
3
|
+
import type { LsOptions } from '../index.ts'
|
|
4
|
+
import type { GetStore } from '../unixfs.ts'
|
|
5
5
|
import type { UnixFSDirectoryEntry } from 'ipfs-unixfs-exporter'
|
|
6
6
|
import type { CID } from 'multiformats/cid'
|
|
7
7
|
|
|
8
|
-
export async function * ls (cid: CID, blockstore: GetStore, options:
|
|
8
|
+
export async function * ls (cid: CID, blockstore: GetStore, options: LsOptions = {}): AsyncIterable<UnixFSDirectoryEntry> {
|
|
9
9
|
const resolved = await resolve(cid, options.path, blockstore, options)
|
|
10
10
|
const result = await exporter(resolved.cid, blockstore, options)
|
|
11
11
|
|
package/src/commands/mkdir.ts
CHANGED
|
@@ -5,16 +5,16 @@ import { exporter } from 'ipfs-unixfs-exporter'
|
|
|
5
5
|
import { CID } from 'multiformats/cid'
|
|
6
6
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
7
7
|
import { DEFAULT_CID_VERSION } from '../constants.ts'
|
|
8
|
-
import { InvalidParametersError, NotADirectoryError } from '../errors.
|
|
9
|
-
import { addLink } from './utils/add-link.
|
|
10
|
-
import { cidToDirectory } from './utils/cid-to-directory.
|
|
11
|
-
import { cidToPBLink } from './utils/cid-to-pblink.
|
|
12
|
-
import type { MkdirOptions } from '../index.
|
|
13
|
-
import type { GetStore, PutStore } from '../unixfs.
|
|
8
|
+
import { InvalidParametersError, NotADirectoryError } from '../errors.ts'
|
|
9
|
+
import { addLink } from './utils/add-link.ts'
|
|
10
|
+
import { cidToDirectory } from './utils/cid-to-directory.ts'
|
|
11
|
+
import { cidToPBLink } from './utils/cid-to-pblink.ts'
|
|
12
|
+
import type { MkdirOptions } from '../index.ts'
|
|
13
|
+
import type { GetStore, PutStore } from '../unixfs.ts'
|
|
14
14
|
|
|
15
15
|
const log = logger('helia:unixfs:mkdir')
|
|
16
16
|
|
|
17
|
-
export async function mkdir (parentCid: CID, dirname: string, blockstore: GetStore & PutStore, options:
|
|
17
|
+
export async function mkdir (parentCid: CID, dirname: string, blockstore: GetStore & PutStore, options: MkdirOptions = {}): Promise<CID> {
|
|
18
18
|
if (dirname.includes('/')) {
|
|
19
19
|
throw new InvalidParametersError('Path must not have slashes')
|
|
20
20
|
}
|
package/src/commands/rm.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { logger } from '@libp2p/logger'
|
|
2
|
-
import { InvalidParametersError } from '../errors.
|
|
3
|
-
import { cidToDirectory } from './utils/cid-to-directory.
|
|
4
|
-
import { removeLink } from './utils/remove-link.
|
|
5
|
-
import type { RmOptions } from '../index.
|
|
6
|
-
import type { GetStore, PutStore } from '../unixfs.
|
|
2
|
+
import { InvalidParametersError } from '../errors.ts'
|
|
3
|
+
import { cidToDirectory } from './utils/cid-to-directory.ts'
|
|
4
|
+
import { removeLink } from './utils/remove-link.ts'
|
|
5
|
+
import type { RmOptions } from '../index.ts'
|
|
6
|
+
import type { GetStore, PutStore } from '../unixfs.ts'
|
|
7
7
|
import type { CID } from 'multiformats/cid'
|
|
8
8
|
|
|
9
9
|
const log = logger('helia:unixfs:rm')
|
|
10
10
|
|
|
11
|
-
export async function rm (target: CID, name: string, blockstore: GetStore & PutStore, options:
|
|
11
|
+
export async function rm (target: CID, name: string, blockstore: GetStore & PutStore, options: RmOptions = {}): Promise<CID> {
|
|
12
12
|
if (name.includes('/')) {
|
|
13
13
|
throw new InvalidParametersError('Name must not have slashes')
|
|
14
14
|
}
|
package/src/commands/stat.ts
CHANGED
|
@@ -5,10 +5,10 @@ import { UnixFS } from 'ipfs-unixfs'
|
|
|
5
5
|
import { exporter } from 'ipfs-unixfs-exporter'
|
|
6
6
|
import toBuffer from 'it-to-buffer'
|
|
7
7
|
import * as raw from 'multiformats/codecs/raw'
|
|
8
|
-
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from '../errors.
|
|
9
|
-
import { resolve } from './utils/resolve.
|
|
10
|
-
import type { ExtendedStatOptions, ExtendedDirectoryStats, ExtendedFileStats, StatOptions, DirectoryStats, FileStats, RawStats, ExtendedRawStats } from '../index.
|
|
11
|
-
import type { GetStore, HasStore } from '../unixfs.
|
|
8
|
+
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from '../errors.ts'
|
|
9
|
+
import { resolve } from './utils/resolve.ts'
|
|
10
|
+
import type { ExtendedStatOptions, ExtendedDirectoryStats, ExtendedFileStats, StatOptions, DirectoryStats, FileStats, RawStats, ExtendedRawStats } from '../index.ts'
|
|
11
|
+
import type { GetStore, HasStore } from '../unixfs.ts'
|
|
12
12
|
import type { Filter } from '@libp2p/utils'
|
|
13
13
|
import type { RawNode, UnixFSDirectory, UnixFSFile } from 'ipfs-unixfs-exporter'
|
|
14
14
|
import type { CID } from 'multiformats/cid'
|
package/src/commands/touch.ts
CHANGED
|
@@ -9,16 +9,16 @@ import toBuffer from 'it-to-buffer'
|
|
|
9
9
|
import { CID } from 'multiformats/cid'
|
|
10
10
|
import * as raw from 'multiformats/codecs/raw'
|
|
11
11
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
12
|
-
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from '../errors.
|
|
13
|
-
import { persist } from './utils/persist.
|
|
14
|
-
import { resolve, updatePathCids } from './utils/resolve.
|
|
15
|
-
import type { TouchOptions } from '../index.
|
|
16
|
-
import type { GetStore, PutStore } from '../unixfs.
|
|
12
|
+
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from '../errors.ts'
|
|
13
|
+
import { persist } from './utils/persist.ts'
|
|
14
|
+
import { resolve, updatePathCids } from './utils/resolve.ts'
|
|
15
|
+
import type { TouchOptions } from '../index.ts'
|
|
16
|
+
import type { GetStore, PutStore } from '../unixfs.ts'
|
|
17
17
|
import type { PBNode, PBLink } from '@ipld/dag-pb'
|
|
18
18
|
|
|
19
19
|
const log = logger('helia:unixfs:touch')
|
|
20
20
|
|
|
21
|
-
export async function touch (cid: CID, blockstore: GetStore & PutStore, options:
|
|
21
|
+
export async function touch (cid: CID, blockstore: GetStore & PutStore, options: TouchOptions = {}): Promise<CID> {
|
|
22
22
|
const resolved = await resolve(cid, options.path, blockstore, options)
|
|
23
23
|
const mtime = options.mtime ?? {
|
|
24
24
|
secs: BigInt(Math.round(Date.now() / 1000)),
|