pinata 1.10.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -6,22 +6,52 @@ type PinataConfig = {
6
6
  endpointUrl?: string;
7
7
  uploadUrl?: string;
8
8
  };
9
- type AuthTestResponse = {
10
- message: string;
9
+
10
+ type AnalyticsQuery = {
11
+ gateway_domain: string;
12
+ start_date: string;
13
+ end_date: string;
14
+ cid?: string;
15
+ file_name?: string;
16
+ user_agent?: string;
17
+ country?: string;
18
+ region?: string;
19
+ referer?: string;
20
+ limit?: number;
21
+ sort_order?: "asc" | "desc";
11
22
  };
12
- type UploadResponse = {
13
- id: string;
14
- name: string;
15
- cid: string;
16
- size: number;
17
- created_at: string;
18
- number_of_files: number;
19
- mime_type: string;
20
- user_id: string;
21
- group_id: string | null;
22
- is_duplicate: true | null;
23
- vectorized: true | null;
23
+ type TopAnalyticsQuery = AnalyticsQuery & {
24
+ sort_by: "requests" | "bandwidth";
25
+ attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name";
26
+ };
27
+ type TopAnalyticsResponse = {
28
+ data: TopAnalyticsItem[];
29
+ };
30
+ type TopAnalyticsItem = {
31
+ value: string;
32
+ requests: number;
33
+ bandwidth: number;
34
+ };
35
+ type TimeIntervalAnalyticsQuery = AnalyticsQuery & {
36
+ sort_by?: "requests" | "bandwidth";
37
+ date_interval: "day" | "week";
38
+ };
39
+ type TimePeriodItem = {
40
+ period_start_time: string;
41
+ requests: number;
42
+ bandwidth: number;
43
+ };
44
+ type TimeIntervalAnalyticsResponse = {
45
+ total_requests: number;
46
+ total_bandwidth: number;
47
+ time_periods: TimePeriodItem[];
24
48
  };
49
+ type UserPinnedDataResponse = {
50
+ pin_count: number;
51
+ pin_size_total: number;
52
+ pin_size_with_replications_total: number;
53
+ };
54
+
25
55
  type FileObject = {
26
56
  name: string;
27
57
  size: number;
@@ -39,13 +69,6 @@ type UpdateFileOptions = {
39
69
  name?: string;
40
70
  keyvalues?: Record<string, string>;
41
71
  };
42
- type UploadOptions = {
43
- metadata?: PinataMetadata;
44
- keys?: string;
45
- groupId?: string;
46
- vectorize?: boolean;
47
- url?: string;
48
- };
49
72
  type DeleteResponse = {
50
73
  id: string;
51
74
  status: string;
@@ -77,16 +100,17 @@ type FileListQuery = {
77
100
  limit?: number;
78
101
  pageToken?: string;
79
102
  };
80
- type PinJobQuery = {
103
+ type PinQueueQuery = {
81
104
  sort?: "ASC" | "DSC";
82
105
  status?: "prechecking" | "retrieving" | "expired" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node";
83
- ipfs_pin_hash?: string;
106
+ cid?: string;
84
107
  limit?: number;
85
- offset?: number;
108
+ pageToken?: string;
86
109
  };
87
- type PinJobItem = {
110
+ type PinQueueItem = {
88
111
  id: string;
89
- ipfs_pin_hash: string;
112
+ cid?: string;
113
+ ipfs_pin_hash?: string;
90
114
  date_queued: string;
91
115
  name: string;
92
116
  status: string;
@@ -100,9 +124,40 @@ type PinJobItem = {
100
124
  version: number;
101
125
  };
102
126
  };
103
- type PinJobResponse = {
104
- rows: PinJobItem[];
127
+ type PinQueueResponse = {
128
+ rows: PinQueueItem[];
129
+ next_page_token: string;
130
+ };
131
+ type SwapCidOptions = {
132
+ cid: string;
133
+ swapCid: string;
134
+ };
135
+ type SwapHistoryOptions = {
136
+ cid: string;
137
+ domain: string;
138
+ };
139
+ type SwapCidResponse = {
140
+ mapped_cid: string;
141
+ created_at: string;
142
+ };
143
+ type VectorizeFileResponse = {
144
+ status: boolean;
145
+ };
146
+ type VectorizeQuery = {
147
+ groupId: string;
148
+ query: string;
149
+ returnFile?: boolean;
150
+ };
151
+ type VectorQueryMatch = {
152
+ file_id: string;
153
+ cid: string;
154
+ score: number;
155
+ };
156
+ type VectorizeQueryResponse = {
157
+ count: number;
158
+ matches: VectorQueryMatch[];
105
159
  };
160
+
106
161
  type ContentType = "application/json" | "application/xml" | "text/plain" | "text/html" | "text/css" | "text/javascript" | "application/javascript" | "image/jpeg" | "image/png" | "image/gif" | "image/svg+xml" | "audio/mpeg" | "audio/ogg" | "video/mp4" | "application/pdf" | "application/octet-stream" | string | null;
107
162
  type GetCIDResponse = {
108
163
  data?: JSON | string | Blob | null;
@@ -121,56 +176,54 @@ type OptimizeImageOptions = {
121
176
  onError?: boolean;
122
177
  metadata?: "keep" | "copyright" | "none";
123
178
  };
124
- type SignedUrlOptions = {
179
+ type AccessLinkOptions = {
125
180
  cid: string;
126
181
  date?: number;
127
182
  expires: number;
128
183
  gateway?: string;
129
184
  };
130
- type AnalyticsQuery = {
131
- gateway_domain: string;
132
- start_date: string;
133
- end_date: string;
134
- cid?: string;
135
- file_name?: string;
136
- user_agent?: string;
137
- country?: string;
138
- region?: string;
139
- referer?: string;
140
- limit?: number;
141
- sort_order?: "asc" | "desc";
185
+ type ContainsCIDResponse = {
186
+ containsCid: boolean;
187
+ cid: string | null;
142
188
  };
143
- type TopAnalyticsQuery = AnalyticsQuery & {
144
- sort_by: "requests" | "bandwidth";
145
- attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name";
189
+
190
+ type GroupOptions = {
191
+ name: string;
192
+ isPublic?: boolean;
146
193
  };
147
- type TopAnalyticsResponse = {
148
- data: TopAnalyticsItem[];
194
+ type UpdateGroupOptions = {
195
+ groupId: string;
196
+ name?: string;
197
+ isPublic?: boolean;
149
198
  };
150
- type TopAnalyticsItem = {
151
- value: string;
152
- requests: number;
153
- bandwidth: number;
199
+ type GetGroupOptions = {
200
+ groupId: string;
154
201
  };
155
- type TimeIntervalAnalyticsQuery = AnalyticsQuery & {
156
- sort_by?: "requests" | "bandwidth";
157
- date_interval: "day" | "week";
202
+ type GroupListResponse = {
203
+ groups: GroupResponseItem[];
204
+ next_page_token: string;
158
205
  };
159
- type TimePeriodItem = {
160
- period_start_time: string;
161
- requests: number;
162
- bandwidth: number;
206
+ type GroupResponseItem = {
207
+ id: string;
208
+ is_public: boolean;
209
+ name: string;
210
+ createdAt: string;
163
211
  };
164
- type TimeIntervalAnalyticsResponse = {
165
- total_requests: number;
166
- total_bandwidth: number;
167
- time_periods: TimePeriodItem[];
212
+ type GroupQueryOptions = {
213
+ name?: string;
214
+ limit?: number;
215
+ pageToken?: string;
216
+ isPublic?: boolean;
168
217
  };
169
- type UserPinnedDataResponse = {
170
- pin_count: number;
171
- pin_size_total: number;
172
- pin_size_with_replications_total: number;
218
+ type GroupCIDOptions = {
219
+ groupId: string;
220
+ files: string[];
221
+ };
222
+ type UpdateGroupFilesResponse = {
223
+ id: string;
224
+ status: string;
173
225
  };
226
+
174
227
  type KeyPermissions = {
175
228
  admin?: boolean;
176
229
  endpoints?: Endpoints;
@@ -240,82 +293,39 @@ type RevokeKeyResponse = {
240
293
  key: string;
241
294
  status: string;
242
295
  };
243
- type GroupOptions = {
244
- name: string;
245
- isPublic?: boolean;
246
- };
247
- type UpdateGroupOptions = {
248
- groupId: string;
249
- name?: string;
250
- isPublic?: boolean;
251
- };
252
- type GetGroupOptions = {
253
- groupId: string;
254
- };
255
- type GroupListResponse = {
256
- groups: GroupResponseItem[];
257
- next_page_token: string;
258
- };
259
- type GroupResponseItem = {
260
- id: string;
261
- is_public: boolean;
262
- name: string;
263
- createdAt: string;
264
- };
265
- type GroupQueryOptions = {
266
- name?: string;
267
- limit?: number;
268
- pageToken?: string;
269
- isPublic?: boolean;
270
- };
271
- type GroupCIDOptions = {
272
- groupId: string;
273
- files: string[];
274
- };
275
- type UpdateGroupFilesResponse = {
276
- id: string;
277
- status: string;
278
- };
296
+
279
297
  type SignatureOptions = {
280
298
  cid: string;
281
299
  signature: string;
300
+ address: string;
282
301
  };
283
302
  type SignatureResponse = {
284
303
  cid: string;
285
304
  signature: string;
286
305
  };
287
- type SwapCidOptions = {
288
- cid: string;
289
- swapCid: string;
290
- };
291
- type SwapHistoryOptions = {
306
+
307
+ type UploadResponse = {
308
+ id: string;
309
+ name: string;
292
310
  cid: string;
293
- domain: string;
294
- };
295
- type SwapCidResponse = {
296
- mapped_cid: string;
311
+ size: number;
297
312
  created_at: string;
313
+ number_of_files: number;
314
+ mime_type: string;
315
+ group_id: string | null;
316
+ keyvalues: {
317
+ [key: string]: string;
318
+ };
319
+ vectorized: boolean;
320
+ network: string;
298
321
  };
299
- type ContainsCIDResponse = {
300
- containsCid: boolean;
301
- cid: string | null;
302
- };
303
- type VectorizeFileResponse = {
304
- status: boolean;
305
- };
306
- type VectorizeQuery = {
307
- groupId: string;
308
- query: string;
309
- returnFile?: boolean;
310
- };
311
- type VectorQueryMatch = {
312
- file_id: string;
313
- cid: string;
314
- score: number;
315
- };
316
- type VectorizeQueryResponse = {
317
- count: number;
318
- matches: VectorQueryMatch[];
322
+ type UploadOptions = {
323
+ metadata?: PinataMetadata;
324
+ keys?: string;
325
+ groupId?: string;
326
+ vectorize?: boolean;
327
+ url?: string;
328
+ peerAddresses?: string[];
319
329
  };
320
330
  type SignedUploadUrlOptions = {
321
331
  date?: number;
@@ -325,104 +335,216 @@ type SignedUploadUrlOptions = {
325
335
  keyvalues?: Record<string, string>;
326
336
  vectorize?: boolean;
327
337
  };
328
-
329
- declare class PinataSDK {
330
- config: PinataConfig | undefined;
331
- files: Files;
332
- upload: Upload;
333
- gateways: Gateways;
334
- keys: Keys;
335
- groups: Groups;
336
- analytics: Analytics;
338
+ type UploadCIDOptions = {
339
+ metadata?: PinataMetadata;
340
+ peerAddresses?: string[];
341
+ keys?: string;
342
+ groupId?: string;
343
+ };
344
+ type PinByCIDResponse = {
345
+ id: string;
346
+ cid: string;
347
+ date_queued: string;
348
+ name: string;
349
+ status: string;
350
+ keyvalues: Record<string, any> | null;
351
+ host_nodes: string[] | null;
352
+ group_id: string | null;
353
+ };
354
+
355
+ declare const analyticsDateInterval: (config: PinataConfig | undefined, options?: TimeIntervalAnalyticsQuery) => Promise<TimeIntervalAnalyticsResponse>;
356
+
357
+ declare const analyticsTopUsage: (config: PinataConfig | undefined, options?: TopAnalyticsQuery) => Promise<TopAnalyticsResponse>;
358
+
359
+ declare const testAuthentication: (config: PinataConfig | undefined) => Promise<string>;
360
+
361
+ declare const deleteFile: (config: PinataConfig | undefined, files: string[], privacy: "public" | "private") => Promise<DeleteResponse[]>;
362
+
363
+ declare const deleteFileVectors: (config: PinataConfig | undefined, fileId: string) => Promise<VectorizeFileResponse>;
364
+
365
+ declare const deleteSwap: (config: PinataConfig | undefined, cid: string, network: "public" | "private") => Promise<string>;
366
+
367
+ declare const listFiles: (config: PinataConfig | undefined, privacy: "private" | "public", options?: FileListQuery) => Promise<FileListResponse>;
368
+
369
+ declare const pinnedFileCount: (config: PinataConfig | undefined) => Promise<number>;
370
+
371
+ declare const swapCid: (config: PinataConfig | undefined, options: SwapCidOptions, network: "public" | "private") => Promise<SwapCidResponse>;
372
+
373
+ declare const swapHistory: (config: PinataConfig | undefined, options: SwapHistoryOptions, network: "public" | "private") => Promise<SwapCidResponse[]>;
374
+
375
+ declare const totalStorageUsage: (config: PinataConfig | undefined) => Promise<number>;
376
+
377
+ declare const updateFile: (config: PinataConfig | undefined, options: UpdateFileOptions, privacy: "public" | "private") => Promise<FileListItem>;
378
+
379
+ declare const vectorizeFile: (config: PinataConfig | undefined, fileId: string) => Promise<VectorizeFileResponse>;
380
+
381
+ declare const vectorizeQuery: (config: PinataConfig | undefined, options: VectorizeQuery) => Promise<VectorizeQueryResponse | GetCIDResponse>;
382
+
383
+ declare const queue: (config: PinataConfig | undefined, options?: PinQueueQuery) => Promise<PinQueueResponse>;
384
+
385
+ declare const deletePinRequest: (config: PinataConfig | undefined, id: string) => Promise<string>;
386
+
387
+ declare const getCid: (config: PinataConfig | undefined, cid: string, gatewayType?: "ipfs" | "files", options?: OptimizeImageOptions) => Promise<GetCIDResponse>;
388
+
389
+ declare const convertIPFSUrl: (config: PinataConfig | undefined, url: string, gatewayPrefix?: string) => Promise<string>;
390
+
391
+ declare const createAccessLink: (config: PinataConfig | undefined, options: AccessLinkOptions, imgOpts: OptimizeImageOptions) => Promise<string>;
392
+
393
+ declare const addToGroup: (config: PinataConfig | undefined, options: GroupCIDOptions, privacy: "public" | "private") => Promise<UpdateGroupFilesResponse[]>;
394
+
395
+ declare const createGroup: (config: PinataConfig | undefined, options: GroupOptions, privacy: "public" | "private") => Promise<GroupResponseItem>;
396
+
397
+ declare const deleteGroup: (config: PinataConfig | undefined, options: GetGroupOptions, privacy: "public" | "private") => Promise<string>;
398
+
399
+ declare const getGroup: (config: PinataConfig | undefined, options: GetGroupOptions, privacy: "public" | "private") => Promise<GroupResponseItem>;
400
+
401
+ declare const listGroups: (config: PinataConfig | undefined, privacy: "public" | "private", options?: GroupQueryOptions) => Promise<GroupListResponse>;
402
+
403
+ declare const removeFromGroup: (config: PinataConfig | undefined, options: GroupCIDOptions, privacy: "public" | "private") => Promise<UpdateGroupFilesResponse[]>;
404
+
405
+ declare const updateGroup: (config: PinataConfig | undefined, options: UpdateGroupOptions, privacy: "public" | "private") => Promise<GroupResponseItem>;
406
+
407
+ declare const createKey: (config: PinataConfig | undefined, options: KeyOptions) => Promise<KeyResponse>;
408
+
409
+ declare const listKeys: (config: PinataConfig | undefined, options?: KeyListQuery) => Promise<KeyListItem[]>;
410
+
411
+ declare const revokeKeys: (config: PinataConfig | undefined, keys: string[]) => Promise<RevokeKeyResponse[]>;
412
+
413
+ declare const uploadBase64: (config: PinataConfig | undefined, base64String: string, network: "private" | "public", options?: UploadOptions) => Promise<UploadResponse>;
414
+
415
+ declare const createSignedUploadURL: (config: PinataConfig | undefined, options: SignedUploadUrlOptions, network: "public" | "private") => Promise<string>;
416
+
417
+ declare const uploadFile: (config: PinataConfig | undefined, file: File, network: "public" | "private", options?: UploadOptions) => Promise<UploadResponse>;
418
+
419
+ declare const uploadFileArray: (config: PinataConfig | undefined, files: File[], network: "public" | "private", options?: UploadOptions) => Promise<UploadResponse>;
420
+
421
+ declare const uploadJson: <T extends JsonBody>(config: PinataConfig | undefined, jsonData: T, network: "public" | "private", options?: UploadOptions) => Promise<UploadResponse>;
422
+
423
+ declare const uploadUrl: (config: PinataConfig | undefined, url: string, network: "public" | "private", options?: UploadOptions) => Promise<UploadResponse>;
424
+
425
+ declare const uploadCid: (config: PinataConfig | undefined, cid: string, options?: UploadCIDOptions) => Promise<PinByCIDResponse>;
426
+
427
+ declare class Analytics {
428
+ config: PinataConfig | undefined;
429
+ requests: AnalyticsRequests;
430
+ bandwidth: AnalyticsBandwidth;
337
431
  constructor(config?: PinataConfig);
338
- setNewHeaders(headers: Record<string, string>): void;
339
- setNewJwt(jwt: string): void;
340
- testAuthentication(): Promise<AuthTestResponse>;
432
+ updateConfig(newConfig: PinataConfig): void;
433
+ summary(options: {
434
+ domain: string;
435
+ start: string;
436
+ end: string;
437
+ interval: "day" | "week";
438
+ }): TimeIntervalAnalyticsBuilder;
341
439
  }
342
- declare class Files {
343
- config: PinataConfig | undefined;
440
+
441
+ declare class AnalyticsFilter {
442
+ protected config: PinataConfig | undefined;
443
+ protected query: TopAnalyticsQuery;
444
+ constructor(config: PinataConfig | undefined, domain: string, start: string, end: string);
445
+ cid(cid?: string): this;
446
+ fileName(fileName?: string): this;
447
+ userAgent(userAgent?: string): this;
448
+ country(country?: string): this;
449
+ region(region?: string): this;
450
+ referer(referer?: string): this;
451
+ limit(limit: number): this;
452
+ sort(order: "asc" | "desc"): this;
453
+ days(numberOfDays: number): this;
454
+ then(onfulfilled?: ((value: TopAnalyticsResponse) => any) | null): Promise<any>;
455
+ }
456
+
457
+ declare class AnalyticsBandwidth extends AnalyticsFilter {
344
458
  constructor(config?: PinataConfig);
345
459
  updateConfig(newConfig: PinataConfig): void;
346
- list(): FilterFiles;
347
- delete(files: string[]): Promise<DeleteResponse[]>;
348
- update(options: UpdateFileOptions): Promise<FileListItem>;
349
- addSwap(options: SwapCidOptions): Promise<SwapCidResponse>;
350
- getSwapHistory(options: SwapHistoryOptions): Promise<SwapCidResponse[]>;
351
- deleteSwap(cid: string): Promise<string>;
352
- vectorize(fileId: string): Promise<VectorizeFileResponse>;
353
- queryVectors(options: VectorizeQuery): Promise<VectorizeQueryResponse | GetCIDResponse>;
354
- deleteVectors(fileId: string): Promise<VectorizeFileResponse>;
460
+ customDates(start?: string, end?: string): this;
461
+ from(domain: string): this;
355
462
  }
356
- declare class UploadBuilder<T> {
357
- private config;
358
- private uploadFunction;
359
- private args;
360
- private metadata;
361
- private keys;
362
- private groupId;
363
- private vector;
364
- private uploadUrl;
365
- constructor(config: PinataConfig | undefined, uploadFunction: (config: PinataConfig | undefined, ...args: any[]) => Promise<T>, ...args: any[]);
366
- addMetadata(metadata: PinataMetadata): UploadBuilder<T>;
367
- key(jwt: string): UploadBuilder<T>;
368
- vectorize(): UploadBuilder<T>;
369
- url(url: string): UploadBuilder<T>;
370
- group(groupId: string): UploadBuilder<T>;
371
- then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
463
+
464
+ declare class AnalyticsBuilder<T extends AnalyticsQuery, R> {
465
+ protected config: PinataConfig | undefined;
466
+ protected query: T;
467
+ private requestCount;
468
+ private lastRequestTime;
469
+ private readonly MAX_REQUESTS_PER_MINUTE;
470
+ private readonly MINUTE_IN_MS;
471
+ constructor(config: PinataConfig | undefined, query: T);
472
+ cid(cid: string): this;
473
+ fileName(fileName: string): this;
474
+ userAgent(userAgent: string): this;
475
+ country(country: string): this;
476
+ region(region: string): this;
477
+ referer(referer: string): this;
478
+ limit(limit: number): this;
479
+ sort(order: "asc" | "desc"): this;
480
+ protected getAnalytics(): Promise<R>;
481
+ then(onfulfilled?: ((value: R) => any) | null): Promise<any>;
372
482
  }
373
- declare class Upload {
374
- config: PinataConfig | undefined;
483
+
484
+ declare class AnalyticsRequests extends AnalyticsFilter {
375
485
  constructor(config?: PinataConfig);
376
486
  updateConfig(newConfig: PinataConfig): void;
377
- file(file: FileObject, options?: UploadOptions): UploadBuilder<UploadResponse>;
378
- base64(base64String: string, options?: UploadOptions): UploadBuilder<UploadResponse>;
379
- url(url: string, options?: UploadOptions): UploadBuilder<UploadResponse>;
380
- json(data: object, options?: UploadOptions): UploadBuilder<UploadResponse>;
381
- createSignedURL(options: SignedUploadUrlOptions): Promise<string>;
487
+ customDates(start?: string, end?: string): this;
488
+ from(domain: string): this;
382
489
  }
383
- declare class FilterFiles {
490
+
491
+ declare class TimeIntervalAnalyticsBuilder extends AnalyticsBuilder<TimeIntervalAnalyticsQuery, TimeIntervalAnalyticsResponse> {
492
+ constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, dateInterval: "day" | "week");
493
+ sortBy(sortBy: "requests" | "bandwidth"): this;
494
+ protected getAnalytics(): Promise<TimeIntervalAnalyticsResponse>;
495
+ all(): Promise<TimeIntervalAnalyticsResponse>;
496
+ }
497
+
498
+ declare class FilterGroups {
384
499
  private config;
385
500
  private query;
386
- private currentPageToken;
387
- constructor(config: PinataConfig | undefined);
388
- name(name: string): FilterFiles;
389
- group(group: string): FilterFiles;
390
- cid(cid: string): FilterFiles;
391
- mimeType(mimeType: string): FilterFiles;
392
- order(order: "ASC" | "DESC"): FilterFiles;
393
- limit(limit: number): FilterFiles;
394
- cidPending(cidPending: boolean): FilterFiles;
395
- metadata(keyvalues: Record<string, string>): FilterFiles;
396
- noGroup(noGroup: boolean): FilterFiles;
397
- pageToken(pageToken: string): FilterFiles;
398
- then(onfulfilled?: ((value: FileListResponse) => any) | null): Promise<any>;
501
+ private privacy;
502
+ private nextPageToken;
503
+ constructor(config: PinataConfig | undefined, privacy: "private" | "public");
504
+ name(name: string): FilterGroups;
505
+ limit(limit: number): FilterGroups;
506
+ isPublic(isPublic: boolean): FilterGroups;
507
+ pageToken(pageToken: string): FilterGroups;
508
+ then(onfulfilled?: ((value: GroupListResponse) => any) | null): Promise<GroupListResponse>;
399
509
  private fetchPage;
400
- [Symbol.asyncIterator](): AsyncGenerator<FileListItem, void, unknown>;
401
- all(): Promise<FileListItem[]>;
510
+ [Symbol.asyncIterator](): AsyncGenerator<GroupResponseItem, void, unknown>;
511
+ all(): Promise<GroupResponseItem[]>;
402
512
  }
403
- declare class Gateways {
513
+
514
+ declare class PublicGroups {
404
515
  config: PinataConfig | undefined;
405
516
  constructor(config?: PinataConfig);
406
517
  updateConfig(newConfig: PinataConfig): void;
407
- get(cid: string): OptimizeImageGetCid;
408
- createSignedURL(options: SignedUrlOptions): OptimizeImageCreateSignedURL;
518
+ create(options: GroupOptions): Promise<GroupResponseItem>;
519
+ list(): FilterGroups;
520
+ get(options: GetGroupOptions): Promise<GroupResponseItem>;
521
+ addFiles(options: GroupCIDOptions): Promise<UpdateGroupFilesResponse[]>;
522
+ removeFiles(options: GroupCIDOptions): Promise<UpdateGroupFilesResponse[]>;
523
+ update(options: UpdateGroupOptions): Promise<GroupResponseItem>;
524
+ delete(options: GetGroupOptions): Promise<string>;
409
525
  }
410
- declare class OptimizeImageGetCid {
411
- private config;
412
- private cid;
413
- private options;
414
- constructor(config: PinataConfig | undefined, cid: string);
415
- optimizeImage(options: OptimizeImageOptions): OptimizeImageGetCid;
416
- then(onfulfilled?: ((value: GetCIDResponse) => any) | null): Promise<any>;
526
+
527
+ declare class PrivateGroups {
528
+ config: PinataConfig | undefined;
529
+ constructor(config?: PinataConfig);
530
+ updateConfig(newConfig: PinataConfig): void;
531
+ create(options: GroupOptions): Promise<GroupResponseItem>;
532
+ list(): FilterGroups;
533
+ get(options: GetGroupOptions): Promise<GroupResponseItem>;
534
+ addFiles(options: GroupCIDOptions): Promise<UpdateGroupFilesResponse[]>;
535
+ removeFiles(options: GroupCIDOptions): Promise<UpdateGroupFilesResponse[]>;
536
+ update(options: UpdateGroupOptions): Promise<GroupResponseItem>;
537
+ delete(options: GetGroupOptions): Promise<string>;
417
538
  }
418
- declare class OptimizeImageCreateSignedURL {
419
- private config;
420
- private urlOpts;
421
- private imgOpts;
422
- constructor(config: PinataConfig | undefined, urlOpts: SignedUrlOptions);
423
- optimizeImage(options: OptimizeImageOptions): OptimizeImageCreateSignedURL;
424
- then(onfulfilled?: ((value: string) => any) | null): Promise<any>;
539
+
540
+ declare class Groups {
541
+ config: PinataConfig | undefined;
542
+ public: PublicGroups;
543
+ private: PrivateGroups;
544
+ constructor(config?: PinataConfig);
545
+ updateConfig(newConfig: PinataConfig): void;
425
546
  }
547
+
426
548
  declare class Keys {
427
549
  config: PinataConfig | undefined;
428
550
  constructor(config?: PinataConfig);
@@ -431,6 +553,7 @@ declare class Keys {
431
553
  list(): FilterKeys;
432
554
  revoke(keys: string[]): Promise<RevokeKeyResponse[]>;
433
555
  }
556
+
434
557
  declare class FilterKeys {
435
558
  private config;
436
559
  private query;
@@ -444,96 +567,237 @@ declare class FilterKeys {
444
567
  [Symbol.asyncIterator](): AsyncGenerator<KeyListItem, void, unknown>;
445
568
  all(): Promise<KeyListItem[]>;
446
569
  }
447
- declare class Groups {
570
+
571
+ declare class Gateways {
448
572
  config: PinataConfig | undefined;
573
+ public: PublicGateways;
574
+ private: PrivateGateways;
449
575
  constructor(config?: PinataConfig);
450
576
  updateConfig(newConfig: PinataConfig): void;
451
- create(options: GroupOptions): Promise<GroupResponseItem>;
452
- list(): FilterGroups;
453
- get(options: GetGroupOptions): Promise<GroupResponseItem>;
454
- addFiles(options: GroupCIDOptions): Promise<UpdateGroupFilesResponse[]>;
455
- removeFiles(options: GroupCIDOptions): Promise<UpdateGroupFilesResponse[]>;
456
- update(options: UpdateGroupOptions): Promise<GroupResponseItem>;
457
- delete(options: GetGroupOptions): Promise<string>;
458
577
  }
459
- declare class FilterGroups {
578
+
579
+ declare class OptimizeImageCreateAccessLink {
580
+ private config;
581
+ private urlOpts;
582
+ private imgOpts;
583
+ constructor(config: PinataConfig | undefined, urlOpts: AccessLinkOptions);
584
+ optimizeImage(options: OptimizeImageOptions): OptimizeImageCreateAccessLink;
585
+ then(onfulfilled?: ((value: string) => any) | null): Promise<any>;
586
+ }
587
+
588
+ declare class OptimizeImageGetCid {
589
+ private config;
590
+ private cid;
591
+ private gatewayType?;
592
+ private options;
593
+ constructor(config: PinataConfig | undefined, cid: string, gatewayType?: "ipfs" | "files");
594
+ optimizeImage(options: OptimizeImageOptions): OptimizeImageGetCid;
595
+ then(onfulfilled?: ((value: GetCIDResponse) => any) | null): Promise<any>;
596
+ }
597
+
598
+ declare class PrivateGateways {
599
+ private config;
600
+ constructor(config: PinataConfig | undefined);
601
+ get(cid: string): OptimizeImageGetCid;
602
+ createAccessLink(options: AccessLinkOptions): OptimizeImageCreateAccessLink;
603
+ }
604
+
605
+ declare class PublicGateways {
606
+ private config;
607
+ constructor(config: PinataConfig | undefined);
608
+ get(cid: string): OptimizeImageGetCid;
609
+ convert(url: string, gatewayPrefix?: string): Promise<string>;
610
+ }
611
+
612
+ declare class FilterFiles {
460
613
  private config;
461
614
  private query;
462
- private nextPageToken;
615
+ private currentPageToken;
616
+ private privacy;
617
+ constructor(config: PinataConfig | undefined, privacy: "private" | "public");
618
+ name(name: string): FilterFiles;
619
+ group(group: string): FilterFiles;
620
+ cid(cid: string): FilterFiles;
621
+ mimeType(mimeType: string): FilterFiles;
622
+ order(order: "ASC" | "DESC"): FilterFiles;
623
+ limit(limit: number): FilterFiles;
624
+ cidPending(cidPending: boolean): FilterFiles;
625
+ keyvalues(keyvalues: Record<string, string>): FilterFiles;
626
+ noGroup(noGroup: boolean): FilterFiles;
627
+ pageToken(pageToken: string): FilterFiles;
628
+ then(onfulfilled?: ((value: FileListResponse) => any) | null): Promise<any>;
629
+ private fetchPage;
630
+ [Symbol.asyncIterator](): AsyncGenerator<FileListItem, void, unknown>;
631
+ all(): Promise<FileListItem[]>;
632
+ }
633
+
634
+ declare class FilterQueue {
635
+ private config;
636
+ private query;
637
+ private currentPageToken;
638
+ private requestCount;
639
+ private lastRequestTime;
640
+ private readonly MAX_REQUESTS_PER_MINUTE;
641
+ private readonly MINUTE_IN_MS;
463
642
  constructor(config: PinataConfig | undefined);
464
- name(name: string): FilterGroups;
465
- limit(limit: number): FilterGroups;
466
- isPublic(isPublic: boolean): FilterGroups;
467
- pageToken(pageToken: string): FilterGroups;
468
- then(onfulfilled?: ((value: GroupListResponse) => any) | null): Promise<GroupListResponse>;
643
+ cid(cid: string): FilterQueue;
644
+ status(status: "prechecking" | "retrieving" | "expired" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node"): FilterQueue;
645
+ pageLimit(limit: number): FilterQueue;
646
+ pageToken(pageToken: string): FilterQueue;
469
647
  private fetchPage;
470
- [Symbol.asyncIterator](): AsyncGenerator<GroupResponseItem, void, unknown>;
471
- all(): Promise<GroupResponseItem[]>;
648
+ sort(sort: "ASC" | "DSC"): FilterQueue;
649
+ then(onfulfilled?: ((value: PinQueueResponse) => any) | null): Promise<any>;
650
+ private rateLimit;
651
+ [Symbol.asyncIterator](): AsyncGenerator<PinQueueItem, void, unknown>;
652
+ all(): Promise<PinQueueItem[]>;
472
653
  }
473
- declare class Analytics {
654
+
655
+ declare class PublicFiles {
656
+ private config;
657
+ constructor(config?: PinataConfig);
658
+ list(): FilterFiles;
659
+ get(id: string): Promise<FileListItem>;
660
+ delete(files: string[]): Promise<DeleteResponse[]>;
661
+ update(options: UpdateFileOptions): Promise<FileListItem>;
662
+ addSwap(options: SwapCidOptions): Promise<SwapCidResponse>;
663
+ getSwapHistory(options: SwapHistoryOptions): Promise<SwapCidResponse[]>;
664
+ deleteSwap(cid: string): Promise<string>;
665
+ queue(): FilterQueue;
666
+ deletePinRequest(requestId: string): Promise<string>;
667
+ }
668
+
669
+ declare class PrivateFiles {
670
+ private config;
671
+ constructor(config?: PinataConfig);
672
+ list(): FilterFiles;
673
+ get(id: string): Promise<FileListItem>;
674
+ delete(files: string[]): Promise<DeleteResponse[]>;
675
+ update(options: UpdateFileOptions): Promise<FileListItem>;
676
+ addSwap(options: SwapCidOptions): Promise<SwapCidResponse>;
677
+ getSwapHistory(options: SwapHistoryOptions): Promise<SwapCidResponse[]>;
678
+ deleteSwap(cid: string): Promise<string>;
679
+ vectorize(fileId: string): Promise<VectorizeFileResponse>;
680
+ queryVectors(options: VectorizeQuery): Promise<VectorizeQueryResponse | GetCIDResponse>;
681
+ deleteVectors(fileId: string): Promise<VectorizeFileResponse>;
682
+ }
683
+
684
+ declare class Files {
474
685
  config: PinataConfig | undefined;
475
- requests: AnalyticsRequests;
476
- bandwidth: AnalyticsBandwidth;
686
+ public: PublicFiles;
687
+ private: PrivateFiles;
477
688
  constructor(config?: PinataConfig);
478
689
  updateConfig(newConfig: PinataConfig): void;
479
- summary(options: {
480
- domain: string;
481
- start: string;
482
- end: string;
483
- interval: "day" | "week";
484
- }): TimeIntervalAnalyticsBuilder;
485
690
  }
486
- declare class AnalyticsFilter {
487
- protected config: PinataConfig | undefined;
488
- protected query: TopAnalyticsQuery;
489
- constructor(config: PinataConfig | undefined, domain: string, start: string, end: string);
490
- cid(cid?: string): this;
491
- fileName(fileName?: string): this;
492
- userAgent(userAgent?: string): this;
493
- country(country?: string): this;
494
- region(region?: string): this;
495
- referer(referer?: string): this;
496
- limit(limit: number): this;
497
- sort(order: "asc" | "desc"): this;
498
- days(numberOfDays: number): this;
499
- then(onfulfilled?: ((value: TopAnalyticsResponse) => any) | null): Promise<any>;
691
+
692
+ declare class UploadBuilder<T> {
693
+ private config;
694
+ private uploadFunction;
695
+ private args;
696
+ private metadata;
697
+ private keys;
698
+ private groupId;
699
+ private vector;
700
+ private uploadUrl;
701
+ private peerAddresses;
702
+ constructor(config: PinataConfig | undefined, uploadFunction: (config: PinataConfig | undefined, ...args: any[]) => Promise<T>, ...args: any[]);
703
+ name(name: string): UploadBuilder<T>;
704
+ keyvalues(keyvalues: Record<string, string>): UploadBuilder<T>;
705
+ key(jwt: string): UploadBuilder<T>;
706
+ vectorize(): UploadBuilder<T>;
707
+ url(url: string): UploadBuilder<T>;
708
+ group(groupId: string): UploadBuilder<T>;
709
+ peerAddress(peerAddresses: string[]): UploadBuilder<T>;
710
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
500
711
  }
501
- declare class AnalyticsRequests extends AnalyticsFilter {
712
+
713
+ declare class PublicUpload {
714
+ config: PinataConfig | undefined;
502
715
  constructor(config?: PinataConfig);
503
716
  updateConfig(newConfig: PinataConfig): void;
504
- customDates(start?: string, end?: string): this;
505
- from(domain: string): this;
717
+ file(file: FileObject, options?: UploadOptions): UploadBuilder<UploadResponse>;
718
+ fileArray(files: FileObject[], options?: UploadOptions): UploadBuilder<UploadResponse>;
719
+ base64(base64String: string, options?: UploadOptions): UploadBuilder<UploadResponse>;
720
+ url(url: string, options?: UploadOptions): UploadBuilder<UploadResponse>;
721
+ json(data: object, options?: UploadOptions): UploadBuilder<UploadResponse>;
722
+ cid(cid: string, options?: UploadCIDOptions): UploadBuilder<PinByCIDResponse>;
723
+ createSignedURL(options: SignedUploadUrlOptions): Promise<string>;
506
724
  }
507
- declare class AnalyticsBandwidth extends AnalyticsFilter {
725
+
726
+ declare class PrivateUpload {
727
+ config: PinataConfig | undefined;
508
728
  constructor(config?: PinataConfig);
509
729
  updateConfig(newConfig: PinataConfig): void;
510
- customDates(start?: string, end?: string): this;
511
- from(domain: string): this;
730
+ file(file: FileObject, options?: UploadOptions): UploadBuilder<UploadResponse>;
731
+ base64(base64String: string, options?: UploadOptions): UploadBuilder<UploadResponse>;
732
+ url(url: string, options?: UploadOptions): UploadBuilder<UploadResponse>;
733
+ json(data: object, options?: UploadOptions): UploadBuilder<UploadResponse>;
734
+ createSignedURL(options: SignedUploadUrlOptions): Promise<string>;
512
735
  }
513
- declare class AnalyticsBuilder<T extends AnalyticsQuery, R> {
514
- protected config: PinataConfig | undefined;
515
- protected query: T;
516
- private requestCount;
517
- private lastRequestTime;
518
- private readonly MAX_REQUESTS_PER_MINUTE;
519
- private readonly MINUTE_IN_MS;
520
- constructor(config: PinataConfig | undefined, query: T);
521
- cid(cid: string): this;
522
- fileName(fileName: string): this;
523
- userAgent(userAgent: string): this;
524
- country(country: string): this;
525
- region(region: string): this;
526
- referer(referer: string): this;
527
- limit(limit: number): this;
528
- sort(order: "asc" | "desc"): this;
529
- protected getAnalytics(): Promise<R>;
530
- then(onfulfilled?: ((value: R) => any) | null): Promise<any>;
736
+
737
+ declare class Upload {
738
+ config: PinataConfig | undefined;
739
+ public: PublicUpload;
740
+ private: PrivateUpload;
741
+ constructor(config?: PinataConfig);
742
+ updateConfig(newConfig: PinataConfig): void;
531
743
  }
532
- declare class TimeIntervalAnalyticsBuilder extends AnalyticsBuilder<TimeIntervalAnalyticsQuery, TimeIntervalAnalyticsResponse> {
533
- constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, dateInterval: "day" | "week");
534
- sortBy(sortBy: "requests" | "bandwidth"): this;
535
- protected getAnalytics(): Promise<TimeIntervalAnalyticsResponse>;
536
- all(): Promise<TimeIntervalAnalyticsResponse>;
744
+
745
+ declare class PublicSignatures {
746
+ config: PinataConfig | undefined;
747
+ constructor(config?: PinataConfig);
748
+ updateConfig(newConfig: PinataConfig): void;
749
+ add(options: SignatureOptions): Promise<SignatureResponse>;
750
+ get(cid: string): Promise<SignatureResponse>;
751
+ delete(cid: string): Promise<string>;
752
+ }
753
+
754
+ declare class Signatures {
755
+ config: PinataConfig | undefined;
756
+ public: PublicSignatures;
757
+ constructor(config?: PinataConfig);
758
+ updateConfig(newConfig: PinataConfig): void;
759
+ }
760
+
761
+ declare class PinataSDK {
762
+ config: PinataConfig | undefined;
763
+ files: Files;
764
+ upload: Upload;
765
+ gateways: Gateways;
766
+ keys: Keys;
767
+ groups: Groups;
768
+ analytics: Analytics;
769
+ signatures: Signatures;
770
+ constructor(config?: PinataConfig);
771
+ setNewHeaders(headers: Record<string, string>): void;
772
+ setNewJwt(jwt: string): void;
773
+ testAuthentication(): Promise<string>;
774
+ }
775
+
776
+ interface ErrorDetails {
777
+ error?: string;
778
+ code?: string;
779
+ metadata?: Record<string, any>;
780
+ }
781
+ declare class PinataError extends Error {
782
+ statusCode?: number | undefined;
783
+ details?: ErrorDetails | undefined;
784
+ constructor(message: string, statusCode?: number | undefined, details?: ErrorDetails | undefined);
537
785
  }
786
+ declare class NetworkError extends PinataError {
787
+ constructor(message: string, statusCode?: number, details?: ErrorDetails);
788
+ }
789
+ declare class AuthenticationError extends PinataError {
790
+ constructor(message: string, statusCode?: number, details?: ErrorDetails);
791
+ }
792
+ declare class ValidationError extends PinataError {
793
+ constructor(message: string, details?: ErrorDetails);
794
+ }
795
+
796
+ declare function containsCID(input: string): Promise<ContainsCIDResponse>;
797
+ declare function convertToDesiredGateway(sourceUrl: string, desiredGatewayPrefix: string | undefined): Promise<string>;
798
+
799
+ declare function getFileIdFromUrl(url: string): string;
800
+
801
+ declare const formatConfig: (config: PinataConfig | undefined) => PinataConfig | undefined;
538
802
 
539
- export { type AnalyticsQuery, type AuthTestResponse, type ContainsCIDResponse, type ContentType, type DataEndponts, type DeleteResponse, type Endpoints, type FileListItem, type FileListQuery, type FileListResponse, type FileObject, type GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, type JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, type OptimizeImageOptions, type PinJobItem, type PinJobQuery, type PinJobResponse, type PinataConfig, type PinataMetadata, PinataSDK, type PinningEndpoints, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, type SignedUploadUrlOptions, type SignedUrlOptions, type SwapCidOptions, type SwapCidResponse, type SwapHistoryOptions, type TimeIntervalAnalyticsQuery, type TimeIntervalAnalyticsResponse, type TimePeriodItem, type TopAnalyticsItem, type TopAnalyticsQuery, type TopAnalyticsResponse, type UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, type UploadOptions, type UploadResponse, type UserPinnedDataResponse, type VectorQueryMatch, type VectorizeFileResponse, type VectorizeQuery, type VectorizeQueryResponse };
803
+ export { type AccessLinkOptions, type AnalyticsQuery, AuthenticationError, type ContainsCIDResponse, type ContentType, type DataEndponts, type DeleteResponse, type Endpoints, type FileListItem, type FileListQuery, type FileListResponse, type FileObject, type GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, type JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, NetworkError, type OptimizeImageOptions, type PinByCIDResponse, type PinQueueItem, type PinQueueQuery, type PinQueueResponse, type PinataConfig, PinataError, type PinataMetadata, PinataSDK, type PinningEndpoints, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, type SignedUploadUrlOptions, type SwapCidOptions, type SwapCidResponse, type SwapHistoryOptions, type TimeIntervalAnalyticsQuery, type TimeIntervalAnalyticsResponse, type TimePeriodItem, type TopAnalyticsItem, type TopAnalyticsQuery, type TopAnalyticsResponse, type UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, type UploadCIDOptions, type UploadOptions, type UploadResponse, type UserPinnedDataResponse, ValidationError, type VectorQueryMatch, type VectorizeFileResponse, type VectorizeQuery, type VectorizeQueryResponse, addToGroup, analyticsDateInterval, analyticsTopUsage, containsCID, convertIPFSUrl, convertToDesiredGateway, createAccessLink, createGroup, createKey, createSignedUploadURL, deleteFile, deleteFileVectors, deleteGroup, deletePinRequest, deleteSwap, formatConfig, getCid, getFileIdFromUrl, getGroup, listFiles, listGroups, listKeys, pinnedFileCount, queue, removeFromGroup, revokeKeys, swapCid, swapHistory, testAuthentication, totalStorageUsage, updateFile, updateGroup, uploadBase64, uploadCid, uploadFile, uploadFileArray, uploadJson, uploadUrl, vectorizeFile, vectorizeQuery };