Skip to content

fixed all eslint warnings in root #2378

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
267 changes: 133 additions & 134 deletions @types/ipfs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,95 +4,91 @@ declare module 'ipfs' {
import type { Buffer } from 'buffer'
import type { KuboRPCClient } from 'kubo-rpc-client'

declare export interface IPFSService extends CoreService {
pin: PinService;
files: FileService;
name: NameService;
object: ObjectService;
config: ConfigService;
dag: KuboRPCClient['dag'];

stop(options?: TimeoutOptions): Promise<void>
}

declare export interface CoreService {
// TODO: cat returns AsyncIterable<Uint8Array>. see https://github.com/ipfs/js-kubo-rpc-client/blob/1ab7941819dd1a48df653ee159e6983608e72132/src/index.ts#L353C50-L353C75
cat(pathOrCID: string | CID, options?: CatOptions): AsyncIterable<Buffer>;
ls(pathOrCID: string | CID, options?: ListOptions): AsyncIterable<ListEntry>;
add(file: FileContent | FileObject, options?: AddOptions): Promise<UnixFSEntry>;
addAll(files: Iterable<FileContent | FileObject> | AsyncIterable<FileContent | FileObject> | ReadableStream<FileContent | FileObject>, options?: AddOptions): AsyncIterable<UnixFSEntry>;
}

declare export interface PinService {
add(cid: CID, options?: PinAddOptions): Promise<Pin[]>;
ls(options?: PinListOptions): AsyncIterable<PinEntry>;
rm(cid: CID, options?: PinRemoveOptions): Promise<Pin[]>;
remote: RemotePinService;
declare export type UnixFSTime = {
secs: number,
nsecs: number
}

declare export interface RemotePinServicesOptions {
cid: CID[];
service: string;
}
declare export interface RemotePinService {
rm(options: RemotePinServicesOptions): Promise<boolean>;
declare export type UnixFSEntry = {
path: string,
cid: CID,
mode: number,
mtime: UnixFSTime,
size: number
}

declare export interface FileService {
stat(path: string, options?: FSStatOptions): Promise<FileStat>;
cp(from: string, to: string, options?: FSCopyOptions): Promise<void>;
mv(from: string, to: string, options?: FSMoveOptions): Promise<void>;
rm(path: string, options: FSRemoveOptions): Promise<void>;
mkdir(path: string, options: FSMakDirectoryOptions): Promise<void>;
}
declare type FileContent =
| Uint8Array
| Blob
| String
| AsyncIterable<Uint8Array>
| ReadableStream<Uint8Array>

declare export interface ConfigService {
get(key: string, options?: TimeoutOptions): Promise<Object>;
getAll(options?: TimeoutOptions): Promise<Object>;
set(key: string, value: string | number | null | boolean | Object, options?: TimeoutOptions): Promise<void>;
replace(config: Object, options?: TimeoutOptions): Promise<void>;
declare export type FileType =
| 'file'
| 'directory'

profiles: ConfigProfiles;
declare type FileObject = {
path?: string,
content?: FileContent,
mode?: number | string,
mtime?: Date | UnixFSTime | [number, number]
}

declare export interface ConfigProfiles {
list(options?: TimeoutOptions): Promise<Array<{ name: string, description: string }>>;
apply(name: string, options?: { dryRun?: boolean } & TimeoutOptions): Promise<{ original: Object, updated: Object }>;
declare export type TimeoutOptions = {
timeout?: number,
signal?: AbortSignal
}

declare export interface NameService {
resolve(value: string, options?: NameResloveOptions): AsyncIterable<string>
}
declare export type ListOptions = TimeoutOptions & {}

declare export interface SwarmService {
connect(addr: Multiaddr, options?: TimeoutOptions): Promise<void>
declare export type CatOptions = TimeoutOptions & {
offset?: number;
length?: number;
}

declare export interface ObjectService {
new: (options?: ObjectNewOptions) => Promise<CID>;
patch: ObjectPatchService
declare type LoadProgress = {
total: number,
loaded: number,
lengthComputable: boolean
}

declare export interface ObjectPatchService {
addLink(cid: CID, link: DAGLink, options?: TimeoutOptions): Promise<CID>
declare export type AddOptions = TimeoutOptions & {
chunker?: string,
cidVersion?: number,
hashAlg?: number,
onlyHash?: boolean,
pin?: boolean,
progress?: (bytes: number, name:string) => void,
rawLeaves?: boolean,
trickle?: boolean,
wrapWithDirectory?: boolean,
onUploadProgress?: (progress: LoadProgress) => void,
onDownloadProgress?: (progress: LoadProgress) => void
}

declare export type DAGLink = {
declare export type ListEntry = {
depth: number,
name: string,
path: string,
size: number,
cid: CID
cid: CID,
// IPFS is pretty inconsistent with type field see
// https://github.com/ipfs/js-ipfs/issues/3229
type: FileType | 'dir',
mode: number,
mtime: { secs: number, nsecs?: number }
}

declare export type Pin = { cid: CID }

declare export type TimeoutOptions = {
timeout?: number,
signal?: AbortSignal
declare export interface CoreService {
// TODO: cat returns AsyncIterable<Uint8Array>. see https://github.com/ipfs/js-kubo-rpc-client/blob/1ab7941819dd1a48df653ee159e6983608e72132/src/index.ts#L353C50-L353C75
cat(pathOrCID: string | CID, options?: CatOptions): AsyncIterable<Buffer>;
ls(pathOrCID: string | CID, options?: ListOptions): AsyncIterable<ListEntry>;
add(file: FileContent | FileObject, options?: AddOptions): Promise<UnixFSEntry>;
addAll(files: Iterable<FileContent | FileObject> | AsyncIterable<FileContent | FileObject> | ReadableStream<FileContent | FileObject>, options?: AddOptions): AsyncIterable<UnixFSEntry>;
}

declare export type PinAddOptions = TimeoutOptions & {
recursive?: boolean,
}
declare export type Pin = { cid: CID }

declare export type PinType =
| 'recursive'
Expand All @@ -113,12 +109,43 @@ declare module 'ipfs' {
recursive?: boolean
}

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

declare export interface RemotePinServicesOptions {
cid: CID[];
service: string;
}

declare export interface RemotePinService {
rm(options: RemotePinServicesOptions): Promise<boolean>;
}

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

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

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

declare export type FSCopyOptions = TimeoutOptions & {
parents?: boolean,
flush?: boolean,
Expand Down Expand Up @@ -149,100 +176,72 @@ declare module 'ipfs' {
cidVersion?: number
}

declare export type FileType =
| 'file'
| 'directory'

declare export interface FileStat {
cid: CID;
size: number;
cumulativeSize: number;
type: FileType;
blocks: number;
withLocality: boolean;
local: boolean;
sizeLocal: number;
declare export interface FileService {
stat(path: string, options?: FSStatOptions): Promise<FileStat>;
cp(from: string, to: string, options?: FSCopyOptions): Promise<void>;
mv(from: string, to: string, options?: FSMoveOptions): Promise<void>;
rm(path: string, options: FSRemoveOptions): Promise<void>;
mkdir(path: string, options: FSMakDirectoryOptions): Promise<void>;
}

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

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

declare export type ObjectNewOptions = TimeoutOptions & {
template?: string,
recursive?: boolean,
nocache?: boolean
}

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

declare export type ListOptions = TimeoutOptions & {

}

declare export type ListEntry = {
depth: number,
declare export type DAGLink = {
name: string,
path: string,
size: number,
cid: CID,
// IPFS is pretty inconsistent with type field see
// https://github.com/ipfs/js-ipfs/issues/3229
type: FileType | 'dir',
mode: number,
mtime: { secs: number, nsecs?: number }
cid: CID
}

declare type FileContent =
| Uint8Array
| Blob
| String
| AsyncIterable<Uint8Array>
| ReadableStream<Uint8Array>
declare export interface ObjectPatchService {
addLink(cid: CID, link: DAGLink, options?: TimeoutOptions): Promise<CID>
}

declare type FileObject = {
path?: string,
content?: FileContent,
mode?: number | string,
mtime?: Date | UnixFSTime | [number, number]
declare export interface ObjectService {
new: (options?: ObjectNewOptions) => Promise<CID>;
patch: ObjectPatchService
}

declare export type AddOptions = TimeoutOptions & {
chunker?: string,
cidVersion?: number,
hashAlg?: number,
onlyHash?: boolean,
pin?: boolean,
progress?: (bytes: number, name:string) => void,
rawLeaves?: boolean,
trickle?: boolean,
wrapWithDirectory?: boolean,
onUploadProgress?: (progress: LoadProgress) => void,
onDownloadProgress?: (progress: LoadProgress) => void
declare export interface ConfigProfiles {
list(options?: TimeoutOptions): Promise<Array<{ name: string, description: string }>>;
apply(name: string, options?: { dryRun?: boolean } & TimeoutOptions): Promise<{ original: Object, updated: Object }>;
}

declare type LoadProgress = {
total: number,
loaded: number,
lengthComputable: boolean
declare export interface ConfigService {
get(key: string, options?: TimeoutOptions): Promise<Object>;
getAll(options?: TimeoutOptions): Promise<Object>;
set(key: string, value: string | number | null | boolean | Object, options?: TimeoutOptions): Promise<void>;
replace(config: Object, options?: TimeoutOptions): Promise<void>;

profiles: ConfigProfiles;
}

declare export type UnixFSEntry = {
path: string,
cid: CID,
mode: number,
mtime: UnixFSTime,
size: number
declare export interface IPFSService extends CoreService {
pin: PinService;
files: FileService;
name: NameService;
object: ObjectService;
config: ConfigService;
dag: KuboRPCClient['dag'];

stop(options?: TimeoutOptions): Promise<void>
}

declare export type UnixFSTime = {
secs: number,
nsecs: number
declare export interface SwarmService {
connect(addr: Multiaddr, options?: TimeoutOptions): Promise<void>
}

declare export var IPFS: IPFSService
declare export let IPFS: IPFSService
}
4 changes: 2 additions & 2 deletions @types/it-all/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module "it-all" {
declare module 'it-all' {
function all<T>(source: AsyncIterable<T>): Promise<T[]>

export default all
}
}
2 changes: 1 addition & 1 deletion @types/it-first/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module "it-first" {
declare module 'it-first' {
function first<T>(input: AsyncIterable<T>): Promise<T>

export default first
Expand Down
4 changes: 2 additions & 2 deletions @types/it-last/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module "it-last" {
declare module 'it-last' {
function last<T>(input: AsyncIterable<T>): Promise<T>

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