@thorprovider/adapters 4.2.1 → 4.2.2

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.mts CHANGED
@@ -322,6 +322,11 @@ declare class ProviderAPIError extends CommerceError {
322
322
  readonly provider: string;
323
323
  constructor(message: string, provider: string, status?: number);
324
324
  }
325
+ /**
326
+ * Extract error message from various error types
327
+ * Handles standard Error objects, API responses, and unknown error types
328
+ */
329
+ declare function extractErrorMessage(error: unknown): string;
325
330
 
326
331
  /**
327
332
  * @thorprovider/adapters v2.0
@@ -377,6 +382,51 @@ interface RetryConfig {
377
382
  */
378
383
  retryableStatusCodes?: number[];
379
384
  }
385
+ /**
386
+ * Enhanced fetch with retry logic and timeout
387
+ *
388
+ * @example
389
+ * ```typescript
390
+ * import { fetchWithRetry } from '@thorprovider/adapters/core/fetch-utils';
391
+ *
392
+ * // Basic usage with defaults (3 retries, 10s timeout)
393
+ * const response = await fetchWithRetry('https://api.example.com/products');
394
+ *
395
+ * // Custom configuration
396
+ * const response = await fetchWithRetry(
397
+ * 'https://api.example.com/products',
398
+ * {
399
+ * method: 'POST',
400
+ * body: JSON.stringify({ name: 'Product' }),
401
+ * },
402
+ * {
403
+ * maxRetries: 5,
404
+ * timeoutMs: 15000, // 15 seconds
405
+ * initialDelayMs: 500,
406
+ * }
407
+ * );
408
+ * ```
409
+ */
410
+ declare function fetchWithRetry(url: string, init?: RequestInit, retryConfig?: RetryConfig): Promise<Response>;
411
+ /**
412
+ * Create a fetch function with custom retry configuration
413
+ * Useful for creating a configured fetch instance
414
+ *
415
+ * @example
416
+ * ```typescript
417
+ * import { createFetchWithRetry } from '@thorprovider/adapters/core/fetch-utils';
418
+ *
419
+ * // Create configured fetch
420
+ * const customFetch = createFetchWithRetry({
421
+ * maxRetries: 5,
422
+ * timeoutMs: 15000,
423
+ * });
424
+ *
425
+ * // Use it like regular fetch
426
+ * const response = await customFetch('https://api.example.com/products');
427
+ * ```
428
+ */
429
+ declare function createFetchWithRetry(retryConfig?: RetryConfig): (url: string, init?: RequestInit) => Promise<Response>;
380
430
 
381
431
  /**
382
432
  * Circuit Breaker Pattern Implementation
@@ -2690,4 +2740,4 @@ declare function createProvider(options: ProviderFactoryConfig | RuntimeProvider
2690
2740
  */
2691
2741
  declare function isProviderType<T extends ProviderType>(provider: CommerceProvider, type: T): boolean;
2692
2742
 
2693
- export { AdminAuthService, type AdminSession, AdminSessionService, BIGCOMMERCE_CAPABILITIES, type BackendMapping, type BackendMetadataAdapter, type BackendMetadataAdapterConfig, BigCommerceProvider, type BigCommerceProviderConfig, CHANNEL_ASSIGNED_AT_KEY, CHANNEL_ASSIGNED_BY_KEY, CHANNEL_SCOPE_KEY, type ChannelScopeMetadata, ChannelScopeValidationError, type ChannelScopeable, CircuitBreaker, type CircuitBreakerConfig, CircuitBreakerOpenError, type CircuitBreakerStats, type CircuitState, CommerceError, ConfigurationError, type Coordinates, type FulfillmentGroup, type FulfillmentPlan, type LogLevel, type Logger, MAGENTO_CAPABILITIES, MEDUSA_CAPABILITIES, MOCK_CAPABILITIES, MagentoProvider, type MagentoProviderConfig, MedusaMetadataAdapter, MedusaProvider, type MedusaProviderConfig, type MetricsOrderInput, type MetricsProductInput, MetricsService, MockProvider, type MockProviderConfig, type PlanFulfillmentShippingAddress, ProviderAPIError, type ProviderFactoryConfig, ProviderNotFoundError, type ProviderType, ResourceNotFoundError, SHOPIFY_CAPABILITIES, SPREE_CAPABILITIES, STELORDER_CAPABILITIES, ShopifyProvider, type ShopifyProviderConfig, SpreeProvider, type SpreeProviderConfig, StelOrderProvider, type StelOrderProviderConfig, type UICartItem, type UICartTotals, type UIDiscountCode, type UIPaymentMethod, type UIShippingMethod, WOOCOMMERCE_CAPABILITIES, WooCommerceProvider, type WooCommerceProviderConfig, assertEntityBelongsToChannel, backendCircuitBreaker, buildChannelScopeMetadata, calculateDistance, createBackendMetadataAdapter, createLogger, createProvider, filterByChannel, filterGlobalOnly, geocodeAddress, getBackendProviderId, getCapabilityDescription, getChannelScope, isBackendCapabilities, isGlobalEntity, isProviderType, isScopedToChannel, moneyToNumber, moneyToNumberSafe, numberToMoney, partitionByChannel, planFulfillment, transformFulfillmentOption, transformInventoryLevel, transformStockLocation, transformStorefrontConfig, validateAssignedBy, validateChannelId, validateChannelScopeAssignment, validateEntityId, validatePaymentId };
2743
+ export { AdminAuthService, type AdminSession, AdminSessionService, BIGCOMMERCE_CAPABILITIES, type BackendMapping, type BackendMetadataAdapter, type BackendMetadataAdapterConfig, BigCommerceProvider, type BigCommerceProviderConfig, CHANNEL_ASSIGNED_AT_KEY, CHANNEL_ASSIGNED_BY_KEY, CHANNEL_SCOPE_KEY, type ChannelScopeMetadata, ChannelScopeValidationError, type ChannelScopeable, CircuitBreaker, type CircuitBreakerConfig, CircuitBreakerOpenError, type CircuitBreakerStats, type CircuitState, CommerceError, ConfigurationError, type Coordinates, type FulfillmentGroup, type FulfillmentPlan, type LogLevel, type Logger, MAGENTO_CAPABILITIES, MEDUSA_CAPABILITIES, MOCK_CAPABILITIES, MagentoProvider, type MagentoProviderConfig, MedusaMetadataAdapter, MedusaProvider, type MedusaProviderConfig, type MetricsOrderInput, type MetricsProductInput, MetricsService, MockProvider, type MockProviderConfig, type PlanFulfillmentShippingAddress, ProviderAPIError, type ProviderFactoryConfig, ProviderNotFoundError, type ProviderType, ResourceNotFoundError, type RetryConfig, SHOPIFY_CAPABILITIES, SPREE_CAPABILITIES, STELORDER_CAPABILITIES, ShopifyProvider, type ShopifyProviderConfig, SpreeProvider, type SpreeProviderConfig, StelOrderProvider, type StelOrderProviderConfig, type UICartItem, type UICartTotals, type UIDiscountCode, type UIPaymentMethod, type UIShippingMethod, WOOCOMMERCE_CAPABILITIES, WooCommerceProvider, type WooCommerceProviderConfig, assertEntityBelongsToChannel, backendCircuitBreaker, buildChannelScopeMetadata, calculateDistance, createBackendMetadataAdapter, createFetchWithRetry, createLogger, createProvider, extractErrorMessage, fetchWithRetry, filterByChannel, filterGlobalOnly, geocodeAddress, getBackendProviderId, getCapabilityDescription, getChannelScope, isBackendCapabilities, isGlobalEntity, isProviderType, isScopedToChannel, moneyToNumber, moneyToNumberSafe, numberToMoney, partitionByChannel, planFulfillment, transformFulfillmentOption, transformInventoryLevel, transformStockLocation, transformStorefrontConfig, validateAssignedBy, validateChannelId, validateChannelScopeAssignment, validateEntityId, validatePaymentId };
package/dist/index.d.ts CHANGED
@@ -322,6 +322,11 @@ declare class ProviderAPIError extends CommerceError {
322
322
  readonly provider: string;
323
323
  constructor(message: string, provider: string, status?: number);
324
324
  }
325
+ /**
326
+ * Extract error message from various error types
327
+ * Handles standard Error objects, API responses, and unknown error types
328
+ */
329
+ declare function extractErrorMessage(error: unknown): string;
325
330
 
326
331
  /**
327
332
  * @thorprovider/adapters v2.0
@@ -377,6 +382,51 @@ interface RetryConfig {
377
382
  */
378
383
  retryableStatusCodes?: number[];
379
384
  }
