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/dist/index.mjs CHANGED
@@ -2528,13 +2528,13 @@ var uploadFile = async (config, file, network, options) => {
2528
2528
  const name = options?.metadata?.name || file.name || "File from SDK";
2529
2529
  let metadata = `filename ${btoa(name)},filetype ${btoa(file.type)},network ${btoa(network)}`;
2530
2530
  if (options?.groupId) {
2531
- metadata + `,group_id ${btoa(options.groupId)}`;
2531
+ metadata += `,group_id ${btoa(options.groupId)}`;
2532
2532
  }
2533
2533
  if (options?.metadata?.keyvalues) {
2534
- metadata + `,keyvalues ${btoa(JSON.stringify(options.metadata.keyvalues))}`;
2534
+ metadata += `,keyvalues ${btoa(JSON.stringify(options.metadata.keyvalues))}`;
2535
2535
  }
2536
2536
  if (options?.streamable) {
2537
- metadata + `,keyvalues ${btoa("true")}`;
2537
+ metadata += `,streamable ${btoa("true")}`;
2538
2538
  }
2539
2539
  let updatedEndpoint = `${endpoint}/files`;
2540
2540
  if (options?.url) {
@@ -2610,6 +2610,22 @@ var uploadFile = async (config, file, network, options) => {
2610
2610
  }
2611
2611
  if (uploadReq.status === 204) {
2612
2612
  const cid = uploadReq.headers.get("upload-cid");
2613
+ if (!config.pinataJwt) {
2614
+ const data3 = {
2615
+ id: "",
2616
+ name: "",
2617
+ cid,
2618
+ size: file.size,
2619
+ created_at: "",
2620
+ number_of_files: 1,
2621
+ group_id: null,
2622
+ mime_type: "",
2623
+ keyvalues: {},
2624
+ vectorized: false,
2625
+ network: ""
2626
+ };
2627
+ return data3;
2628
+ }
2613
2629
  let dataEndpoint;
2614
2630
  if (config.endpointUrl) {
2615
2631
  dataEndpoint = config.endpointUrl;
@@ -3402,8 +3418,11 @@ var AnalyticsFilter = class {
3402
3418
  this.query.end_date = end;
3403
3419
  return this;
3404
3420
  }
3405
- then(onfulfilled) {
3406
- return analyticsTopUsage(this.config, this.query).then(onfulfilled);
3421
+ then(onfulfilled, onrejected) {
3422
+ return analyticsTopUsage(this.config, this.query).then(
3423
+ onfulfilled,
3424
+ onrejected
3425
+ );
3407
3426
  }
3408
3427
  };
3409
3428
 
@@ -3485,8 +3504,8 @@ var AnalyticsBuilder = class {
3485
3504
  async getAnalytics() {
3486
3505
  throw new Error("getAnalytics method must be implemented in derived class");
3487
3506
  }
3488
- then(onfulfilled) {
3489
- return this.getAnalytics().then(onfulfilled);
3507
+ then(onfulfilled, onrejected) {
3508
+ return this.getAnalytics().then(onfulfilled, onrejected);
3490
3509
  }
3491
3510
  };
3492
3511
 
@@ -3555,11 +3574,11 @@ var FilterGroups = class {
3555
3574
  this.query.pageToken = pageToken;
3556
3575
  return this;
3557
3576
  }
3558
- then(onfulfilled) {
3577
+ then(onfulfilled, onrejected) {
3559
3578
  return this.fetchPage().then((response) => {
3560
3579
  this.nextPageToken = response.next_page_token;
3561
3580
  return response;
3562
- }).then(onfulfilled);
3581
+ }).then(onfulfilled, onrejected);
3563
3582
  }
3564
3583
  async fetchPage() {
3565
3584
  if (this.nextPageToken) {
@@ -3726,8 +3745,8 @@ var FilterKeys = class {
3726
3745
  this.query.name = name;
3727
3746
  return this;
3728
3747
  }
3729
- then(onfulfilled) {
3730
- return listKeys(this.config, this.query).then(onfulfilled);
3748
+ then(onfulfilled, onrejected) {
3749
+ return listKeys(this.config, this.query).then(onfulfilled, onrejected);
3731
3750
  }
3732
3751
  // private async rateLimit(): Promise<void> {
3733
3752
  // this.requestCount++;
@@ -3790,9 +3809,10 @@ var OptimizeImageCreateAccessLink = class {
3790
3809
  this.imgOpts = { ...this.imgOpts, ...options };
3791
3810
  return this;
3792
3811
  }
3793
- then(onfulfilled) {
3812
+ then(onfulfilled, onrejected) {
3794
3813
  return createAccessLink(this.config, this.urlOpts, this.imgOpts).then(
3795
- onfulfilled
3814
+ onfulfilled,
3815
+ onrejected
3796
3816
  );
3797
3817
  }
3798
3818
  };
@@ -3809,9 +3829,10 @@ var OptimizeImageGetCid = class {
3809
3829
  this.options = { ...this.options, ...options };
3810
3830
  return this;
3811
3831
  }
3812
- then(onfulfilled) {
3832
+ then(onfulfilled, onrejected) {
3813
3833
  return getCid(this.config, this.cid, this.gatewayType, this.options).then(
3814
- onfulfilled
3834
+ onfulfilled,
3835
+ onrejected
3815
3836
  );
3816
3837
  }
3817
3838
  };
@@ -3961,8 +3982,8 @@ var FilterFiles = class {
3961
3982
  this.query.pageToken = pageToken;
3962
3983
  return this;
3963
3984
  }
3964
- then(onfulfilled) {
3965
- return this.fetchPage().then(onfulfilled);
3985
+ then(onfulfilled, onrejected) {
3986
+ return this.fetchPage().then(onfulfilled, onrejected);
3966
3987
  }
3967
3988
  async fetchPage() {
3968
3989
  if (this.currentPageToken) {
@@ -4045,8 +4066,8 @@ var FilterQueue = class {
4045
4066
  this.query.sort = sort;
4046
4067
  return this;
4047
4068
  }
4048
- then(onfulfilled) {
4049
- return queue(this.config, this.query).then(onfulfilled);
4069
+ then(onfulfilled, onrejected) {
4070
+ return queue(this.config, this.query).then(onfulfilled, onrejected);
4050
4071
  }
4051
4072
  // rate limit, hopefully temporary?
4052
4073
  async rateLimit() {