Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ipfs update #1568

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions @types/ipfs/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
declare module "ipfs" {
import CID from "cids"
import Multiaddr from 'multiaddr'

interface IPFSService extends CoreService {
pin: PinService
files: FileService
name: NameService
}

interface CoreService {
cat(pathOrCID: string | CID, options?: CatOptions): AsyncIterable<Buffer>
ls(pathOrCID: string | CID, options?: ListOptions): AsyncIterable<ListEntry>
}

interface PinService {
add(cid: CID, options?: PinAddOptions): Promise<Pin[]>
ls(options?: PinListOptions): AsyncIterable<PinEntry>
rm(cid: CID, options?: PinRemoveOptions): Promise<Pin[]>
}

interface FileService {
stat(path: string, options?: FSStatOptions): Promise<FileStat>
}

interface NameService {
resolve(value: string, options?: NameResloveOptions): AsyncIterable<string>
}

interface SwarmService {
connect(addr: Multiaddr, options?: TimeoutOptions): Promise<void>
}


type Pin = { cid: CID }

type TimeoutOptions = {
timeout?: number,
signal?: AbortSignal
}

type PinAddOptions = TimeoutOptions & {
recursive?: boolean,
}

type PinType =
| "recursive"
| "direct"
| "indirect"

type PinEntry = {
cid: CID,
typ: PinType
}

type PinListOptions = TimeoutOptions & {
paths?: string | CID | string[] | CID[],
type?: PinType
}

type PinRemoveOptions = TimeoutOptions & {
recursive?: boolean
}



type FSStatOptions = TimeoutOptions & {
hash?: boolean,
size?: boolean,
withLocal?: boolean
}

type FileType =
| 'file'
| 'directory'

interface FileStat {
cid: CID
size: number
cumulativeSize: number
type: FileType
blocks: number
withLocality: boolean
local: boolean
sizeLocal: number
}


type NameResloveOptions = TimeoutOptions & {
recursive?: boolean,
nocache?: boolean
}

type CatOptions = TimeoutOptions & {
offset?: number
length?: number
}

type ListOptions = TimeoutOptions & {

}

type ListEntry = {
depth: number,
name: string,
path: string,
size: number,
cid: CID,
type: FileType,
mode: number,
mtime: { secs: number, nsecs?: number }
}


export { IPFSService, CoreService, PinService, FileService, NameService, CID, Pin }
declare var ipfs: IPFSService
declare export default ipfs
}
5 changes: 5 additions & 0 deletions @types/it-last/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module "it-last" {
declare function last<T>(input: AsyncIterable<T>): Promise<T>

export default last
}
4 changes: 4 additions & 0 deletions @types/it-map/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "it-map" {
declare function map<I, O>(input: AsyncIterable<I>, f: (input: I) => O): AsyncIterable<O>
declare export default map
}
184 changes: 141 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading