@thorprovider/adapters 4.3.0 → 5.0.0
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 +66 -387
- package/dist/index.d.ts +66 -387
- package/dist/index.js +70 -2901
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -2891
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/backend/factory.ts +1 -11
- package/src/factory/index.ts +74 -52
- package/src/index.ts +5 -15
- package/src/providers/index.ts +1 -16
- package/src/types/capabilities.types.ts +0 -250
- package/src/providers/bigcommerce/bigcommerce.ts +0 -6
- package/src/providers/bigcommerce/index.ts +0 -315
- package/src/providers/bigcommerce/transforms.ts +0 -227
- package/src/providers/magento/index.ts +0 -387
- package/src/providers/magento/magento.ts +0 -5
- package/src/providers/magento/queries.ts +0 -267
- package/src/providers/magento/transforms.ts +0 -249
- package/src/providers/shopify/auth.ts +0 -408
- package/src/providers/shopify/index.ts +0 -444
- package/src/providers/shopify/mutations.ts +0 -247
- package/src/providers/shopify/queries.ts +0 -324
- package/src/providers/shopify/shopify.ts +0 -7
- package/src/providers/shopify/transforms.ts +0 -275
- package/src/providers/spree/index.ts +0 -344
- package/src/providers/spree/spree.ts +0 -5
- package/src/providers/spree/transforms.ts +0 -254
- package/src/providers/woocommerce/index.ts +0 -310
- package/src/providers/woocommerce/transforms.ts +0 -254
- package/src/providers/woocommerce/woocommerce.ts +0 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _thorprovider_types from '@thorprovider/types';
|
|
2
|
-
import { BackendCapabilities, Money, PaymentMethod, FulfillmentOption, CartItem, StockLocation, InventoryLevel, StorefrontConfig, DashboardMetrics, ProviderTypeString, GetChannelCustomersOptions, GetChannelCustomersResponse, GetChannelApiKeysResponse, GetChannelCategoriesOptions, GetChannelCategoriesResponse, GetCategorySalesChannelsResponse, AssignCategoriesToChannelsBody, AssignCategoriesToChannelsResponse, UnassignCategoriesFromChannelsBody, UnassignCategoriesFromChannelsResponse, GetCollectionSalesChannelsResponse, AssignCollectionsToChannelsBody, AssignCollectionsToChannelsResponse, UnassignCollectionsFromChannelsBody, UnassignCollectionsFromChannelsResponse, GetAdminStorefrontConfigResponse, UpdateStorefrontConfigBody, UpdateStorefrontConfigResponse, GetAdminSiteConfigResponse, UpdateSiteConfigBody, UpdateSiteConfigResponse, GetAdminSiteConfigHistoryOptions, GetAdminSiteConfigHistoryResponse, RestoreSiteConfigResponse, CommerceProvider, AuthProvider, ProviderConfig, AuthConfig, Product, GetProductsOptions, AdvancedSearchProductsOptions, SearchResultMeta, FilterConfig, Collection, GetCollectionsOptions, CollectionProductsOptions, ProductCategory, GetCategoriesOptions, Cart, CartLineInput, CartLineUpdate, GetOrdersOptions, Order, GetCustomersOptions, Customer, Address, Region, AdminProduct, PaymentMethodsOptions, StockValidation, StorefrontContext, DesignerConfig, DesignerHistoryEntry,
|
|
2
|
+
import { BackendCapabilities, Money, PaymentMethod, FulfillmentOption, CartItem, StockLocation, InventoryLevel, StorefrontConfig, DashboardMetrics, ProviderTypeString, GetChannelCustomersOptions, GetChannelCustomersResponse, GetChannelApiKeysResponse, GetChannelCategoriesOptions, GetChannelCategoriesResponse, GetCategorySalesChannelsResponse, AssignCategoriesToChannelsBody, AssignCategoriesToChannelsResponse, UnassignCategoriesFromChannelsBody, UnassignCategoriesFromChannelsResponse, GetCollectionSalesChannelsResponse, AssignCollectionsToChannelsBody, AssignCollectionsToChannelsResponse, UnassignCollectionsFromChannelsBody, UnassignCollectionsFromChannelsResponse, GetAdminStorefrontConfigResponse, UpdateStorefrontConfigBody, UpdateStorefrontConfigResponse, GetAdminSiteConfigResponse, UpdateSiteConfigBody, UpdateSiteConfigResponse, GetAdminSiteConfigHistoryOptions, GetAdminSiteConfigHistoryResponse, RestoreSiteConfigResponse, CommerceProvider, AuthProvider, ProviderConfig, AuthConfig, Product, GetProductsOptions, AdvancedSearchProductsOptions, SearchResultMeta, FilterConfig, Collection, GetCollectionsOptions, CollectionProductsOptions, ProductCategory, GetCategoriesOptions, Cart, CartLineInput, CartLineUpdate, GetOrdersOptions, Order, GetCustomersOptions, Customer, Address, Region, AdminProduct, PaymentMethodsOptions, StockValidation, StorefrontContext, DesignerConfig, DesignerHistoryEntry, Country, ShippingMethod } from '@thorprovider/types';
|
|
3
3
|
export * from '@thorprovider/types';
|
|
4
4
|
export { BackendCapabilities, CommerceProvider, DesignerConfig, DesignerHistoryEntry, DesignerNavItem, DesignerThemeConfig, DesignerThemePreset, ProviderConfig, StorefrontConfig, StorefrontConfigError, StorefrontContext, StorefrontPlatformType, StorefrontSeoDefaults } from '@thorprovider/types';
|
|
5
5
|
import Medusa from '@medusajs/js-sdk';
|
|
@@ -246,36 +246,6 @@ declare const MEDUSA_CAPABILITIES: Readonly<BackendCapabilities>;
|
|
|
246
246
|
* but without cart, checkout, customer auth, or storefront-native payment flows.
|
|
247
247
|
*/
|
|
248
248
|
declare const STELORDER_CAPABILITIES: Readonly<BackendCapabilities>;
|
|
249
|
-
/**
|
|
250
|
-
* Shopify backend capabilities
|
|
251
|
-
*
|
|
252
|
-
* @see https://shopify.dev/docs/api/storefront
|
|
253
|
-
*/
|
|
254
|
-
declare const SHOPIFY_CAPABILITIES: Readonly<BackendCapabilities>;
|
|
255
|
-
/**
|
|
256
|
-
* BigCommerce backend capabilities
|
|
257
|
-
*
|
|
258
|
-
* @see https://developer.bigcommerce.com/docs/rest-storefront
|
|
259
|
-
*/
|
|
260
|
-
declare const BIGCOMMERCE_CAPABILITIES: Readonly<BackendCapabilities>;
|
|
261
|
-
/**
|
|
262
|
-
* WooCommerce backend capabilities
|
|
263
|
-
*
|
|
264
|
-
* @see https://developer.woocommerce.com/docs/apis/store-api
|
|
265
|
-
*/
|
|
266
|
-
declare const WOOCOMMERCE_CAPABILITIES: Readonly<BackendCapabilities>;
|
|
267
|
-
/**
|
|
268
|
-
* Spree Commerce backend capabilities
|
|
269
|
-
*
|
|
270
|
-
* @see https://docs.spreecommerce.org/api-reference
|
|
271
|
-
*/
|
|
272
|
-
declare const SPREE_CAPABILITIES: Readonly<BackendCapabilities>;
|
|
273
|
-
/**
|
|
274
|
-
* Adobe Commerce / Magento backend capabilities
|
|
275
|
-
*
|
|
276
|
-
* @see https://developer.adobe.com/commerce/webapi/graphql/
|
|
277
|
-
*/
|
|
278
|
-
declare const MAGENTO_CAPABILITIES: Readonly<BackendCapabilities>;
|
|
279
249
|
/**
|
|
280
250
|
* Type guard to check if an object is a valid BackendCapabilities
|
|
281
251
|
*/
|
|
@@ -322,6 +292,11 @@ declare class ProviderAPIError extends CommerceError {
|
|
|
322
292
|
readonly provider: string;
|
|
323
293
|
constructor(message: string, provider: string, status?: number);
|
|
324
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Extract error message from various error types
|
|
297
|
+
* Handles standard Error objects, API responses, and unknown error types
|
|
298
|
+
*/
|
|
299
|
+
declare function extractErrorMessage(error: unknown): string;
|
|
325
300
|
|
|
326
301
|
/**
|
|
327
302
|
* @thorprovider/adapters v2.0
|
|
@@ -377,6 +352,32 @@ interface RetryConfig {
|
|
|
377
352
|
*/
|
|
378
353
|
retryableStatusCodes?: number[];
|
|
379
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Enhanced fetch with retry logic and timeout
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* import { fetchWithRetry } from '@thorprovider/adapters/core/fetch-utils';
|
|
361
|
+
*
|
|
362
|
+
* // Basic usage with defaults (3 retries, 10s timeout)
|
|
363
|
+
* const response = await fetchWithRetry('https://api.example.com/products');
|
|
364
|
+
*
|
|
365
|
+
* // Custom configuration
|
|
366
|
+
* const response = await fetchWithRetry(
|
|
367
|
+
* 'https://api.example.com/products',
|
|
368
|
+
* {
|
|
369
|
+
* method: 'POST',
|
|
370
|
+
* body: JSON.stringify({ name: 'Product' }),
|
|
371
|
+
* },
|
|
372
|
+
* {
|
|
373
|
+
* maxRetries: 5,
|
|
374
|
+
* timeoutMs: 15000, // 15 seconds
|
|
375
|
+
* initialDelayMs: 500,
|
|
376
|
+
* }
|
|
377
|
+
* );
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
declare function fetchWithRetry(url: string, init?: RequestInit, retryConfig?: RetryConfig): Promise<Response>;
|
|
380
381
|
|
|
381
382
|
/**
|
|
382
383
|
* Circuit Breaker Pattern Implementation
|
|
@@ -2303,330 +2304,6 @@ declare class MedusaProvider implements CommerceProvider {
|
|
|
2303
2304
|
}>;
|
|
2304
2305
|
}
|
|
2305
2306
|
|
|
2306
|
-
/**
|
|
2307
|
-
* Shopify provider configuration
|
|
2308
|
-
*/
|
|
2309
|
-
interface ShopifyProviderConfig extends ProviderConfig {
|
|
2310
|
-
/** Store domain (e.g., 'your-store.myshopify.com') */
|
|
2311
|
-
storeDomain: string;
|
|
2312
|
-
/** Public Storefront API access token */
|
|
2313
|
-
publicAccessToken: string;
|
|
2314
|
-
/** Private Storefront API access token (server-side only) */
|
|
2315
|
-
privateAccessToken?: string;
|
|
2316
|
-
/** API version (default: '2026-04') */
|
|
2317
|
-
apiVersion?: string;
|
|
2318
|
-
}
|
|
2319
|
-
/**
|
|
2320
|
-
* Shopify commerce provider
|
|
2321
|
-
*
|
|
2322
|
-
* Implements CommerceProvider for Shopify Storefront API.
|
|
2323
|
-
* Uses raw fetch + GraphQL queries (no SDK dependency to stay L2-pure).
|
|
2324
|
-
*/
|
|
2325
|
-
declare class ShopifyProvider implements CommerceProvider {
|
|
2326
|
-
readonly name = "shopify";
|
|
2327
|
-
readonly version = "1.0.0";
|
|
2328
|
-
readonly capabilities: BackendCapabilities;
|
|
2329
|
-
private logger;
|
|
2330
|
-
private storeDomain;
|
|
2331
|
-
private apiVersion;
|
|
2332
|
-
private endpoint;
|
|
2333
|
-
private headers;
|
|
2334
|
-
constructor(config: ShopifyProviderConfig);
|
|
2335
|
-
private query;
|
|
2336
|
-
getProduct(handle: string): Promise<Product | undefined>;
|
|
2337
|
-
getProducts(options?: GetProductsOptions): Promise<Product[]>;
|
|
2338
|
-
getProductRecommendations(productId: string): Promise<Product[]>;
|
|
2339
|
-
getCollection(handle: string): Promise<Collection | undefined>;
|
|
2340
|
-
getCollections(options?: GetCollectionsOptions): Promise<Collection[]>;
|
|
2341
|
-
getCollectionProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
|
|
2342
|
-
getCategory(): Promise<ProductCategory | undefined>;
|
|
2343
|
-
getCategories(): Promise<ProductCategory[]>;
|
|
2344
|
-
getCategoryProducts(): Promise<Product[]>;
|
|
2345
|
-
createCart(): Promise<Cart>;
|
|
2346
|
-
getCart(cartId: string): Promise<Cart | undefined>;
|
|
2347
|
-
addToCart(cartId: string, lines: CartLineInput[]): Promise<Cart>;
|
|
2348
|
-
removeFromCart(cartId: string, lineIds: string[]): Promise<Cart>;
|
|
2349
|
-
updateCart(cartId: string, lines: CartLineUpdate[]): Promise<Cart>;
|
|
2350
|
-
completeCheckout(_cartId: string): Promise<Order>;
|
|
2351
|
-
getShippingMethods(_cartId: string): Promise<ShippingMethod[]>;
|
|
2352
|
-
getRegionCountries(): Promise<_thorprovider_types.Country[]>;
|
|
2353
|
-
addShippingMethod(_cartId: string, _methodId: string): Promise<Cart>;
|
|
2354
|
-
initiatePaymentSession(_cartId: string, _providerId: string): Promise<void>;
|
|
2355
|
-
applyDiscountCode(cartId: string, code: string): Promise<Cart>;
|
|
2356
|
-
removeDiscountCode(cartId: string, _code: string): Promise<Cart>;
|
|
2357
|
-
getOrders(options: GetOrdersOptions): Promise<Order[]>;
|
|
2358
|
-
getPaymentMethods(_options: PaymentMethodsOptions): Promise<PaymentMethod[]>;
|
|
2359
|
-
getStockLocations(): Promise<StockLocation[]>;
|
|
2360
|
-
checkInventoryLevels(): Promise<InventoryLevel[]>;
|
|
2361
|
-
validateCartStock(): Promise<StockValidation>;
|
|
2362
|
-
getFulfillmentOptions(): Promise<FulfillmentOption[]>;
|
|
2363
|
-
cancelOrder(_orderId: string): Promise<Order>;
|
|
2364
|
-
createFulfillment(_orderId: string): Promise<void>;
|
|
2365
|
-
createRefund(_orderId: string): Promise<void>;
|
|
2366
|
-
getAdminOrders(): Promise<{
|
|
2367
|
-
orders: Order[];
|
|
2368
|
-
count: number;
|
|
2369
|
-
}>;
|
|
2370
|
-
getStorefrontContext(): Promise<StorefrontContext>;
|
|
2371
|
-
isStorefrontRequired(): boolean;
|
|
2372
|
-
}
|
|
2373
|
-
|
|
2374
|
-
/**
|
|
2375
|
-
* BigCommerce provider configuration
|
|
2376
|
-
*/
|
|
2377
|
-
interface BigCommerceProviderConfig extends ProviderConfig {
|
|
2378
|
-
/** BigCommerce store hash */
|
|
2379
|
-
storeHash: string;
|
|
2380
|
-
/** Storefront API token (JWT) */
|
|
2381
|
-
storefrontApiToken: string;
|
|
2382
|
-
/** Storefront API URL (usually https://store-{hash}.mybigcommerce.com) */
|
|
2383
|
-
storefrontApiUrl: string;
|
|
2384
|
-
/** Channel ID */
|
|
2385
|
-
channelId: string;
|
|
2386
|
-
/** Default currency code (default: 'USD') */
|
|
2387
|
-
currencyCode?: string;
|
|
2388
|
-
}
|
|
2389
|
-
declare class BigCommerceProvider implements CommerceProvider {
|
|
2390
|
-
readonly name = "bigcommerce";
|
|
2391
|
-
readonly version = "1.0.0";
|
|
2392
|
-
readonly capabilities: BackendCapabilities;
|
|
2393
|
-
private logger;
|
|
2394
|
-
private storefrontApiUrl;
|
|
2395
|
-
private storeHash;
|
|
2396
|
-
private channelId;
|
|
2397
|
-
private currencyCode;
|
|
2398
|
-
private headers;
|
|
2399
|
-
constructor(config: BigCommerceProviderConfig);
|
|
2400
|
-
private fetchApi;
|
|
2401
|
-
getProduct(handle: string): Promise<Product | undefined>;
|
|
2402
|
-
getProducts(options?: GetProductsOptions): Promise<Product[]>;
|
|
2403
|
-
getProductRecommendations(_productId: string): Promise<Product[]>;
|
|
2404
|
-
getCollection(handle: string): Promise<Collection | undefined>;
|
|
2405
|
-
getCollections(options?: GetCollectionsOptions): Promise<Collection[]>;
|
|
2406
|
-
getCollectionProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
|
|
2407
|
-
getCategory(idOrHandle: string): Promise<ProductCategory | undefined>;
|
|
2408
|
-
getCategories(options?: GetCategoriesOptions): Promise<ProductCategory[]>;
|
|
2409
|
-
getCategoryProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
|
|
2410
|
-
createCart(): Promise<Cart>;
|
|
2411
|
-
getCart(cartId: string): Promise<Cart | undefined>;
|
|
2412
|
-
addToCart(cartId: string, lines: CartLineInput[]): Promise<Cart>;
|
|
2413
|
-
removeFromCart(cartId: string, lineIds: string[]): Promise<Cart>;
|
|
2414
|
-
updateCart(cartId: string, lines: CartLineUpdate[]): Promise<Cart>;
|
|
2415
|
-
completeCheckout(_cartId: string): Promise<Order>;
|
|
2416
|
-
getShippingMethods(_cartId: string): Promise<ShippingMethod[]>;
|
|
2417
|
-
getRegionCountries(): Promise<_thorprovider_types.Country[]>;
|
|
2418
|
-
addShippingMethod(_cartId: string, _methodId: string): Promise<Cart>;
|
|
2419
|
-
initiatePaymentSession(_cartId: string, _providerId: string): Promise<void>;
|
|
2420
|
-
applyDiscountCode(cartId: string, code: string): Promise<Cart>;
|
|
2421
|
-
removeDiscountCode(cartId: string, code: string): Promise<Cart>;
|
|
2422
|
-
getOrders(_options: GetOrdersOptions): Promise<Order[]>;
|
|
2423
|
-
getPaymentMethods(_options: PaymentMethodsOptions): Promise<PaymentMethod[]>;
|
|
2424
|
-
getStockLocations(): Promise<StockLocation[]>;
|
|
2425
|
-
checkInventoryLevels(): Promise<InventoryLevel[]>;
|
|
2426
|
-
validateCartStock(): Promise<StockValidation>;
|
|
2427
|
-
getFulfillmentOptions(): Promise<FulfillmentOption[]>;
|
|
2428
|
-
cancelOrder(_orderId: string): Promise<Order>;
|
|
2429
|
-
createFulfillment(_orderId: string): Promise<void>;
|
|
2430
|
-
createRefund(_orderId: string): Promise<void>;
|
|
2431
|
-
getAdminOrders(): Promise<{
|
|
2432
|
-
orders: Order[];
|
|
2433
|
-
count: number;
|
|
2434
|
-
}>;
|
|
2435
|
-
getStorefrontContext(): Promise<StorefrontContext>;
|
|
2436
|
-
isStorefrontRequired(): boolean;
|
|
2437
|
-
}
|
|
2438
|
-
|
|
2439
|
-
/**
|
|
2440
|
-
* WooCommerce provider configuration
|
|
2441
|
-
*/
|
|
2442
|
-
interface WooCommerceProviderConfig extends ProviderConfig {
|
|
2443
|
-
/** WordPress site URL (e.g., 'https://mystore.com') */
|
|
2444
|
-
url: string;
|
|
2445
|
-
/** WooCommerce REST API consumer key (for authenticated operations) */
|
|
2446
|
-
consumerKey?: string;
|
|
2447
|
-
/** WooCommerce REST API consumer secret (for authenticated operations) */
|
|
2448
|
-
consumerSecret?: string;
|
|
2449
|
-
/** Default currency code (default: 'USD') */
|
|
2450
|
-
currencyCode?: string;
|
|
2451
|
-
}
|
|
2452
|
-
declare class WooCommerceProvider implements CommerceProvider {
|
|
2453
|
-
readonly name = "woocommerce";
|
|
2454
|
-
readonly version = "1.0.0";
|
|
2455
|
-
readonly capabilities: BackendCapabilities;
|
|
2456
|
-
private logger;
|
|
2457
|
-
private baseUrl;
|
|
2458
|
-
private storeApiBase;
|
|
2459
|
-
private restApiBase;
|
|
2460
|
-
private currencyCode;
|
|
2461
|
-
private authHeader?;
|
|
2462
|
-
constructor(config: WooCommerceProviderConfig);
|
|
2463
|
-
private storeApiFetch;
|
|
2464
|
-
private restApiFetch;
|
|
2465
|
-
getProduct(handle: string): Promise<Product | undefined>;
|
|
2466
|
-
getProducts(options?: GetProductsOptions): Promise<Product[]>;
|
|
2467
|
-
getProductRecommendations(_productId: string): Promise<Product[]>;
|
|
2468
|
-
getCollection(handle: string): Promise<Collection | undefined>;
|
|
2469
|
-
getCollections(options?: GetCollectionsOptions): Promise<Collection[]>;
|
|
2470
|
-
getCollectionProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
|
|
2471
|
-
getCategory(idOrHandle: string): Promise<ProductCategory | undefined>;
|
|
2472
|
-
getCategories(options?: GetCategoriesOptions): Promise<ProductCategory[]>;
|
|
2473
|
-
getCategoryProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
|
|
2474
|
-
createCart(): Promise<Cart>;
|
|
2475
|
-
getCart(_cartId: string): Promise<Cart | undefined>;
|
|
2476
|
-
addToCart(_cartId: string, lines: CartLineInput[]): Promise<Cart>;
|
|
2477
|
-
removeFromCart(_cartId: string, lineIds: string[]): Promise<Cart>;
|
|
2478
|
-
updateCart(_cartId: string, lines: CartLineUpdate[]): Promise<Cart>;
|
|
2479
|
-
completeCheckout(_cartId: string): Promise<Order>;
|
|
2480
|
-
getShippingMethods(_cartId: string): Promise<ShippingMethod[]>;
|
|
2481
|
-
getRegionCountries(): Promise<_thorprovider_types.Country[]>;
|
|
2482
|
-
addShippingMethod(_cartId: string, methodId: string): Promise<Cart>;
|
|
2483
|
-
initiatePaymentSession(_cartId: string, _providerId: string): Promise<void>;
|
|
2484
|
-
applyDiscountCode(_cartId: string, code: string): Promise<Cart>;
|
|
2485
|
-
removeDiscountCode(_cartId: string, code: string): Promise<Cart>;
|
|
2486
|
-
getOrders(_options: GetOrdersOptions): Promise<Order[]>;
|
|
2487
|
-
getPaymentMethods(_options: PaymentMethodsOptions): Promise<PaymentMethod[]>;
|
|
2488
|
-
getStockLocations(): Promise<StockLocation[]>;
|
|
2489
|
-
checkInventoryLevels(): Promise<InventoryLevel[]>;
|
|
2490
|
-
validateCartStock(): Promise<StockValidation>;
|
|
2491
|
-
getFulfillmentOptions(): Promise<FulfillmentOption[]>;
|
|
2492
|
-
cancelOrder(_orderId: string): Promise<Order>;
|
|
2493
|
-
createFulfillment(_orderId: string): Promise<void>;
|
|
2494
|
-
createRefund(_orderId: string): Promise<void>;
|
|
2495
|
-
getAdminOrders(): Promise<{
|
|
2496
|
-
orders: Order[];
|
|
2497
|
-
count: number;
|
|
2498
|
-
}>;
|
|
2499
|
-
getStorefrontContext(): Promise<StorefrontContext>;
|
|
2500
|
-
isStorefrontRequired(): boolean;
|
|
2501
|
-
}
|
|
2502
|
-
|
|
2503
|
-
/**
|
|
2504
|
-
* Spree provider configuration
|
|
2505
|
-
*/
|
|
2506
|
-
interface SpreeProviderConfig extends ProviderConfig {
|
|
2507
|
-
/** Spree store base URL (e.g., 'https://myspreestore.com') */
|
|
2508
|
-
baseUrl: string;
|
|
2509
|
-
/** Bearer token for authenticated operations (customer or OAuth) */
|
|
2510
|
-
bearerToken?: string;
|
|
2511
|
-
/** Default currency code (default: 'USD') */
|
|
2512
|
-
currencyCode?: string;
|
|
2513
|
-
}
|
|
2514
|
-
declare class SpreeProvider implements CommerceProvider {
|
|
2515
|
-
readonly name = "spree";
|
|
2516
|
-
readonly version = "1.0.0";
|
|
2517
|
-
readonly capabilities: BackendCapabilities;
|
|
2518
|
-
private logger;
|
|
2519
|
-
private baseUrl;
|
|
2520
|
-
private apiBase;
|
|
2521
|
-
private currencyCode;
|
|
2522
|
-
private bearerToken?;
|
|
2523
|
-
private orderToken?;
|
|
2524
|
-
constructor(config: SpreeProviderConfig);
|
|
2525
|
-
private apiFetch;
|
|
2526
|
-
getProduct(handle: string): Promise<Product | undefined>;
|
|
2527
|
-
getProducts(options?: GetProductsOptions): Promise<Product[]>;
|
|
2528
|
-
getProductRecommendations(_productId: string): Promise<Product[]>;
|
|
2529
|
-
getCollection(handle: string): Promise<Collection | undefined>;
|
|
2530
|
-
getCollections(options?: GetCollectionsOptions): Promise<Collection[]>;
|
|
2531
|
-
getCollectionProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
|
|
2532
|
-
getCategory(handle: string): Promise<ProductCategory | undefined>;
|
|
2533
|
-
getCategories(options?: GetCategoriesOptions): Promise<ProductCategory[]>;
|
|
2534
|
-
getCategoryProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
|
|
2535
|
-
createCart(): Promise<Cart>;
|
|
2536
|
-
getCart(_cartId: string): Promise<Cart | undefined>;
|
|
2537
|
-
addToCart(_cartId: string, lines: CartLineInput[]): Promise<Cart>;
|
|
2538
|
-
removeFromCart(_cartId: string, lineIds: string[]): Promise<Cart>;
|
|
2539
|
-
updateCart(_cartId: string, lines: CartLineUpdate[]): Promise<Cart>;
|
|
2540
|
-
completeCheckout(_cartId: string): Promise<Order>;
|
|
2541
|
-
getShippingMethods(_cartId: string): Promise<ShippingMethod[]>;
|
|
2542
|
-
getRegionCountries(): Promise<_thorprovider_types.Country[]>;
|
|
2543
|
-
addShippingMethod(_cartId: string, methodId: string): Promise<Cart>;
|
|
2544
|
-
initiatePaymentSession(_cartId: string, _providerId: string): Promise<void>;
|
|
2545
|
-
applyDiscountCode(_cartId: string, code: string): Promise<Cart>;
|
|
2546
|
-
removeDiscountCode(_cartId: string, code: string): Promise<Cart>;
|
|
2547
|
-
getOrders(_options: GetOrdersOptions): Promise<Order[]>;
|
|
2548
|
-
getPaymentMethods(_options: PaymentMethodsOptions): Promise<PaymentMethod[]>;
|
|
2549
|
-
getStockLocations(): Promise<StockLocation[]>;
|
|
2550
|
-
checkInventoryLevels(): Promise<InventoryLevel[]>;
|
|
2551
|
-
validateCartStock(): Promise<StockValidation>;
|
|
2552
|
-
getFulfillmentOptions(): Promise<FulfillmentOption[]>;
|
|
2553
|
-
cancelOrder(_orderId: string): Promise<Order>;
|
|
2554
|
-
createFulfillment(_orderId: string): Promise<void>;
|
|
2555
|
-
createRefund(_orderId: string): Promise<void>;
|
|
2556
|
-
getAdminOrders(): Promise<{
|
|
2557
|
-
orders: Order[];
|
|
2558
|
-
count: number;
|
|
2559
|
-
}>;
|
|
2560
|
-
getStorefrontContext(): Promise<StorefrontContext>;
|
|
2561
|
-
isStorefrontRequired(): boolean;
|
|
2562
|
-
}
|
|
2563
|
-
|
|
2564
|
-
/**
|
|
2565
|
-
* Magento provider configuration
|
|
2566
|
-
*/
|
|
2567
|
-
interface MagentoProviderConfig extends ProviderConfig {
|
|
2568
|
-
/** Magento base URL (e.g., 'https://mymagento.com') */
|
|
2569
|
-
baseUrl: string;
|
|
2570
|
-
/** Store code for multi-tenant (default: 'default') */
|
|
2571
|
-
storeCode?: string;
|
|
2572
|
-
/** Customer bearer token (for authenticated operations) */
|
|
2573
|
-
customerToken?: string;
|
|
2574
|
-
/** Integration access token (for admin-level operations) */
|
|
2575
|
-
accessToken?: string;
|
|
2576
|
-
/** Default currency code (default: 'USD') */
|
|
2577
|
-
currencyCode?: string;
|
|
2578
|
-
}
|
|
2579
|
-
declare class MagentoProvider implements CommerceProvider {
|
|
2580
|
-
readonly name = "magento";
|
|
2581
|
-
readonly version = "1.0.0";
|
|
2582
|
-
readonly capabilities: BackendCapabilities;
|
|
2583
|
-
private logger;
|
|
2584
|
-
private baseUrl;
|
|
2585
|
-
private storeCode;
|
|
2586
|
-
private currencyCode;
|
|
2587
|
-
private graphqlEndpoint;
|
|
2588
|
-
private customerToken?;
|
|
2589
|
-
private accessToken?;
|
|
2590
|
-
constructor(config: MagentoProviderConfig);
|
|
2591
|
-
private graphql;
|
|
2592
|
-
getProduct(handle: string): Promise<Product | undefined>;
|
|
2593
|
-
getProducts(options?: GetProductsOptions): Promise<Product[]>;
|
|
2594
|
-
getProductRecommendations(_productId: string): Promise<Product[]>;
|
|
2595
|
-
getCollection(handle: string): Promise<Collection | undefined>;
|
|
2596
|
-
getCollections(options?: GetCollectionsOptions): Promise<Collection[]>;
|
|
2597
|
-
getCollectionProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
|
|
2598
|
-
getCategory(handle: string): Promise<ProductCategory | undefined>;
|
|
2599
|
-
getCategories(options?: GetCategoriesOptions): Promise<ProductCategory[]>;
|
|
2600
|
-
getCategoryProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
|
|
2601
|
-
createCart(): Promise<Cart>;
|
|
2602
|
-
getCart(cartId: string): Promise<Cart | undefined>;
|
|
2603
|
-
addToCart(cartId: string, lines: CartLineInput[]): Promise<Cart>;
|
|
2604
|
-
removeFromCart(cartId: string, lineIds: string[]): Promise<Cart>;
|
|
2605
|
-
updateCart(cartId: string, lines: CartLineUpdate[]): Promise<Cart>;
|
|
2606
|
-
completeCheckout(_cartId: string): Promise<Order>;
|
|
2607
|
-
getShippingMethods(_cartId: string): Promise<ShippingMethod[]>;
|
|
2608
|
-
getRegionCountries(): Promise<_thorprovider_types.Country[]>;
|
|
2609
|
-
addShippingMethod(_cartId: string, _methodId: string): Promise<Cart>;
|
|
2610
|
-
initiatePaymentSession(_cartId: string, _providerId: string): Promise<void>;
|
|
2611
|
-
applyDiscountCode(cartId: string, code: string): Promise<Cart>;
|
|
2612
|
-
removeDiscountCode(cartId: string, _code: string): Promise<Cart>;
|
|
2613
|
-
getOrders(_options: GetOrdersOptions): Promise<Order[]>;
|
|
2614
|
-
getPaymentMethods(_options: PaymentMethodsOptions): Promise<PaymentMethod[]>;
|
|
2615
|
-
getStockLocations(): Promise<StockLocation[]>;
|
|
2616
|
-
checkInventoryLevels(): Promise<InventoryLevel[]>;
|
|
2617
|
-
validateCartStock(): Promise<StockValidation>;
|
|
2618
|
-
getFulfillmentOptions(): Promise<FulfillmentOption[]>;
|
|
2619
|
-
cancelOrder(_orderId: string): Promise<Order>;
|
|
2620
|
-
createFulfillment(_orderId: string): Promise<void>;
|
|
2621
|
-
createRefund(_orderId: string): Promise<void>;
|
|
2622
|
-
getAdminOrders(): Promise<{
|
|
2623
|
-
orders: Order[];
|
|
2624
|
-
count: number;
|
|
2625
|
-
}>;
|
|
2626
|
-
getStorefrontContext(): Promise<StorefrontContext>;
|
|
2627
|
-
isStorefrontRequired(): boolean;
|
|
2628
|
-
}
|
|
2629
|
-
|
|
2630
2307
|
interface StelOrderProviderConfig extends ProviderConfig {
|
|
2631
2308
|
baseUrl: string;
|
|
2632
2309
|
apiKey?: string;
|
|
@@ -2776,24 +2453,40 @@ declare class MockProvider implements CommerceProvider {
|
|
|
2776
2453
|
}
|
|
2777
2454
|
|
|
2778
2455
|
/**
|
|
2779
|
-
* @thorprovider/adapters
|
|
2780
|
-
* Provider Factory -
|
|
2456
|
+
* @thorprovider/adapters v5.0
|
|
2457
|
+
* Provider Factory - Dynamic registry pattern
|
|
2458
|
+
*
|
|
2459
|
+
* Providers register themselves at import time via `registerProvider()`.
|
|
2460
|
+
* The factory no longer statically imports every backend — only the ones
|
|
2461
|
+
* the consumer explicitly imports will be available.
|
|
2781
2462
|
*
|
|
2782
|
-
*
|
|
2783
|
-
* When adding a new provider:
|
|
2784
|
-
* 1. Update SupportedProviderType enum in packages/types/src/provider.ts
|
|
2785
|
-
* 2. Add new discriminated union case here
|
|
2786
|
-
* 3. Create packages/adapters/src/providers/[platform]/
|
|
2787
|
-
* 4. Implement CommerceProvider interface
|
|
2463
|
+
* Built-in providers (medusa, stelorder, mock) are registered automatically.
|
|
2788
2464
|
*/
|
|
2789
2465
|
|
|
2466
|
+
type ProviderFactory = (config: any) => CommerceProvider;
|
|
2790
2467
|
/**
|
|
2791
|
-
*
|
|
2792
|
-
*
|
|
2468
|
+
* Register a provider factory for a given type string.
|
|
2469
|
+
* Call this to make a provider available to `createProvider()`.
|
|
2470
|
+
*
|
|
2471
|
+
* @example
|
|
2472
|
+
* ```ts
|
|
2473
|
+
* import { registerProvider } from '@thorprovider/adapters';
|
|
2474
|
+
* import { MyProvider } from './my-provider';
|
|
2475
|
+
*
|
|
2476
|
+
* registerProvider('my-provider', (config) => new MyProvider(config));
|
|
2477
|
+
* ```
|
|
2478
|
+
*/
|
|
2479
|
+
declare function registerProvider(type: string, factory: ProviderFactory): void;
|
|
2480
|
+
/**
|
|
2481
|
+
* Get all registered provider type strings.
|
|
2793
2482
|
*/
|
|
2794
|
-
|
|
2483
|
+
declare function getRegisteredProviders(): string[];
|
|
2795
2484
|
/**
|
|
2796
|
-
*
|
|
2485
|
+
* Supported provider types
|
|
2486
|
+
*/
|
|
2487
|
+
type ProviderType = ProviderTypeString | (string & {});
|
|
2488
|
+
/**
|
|
2489
|
+
* Provider configuration discriminated union (built-in providers)
|
|
2797
2490
|
*/
|
|
2798
2491
|
type ProviderFactoryConfig = {
|
|
2799
2492
|
provider: 'mock';
|
|
@@ -2805,30 +2498,18 @@ type ProviderFactoryConfig = {
|
|
|
2805
2498
|
provider: 'stelorder';
|
|
2806
2499
|
config: StelOrderProviderConfig;
|
|
2807
2500
|
} | {
|
|
2808
|
-
provider:
|
|
2809
|
-
config:
|
|
2810
|
-
} | {
|
|
2811
|
-
provider: 'bigcommerce';
|
|
2812
|
-
config: BigCommerceProviderConfig;
|
|
2813
|
-
} | {
|
|
2814
|
-
provider: 'woocommerce';
|
|
2815
|
-
config: WooCommerceProviderConfig;
|
|
2816
|
-
} | {
|
|
2817
|
-
provider: 'spree';
|
|
2818
|
-
config: SpreeProviderConfig;
|
|
2819
|
-
} | {
|
|
2820
|
-
provider: 'magento';
|
|
2821
|
-
config: MagentoProviderConfig;
|
|
2501
|
+
provider: string;
|
|
2502
|
+
config: Record<string, unknown>;
|
|
2822
2503
|
};
|
|
2823
2504
|
/**
|
|
2824
|
-
* Runtime provider configuration (accepts any
|
|
2505
|
+
* Runtime provider configuration (accepts any registered provider string)
|
|
2825
2506
|
*/
|
|
2826
2507
|
type RuntimeProviderConfig = {
|
|
2827
|
-
provider:
|
|
2508
|
+
provider: string;
|
|
2828
2509
|
config: Record<string, unknown>;
|
|
2829
2510
|
};
|
|
2830
2511
|
/**
|
|
2831
|
-
* Create a commerce provider instance
|
|
2512
|
+
* Create a commerce provider instance from the registry.
|
|
2832
2513
|
*
|
|
2833
2514
|
* @example
|
|
2834
2515
|
* ```ts
|
|
@@ -2839,8 +2520,6 @@ type RuntimeProviderConfig = {
|
|
|
2839
2520
|
* publishableKey: process.env.MEDUSA_PUBLISHABLE_KEY,
|
|
2840
2521
|
* }
|
|
2841
2522
|
* });
|
|
2842
|
-
*
|
|
2843
|
-
* const products = await commerce.getProducts();
|
|
2844
2523
|
* ```
|
|
2845
2524
|
*/
|
|
2846
2525
|
declare function createProvider(options: ProviderFactoryConfig | RuntimeProviderConfig): CommerceProvider;
|
|
@@ -2849,4 +2528,4 @@ declare function createProvider(options: ProviderFactoryConfig | RuntimeProvider
|
|
|
2849
2528
|
*/
|
|
2850
2529
|
declare function isProviderType<T extends ProviderType>(provider: CommerceProvider, type: T): boolean;
|
|
2851
2530
|
|
|
2852
|
-
export { AdminAuthService, type AdminSession, AdminSessionService,
|
|
2531
|
+
export { AdminAuthService, type AdminSession, AdminSessionService, type BackendMapping, type BackendMetadataAdapter, type BackendMetadataAdapterConfig, 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, MEDUSA_CAPABILITIES, MOCK_CAPABILITIES, MedusaMetadataAdapter, MedusaProvider, type MedusaProviderConfig, type MetricsOrderInput, type MetricsProductInput, MetricsService, MockProvider, type MockProviderConfig, type PlanFulfillmentShippingAddress, ProviderAPIError, type ProviderFactoryConfig, ProviderNotFoundError, type ProviderType, ResourceNotFoundError, type RetryConfig, STELORDER_CAPABILITIES, StelOrderProvider, type StelOrderProviderConfig, type UICartItem, type UICartTotals, type UIDiscountCode, type UIPaymentMethod, type UIShippingMethod, assertEntityBelongsToChannel, backendCircuitBreaker, buildChannelScopeMetadata, calculateDistance, createBackendMetadataAdapter, createLogger, createProvider, extractErrorMessage, fetchWithRetry, filterByChannel, filterGlobalOnly, geocodeAddress, getBackendProviderId, getCapabilityDescription, getChannelScope, getRegisteredProviders, isBackendCapabilities, isGlobalEntity, isProviderType, isScopedToChannel, moneyToNumber, moneyToNumberSafe, numberToMoney, partitionByChannel, planFulfillment, registerProvider, transformFulfillmentOption, transformInventoryLevel, transformStockLocation, transformStorefrontConfig, validateAssignedBy, validateChannelId, validateChannelScopeAssignment, validateEntityId, validatePaymentId };
|