pinata 0.4.0 → 1.0.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.ts CHANGED
@@ -8,18 +8,14 @@ type PinataConfig = {
8
8
  type AuthTestResponse = {
9
9
  message: string;
10
10
  };
11
- type PinResponse = {
12
- IpfsHash: string;
13
- PinSize: number;
14
- Timestamp: string;
15
- isDuplicate?: boolean;
16
- };
17
- type PinByCIDResponse = {
11
+ type UploadResponse = {
18
12
  id: string;
19
- ipfsHash: string;
20
- status: "prechecking" | "retrieving";
21
13
  name: string;
22
- updated?: boolean;
14
+ cid: string;
15
+ size: number;
16
+ number_of_files: number;
17
+ mime_type: string;
18
+ user_id: string;
23
19
  };
24
20
  type FileObject = {
25
21
  name: string;
@@ -31,67 +27,38 @@ type FileObject = {
31
27
  type JsonBody = Record<string, unknown>;
32
28
  type PinataMetadata = {
33
29
  name?: string;
34
- keyValues?: Record<string, string | number>;
35
30
  };
36
- type PinataMetadataUpdate = {
37
- cid: string;
31
+ type UpdateFileOptions = {
32
+ id: string;
38
33
  name?: string;
39
- keyValues?: Record<string, string | number>;
40
34
  };
41
35
  type UploadOptions = {
42
36
  metadata?: PinataMetadata;
43
- pinType?: "async" | "sync" | "cidOnly";
44
- keys?: string;
45
- groupId?: string;
46
- cidVersion?: 0 | 1;
47
- };
48
- type UploadCIDOptions = {
49
- metadata?: PinataMetadata;
50
- peerAddresses?: string[];
51
37
  keys?: string;
52
38
  groupId?: string;
53
39
  };
54
- type UnpinResponse = {
55
- hash: string;
40
+ type DeleteResponse = {
41
+ id: string;
56
42
  status: string;
57
43
  };
58
- type PinListItem = {
44
+ type FileListItem = {
59
45
  id: string;
60
- ipfs_pin_hash: string;
46
+ name: string | null;
47
+ cid: "pending" | string;
61
48
  size: number;
62
- user_id: string;
63
- date_pinned: string;
64
- date_unpinned: string | null;
65
- metadata: {
66
- name: string | null;
67
- keyvalues: {
68
- [key: string]: any;
69
- } | null;
70
- };
71
- regions: {
72
- regionId: string;
73
- currentReplicationCount: number;
74
- desiredReplicationCount: number;
75
- }[];
76
- mime_type: string;
77
49
  number_of_files: number;
50
+ mime_type: string;
51
+ group_id: string;
52
+ created_at: string;
78
53
  };
79
- type PinListResponse = {
80
- rows: PinListItem[];
54
+ type FileListResponse = {
55
+ files: FileListItem[];
56
+ next_page_token: string;
81
57
  };
82
- type PinListQuery = {
83
- cid?: string;
84
- pinStart?: string;
85
- pinEnd?: string;
86
- pinSizeMin?: number;
87
- pinSizeMax?: number;
88
- pageLimit?: number;
89
- pageOffset?: number;
90
- name?: string;
91
- groupId?: string;
92
- key?: string;
93
- value?: string | number;
94
- operator?: "gt" | "gte" | "lt" | "lte" | "ne" | "eq" | "between" | "notBetween" | "like" | "notLike" | "iLike" | "notILike" | "regexp" | "iRegexp";
58
+ type FileListQuery = {
59
+ limit?: number;
60
+ pageToken?: string;
61
+ cidPending?: boolean;
95
62
  };
96
63
  type PinJobQuery = {
97
64
  sort?: "ASC" | "DSC";
@@ -137,6 +104,11 @@ type OptimizeImageOptions = {
137
104
  onError?: boolean;
138
105
  metadata?: "keep" | "copyright" | "none";
139
106
  };
107
+ type SignedUrlOptions = {
108
+ cid: string;
109
+ date?: number;
110
+ expires: number;
111
+ };
140
112
  type GatewayAnalyticsQuery = {
141
113
  gateway_domain: string;
142
114
  start_date: string;
@@ -249,25 +221,31 @@ type RevokeKeyResponse = {
249
221
  };
250
222
  type GroupOptions = {
251
223
  name: string;
224
+ isPublic?: boolean;
252
225
  };
253
226
  type UpdateGroupOptions = {
254
- name: string;
255
227
  groupId: string;
228
+ name?: string;
229
+ isPublic?: boolean;
256
230
  };
257
231
  type GetGroupOptions = {
258
232
  groupId: string;
259
233
  };
234
+ type GroupListResponse = {
235
+ groups: GroupResponseItem[];
236
+ next_page_token: string;
237
+ };
260
238
  type GroupResponseItem = {
261
239
  id: string;
262
- user_id: string;
240
+ is_public: boolean;
263
241
  name: string;
264
- updatedAt: string;
265
242
  createdAt: string;
266
243
  };
267
244
  type GroupQueryOptions = {
268
245
  nameContains?: string;
269
- offset?: number;
270
246
  limit?: number;
247
+ pageToken?: string;
248
+ isPublic?: boolean;
271
249
  };
272
250
  type GroupCIDOptions = {
273
251
  groupId: string;
@@ -300,19 +278,22 @@ type ContainsCIDResponse = {
300
278
 
301
279
  declare class PinataSDK {
302
280
  config: PinataConfig | undefined;
281
+ files: Files;
303
282
  upload: Upload;
304
283
  gateways: Gateways;
305
- usage: Usage;
306
284
  keys: Keys;
307
285
  groups: Groups;
308
- signatures: Signatures;
309
286
  constructor(config?: PinataConfig);
310
287
  setNewHeaders(headers: Record<string, string>): void;
311
288
  testAuthentication(): Promise<AuthTestResponse>;
312
- unpin(files: string[]): Promise<UnpinResponse[]>;
313
- listFiles(): FilterFiles;
314
- updateMetadata(options: PinataMetadataUpdate): Promise<string>;
315
- pinJobs(): FilterPinJobs;
289
+ }
290
+ declare class Files {
291
+ config: PinataConfig | undefined;
292
+ constructor(config?: PinataConfig);
293
+ updateConfig(newConfig: PinataConfig): void;
294
+ list(): FilterFiles;
295
+ delete(files: string[]): Promise<DeleteResponse[]>;
296
+ update(options: UpdateFileOptions): Promise<FileListItem>;
316
297
  }
317
298
  declare class UploadBuilder<T> {
318
299
  private config;
@@ -320,107 +301,40 @@ declare class UploadBuilder<T> {
320
301
  private args;
321
302
  private metadata;
322
303
  private keys;
323
- private peerAddresses;
324
- private version;
325
304
  private groupId;
326
305
  constructor(config: PinataConfig | undefined, uploadFunction: (config: PinataConfig | undefined, ...args: any[]) => Promise<T>, ...args: any[]);
327
306
  addMetadata(metadata: PinataMetadata): UploadBuilder<T>;
328
307
  key(jwt: string): UploadBuilder<T>;
329
- cidVersion(v: 0 | 1): UploadBuilder<T>;
330
308
  group(groupId: string): UploadBuilder<T>;
331
- peerAddress(peerAddresses: string[]): UploadBuilder<T>;
332
309
  then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
333
310
  }
334
311
  declare class Upload {
335
312
  config: PinataConfig | undefined;
336
313
  constructor(config?: PinataConfig);
337
314
  updateConfig(newConfig: PinataConfig): void;
338
- file(file: FileObject, options?: UploadOptions): UploadBuilder<PinResponse>;
339
- fileArray(files: FileObject[], options?: UploadOptions): UploadBuilder<PinResponse>;
340
- base64(base64String: string, options?: UploadOptions): UploadBuilder<PinResponse>;
341
- url(url: string, options?: UploadOptions): UploadBuilder<PinResponse>;
342
- json(data: object, options?: UploadOptions): UploadBuilder<PinResponse>;
343
- cid(cid: string, options?: UploadCIDOptions): UploadBuilder<PinByCIDResponse>;
315
+ file(file: FileObject, options?: UploadOptions): UploadBuilder<UploadResponse>;
316
+ base64(base64String: string, options?: UploadOptions): UploadBuilder<UploadResponse>;
317
+ url(url: string, options?: UploadOptions): UploadBuilder<UploadResponse>;
318
+ json(data: object, options?: UploadOptions): UploadBuilder<UploadResponse>;
344
319
  }
345
320
  declare class FilterFiles {
346
321
  private config;
347
322
  private query;
348
- private requestCount;
349
- private lastRequestTime;
350
- private readonly MAX_REQUESTS_PER_MINUTE;
351
- private readonly MINUTE_IN_MS;
323
+ private currentPageToken;
352
324
  constructor(config: PinataConfig | undefined);
353
- cid(cid: string): FilterFiles;
354
- pinStart(date: string): FilterFiles;
355
- pinEnd(date: string): FilterFiles;
356
- pinSizeMin(size: number): FilterFiles;
357
- pinSizeMax(size: number): FilterFiles;
358
- pageLimit(limit: number): FilterFiles;
359
- pageOffset(offset: number): FilterFiles;
360
- name(name: string): FilterFiles;
361
- group(groupId: string): FilterFiles;
362
- keyValue(key: string, value: string | number, operator?: PinListQuery["operator"]): FilterFiles;
363
- then(onfulfilled?: ((value: PinListItem[]) => any) | null): Promise<any>;
364
- private rateLimit;
365
- [Symbol.asyncIterator](): AsyncGenerator<PinListItem, void, unknown>;
366
- all(): Promise<PinListItem[]>;
325
+ limit(limit: number): FilterFiles;
326
+ cidPending(cidPending: boolean): FilterFiles;
327
+ then(onfulfilled?: ((value: FileListItem[]) => any) | null): Promise<any>;
328
+ private fetchPage;
329
+ [Symbol.asyncIterator](): AsyncGenerator<FileListItem, void, unknown>;
330
+ all(): Promise<FileListItem[]>;
367
331
  }
368
332
  declare class Gateways {
369
333
  config: PinataConfig | undefined;
370
334
  constructor(config?: PinataConfig);
371
335
  updateConfig(newConfig: PinataConfig): void;
372
- get(cid: string): OptimizeImage;
373
- convert(url: string, gatewayPrefix?: string): Promise<string>;
374
- containsCID(cid: string): Promise<ContainsCIDResponse>;
375
- topUsageAnalytics(options: {
376
- domain: string;
377
- start: string;
378
- end: string;
379
- sortBy: "requests" | "bandwidth";
380
- attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name";
381
- }): TopGatewayAnalyticsBuilder;
382
- dateIntervalAnalytics(options: {
383
- domain: string;
384
- start: string;
385
- end: string;
386
- interval: "day" | "week";
387
- }): TimeIntervalGatewayAnalyticsBuilder;
388
- swapCid(options: SwapCidOptions): Promise<SwapCidResponse>;
389
- swapHistory(options: SwapHistoryOptions): Promise<SwapCidResponse[]>;
390
- deleteSwap(cid: string): Promise<string>;
391
- }
392
- declare class OptimizeImage {
393
- private config;
394
- private cid;
395
- private options;
396
- constructor(config: PinataConfig | undefined, cid: string);
397
- optimizeImage(options: OptimizeImageOptions): OptimizeImage;
398
- then(onfulfilled?: ((value: GetCIDResponse) => any) | null): Promise<any>;
399
- }
400
- declare class FilterPinJobs {
401
- private config;
402
- private query;
403
- private requestCount;
404
- private lastRequestTime;
405
- private readonly MAX_REQUESTS_PER_MINUTE;
406
- private readonly MINUTE_IN_MS;
407
- constructor(config: PinataConfig | undefined);
408
- cid(cid: string): FilterPinJobs;
409
- status(status: "prechecking" | "retrieving" | "expired" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node"): FilterPinJobs;
410
- pageLimit(limit: number): FilterPinJobs;
411
- pageOffset(offset: number): FilterPinJobs;
412
- sort(sort: "ASC" | "DSC"): FilterPinJobs;
413
- then(onfulfilled?: ((value: PinJobItem[]) => any) | null): Promise<any>;
414
- private rateLimit;
415
- [Symbol.asyncIterator](): AsyncGenerator<PinJobItem, void, unknown>;
416
- all(): Promise<PinJobItem[]>;
417
- }
418
- declare class Usage {
419
- config: PinataConfig | undefined;
420
- constructor(config?: PinataConfig);
421
- updateConfig(newConfig: PinataConfig): void;
422
- pinnedFileCount(): Promise<number>;
423
- totalStorageSize(): Promise<number>;
336
+ get(cid: string): Promise<GetCIDResponse>;
337
+ createSignedURL(options: SignedUrlOptions): Promise<string>;
424
338
  }
425
339
  declare class Keys {
426
340
  config: PinataConfig | undefined;
@@ -433,10 +347,6 @@ declare class Keys {
433
347
  declare class FilterKeys {
434
348
  private config;
435
349
  private query;
436
- private requestCount;
437
- private lastRequestTime;
438
- private readonly MAX_REQUESTS_PER_MINUTE;
439
- private readonly MINUTE_IN_MS;
440
350
  constructor(config: PinataConfig | undefined);
441
351
  offset(offset: number): FilterKeys;
442
352
  revoked(revoked: boolean): FilterKeys;
@@ -444,7 +354,6 @@ declare class FilterKeys {
444
354
  exhausted(exhausted: boolean): FilterKeys;
445
355
  name(name: string): FilterKeys;
446
356
  then(onfulfilled?: ((value: KeyListItem[]) => any) | null): Promise<any>;
447
- private rateLimit;
448
357
  [Symbol.asyncIterator](): AsyncGenerator<KeyListItem, void, unknown>;
449
358
  all(): Promise<KeyListItem[]>;
450
359
  }
@@ -455,65 +364,20 @@ declare class Groups {
455
364
  create(options: GroupOptions): Promise<GroupResponseItem>;
456
365
  list(): FilterGroups;
457
366
  get(options: GetGroupOptions): Promise<GroupResponseItem>;
458
- addCids(options: GroupCIDOptions): Promise<string>;
459
- removeCids(options: GroupCIDOptions): Promise<string>;
460
367
  update(options: UpdateGroupOptions): Promise<GroupResponseItem>;
461
368
  delete(options: GetGroupOptions): Promise<string>;
462
369
  }
463
370
  declare class FilterGroups {
464
371
  private config;
465
372
  private query;
466
- private requestCount;
467
- private lastRequestTime;
468
- private readonly MAX_REQUESTS_PER_MINUTE;
469
- private readonly MINUTE_IN_MS;
373
+ private nextPageToken;
470
374
  constructor(config: PinataConfig | undefined);
471
- offset(offset: number): FilterGroups;
472
- name(nameContains: string): FilterGroups;
473
375
  limit(limit: number): FilterGroups;
376
+ isPublic(isPublic: boolean): FilterGroups;
474
377
  then(onfulfilled?: ((value: GroupResponseItem[]) => any) | null): Promise<GroupResponseItem[]>;
475
- private rateLimit;
378
+ private fetchPage;
476
379
  [Symbol.asyncIterator](): AsyncGenerator<GroupResponseItem, void, unknown>;
477
380
  all(): Promise<GroupResponseItem[]>;
478
381
  }
479
- declare class Signatures {
480
- config: PinataConfig | undefined;
481
- constructor(config?: PinataConfig);
482
- updateConfig(newConfig: PinataConfig): void;
483
- add(options: SignatureOptions): Promise<SignatureResponse>;
484
- get(cid: string): Promise<SignatureResponse>;
485
- delete(cid: string): Promise<string>;
486
- }
487
- declare class GatewayAnalyticsBuilder<T extends GatewayAnalyticsQuery, R> {
488
- protected config: PinataConfig | undefined;
489
- protected query: T;
490
- private requestCount;
491
- private lastRequestTime;
492
- private readonly MAX_REQUESTS_PER_MINUTE;
493
- private readonly MINUTE_IN_MS;
494
- constructor(config: PinataConfig | undefined, query: T);
495
- cid(cid: string): this;
496
- fileName(fileName: string): this;
497
- userAgent(userAgent: string): this;
498
- country(country: string): this;
499
- region(region: string): this;
500
- referer(referer: string): this;
501
- limit(limit: number): this;
502
- sort(order: "asc" | "desc"): this;
503
- private rateLimit;
504
- protected getAnalytics(): Promise<R>;
505
- then(onfulfilled?: ((value: R) => any) | null): Promise<any>;
506
- }
507
- declare class TopGatewayAnalyticsBuilder extends GatewayAnalyticsBuilder<TopGatewayAnalyticsQuery, TopGatewayAnalyticsItem[]> {
508
- constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, sortBy: "requests" | "bandwidth", attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name");
509
- protected getAnalytics(): Promise<TopGatewayAnalyticsItem[]>;
510
- all(): Promise<TopGatewayAnalyticsItem[]>;
511
- }
512
- declare class TimeIntervalGatewayAnalyticsBuilder extends GatewayAnalyticsBuilder<TimeIntervalGatewayAnalyticsQuery, TimeIntervalGatewayAnalyticsResponse> {
513
- constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, dateInterval: "day" | "week");
514
- sortBy(sortBy: "requests" | "bandwidth"): this;
515
- protected getAnalytics(): Promise<TimeIntervalGatewayAnalyticsResponse>;
516
- all(): Promise<TimeIntervalGatewayAnalyticsResponse>;
517
- }
518
382
 
519
- export { type AuthTestResponse, type ContainsCIDResponse, type ContentType, type DataEndponts, type Endpoints, type FileObject, type GatewayAnalyticsQuery, type GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, type JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, type OptimizeImageOptions, type PinByCIDResponse, type PinJobItem, type PinJobQuery, type PinJobResponse, type PinListItem, type PinListQuery, type PinListResponse, type PinResponse, type PinataConfig, type PinataMetadata, type PinataMetadataUpdate, PinataSDK, type PinningEndpoints, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, type SwapCidOptions, type SwapCidResponse, type SwapHistoryOptions, type TimeIntervalGatewayAnalyticsQuery, type TimeIntervalGatewayAnalyticsResponse, type TimePeriodItem, type TopGatewayAnalyticsItem, type TopGatewayAnalyticsQuery, type UnpinResponse, type UpdateGroupOptions, type UploadCIDOptions, type UploadOptions, type UserPinnedDataResponse };
383
+ export { type AuthTestResponse, type ContainsCIDResponse, type ContentType, type DataEndponts, type DeleteResponse, type Endpoints, type FileListItem, type FileListQuery, type FileListResponse, type FileObject, type GatewayAnalyticsQuery, 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 SignedUrlOptions, type SwapCidOptions, type SwapCidResponse, type SwapHistoryOptions, type TimeIntervalGatewayAnalyticsQuery, type TimeIntervalGatewayAnalyticsResponse, type TimePeriodItem, type TopGatewayAnalyticsItem, type TopGatewayAnalyticsQuery, type UpdateFileOptions, type UpdateGroupOptions, type UploadOptions, type UploadResponse, type UserPinnedDataResponse };