385
+ /**
386
+ * Enhanced fetch with retry logic and timeout
387
+ *
388
+ * @example
389
+ * ```typescript
390
+ * import { fetchWithRetry } from '@thorprovider/adapters/core/fetch-utils';
391
+ *
392
+ * // Basic usage with defaults (3 retries, 10s timeout)
393
+ * const response = await fetchWithRetry('https://api.example.com/products');
394
+ *
395
+ * // Custom configuration
396
+ * const response = await fetchWithRetry(
397
+ * 'https://api.example.com/products',
398
+ * {
399
+ * method: 'POST',
400
+ * body: JSON.stringify({ name: 'Product' }),
401
+ * },
402
+ * {
403
+ * maxRetries: 5,
404
+ * timeoutMs: 15000, // 15 seconds
405
+ * initialDelayMs: 500,
406
+ * }
407
+ * );
408
+ * ```
409
+ */
410
+ declare function fetchWithRetry(url: string, init?: RequestInit, retryConfig?: RetryConfig): Promise<Response>;
411
+ /**
412
+ * Create a fetch function with custom retry configuration
413
+ * Useful for creating a configured fetch instance
414
+ *
415
+ * @example
416
+ * ```typescript
417
+ * import { createFetchWithRetry } from '@thorprovider/adapters/core/fetch-utils';
418
+ *
419
+ * // Create configured fetch
420
+ * const customFetch = createFetchWithRetry({
421
+ * maxRetries: 5,
422
+ * timeoutMs: 15000,
423
+ * });
424
+ *
425
+ * // Use it like regular fetch
426
+ * const response = await customFetch('https://api.example.com/products');
427
+ * ```
428
+ */
429
+ declare function createFetchWithRetry(retryConfig?: RetryConfig): (url: string, init?: RequestInit) => Promise<Response>;
380
430
 
381
431
  /**
382
432
  * Circuit Breaker Pattern Implementation
@@ -2690,4 +2740,4 @@ declare function createProvider(options: ProviderFactoryConfig | RuntimeProvider
2690
2740
  */
2691
2741
  declare function isProviderType<T extends ProviderType>(provider: CommerceProvider, type: T): boolean;
2692
2742
 
