-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: declare types in .ts files (#168)
`.d.ts` files are not type checked as they are usually machine generated. Switch to using `.ts` files instead so we get some compiler safety. Refs: ipfs/aegir#849
- Loading branch information
1 parent
2713329
commit 76ec6e5
Showing
4 changed files
with
93 additions
and
93 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
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 | ||
} | ||
|
||
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.