@thorprovider/types 3.2.0 → 3.3.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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +294 -40
- package/dist/index.d.ts +294 -40
- package/dist/index.js +12 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
- package/src/admin/MultiTenantAdmin.ts +295 -0
- package/src/admin/index.ts +1 -0
- package/src/auth.ts +15 -28
- package/src/index.ts +36 -7
- package/src/provider.ts +11 -55
- package/src/storefront.ts +11 -9
- package/.turbo/turbo-build.log +0 -18
- package/dist/.tsbuildinfo +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
// src/provider.ts
|
|
2
|
-
var SupportedProviderType = /* @__PURE__ */ ((
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
SupportedProviderType3["WooCommerce"] = "woocommerce";
|
|
8
|
-
SupportedProviderType3["Spree"] = "spree";
|
|
9
|
-
SupportedProviderType3["Magento"] = "magento";
|
|
10
|
-
return SupportedProviderType3;
|
|
2
|
+
var SupportedProviderType = /* @__PURE__ */ ((SupportedProviderType2) => {
|
|
3
|
+
SupportedProviderType2["Mock"] = "mock";
|
|
4
|
+
SupportedProviderType2["Medusa"] = "medusa";
|
|
5
|
+
SupportedProviderType2["StelOrder"] = "stelorder";
|
|
6
|
+
return SupportedProviderType2;
|
|
11
7
|
})(SupportedProviderType || {});
|
|
12
8
|
var PROVIDER_METADATA = {
|
|
13
9
|
mock: {
|
|
@@ -28,56 +24,15 @@ var PROVIDER_METADATA = {
|
|
|
28
24
|
],
|
|
29
25
|
maxRetries: 3
|
|
30
26
|
},
|
|
31
|
-
|
|
32
|
-
name: "
|
|
33
|
-
description: "
|
|
27
|
+
stelorder: {
|
|
28
|
+
name: "Stel Order",
|
|
29
|
+
description: "Stel Order ERP and sales document API",
|
|
34
30
|
requiresStorefront: false,
|
|
35
31
|
requiredEnvVars: [
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
],
|
|
39
|
-
maxRetries: 3
|
|
40
|
-
},
|
|
41
|
-
bigcommerce: {
|
|
42
|
-
name: "BigCommerce",
|
|
43
|
-
description: "BigCommerce REST Storefront API",
|
|
44
|
-
requiresStorefront: false,
|
|
45
|
-
requiredEnvVars: [
|
|
46
|
-
"BIGCOMMERCE_STORE_HASH",
|
|
47
|
-
"BIGCOMMERCE_STOREFRONT_API_TOKEN",
|
|
48
|
-
"BIGCOMMERCE_CHANNEL_ID"
|
|
49
|
-
],
|
|
50
|
-
maxRetries: 3
|
|
51
|
-
},
|
|
52
|
-
woocommerce: {
|
|
53
|
-
name: "WooCommerce",
|
|
54
|
-
description: "WooCommerce Store API + REST API v3",
|
|
55
|
-
requiresStorefront: false,
|
|
56
|
-
requiredEnvVars: [
|
|
57
|
-
"WOOCOMMERCE_URL",
|
|
58
|
-
"WOOCOMMERCE_CONSUMER_KEY",
|
|
59
|
-
"WOOCOMMERCE_CONSUMER_SECRET"
|
|
60
|
-
],
|
|
61
|
-
maxRetries: 3
|
|
62
|
-
},
|
|
63
|
-
spree: {
|
|
64
|
-
name: "Spree Commerce",
|
|
65
|
-
description: "Spree API v2 Storefront (JSON:API)",
|
|
66
|
-
requiresStorefront: false,
|
|
67
|
-
requiredEnvVars: [
|
|
68
|
-
"SPREE_API_URL"
|
|
69
|
-
],
|
|
70
|
-
maxRetries: 3
|
|
71
|
-
},
|
|
72
|
-
magento: {
|
|
73
|
-
name: "Adobe Commerce (Magento)",
|
|
74
|
-
description: "Adobe Commerce GraphQL + REST API",
|
|
75
|
-
requiresStorefront: true,
|
|
76
|
-
requiredEnvVars: [
|
|
77
|
-
"MAGENTO_URL",
|
|
78
|
-
"MAGENTO_STORE_CODE"
|
|
32
|
+
"NEXT_PUBLIC_COMMERCE_API_URL",
|
|
33
|
+
"NEXT_PUBLIC_COMMERCE_API_KEY"
|
|
79
34
|
],
|
|
80
|
-
maxRetries:
|
|
35
|
+
maxRetries: 2
|
|
81
36
|
}
|
|
82
37
|
};
|
|
83
38
|
function isSupportedProviderType(value) {
|
|
@@ -105,17 +60,10 @@ var StorefrontConfigError = class extends Error {
|
|
|
105
60
|
this.requiredEnvVar = requiredEnvVar;
|
|
106
61
|
}
|
|
107
62
|
};
|
|
108
|
-
|
|
109
|
-
// src/index.ts
|
|
110
|
-
var SupportedProviderType2 = /* @__PURE__ */ ((SupportedProviderType3) => {
|
|
111
|
-
SupportedProviderType3["Mock"] = "mock";
|
|
112
|
-
SupportedProviderType3["Medusa"] = "medusa";
|
|
113
|
-
return SupportedProviderType3;
|
|
114
|
-
})(SupportedProviderType2 || {});
|
|
115
63
|
export {
|
|
116
64
|
PROVIDER_METADATA,
|
|
117
65
|
StorefrontConfigError,
|
|
118
|
-
|
|
66
|
+
SupportedProviderType,
|
|
119
67
|
getProviderMetadata,
|
|
120
68
|
isSupportedProviderType
|
|
121
69
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider.ts","../src/storefront.ts","../src/index.ts"],"sourcesContent":["/**\n * @thorprovider/types — Supported Providers\n *\n * Centralized list of all supported commerce providers.\n * This is the single source of truth for provider types across the monorepo.\n *\n * @remarks\n * - L1 (Foundation): Defines the contract\n * - L2 (@thorprovider/adapters) imports from here to build the factory\n * - L5 (Starters) uses the factory which is bound to this enum\n *\n * When adding a new provider (e.g., Shopify):\n * 1. Add to SupportedProviderType enum below\n * 2. Update @thorprovider/adapters factory/index.ts with discriminated union\n * 3. Create packages/adapters/src/providers/shopify/\n * 4. Implement CommerceProvider interface\n * 5. Update StorefrontPlatformType in storefront.ts (automatically synced)\n */\n\n/**\n * All supported commerce platform providers.\n * `mock` is the backend-optional runtime provider used for layout/design mode.\n * `medusa` is fully implemented for real backend usage; others are placeholders for future expansion.\n *\n * @remarks Implementation status:\n * - ✅ mock: Fixture-backed provider for backend-optional storefronts\n * - ✅ medusa: Fully implemented\n * - 🟡 shopify: Planned (Phase 2)\n * - 🟡 bigcommerce: Planned (Phase 2)\n * - 🟡 woocommerce: Planned (Phase 3)\n * - 🟡 spree: Planned (Phase 3)\n * - 🟡 magento: Planned (Phase 3)\n */\nexport enum SupportedProviderType {\n Mock = 'mock',\n Medusa = 'medusa',\n Shopify = 'shopify',\n BigCommerce = 'bigcommerce',\n WooCommerce = 'woocommerce',\n Spree = 'spree',\n Magento = 'magento',\n}\n\n/**\n * Union type of all supported provider string values.\n * Use this for type annotations when a provider type is expected.\n *\n * @example\n * ```typescript\n * function getProviderName(type: ProviderTypeString): string {\n * // type is 'medusa'\n * }\n * ```\n */\nexport type ProviderTypeString = 'mock' | 'medusa' | 'shopify' | 'bigcommerce' | 'woocommerce' | 'spree' | 'magento';\n\n/**\n * Metadata about each provider.\n * Useful for UI, error messages, validation, and documentation.\n *\n * @internal\n */\nexport const PROVIDER_METADATA: Record<\n ProviderTypeString,\n {\n name: string;\n description: string;\n requiresStorefront: boolean;\n requiredEnvVars: string[];\n maxRetries: number;\n }\n> = {\n mock: {\n name: 'Mock',\n description: 'Fixture-backed runtime provider for layout/design mode without a real backend',\n requiresStorefront: false,\n requiredEnvVars: [],\n maxRetries: 0,\n },\n medusa: {\n name: 'Medusa JS',\n description: 'Medusa v2 commerce engine',\n requiresStorefront: true,\n requiredEnvVars: [\n 'NEXT_PUBLIC_COMMERCE_API_URL',\n 'NEXT_PUBLIC_COMMERCE_API_KEY',\n 'NEXT_PUBLIC_SALES_CHANNEL_ID',\n ],\n maxRetries: 3,\n },\n shopify: {\n name: 'Shopify',\n description: 'Shopify Storefront API (GraphQL)',\n requiresStorefront: false,\n requiredEnvVars: [\n 'NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN',\n 'NEXT_PUBLIC_SHOPIFY_STOREFRONT_TOKEN',\n ],\n maxRetries: 3,\n },\n bigcommerce: {\n name: 'BigCommerce',\n description: 'BigCommerce REST Storefront API',\n requiresStorefront: false,\n requiredEnvVars: [\n 'BIGCOMMERCE_STORE_HASH',\n 'BIGCOMMERCE_STOREFRONT_API_TOKEN',\n 'BIGCOMMERCE_CHANNEL_ID',\n ],\n maxRetries: 3,\n },\n woocommerce: {\n name: 'WooCommerce',\n description: 'WooCommerce Store API + REST API v3',\n requiresStorefront: false,\n requiredEnvVars: [\n 'WOOCOMMERCE_URL',\n 'WOOCOMMERCE_CONSUMER_KEY',\n 'WOOCOMMERCE_CONSUMER_SECRET',\n ],\n maxRetries: 3,\n },\n spree: {\n name: 'Spree Commerce',\n description: 'Spree API v2 Storefront (JSON:API)',\n requiresStorefront: false,\n requiredEnvVars: [\n 'SPREE_API_URL',\n ],\n maxRetries: 3,\n },\n magento: {\n name: 'Adobe Commerce (Magento)',\n description: 'Adobe Commerce GraphQL + REST API',\n requiresStorefront: true,\n requiredEnvVars: [\n 'MAGENTO_URL',\n 'MAGENTO_STORE_CODE',\n ],\n maxRetries: 3,\n },\n};\n\n/**\n * Check if a string is a valid provider type.\n *\n * @example\n * ```typescript\n * if (isSupportedProviderType(process.env.COMMERCE_PROVIDER)) {\n * // type is narrowed to ProviderTypeString\n * }\n * ```\n */\nexport function isSupportedProviderType(\n value: unknown\n): value is ProviderTypeString {\n return (\n typeof value === 'string' &&\n Object.values(SupportedProviderType).includes(value as SupportedProviderType)\n );\n}\n\n/**\n * Get metadata for a provider type.\n * Useful for validation, error messages, and logging.\n *\n * @example\n * ```typescript\n * const meta = getProviderMetadata('medusa');\n * console.log(`Using ${meta.name} with max ${meta.maxRetries} retries`);\n * ```\n */\nexport function getProviderMetadata(\n type: ProviderTypeString\n): (typeof PROVIDER_METADATA)[ProviderTypeString] {\n if (!isSupportedProviderType(type)) {\n throw new Error(\n `Unsupported provider: ${type}. Supported: ${Object.values(\n SupportedProviderType\n ).join(', ')}`\n );\n }\n return PROVIDER_METADATA[type];\n}\n","/**\n * @thorprovider/types — Storefront Context\n *\n * Platform-agnostic representation of a \"sales channel\" or equivalent.\n * Abstracts differences between Medusa sales_channel, Shopify publications,\n * BigCommerce channels, WooCommerce sites, Spree stores, and Magento store views.\n *\n * @remarks\n * - Required for all multi-tenant deployments\n * - Returned by `CommerceProvider.getStorefrontContext()`\n * - MUST be validated on startup; errors should NOT be silently ignored\n */\n\n/**\n * Supported commerce platform types for storefront identification.\n *\n * @remarks\n * This type is automatically synced with SupportedProviderType from provider.ts.\n * When adding a new provider, update packages/types/src/provider.ts,\n * and this type will automatically reflect the new provider.\n *\n * Currently supported:\n * - ✅ 'mock': Backend-optional layout/design mode using fixture data\n * - ✅ 'medusa': Fully implemented\n *\n * Planned (not yet implemented):\n * - 🟡 'shopify': Phase 2\n * - 🟡 'bigcommerce': Phase 2\n * - 🟡 'woocommerce': Phase 3\n * - 🟡 'spree': Phase 3\n * - 🟡 'magento': Phase 3\n */\nexport type StorefrontPlatformType = 'mock' | 'medusa' | 'shopify' | 'bigcommerce' | 'woocommerce' | 'spree' | 'magento';\n\n/**\n * StorefrontContext\n *\n * Platform-agnostic representation of a \"sales channel\" or equivalent.\n *\n * @example\n * ```typescript\n * const ctx: StorefrontContext = {\n * id: 'sc_01J...',\n * name: 'B2C Storefront',\n * platformType: 'medusa',\n * requiresProductScoping: true,\n * currencyCode: 'USD',\n * };\n * ```\n */\nexport interface StorefrontContext {\n /**\n * Unique identifier for this storefront across the system.\n * Examples: \"sc_123\" (Medusa), \"gid://shopify/Channel/789\" (Shopify), \"1\" (WooCommerce)\n */\n id: string;\n\n /**\n * Human-readable name for logging and debugging.\n */\n name: string;\n\n /**\n * Platform this storefront belongs to.\n */\n platformType: StorefrontPlatformType;\n\n /**\n * Whether products must be explicitly linked/published to this storefront.\n *\n * @remarks\n * - Medusa: true (products must be linked to sales channel)\n * - Shopify: false (products visible by default unless unlisted)\n * - WooCommerce: false (no scoping concept)\n * - BigCommerce: false (products visible by default unless delisted)\n * - Spree: true (products must be assigned per store)\n * - Magento: true (products must be assigned per website)\n */\n requiresProductScoping: boolean;\n\n /**\n * Primary currency code for this storefront.\n * Examples: \"USD\", \"EUR\", \"GBP\"\n */\n currencyCode: string;\n\n /**\n * Optional region or locale code.\n * Examples: \"US\", \"EU\", \"en-US\", \"es-ES\"\n */\n locale?: string;\n\n /**\n * Optional: Store/Channel metadata from platform.\n * @internal\n */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Storefront validation error.\n * Thrown when storefront configuration is invalid or missing.\n *\n * @example\n * ```typescript\n * throw new StorefrontConfigError(\n * 'Medusa requires NEXT_PUBLIC_SALES_CHANNEL_ID',\n * 'medusa',\n * 'NEXT_PUBLIC_SALES_CHANNEL_ID',\n * );\n * ```\n */\nexport class StorefrontConfigError extends Error {\n public readonly platformType: string;\n public readonly requiredEnvVar?: string;\n\n constructor(\n message: string,\n platformType: string,\n requiredEnvVar?: string,\n ) {\n super(message);\n this.name = 'StorefrontConfigError';\n this.platformType = platformType;\n this.requiredEnvVar = requiredEnvVar;\n }\n}\n","/**\n * @thorprovider/types v1.0\n * Shared TypeScript types for Thor Commerce ecosystem\n * \n * Pure type definitions with zero runtime dependencies.\n * Foundation for type-safe commerce operations following SOLID principles.\n */\n\n// ============================================\n// Common Types\n// ============================================\nexport type {\n Money,\n Image,\n SEO,\n Connection,\n Edge,\n PaginationOptions,\n SortOptions,\n Country,\n} from './common';\n\nexport type {\n AuthorConfig,\n BrandConfig,\n ModulesConfig,\n NavigationItem,\n SiteConfig,\n SocialConfig,\n} from './site-config';\n\nexport type { SiteConfigLabels } from './site-config-labels';\n\n// ============================================\n// Product Types\n// ============================================\nexport type {\n Product,\n ProductOption,\n ProductVariant,\n SelectedOption,\n PriceRange,\n GetProductsOptions,\n ActiveFilter,\n SortOption,\n FilterSection,\n FilterOption,\n ProductPreview,\n Review,\n CompareProduct,\n AdminProductVariant,\n AdminProduct,\n AdvancedSearchProductsOptions,\n SearchResultMeta,\n FilterConfig,\n} from './product';\n\n// ============================================\n// Cart Types\n// ============================================\nexport type {\n Cart,\n CartItem,\n CartProduct,\n CartCost,\n CartLineInput,\n CartLineUpdate,\n ShippingMethod,\n DiscountCode,\n} from './cart';\n\n// ============================================\n// Inventory & Fulfillment Types\n// ============================================\nexport type {\n StockLocation,\n InventoryLevel,\n FulfillmentSet,\n FulfillmentOption,\n StockStatus,\n StockValidation,\n} from './stock-location';\n\n// ============================================\n// Collection Types\n// ============================================\nexport type {\n Collection,\n CollectionProductsOptions,\n GetCollectionsOptions,\n} from './collection';\n\n// ============================================\n// Category Types\n// ============================================\nexport type {\n ProductCategory,\n GetCategoriesOptions,\n GetCategoriesCallback,\n} from './category';\n\n// ============================================\n// Customer Types\n// ============================================\nexport type {\n Customer,\n Address,\n GetCustomersOptions,\n GetCustomersCallback,\n} from './customer';\n\n// ============================================\n// Region Types\n// ============================================\nexport type {\n Region,\n} from './region';\n\n// ============================================\n// Order Types\n// ============================================\nexport type {\n Order,\n OrderItem,\n OrderStatus,\n PaymentStatus,\n FulfillmentStatus,\n GetOrdersOptions,\n GetOrdersCallback,\n} from './order';\n\n// ============================================\n// Provider Types (L1 - Source of Truth)\n// ============================================\nexport enum SupportedProviderType {\n Mock = 'mock',\n Medusa = 'medusa',\n}\n\n// Re-export provider types directly\nexport { type ProviderTypeString } from './provider';\n\nexport {\n isSupportedProviderType,\n getProviderMetadata,\n PROVIDER_METADATA,\n} from './provider';\n\n// ============================================\n// Storefront Types\n// ============================================\nexport type {\n StorefrontContext,\n StorefrontPlatformType,\n} from './storefront';\n\nexport {\n StorefrontConfigError,\n} from './storefront';\n\n// ============================================\n// Storefront Configuration Types\n// ============================================\nexport type {\n StorefrontConfig,\n StorefrontSeoDefaults,\n} from './storefront-config';\n\n// ============================================\n// Designer Configuration Types\n// ============================================\nexport type {\n DesignerConfig,\n DesignerThemeConfig,\n DesignerThemePreset,\n DesignerNavItem,\n DesignerHistoryEntry,\n} from './designer-config';\n\n// ============================================\n// Auth Types\n// ============================================\nexport type {\n AuthProvider,\n AuthConfig,\n AuthMethod,\n AuthStorage,\n LoginCredentials,\n RegisterData,\n AuthResponse,\n UpdateCustomerData,\n CreateAddressData,\n PasswordResetRequest,\n PasswordResetConfirm,\n} from './auth';\n\n// ============================================\n// Payment Types\n// ============================================\nexport type {\n PaymentMethod,\n PaymentMethodType,\n PaymentMethodFeatures,\n PaymentMethodsOptions,\n CachedPaymentMethods,\n} from './payment';\n\n// ============================================\n// Commerce Provider Interface\n// ============================================\nexport type {\n CommerceProvider,\n BackendCapabilities,\n ProviderConfig,\n} from './commerce-provider';\n\n// ============================================\n// Admin Types\n// ============================================\nexport type {\n AdminUser,\n AuditLog,\n DashboardConfig,\n DashboardMetrics,\n SalesMetrics,\n OrdersMetrics,\n ProductsMetrics,\n ChartDataPoint,\n DashboardMetricsAdapter,\n DashboardOrdersAdapter,\n DashboardProductsAdapter,\n AuditLogAdapter,\n SiteConfigMetadata,\n ConfigHistoryEntry,\n} from './admin';\n\n// ============================================\n// Header Configuration Types\n// ============================================\nexport type {\n IconConfig,\n NavigationCalloutItem,\n NavigationLinkItem,\n DynamicSource,\n HeaderLinkItem,\n AccountMenuItem,\n AccountDropdownConfig,\n SearchBarConfig,\n HeaderNavigationConfig,\n} from './header-config';\n"],"mappings":";AAiCO,IAAK,wBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,YAAS;AACT,EAAAA,uBAAA,aAAU;AACV,EAAAA,uBAAA,iBAAc;AACd,EAAAA,uBAAA,iBAAc;AACd,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,aAAU;AAPA,SAAAA;AAAA,GAAA;AA6BL,IAAM,oBAST;AAAA,EACF,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB,CAAC;AAAA,IAClB,YAAY;AAAA,EACd;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EACA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EACA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EACA,OAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AACF;AAYO,SAAS,wBACd,OAC6B;AAC7B,SACE,OAAO,UAAU,YACjB,OAAO,OAAO,qBAAqB,EAAE,SAAS,KAA8B;AAEhF;AAYO,SAAS,oBACd,MACgD;AAChD,MAAI,CAAC,wBAAwB,IAAI,GAAG;AAClC,UAAM,IAAI;AAAA,MACR,yBAAyB,IAAI,gBAAgB,OAAO;AAAA,QAClD;AAAA,MACF,EAAE,KAAK,IAAI,CAAC;AAAA,IACd;AAAA,EACF;AACA,SAAO,kBAAkB,IAAI;AAC/B;;;ACvEO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC/B;AAAA,EACA;AAAA,EAEhB,YACE,SACA,cACA,gBACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,eAAe;AACpB,SAAK,iBAAiB;AAAA,EACxB;AACF;;;ACQO,IAAKC,yBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,YAAS;AAFC,SAAAA;AAAA,6BAAA;","names":["SupportedProviderType","SupportedProviderType"]}
|
|
1
|
+
{"version":3,"sources":["../src/provider.ts","../src/storefront.ts"],"sourcesContent":["/**\n * @thorprovider/types — Supported Providers\n *\n * Centralized list of all supported commerce providers.\n * This is the single source of truth for provider types across the monorepo.\n *\n * @remarks\n * - L1 (Foundation): Defines the contract\n * - L2 (@thorprovider/adapters) imports from here to build the factory\n * - L5 (Starters) uses the factory which is bound to this enum\n *\n * When adding a new provider (e.g., Stel Order):\n * 1. Add to SupportedProviderType enum below\n * 2. Update @thorprovider/adapters factory/index.ts with discriminated union\n * 3. Create packages/adapters/src/providers/shopify/\n * 4. Implement CommerceProvider interface\n * 5. Update StorefrontPlatformType in storefront.ts\n */\n\n/**\n * All supported commerce platform providers.\n * `mock` is the backend-optional runtime provider used for layout/design mode.\n * `medusa` is fully implemented for real backend usage; others are placeholders for future expansion.\n *\n * @remarks Implementation status:\n * - ✅ mock: Fixture-backed provider for backend-optional storefronts\n * - ✅ medusa: Fully implemented\n * - 🟡 stelorder: In progress (ERP adapter v1)\n * - 🟡 shopify: Planned (Phase 2)\n * - 🟡 bigcommerce: Planned (Phase 2)\n * - 🟡 woocommerce: Planned (Phase 3)\n * - 🟡 spree: Planned (Phase 3)\n * - 🟡 magento: Planned (Phase 3)\n */\nexport enum SupportedProviderType {\n Mock = 'mock',\n Medusa = 'medusa',\n StelOrder = 'stelorder',\n}\n\n/**\n * Union type of all supported provider string values.\n * Use this for type annotations when a provider type is expected.\n *\n * @example\n * ```typescript\n * function getProviderName(type: ProviderTypeString): string {\n * // type is 'medusa'\n * }\n * ```\n */\nexport type ProviderTypeString = 'mock' | 'medusa' | 'stelorder';\n\n/**\n * Metadata about each provider.\n * Useful for UI, error messages, validation, and documentation.\n *\n * @internal\n */\nexport const PROVIDER_METADATA: Record<\n ProviderTypeString,\n {\n name: string;\n description: string;\n requiresStorefront: boolean;\n requiredEnvVars: string[];\n maxRetries: number;\n }\n> = {\n mock: {\n name: 'Mock',\n description: 'Fixture-backed runtime provider for layout/design mode without a real backend',\n requiresStorefront: false,\n requiredEnvVars: [],\n maxRetries: 0,\n },\n medusa: {\n name: 'Medusa JS',\n description: 'Medusa v2 commerce engine',\n requiresStorefront: true,\n requiredEnvVars: [\n 'NEXT_PUBLIC_COMMERCE_API_URL',\n 'NEXT_PUBLIC_COMMERCE_API_KEY',\n 'NEXT_PUBLIC_SALES_CHANNEL_ID',\n ],\n maxRetries: 3,\n },\n stelorder: {\n name: 'Stel Order',\n description: 'Stel Order ERP and sales document API',\n requiresStorefront: false,\n requiredEnvVars: [\n 'NEXT_PUBLIC_COMMERCE_API_URL',\n 'NEXT_PUBLIC_COMMERCE_API_KEY',\n ],\n maxRetries: 2,\n },\n};\n\n/**\n * Check if a string is a valid provider type.\n *\n * @example\n * ```typescript\n * if (isSupportedProviderType(process.env.COMMERCE_PROVIDER)) {\n * // type is narrowed to ProviderTypeString\n * }\n * ```\n */\nexport function isSupportedProviderType(\n value: unknown\n): value is ProviderTypeString {\n return (\n typeof value === 'string' &&\n Object.values(SupportedProviderType).includes(value as SupportedProviderType)\n );\n}\n\n/**\n * Get metadata for a provider type.\n * Useful for validation, error messages, and logging.\n *\n * @example\n * ```typescript\n * const meta = getProviderMetadata('medusa');\n * console.log(`Using ${meta.name} with max ${meta.maxRetries} retries`);\n * ```\n */\nexport function getProviderMetadata(\n type: ProviderTypeString\n): (typeof PROVIDER_METADATA)[ProviderTypeString] {\n if (!isSupportedProviderType(type)) {\n throw new Error(\n `Unsupported provider: ${type}. Supported: ${Object.values(\n SupportedProviderType\n ).join(', ')}`\n );\n }\n return PROVIDER_METADATA[type];\n}\n","/**\n * @thorprovider/types — Storefront Context\n *\n * Platform-agnostic representation of a \"sales channel\" or equivalent.\n * Abstracts differences between Medusa sales_channel, Shopify publications,\n * BigCommerce channels, WooCommerce sites, Spree stores, and Magento store views.\n *\n * @remarks\n * - Required for all multi-tenant deployments\n * - Returned by `CommerceProvider.getStorefrontContext()`\n * - MUST be validated on startup; errors should NOT be silently ignored\n */\n\n/**\n * Supported commerce platform types for storefront identification.\n *\n * @remarks\n * Keep this type in sync with SupportedProviderType from provider.ts.\n * When adding a new provider, update both packages/types/src/provider.ts\n * and this type.\n *\n * Currently supported:\n * - ✅ 'mock': Backend-optional layout/design mode using fixture data\n * - ✅ 'medusa': Fully implemented\n * - 🟡 'stelorder': ERP adapter v1\n *\n * Planned (not yet implemented):\n * - 🟡 'shopify': Phase 2\n * - 🟡 'bigcommerce': Phase 2\n * - 🟡 'woocommerce': Phase 3\n * - 🟡 'spree': Phase 3\n * - 🟡 'magento': Phase 3\n */\nexport type StorefrontPlatformType = 'mock' | 'medusa' | 'stelorder' | 'shopify' | 'bigcommerce' | 'woocommerce' | 'spree' | 'magento';\n\n/**\n * StorefrontContext\n *\n * Platform-agnostic representation of a \"sales channel\" or equivalent.\n *\n * @example\n * ```typescript\n * const ctx: StorefrontContext = {\n * id: 'sc_01J...',\n * name: 'B2C Storefront',\n * platformType: 'medusa',\n * requiresProductScoping: true,\n * currencyCode: 'USD',\n * };\n * ```\n */\nexport interface StorefrontContext {\n /**\n * Unique identifier for this storefront across the system.\n * Examples: \"sc_123\" (Medusa), \"gid://shopify/Channel/789\" (Shopify), \"1\" (WooCommerce)\n */\n id: string;\n\n /**\n * Human-readable name for logging and debugging.\n */\n name: string;\n\n /**\n * Platform this storefront belongs to.\n */\n platformType: StorefrontPlatformType;\n\n /**\n * Whether products must be explicitly linked/published to this storefront.\n *\n * @remarks\n * - Medusa: true (products must be linked to sales channel)\n * - Shopify: false (products visible by default unless unlisted)\n * - Stel Order: false (single-company ERP model, no native channel scoping)\n * - WooCommerce: false (no scoping concept)\n * - BigCommerce: false (products visible by default unless delisted)\n * - Spree: true (products must be assigned per store)\n * - Magento: true (products must be assigned per website)\n */\n requiresProductScoping: boolean;\n\n /**\n * Primary currency code for this storefront.\n * Examples: \"USD\", \"EUR\", \"GBP\"\n */\n currencyCode: string;\n\n /**\n * Optional region or locale code.\n * Examples: \"US\", \"EU\", \"en-US\", \"es-ES\"\n */\n locale?: string;\n\n /**\n * Optional: Store/Channel metadata from platform.\n * @internal\n */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Storefront validation error.\n * Thrown when storefront configuration is invalid or missing.\n *\n * @example\n * ```typescript\n * throw new StorefrontConfigError(\n * 'Medusa requires NEXT_PUBLIC_SALES_CHANNEL_ID',\n * 'medusa',\n * 'NEXT_PUBLIC_SALES_CHANNEL_ID',\n * );\n * ```\n */\nexport class StorefrontConfigError extends Error {\n public readonly platformType: string;\n public readonly requiredEnvVar?: string;\n\n constructor(\n message: string,\n platformType: string,\n requiredEnvVar?: string,\n ) {\n super(message);\n this.name = 'StorefrontConfigError';\n this.platformType = platformType;\n this.requiredEnvVar = requiredEnvVar;\n }\n}\n"],"mappings":";AAkCO,IAAK,wBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,YAAS;AACT,EAAAA,uBAAA,eAAY;AAHF,SAAAA;AAAA,GAAA;AAyBL,IAAM,oBAST;AAAA,EACF,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB,CAAC;AAAA,IAClB,YAAY;AAAA,EACd;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AAAA,EACA,WAAW;AAAA,IACT,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,MACf;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AACF;AAYO,SAAS,wBACd,OAC6B;AAC7B,SACE,OAAO,UAAU,YACjB,OAAO,OAAO,qBAAqB,EAAE,SAAS,KAA8B;AAEhF;AAYO,SAAS,oBACd,MACgD;AAChD,MAAI,CAAC,wBAAwB,IAAI,GAAG;AAClC,UAAM,IAAI;AAAA,MACR,yBAAyB,IAAI,gBAAgB,OAAO;AAAA,QAClD;AAAA,MACF,EAAE,KAAK,IAAI,CAAC;AAAA,IACd;AAAA,EACF;AACA,SAAO,kBAAkB,IAAI;AAC/B;;;ACzBO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC/B;AAAA,EACA;AAAA,EAEhB,YACE,SACA,cACA,gBACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,eAAe;AACpB,SAAK,iBAAiB;AAAA,EACxB;AACF;","names":["SupportedProviderType"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thorprovider/types",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Shared TypeScript types for Thor Commerce ecosystem - Framework-agnostic type definitions",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
|
-
"development": "./
|
|
21
|
-
"import": "./dist/index.
|
|
22
|
-
"require": "./dist/index.js"
|
|
20
|
+
"development": "./dist/index.mjs",
|
|
21
|
+
"import": "./dist/index.mjs",
|
|
22
|
+
"require": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.mjs"
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @thorprovider/types — Multi-Tenant Admin Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for admin operations on the Thor Commerce multi-tenant
|
|
5
|
+
* backend plugin (`/admin/thor/`).
|
|
6
|
+
*
|
|
7
|
+
* These types map 1:1 to the API contract defined in
|
|
8
|
+
* `multitenant-api-contract.md`.
|
|
9
|
+
*
|
|
10
|
+
* @module admin/MultiTenantAdmin
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// ============================================================
|
|
14
|
+
// Sales Channel — Customers
|
|
15
|
+
// ============================================================
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A customer entry as returned by the admin multi-tenant API.
|
|
19
|
+
*/
|
|
20
|
+
export interface AdminChannelCustomer {
|
|
21
|
+
id: string;
|
|
22
|
+
email: string;
|
|
23
|
+
first_name: string | null;
|
|
24
|
+
last_name: string | null;
|
|
25
|
+
phone: string | null;
|
|
26
|
+
created_at: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Response for `GET /admin/thor/sales-channels/:id/customers` */
|
|
30
|
+
export interface GetChannelCustomersResponse {
|
|
31
|
+
customers: AdminChannelCustomer[];
|
|
32
|
+
count: number;
|
|
33
|
+
limit: number;
|
|
34
|
+
offset: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Options for paginating channel customers */
|
|
38
|
+
export interface GetChannelCustomersOptions {
|
|
39
|
+
/** Max customers to return (default 20, max 100) */
|
|
40
|
+
limit?: number;
|
|
41
|
+
/** Pagination offset (default 0) */
|
|
42
|
+
offset?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ============================================================
|
|
46
|
+
// Sales Channel — API Keys
|
|
47
|
+
// ============================================================
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A publishable API key entry as returned by the admin multi-tenant API.
|
|
51
|
+
*/
|
|
52
|
+
export interface AdminApiKey {
|
|
53
|
+
id: string;
|
|
54
|
+
title: string;
|
|
55
|
+
token: string;
|
|
56
|
+
type: 'publishable' | string;
|
|
57
|
+
created_at: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Response for `GET /admin/thor/sales-channels/:id/api-keys` */
|
|
61
|
+
export interface GetChannelApiKeysResponse {
|
|
62
|
+
api_keys: AdminApiKey[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ============================================================
|
|
66
|
+
// Sales Channel — Categories
|
|
67
|
+
// ============================================================
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A product category entry as returned by admin channel category endpoints.
|
|
71
|
+
*/
|
|
72
|
+
export interface AdminChannelCategory {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
handle: string;
|
|
76
|
+
description: string | null;
|
|
77
|
+
parent_category_id: string | null;
|
|
78
|
+
rank: number;
|
|
79
|
+
metadata: Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Response for `GET /admin/thor/sales-channels/:id/categories` */
|
|
83
|
+
export interface GetChannelCategoriesResponse {
|
|
84
|
+
categories: AdminChannelCategory[];
|
|
85
|
+
count: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Options for listing channel categories */
|
|
89
|
+
export interface GetChannelCategoriesOptions {
|
|
90
|
+
/** Max categories per page (default 20, max 100) */
|
|
91
|
+
limit?: number;
|
|
92
|
+
/** Pagination offset (default 0) */
|
|
93
|
+
offset?: number;
|
|
94
|
+
/** Expand child categories in nested tree */
|
|
95
|
+
include_descendants?: boolean;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A slim sales channel reference returned when listing channels for a resource.
|
|
100
|
+
*/
|
|
101
|
+
export interface AdminSalesChannelRef {
|
|
102
|
+
id: string;
|
|
103
|
+
name: string;
|
|
104
|
+
description?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Response for `GET /admin/thor/categories/:id/sales-channels` */
|
|
108
|
+
export interface GetCategorySalesChannelsResponse {
|
|
109
|
+
sales_channels: AdminSalesChannelRef[];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Body for `POST /admin/thor/categories/:id/sales-channels` */
|
|
113
|
+
export interface AssignCategoriesToChannelsBody {
|
|
114
|
+
sales_channel_ids: string[];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Response for `POST /admin/thor/categories/:id/sales-channels` */
|
|
118
|
+
export interface AssignCategoriesToChannelsResponse {
|
|
119
|
+
message: string;
|
|
120
|
+
linked: number;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Body for `DELETE /admin/thor/categories/:id/sales-channels` */
|
|
124
|
+
export interface UnassignCategoriesFromChannelsBody {
|
|
125
|
+
sales_channel_ids: string[];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Response for `DELETE /admin/thor/categories/:id/sales-channels` */
|
|
129
|
+
export interface UnassignCategoriesFromChannelsResponse {
|
|
130
|
+
message: string;
|
|
131
|
+
dismissed: number;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ============================================================
|
|
135
|
+
// Collections — Channel Mapping
|
|
136
|
+
// ============================================================
|
|
137
|
+
|
|
138
|
+
/** Response for `GET /admin/thor/collections/:id/sales-channels` */
|
|
139
|
+
export interface GetCollectionSalesChannelsResponse {
|
|
140
|
+
sales_channels: AdminSalesChannelRef[];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Body for `POST /admin/thor/collections/:id/sales-channels` */
|
|
144
|
+
export interface AssignCollectionsToChannelsBody {
|
|
145
|
+
sales_channel_ids: string[];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Response for `POST /admin/thor/collections/:id/sales-channels` */
|
|
149
|
+
export interface AssignCollectionsToChannelsResponse {
|
|
150
|
+
message: string;
|
|
151
|
+
linked: number;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Body for `DELETE /admin/thor/collections/:id/sales-channels` */
|
|
155
|
+
export interface UnassignCollectionsFromChannelsBody {
|
|
156
|
+
sales_channel_ids: string[];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Response for `DELETE /admin/thor/collections/:id/sales-channels` */
|
|
160
|
+
export interface UnassignCollectionsFromChannelsResponse {
|
|
161
|
+
message: string;
|
|
162
|
+
dismissed: number;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// ============================================================
|
|
166
|
+
// Storefront Config (Admin CRUD)
|
|
167
|
+
// ============================================================
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* SEO defaults as stored in the storefront config.
|
|
171
|
+
*/
|
|
172
|
+
export interface AdminStorefrontSeoDefaults {
|
|
173
|
+
title: string;
|
|
174
|
+
description: string;
|
|
175
|
+
ogImage?: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Full storefront config record as returned by admin endpoints.
|
|
180
|
+
* Uses snake_case to match the API contract response shape exactly.
|
|
181
|
+
*/
|
|
182
|
+
export interface AdminStorefrontConfig {
|
|
183
|
+
id: string;
|
|
184
|
+
sales_channel_id: string;
|
|
185
|
+
theme_accent_color: string;
|
|
186
|
+
logo_url: string;
|
|
187
|
+
currency_code: string;
|
|
188
|
+
seo_defaults: AdminStorefrontSeoDefaults;
|
|
189
|
+
frontend_webhook_url?: string;
|
|
190
|
+
created_at: string;
|
|
191
|
+
updated_at: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Response for `GET /admin/thor/storefront-config/:id` */
|
|
195
|
+
export interface GetAdminStorefrontConfigResponse {
|
|
196
|
+
storefront_config: AdminStorefrontConfig;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Body for `PUT /admin/thor/storefront-config/:id` */
|
|
200
|
+
export interface UpdateStorefrontConfigBody {
|
|
201
|
+
theme_accent_color: string;
|
|
202
|
+
logo_url: string;
|
|
203
|
+
currency_code: string;
|
|
204
|
+
seo_defaults: {
|
|
205
|
+
title: string;
|
|
206
|
+
description: string;
|
|
207
|
+
ogImage?: string;
|
|
208
|
+
};
|
|
209
|
+
frontend_webhook_url?: string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Response for `PUT /admin/thor/storefront-config/:id` */
|
|
213
|
+
export interface UpdateStorefrontConfigResponse {
|
|
214
|
+
storefront_config: AdminStorefrontConfig;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ============================================================
|
|
218
|
+
// Site Designer Config (Admin CRUD + History + Restore)
|
|
219
|
+
// ============================================================
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* A single history entry for the Site Designer config.
|
|
223
|
+
*/
|
|
224
|
+
export interface AdminSiteConfigHistoryEntry {
|
|
225
|
+
id?: string;
|
|
226
|
+
version: string;
|
|
227
|
+
createdAt: string;
|
|
228
|
+
createdBy?: string;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Full site config record as returned by admin endpoints.
|
|
233
|
+
* `config` is the free-form `DesignerConfig` JSON object.
|
|
234
|
+
*/
|
|
235
|
+
export interface AdminSiteConfig {
|
|
236
|
+
id: string;
|
|
237
|
+
sales_channel_id: string;
|
|
238
|
+
version: string;
|
|
239
|
+
/** Free-form DesignerConfig object managed by the Site Designer */
|
|
240
|
+
config: Record<string, unknown>;
|
|
241
|
+
history?: AdminSiteConfigHistoryEntry[];
|
|
242
|
+
created_at?: string;
|
|
243
|
+
updated_at?: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Response for `GET /admin/thor/site-config/:sales_channel_id` */
|
|
247
|
+
export interface GetAdminSiteConfigResponse {
|
|
248
|
+
site_config: AdminSiteConfig;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Body for `PUT /admin/thor/site-config/:sales_channel_id` */
|
|
252
|
+
export type UpdateSiteConfigBody = Record<string, unknown>;
|
|
253
|
+
|
|
254
|
+
/** Response for `PUT /admin/thor/site-config/:sales_channel_id` */
|
|
255
|
+
export interface UpdateSiteConfigResponse {
|
|
256
|
+
site_config: AdminSiteConfig;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* A full history entry including the stored config snapshot.
|
|
261
|
+
*/
|
|
262
|
+
export interface AdminSiteConfigHistoryEntryFull {
|
|
263
|
+
id: string;
|
|
264
|
+
version: string;
|
|
265
|
+
config: Record<string, unknown>;
|
|
266
|
+
createdAt: string;
|
|
267
|
+
createdBy?: string;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** Response for `GET /admin/thor/site-config/:sales_channel_id/history` */
|
|
271
|
+
export interface GetAdminSiteConfigHistoryResponse {
|
|
272
|
+
history: AdminSiteConfigHistoryEntryFull[];
|
|
273
|
+
count: number;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** Options for paginating site config history */
|
|
277
|
+
export interface GetAdminSiteConfigHistoryOptions {
|
|
278
|
+
limit?: number;
|
|
279
|
+
offset?: number;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** Response for `POST /admin/thor/site-config/:sales_channel_id/restore/:version` */
|
|
283
|
+
export interface RestoreSiteConfigResponse {
|
|
284
|
+
site_config: AdminSiteConfig;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// ============================================================
|
|
288
|
+
// Channel Link — Store endpoints
|
|
289
|
+
// ============================================================
|
|
290
|
+
|
|
291
|
+
/** Response for `POST /store/thor/customers/me/channels` */
|
|
292
|
+
export interface LinkCustomerToChannelResponse {
|
|
293
|
+
linked: boolean;
|
|
294
|
+
reason?: 'already_linked';
|
|
295
|
+
}
|
package/src/admin/index.ts
CHANGED
package/src/auth.ts
CHANGED
|
@@ -233,35 +233,22 @@ export interface AuthProvider {
|
|
|
233
233
|
* Only implemented if capabilities.deleteAccount is true.
|
|
234
234
|
*/
|
|
235
235
|
deleteCustomerAccount(): Promise<void>;
|
|
236
|
-
|
|
236
|
+
|
|
237
237
|
// ========================================
|
|
238
|
-
//
|
|
238
|
+
// Multi-Tenant — Channel Link
|
|
239
239
|
// ========================================
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Get customer addresses
|
|
243
|
-
* @returns List of customer addresses
|
|
244
|
-
*/
|
|
245
|
-
getAddresses(): Promise<Address[]>;
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Create new address for current customer
|
|
249
|
-
* @param data - Address data
|
|
250
|
-
* @returns Created address
|
|
251
|
-
*/
|
|
252
|
-
createAddress(data: CreateAddressData): Promise<Address>;
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Update customer address
|
|
256
|
-
* @param addressId - Address ID
|
|
257
|
-
* @param data - Fields to update
|
|
258
|
-
* @returns Updated address
|
|
259
|
-
*/
|
|
260
|
-
updateAddress(addressId: string, data: Partial<CreateAddressData>): Promise<Address>;
|
|
261
|
-
|
|
240
|
+
|
|
262
241
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
|
|
266
|
-
|
|
242
|
+
* Link the currently authenticated customer to the storefront's sales channel.
|
|
243
|
+
*
|
|
244
|
+
* Call immediately after a successful `login()` so the customer appears in the
|
|
245
|
+
* correct channel on the admin panel. Idempotent — repeated calls return
|
|
246
|
+
* `{ linked: false, reason: 'already_linked' }`.
|
|
247
|
+
*
|
|
248
|
+
* Implements `POST /store/thor/customers/me/channels`.
|
|
249
|
+
*
|
|
250
|
+
* @returns `{ linked: true }` when the link was created, or
|
|
251
|
+
* `{ linked: false, reason: 'already_linked' }` when it already existed.
|
|
252
|
+
*/
|
|
253
|
+
linkCustomerToChannel(): Promise<{ linked: boolean; reason?: string }>;
|
|
267
254
|
}
|
package/src/index.ts
CHANGED
|
@@ -132,13 +132,7 @@ export type {
|
|
|
132
132
|
// ============================================
|
|
133
133
|
// Provider Types (L1 - Source of Truth)
|
|
134
134
|
// ============================================
|
|
135
|
-
export
|
|
136
|
-
Mock = 'mock',
|
|
137
|
-
Medusa = 'medusa',
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Re-export provider types directly
|
|
141
|
-
export { type ProviderTypeString } from './provider';
|
|
135
|
+
export { SupportedProviderType, type ProviderTypeString } from './provider';
|
|
142
136
|
|
|
143
137
|
export {
|
|
144
138
|
isSupportedProviderType,
|
|
@@ -232,6 +226,41 @@ export type {
|
|
|
232
226
|
AuditLogAdapter,
|
|
233
227
|
SiteConfigMetadata,
|
|
234
228
|
ConfigHistoryEntry,
|
|
229
|
+
// Multi-tenant admin types
|
|
230
|
+
AdminChannelCustomer,
|
|
231
|
+
GetChannelCustomersResponse,
|
|
232
|
+
GetChannelCustomersOptions,
|
|
233
|
+
AdminApiKey,
|
|
234
|
+
GetChannelApiKeysResponse,
|
|
235
|
+
AdminChannelCategory,
|
|
236
|
+
GetChannelCategoriesResponse,
|
|
237
|
+
GetChannelCategoriesOptions,
|
|
238
|
+
AdminSalesChannelRef,
|
|
239
|
+
GetCategorySalesChannelsResponse,
|
|
240
|
+
AssignCategoriesToChannelsBody,
|
|
241
|
+
AssignCategoriesToChannelsResponse,
|
|
242
|
+
UnassignCategoriesFromChannelsBody,
|
|
243
|
+
UnassignCategoriesFromChannelsResponse,
|
|
244
|
+
GetCollectionSalesChannelsResponse,
|
|
245
|
+
AssignCollectionsToChannelsBody,
|
|
246
|
+
AssignCollectionsToChannelsResponse,
|
|
247
|
+
UnassignCollectionsFromChannelsBody,
|
|
248
|
+
UnassignCollectionsFromChannelsResponse,
|
|
249
|
+
AdminStorefrontSeoDefaults,
|
|
250
|
+
AdminStorefrontConfig,
|
|
251
|
+
GetAdminStorefrontConfigResponse,
|
|
252
|
+
UpdateStorefrontConfigBody,
|
|
253
|
+
UpdateStorefrontConfigResponse,
|
|
254
|
+
AdminSiteConfigHistoryEntry,
|
|
255
|
+
AdminSiteConfig,
|
|
256
|
+
GetAdminSiteConfigResponse,
|
|
257
|
+
UpdateSiteConfigBody,
|
|
258
|
+
UpdateSiteConfigResponse,
|
|
259
|
+
AdminSiteConfigHistoryEntryFull,
|
|
260
|
+
GetAdminSiteConfigHistoryResponse,
|
|
261
|
+
GetAdminSiteConfigHistoryOptions,
|
|
262
|
+
RestoreSiteConfigResponse,
|
|
263
|
+
LinkCustomerToChannelResponse,
|
|
235
264
|
} from './admin';
|
|
236
265
|
|
|
237
266
|
// ============================================
|