2693
- export { AdminAuthService, type AdminSession, AdminSessionService, BIGCOMMERCE_CAPABILITIES, type BackendMapping, type BackendMetadataAdapter, type BackendMetadataAdapterConfig, BigCommerceProvider, type BigCommerceProviderConfig, CHANNEL_ASSIGNED_AT_KEY, CHANNEL_ASSIGNED_BY_KEY, CHANNEL_SCOPE_KEY, type ChannelScopeMetadata, ChannelScopeValidationError, type ChannelScopeable, CircuitBreaker, type CircuitBreakerConfig, CircuitBreakerOpenError, type CircuitBreakerStats, type CircuitState, CommerceError, ConfigurationError, type Coordinates, type FulfillmentGroup, type FulfillmentPlan, type LogLevel, type Logger, MAGENTO_CAPABILITIES, MEDUSA_CAPABILITIES, MOCK_CAPABILITIES, MagentoProvider, type MagentoProviderConfig, MedusaMetadataAdapter, MedusaProvider, type MedusaProviderConfig, type MetricsOrderInput, type MetricsProductInput, MetricsService, MockProvider, type MockProviderConfig, type PlanFulfillmentShippingAddress, ProviderAPIError, type ProviderFactoryConfig, ProviderNotFoundError, type ProviderType, ResourceNotFoundError, SHOPIFY_CAPABILITIES, SPREE_CAPABILITIES, STELORDER_CAPABILITIES, ShopifyProvider, type ShopifyProviderConfig, SpreeProvider, type SpreeProviderConfig, StelOrderProvider, type StelOrderProviderConfig, type UICartItem, type UICartTotals, type UIDiscountCode, type UIPaymentMethod, type UIShippingMethod, WOOCOMMERCE_CAPABILITIES, WooCommerceProvider, type WooCommerceProviderConfig, assertEntityBelongsToChannel, backendCircuitBreaker, buildChannelScopeMetadata, calculateDistance, createBackendMetadataAdapter, createLogger, createProvider, filterByChannel, filterGlobalOnly, geocodeAddress, getBackendProviderId, getCapabilityDescription, getChannelScope, isBackendCapabilities, isGlobalEntity, isProviderType, isScopedToChannel, moneyToNumber, moneyToNumberSafe, numberToMoney, partitionByChannel, planFulfillment, transformFulfillmentOption, transformInventoryLevel, transformStockLocation, transformStorefrontConfig, validateAssignedBy, validateChannelId, validateChannelScopeAssignment, validateEntityId, validatePaymentId };
2743
+ export { AdminAuthService, type AdminSession, AdminSessionService, BIGCOMMERCE_CAPABILITIES, type BackendMapping, type BackendMetadataAdapter, type BackendMetadataAdapterConfig, BigCommerceProvider, type BigCommerceProviderConfig, CHANNEL_ASSIGNED_AT_KEY, CHANNEL_ASSIGNED_BY_KEY, CHANNEL_SCOPE_KEY, type ChannelScopeMetadata, ChannelScopeValidationError, type ChannelScopeable, CircuitBreaker, type CircuitBreakerConfig, CircuitBreakerOpenError, type CircuitBreakerStats, type CircuitState, CommerceError, ConfigurationError, type Coordinates, type FulfillmentGroup, type FulfillmentPlan, type LogLevel, type Logger, MAGENTO_CAPABILITIES, MEDUSA_CAPABILITIES, MOCK_CAPABILITIES, MagentoProvider, type MagentoProviderConfig, MedusaMetadataAdapter, MedusaProvider, type MedusaProviderConfig, type MetricsOrderInput, type MetricsProductInput, MetricsService, MockProvider, type MockProviderConfig, type PlanFulfillmentShippingAddress, ProviderAPIError, type ProviderFactoryConfig, ProviderNotFoundError, type ProviderType, ResourceNotFoundError, type RetryConfig, SHOPIFY_CAPABILITIES, SPREE_CAPABILITIES, STELORDER_CAPABILITIES, ShopifyProvider, type ShopifyProviderConfig, SpreeProvider, type SpreeProviderConfig, StelOrderProvider, type StelOrderProviderConfig, type UICartItem, type UICartTotals, type UIDiscountCode, type UIPaymentMethod, type UIShippingMethod, WOOCOMMERCE_CAPABILITIES, WooCommerceProvider, type WooCommerceProviderConfig, assertEntityBelongsToChannel, backendCircuitBreaker, buildChannelScopeMetadata, calculateDistance, createBackendMetadataAdapter, createFetchWithRetry, createLogger, createProvider, extractErrorMessage, fetchWithRetry, filterByChannel, filterGlobalOnly, geocodeAddress, getBackendProviderId, getCapabilityDescription, getChannelScope, isBackendCapabilities, isGlobalEntity, isProviderType, isScopedToChannel, moneyToNumber, moneyToNumberSafe, numberToMoney, partitionByChannel, planFulfillment, transformFulfillmentOption, transformInventoryLevel, transformStockLocation, transformStorefrontConfig, validateAssignedBy, validateChannelId, validateChannelScopeAssignment, validateEntityId, validatePaymentId };
package/dist/index.js CHANGED
@@ -67,8 +67,11 @@ __export(src_exports, {
67
67
  buildChannelScopeMetadata: () => buildChannelScopeMetadata,
68
68
  calculateDistance: () => calculateDistance,
69
69
  createBackendMetadataAdapter: () => createBackendMetadataAdapter,
70
+ createFetchWithRetry: () => createFetchWithRetry,
70
71
  createLogger: () => createLogger,
71
72
  createProvider: () => createProvider,
73
+ extractErrorMessage: () => extractErrorMessage,
74
+ fetchWithRetry: () => fetchWithRetry,
72
75
  filterByChannel: () => filterByChannel,
73
76
  filterGlobalOnly: () => filterGlobalOnly,
74
77
  geocodeAddress: () => geocodeAddress,
@@ -617,6 +620,9 @@ async function fetchWithRetry(url, init, retryConfig) {
617
620
  }
618
621
  throw lastError;
619
622
  }
623
+ function createFetchWithRetry(retryConfig) {
624
+ return (url, init) => fetchWithRetry(url, init, retryConfig);
625
+ }
620
626
 
621
627
  // src/resilience/circuit-breaker.ts
622
628
  var CircuitBreaker = class {
@@ -10208,8 +10214,11 @@ function isProviderType(provider, type) {
10208
10214
  buildChannelScopeMetadata,
10209
10215
  calculateDistance,
10210
10216
  createBackendMetadataAdapter,
10217
+ createFetchWithRetry,
10211
10218
  createLogger,
10212
10219
  createProvider,
10220
+ extractErrorMessage,
10221
+ fetchWithRetry,
10213
10222
  filterByChannel,
10214
10223
  filterGlobalOnly,
10215
10224
  geocodeAddress,