|
1 |
| -import { UnixFS, Mtime } from 'ipfs-unixfs' |
2 |
| -import { CID, CIDVersion } from 'multiformats/cid' |
3 |
| -import { MultihashHasher } from 'multiformats/hashes/interface' |
4 |
| -import { BlockCodec } from 'multiformats/codecs/interface' |
5 |
| -import { Blockstore } from 'interface-blockstore' |
| 1 | +import type { UnixFS, Mtime } from 'ipfs-unixfs' |
| 2 | +import type { CID, CIDVersion } from 'multiformats/cid' |
| 3 | +import type { MultihashHasher } from 'multiformats/hashes/interface' |
| 4 | +import type { BlockCodec } from 'multiformats/codecs/interface' |
| 5 | +import type { Blockstore } from 'interface-blockstore' |
6 | 6 |
|
7 |
| -interface ImportCandidate { |
| 7 | +export interface ImportCandidate { |
8 | 8 | path?: string
|
9 | 9 | content?: AsyncIterable<Uint8Array> | Iterable<Uint8Array> | Uint8Array
|
10 | 10 | mtime?: Mtime
|
11 | 11 | mode?: number
|
12 | 12 | }
|
13 | 13 |
|
14 |
| -interface File { |
| 14 | +export interface File { |
15 | 15 | content: AsyncIterable<Uint8Array>
|
16 | 16 | path?: string
|
17 | 17 | mtime?: Mtime
|
18 | 18 | mode?: number
|
19 | 19 | }
|
20 | 20 |
|
21 |
| -interface Directory { |
| 21 | +export interface Directory { |
22 | 22 | path?: string
|
23 | 23 | mtime?: Mtime
|
24 | 24 | mode?: number
|
25 | 25 | }
|
26 | 26 |
|
27 |
| -interface ImportResult { |
| 27 | +export interface ImportResult { |
28 | 28 | cid: CID
|
29 | 29 | size: number
|
30 | 30 | path?: string
|
31 | 31 | unixfs?: UnixFS
|
32 | 32 | }
|
33 | 33 |
|
34 |
| -interface InProgressImportResult extends ImportResult { |
| 34 | +export interface InProgressImportResult extends ImportResult { |
35 | 35 | single?: boolean
|
36 | 36 | }
|
37 | 37 |
|
38 |
| -type ChunkerType = 'fixed' | 'rabin' |
39 |
| -interface ProgressHandler { (chunkSize: number, path?: string): void } |
40 |
| -interface HamtHashFn { (value: Uint8Array): Promise<Uint8Array> } |
41 |
| -interface Chunker { (source: AsyncIterable<Uint8Array>, options: ImporterOptions): AsyncIterable<Uint8Array> } |
42 |
| -interface DAGBuilder { (source: AsyncIterable<ImportCandidate> | Iterable<ImportCandidate>, blockstore: Blockstore, options: ImporterOptions): AsyncIterable<() => Promise<InProgressImportResult>> } |
43 |
| -interface TreeBuilder { (source: AsyncIterable<InProgressImportResult>, blockstore: Blockstore, options: ImporterOptions): AsyncIterable<ImportResult> } |
44 |
| -interface BufferImporter { (file: File, blockstore: Blockstore, options: ImporterOptions): AsyncIterable<() => Promise<InProgressImportResult>> } |
45 |
| -interface ChunkValidator { (source: AsyncIterable<Uint8Array>, options: ImporterOptions): AsyncIterable<Uint8Array> } |
46 |
| -interface UnixFSV1DagBuilder<T> { (item: T, blockstore: Blockstore, options: ImporterOptions): Promise<InProgressImportResult> } |
47 |
| -interface Reducer { (leaves: InProgressImportResult[]): Promise<InProgressImportResult> } |
| 38 | +export type ChunkerType = 'fixed' | 'rabin' |
| 39 | +export interface ProgressHandler { (chunkSize: number, path?: string): void } |
| 40 | +export interface HamtHashFn { (value: Uint8Array): Promise<Uint8Array> } |
| 41 | +export interface Chunker { (source: AsyncIterable<Uint8Array>, options: ImporterOptions): AsyncIterable<Uint8Array> } |
| 42 | +export interface DAGBuilder { (source: AsyncIterable<ImportCandidate> | Iterable<ImportCandidate>, blockstore: Blockstore, options: ImporterOptions): AsyncIterable<() => Promise<InProgressImportResult>> } |
| 43 | +export interface TreeBuilder { (source: AsyncIterable<InProgressImportResult>, blockstore: Blockstore, options: ImporterOptions): AsyncIterable<ImportResult> } |
| 44 | +export interface BufferImporter { (file: File, blockstore: Blockstore, options: ImporterOptions): AsyncIterable<() => Promise<InProgressImportResult>> } |
| 45 | +export interface ChunkValidator { (source: AsyncIterable<Uint8Array>, options: ImporterOptions): AsyncIterable<Uint8Array> } |
| 46 | +export interface UnixFSV1DagBuilder<T> { (item: T, blockstore: Blockstore, options: ImporterOptions): Promise<InProgressImportResult> } |
| 47 | +export interface Reducer { (leaves: InProgressImportResult[]): Promise<InProgressImportResult> } |
48 | 48 |
|
49 |
| -interface FileDAGBuilder { (source: AsyncIterable<InProgressImportResult> | Iterable<InProgressImportResult>, reducer: Reducer, options: ImporterOptions): Promise<InProgressImportResult> } |
| 49 | +export interface FileDAGBuilder { (source: AsyncIterable<InProgressImportResult> | Iterable<InProgressImportResult>, reducer: Reducer, options: ImporterOptions): Promise<InProgressImportResult> } |
50 | 50 |
|
51 |
| -interface UserImporterOptions { |
| 51 | +export interface UserImporterOptions { |
52 | 52 | strategy?: 'balanced' | 'flat' | 'trickle'
|
53 | 53 | rawLeaves?: boolean
|
54 | 54 | onlyHash?: boolean
|
@@ -81,7 +81,7 @@ interface UserImporterOptions {
|
81 | 81 | chunkValidator?: ChunkValidator
|
82 | 82 | }
|
83 | 83 |
|
84 |
| -interface ImporterOptions { |
| 84 | +export interface ImporterOptions { |
85 | 85 | strategy: 'balanced' | 'flat' | 'trickle'
|
86 | 86 | rawLeaves: boolean
|
87 | 87 | onlyHash: boolean
|
|
0 commit comments