ts / dist / esm / ipfs.d.ts
1,543 words
  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
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
/**
 * IPFS pinning, direct uploads, IPNS names and customer gateway domains
 * (which can serve your pins directly at /ipfs/<cid>). Prepaid hourly
 * billing per pinned MiB plus gateway egress; deletes are always free. The
 * standard IPFS Pinning Service API lives in `pins`.
 *
 * For uploading local content use `addFile`, which drives the whole
 * grant → upload → pin flow.
 */
import type { Client } from './client.js';
import * as http from './http.js';
import type { Body, Query, Res } from './types.js';
/** GET /ipfs/pins — List your pins (offset-paginated). */
export declare const listPins: (client: Client, query?: Query<"/ipfs/pins", "get">) => Promise<{
    pins: {
        cid: string | null;
        cid_v1: string | null;
        created_at: string | null;
        gateway_url: string | null;
        id: string;
        last_error: string | null;
        meta: {
            [key: string]: string;
        };
        name: string | null;
        size_bytes: number | null;
        state: "awaiting-upload" | "queued" | "pinning" | "pinned" | "failed" | "deleting";
        updated_at: string | null;
    }[];
    total: number;
}>;
/** Every pin, following offset pagination (page `limit` defaults to 100). */
export declare const listAllPins: (client: Client, query?: Query<"/ipfs/pins", "get">) => Promise<readonly {
    cid: string | null;
    cid_v1: string | null;
    created_at: string | null;
    gateway_url: string | null;
    id: string;
    last_error: string | null;
    meta: {
        [key: string]: string;
    };
    name: string | null;
    size_bytes: number | null;
    state: "awaiting-upload" | "queued" | "pinning" | "pinned" | "failed" | "deleting";
    updated_at: string | null;
}[]>;
/** POST /ipfs/pins — Pin by CID (202; billing starts once pinned). */
export declare const pin: (client: Client, body: Body<"/ipfs/pins", "post">) => Promise<{
    pin: {
        cid: string | null;
        cid_v1: string | null;
        created_at: string | null;
        gateway_url: string | null;
        id: string;
        last_error: string | null;
        meta: {
            [key: string]: string;
        };
        name: string | null;
        size_bytes: number | null;
        state: "awaiting-upload" | "queued" | "pinning" | "pinned" | "failed" | "deleting";
        updated_at: string | null;
    };
}>;
/** GET /ipfs/pins/{id} — Pin detail. */
export declare const getPin: (client: Client, id: string) => Promise<{
    pin: {
        cid: string | null;
        cid_v1: string | null;
        created_at: string | null;
        gateway_url: string | null;
        id: string;
        last_error: string | null;
        meta: {
            [key: string]: string;
        };
        name: string | null;
        size_bytes: number | null;
        state: "awaiting-upload" | "queued" | "pinning" | "pinned" | "failed" | "deleting";
        updated_at: string | null;
    };
}>;
/** DELETE /ipfs/pins/{id} — Unpin (202; free). */
export declare const unpin: (client: Client, id: string) => Promise<{
    deleted: boolean;
}>;
/**
 * POST /ipfs/uploads — Start a direct upload. Issues a short-lived
 * single-use grant `{ upload: { url, token, ... } }`; POST the raw bytes to
 * that URL (see `http.uploadBytes`) then poll `getUpload`.
 */
