@edgebound/bigcommerce 0.5.7 → 0.5.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.
Files changed (33) hide show
  1. package/dist/bigcommerce-entities/b2b-orders/b2b-orders.service.d.ts +1 -1
  2. package/dist/bigcommerce-entities/companies/companies.service.d.ts +15 -15
  3. package/dist/bigcommerce-entities/companies/schemas/credit.schemas.d.ts +1 -0
  4. package/dist/bigcommerce-entities/companies/schemas/credit.schemas.d.ts.map +1 -1
  5. package/dist/bigcommerce-entities/companies/schemas/credit.schemas.js +1 -1
  6. package/dist/bigcommerce-entities/companies/schemas/credit.schemas.js.map +1 -1
  7. package/dist/bigcommerce-entities/customers/customers.service.d.ts +9 -9
  8. package/dist/bigcommerce-entities/orders/orders.service.d.ts +7 -7
  9. package/dist/bigcommerce-entities/payments/payments.service.d.ts +1 -1
  10. package/dist/bigcommerce-entities/price-lists/price-lists.service.d.ts +3 -3
  11. package/dist/bigcommerce-entities/products/products.service.d.ts +3 -3
  12. package/dist/bigcommerce-entities/sales-staff/sales-staff.service.d.ts +2 -2
  13. package/dist/core/bigcommerce-fetcher.service.d.ts +4 -4
  14. package/dist/core/bigcommerce-fetcher.service.d.ts.map +1 -1
  15. package/dist/core/bigcommerce-fetcher.service.js +14 -14
  16. package/dist/core/bigcommerce-fetcher.service.js.map +1 -1
  17. package/dist/core/bigcommerce.error.d.ts +17 -39
  18. package/dist/core/bigcommerce.error.d.ts.map +1 -1
  19. package/dist/core/bigcommerce.error.js +60 -64
  20. package/dist/core/bigcommerce.error.js.map +1 -1
  21. package/dist/utils/index.d.ts +2 -2
  22. package/dist/utils/index.d.ts.map +1 -1
  23. package/dist/utils/index.js +2 -2
  24. package/dist/utils/index.js.map +1 -1
  25. package/dist/utils/retry.d.ts +21 -0
  26. package/dist/utils/retry.d.ts.map +1 -0
  27. package/dist/utils/retry.js +67 -0
  28. package/dist/utils/retry.js.map +1 -0
  29. package/package.json +15 -12
  30. package/dist/utils/validation.error.d.ts +0 -6
  31. package/dist/utils/validation.error.d.ts.map +0 -1
  32. package/dist/utils/validation.error.js +0 -50
  33. package/dist/utils/validation.error.js.map +0 -1
@@ -6,6 +6,6 @@ export declare class BigCommerceB2BOrdersService {
6
6
  constructor(fetcher: BigCommerceFetcherService);
7
7
  updateOrderCustomFields(input: z.input<typeof UpdateB2BOrderCustomFieldsSchema>): import("neverthrow").ResultAsync<{
8
8
  code: number;
9
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
9
+ }, import("../../core").BigCommerceError>;
10
10
  }
11
11
  //# sourceMappingURL=b2b-orders.service.d.ts.map
@@ -52,8 +52,8 @@ export declare class BigCommerceCompaniesService {
52
52
  message: string;
53
53
  };
54
54
  }[];
55
- errors: import("../../core").SomeBigCommerceError[];
56
- }, import("../../utils/validation.error").InputDataValidationError>;
55
+ errors: import("../../core").BigCommerceError[];
56
+ }, import("../../core").BigCommerceError>;
57
57
  /**
58
58
  * Creates a new user within a company.
59
59
  *
@@ -80,7 +80,7 @@ export declare class BigCommerceCompaniesService {
80
80
  meta: {
81
81
  message: string;
82
82
  };
83
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
83
+ }, import("../../core").BigCommerceError>;
84
84
  /**
85
85
  * Creates a new B2B company in BigCommerce.
86
86
  *
@@ -103,7 +103,7 @@ export declare class BigCommerceCompaniesService {
103
103
  meta: {
104
104
  message: string;
105
105
  };
106
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
106
+ }, import("../../core").BigCommerceError>;
107
107
  /**
108
108
  * Sets or updates the credit limit for a company.
109
109
  *
@@ -121,7 +121,7 @@ export declare class BigCommerceCompaniesService {
121
121
  * });
122
122
  * ```
123
123
  */
124
- setCompanyCredit(input: z.infer<typeof SetCompanyCreditSchema>): import("neverthrow").ResultAsync<Record<string, never>, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
124
+ setCompanyCredit(input: z.infer<typeof SetCompanyCreditSchema>): import("neverthrow").ResultAsync<Record<string, never>, import("../../core").BigCommerceError>;
125
125
  /**
126
126
  * Finds company extra fields with pagination.
127
127
  *
@@ -151,7 +151,7 @@ export declare class BigCommerceCompaniesService {
151
151
  limit: number;
152
152
  };
153
153
  };
154
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
154
+ }, import("../../core").BigCommerceError>;
155
155
  /**
156
156
  * Retrieves all company extra fields by automatically handling pagination.
157
157
  *
@@ -169,7 +169,7 @@ export declare class BigCommerceCompaniesService {
169
169
  labelName: string;
170
170
  listOfValue: string[];
171
171
  maximumLength?: number | undefined;
172
- }[], import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
172
+ }[], import("../../core").BigCommerceError>;
173
173
  /**
174
174
  * Finds company roles with pagination.
175
175
  *
@@ -199,7 +199,7 @@ export declare class BigCommerceCompaniesService {
199
199
  totalCount: number;
200
200
  };
201
201
  };
202
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
202
+ }, import("../../core").BigCommerceError>;
203
203
  /**
204
204
  * Retrieves all company roles by automatically handling pagination.
205
205
  *
@@ -211,7 +211,7 @@ export declare class BigCommerceCompaniesService {
211
211
  name: string;
212
212
  roleLevel: number;
213
213
  roleType: number;
214
- }[], import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
214
+ }[], import("../../core").BigCommerceError>;
215
215
  /**
216
216
  * Retrieves detailed information about a specific company.
217
217
  *
@@ -248,7 +248,7 @@ export declare class BigCommerceCompaniesService {
248
248
  }[];
249
249
  bcGroupId?: number | null | undefined;
250
250
  };
251
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
251
+ }, import("../../core").BigCommerceError>;
252
252
  /**
253
253
  * Retrieves company user details by customer ID.
254
254
  *
@@ -286,7 +286,7 @@ export declare class BigCommerceCompaniesService {
286
286
  meta: {
287
287
  message: string;
288
288
  };
289
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
289
+ }, import("../../core").BigCommerceError>;
290
290
  /**
291
291
  * Configures available payment methods for a company.
292
292
  *
@@ -303,7 +303,7 @@ export declare class BigCommerceCompaniesService {
303
303
  * });
304
304
  * ```
305
305
  */
