pinata 0.3.4 → 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";
@@ -124,6 +91,24 @@ type GetCIDResponse = {
124
91
  data?: JSON | string | Blob | null;
125
92
  contentType: ContentType;
126
93
  };
94
+ type OptimizeImageOptions = {
95
+ width?: number;
96
+ height?: number;
97
+ dpr?: number;
98
+ fit?: "scaleDown" | "contain" | "cover" | "crop" | "pad";
99
+ gravity?: "auto" | "side" | string;
100
+ quality?: number;
101
+ format?: "auto" | "webp";
102
+ animation?: boolean;
103
+ sharpen?: number;
104
+ onError?: boolean;
105
+ metadata?: "keep" | "copyright" | "none";
106
+ };
107
+ type SignedUrlOptions = {
108
+ cid: string;
109
+ date?: number;
110
+ expires: number;
111
+ };
127
112
  type GatewayAnalyticsQuery = {
128
113
  gateway_domain: string;
129
114
  start_date: string;
@@ -236,25 +221,31 @@ type RevokeKeyResponse = {
236
221
  };
237
222
  type GroupOptions = {
238
223
  name: string;
224
+ isPublic?: boolean;
239
225
  };
240
226
  type UpdateGroupOptions = {
241
- name: string;
242
227
  groupId: string;
228
+ name?: string;
229
+ isPublic?: boolean;
243
230
  };
244
231
  type GetGroupOptions = {
245
232
  groupId: string;
246
233
  };
234
+ type GroupListResponse = {
235
+ groups: GroupResponseItem[];
236
+ next_page_token: string;
237
+ };
247
238
  type GroupResponseItem = {
248
239
  id: string;
249
- user_id: string;
240
+ is_public: boolean;
250
241
  name: string;
251
- updatedAt: string;
252
242
  createdAt: string;
253
243
  };
254
244
  type GroupQueryOptions = {
255
245
  nameContains?: string;
256
- offset?: number;
257
246
  limit?: number;
247
+ pageToken?: string;
248
+ isPublic?: boolean;
258
249
  };
259
250
  type GroupCIDOptions = {
260
251
  groupId: string;
@@ -280,22 +271,29 @@ type SwapCidResponse = {
280
271
  mappedCid: string;
281
272
  createdAt: string;
282
273
  };
274
+ type ContainsCIDResponse = {
275
+ containsCid: boolean;
276
+ cid: string | null;
277
+ };
283
278
 
284
279
  declare class PinataSDK {
285
280
  config: PinataConfig | undefined;
281
+ files: Files;
286
282
  upload: Upload;
287
283
  gateways: Gateways;
288
- usage: Usage;
289
284
  keys: Keys;
290
285
  groups: Groups;
291
- signatures: Signatures;
292
286
  constructor(config?: PinataConfig);
293
287
  setNewHeaders(headers: Record<string, string>): void;
294
288
  testAuthentication(): Promise<AuthTestResponse>;
295
- unpin(files: string[]): Promise<UnpinResponse[]>;
296
- listFiles(): FilterFiles;
297
- updateMetadata(options: PinataMetadataUpdate): Promise<string>;
298
- 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>;
299
297
  }
300
298
  declare class UploadBuilder<T> {
301
299
  private config;
@@ -303,98 +301,40 @@ declare class UploadBuilder<T> {
303
301
  private args;
304
302
  private metadata;
305
303
  private keys;
306
- private peerAddresses;
307
- private version;
308
304
  private groupId;
309
305
  constructor(config: PinataConfig | undefined, uploadFunction: (config: PinataConfig | undefined, ...args: any[]) => Promise<T>, ...args: any[]);
310
306
  addMetadata(metadata: PinataMetadata): UploadBuilder<T>;
311
307
  key(jwt: string): UploadBuilder<T>;
312
- cidVersion(v: 0 | 1): UploadBuilder<T>;
313
308
  group(groupId: string): UploadBuilder<T>;
314
- peerAddress(peerAddresses: string[]): UploadBuilder<T>;
315
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>;
316
310
  }
317
311
  declare class Upload {
318
312
  config: PinataConfig | undefined;
319
313
  constructor(config?: PinataConfig);
320
314
  updateConfig(newConfig: PinataConfig): void;
321
- file(file: FileObject, options?: UploadOptions): UploadBuilder<PinResponse>;
322
- fileArray(files: FileObject[], options?: UploadOptions): UploadBuilder<PinResponse>;
323
- base64(base64String: string, options?: UploadOptions): UploadBuilder<PinResponse>;
324
- url(url: string, options?: UploadOptions): UploadBuilder<PinResponse>;
325
- json(data: object, options?: UploadOptions): UploadBuilder<PinResponse>;
326
- 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>;
327
319
  }
328
320
  declare class FilterFiles {
329
321
  private config;
330
322
  private query;
331
- private requestCount;
332
- private lastRequestTime;
333
- private readonly MAX_REQUESTS_PER_MINUTE;
334
- private readonly MINUTE_IN_MS;
323
+ private currentPageToken;
335
324
  constructor(config: PinataConfig | undefined);
336
- cid(cid: string): FilterFiles;
337
- pinStart(date: string): FilterFiles;
338
- pinEnd(date: string): FilterFiles;
339
- pinSizeMin(size: number): FilterFiles;
340
- pinSizeMax(size: number): FilterFiles;
341
- pageLimit(limit: number): FilterFiles;
342
- pageOffset(offset: number): FilterFiles;
343
- name(name: string): FilterFiles;
344
- group(groupId: string): FilterFiles;
345
- keyValue(key: string, value: string | number, operator?: PinListQuery["operator"]): FilterFiles;
346
- then(onfulfilled?: ((value: PinListItem[]) => any) | null): Promise<any>;
347
- private rateLimit;
348
- [Symbol.asyncIterator](): AsyncGenerator<PinListItem, void, unknown>;
349
- 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[]>;
350
331
  }
351
332
  declare class Gateways {
352
333
  config: PinataConfig | undefined;
353
334
  constructor(config?: PinataConfig);
354
335
  updateConfig(newConfig: PinataConfig): void;
355
336
  get(cid: string): Promise<GetCIDResponse>;
356
- convert(url: string): Promise<string>;
357
- topUsageAnalytics(options: {
358
- domain: string;
359
- start: string;
360
- end: string;
361
- sortBy: "requests" | "bandwidth";
362
- attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name";
363
- }): TopGatewayAnalyticsBuilder;
364
- dateIntervalAnalytics(options: {
365
- domain: string;
366
- start: string;
367
- end: string;
368
- interval: "day" | "week";
369
- }): TimeIntervalGatewayAnalyticsBuilder;
370
- swapCid(options: SwapCidOptions): Promise<SwapCidResponse>;
371
- swapHistory(options: SwapHistoryOptions): Promise<SwapCidResponse[]>;
372
- deleteSwap(cid: string): Promise<string>;
373
- }
374
- declare class FilterPinJobs {
375
- private config;
376
- private query;
377
- private requestCount;
378
- private lastRequestTime;
379
- private readonly MAX_REQUESTS_PER_MINUTE;
380
- private readonly MINUTE_IN_MS;
381
- constructor(config: PinataConfig | undefined);
382
- cid(cid: string): FilterPinJobs;
383
- status(status: "prechecking" | "retrieving" | "expired" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node"): FilterPinJobs;
384
- pageLimit(limit: number): FilterPinJobs;
385
- pageOffset(offset: number): FilterPinJobs;
386
- sort(sort: "ASC" | "DSC"): FilterPinJobs;
387
- then(onfulfilled?: ((value: PinJobItem[]) => any) | null): Promise<any>;
388
- private rateLimit;
389
- [Symbol.asyncIterator](): AsyncGenerator<PinJobItem, void, unknown>;
390
- all(): Promise<PinJobItem[]>;
391
- }
392
- declare class Usage {
393
- config: PinataConfig | undefined;
394
- constructor(config?: PinataConfig);
395
- updateConfig(newConfig: PinataConfig): void;
396
- pinnedFileCount(): Promise<number>;
397
- totalStorageSize(): Promise<number>;
337
+ createSignedURL(options: SignedUrlOptions): Promise<string>;
398
338
  }
399
339
  declare class Keys {
400
340
  config: PinataConfig | undefined;
@@ -407,10 +347,6 @@ declare class Keys {
407
347
  declare class FilterKeys {
408
348
  private config;
409
349
  private query;
410
- private requestCount;
411
- private lastRequestTime;
412
- private readonly MAX_REQUESTS_PER_MINUTE;
413
- private readonly MINUTE_IN_MS;
414
350
  constructor(config: PinataConfig | undefined);
415
351
  offset(offset: number): FilterKeys;
416
352
  revoked(revoked: boolean): FilterKeys;
@@ -418,7 +354,6 @@ declare class FilterKeys {
418
354
  exhausted(exhausted: boolean): FilterKeys;
419
355
  name(name: string): FilterKeys;
420
356
  then(onfulfilled?: ((value: KeyListItem[]) => any) | null): Promise<any>;
421
- private rateLimit;
422
357
  [Symbol.asyncIterator](): AsyncGenerator<KeyListItem, void, unknown>;
423
358
  all(): Promise<KeyListItem[]>;
424
359
  }
@@ -429,65 +364,20 @@ declare class Groups {
429
364
  create(options: GroupOptions): Promise<GroupResponseItem>;
430
365
  list(): FilterGroups;
431
366
  get(options: GetGroupOptions): Promise<GroupResponseItem>;
432
- addCids(options: GroupCIDOptions): Promise<string>;
433
- removeCids(options: GroupCIDOptions): Promise<string>;
434
367
  update(options: UpdateGroupOptions): Promise<GroupResponseItem>;
435
368
  delete(options: GetGroupOptions): Promise<string>;
436
369
  }
437
370
  declare class FilterGroups {
438
371
  private config;
439
372
  private query;
440
- private requestCount;
441
- private lastRequestTime;
442
- private readonly MAX_REQUESTS_PER_MINUTE;
443
- private readonly MINUTE_IN_MS;
373
+ private nextPageToken;
444
374
  constructor(config: PinataConfig | undefined);
445
- offset(offset: number): FilterGroups;
446
- name(nameContains: string): FilterGroups;
447
375
  limit(limit: number): FilterGroups;
448
- then(onfulfilled?: ((value: GroupResponseItem[]) => any) | null): Promise<any>;
449
- private rateLimit;
376
+ isPublic(isPublic: boolean): FilterGroups;
377
+ then(onfulfilled?: ((value: GroupResponseItem[]) => any) | null): Promise<GroupResponseItem[]>;
378
+ private fetchPage;
450
379
  [Symbol.asyncIterator](): AsyncGenerator<GroupResponseItem, void, unknown>;
451
380
  all(): Promise<GroupResponseItem[]>;
452
381
  }
453
- declare class Signatures {
454
- config: PinataConfig | undefined;
455
- constructor(config?: PinataConfig);
456
- updateConfig(newConfig: PinataConfig): void;
457
- add(options: SignatureOptions): Promise<SignatureResponse>;
458
- get(cid: string): Promise<SignatureResponse>;
459
- delete(cid: string): Promise<string>;
460
- }
461
- declare class GatewayAnalyticsBuilder<T extends GatewayAnalyticsQuery, R> {
462
- protected config: PinataConfig | undefined;
463
- protected query: T;
464
- private requestCount;
465
- private lastRequestTime;
466
- private readonly MAX_REQUESTS_PER_MINUTE;
467
- private readonly MINUTE_IN_MS;
468
- constructor(config: PinataConfig | undefined, query: T);
469
- cid(cid: string): this;
470
- fileName(fileName: string): this;
471
- userAgent(userAgent: string): this;
472
- country(country: string): this;
473
- region(region: string): this;
474
- referer(referer: string): this;
475
- limit(limit: number): this;
476
- sort(order: "asc" | "desc"): this;
477
- private rateLimit;
478
- protected getAnalytics(): Promise<R>;
479
- then(onfulfilled?: ((value: R) => any) | null): Promise<any>;
480
- }
481
- declare class TopGatewayAnalyticsBuilder extends GatewayAnalyticsBuilder<TopGatewayAnalyticsQuery, TopGatewayAnalyticsItem[]> {
482
- constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, sortBy: "requests" | "bandwidth", attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name");
483
- protected getAnalytics(): Promise<TopGatewayAnalyticsItem[]>;
484
- all(): Promise<TopGatewayAnalyticsItem[]>;
485
- }
486
- declare class TimeIntervalGatewayAnalyticsBuilder extends GatewayAnalyticsBuilder<TimeIntervalGatewayAnalyticsQuery, TimeIntervalGatewayAnalyticsResponse> {
487
- constructor(config: PinataConfig | undefined, domain: string, start: string, end: string, dateInterval: "day" | "week");
488
- sortBy(sortBy: "requests" | "bandwidth"): this;
489
- protected getAnalytics(): Promise<TimeIntervalGatewayAnalyticsResponse>;
490
- all(): Promise<TimeIntervalGatewayAnalyticsResponse>;
491
- }
492
382
 
493
- export { type AuthTestResponse, 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 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 };