export declare const startUpload: (client: Client, body?: Body<"/ipfs/uploads", "post">) => Promise<{
    upload: {
        cid: string | null;
        error: string | null;
        expires_at: string | null;
        id: string;
        max_bytes: number;
        pin_id: string;
        size_bytes: number | null;
        status: "issued" | "completed" | "failed" | "expired";
        token: string | null;
        url: string;
    };
}>;
/** GET /ipfs/uploads/{id} — Upload status (issued/completed/failed/expired). */
export declare const getUpload: (client: Client, id: string) => Promise<{
    upload: {
        cid: string | null;
        error: string | null;
        expires_at: string | null;
        id: string;
        max_bytes: number;
        pin_id: string;
        size_bytes: number | null;
        status: "issued" | "completed" | "failed" | "expired";
        token: string | null;
        url: string;
    };
}>;
/** GET /ipfs/names — List your IPNS names. */
export declare const listNames: (client: Client) => Promise<{
    names: {
        created_at: string | null;
        id: string;
        label: string;
        last_error: string | null;
        last_published_at: string | null;
        last_published_cid: string | null;
        name: string | null;
        state: "creating" | "active" | "failed" | "deleting";
        target_cid: string | null;
        target_url: string | null;
        updated_at: string | null;
        url: string | null;
    }[];
}>;
/** POST /ipfs/names — Create an IPNS name. */
export declare const createName: (client: Client, body?: Body<"/ipfs/names", "post">) => Promise<{
    domain?: {
        created_at: string | null;
        delegated?: boolean;
        dns_target?: string;
        dnslink_hint: string;
        domain: string;
        id: string;
        ipns_name_id: string | null;
        last_error: string | null;
        pin_count: number;
        state: "pending" | "active" | "failed" | "deleting";
        updated_at: string | null;
        verified_at: string | null;
    };
    name: {
        created_at: string | null;
        id: string;
        label: string;
        last_error: string | null;
        last_published_at: string | null;
        last_published_cid: string | null;
        name: string | null;
        state: "creating" | "active" | "failed" | "deleting";
        target_cid: string | null;
        target_url: string | null;
        updated_at: string | null;
        url: string | null;
    };
}>;
/** GET /ipfs/names/{id} — IPNS name detail. */
export declare const getName: (client: Client, id: string) => Promise<{
    name: {
        created_at: string | null;
        id: string;
        label: string;
        last_error: string | null;
        last_published_at: string | null;
        last_published_cid: string | null;
        name: string | null;
        state: "creating" | "active" | "failed" | "deleting";
        target_cid: string | null;
        target_url: string | null;
        updated_at: string | null;
        url: string | null;
    };
}>;
/** DELETE /ipfs/names/{id} — Delete an IPNS name (202). */
export declare const deleteName: (client: Client, id: string) => Promise<{
    deleted: boolean;
}>;
/** PUT /ipfs/names/{id}/target — Publish a new target for an IPNS name. */
export declare const publishTarget: (client: Client, id: string, body: Body<"/ipfs/names/{id}/target", "put">) => Promise<{
    name: {
        created_at: string | null;
        id: string;
        label: string;
        last_error: string | null;
        last_published_at: string | null;
        last_published_cid: string | null;
        name: string | null;
        state: "creating" | "active" | "failed" | "deleting";
        target_cid: string | null;
        target_url: string | null;
        updated_at: string | null;
        url: string | null;
    };
}>;
/** GET /ipfs/domains — List your gateway domains. */
export declare const listDomains: (client: Client) => Promise<{
    domains: {
        created_at: string | null;
        delegated?: boolean;
        dns_target?: string;
        dnslink_hint: string;
        domain: string;
        id: string;
        ipns_name_id: string | null;
        last_error: string | null;
        pin_count: number;
        state: "pending" | "active" | "failed" | "deleting";
        updated_at: string | null;
        verified_at: string | null;
    }[];
}>;
/**
 * POST /ipfs/domains — Attach your own domain as an IPFS gateway. Gated on
 * `domain`. The response's `dns_target` is the gateway IPv4 the domain's A
 * record must point at on manually mapped rows.
 */
