@thorprovider/adapters 4.1.0 → 4.2.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 CHANGED
@@ -225,6 +225,14 @@ interface UIPaymentMethod {
225
225
  * @see packages/core/docs/COMMERCE_PROVIDER_ARCHITECTURE.md
226
226
  */
227
227
 
228
+ /**
229
+ * Mock backend capabilities
230
+ *
231
+ * Fixture-backed provider used when a storefront has not yet been connected
232
+ * to a real backend. Supports the minimum commerce flows needed for layout,
233
+ * preview, navigation, region switching, and cart prototyping.
234
+ */
235
+ declare const MOCK_CAPABILITIES: Readonly<BackendCapabilities>;
228
236
  /**
229
237
  * Medusa backend capabilities
230
238
  *
@@ -2453,6 +2461,76 @@ declare class MagentoProvider implements CommerceProvider {
2453
2461
  isStorefrontRequired(): boolean;
2454
2462
  }
2455
2463
 
2464
+ interface MockProviderConfig extends ProviderConfig {
2465
+ currencyCode?: string;
2466
+ siteUrl?: string;
2467
+ }
2468
+ declare class MockProvider implements CommerceProvider {
2469
+ readonly name = "mock";
2470
+ readonly version = "1.0.0";
2471
+ readonly capabilities: Readonly<_thorprovider_types.BackendCapabilities>;
2472
+ readonly isMock = true;
2473
+ private readonly currencyCode;
2474
+ private readonly siteUrl;
2475
+ constructor(config?: MockProviderConfig);
2476
+ private hasVariant;
2477
+ getProduct(handle: string, options?: {
2478
+ regionId?: string;
2479
+ }): Promise<Product | undefined>;
2480
+ getProducts(options?: GetProductsOptions): Promise<Product[]>;
2481
+ getProductRecommendations(productId: string): Promise<Product[]>;
2482
+ getCollection(handle: string): Promise<Collection | undefined>;
2483
+ getCollections(options?: GetCollectionsOptions): Promise<Collection[]>;
2484
+ getCollectionProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
2485
+ getCategory(idOrHandle: string): Promise<ProductCategory | undefined>;
2486
+ getCategories(options?: GetCategoriesOptions): Promise<ProductCategory[]>;
2487
+ getCategoryProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
2488
+ createCart(options?: {
2489
+ regionId?: string;
2490
+ }): Promise<Cart>;
2491
+ getCart(cartId: string): Promise<Cart | undefined>;
2492
+ addToCart(cartId: string, lines: CartLineInput[]): Promise<Cart>;
2493
+ removeFromCart(cartId: string, lineIds: string[]): Promise<Cart>;
2494
+ updateCart(cartId: string, lines: CartLineUpdate[]): Promise<Cart>;
2495
+ getRegions(): Promise<Array<{
2496
+ id: string;
2497
+ name: string;
2498
+ currency_code: string;
2499
+ countries?: Array<{
2500
+ id: string;
2501
+ iso_2: string;
2502
+ name: string;
2503
+ display_name?: string;
2504
+ }>;
2505
+ }>>;
2506
+ completeCheckout(cartId: string): Promise<Order>;
2507
+ getShippingMethods(cartId: string): Promise<ShippingMethod[]>;
2508
+ getRegionCountries(regionId: string): Promise<_thorprovider_types.Country[]>;
2509
+ addShippingMethod(cartId: string, methodId: string): Promise<Cart>;
2510
+ initiatePaymentSession(cartId: string, providerId: string): Promise<void>;
2511
+ applyDiscountCode(cartId: string, code: string): Promise<Cart>;
2512
+ removeDiscountCode(cartId: string, _code: string): Promise<Cart>;
2513
+ getOrders(_options: GetOrdersOptions): Promise<Order[]>;
2514
+ getPaymentMethods(options: PaymentMethodsOptions): Promise<PaymentMethod[]>;
2515
+ getStockLocations(): Promise<StockLocation[]>;
2516
+ checkInventoryLevels(variantId: string): Promise<InventoryLevel[]>;
2517
+ validateCartStock(cartId: string): Promise<StockValidation>;
2518
+ getFulfillmentOptions(cartId: string, _salesChannelId: string): Promise<FulfillmentOption[]>;
2519
+ cancelOrder(orderId: string): Promise<Order>;
2520
+ createFulfillment(_orderId: string, _items?: Array<{
2521
+ id: string;
2522
+ quantity: number;
2523
+ }>): Promise<void>;
2524
+ createRefund(orderId: string, _amount?: number, _reason?: string): Promise<void>;
2525
+ getAdminOrders(): Promise<{
2526
+ orders: Order[];
2527
+ count: number;
2528
+ }>;
2529
+ getAdminRegions(): Promise<Region[]>;
2530
+ getStorefrontContext(): Promise<StorefrontContext>;
2531
+ isStorefrontRequired(): boolean;
2532
+ }
2533
+
2456
2534
  /**
2457
2535
  * @thorprovider/adapters v2.0
2458
2536
  * Provider Factory - Create commerce providers dynamically
@@ -2474,6 +2552,9 @@ type ProviderType = ProviderTypeString;
2474
2552
  * Provider configuration discriminated union
2475
2553
  */
2476
2554
  type ProviderFactoryConfig = {
2555
+ provider: 'mock';
2556
+ config: MockProviderConfig;
2557
+ } | {
2477
2558
  provider: 'medusa';
2478
2559
  config: MedusaProviderConfig;
2479
2560
  } | {
@@ -2521,4 +2602,4 @@ declare function createProvider(options: ProviderFactoryConfig | RuntimeProvider
2521
2602
  */
2522
2603
  declare function isProviderType<T extends ProviderType>(provider: CommerceProvider, type: T): boolean;
2523
2604
 
2524
- 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, MagentoProvider, type MagentoProviderConfig, MedusaMetadataAdapter, MedusaProvider, type MedusaProviderConfig, type MetricsOrderInput, type MetricsProductInput, MetricsService, type PlanFulfillmentShippingAddress, ProviderAPIError, type ProviderFactoryConfig, ProviderNotFoundError, type ProviderType, ResourceNotFoundError, SHOPIFY_CAPABILITIES, SPREE_CAPABILITIES, ShopifyProvider, type ShopifyProviderConfig, SpreeProvider, type SpreeProviderConfig, 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 };
2605
+ 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, ShopifyProvider, type ShopifyProviderConfig, SpreeProvider, type SpreeProviderConfig, 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 };
package/dist/index.d.ts CHANGED
@@ -225,6 +225,14 @@ interface UIPaymentMethod {
225
225
  * @see packages/core/docs/COMMERCE_PROVIDER_ARCHITECTURE.md
226
226
  */
227
227
 
228
+ /**
229
+ * Mock backend capabilities
230
+ *
231
+ * Fixture-backed provider used when a storefront has not yet been connected
232
+ * to a real backend. Supports the minimum commerce flows needed for layout,
233
+ * preview, navigation, region switching, and cart prototyping.
234
+ */
235
+ declare const MOCK_CAPABILITIES: Readonly<BackendCapabilities>;
228
236
  /**
229
237
  * Medusa backend capabilities
230
238
  *
@@ -2453,6 +2461,76 @@ declare class MagentoProvider implements CommerceProvider {
2453
2461
  isStorefrontRequired(): boolean;
2454
2462
  }
2455
2463
 
2464
+ interface MockProviderConfig extends ProviderConfig {
2465
+ currencyCode?: string;
2466
+ siteUrl?: string;
2467
+ }
2468
+ declare class MockProvider implements CommerceProvider {
2469
+ readonly name = "mock";
2470
+ readonly version = "1.0.0";
2471
+ readonly capabilities: Readonly<_thorprovider_types.BackendCapabilities>;
2472
+ readonly isMock = true;
2473
+ private readonly currencyCode;
2474
+ private readonly siteUrl;
2475
+ constructor(config?: MockProviderConfig);
2476
+ private hasVariant;
2477
+ getProduct(handle: string, options?: {
2478
+ regionId?: string;
2479
+ }): Promise<Product | undefined>;
2480
+ getProducts(options?: GetProductsOptions): Promise<Product[]>;
2481
+ getProductRecommendations(productId: string): Promise<Product[]>;
2482
+ getCollection(handle: string): Promise<Collection | undefined>;
2483
+ getCollections(options?: GetCollectionsOptions): Promise<Collection[]>;
2484
+ getCollectionProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
2485
+ getCategory(idOrHandle: string): Promise<ProductCategory | undefined>;
2486
+ getCategories(options?: GetCategoriesOptions): Promise<ProductCategory[]>;
2487
+ getCategoryProducts(handle: string, options?: CollectionProductsOptions): Promise<Product[]>;
2488
+ createCart(options?: {
2489
+ regionId?: string;
2490
+ }): Promise<Cart>;
2491
+ getCart(cartId: string): Promise<Cart | undefined>;
2492
+ addToCart(cartId: string, lines: CartLineInput[]): Promise<Cart>;
2493
+ removeFromCart(cartId: string, lineIds: string[]): Promise<Cart>;
2494
+ updateCart(cartId: string, lines: CartLineUpdate[]): Promise<Cart>;
2495
+ getRegions(): Promise<Array<{
2496
+ id: string;
2497
+ name: string;
2498
+ currency_code: string;
2499
+ countries?: Array<{
2500
+ id: string;
2501
+ iso_2: string;
2502
+ name: string;
2503
+ display_name?: string;
2504
+ }>;
2505
+ }>>;
2506
+ completeCheckout(cartId: string): Promise<Order>;
2507
+ getShippingMethods(cartId: string): Promise<ShippingMethod[]>;
2508
+ getRegionCountries(regionId: string): Promise<_thorprovider_types.Country[]>;
2509
+ addShippingMethod(cartId: string, methodId: string): Promise<Cart>;
2510
+ initiatePaymentSession(cartId: string, providerId: string): Promise<void>;
2511
+ applyDiscountCode(cartId: string, code: string): Promise<Cart>;
2512
+ removeDiscountCode(cartId: string, _code: string): Promise<Cart>;
2513
+ getOrders(_options: GetOrdersOptions): Promise<Order[]>;
2514
+ getPaymentMethods(options: PaymentMethodsOptions): Promise<PaymentMethod[]>;
2515
+ getStockLocations(): Promise<StockLocation[]>;
2516
+ checkInventoryLevels(variantId: string): Promise<InventoryLevel[]>;
2517
+ validateCartStock(cartId: string): Promise<StockValidation>;
2518
+ getFulfillmentOptions(cartId: string, _salesChannelId: string): Promise<FulfillmentOption[]>;
2519
+ cancelOrder(orderId: string): Promise<Order>;
2520
+ createFulfillment(_orderId: string, _items?: Array<{
2521
+ id: string;
2522
+ quantity: number;
2523
+ }>): Promise<void>;
2524
+ createRefund(orderId: string, _amount?: number, _reason?: string): Promise<void>;
2525
+ getAdminOrders(): Promise<{
2526
+ orders: Order[];
2527
+ count: number;
2528
+ }>;
2529
+ getAdminRegions(): Promise<Region[]>;
2530
+ getStorefrontContext(): Promise<StorefrontContext>;
2531
+ isStorefrontRequired(): boolean;
2532
+ }
2533
+
2456
2534
  /**
2457
2535
  * @thorprovider/adapters v2.0
2458
2536
  * Provider Factory - Create commerce providers dynamically
@@ -2474,6 +2552,9 @@ type ProviderType = ProviderTypeString;
2474
2552
  * Provider configuration discriminated union
2475
2553
  */
2476
2554
  type ProviderFactoryConfig = {
2555
+ provider: 'mock';
2556
+ config: MockProviderConfig;
2557
+ } | {
2477
2558
  provider: 'medusa';
2478
2559
  config: MedusaProviderConfig;
2479
2560
  } | {
@@ -2521,4 +2602,4 @@ declare function createProvider(options: ProviderFactoryConfig | RuntimeProvider
2521
2602
  */
2522
2603
  declare function isProviderType<T extends ProviderType>(provider: CommerceProvider, type: T): boolean;
2523
2604
 
2524
- 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, MagentoProvider, type MagentoProviderConfig, MedusaMetadataAdapter, MedusaProvider, type MedusaProviderConfig, type MetricsOrderInput, type MetricsProductInput, MetricsService, type PlanFulfillmentShippingAddress, ProviderAPIError, type ProviderFactoryConfig, ProviderNotFoundError, type ProviderType, ResourceNotFoundError, SHOPIFY_CAPABILITIES, SPREE_CAPABILITIES, ShopifyProvider, type ShopifyProviderConfig, SpreeProvider, type SpreeProviderConfig, 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 };
2605
+ 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, ShopifyProvider, type ShopifyProviderConfig, SpreeProvider, type SpreeProviderConfig, 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 };