306
- setCompanyPaymentMethods(input: z.infer<typeof SetCompanyPaymentMethodsSchema>): import("neverthrow").ResultAsync<Record<string, never>, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
306
+ setCompanyPaymentMethods(input: z.infer<typeof SetCompanyPaymentMethodsSchema>): import("neverthrow").ResultAsync<Record<string, never>, import("../../core").BigCommerceError>;
307
307
  setCompanyUuid(input: z.input<typeof SetCompanyUuidSchema>): import("neverthrow").ResultAsync<{
308
308
  code: number;
309
309
  data: {
@@ -312,7 +312,7 @@ export declare class BigCommerceCompaniesService {
312
312
  meta: {
313
313
  message: string;
314
314
  };
315
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
315
+ }, import("../../core").BigCommerceError>;
316
316
  findCompanies(inputData: z.input<typeof FindCompaniesCriteriaSchema>): import("neverthrow").ResultAsync<{
317
317
  code: number;
318
318
  data: {
@@ -348,7 +348,7 @@ export declare class BigCommerceCompaniesService {
348
348
  };
349
349
  message: string;
350
350
  };
351
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
351
+ }, import("../../core").BigCommerceError>;
352
352
  getAllCompaniesBy(criteria: Omit<z.input<typeof FindCompaniesCriteriaSchema>, 'limit' | 'offset'>): import("neverthrow").ResultAsync<{
353
353
  code: number;
354
354
  data: {
@@ -384,7 +384,7 @@ export declare class BigCommerceCompaniesService {
384
384
  };
385
385
  message: string;
386
386
  };
387
- }[], import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
387
+ }[], import("../../core").BigCommerceError>;
388
388
  private assignSalesStaffToCompanyBatch;
389
389
  }
390
390
  //# sourceMappingURL=companies.service.d.ts.map
