pinata 2.4.7 → 2.4.9
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/LICENSE +0 -0
- package/README.md +1 -0
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +40 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +68 -68
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -274,7 +274,7 @@ declare class AnalyticsFilter {
|
|
|
274
274
|
limit(limit: number): this;
|
|
275
275
|
sort(order: "asc" | "desc"): this;
|
|
276
276
|
days(numberOfDays: number): this;
|
|
277
|
-
then(onfulfilled?: ((value: TopAnalyticsResponse) => any) | null): Promise<any>;
|
|
277
|
+
then(onfulfilled?: ((value: TopAnalyticsResponse) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
declare class AnalyticsBandwidth extends AnalyticsFilter {
|
|
@@ -301,7 +301,7 @@ declare class AnalyticsBuilder<T extends AnalyticsQuery, R> {
|
|
|
301
301
|
limit(limit: number): this;
|
|
302
302
|
sort(order: "asc" | "desc"): this;
|
|
303
303
|
protected getAnalytics(): Promise<R>;
|
|
304
|
-
then(onfulfilled?: ((value: R) => any) | null): Promise<any>;
|
|
304
|
+
then(onfulfilled?: ((value: R) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
declare class AnalyticsRequests extends AnalyticsFilter {
|
|
@@ -328,7 +328,7 @@ declare class FilterGroups {
|
|
|
328
328
|
limit(limit: number): FilterGroups;
|
|
329
329
|
isPublic(isPublic: boolean): FilterGroups;
|
|
330
330
|
pageToken(pageToken: string): FilterGroups;
|
|
331
|
-
then(onfulfilled?: ((value: GroupListResponse) => any) | null): Promise<GroupListResponse>;
|
|
331
|
+
then(onfulfilled?: ((value: GroupListResponse) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<GroupListResponse>;
|
|
332
332
|
private fetchPage;
|
|
333
333
|
[Symbol.asyncIterator](): AsyncGenerator<GroupResponseItem, void, unknown>;
|
|
334
334
|
all(): Promise<GroupResponseItem[]>;
|
|
@@ -386,7 +386,7 @@ declare class FilterKeys {
|
|
|
386
386
|
limitedUse(limitedUse: boolean): FilterKeys;
|
|
387
387
|
exhausted(exhausted: boolean): FilterKeys;
|
|
388
388
|
name(name: string): FilterKeys;
|
|
389
|
-
then(onfulfilled?: ((value: KeyListItem[]) => any) | null): Promise<any>;
|
|
389
|
+
then(onfulfilled?: ((value: KeyListItem[]) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
390
390
|
[Symbol.asyncIterator](): AsyncGenerator<KeyListItem, void, unknown>;
|
|
391
391
|
all(): Promise<KeyListItem[]>;
|
|
392
392
|
}
|
|
@@ -405,7 +405,7 @@ declare class OptimizeImageCreateAccessLink {
|
|
|
405
405
|
private imgOpts;
|
|
406
406
|
constructor(config: PinataConfig | undefined, urlOpts: AccessLinkOptions);
|
|
407
407
|
optimizeImage(options: OptimizeImageOptions): OptimizeImageCreateAccessLink;
|
|
408
|
-
then(onfulfilled?: ((value: string) => any) | null): Promise<any>;
|
|
408
|
+
then(onfulfilled?: ((value: string) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
declare class OptimizeImageGetCid {
|
|
@@ -415,7 +415,7 @@ declare class OptimizeImageGetCid {
|
|
|
415
415
|
private options;
|
|
416
416
|
constructor(config: PinataConfig | undefined, cid: string, gatewayType?: "ipfs" | "files");
|
|
417
417
|
optimizeImage(options: OptimizeImageOptions): OptimizeImageGetCid;
|
|
418
|
-
then(onfulfilled?: ((value: GetCIDResponse) => any) | null): Promise<any>;
|
|
418
|
+
then(onfulfilled?: ((value: GetCIDResponse) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
declare class PrivateGateways {
|
|
@@ -448,7 +448,7 @@ declare class FilterFiles {
|
|
|
448
448
|
keyvalues(keyvalues: Record<string, string>): FilterFiles;
|
|
449
449
|
noGroup(noGroup: boolean): FilterFiles;
|
|
450
450
|
pageToken(pageToken: string): FilterFiles;
|
|
451
|
-
then(onfulfilled?: ((value: FileListResponse) => any) | null): Promise<any>;
|
|
451
|
+
then(onfulfilled?: ((value: FileListResponse) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
452
452
|
private fetchPage;
|
|
453
453
|
[Symbol.asyncIterator](): AsyncGenerator<FileListItem, void, unknown>;
|
|
454
454
|
all(): Promise<FileListItem[]>;
|
|
@@ -469,7 +469,7 @@ declare class FilterQueue {
|
|
|
469
469
|
pageToken(pageToken: string): FilterQueue;
|
|
470
470
|
private fetchPage;
|
|
471
471
|
sort(sort: "ASC" | "DSC"): FilterQueue;
|
|
472
|
-
then(onfulfilled?: ((value: PinQueueResponse) => any) | null): Promise<any>;
|
|
472
|
+
then(onfulfilled?: ((value: PinQueueResponse) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
473
473
|
private rateLimit;
|
|
474
474
|
[Symbol.asyncIterator](): AsyncGenerator<PinQueueItem, void, unknown>;
|
|
475
475
|
all(): Promise<PinQueueItem[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -274,7 +274,7 @@ declare class AnalyticsFilter {
|
|
|
274
274
|
limit(limit: number): this;
|
|
275
275
|
sort(order: "asc" | "desc"): this;
|
|
276
276
|
days(numberOfDays: number): this;
|
|
277
|
-
then(onfulfilled?: ((value: TopAnalyticsResponse) => any) | null): Promise<any>;
|
|
277
|
+
then(onfulfilled?: ((value: TopAnalyticsResponse) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
declare class AnalyticsBandwidth extends AnalyticsFilter {
|
|
@@ -301,7 +301,7 @@ declare class AnalyticsBuilder<T extends AnalyticsQuery, R> {
|
|
|
301
301
|
limit(limit: number): this;
|
|
302
302
|
sort(order: "asc" | "desc"): this;
|
|
303
303
|
protected getAnalytics(): Promise<R>;
|
|
304
|
-
then(onfulfilled?: ((value: R) => any) | null): Promise<any>;
|
|
304
|
+
then(onfulfilled?: ((value: R) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
declare class AnalyticsRequests extends AnalyticsFilter {
|
|
@@ -328,7 +328,7 @@ declare class FilterGroups {
|
|
|
328
328
|
limit(limit: number): FilterGroups;
|
|
329
329
|
isPublic(isPublic: boolean): FilterGroups;
|
|
330
330
|
pageToken(pageToken: string): FilterGroups;
|
|
331
|
-
then(onfulfilled?: ((value: GroupListResponse) => any) | null): Promise<GroupListResponse>;
|
|
331
|
+
then(onfulfilled?: ((value: GroupListResponse) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<GroupListResponse>;
|
|
332
332
|
private fetchPage;
|
|
333
333
|
[Symbol.asyncIterator](): AsyncGenerator<GroupResponseItem, void, unknown>;
|
|
334
334
|
all(): Promise<GroupResponseItem[]>;
|
|
@@ -386,7 +386,7 @@ declare class FilterKeys {
|
|
|
386
386
|
limitedUse(limitedUse: boolean): FilterKeys;
|
|
387
387
|
exhausted(exhausted: boolean): FilterKeys;
|
|
388
388
|
name(name: string): FilterKeys;
|
|
389
|
-
then(onfulfilled?: ((value: KeyListItem[]) => any) | null): Promise<any>;
|
|
389
|
+
then(onfulfilled?: ((value: KeyListItem[]) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
390
390
|
[Symbol.asyncIterator](): AsyncGenerator<KeyListItem, void, unknown>;
|
|
391
391
|
all(): Promise<KeyListItem[]>;
|
|
392
392
|
}
|
|
@@ -405,7 +405,7 @@ declare class OptimizeImageCreateAccessLink {
|
|
|
405
405
|
private imgOpts;
|
|
406
406
|
constructor(config: PinataConfig | undefined, urlOpts: AccessLinkOptions);
|
|
407
407
|
optimizeImage(options: OptimizeImageOptions): OptimizeImageCreateAccessLink;
|
|
408
|
-
then(onfulfilled?: ((value: string) => any) | null): Promise<any>;
|
|
408
|
+
then(onfulfilled?: ((value: string) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
declare class OptimizeImageGetCid {
|
|
@@ -415,7 +415,7 @@ declare class OptimizeImageGetCid {
|
|
|
415
415
|
private options;
|
|
416
416
|
constructor(config: PinataConfig | undefined, cid: string, gatewayType?: "ipfs" | "files");
|
|
417
417
|
optimizeImage(options: OptimizeImageOptions): OptimizeImageGetCid;
|
|
418
|
-
then(onfulfilled?: ((value: GetCIDResponse) => any) | null): Promise<any>;
|
|
418
|
+
then(onfulfilled?: ((value: GetCIDResponse) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
declare class PrivateGateways {
|
|
@@ -448,7 +448,7 @@ declare class FilterFiles {
|
|
|
448
448
|
keyvalues(keyvalues: Record<string, string>): FilterFiles;
|
|
449
449
|
noGroup(noGroup: boolean): FilterFiles;
|
|
450
450
|
pageToken(pageToken: string): FilterFiles;
|
|
451
|
-
then(onfulfilled?: ((value: FileListResponse) => any) | null): Promise<any>;
|
|
451
|
+
then(onfulfilled?: ((value: FileListResponse) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
452
452
|
private fetchPage;
|
|
453
453
|
[Symbol.asyncIterator](): AsyncGenerator<FileListItem, void, unknown>;
|
|
454
454
|
all(): Promise<FileListItem[]>;
|
|
@@ -469,7 +469,7 @@ declare class FilterQueue {
|
|
|
469
469
|
pageToken(pageToken: string): FilterQueue;
|
|
470
470
|
private fetchPage;
|
|
471
471
|
sort(sort: "ASC" | "DSC"): FilterQueue;
|
|
472
|
-
then(onfulfilled?: ((value: PinQueueResponse) => any) | null): Promise<any>;
|
|
472
|
+
then(onfulfilled?: ((value: PinQueueResponse) => any) | null, onrejected?: ((reason: any) => any) | null): Promise<any>;
|
|
473
473
|
private rateLimit;
|
|
474
474
|
[Symbol.asyncIterator](): AsyncGenerator<PinQueueItem, void, unknown>;
|
|
475
475
|
all(): Promise<PinQueueItem[]>;
|
package/dist/index.js
CHANGED
|
@@ -2529,13 +2529,13 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2529
2529
|
const name = options?.metadata?.name || file.name || "File from SDK";
|
|
2530
2530
|
let metadata = `filename ${btoa(name)},filetype ${btoa(file.type)},network ${btoa(network)}`;
|
|
2531
2531
|
if (options?.groupId) {
|
|
2532
|
-
metadata
|
|
2532
|
+
metadata += `,group_id ${btoa(options.groupId)}`;
|
|
2533
2533
|
}
|
|
2534
2534
|
if (options?.metadata?.keyvalues) {
|
|
2535
|
-
metadata
|
|
2535
|
+
metadata += `,keyvalues ${btoa(JSON.stringify(options.metadata.keyvalues))}`;
|
|
2536
2536
|
}
|
|
2537
2537
|
if (options?.streamable) {
|
|
2538
|
-
metadata
|
|
2538
|
+
metadata += `,streamable ${btoa("true")}`;
|
|
2539
2539
|
}
|
|
2540
2540
|
let updatedEndpoint = `${endpoint}/files`;
|
|
2541
2541
|
if (options?.url) {
|
|
@@ -2611,6 +2611,22 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2611
2611
|
}
|
|
2612
2612
|
if (uploadReq.status === 204) {
|
|
2613
2613
|
const cid = uploadReq.headers.get("upload-cid");
|
|
2614
|
+
if (!config.pinataJwt) {
|
|
2615
|
+
const data3 = {
|
|
2616
|
+
id: "",
|
|
2617
|
+
name: "",
|
|
2618
|
+
cid,
|
|
2619
|
+
size: file.size,
|
|
2620
|
+
created_at: "",
|
|
2621
|
+
number_of_files: 1,
|
|
2622
|
+
group_id: null,
|
|
2623
|
+
mime_type: "",
|
|
2624
|
+
keyvalues: {},
|
|
2625
|
+
vectorized: false,
|
|
2626
|
+
network: ""
|
|
2627
|
+
};
|
|
2628
|
+
return data3;
|
|
2629
|
+
}
|
|
2614
2630
|
let dataEndpoint;
|
|
2615
2631
|
if (config.endpointUrl) {
|
|
2616
2632
|
dataEndpoint = config.endpointUrl;
|
|
@@ -3403,8 +3419,11 @@ var AnalyticsFilter = class {
|
|
|
3403
3419
|
this.query.end_date = end;
|
|
3404
3420
|
return this;
|
|
3405
3421
|
}
|
|
3406
|
-
then(onfulfilled) {
|
|
3407
|
-
return analyticsTopUsage(this.config, this.query).then(
|
|
3422
|
+
then(onfulfilled, onrejected) {
|
|
3423
|
+
return analyticsTopUsage(this.config, this.query).then(
|
|
3424
|
+
onfulfilled,
|
|
3425
|
+
onrejected
|
|
3426
|
+
);
|
|
3408
3427
|
}
|
|
3409
3428
|
};
|
|
3410
3429
|
|
|
@@ -3486,8 +3505,8 @@ var AnalyticsBuilder = class {
|
|
|
3486
3505
|
async getAnalytics() {
|
|
3487
3506
|
throw new Error("getAnalytics method must be implemented in derived class");
|
|
3488
3507
|
}
|
|
3489
|
-
then(onfulfilled) {
|
|
3490
|
-
return this.getAnalytics().then(onfulfilled);
|
|
3508
|
+
then(onfulfilled, onrejected) {
|
|
3509
|
+
return this.getAnalytics().then(onfulfilled, onrejected);
|
|
3491
3510
|
}
|
|
3492
3511
|
};
|
|
3493
3512
|
|
|
@@ -3556,11 +3575,11 @@ var FilterGroups = class {
|
|
|
3556
3575
|
this.query.pageToken = pageToken;
|
|
3557
3576
|
return this;
|
|
3558
3577
|
}
|
|
3559
|
-
then(onfulfilled) {
|
|
3578
|
+
then(onfulfilled, onrejected) {
|
|
3560
3579
|
return this.fetchPage().then((response) => {
|
|
3561
3580
|
this.nextPageToken = response.next_page_token;
|
|
3562
3581
|
return response;
|
|
3563
|
-
}).then(onfulfilled);
|
|
3582
|
+
}).then(onfulfilled, onrejected);
|
|
3564
3583
|
}
|
|
3565
3584
|
async fetchPage() {
|
|
3566
3585
|
if (this.nextPageToken) {
|
|
@@ -3727,8 +3746,8 @@ var FilterKeys = class {
|
|
|
3727
3746
|
this.query.name = name;
|
|
3728
3747
|
return this;
|
|
3729
3748
|
}
|
|
3730
|
-
then(onfulfilled) {
|
|
3731
|
-
return listKeys(this.config, this.query).then(onfulfilled);
|
|
3749
|
+
then(onfulfilled, onrejected) {
|
|
3750
|
+
return listKeys(this.config, this.query).then(onfulfilled, onrejected);
|
|
3732
3751
|
}
|
|
3733
3752
|
// private async rateLimit(): Promise<void> {
|
|
3734
3753
|
// this.requestCount++;
|
|
@@ -3791,9 +3810,10 @@ var OptimizeImageCreateAccessLink = class {
|
|
|
3791
3810
|
this.imgOpts = { ...this.imgOpts, ...options };
|
|
3792
3811
|
return this;
|
|
3793
3812
|
}
|
|
3794
|
-
then(onfulfilled) {
|
|
3813
|
+
then(onfulfilled, onrejected) {
|
|
3795
3814
|
return createAccessLink(this.config, this.urlOpts, this.imgOpts).then(
|
|
3796
|
-
onfulfilled
|
|
3815
|
+
onfulfilled,
|
|
3816
|
+
onrejected
|
|
3797
3817
|
);
|
|
3798
3818
|
}
|
|
3799
3819
|
};
|
|
@@ -3810,9 +3830,10 @@ var OptimizeImageGetCid = class {
|
|
|
3810
3830
|
this.options = { ...this.options, ...options };
|
|
3811
3831
|
return this;
|
|
3812
3832
|
}
|
|
3813
|
-
then(onfulfilled) {
|
|
3833
|
+
then(onfulfilled, onrejected) {
|
|
3814
3834
|
return getCid(this.config, this.cid, this.gatewayType, this.options).then(
|
|
3815
|
-
onfulfilled
|
|
3835
|
+
onfulfilled,
|
|
3836
|
+
onrejected
|
|
3816
3837
|
);
|
|
3817
3838
|
}
|
|
3818
3839
|
};
|
|
@@ -3962,8 +3983,8 @@ var FilterFiles = class {
|
|
|
3962
3983
|
this.query.pageToken = pageToken;
|
|
3963
3984
|
return this;
|
|
3964
3985
|
}
|
|
3965
|
-
then(onfulfilled) {
|
|
3966
|
-
return this.fetchPage().then(onfulfilled);
|
|
3986
|
+
then(onfulfilled, onrejected) {
|
|
3987
|
+
return this.fetchPage().then(onfulfilled, onrejected);
|
|
3967
3988
|
}
|
|
3968
3989
|
async fetchPage() {
|
|
3969
3990
|
if (this.currentPageToken) {
|
|
@@ -4046,8 +4067,8 @@ var FilterQueue = class {
|
|
|
4046
4067
|
this.query.sort = sort;
|
|
4047
4068
|
return this;
|
|
4048
4069
|
}
|
|
4049
|
-
then(onfulfilled) {
|
|
4050
|
-
return queue(this.config, this.query).then(onfulfilled);
|
|
4070
|
+
then(onfulfilled, onrejected) {
|
|
4071
|
+
return queue(this.config, this.query).then(onfulfilled, onrejected);
|
|
4051
4072
|
}
|
|
4052
4073
|
// rate limit, hopefully temporary?
|
|
4053
4074
|
async rateLimit() {
|