@thorprovider/types 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ PROVIDER_METADATA: () => PROVIDER_METADATA,
24
+ StorefrontConfigError: () => StorefrontConfigError,
25
+ SupportedProviderType: () => SupportedProviderType2,
26
+ getProviderMetadata: () => getProviderMetadata,
27
+ isSupportedProviderType: () => isSupportedProviderType
28
+ });
29
+ module.exports = __toCommonJS(src_exports);
30
+
31
+ // src/provider.ts
32
+ var SupportedProviderType = /* @__PURE__ */ ((SupportedProviderType3) => {
33
+ SupportedProviderType3["Medusa"] = "medusa";
34
+ SupportedProviderType3["Shopify"] = "shopify";
35
+ SupportedProviderType3["BigCommerce"] = "bigcommerce";
36
+ SupportedProviderType3["WooCommerce"] = "woocommerce";
37
+ SupportedProviderType3["Spree"] = "spree";
38
+ SupportedProviderType3["Magento"] = "magento";
39
+ return SupportedProviderType3;
40
+ })(SupportedProviderType || {});
41
+ var PROVIDER_METADATA = {
42
+ medusa: {
43
+ name: "Medusa JS",
44
+ description: "Medusa v2 commerce engine",
45
+ requiresStorefront: true,
46
+ requiredEnvVars: [
47
+ "NEXT_PUBLIC_COMMERCE_API_URL",
48
+ "NEXT_PUBLIC_COMMERCE_API_KEY",
49
+ "NEXT_PUBLIC_SALES_CHANNEL_ID"
50
+ ],
51
+ maxRetries: 3
52
+ },
53
+ shopify: {
54
+ name: "Shopify",
55
+ description: "Shopify Storefront API (GraphQL)",
56
+ requiresStorefront: false,
57
+ requiredEnvVars: [
58
+ "NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN",
59
+ "NEXT_PUBLIC_SHOPIFY_STOREFRONT_TOKEN"
60
+ ],
61
+ maxRetries: 3
62
+ },
63
+ bigcommerce: {
64
+ name: "BigCommerce",
65
+ description: "BigCommerce REST Storefront API",
66
+ requiresStorefront: false,
67
+ requiredEnvVars: [
68
+ "BIGCOMMERCE_STORE_HASH",
69
+ "BIGCOMMERCE_STOREFRONT_API_TOKEN",
70
+ "BIGCOMMERCE_CHANNEL_ID"
71
+ ],
72
+ maxRetries: 3
73
+ },
74
+ woocommerce: {
75
+ name: "WooCommerce",
76
+ description: "WooCommerce Store API + REST API v3",
77
+ requiresStorefront: false,
78
+ requiredEnvVars: [
79
+ "WOOCOMMERCE_URL",
80
+ "WOOCOMMERCE_CONSUMER_KEY",
81
+ "WOOCOMMERCE_CONSUMER_SECRET"
82
+ ],
83
+ maxRetries: 3
84
+ },
85
+ spree: {
86
+ name: "Spree Commerce",
87
+ description: "Spree API v2 Storefront (JSON:API)",
88
+ requiresStorefront: false,
89
+ requiredEnvVars: [
90
+ "SPREE_API_URL"
91
+ ],
92
+ maxRetries: 3
93
+ },
94
+ magento: {
95
+ name: "Adobe Commerce (Magento)",
96
+ description: "Adobe Commerce GraphQL + REST API",
97
+ requiresStorefront: true,
98
+ requiredEnvVars: [
99
+ "MAGENTO_URL",
100
+ "MAGENTO_STORE_CODE"
101
+ ],
102
+ maxRetries: 3
103
+ }
104
+ };
105
+ function isSupportedProviderType(value) {
106
+ return typeof value === "string" && Object.values(SupportedProviderType).includes(value);
107
+ }
108
+ function getProviderMetadata(type) {
109
+ if (!isSupportedProviderType(type)) {
110
+ throw new Error(
111
+ `Unsupported provider: ${type}. Supported: ${Object.values(
112
+ SupportedProviderType
113
+ ).join(", ")}`
114
+ );
115
+ }
116
+ return PROVIDER_METADATA[type];
117
+ }
118
+
119
+ // src/storefront.ts
120
+ var StorefrontConfigError = class extends Error {
121
+ platformType;
122
+ requiredEnvVar;
123
+ constructor(message, platformType, requiredEnvVar) {
124
+ super(message);
125
+ this.name = "StorefrontConfigError";
126
+ this.platformType = platformType;
127
+ this.requiredEnvVar = requiredEnvVar;
128
+ }
129
+ };
130
+
131
+ // src/index.ts
132
+ var SupportedProviderType2 = /* @__PURE__ */ ((SupportedProviderType3) => {
133
+ SupportedProviderType3["Medusa"] = "medusa";
134
+ return SupportedProviderType3;
135
+ })(SupportedProviderType2 || {});
136
+ // Annotate the CommonJS export names for ESM import in node:
137
+ 0 && (module.exports = {
138
+ PROVIDER_METADATA,
139
+ StorefrontConfigError,
140
+ SupportedProviderType,
141
+ getProviderMetadata,
142
+ isSupportedProviderType
143
+ });
144
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/provider.ts","../src/storefront.ts"],"sourcesContent":["/**\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 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","/**\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 * Currently only 'medusa' is implemented; others are placeholders for future expansion.\n *\n * @remarks Implementation status:\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 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 = '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 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 * - ✅ '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 = '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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;;;AC+BO,IAAK,wBAAL,kBAAKC,2BAAL;AACL,EAAAA,uBAAA,YAAS;AACT,EAAAA,uBAAA,aAAU;AACV,EAAAA,uBAAA,iBAAc;AACd,EAAAA,uBAAA,iBAAc;AACd,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,aAAU;AANA,SAAAA;AAAA,GAAA;AA4BL,IAAM,oBAST;AAAA,EACF,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;;;AC9DO,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;;;AFSO,IAAKC,yBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,YAAS;AADC,SAAAA;AAAA,6BAAA;","names":["SupportedProviderType","SupportedProviderType","SupportedProviderType"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,113 @@
1
+ // src/provider.ts
2
+ var SupportedProviderType = /* @__PURE__ */ ((SupportedProviderType3) => {
3
+ SupportedProviderType3["Medusa"] = "medusa";
4
+ SupportedProviderType3["Shopify"] = "shopify";
5
+ SupportedProviderType3["BigCommerce"] = "bigcommerce";
6
+ SupportedProviderType3["WooCommerce"] = "woocommerce";
7
+ SupportedProviderType3["Spree"] = "spree";
8
+ SupportedProviderType3["Magento"] = "magento";
9
+ return SupportedProviderType3;
10
+ })(SupportedProviderType || {});
11
+ var PROVIDER_METADATA = {
12
+ medusa: {
13
+ name: "Medusa JS",
14
+ description: "Medusa v2 commerce engine",
15
+ requiresStorefront: true,
16
+ requiredEnvVars: [
17
+ "NEXT_PUBLIC_COMMERCE_API_URL",
18
+ "NEXT_PUBLIC_COMMERCE_API_KEY",
19
+ "NEXT_PUBLIC_SALES_CHANNEL_ID"
20
+ ],
21
+ maxRetries: 3
22
+ },
23
+ shopify: {
24
+ name: "Shopify",
25
+ description: "Shopify Storefront API (GraphQL)",
26
+ requiresStorefront: false,
27
+ requiredEnvVars: [
28
+ "NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN",
29
+ "NEXT_PUBLIC_SHOPIFY_STOREFRONT_TOKEN"
30
+ ],
31
+ maxRetries: 3
32
+ },
33
+ bigcommerce: {
34
+ name: "BigCommerce",
35
+ description: "BigCommerce REST Storefront API",
36
+ requiresStorefront: false,
37
+ requiredEnvVars: [
38
+ "BIGCOMMERCE_STORE_HASH",
39
+ "BIGCOMMERCE_STOREFRONT_API_TOKEN",
40
+ "BIGCOMMERCE_CHANNEL_ID"
41
+ ],
42
+ maxRetries: 3
43
+ },
44
+ woocommerce: {
45
+ name: "WooCommerce",
46
+ description: "WooCommerce Store API + REST API v3",
47
+ requiresStorefront: false,
48
+ requiredEnvVars: [
49
+ "WOOCOMMERCE_URL",
50
+ "WOOCOMMERCE_CONSUMER_KEY",
51
+ "WOOCOMMERCE_CONSUMER_SECRET"
52
+ ],
53
+ maxRetries: 3
54
+ },
55
+ spree: {
56
+ name: "Spree Commerce",
57
+ description: "Spree API v2 Storefront (JSON:API)",
58
+ requiresStorefront: false,
59
+ requiredEnvVars: [
60
+ "SPREE_API_URL"
61
+ ],
62
+ maxRetries: 3
63
+ },
64
+ magento: {
65
+ name: "Adobe Commerce (Magento)",
66
+ description: "Adobe Commerce GraphQL + REST API",
67
+ requiresStorefront: true,
68
+ requiredEnvVars: [
69
+ "MAGENTO_URL",
70
+ "MAGENTO_STORE_CODE"
71
+ ],
72
+ maxRetries: 3
73
+ }
74
+ };
75
+ function isSupportedProviderType(value) {
76
+ return typeof value === "string" && Object.values(SupportedProviderType).includes(value);
77
+ }
78
+ function getProviderMetadata(type) {
79
+ if (!isSupportedProviderType(type)) {
80
+ throw new Error(
81
+ `Unsupported provider: ${type}. Supported: ${Object.values(
82
+ SupportedProviderType
83
+ ).join(", ")}`
84
+ );
85
+ }
86
+ return PROVIDER_METADATA[type];
87
+ }
88
+
89
+ // src/storefront.ts
90
+ var StorefrontConfigError = class extends Error {
91
+ platformType;
92
+ requiredEnvVar;
93
+ constructor(message, platformType, requiredEnvVar) {
94
+ super(message);
95
+ this.name = "StorefrontConfigError";
96
+ this.platformType = platformType;
97
+ this.requiredEnvVar = requiredEnvVar;
98
+ }
99
+ };
100
+
101
+ // src/index.ts
102
+ var SupportedProviderType2 = /* @__PURE__ */ ((SupportedProviderType3) => {
103
+ SupportedProviderType3["Medusa"] = "medusa";
104
+ return SupportedProviderType3;
105
+ })(SupportedProviderType2 || {});
106
+ export {
107
+ PROVIDER_METADATA,
108
+ StorefrontConfigError,
109
+ SupportedProviderType2 as SupportedProviderType,
110
+ getProviderMetadata,
111
+ isSupportedProviderType
112
+ };
113
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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 * Currently only 'medusa' is implemented; others are placeholders for future expansion.\n *\n * @remarks Implementation status:\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 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 = '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 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 * - ✅ '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 = '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 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":";AA+BO,IAAK,wBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,YAAS;AACT,EAAAA,uBAAA,aAAU;AACV,EAAAA,uBAAA,iBAAc;AACd,EAAAA,uBAAA,iBAAc;AACd,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,aAAU;AANA,SAAAA;AAAA,GAAA;AA4BL,IAAM,oBAST;AAAA,EACF,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;;;AC9DO,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;;;ACSO,IAAKC,yBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,YAAS;AADC,SAAAA;AAAA,6BAAA;","names":["SupportedProviderType","SupportedProviderType"]}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@thorprovider/types",
3
+ "version": "2.0.2",
4
+ "description": "Shared TypeScript types for Thor Commerce ecosystem - Framework-agnostic type definitions",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org",
9
+ "access": "restricted"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/thorprovider/thor-commerce",
14
+ "directory": "packages/types"
15
+ },
16
+ "license": "MIT",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "development": "./src/index.ts",
21
+ "import": "./dist/index.js",
22
+ "require": "./dist/index.js"
23
+ }
24
+ },
25
+ "scripts": {
26
+ "build": "tsup",
27
+ "dev": "tsup --watch",
28
+ "type-check": "tsc --noEmit"
29
+ },
30
+ "devDependencies": {
31
+ "tsup": "^8.0.0",
32
+ "typescript": "^5.0.0"
33
+ }
34
+ }
package/publish.log ADDED
@@ -0,0 +1,60 @@
1
+ npm warn Unknown project config "network-concurrency". This will stop working in the next major version of npm.
2
+ npm warn publish npm auto-corrected some errors in your package.json when publishing. Please run "npm pkg fix" to address these errors.
3
+ npm warn publish errors corrected:
4
+ npm warn publish "repository.url" was normalized to "git+https://github.com/thorprovider/thor-commerce.git"
5
+ npm notice
6
+ npm notice 📦 @thor/types@2.0.1
7
+ npm notice Tarball Contents
8
+ npm notice 277B AGENTS.md
9
+ npm notice 1.6kB CHANGELOG.md
10
+ npm notice 6.4kB README.md
11
+ npm notice 101.2kB dist/index.d.mts
12
+ npm notice 101.2kB dist/index.d.ts
13
+ npm notice 3.2kB dist/index.js
14
+ npm notice 14.3kB dist/index.js.map
15
+ npm notice 1.9kB dist/index.mjs
16
+ npm notice 14.2kB dist/index.mjs.map
17
+ npm notice 832B package.json
18
+ npm notice 724B src/admin/AdminUser.ts
19
+ npm notice 946B src/admin/AuditLog.ts
20
+ npm notice 2.0kB src/admin/DashboardConfig.ts
21
+ npm notice 1.5kB src/admin/DashboardMetrics.ts
22
+ npm notice 268B src/admin/index.ts
23
+ npm notice 1.2kB src/admin/SiteConfigMetadata.ts
24
+ npm notice 6.5kB src/auth.ts
25
+ npm notice 2.8kB src/cart.ts
26
+ npm notice 3.0kB src/category.ts
27
+ npm notice 733B src/collection.ts
28
+ npm notice 35.3kB src/commerce-provider.ts
29
+ npm notice 2.1kB src/common.ts
30
+ npm notice 4.6kB src/customer.ts
31
+ npm notice 2.5kB src/designer-config.ts
32
+ npm notice 7.3kB src/header-config.README.md
33
+ npm notice 4.6kB src/header-config.ts
34
+ npm notice 5.5kB src/index.ts
35
+ npm notice 5.0kB src/order.ts
36
+ npm notice 6.0kB src/payment.ts
37
+ npm notice 10.7kB src/product.ts
38
+ npm notice 3.8kB src/provider.ts
39
+ npm notice 1.4kB src/region.ts
40
+ npm notice 2.1kB src/site-config-labels.ts
41
+ npm notice 3.0kB src/site-config.ts
42
+ npm notice 1.3kB src/stock-location.ts
43
+ npm notice 1.5kB src/storefront-config.ts
44
+ npm notice 3.3kB src/storefront.ts
45
+ npm notice 333B tsconfig.json
46
+ npm notice 303B tsup.config.ts
47
+ npm notice Tarball Details
48
+ npm notice name: @thor/types
49
+ npm notice version: 2.0.1
50
+ npm notice filename: thor-types-2.0.1.tgz
51
+ npm notice package size: 87.7 kB
52
+ npm notice unpacked size: 365.5 kB
53
+ npm notice shasum: 45a0c68b20d21a5446a471abb9077f2dd59cdd0d
54
+ npm notice integrity: sha512-AJRNa0Gs1osFo[...]RLXmlsHuMfinQ==
55
+ npm notice total files: 39
56
+ npm notice
57
+ npm notice Publishing to https://npm.pkg.github.com with tag latest and restricted access
58
+ npm error code E401
59
+ npm error 401 Unauthorized - PUT https://npm.pkg.github.com/@thor%2ftypes - unauthenticated: User cannot be authenticated with the token provided.
60
+ npm error A complete log of this run can be found in: /home/nelson/.npm/_logs/2026-04-16T15_45_29_457Z-debug-0.log
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Admin User Types
3
+ *
4
+ * Defines the structure for admin user accounts.
5
+ * MVP uses single password (no email), but prepared for multi-admin.
6
+ *
7
+ * @module admin/AdminUser
8
+ */
9
+
10
+ /**
11
+ * Admin User Account
12
+ *
13
+ * @remarks
14
+ * - MVP: email and passwordHash are optional (uses global password)
15
+ * - Future: Required fields for multi-admin system
16
+ */
17
+ export interface AdminUser {
18
+ /** Unique identifier */
19
+ id: string;
20
+
21
+ /** Email address (optional in MVP, required for multi-admin) */
22
+ email?: string;
23
+
24
+ /** Bcrypt password hash (optional in MVP, required for multi-admin) */
25
+ passwordHash?: string;
26
+
27
+ /** Account creation timestamp */
28
+ createdAt: Date;
29
+
30
+ /** Last update timestamp */
31
+ updatedAt: Date;
32
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Audit Log Types
3
+ *
4
+ * Defines the structure for audit logging of admin actions.
5
+ * Tracks all critical operations for security and compliance.
6
+ *
7
+ * @module admin/AuditLog
8
+ */
9
+
10
+ /**
11
+ * Audit Log Entry
12
+ *
13
+ * @remarks
14
+ * Records all admin actions for security auditing and compliance
15
+ */
16
+ export interface AuditLog {
17
+ /** Unique identifier */
18
+ id: string;
19
+
20
+ /** ID of the admin who performed the action */
21
+ adminId: string;
22
+
23
+ /** Action performed (e.g., 'login_success', 'update_order_status') */
24
+ action: string;
25
+
26
+ /** Type of resource affected (e.g., 'auth', 'order', 'product') */
27
+ resourceType: string;
28
+
29
+ /** ID of the specific resource (optional) */
30
+ resourceId?: string;
31
+
32
+ /** Additional context data */
33
+ metadata?: Record<string, unknown>;
34
+
35
+ /** IP address of the requester */
36
+ ipAddress?: string;
37
+
38
+ /** User agent string */
39
+ userAgent?: string;
40
+
41
+ /** Timestamp of the action */
42
+ createdAt: Date;
43
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Dashboard Configuration Types
3
+ *
4
+ * Defines the configuration structure for the DashboardModule.
5
+ * Uses adapters pattern for maximum flexibility and testability.
6
+ *
7
+ * @module admin/DashboardConfig
8
+ */
9
+
10
+ import type { DashboardMetrics } from './DashboardMetrics';
11
+ import type { Order, Product } from '../index';
12
+
13
+ /**
14
+ * Adapter for fetching dashboard metrics
15
+ *
16
+ * @remarks
17
+ * L3 components use this interface, L5 provides HTTP implementation
18
+ */
19
+ export interface DashboardMetricsAdapter {
20
+ getMetrics(): Promise<DashboardMetrics>;
21
+ }
22
+
23
+ /**
24
+ * Adapter for fetching and managing orders
25
+ */
26
+ export interface DashboardOrdersAdapter {
27
+ getOrders(params?: {
28
+ page?: number;
29
+ limit?: number;
30
+ search?: string;
31
+ }): Promise<{ orders: Order[]; total: number }>;
32
+
33
+ getOrderById(id: string): Promise<Order>;
34
+
35
+ updateOrderStatus?(id: string, status: string): Promise<Order>;
36
+ }
37
+
38
+ /**
39
+ * Adapter for fetching and managing products
40
+ */
41
+ export interface DashboardProductsAdapter {
42
+ getProducts(params?: {
43
+ page?: number;
44
+ limit?: number;
45
+ search?: string;
46
+ }): Promise<{ products: Product[]; total: number }>;
47
+
48
+ getProductById(id: string): Promise<Product>;
49
+ }
50
+
51
+ /**
52
+ * Adapter for fetching audit logs
53
+ */
54
+ export interface AuditLogAdapter {
55
+ getLogs(params?: {
56
+ page?: number;
57
+ limit?: number;
58
+ }): Promise<{ logs: any[]; total: number }>;
59
+ }
60
+
61
+ /**
62
+ * Complete Dashboard Configuration
63
+ *
64
+ * @remarks
65
+ * Passed to DashboardModule component
66
+ */
67
+ export interface DashboardConfig {
68
+ /** Storefront identifier */
69
+ storefrontId: string;
70
+
71
+ /** Metrics adapter (required for all variants) */
72
+ metrics: DashboardMetricsAdapter;
73
+
74
+ /** Orders adapter (required for standard and complete variants) */
75
+ orders: DashboardOrdersAdapter;
76
+
77
+ /** Products adapter (optional, for complete variant) */
78
+ products?: DashboardProductsAdapter;
79
+
80
+ /** Audit logs adapter (optional, for complete variant) */
81
+ auditLogs?: AuditLogAdapter;
82
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Dashboard Metrics Types
3
+ *
4
+ * Defines the structure for dashboard analytics and metrics.
5
+ * Used by the DashboardModule to display key business indicators.
6
+ *
7
+ * @module admin/DashboardMetrics
8
+ */
9
+
10
+ /**
11
+ * Sales Metrics
12
+ */
13
+ export interface SalesMetrics {
14
+ /** Total sales amount (all time) */
15
+ total: number;
16
+
17
+ /** Sales amount today */
18
+ today: number;
19
+
20
+ /** Sales amount in the last 7 days */
21
+ week: number;
22
+
23
+ /** Sales amount in the last 30 days */
24
+ month: number;
25
+ }
26
+
27
+ /**
28
+ * Orders Metrics
29
+ */
30
+ export interface OrdersMetrics {
31
+ /** Total number of orders */
32
+ total: number;
33
+
34
+ /** Number of pending orders */
35
+ pending: number;
36
+
37
+ /** Number of orders being processed */
38
+ processing: number;
39
+
40
+ /** Number of completed orders */
41
+ completed: number;
42
+ }
43
+
44
+ /**
45
+ * Products Metrics
46
+ */
47
+ export interface ProductsMetrics {
48
+ /** Total number of products */
49
+ total: number;
50
+
51
+ /** Number of products with low stock */
52
+ lowStock: number;
53
+ }
54
+
55
+ /**
56
+ * Chart Data Point
57
+ */
58
+ export interface ChartDataPoint {
59
+ /** Date in ISO format (YYYY-MM-DD) */
60
+ date: string;
61
+
62
+ /** Sales amount for this date */
63
+ sales: number;
64
+ }
65
+
66
+ /**
67
+ * Complete Dashboard Metrics
68
+ */
69
+ export interface DashboardMetrics {
70
+ /** Sales metrics */
71
+ sales: SalesMetrics;
72
+
73
+ /** Orders metrics */
74
+ orders: OrdersMetrics;
75
+
76
+ /** Products metrics */
77
+ products: ProductsMetrics;
78
+
79
+ /** Chart data for visualization (last 7 days) */
80
+ chartData: ChartDataPoint[];
81
+ }