This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.ts
71 lines (59 loc) · 2.12 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import type { CID } from 'multiformats/cid'
import type { UnixFS } from 'ipfs-unixfs'
import type { PBNode } from '@ipld/dag-pb'
import type { Blockstore } from 'interface-blockstore'
export interface ExporterOptions {
offset?: number
length?: number
signal?: AbortSignal
timeout?: number
blockReadConcurrency?: number
}
export interface Exportable<T> {
type: 'file' | 'directory' | 'object' | 'raw' | 'identity'
name: string
path: string
cid: CID
depth: number
size: number
content: (options?: ExporterOptions) => AsyncIterable<T>
}
export interface UnixFSFile extends Exportable<Uint8Array> {
type: 'file'
unixfs: UnixFS
node: PBNode
}
export interface UnixFSDirectory extends Exportable<UnixFSEntry> {
type: 'directory'
unixfs: UnixFS
node: PBNode
}
export interface ObjectNode extends Exportable<any> {
type: 'object'
node: Uint8Array
}
export interface RawNode extends Exportable<Uint8Array> {
type: 'raw'
node: Uint8Array
}
export interface IdentityNode extends Exportable<Uint8Array> {
type: 'identity'
node: Uint8Array
}
export type UnixFSEntry = UnixFSFile | UnixFSDirectory | ObjectNode | RawNode | IdentityNode
export interface NextResult {
cid: CID
name: string
path: string
toResolve: string[]
}
export interface ResolveResult {
entry: UnixFSEntry
next?: NextResult
}
export interface Resolve { (cid: CID, name: string, path: string, toResolve: string[], depth: number, blockstore: Blockstore, options: ExporterOptions): Promise<ResolveResult> }
export interface Resolver { (cid: CID, name: string, path: string, toResolve: string[], resolve: Resolve, depth: number, blockstore: Blockstore, options: ExporterOptions): Promise<ResolveResult> }
export type UnixfsV1FileContent = AsyncIterable<Uint8Array> | Iterable<Uint8Array>
export type UnixfsV1DirectoryContent = AsyncIterable<UnixFSEntry> | Iterable<UnixFSEntry>
export type UnixfsV1Content = UnixfsV1FileContent | UnixfsV1DirectoryContent
export interface UnixfsV1Resolver { (cid: CID, node: PBNode, unixfs: UnixFS, path: string, resolve: Resolve, depth: number, blockstore: Blockstore): (options: ExporterOptions) => UnixfsV1Content }