@@ -4,6 +4,7 @@ export declare const SetCompanyCreditSchema: z.ZodObject<{
4
4
  creditEnabled: z.ZodBoolean;
5
5
  creditCurrency: z.ZodEnum<{
6
6
  MXN: "MXN";
7
+ USD: "USD";
7
8
  }>;
8
9
  availableCredit: z.ZodNumber;
9
10
  limitPurchases: z.ZodBoolean;
@@ -1 +1 @@
1
- {"version":3,"file":"credit.schemas.d.ts","sourceRoot":"","sources":["../../../../src/bigcommerce-entities/companies/schemas/credit.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,eAAO,MAAM,sBAAsB;;;;;;;;;;;iBASjC,CAAC;AAEH,eAAO,MAAM,8BAA8B,gCAAe,CAAC"}
1
+ {"version":3,"file":"credit.schemas.d.ts","sourceRoot":"","sources":["../../../../src/bigcommerce-entities/companies/schemas/credit.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;iBASjC,CAAC;AAEH,eAAO,MAAM,8BAA8B,gCAAe,CAAC"}
@@ -38,7 +38,7 @@ const z = __importStar(require("zod"));
38
38
  exports.SetCompanyCreditSchema = z.object({
39
39
  data: z.object({
40
40
  creditEnabled: z.boolean(),
41
- creditCurrency: z.enum(['MXN']),
41
+ creditCurrency: z.enum(['MXN', 'USD']),
42
42
  availableCredit: z.number(),
43
43
  limitPurchases: z.boolean(),
44
44
  creditHold: z.boolean(),
@@ -1 +1 @@
1
- {"version":3,"file":"credit.schemas.js","sourceRoot":"","sources":["../../../../src/bigcommerce-entities/companies/schemas/credit.schemas.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACZ,QAAA,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QACb,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE;QAC1B,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;QAC/B,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;QAC3B,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE;QAC3B,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE;KACxB,CAAC;IACF,SAAS,EAAE,CAAC,CAAC,GAAG,EAAE;CACnB,CAAC,CAAC;AAEU,QAAA,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"credit.schemas.js","sourceRoot":"","sources":["../../../../src/bigcommerce-entities/companies/schemas/credit.schemas.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACZ,QAAA,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QACb,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE;QAC1B,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACtC,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;QAC3B,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE;QAC3B,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE;KACxB,CAAC;IACF,SAAS,EAAE,CAAC,CAAC,GAAG,EAAE;CACnB,CAAC,CAAC;AAEU,QAAA,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC"}
@@ -41,7 +41,7 @@ export declare class BigCommerceCustomersService {
41
41
  */
42
42
  createCustomerGroup(data: z.input<typeof CreateCustomerGroupSchema>): import("neverthrow").ResultAsync<{
43
43
  id: number;
44
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
44
+ }, import("../../core").BigCommerceError>;
45
45
  /**
46
46
  * Finds customer addresses with pagination.
47
47
  *
@@ -83,7 +83,7 @@ export declare class BigCommerceCustomersService {
83
83
  total_pages: number;
84
84
  };
85
85
  };
86
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
86
+ }, import("../../core").BigCommerceError>;
87
87
  /**
88
88
  * Retrieves all customer addresses by automatically handling pagination.
89
89
  *
@@ -112,7 +112,7 @@ export declare class BigCommerceCustomersService {
112
112
  phone: string;
113
113
  postal_code: string;
114
114
  state_or_province: string;
115
- }[], import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
115
+ }[], import("../../core").BigCommerceError>;
116
116
  /**
117
117
  * Finds customers with pagination.
118
118
  *
@@ -153,7 +153,7 @@ export declare class BigCommerceCustomersService {
153
153
  };
154
154
  };
155
155
  };
156
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
156
+ }, import("../../core").BigCommerceError>;
157
157
  /**
158
158
  * Retrieves all customers by automatically handling pagination.
159
159
  *
@@ -176,7 +176,7 @@ export declare class BigCommerceCustomersService {
176
176
  id: number;
177
177
  channel_ids: number[];
178
178
  company?: string | undefined;
179
- }[], import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
179
+ }[], import("../../core").BigCommerceError>;
180
180
  /**
181
181
  * Finds customer groups with pagination.
182
182
  *
@@ -188,7 +188,7 @@ export declare class BigCommerceCustomersService {
188
188
  name: string;
189
189
  is_default: boolean;
190
190
  is_group_for_guests: boolean;
191
- }[], import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
191
+ }[], import("../../core").BigCommerceError>;
192
192
  /**
193
193
  * Retrieves all customer groups by automatically handling pagination.
194
194
  *
@@ -200,7 +200,7 @@ export declare class BigCommerceCustomersService {
200
200
  name: string;
201
201
  is_default: boolean;
202
202
  is_group_for_guests: boolean;
203
- }[], import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
203
+ }[], import("../../core").BigCommerceError>;
204
204
  /**
205
205
  * Retrieves a specific customer by ID.
206
206
  *
@@ -221,7 +221,7 @@ export declare class BigCommerceCustomersService {
221
221
  id: number;
222
222
  channel_ids: number[];
223
223
  company?: string | undefined;
224
- } | undefined, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
224
+ } | undefined, import("../../core").BigCommerceError>;
225
225
  /**
226
226
  * Sets or updates the price list for a customer group.
227
227
  *
@@ -241,6 +241,6 @@ export declare class BigCommerceCustomersService {
241
241
  setCustomerGroupPriceList(input: z.input<typeof SetCustomerGroupPriceListSchema>): import("neverthrow").ResultAsync<{
242
242
  id: number;
243
243
  name: string;
244
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
244
+ }, import("../../core").BigCommerceError>;
245
245
  }
246
246
  //# sourceMappingURL=customers.service.d.ts.map
@@ -126,7 +126,7 @@ export declare class BigCommerceOrdersService {
126
126
  store_default_to_transactional_exchange_rate: string;
127
127
  custom_status: string;
128
128
  payment_provider_id?: string | null | undefined;
129
- }[], import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
129
+ }[], import("../../core").BigCommerceError>;
130
130
  /**
131
131
  * Retrieves all orders by automatically handling pagination.
132
132
  *
@@ -226,7 +226,7 @@ export declare class BigCommerceOrdersService {
226
226
  store_default_to_transactional_exchange_rate: string;
227
227
  custom_status: string;
228
228
  payment_provider_id?: string | null | undefined;
229
- }[], import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
229
+ }[], import("../../core").BigCommerceError>;
230
230
  /**
231
231
  * Retrieves a specific order by ID.
232
232
  *
@@ -323,7 +323,7 @@ export declare class BigCommerceOrdersService {
323
323
  store_default_to_transactional_exchange_rate: string;
324
324
  custom_status: string;
325
325
  payment_provider_id?: string | null | undefined;
326
- }, import("../../core").SomeBigCommerceError>;
326
+ }, import("../../core").BigCommerceError>;
327
327
  /**
328
328
  * Finds shipping addresses for a specific order with pagination.
329
329
  *
@@ -357,7 +357,7 @@ export declare class BigCommerceOrdersService {
357
357
  id: number;
358
358
  order_id: number;
359
359
  shipping_method: string;
360
- }[], import("../../core").SomeBigCommerceError>;
360
+ }[], import("../../core").BigCommerceError>;
361
361
  /**
362
362
  * Retrieves all shipping addresses for an order by automatically handling pagination.
363
363
  *
@@ -389,7 +389,7 @@ export declare class BigCommerceOrdersService {
389
389
  id: number;
390
390
  order_id: number;
391
391
  shipping_method: string;
392
- }[], import("../../core").SomeBigCommerceError>;
392
+ }[], import("../../core").BigCommerceError>;
393
393
  /**
394
394
  * Finds products for a specific order with pagination.
395
395
  *
@@ -428,7 +428,7 @@ export declare class BigCommerceOrdersService {
428
428
  cost_price_inc_tax: number;
429
429
  cost_price_ex_tax: number;
430
430
  cost_price_tax: number;
431
- }[], import("../../core").SomeBigCommerceError>;
431
+ }[], import("../../core").BigCommerceError>;
432
432
  /**
433
433
  * Retrieves all products for an order by automatically handling pagination.
434
434
  *
@@ -465,6 +465,6 @@ export declare class BigCommerceOrdersService {
465
465
  cost_price_inc_tax: number;
466
466
  cost_price_ex_tax: number;
467
467
  cost_price_tax: number;
468
- }[], import("../../core").SomeBigCommerceError>;
468
+ }[], import("../../core").BigCommerceError>;
469
469
  }
470
470
  //# sourceMappingURL=orders.service.d.ts.map
@@ -35,6 +35,6 @@ export declare class BigCommercePaymentsService {
35
35
  paymentCode: string;
36
36
  paymentTitle: string;
37
37
  }[];
38
- }, import("../../core").SomeBigCommerceError>;
38
+ }, import("../../core").BigCommerceError>;
39
39
  }
40
40
  //# sourceMappingURL=payments.service.d.ts.map
@@ -42,7 +42,7 @@ export declare class BigCommercePriceListsService {
42
42
  data: {
43
43
  id: number;
44
44
  };
45
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
45
+ }, import("../../core").BigCommerceError>;
46
46
  /**
47
47
  * Finds price lists with pagination.
48
48
  *
@@ -74,7 +74,7 @@ export declare class BigCommercePriceListsService {
74
74
  total_pages: number;
75
75
  };
76
76
  };
77
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
77
+ }, import("../../core").BigCommerceError>;
78
78
  /**
79
79
  * Retrieves all price lists by automatically handling pagination.
80
80
  *
@@ -92,6 +92,6 @@ export declare class BigCommercePriceListsService {
92
92
  date_created: string;
93
93
  date_modified: string;
94
94
  active: boolean;
95
- }[], import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
95
+ }[], import("../../core").BigCommerceError>;
96
96
  }
97
97
  //# sourceMappingURL=price-lists.service.d.ts.map
@@ -44,7 +44,7 @@ export declare class BigCommerceProductsService {
44
44
  success: {
45
45
  transaction_id: string;
46
46
  }[];
47
- errors: (import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError)[];
47
+ errors: import("../../core").BigCommerceError[];
48
48
  }, never>;
49
49
  /**
50
50
  * Updates multiple products in batch with automatic concurrency control.
@@ -64,7 +64,7 @@ export declare class BigCommerceProductsService {
64
64
  */
65
65
  updateProducts(dtos: z.input<typeof UpdateProductSchema>[]): import("neverthrow").ResultAsync<{
66
66
  success: unknown[];
67
- errors: (import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError)[];
67
+ errors: import("../../core").BigCommerceError[];
68
68
  }, never>;
69
69
  /**
70
70
  * Sets product visibility for multiple products in batch.
@@ -82,7 +82,7 @@ export declare class BigCommerceProductsService {
82
82
  */
83
83
  setProductVisibility(dtos: z.input<typeof UpdateProductVisibilitySchema>[]): import("neverthrow").ResultAsync<{
84
84
  success: unknown[];
85
- errors: (import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError)[];
85
+ errors: import("../../core").BigCommerceError[];
86
86
  }, never>;
87
87
  }
88
88
  //# sourceMappingURL=products.service.d.ts.map
@@ -55,7 +55,7 @@ export declare class BigCommerceSalesStaffService {
55
55
  totalCount: number;
56
56
  };
57
57
  };
58
- }, import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
58
+ }, import("../../core").BigCommerceError>;
59
59
  /**
60
60
  * Retrieves all sales staff by automatically handling pagination.
61
61
  *
@@ -73,6 +73,6 @@ export declare class BigCommerceSalesStaffService {
73
73
  id: number;
74
74
  roleName: string;
75
75
  salesRepName: string;
76
- }[], import("../../core").SomeBigCommerceError | import("../../utils/validation.error").InputDataValidationError>;
76
+ }[], import("../../core").BigCommerceError>;
77
77
  }
78
78
  //# sourceMappingURL=sales-staff.service.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { ResultAsync } from 'neverthrow';
2
2
  import * as z from 'zod';
3
- import { BigCommerceParseResponseError, DecodeBigCommerceTextResponseError, SomeBigCommerceError } from './bigcommerce.error';
3
+ import { BigCommerceError } from './bigcommerce.error';
4
4
  import { BigCommerceConfigService } from './config.schema';
5
5
  type BigCommerceFetchMethods = 'GET' | 'POST' | 'PUT' | 'DELETE';
6
6
  export type BigCommerceFetchParams<Body extends Record<string, unknown> | Array<Record<string, unknown>>, Query extends Record<string, string> | string, Result extends z.ZodType> = Prettify<NoGenericParams & {
@@ -19,7 +19,7 @@ export declare abstract class BigCommerceFetcherService {
19
19
  abstract fetch<Body extends Record<string, unknown> | Array<Record<string, unknown>>, Query extends Record<string, string> | string, Result extends z.ZodType>(params: BigCommerceFetchParams<Body, Query, Result>, options?: {
20
20
  timeout?: number;
21
21
  shouldRetry?: boolean;
22
- }): ResultAsync<z.output<Result>, SomeBigCommerceError>;
22
+ }): ResultAsync<z.output<Result>, BigCommerceError>;
23
23
  }
24
24
  export declare class BigCommerceFetcherServiceImpl extends BigCommerceFetcherService {
25
25
  private readonly config;
@@ -27,14 +27,14 @@ export declare class BigCommerceFetcherServiceImpl extends BigCommerceFetcherSer
27
27
  fetch<Body extends Record<string, unknown> | Array<Record<string, unknown>>, Query extends Record<string, string> | string, Result extends z.ZodType>(params: BigCommerceFetchParams<Body, Query, Result>, options?: {
28
28
  timeout?: number;
29
29
  shouldRetry?: boolean;
30
- }): ResultAsync<z.output<Result>, SomeBigCommerceError>;
30
+ }): ResultAsync<z.output<Result>, BigCommerceError>;
31
31
  private applyParams;
32
32
  private getBase;
33
33
  private safeJson;
34
34
  private processSuccessResponse;
35
35
  private getErrorByCode;
36
36
  private processErrorResponse;
37
- transformResponse<Schema extends z.ZodType>(response: Response, schema: Schema): ResultAsync<z.core.output<Schema>, DecodeBigCommerceTextResponseError | BigCommerceParseResponseError>;
37
+ transformResponse<Schema extends z.ZodType>(response: Response, schema: Schema): ResultAsync<z.core.output<Schema>, BigCommerceError>;
38
38
  }
39
39
  export {};
40
40
  //# sourceMappingURL=bigcommerce-fetcher.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bigcommerce-fetcher.service.d.ts","sourceRoot":"","sources":["../../src/core/bigcommerce-fetcher.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,WAAW,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAML,6BAA6B,EAI7B,kCAAkC,EAClC,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,KAAK,uBAAuB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;AACjE,MAAM,MAAM,sBAAsB,CAEhC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACrE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAC7C,MAAM,SAAS,CAAC,CAAC,OAAO,IACtB,QAAQ,CACV,eAAe,GAAG;IAChB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;C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EAAE,KAAK,EAAE,MAAM,CAAC,EACnD,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,GACpD,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAoDlD,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,QAAQ;IAchB,OAAO,CAAC,sBAAsB;IAQ9B,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,oBAAoB;IAK5B,iBAAiB,CAAC,MAAM,SAAS,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM;CAK/E"}
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BigCommerceFetcherServiceImpl = exports.BigCommerceFetcherService = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
14
  const neverthrow_1 = require("neverthrow");
15
- const neverthrow_result_utils_1 = require("neverthrow-result-utils");
16
15
  const constants_1 = require("../constants");
16
+ const retry_1 = require("../utils/retry");
17
17
  const bigcommerce_error_1 = require("./bigcommerce.error");
18
18
  const config_schema_1 = require("./config.schema");
19
19
  class BigCommerceFetcherService {
@@ -46,20 +46,20 @@ let BigCommerceFetcherServiceImpl = class BigCommerceFetcherServiceImpl extends
46
46
  }), (error) => {
47
47
  if (error instanceof Error &&
48
48
  (error.name === 'TimeoutError' || error.name === 'AbortError')) {
49
- return new bigcommerce_error_1.BigCommerceConnectionError({
49
+ return bigcommerce_error_1.BigCommerceError.connection({
50
50
  message: `Request timeout after ${timeoutMs}ms`,
51
51
  type: 'timeout',
52
52
  cause: error,
53
53
  });
54
54
  }
55
- return new bigcommerce_error_1.BigCommerceConnectionError({
55
+ return bigcommerce_error_1.BigCommerceError.connection({
56
56
  cause: error,
57
57
  message: 'Failed to make fetch call',
58
58
  type: 'unknown',
59
59
  });
60
60
  })().andThen((response) => this.transformResponse(response, params.resultSchema));
61
61
  if (options?.shouldRetry) {
62
- neverthrow_result_utils_1.ResultUtils.backoffAndRetry(toFetch, [bigcommerce_error_1.BigCommerceConnectionError], this.config.get('api.maxRetries'), this.config.get('api.baseDelaySeconds'));
62
+ (0, retry_1.backoffAndRetry)(toFetch, (error) => error.isConnectionError, this.config.get('api.maxRetries'), this.config.get('api.baseDelaySeconds'));
63
63
  }
64
64
  return toFetch();
65
65
  }
@@ -85,32 +85,32 @@ let BigCommerceFetcherServiceImpl = class BigCommerceFetcherServiceImpl extends
85
85
  return `${constants_1.DEFAULTS.bigcommerceUrls.regular}/[storeHash]/${version}/${path}`;
86
86
  }
87
87
  safeJson(response) {
88
- return neverthrow_1.ResultAsync.fromPromise(response.text(), (err) => new bigcommerce_error_1.DecodeBigCommerceTextResponseError(response, err)).andThen((text) => {
88
+ return neverthrow_1.ResultAsync.fromPromise(response.text(), (error) => bigcommerce_error_1.BigCommerceError.decodeTextResponse(response, error)).andThen((text) => {
89
89
  if (!text || text.trim() === '') {
90
90
  return (0, neverthrow_1.ok)(null);
91
91
  }
92
- return neverthrow_1.Result.fromThrowable(() => JSON.parse(text), (err) => new bigcommerce_error_1.DecodeBigCommerceTextResponseError(response, err))();
92
+ return neverthrow_1.Result.fromThrowable(() => JSON.parse(text), (error) => bigcommerce_error_1.BigCommerceError.decodeTextResponse(response, error))();
93
93
  });
94
94
  }
95
95
  processSuccessResponse(response, schema) {
96
- return this.safeJson(response).andThen((json) => neverthrow_1.Result.fromThrowable(() => schema.parse(json), (err) => new bigcommerce_error_1.BigCommerceParseResponseError(err))());
96
+ return this.safeJson(response).andThen((json) => neverthrow_1.Result.fromThrowable(() => schema.parse(json), (error) => bigcommerce_error_1.BigCommerceError.parseResponse(error))());
97
97
  }
98
98
  getErrorByCode(response, status) {
99
99
  switch (status) {
100
100
  case 400:
101
- return new bigcommerce_error_1.BigCommerceInvalidRequestError(response, response);
101
+ return bigcommerce_error_1.BigCommerceError.invalidRequest(response, response);
102
102
  case 401:
103
- return new bigcommerce_error_1.BigCommerceUnauthorizedError(response, response);
103
+ return bigcommerce_error_1.BigCommerceError.unauthorized(response, response);
104
104
  case 403:
105
- return new bigcommerce_error_1.BigCommerceForbiddenError(response, response);
105
+ return bigcommerce_error_1.BigCommerceError.forbidden(response, response);
106
106
  case 404:
107
- return new bigcommerce_error_1.BigCommerceNotFoundError(response, response);
107
+ return bigcommerce_error_1.BigCommerceError.notFound(response, response);
108
108
  case 409:
109
- return new bigcommerce_error_1.BigCommerceConflictError(response, response);
109
+ return bigcommerce_error_1.BigCommerceError.conflict(response, response);
110
110
  case 429:
111
- return new bigcommerce_error_1.BigCommerceRateLimitError(response, response);
111
+ return bigcommerce_error_1.BigCommerceError.rateLimit(response, response);
112
112
  default:
113
- return new bigcommerce_error_1.BigCommerceUnknownError(response, response);
113
+ return bigcommerce_error_1.BigCommerceError.unknown(response, response);
114
114
  }
115
115
  }
116
116
  processErrorResponse(response) {
@@ -1 +1 @@
1
- {"version":3,"file":"bigcommerce-fetcher.service.js","sourceRoot":"","sources":["../../src/core/bigcommerce-fetcher.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA0D;AAC1D,qEAAsD;AAEtD,4CAAwC;AACxC,2DAY6B;AAC7B,mDAA2D;AAuB3D,MAAsB,yBAAyB;CAS9C;AATD,8DASC;AAGM,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,yBAAyB;IAC7C;IAA7B,YAA6B,MAAgC;QAC3D,KAAK,EAAE,CAAC;QADmB,WAAM,GAAN,MAAM,CAA0B;IAE7D,CAAC;IAEQ,KAAK,CAKZ,MAAmD,EACnD,OAAqD;QAErD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAClC,MAAM,OAAO,GAA2B;YACtC,MAAM,EAAE,kBAAkB;YAC1B,cAAc,EAAE,kBAAkB;YAClC,cAAc,EAAE,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AAQ,EAAE,MAAM,CAAC;YAC/C,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACF,CAAA;AAxIY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,mBAAU,GAAE;qCAE0B,wCAAwB;GADlD,6BAA6B,CAwIzC"}
@@ -1,51 +1,29 @@
1
1
  import * as z from 'zod';
2
2
  export declare class BigCommerceError extends Error {
3
3
  details: unknown;
4
- constructor({ details, message, cause }: {
4
+ constructor({ details, message, cause, name, }: {
5
5
  message: string;
6
6
  details: unknown;
7
7
  cause: unknown;
8
+ name: string;
8
9
  });
9
- }
10
- export declare class DecodeBigCommerceTextResponseError extends BigCommerceError {
11
- constructor(rawResponse: Response, cause: unknown);
12
- }
13
- export declare class BigCommerceConnectionError extends BigCommerceError {
14
- constructor({ message, type, cause, }: {
10
+ static decodeTextResponse(rawResponse: Response, cause: unknown): BigCommerceError;
11
+ static connection({ message, type, cause, }: {
15
12
  message: string;
16
13
  type: 'timeout' | 'internalError' | 'unknown';
17
14
  cause: unknown;
18
- });
19
- }
20
- export declare class BigCommerceParseResponseError extends BigCommerceError {
21
- constructor(error: z.ZodError);
22
- }
23
- export declare class BigCommerceUnprocessableEntityError extends BigCommerceError {
24
- constructor(response: unknown, error: unknown);
25
- }
26
- export declare class BigCommerceUnauthorizedError extends BigCommerceError {
27
- constructor(response: unknown, error: unknown);
28
- }
29
- export declare class BigCommerceForbiddenError extends BigCommerceError {
30
- constructor(response: unknown, error: unknown);
31
- }
32
- export declare class BigCommerceNotFoundError extends BigCommerceError {
33
- constructor(response: unknown, error: unknown);
34
- }
35
- export declare class BigCommerceConflictError extends BigCommerceError {
36
- constructor(response: unknown, error: unknown);
37
- }
38
- export declare class BigCommerceUnknownError extends BigCommerceError {
39
- constructor(response: unknown, error: unknown);
40
- }
41
- export declare class BigCommerceInvalidResponseError extends BigCommerceError {
42
- constructor(response: unknown, error: unknown);
43
- }
44
- export declare class BigCommerceInvalidRequestError extends BigCommerceError {
45
- constructor(response: unknown, error: unknown);
46
- }
47
- export declare class BigCommerceRateLimitError extends BigCommerceError {
48
- constructor(response: unknown, error: unknown);
15
+ }): BigCommerceError;
16
+ static parseResponse(error: z.ZodError): BigCommerceError;
17
+ static unprocessableEntity(response: unknown, error: unknown): BigCommerceError;
18
+ static unauthorized(response: unknown, error: unknown): BigCommerceError;
19
+ static forbidden(response: unknown, error: unknown): BigCommerceError;
20
+ static notFound(response: unknown, error: unknown): BigCommerceError;
21
+ static conflict(response: unknown, error: unknown): BigCommerceError;
22
+ static unknown(response: unknown, error: unknown): BigCommerceError;
23
+ static invalidResponse(response: unknown, error: unknown): BigCommerceError;
24
+ static invalidRequest(response: unknown, error: unknown): BigCommerceError;
25
+ static rateLimit(response: unknown, error: unknown): BigCommerceError;
26
+ static inputValidation(error: z.ZodError, input: unknown): BigCommerceError;
27
+ get isConnectionError(): boolean;
49
28
  }
50
- export type SomeBigCommerceError = DecodeBigCommerceTextResponseError | BigCommerceInvalidRequestError | BigCommerceUnauthorizedError | BigCommerceForbiddenError | BigCommerceNotFoundError | BigCommerceConflictError | BigCommerceRateLimitError | BigCommerceUnknownError;
51
29
  //# sourceMappingURL=bigcommerce.error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bigcommerce.error.d.ts","sourceRoot":"","sources":["../../src/core/bigcommerce.error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,qBAAa,gBAAiB,SAAQ,KAAK;IACjC,OAAO,EAAE,OAAO,CAAC;gBACb,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE;CAK/F;AACD,qBAAa,kCAAmC,SAAQ,gBAAgB;gBAC1D,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO;CAQlD;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,CAAC,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;IASxD,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;IASvD,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;IASlD,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO;IAUxD,IAAI,iBAAiB,IAAI,OAAO,CAE/B;CACF"}
@@ -33,132 +33,128 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.BigCommerceRateLimitError = exports.BigCommerceInvalidRequestError = exports.BigCommerceInvalidResponseError = exports.BigCommerceUnknownError = exports.BigCommerceConflictError = exports.BigCommerceNotFoundError = exports.BigCommerceForbiddenError = exports.BigCommerceUnauthorizedError = exports.BigCommerceUnprocessableEntityError = exports.BigCommerceParseResponseError = exports.BigCommerceConnectionError = exports.DecodeBigCommerceTextResponseError = exports.BigCommerceError = void 0;
36
+ exports.BigCommerceError = void 0;
37
37
  const z = __importStar(require("zod"));
38
38
  class BigCommerceError extends Error {
39
- constructor({ details, message, cause }) {
39
+ constructor({ details, message, cause, name, }) {
40
40
  super(message, { cause });
41
41
  this.details = details;
42
- this.name = this.constructor.name;
42
+ this.name = name;
43
43
  }
44
- }
45
- exports.BigCommerceError = BigCommerceError;
46
- class DecodeBigCommerceTextResponseError extends BigCommerceError {
47
- constructor(rawResponse, cause) {
44
+ static decodeTextResponse(rawResponse, cause) {
48
45
  const details = {
49
46
  status: rawResponse.status,
50
47
  statusText: rawResponse.statusText,
51
48
  url: rawResponse.url,
52
49
  };
53
- super({ details, cause, message: 'Failed to decode BigCommerce text response' });
50
+ return new BigCommerceError({
51
+ details,
52
+ cause,
53
+ message: 'Failed to decode BigCommerce text response',
54
+ name: 'DECODE_BIG_COMMERCE_TEXT_RESPONSE_ERROR',
55
+ });
54
56
  }
55
- }
56
- exports.DecodeBigCommerceTextResponseError = DecodeBigCommerceTextResponseError;
57
- class BigCommerceConnectionError extends BigCommerceError {
58
- constructor({ message, type, cause, }) {
59
- super({ cause, message, details: { message, type } });
57
+ static connection({ message, type, cause, }) {
58
+ return new BigCommerceError({
59
+ cause,
60
+ message,
61
+ details: { message, type },
62
+ name: 'BIG_COMMERCE_CONNECTION_ERROR',
63
+ });
60
64
  }
61
- }
62
- exports.BigCommerceConnectionError = BigCommerceConnectionError;
63
- class BigCommerceParseResponseError extends BigCommerceError {
64
- constructor(error) {
65
+ static parseResponse(error) {
65
66
  const flattenSchema = z.treeifyError(error);
66
- super({
67
+ return new BigCommerceError({
67
68
  details: flattenSchema,
68
69
  cause: error,
69
70
  message: 'Failed to parse BigCommerce response',
71
+ name: 'BIG_COMMERCE_PARSE_RESPONSE_ERROR',
70
72
  });
71
73
  }
72
- }
73
- exports.BigCommerceParseResponseError = BigCommerceParseResponseError;
74
- class BigCommerceUnprocessableEntityError extends BigCommerceError {
75
- constructor(response, error) {
76
- super({
74
+ static unprocessableEntity(response, error) {
75
+ return new BigCommerceError({
77
76
  details: response,
78
77
  cause: error,
79
78
  message: 'Unprocessable entity error',
79
+ name: 'BIG_COMMERCE_UNPROCESSABLE_ENTITY_ERROR',
80
80
  });
81
81
  }
82
- }
83
- exports.BigCommerceUnprocessableEntityError = BigCommerceUnprocessableEntityError;
84
- class BigCommerceUnauthorizedError extends BigCommerceError {
85
- constructor(response, error) {
86
- super({
82
+ static unauthorized(response, error) {
83
+ return new BigCommerceError({
87
84
  details: response,
88
85
  cause: error,
89
86
  message: 'Unauthorized',
87
+ name: 'BIG_COMMERCE_UNAUTHORIZED_ERROR',
90
88
  });
91
89
  }
92
- }
93
- exports.BigCommerceUnauthorizedError = BigCommerceUnauthorizedError;
94
- class BigCommerceForbiddenError extends BigCommerceError {
95
- constructor(response, error) {
96
- super({
90
+ static forbidden(response, error) {
91
+ return new BigCommerceError({
97
92
  details: response,
98
93
  cause: error,
99
94
  message: 'Forbidden',
95
+ name: 'BIG_COMMERCE_FORBIDDEN_ERROR',
100
96
  });
101
97
  }
102
- }
103
- exports.BigCommerceForbiddenError = BigCommerceForbiddenError;
104
- class BigCommerceNotFoundError extends BigCommerceError {
105
- constructor(response, error) {
106
- super({
98
+ static notFound(response, error) {
99
+ return new BigCommerceError({
107
100
  details: response,
108
101
  cause: error,
109
102
  message: 'Not found',
103
+ name: 'BIG_COMMERCE_NOT_FOUND_ERROR',
110
104
  });
111
105
  }
112
- }
113
- exports.BigCommerceNotFoundError = BigCommerceNotFoundError;
114
- class BigCommerceConflictError extends BigCommerceError {
115
- constructor(response, error) {
116
- super({
106
+ static conflict(response, error) {
107
+ return new BigCommerceError({
117
108
  details: response,
118
109
  cause: error,
119
110
  message: 'Conflict',
111
+ name: 'BIG_COMMERCE_CONFLICT_ERROR',
120
112
  });
121
113
  }
122
- }
123
- exports.BigCommerceConflictError = BigCommerceConflictError;
124
- class BigCommerceUnknownError extends BigCommerceError {
125
- constructor(response, error) {
126
- super({
114
+ static unknown(response, error) {
115
+ return new BigCommerceError({
127
116
  details: response,
128
117
  cause: error,
129
118
  message: 'Unknown error',
119
+ name: 'BIG_COMMERCE_UNKNOWN_ERROR',
130
120
  });
131
121
  }
132
- }
133
- exports.BigCommerceUnknownError = BigCommerceUnknownError;
134
- class BigCommerceInvalidResponseError extends BigCommerceError {
135
- constructor(response, error) {
136
- super({
122
+ static invalidResponse(response, error) {
123
+ return new BigCommerceError({
137
124
  details: response,
138
125
  cause: error,
139
126
  message: 'Invalid response',
127
+ name: 'BIG_COMMERCE_INVALID_RESPONSE_ERROR',
140
128
  });
141
129
  }
142
- }
143
- exports.BigCommerceInvalidResponseError = BigCommerceInvalidResponseError;
144
- class BigCommerceInvalidRequestError extends BigCommerceError {
145
- constructor(response, error) {
146
- super({
130
+ static invalidRequest(response, error) {
131
+ return new BigCommerceError({
147
132
  details: response,
148
133
  cause: error,
149
134
  message: 'Invalid request',
135
+ name: 'BIG_COMMERCE_INVALID_REQUEST_ERROR',
150
136
  });
151
137
  }
152
- }
153
- exports.BigCommerceInvalidRequestError = BigCommerceInvalidRequestError;
154
- class BigCommerceRateLimitError extends BigCommerceError {
155
- constructor(response, error) {
156
- super({
138
+ static rateLimit(response, error) {
139
+ return new BigCommerceError({
157
140
  details: response,
158
141
  cause: error,
159
142
  message: 'Rate limit exceeded',
143
+ name: 'BIG_COMMERCE_RATE_LIMIT_ERROR',
144
+ });
145
+ }
146
+ static inputValidation(error, input) {
147
+ const flattenSchema = z.treeifyError(error);
148
+ return new BigCommerceError({
149
+ message: 'Input data validation failed',
150
+ details: { flatten: flattenSchema, input },
151
+ cause: error,
152
+ name: 'BIG_COMMERCE_INPUT_VALIDATION_ERROR',
160
153
  });
161
154
  }
155
+ get isConnectionError() {
156
+ return this.name === 'BIG_COMMERCE_CONNECTION_ERROR';
157
+ }
162
158
  }
163
- exports.BigCommerceRateLimitError = BigCommerceRateLimitError;
159
+ exports.BigCommerceError = BigCommerceError;
164
160
  //# sourceMappingURL=bigcommerce.error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bigcommerce.error.js","sourceRoot":"","sources":["../../src/core/bigcommerce.error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,MAAa,gBAAiB,SAAQ,KAAK;IAEzC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAyD;QAC5F,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;CACF;AAPD,4CAOC;AACD,MAAa,kCAAmC,SAAQ,gBAAgB;IACtE,YAAY,WAAqB,EAAE,KAAc;QAC/C,MAAM,OAA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 +1,5 @@
1
1
  import { Result } from 'neverthrow';
2
2
  import * as z from 'zod';
3
- import { InputDataValidationError } from './validation.error';
4
- export declare const validateInputData: <Schema extends z.ZodType>(schema: Schema, data: z.input<Schema>) => Result<z.core.output<Schema>, InputDataValidationError>;
3
+ import { BigCommerceError } from '../core';
4
+ export declare const validateInputData: <Schema extends z.ZodType>(schema: Schema, data: z.input<Schema>) => Result<z.core.output<Schema>, BigCommerceError>;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,CAAC,CAAC,OAAO,EACxD,QAAQ,MAAM,EACd,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,4DAMtB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,CAAC,CAAC,OAAO,EACxD,QAAQ,MAAM,EACd,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,oDAMtB,CAAC"}
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateInputData = void 0;
4
4
  const neverthrow_1 = require("neverthrow");
5
- const validation_error_1 = require("./validation.error");
5
+ const core_1 = require("../core");
6
6
  const validateInputData = (schema, data) => {
7
- return neverthrow_1.Result.fromThrowable(() => schema.parse(data), (error) => new validation_error_1.InputDataValidationError(error, data))();
7
+ return neverthrow_1.Result.fromThrowable(() => schema.parse(data), (error) => core_1.BigCommerceError.inputValidation(error, data))();
8
8
  };
9
9
  exports.validateInputData = validateInputData;
10
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,2CAAoC;AAEpC,yDAA8D;AAEvD,MAAM,iBAAiB,GAAG,CAC/B,MAAc,EACd,IAAqB,EACrB,EAAE;IACF,OAAO,mBAAM,CAAC,aAAa,CACzB,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EACxB,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,2CAAwB,CAAC,KAAmB,EAAE,IAAI,CAAC,CACnE,EAAE,CAAC;AACN,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,2CAAoC;AAEpC,kCAA2C;AAEpC,MAAM,iBAAiB,GAAG,CAC/B,MAAc,EACd,IAAqB,EACrB,EAAE;IACF,OAAO,mBAAM,CAAC,aAAa,CACzB,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EACxB,CAAC,KAAK,EAAE,EAAE,CAAC,uBAAgB,CAAC,eAAe,CAAC,KAAmB,EAAE,IAAI,CAAC,CACvE,EAAE,CAAC;AACN,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B"}
@@ -0,0 +1,21 @@
1
+ import { ResultAsync } from 'neverthrow';
2
+ /**
3
+ * backoffAndRetry() is a powerful method that executes a function that returns
4
+ * a ResultAsync. If that result is OK, then the result is returned directly.
5
+ * If it is an error, it will check to see if the returned error is in the
6
+ * acceptableErrors list. If so, it will delay and re-execute the function.
7
+ * If it's not an acceptable error type, the error result is returned.
8
+ * Each failure will backoff exponentially.
9
+ *
10
+ * This is an excellent wrapper for functions that can fail inconsistently
11
+ * in some ways were we expect a retry to succeed. For example, a function
12
+ * that communicates with a database over a sketchy connection might just need
13
+ * to retry in a few seconds.
14
+ * @param func
15
+ * @param validate Validate function to check if the error is acceptable for retry
16
+ * @param maxAttempts This is the maximum number of times a retry will be attempted; set to null to use infinite retries.
17
+ * @param baseSeconds This is the delay in seconds for the first retry attempt. It will double with each successive retry.
18
+ * @returns
19
+ */
20
+ export declare const backoffAndRetry: <T, E extends Error>(func: () => ResultAsync<T, E>, validate: (error: E) => boolean, maxAttempts?: number, baseSeconds?: number) => ResultAsync<T, E>;
21
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,WAAW,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,CAAC,SAAS,KAAK,EAChD,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC7B,UAAU,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,EAC/B,cAAc,MAAM,EACpB,oBAAe,KACd,WAAW,CAAC,CAAC,EAAE,CAAC,CAgDlB,CAAC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.backoffAndRetry = void 0;
7
+ const delay_1 = __importDefault(require("delay"));
8
+ const neverthrow_1 = require("neverthrow");
9
+ /**
10
+ * backoffAndRetry() is a powerful method that executes a function that returns
11
+ * a ResultAsync. If that result is OK, then the result is returned directly.
12
+ * If it is an error, it will check to see if the returned error is in the
13
+ * acceptableErrors list. If so, it will delay and re-execute the function.
14
+ * If it's not an acceptable error type, the error result is returned.
15
+ * Each failure will backoff exponentially.
16
+ *
17
+ * This is an excellent wrapper for functions that can fail inconsistently
18
+ * in some ways were we expect a retry to succeed. For example, a function
19
+ * that communicates with a database over a sketchy connection might just need
20
+ * to retry in a few seconds.
21
+ * @param func
22
+ * @param validate Validate function to check if the error is acceptable for retry
23
+ * @param maxAttempts This is the maximum number of times a retry will be attempted; set to null to use infinite retries.
24
+ * @param baseSeconds This is the delay in seconds for the first retry attempt. It will double with each successive retry.
25
+ * @returns
26
+ */
27
+ const backoffAndRetry = (func, validate, maxAttempts, baseSeconds = 5) => {
28
+ if (maxAttempts != null && maxAttempts < 1) {
29
+ throw new Error('maxAttempts must be 1 or more!');
30
+ }
31
+ if (baseSeconds < 1) {
32
+ throw new Error('baseSeconds must be 1 or more!');
33
+ }
34
+ const runAndCheck = (currentAttempt, nextAttemptSecs, lastError) => {
35
+ if (maxAttempts != null && currentAttempt > maxAttempts) {
36
+ if (lastError == null) {
37
+ throw new Error('Error before first function run; logical error! maxAttempts must be 1 or more!');
38
+ }
39
+ return (0, neverthrow_1.errAsync)(lastError);
40
+ }
41
+ // Check the result. If it's not an error, we're done!
42
+ // If it's an error, check the error type against acceptableErrors. If it's in the list,
43
+ // wait some amount of time and try again.
44
+ // If it is not in the list, return the error and stop.
45
+ return func().orElse((e) => {
46
+ let retry = false;
47
+ try {
48
+ retry = validate(e);
49
+ }
50
+ catch {
51
+ // If fail the validation, don't retry
52
+ retry = false;
53
+ }
54
+ if (retry) {
55
+ return neverthrow_1.ResultAsync.fromSafePromise((0, delay_1.default)(nextAttemptSecs)).andThen(() => {
56
+ const _ = currentAttempt + 1;
57
+ currentAttempt = _;
58
+ return runAndCheck(currentAttempt, nextAttemptSecs * 2, e);
59
+ });
60
+ }
61
+ return (0, neverthrow_1.errAsync)(e);
62
+ });
63
+ };
64
+ return runAndCheck(1, baseSeconds, null);
65
+ };
66
+ exports.backoffAndRetry = backoffAndRetry;
67
+ //# source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AC,OAAO,CAAC,GAAG,EAAE;oBAC5E,MAAM,CAAC,GAAG,cAAc,GAAG,CAAC,CAAC;oBAC7B,cAAc,GAAG,CAAC,CAAC;oBACnB,OAAO,WAAW,CAAC,cAAc,EAAE,eAAe,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC7D,CAAC,CAAC,CAAC;YACL,CAAC;YACD,OAAO,IAAA,qBAAQ,EAAC,CAAC,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC,CAAC;AArDW,QAAA,eAAe,mBAqD1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgebound/bigcommerce",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -12,27 +12,30 @@
12
12
  "README.md"
13
13
  ],
14
14
  "devDependencies": {
15
- "zod": "^4.3.3",
16
15
  "@nestjs/common": "^11.0.0",
17
- "reflect-metadata": "^0.2.0",
18
- "rxjs": "^7.0.0",
19
- "neverthrow-result-utils": "^3.0.0",
20
- "neverthrow": "^8.2.0",
21
- "eslint-plugin-neverthrow": "1.1.4",
22
16
  "@nestjs/config": "^4.0.0",
17
+ "eslint-plugin-neverthrow": "1.1.4",
18
+ "neverthrow": "^8.2.0",
19
+ "neverthrow-result-utils": "^3.0.0",
23
20
  "p-limit": "^7.2.0",
21
+ "reflect-metadata": "^0.2.0",
22
+ "rxjs": "^7.0.0",
23
+ "zod": "^4.3.3",
24
24
  "@edgebound/eslint-config": "0.0.1",
25
25
  "@edgebound/typescript-config": "0.0.0"
26
26
  },
27
27
  "peerDependencies": {
28
- "zod": "^4.3.3",
29
28
  "@nestjs/common": "^11.0.0",
29
+ "@nestjs/config": "^4.0.0",
30
+ "neverthrow": "^8.2.0",
31
+ "neverthrow-result-utils": "^3.0.0",
32
+ "p-limit": "^7.2.0",
30
33
  "reflect-metadata": "^0.2.0",
31
34
  "rxjs": "^7.0.0",
32
- "neverthrow-result-utils": "^3.0.0",
33
- "neverthrow": "^8.2.0",
34
- "@nestjs/config": "^4.0.0",
35
- "p-limit": "^7.2.0"
35
+ "zod": "^4.3.3"
36
+ },
37
+ "dependencies": {
38
+ "delay": "7.0.0"
36
39
  },
37
40
  "scripts": {
38
41
  "lint": "eslint . --max-warnings 0 --fix",
@@ -1,6 +0,0 @@
1
- import * as z from 'zod';
2
- import { BigCommerceError } from '../core';
3
- export declare class InputDataValidationError extends BigCommerceError {
4
- constructor(error: z.ZodError, input: unknown);
5
- }
6
- //# sourceMappingURL=validation.error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.error.d.ts","sourceRoot":"","sources":["../../src/utils/validation.error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,qBAAa,wBAAyB,SAAQ,gBAAgB;gBAChD,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO;CAQ9C"}
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.InputDataValidationError = void 0;
37
- const z = __importStar(require("zod"));
38
- const core_1 = require("../core");
39
- class InputDataValidationError extends core_1.BigCommerceError {
40
- constructor(error, input) {
41
- const flattenSchema = z.treeifyError(error);
42
- super({
43
- message: 'Input data validation failed',
44
- details: { flatten: flattenSchema, input },
45
- cause: error,
46
- });
47
- }
48
- }
49
- exports.InputDataValidationError = InputDataValidationError;
50
- //# sourceMappingURL=validation.error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.error.js","sourceRoot":"","sources":["../../src/utils/validation.error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,kCAA2C;AAC3C,MAAa,wBAAyB,SAAQ,uBAAgB;IAC5D,YAAY,KAAiB,EAAE,KAAc;QAC3C,MAAM,aAAa,GAAG,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC5C,KAAK,CAAC;YACJ,OAAO,EAAE,8BAA8B;YACvC,OAAO,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE;YAC1C,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;CACF;AATD,4DASC"}