export declare const attachDomain: (client: Client, body: Body<"/ipfs/domains", "post">) => Promise<{
    domain: {
        created_at: string | null;
        delegated?: boolean;
        dns_target?: string;
        dnslink_hint: string;
        domain: string;
        id: string;
        ipns_name_id: string | null;
        last_error: string | null;
        pin_count: number;
        state: "pending" | "active" | "failed" | "deleting";
        updated_at: string | null;
        verified_at: string | null;
    };
}>;
/** GET /ipfs/domains/{id} — Gateway domain detail. */
export declare const getDomain: (client: Client, id: string) => Promise<{
    domain: {
        created_at: string | null;
        delegated?: boolean;
        dns_target?: string;
        dnslink_hint: string;
        domain: string;
        id: string;
        ipns_name_id: string | null;
        last_error: string | null;
        pin_count: number;
        state: "pending" | "active" | "failed" | "deleting";
        updated_at: string | null;
        verified_at: string | null;
    };
}>;
/** GET /ipfs/domains/{id}/pins — The pins a gateway domain serves, oldest attachment first. */
export declare const listDomainPins: (client: Client, id: string, query?: Query<"/ipfs/domains/{id}/pins", "get">) => Promise<{
    limit: number;
    offset: number;
    pins: {
        attached_at: string | null;
        cid: string | null;
        cid_v1: string | null;
        id: string;
        name: string | null;
        state: string;
    }[];
    total: number;
}>;
/** Every pin a gateway domain serves, following offset pagination. */
export declare const listAllDomainPins: (client: Client, id: string, query?: Query<"/ipfs/domains/{id}/pins", "get">) => Promise<readonly {
    attached_at: string | null;
    cid: string | null;
    cid_v1: string | null;
    id: string;
    name: string | null;
    state: string;
}[]>;
/**
 * POST /ipfs/domains/{id}/pins — Attach or detach the pins a gateway
 * domain serves (`add` / `remove` pin ids; idempotent delta). Gated on the
 * gateway's domain (resolved via `getDomain` when a gate is set).
 */
export declare const updateDomainPins: (client: Client, id: string, body: Body<"/ipfs/domains/{id}/pins", "post">) => Promise<{
    domain: {
        created_at: string | null;
        delegated?: boolean;
        dns_target?: string;
        dnslink_hint: string;
        domain: string;
        id: string;
        ipns_name_id: string | null;
        last_error: string | null;
        pin_count: number;
        state: "pending" | "active" | "failed" | "deleting";
        updated_at: string | null;
        verified_at: string | null;
    };
}>;
/** DELETE /ipfs/domains/{id} — Detach a gateway domain (202). Gated on the gateway's domain. */
export declare const detachDomain: (client: Client, id: string) => Promise<{
    deleted: boolean;
}>;
/** GET /ipfs/usage — Storage usage and cost. */
export declare const usage: (client: Client) => Promise<{
    usage: {
        hourly_cost: string;
        monthly_estimate: string;
        per_mb_hour: string;
        per_mb_served: string;
        pinned_bytes: number;
        served_bytes_period: number;
    };
}>;
export type Upload = Res<'/ipfs/uploads/{id}', 'get'>['upload'];
export type AddFileOptions = Readonly<{
    /** Display name for the pin. */
    name?: string;
    /** 'file' (default) or 'car' for a client-packed CAR archive. */
    format?: 'file' | 'car';
    /** string → string metadata. */
    meta?: Readonly<Record<string, string>>;
    /** Initial poll interval (default 1000, backing off to an 8 s cap). */
    intervalMs?: number;
    /** Overall deadline (default 300000). */
    timeoutMs?: number;
}>;
/**
 * Upload local content to IPFS end to end: start an upload grant, POST the
 * bytes to the grant URL, poll until the upload completes, and return the
 * final upload (with `cid` and `pin_id`). SOURCE is a file path, bytes, a
 * Blob, or a ReadableStream. Throws an uploadFailed error when the upload
 * fails or expires, or a timeout error when the deadline passes first.
 */
export declare const addFile: (client: Client, source: string | http.UploadSource, options?: AddFileOptions) => Promise<Upload>;

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/ts.git