pinata 1.10.1 → 2.0.1

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.ts 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
106
  ipfs_pin_hash?: 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,38 @@ 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;
319
328
  };
320
329
  type SignedUploadUrlOptions = {
321
330
  date?: number;
@@ -325,104 +334,210 @@ type SignedUploadUrlOptions = {
325
334
  keyvalues?: Record<string, string>;
326
335
  vectorize?: boolean;
327
336
  };
337
+ type UploadCIDOptions = {
338
+ metadata?: PinataMetadata;
339
+ peerAddresses?: string[];
340
+ keys?: string;
341
+ groupId?: string;
342
+ };
343
+ type PinByCIDResponse = {
344
+ id: string;
345
+ cid: string;
346
+ status: "prechecking" | "retrieving";
347
+ name: string;
348
+ };
328
349
 
329
- declare class PinataSDK {
350
+ declare const analyticsDateInterval: (config: PinataConfig | undefined, options?: TimeIntervalAnalyticsQuery) => Promise<TimeIntervalAnalyticsResponse>;
351
+
352
+ declare const analyticsTopUsage: (config: PinataConfig | undefined, options?: TopAnalyticsQuery) => Promise<TopAnalyticsResponse>;
353
+
354
+ declare const testAuthentication: (config: PinataConfig | undefined) => Promise<string>;
355
+
356
+ declare const deleteFile: (config: PinataConfig | undefined, files: string[], privacy: "public" | "private") => Promise<DeleteResponse[]>;
357
+
358
+ declare const deleteFileVectors: (config: PinataConfig | undefined, fileId: string) => Promise<VectorizeFileResponse>;
359
+
360
+ declare const deleteSwap: (config: PinataConfig | undefined, cid: string, network: "public" | "private") => Promise<string>;
361
+
362
+ declare const listFiles: (config: PinataConfig | undefined, privacy: "private" | "public", options?: FileListQuery) => Promise<FileListResponse>;
363
+
364
+ declare const pinnedFileCount: (config: PinataConfig | undefined) => Promise<number>;
365
+
366
+ declare const swapCid: (config: PinataConfig | undefined, options: SwapCidOptions, network: "public" | "private") => Promise<SwapCidResponse>;
367
+
368
+ declare const swapHistory: (config: PinataConfig | undefined, options: SwapHistoryOptions, network: "public" | "private") => Promise<SwapCidResponse[]>;
369
+
370
+ declare const totalStorageUsage: (config: PinataConfig | undefined) => Promise<number>;
371
+
372
+ declare const updateFile: (config: PinataConfig | undefined, options: UpdateFileOptions, privacy: "public" | "private") => Promise<FileListItem>;
373
+
374
+ declare const vectorizeFile: (config: PinataConfig | undefined, fileId: string) => Promise<VectorizeFileResponse>;
375
+
376
+ declare const vectorizeQuery: (config: PinataConfig | undefined, options: VectorizeQuery) => Promise<VectorizeQueryResponse | GetCIDResponse>;
377
+
378
+ declare const queue: (config: PinataConfig | undefined, options?: PinQueueQuery) => Promise<PinQueueResponse>;
379
+
380
+ declare const getCid: (config: PinataConfig | undefined, cid: string, gatewayType?: "ipfs" | "files", options?: OptimizeImageOptions) => Promise<GetCIDResponse>;
381
+
382
+ declare const convertIPFSUrl: (config: PinataConfig | undefined, url: string, gatewayPrefix?: string) => Promise<string>;
383
+
384
+ declare const createAccessLink: (config: PinataConfig | undefined, options: AccessLinkOptions, imgOpts: OptimizeImageOptions) => Promise<string>;
385
+
386
+ declare const addToGroup: (config: PinataConfig | undefined, options: GroupCIDOptions, privacy: "public" | "private") => Promise<UpdateGroupFilesResponse[]>;
387
+
388
+ declare const createGroup: (config: PinataConfig | undefined, options: GroupOptions, privacy: "public" | "private") => Promise<GroupResponseItem>;
389
+
390
+ declare const deleteGroup: (config: PinataConfig | undefined, options: GetGroupOptions, privacy: "public" | "private") => Promise<string>;
391
+
392
+ declare const getGroup: (config: PinataConfig | undefined, options: GetGroupOptions, privacy: "public" | "private") => Promise<GroupResponseItem>;
393
+
394
+ declare const listGroups: (config: PinataConfig | undefined, privacy: "public" | "private", options?: GroupQueryOptions) => Promise<GroupListResponse>;
395
+
396
+ declare const removeFromGroup: (config: PinataConfig | undefined, options: GroupCIDOptions, privacy: "public" | "private") => Promise<UpdateGroupFilesResponse[]>;
397
+
398
+ declare const updateGroup: (config: PinataConfig | undefined, options: UpdateGroupOptions, privacy: "public" | "private") => Promise<GroupResponseItem>;
399
+
400
+ declare const createKey: (config: PinataConfig | undefined, options: KeyOptions) => Promise<KeyResponse>;
401
+
402
+ declare const listKeys: (config: PinataConfig | undefined, options?: KeyListQuery) => Promise<KeyListItem[]>;
403
+
404
+ declare const revokeKeys: (config: PinataConfig | undefined, keys: string[]) => Promise<RevokeKeyResponse[]>;
405
+
406
+ declare const uploadBase64: (config: PinataConfig | undefined, base64String: string, network: "private" | "public", options?: UploadOptions) => Promise<UploadResponse>;
407
+
408
+ declare const createSignedUploadURL: (config: PinataConfig | undefined, options: SignedUploadUrlOptions, network: "public" | "private") => Promise<string>;
409
+
410
+ declare const uploadFile: (config: PinataConfig | undefined, file: File, network: "public" | "private", options?: UploadOptions) => Promise<UploadResponse>;
411
+
412
+ declare const uploadFileArray: (config: PinataConfig | undefined, files: File[], network: "public" | "private", options?: UploadOptions) => Promise<UploadResponse>;
413
+
414
+ declare const uploadJson: <T extends JsonBody>(config: PinataConfig | undefined, jsonData: T, network: "public" | "private", options?: UploadOptions) => Promise<UploadResponse>;
415
+
416
+ declare const uploadUrl: (config: PinataConfig | undefined, url: string, network: "public" | "private", options?: UploadOptions) => Promise<UploadResponse>;
417
+
418
+ declare const uploadCid: (config: PinataConfig | undefined, cid: string, options?: UploadCIDOptions) => Promise<PinByCIDResponse>;
419
+
420
+ declare class Analytics {
330
421
  config: PinataConfig | undefined;
331
- files: Files;
332
- upload: Upload;
333
- gateways: Gateways;
334
- keys: Keys;
335
- groups: Groups;
336
- analytics: Analytics;
422
+ requests: AnalyticsRequests;
423
+ bandwidth: AnalyticsBandwidth;
337
424
  constructor(config?: PinataConfig);
338
- setNewHeaders(headers: Record<string, string>): void;
339
- setNewJwt(jwt: string): void;
340
- testAuthentication(): Promise<AuthTestResponse>;
425
+ updateConfig(newConfig: PinataConfig): void;
426
+ summary(options: {
427
+ domain: string;
428
+ start: string;
429
+ end: string;
430
+ interval: "day" | "week";
431
+ }): TimeIntervalAnalyticsBuilder;
341
432
  }
342
- declare class Files {
343
- config: PinataConfig | undefined;
433
+
434
+ declare class AnalyticsFilter {
435
+ protected config: PinataConfig | undefined;
436
+ protected query: TopAnalyticsQuery;
437
+ constructor(config: PinataConfig | undefined, domain: string, start: string, end: string);
438
+ cid(cid?: string): this;
439
+ fileName(fileName?: string): this;
440
+ userAgent(userAgent?: string): this;
441
+ country(country?: string): this;
442
+ region(region?: string): this;
443
+ referer(referer?: string): this;
444
+ limit(limit: number): this;
445
+ sort(order: "asc" | "desc"): this;
446
+ days(numberOfDays: number): this;
447
+ then(onfulfilled?: ((value: TopAnalyticsResponse) => any) | null): Promise<any>;
448
+ }
449
+
450
+ declare class AnalyticsBandwidth extends AnalyticsFilter {
344
451
  constructor(config?: PinataConfig);
345
452
  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>;
453
+ customDates(start?: string, end?: string): this;
454
+ from(domain: string): this;
355
455
  }
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>;
456
+
457
+ declare class AnalyticsBuilder<T extends AnalyticsQuery, R> {
458
+ protected config: PinataConfig | undefined;
459
+ protected query: T;
460
+ private requestCount;
461
+ private lastRequestTime;
462
+ private readonly MAX_REQUESTS_PER_MINUTE;
463
+ private readonly MINUTE_IN_MS;
464
+ constructor(config: PinataConfig | undefined, query: T);
465
+ cid(cid: string): this;
466
+ fileName(fileName: string): this;
467
+ userAgent(userAgent: string): this;
468
+ country(country: string): this;
469
+ region(region: string): this;
470
+ referer(referer: string): this;
471
+ limit(limit: number): this;
472
+ sort(order: "asc" | "desc"): this;
473
+ protected getAnalytics(): Promise<R>;
474
+ then(onfulfilled?: ((value: R) => any) | null): Promise<any>;
372
475
  }
373
- declare class Upload {
374
- config: PinataConfig | undefined;
476
+
477
+ declare class AnalyticsRequests extends AnalyticsFilter {
375
478
  constructor(config?: PinataConfig);
376
479
  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>;
480
+ customDates(start?: string, end?: string): this;
481
+ from(domain: string): this;
382
482
  }
383
- declare class FilterFiles {
483
+
484
+ declare class TimeIntervalAnalyticsBuilder extends AnalyticsBuilder<TimeIntervalAnalyticsQuery, TimeIntervalAnalyticsResponse> {
485
+ constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, dateInterval: "day" | "week");
486
+ sortBy(sortBy: "requests" | "bandwidth"): this;
487
+ protected getAnalytics(): Promise<TimeIntervalAnalyticsResponse>;
488
+ all(): Promise<TimeIntervalAnalyticsResponse>;
489
+ }
490
+
491
+ declare class FilterGroups {
384
492
  private config;
385
493
  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>;
494
+ private privacy;
495
+ private nextPageToken;
496
+ constructor(config: PinataConfig | undefined, privacy: "private" | "public");
497
+ name(name: string): FilterGroups;
498
+ limit(limit: number): FilterGroups;
499
+ isPublic(isPublic: boolean): FilterGroups;
500
+ pageToken(pageToken: string): FilterGroups;
501
+ then(onfulfilled?: ((value: GroupListResponse) => any) | null): Promise<GroupListResponse>;
399
502
  private fetchPage;
400
- [Symbol.asyncIterator](): AsyncGenerator<FileListItem, void, unknown>;
401
- all(): Promise<FileListItem[]>;
503
+ [Symbol.asyncIterator](): AsyncGenerator<GroupResponseItem, void, unknown>;
504
+ all(): Promise<GroupResponseItem[]>;
402
505
  }
403
- declare class Gateways {
506
+
507
+ declare class PublicGroups {
404
508
  config: PinataConfig | undefined;
405
509
  constructor(config?: PinataConfig);
406
510
  updateConfig(newConfig: PinataConfig): void;
407
- get(cid: string): OptimizeImageGetCid;
408
- createSignedURL(options: SignedUrlOptions): OptimizeImageCreateSignedURL;
511
+ create(options: GroupOptions): Promise<GroupResponseItem>;
512
+ list(): FilterGroups;
513
+ get(options: GetGroupOptions): Promise<GroupResponseItem>;
514
+ addFiles(options: GroupCIDOptions): Promise<UpdateGroupFilesResponse[]>;
515
+ removeFiles(options: GroupCIDOptions): Promise<UpdateGroupFilesResponse[]>;
516
+ update(options: UpdateGroupOptions): Promise<GroupResponseItem>;
517
+ delete(options: GetGroupOptions): Promise<string>;
409
518
  }
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>;
519
+
520
+ declare class PrivateGroups {
521
+ config: PinataConfig | undefined;
522
+ constructor(config?: PinataConfig);
523
+ updateConfig(newConfig: PinataConfig): void;
524
+ create(options: GroupOptions): Promise<GroupResponseItem>;
525
+ list(): FilterGroups;
526
+ get(options: GetGroupOptions): Promise<GroupResponseItem>;
527
+ addFiles(options: GroupCIDOptions): Promise<UpdateGroupFilesResponse[]>;
528
+ removeFiles(options: GroupCIDOptions): Promise<UpdateGroupFilesResponse[]>;
529
+ update(options: UpdateGroupOptions): Promise<GroupResponseItem>;
530
+ delete(options: GetGroupOptions): Promise<string>;
417
531
  }
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>;
532
+
533
+ declare class Groups {
534
+ config: PinataConfig | undefined;
535
+ public: PublicGroups;
536
+ private: PrivateGroups;
537
+ constructor(config?: PinataConfig);
538
+ updateConfig(newConfig: PinataConfig): void;
425
539
  }
540
+
426
541
  declare class Keys {
427
542
  config: PinataConfig | undefined;
428
543
  constructor(config?: PinataConfig);
@@ -431,6 +546,7 @@ declare class Keys {
431
546
  list(): FilterKeys;
432
547
  revoke(keys: string[]): Promise<RevokeKeyResponse[]>;
433
548
  }
549
+
434
550
  declare class FilterKeys {
435
551
  private config;
436
552
  private query;
@@ -444,96 +560,236 @@ declare class FilterKeys {
444
560
  [Symbol.asyncIterator](): AsyncGenerator<KeyListItem, void, unknown>;
445
561
  all(): Promise<KeyListItem[]>;
446
562
  }
447
- declare class Groups {
563
+
564
+ declare class Gateways {
448
565
  config: PinataConfig | undefined;
566
+ public: PublicGateways;
567
+ private: PrivateGateways;
449
568
  constructor(config?: PinataConfig);
450
569
  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
570
  }
459
- declare class FilterGroups {
571
+
572
+ declare class OptimizeImageCreateAccessLink {
573
+ private config;
574
+ private urlOpts;
575
+ private imgOpts;
576
+ constructor(config: PinataConfig | undefined, urlOpts: AccessLinkOptions);
577
+ optimizeImage(options: OptimizeImageOptions): OptimizeImageCreateAccessLink;
578
+ then(onfulfilled?: ((value: string) => any) | null): Promise<any>;
579
+ }
580
+
581
+ declare class OptimizeImageGetCid {
582
+ private config;
583
+ private cid;
584
+ private gatewayType?;
585
+ private options;
586
+ constructor(config: PinataConfig | undefined, cid: string, gatewayType?: "ipfs" | "files");
587
+ optimizeImage(options: OptimizeImageOptions): OptimizeImageGetCid;
588
+ then(onfulfilled?: ((value: GetCIDResponse) => any) | null): Promise<any>;
589
+ }
590
+
591
+ declare class PrivateGateways {
592
+ private config;
593
+ constructor(config: PinataConfig | undefined);
594
+ get(cid: string): OptimizeImageGetCid;
595
+ createAccessLink(options: AccessLinkOptions): OptimizeImageCreateAccessLink;
596
+ }
597
+
598
+ declare class PublicGateways {
599
+ private config;
600
+ constructor(config: PinataConfig | undefined);
601
+ get(cid: string): OptimizeImageGetCid;
602
+ convert(url: string, gatewayPrefix?: string): Promise<string>;
603
+ }
604
+
605
+ declare class FilterFiles {
460
606
  private config;
461
607
  private query;
462
- private nextPageToken;
608
+ private currentPageToken;
609
+ private privacy;
610
+ constructor(config: PinataConfig | undefined, privacy: "private" | "public");
611
+ name(name: string): FilterFiles;
612
+ group(group: string): FilterFiles;
613
+ cid(cid: string): FilterFiles;
614
+ mimeType(mimeType: string): FilterFiles;
615
+ order(order: "ASC" | "DESC"): FilterFiles;
616
+ limit(limit: number): FilterFiles;
617
+ cidPending(cidPending: boolean): FilterFiles;
618
+ keyvalues(keyvalues: Record<string, string>): FilterFiles;
619
+ noGroup(noGroup: boolean): FilterFiles;
620
+ pageToken(pageToken: string): FilterFiles;
621
+ then(onfulfilled?: ((value: FileListResponse) => any) | null): Promise<any>;
622
+ private fetchPage;
623
+ [Symbol.asyncIterator](): AsyncGenerator<FileListItem, void, unknown>;
624
+ all(): Promise<FileListItem[]>;
625
+ }
626
+
627
+ declare class FilterQueue {
628
+ private config;
629
+ private query;
630
+ private currentPageToken;
631
+ private requestCount;
632
+ private lastRequestTime;
633
+ private readonly MAX_REQUESTS_PER_MINUTE;
634
+ private readonly MINUTE_IN_MS;
463
635
  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>;
636
+ cid(cid: string): FilterQueue;
637
+ status(status: "prechecking" | "retrieving" | "expired" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node"): FilterQueue;
638
+ pageLimit(limit: number): FilterQueue;
639
+ pageToken(pageToken: string): FilterQueue;
469
640
  private fetchPage;
470
- [Symbol.asyncIterator](): AsyncGenerator<GroupResponseItem, void, unknown>;
471
- all(): Promise<GroupResponseItem[]>;
641
+ sort(sort: "ASC" | "DSC"): FilterQueue;
642
+ then(onfulfilled?: ((value: PinQueueResponse) => any) | null): Promise<any>;
643
+ private rateLimit;
644
+ [Symbol.asyncIterator](): AsyncGenerator<PinQueueItem, void, unknown>;
645
+ all(): Promise<PinQueueItem[]>;
472
646
  }
473
- declare class Analytics {
647
+
648
+ declare class PublicFiles {
649
+ private config;
650
+ constructor(config?: PinataConfig);
651
+ list(): FilterFiles;
652
+ get(id: string): Promise<FileListItem>;
653
+ delete(files: string[]): Promise<DeleteResponse[]>;
654
+ update(options: UpdateFileOptions): Promise<FileListItem>;
655
+ addSwap(options: SwapCidOptions): Promise<SwapCidResponse>;
656
+ getSwapHistory(options: SwapHistoryOptions): Promise<SwapCidResponse[]>;
657
+ deleteSwap(cid: string): Promise<string>;
658
+ queue(): FilterQueue;
659
+ }
660
+
661
+ declare class PrivateFiles {
662
+ private config;
663
+ constructor(config?: PinataConfig);
664
+ list(): FilterFiles;
665
+ get(id: string): Promise<FileListItem>;
666
+ delete(files: string[]): Promise<DeleteResponse[]>;
667
+ update(options: UpdateFileOptions): Promise<FileListItem>;
668
+ addSwap(options: SwapCidOptions): Promise<SwapCidResponse>;
669
+ getSwapHistory(options: SwapHistoryOptions): Promise<SwapCidResponse[]>;
670
+ deleteSwap(cid: string): Promise<string>;
671
+ vectorize(fileId: string): Promise<VectorizeFileResponse>;
672
+ queryVectors(options: VectorizeQuery): Promise<VectorizeQueryResponse | GetCIDResponse>;
673
+ deleteVectors(fileId: string): Promise<VectorizeFileResponse>;
674
+ }
675
+
676
+ declare class Files {
474
677
  config: PinataConfig | undefined;
475
- requests: AnalyticsRequests;
476
- bandwidth: AnalyticsBandwidth;
678
+ public: PublicFiles;
679
+ private: PrivateFiles;
477
680
  constructor(config?: PinataConfig);
478
681
  updateConfig(newConfig: PinataConfig): void;
479
- summary(options: {
480
- domain: string;
481
- start: string;
482
- end: string;
483
- interval: "day" | "week";
484
- }): TimeIntervalAnalyticsBuilder;
485
682
  }
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>;
683
+
684
+ declare class UploadBuilder<T> {
685
+ private config;
686
+ private uploadFunction;
687
+ private args;
688
+ private metadata;
689
+ private keys;
690
+ private groupId;
691
+ private vector;
692
+ private uploadUrl;
693
+ private peerAddresses;
694
+ constructor(config: PinataConfig | undefined, uploadFunction: (config: PinataConfig | undefined, ...args: any[]) => Promise<T>, ...args: any[]);
695
+ name(name: string): UploadBuilder<T>;
696
+ keyvalues(keyvalues: Record<string, string>): UploadBuilder<T>;
697
+ key(jwt: string): UploadBuilder<T>;
698
+ vectorize(): UploadBuilder<T>;
699
+ url(url: string): UploadBuilder<T>;
700
+ group(groupId: string): UploadBuilder<T>;
701
+ peerAddress(peerAddresses: string[]): UploadBuilder<T>;
702
+ 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
703
  }
501
- declare class AnalyticsRequests extends AnalyticsFilter {
704
+
705
+ declare class PublicUpload {
706
+ config: PinataConfig | undefined;
502
707
  constructor(config?: PinataConfig);
503
708
  updateConfig(newConfig: PinataConfig): void;
504
- customDates(start?: string, end?: string): this;
505
- from(domain: string): this;
709
+ file(file: FileObject, options?: UploadOptions): UploadBuilder<UploadResponse>;
710
+ fileArray(files: FileObject[], options?: UploadOptions): UploadBuilder<UploadResponse>;
711
+ base64(base64String: string, options?: UploadOptions): UploadBuilder<UploadResponse>;
712
+ url(url: string, options?: UploadOptions): UploadBuilder<UploadResponse>;
713
+ json(data: object, options?: UploadOptions): UploadBuilder<UploadResponse>;
714
+ cid(cid: string, options?: UploadCIDOptions): UploadBuilder<PinByCIDResponse>;
715
+ createSignedURL(options: SignedUploadUrlOptions): Promise<string>;
506
716
  }
507
- declare class AnalyticsBandwidth extends AnalyticsFilter {
717
+
718
+ declare class PrivateUpload {
719
+ config: PinataConfig | undefined;
508
720
  constructor(config?: PinataConfig);
509
721
  updateConfig(newConfig: PinataConfig): void;
510
- customDates(start?: string, end?: string): this;
511
- from(domain: string): this;
722
+ file(file: FileObject, options?: UploadOptions): UploadBuilder<UploadResponse>;
723
+ base64(base64String: string, options?: UploadOptions): UploadBuilder<UploadResponse>;
724
+ url(url: string, options?: UploadOptions): UploadBuilder<UploadResponse>;
725
+ json(data: object, options?: UploadOptions): UploadBuilder<UploadResponse>;
726
+ createSignedURL(options: SignedUploadUrlOptions): Promise<string>;
512
727
  }
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>;
728
+
729
+ declare class Upload {
730
+ config: PinataConfig | undefined;
731
+ public: PublicUpload;
732
+ private: PrivateUpload;
733
+ constructor(config?: PinataConfig);
734
+ updateConfig(newConfig: PinataConfig): void;
531
735
  }
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>;
736
+
737
+ declare class PublicSignatures {
738
+ config: PinataConfig | undefined;
739
+ constructor(config?: PinataConfig);
740
+ updateConfig(newConfig: PinataConfig): void;
741
+ add(options: SignatureOptions): Promise<SignatureResponse>;
742
+ get(cid: string): Promise<SignatureResponse>;
743
+ delete(cid: string): Promise<string>;
537
744
  }
538
745
 
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 };
746
+ declare class Signatures {
747
+ config: PinataConfig | undefined;
748
+ public: PublicSignatures;
749
+ constructor(config?: PinataConfig);
750
+ updateConfig(newConfig: PinataConfig): void;
751
+ }
752
+
753
+ declare class PinataSDK {
754
+ config: PinataConfig | undefined;
755
+ files: Files;
756
+ upload: Upload;
757
+ gateways: Gateways;
758
+ keys: Keys;
759
+ groups: Groups;
760
+ analytics: Analytics;
761
+ signatures: Signatures;
762
+ constructor(config?: PinataConfig);
763
+ setNewHeaders(headers: Record<string, string>): void;
764
+ setNewJwt(jwt: string): void;
765
+ testAuthentication(): Promise<string>;
766
+ }
767
+
768
+ interface ErrorDetails {
769
+ error?: string;
770
+ code?: string;
771
+ metadata?: Record<string, any>;
772
+ }
773
+ declare class PinataError extends Error {
774
+ statusCode?: number | undefined;
775
+ details?: ErrorDetails | undefined;
776
+ constructor(message: string, statusCode?: number | undefined, details?: ErrorDetails | undefined);
777
+ }
778
+ declare class NetworkError extends PinataError {
779
+ constructor(message: string, statusCode?: number, details?: ErrorDetails);
780
+ }
781
+ declare class AuthenticationError extends PinataError {
782
+ constructor(message: string, statusCode?: number, details?: ErrorDetails);
783
+ }
784
+ declare class ValidationError extends PinataError {
785
+ constructor(message: string, details?: ErrorDetails);
786
+ }
787
+
788
+ declare function containsCID(input: string): Promise<ContainsCIDResponse>;
789
+ declare function convertToDesiredGateway(sourceUrl: string, desiredGatewayPrefix: string | undefined): Promise<string>;
790
+
791
+ declare function getFileIdFromUrl(url: string): string;
792
+
793
+ declare const formatConfig: (config: PinataConfig | undefined) => PinataConfig | undefined;
794
+
795
+ 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, 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 };