pinata 2.5.0 → 2.5.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.
@@ -156,6 +156,7 @@ type UploadOptions = {
156
156
  url?: string;
157
157
  streamable?: boolean;
158
158
  peerAddresses?: string[];
159
+ car?: boolean;
159
160
  };
160
161
  type SignedUploadUrlOptions = {
161
162
  date?: number;
@@ -167,6 +168,7 @@ type SignedUploadUrlOptions = {
167
168
  maxFileSize?: number;
168
169
  mimeTypes?: string[];
169
170
  streamable?: boolean;
171
+ car?: boolean;
170
172
  };
171
173
  type UploadCIDOptions = {
172
174
  metadata?: PinataMetadata;
@@ -156,6 +156,7 @@ type UploadOptions = {
156
156
  url?: string;
157
157
  streamable?: boolean;
158
158
  peerAddresses?: string[];
159
+ car?: boolean;
159
160
  };
160
161
  type SignedUploadUrlOptions = {
161
162
  date?: number;
@@ -167,6 +168,7 @@ type SignedUploadUrlOptions = {
167
168
  maxFileSize?: number;
168
169
  mimeTypes?: string[];
169
170
  streamable?: boolean;
171
+ car?: boolean;
170
172
  };
171
173
  type UploadCIDOptions = {
172
174
  metadata?: PinataMetadata;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DeleteResponse, V as VectorizeFileResponse, F as FileListQuery, a as FileListResponse, S as SwapCidOptions, b as SwapCidResponse, c as SwapHistoryOptions, U as UpdateFileOptions, d as FileListItem, e as VectorizeQuery, f as VectorizeQueryResponse, G as GetCIDResponse, P as PinQueueQuery, g as PinQueueResponse, O as OptimizeImageOptions, A as AccessLinkOptions, h as UploadOptions, i as UploadResponse, j as SignedUploadUrlOptions, J as JsonBody, k as UploadCIDOptions, l as PinByCIDResponse, m as PinQueueItem } from './gateway-tools-l9hk7kz4.mjs';
2
- export { s as AuthenticationError, q as ContainsCIDResponse, C as ContentType, n as FileObject, N as NetworkError, r as PinataError, o as PinataMetadata, t as ValidationError, p as VectorQueryMatch, u as containsCID, v as convertToDesiredGateway } from './gateway-tools-l9hk7kz4.mjs';
1
+ import { D as DeleteResponse, V as VectorizeFileResponse, F as FileListQuery, a as FileListResponse, S as SwapCidOptions, b as SwapCidResponse, c as SwapHistoryOptions, U as UpdateFileOptions, d as FileListItem, e as VectorizeQuery, f as VectorizeQueryResponse, G as GetCIDResponse, P as PinQueueQuery, g as PinQueueResponse, O as OptimizeImageOptions, A as AccessLinkOptions, h as UploadOptions, i as UploadResponse, j as SignedUploadUrlOptions, J as JsonBody, k as UploadCIDOptions, l as PinByCIDResponse, m as PinQueueItem } from './gateway-tools-Cd7xutmh.mjs';
2
+ export { s as AuthenticationError, q as ContainsCIDResponse, C as ContentType, n as FileObject, N as NetworkError, r as PinataError, o as PinataMetadata, t as ValidationError, p as VectorQueryMatch, u as containsCID, v as convertToDesiredGateway } from './gateway-tools-Cd7xutmh.mjs';
3
3
 
4
4
  type PinataConfig = {
5
5
  pinataJwt?: string;
@@ -523,6 +523,7 @@ declare class UploadBuilder<T> {
523
523
  private uploadUrl;
524
524
  private isStreamable;
525
525
  private peerAddresses;
526
+ private carFormat;
526
527
  constructor(config: PinataConfig | undefined, uploadFunction: (config: PinataConfig | undefined, ...args: any[]) => Promise<T>, ...args: any[]);
527
528
  name(name: string): UploadBuilder<T>;
528
529
  keyvalues(keyvalues: Record<string, string>): UploadBuilder<T>;
@@ -531,6 +532,7 @@ declare class UploadBuilder<T> {
531
532
  url(url: string): UploadBuilder<T>;
532
533
  group(groupId: string): UploadBuilder<T>;
533
534
  streamable(): UploadBuilder<T>;
535
+ car(): UploadBuilder<T>;
534
536
  peerAddress(peerAddresses: string[]): UploadBuilder<T>;
535
537
  then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
536
538
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DeleteResponse, V as VectorizeFileResponse, F as FileListQuery, a as FileListResponse, S as SwapCidOptions, b as SwapCidResponse, c as SwapHistoryOptions, U as UpdateFileOptions, d as FileListItem, e as VectorizeQuery, f as VectorizeQueryResponse, G as GetCIDResponse, P as PinQueueQuery, g as PinQueueResponse, O as OptimizeImageOptions, A as AccessLinkOptions, h as UploadOptions, i as UploadResponse, j as SignedUploadUrlOptions, J as JsonBody, k as UploadCIDOptions, l as PinByCIDResponse, m as PinQueueItem } from './gateway-tools-l9hk7kz4.js';
2
- export { s as AuthenticationError, q as ContainsCIDResponse, C as ContentType, n as FileObject, N as NetworkError, r as PinataError, o as PinataMetadata, t as ValidationError, p as VectorQueryMatch, u as containsCID, v as convertToDesiredGateway } from './gateway-tools-l9hk7kz4.js';
1
+ import { D as DeleteResponse, V as VectorizeFileResponse, F as FileListQuery, a as FileListResponse, S as SwapCidOptions, b as SwapCidResponse, c as SwapHistoryOptions, U as UpdateFileOptions, d as FileListItem, e as VectorizeQuery, f as VectorizeQueryResponse, G as GetCIDResponse, P as PinQueueQuery, g as PinQueueResponse, O as OptimizeImageOptions, A as AccessLinkOptions, h as UploadOptions, i as UploadResponse, j as SignedUploadUrlOptions, J as JsonBody, k as UploadCIDOptions, l as PinByCIDResponse, m as PinQueueItem } from './gateway-tools-Cd7xutmh.js';
2
+ export { s as AuthenticationError, q as ContainsCIDResponse, C as ContentType, n as FileObject, N as NetworkError, r as PinataError, o as PinataMetadata, t as ValidationError, p as VectorQueryMatch, u as containsCID, v as convertToDesiredGateway } from './gateway-tools-Cd7xutmh.js';
3
3
 
4
4
  type PinataConfig = {
5
5
  pinataJwt?: string;
@@ -523,6 +523,7 @@ declare class UploadBuilder<T> {
523
523
  private uploadUrl;
524
524
  private isStreamable;
525
525
  private peerAddresses;
526
+ private carFormat;
526
527
  constructor(config: PinataConfig | undefined, uploadFunction: (config: PinataConfig | undefined, ...args: any[]) => Promise<T>, ...args: any[]);
527
528
  name(name: string): UploadBuilder<T>;
528
529
  keyvalues(keyvalues: Record<string, string>): UploadBuilder<T>;
@@ -531,6 +532,7 @@ declare class UploadBuilder<T> {
531
532
  url(url: string): UploadBuilder<T>;
532
533
  group(groupId: string): UploadBuilder<T>;
533
534
  streamable(): UploadBuilder<T>;
535
+ car(): UploadBuilder<T>;
534
536
  peerAddress(peerAddresses: string[]): UploadBuilder<T>;
535
537
  then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
536
538
  }
package/dist/index.js CHANGED
@@ -2458,9 +2458,8 @@ var createSignedUploadURL = async (config, options, network) => {
2458
2458
  Source: "sdk/createSignURL"
2459
2459
  };
2460
2460
  }
2461
- let retryCount = 0;
2462
2461
  const maxRetries = 3;
2463
- while (retryCount <= maxRetries) {
2462
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
2464
2463
  try {
2465
2464
  const request = await fetch(`${endpoint}/files/sign`, {
2466
2465
  method: "POST",
@@ -2483,21 +2482,13 @@ var createSignedUploadURL = async (config, options, network) => {
2483
2482
  }
2484
2483
  );
2485
2484
  }
2486
- const error = new chunkBK3CLF3Z_js.NetworkError(
2487
- `HTTP error: ${errorData}`,
2488
- request.status,
2489
- {
2490
- error: errorData,
2491
- code: "HTTP_ERROR",
2492
- metadata: {
2493
- requestUrl: request.url
2494
- }
2485
+ throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
2486
+ error: errorData,
2487
+ code: "HTTP_ERROR",
2488
+ metadata: {
2489
+ requestUrl: request.url
2495
2490
  }
2496
- );
2497
- if (request.status >= 400 && request.status < 500 && request.status !== 429) {
2498
- throw error;
2499
- }
2500
- throw error;
2491
+ });
2501
2492
  }
2502
2493
  const res = await request.json();
2503
2494
  return res.data;
@@ -2508,27 +2499,24 @@ var createSignedUploadURL = async (config, options, network) => {
2508
2499
  if (error instanceof chunkBK3CLF3Z_js.NetworkError && error.statusCode && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429) {
2509
2500
  throw error;
2510
2501
  }
2511
- retryCount++;
2512
- if (retryCount > maxRetries) {
2502
+ if (attempt === maxRetries) {
2513
2503
  if (error instanceof chunkBK3CLF3Z_js.PinataError) {
2514
2504
  throw error;
2515
2505
  }
2516
2506
  if (error instanceof Error) {
2517
2507
  throw new chunkBK3CLF3Z_js.PinataError(
2518
- `Error processing createSignedURL after ${maxRetries} retries: ${error.message}`
2508
+ `Error processing createSignedURL: ${error.message}`
2519
2509
  );
2520
2510
  }
2521
2511
  throw new chunkBK3CLF3Z_js.PinataError(
2522
- `An unknown error occurred while getting signed url after ${maxRetries} retries`
2512
+ "An unknown error occurred while getting signed url"
2523
2513
  );
2524
2514
  }
2525
- const delay = Math.min(1e3 * Math.pow(2, retryCount - 1), 4e3);
2515
+ const delay = Math.min(1e3 * Math.pow(2, attempt), 4e3);
2526
2516
  await new Promise((resolve) => setTimeout(resolve, delay));
2527
2517
  }
2528
2518
  }
2529
- return Promise.reject(
2530
- new chunkBK3CLF3Z_js.PinataError("Unexpected error: retry loop completed without resolution")
2531
- );
2519
+ throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while getting signed url");
2532
2520
  };
2533
2521
 
2534
2522
  // src/core/functions/uploads/file.ts
@@ -2565,6 +2553,9 @@ var uploadFile = async (config, file, network, options) => {
2565
2553
  if (options?.streamable) {
2566
2554
  metadata += `,streamable ${btoa("true")}`;
2567
2555
  }
2556
+ if (options?.car) {
2557
+ metadata += `,car ${btoa("true")}`;
2558
+ }
2568
2559
  let updatedEndpoint = `${endpoint}/files`;
2569
2560
  if (options?.url) {
2570
2561
  updatedEndpoint = options.url;
@@ -2728,6 +2719,9 @@ var uploadFile = async (config, file, network, options) => {
2728
2719
  if (options?.streamable) {
2729
2720
  data.append("streamable", "true");
2730
2721
  }
2722
+ if (options?.car) {
2723
+ data.append("car", "true");
2724
+ }
2731
2725
  if (options?.url) {
2732
2726
  try {
2733
2727
  const request = await fetch(options.url, {
@@ -4262,6 +4256,10 @@ var UploadBuilder = class {
4262
4256
  this.isStreamable = true;
4263
4257
  return this;
4264
4258
  }
4259
+ car() {
4260
+ this.carFormat = true;
4261
+ return this;
4262
+ }
4265
4263
  peerAddress(peerAddresses) {
4266
4264
  this.peerAddresses = peerAddresses;
4267
4265
  return this;
@@ -4289,6 +4287,9 @@ var UploadBuilder = class {
4289
4287
  if (this.peerAddresses) {
4290
4288
  options.peerAddresses = this.peerAddresses;
4291
4289
  }
4290
+ if (this.carFormat) {
4291
+ options.car = this.carFormat;
4292
+ }
4292
4293
  this.args[this.args.length - 1] = options;
4293
4294
  return this.uploadFunction(this.config, ...this.args).then(
4294
4295
  onfulfilled,