@shoppexio/storefront 0.3.7 → 0.3.8

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.
Files changed (111) hide show
  1. package/README.md +201 -42
  2. package/dist/__tests__/affiliates.test.d.ts +2 -0
  3. package/dist/__tests__/affiliates.test.d.ts.map +1 -0
  4. package/dist/__tests__/analytics.test.d.ts +2 -0
  5. package/dist/__tests__/analytics.test.d.ts.map +1 -0
  6. package/dist/__tests__/cache.test.d.ts +2 -0
  7. package/dist/__tests__/cache.test.d.ts.map +1 -0
  8. package/dist/__tests__/cart.test.d.ts +2 -0
  9. package/dist/__tests__/cart.test.d.ts.map +1 -0
  10. package/dist/__tests__/checkout.test.d.ts +2 -0
  11. package/dist/__tests__/checkout.test.d.ts.map +1 -0
  12. package/dist/__tests__/client.test.d.ts +2 -0
  13. package/dist/__tests__/client.test.d.ts.map +1 -0
  14. package/dist/__tests__/config.test.d.ts +2 -0
  15. package/dist/__tests__/config.test.d.ts.map +1 -0
  16. package/dist/__tests__/coupons.test.d.ts +2 -0
  17. package/dist/__tests__/coupons.test.d.ts.map +1 -0
  18. package/dist/__tests__/endpoint.test.d.ts +2 -0
  19. package/dist/__tests__/endpoint.test.d.ts.map +1 -0
  20. package/dist/__tests__/invoices.test.d.ts +2 -0
  21. package/dist/__tests__/invoices.test.d.ts.map +1 -0
  22. package/dist/__tests__/navigation.test.d.ts +2 -0
  23. package/dist/__tests__/navigation.test.d.ts.map +1 -0
  24. package/dist/__tests__/pages.test.d.ts +2 -0
  25. package/dist/__tests__/pages.test.d.ts.map +1 -0
  26. package/dist/__tests__/products.test.d.ts +2 -0
  27. package/dist/__tests__/products.test.d.ts.map +1 -0
  28. package/dist/__tests__/reviews.test.d.ts +2 -0
  29. package/dist/__tests__/reviews.test.d.ts.map +1 -0
  30. package/dist/__tests__/sdk.smoke.test.d.ts +2 -0
  31. package/dist/__tests__/sdk.smoke.test.d.ts.map +1 -0
  32. package/dist/__tests__/setup.d.ts +2 -0
  33. package/dist/__tests__/setup.d.ts.map +1 -0
  34. package/dist/__tests__/store.test.d.ts +2 -0
  35. package/dist/__tests__/store.test.d.ts.map +1 -0
  36. package/dist/__tests__/storefront-custom-fields.test.d.ts +2 -0
  37. package/dist/__tests__/storefront-custom-fields.test.d.ts.map +1 -0
  38. package/dist/__tests__/theme.test.d.ts +2 -0
  39. package/dist/__tests__/theme.test.d.ts.map +1 -0
  40. package/dist/core/cache.d.ts +26 -0
  41. package/dist/core/cache.d.ts.map +1 -0
  42. package/dist/core/client.d.ts +17 -0
  43. package/dist/core/client.d.ts.map +1 -0
  44. package/dist/core/config.d.ts +10 -0
  45. package/dist/core/config.d.ts.map +1 -0
  46. package/dist/core/endpoint.d.ts +2 -0
  47. package/dist/core/endpoint.d.ts.map +1 -0
  48. package/dist/core/errors.d.ts +22 -0
  49. package/dist/core/errors.d.ts.map +1 -0
  50. package/dist/core/telemetry.d.ts +20 -0
  51. package/dist/core/telemetry.d.ts.map +1 -0
  52. package/dist/core/typed-client.d.ts +15 -0
  53. package/dist/core/typed-client.d.ts.map +1 -0
  54. package/dist/index.d.ts +33 -1118
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/modules/affiliates.d.ts +15 -0
  57. package/dist/modules/affiliates.d.ts.map +1 -0
  58. package/dist/modules/analytics.d.ts +2 -0
  59. package/dist/modules/analytics.d.ts.map +1 -0
  60. package/dist/modules/cart.d.ts +21 -0
  61. package/dist/modules/cart.d.ts.map +1 -0
  62. package/dist/modules/checkout.d.ts +28 -0
  63. package/dist/modules/checkout.d.ts.map +1 -0
  64. package/dist/modules/coupons.d.ts +3 -0
  65. package/dist/modules/coupons.d.ts.map +1 -0
  66. package/dist/modules/invoices.d.ts +6 -0
  67. package/dist/modules/invoices.d.ts.map +1 -0
  68. package/dist/modules/navigation.d.ts +20 -0
  69. package/dist/modules/navigation.d.ts.map +1 -0
  70. package/dist/modules/pages.d.ts +10 -0
  71. package/dist/modules/pages.d.ts.map +1 -0
  72. package/dist/modules/presence.d.ts +6 -0
  73. package/dist/modules/presence.d.ts.map +1 -0
  74. package/dist/modules/products.d.ts +16 -0
  75. package/dist/modules/products.d.ts.map +1 -0
  76. package/dist/modules/reviews.d.ts +3 -0
  77. package/dist/modules/reviews.d.ts.map +1 -0
  78. package/dist/modules/search.d.ts +6 -0
  79. package/dist/modules/search.d.ts.map +1 -0
  80. package/dist/modules/store.d.ts +11 -0
  81. package/dist/modules/store.d.ts.map +1 -0
  82. package/dist/modules/theme.d.ts +27 -0
  83. package/dist/modules/theme.d.ts.map +1 -0
  84. package/dist/shoppex.esm.js +3 -0
  85. package/dist/shoppex.esm.js.map +1 -0
  86. package/dist/shoppex.umd.js +2 -0
  87. package/dist/shoppex.umd.js.map +1 -0
  88. package/dist/types/api.d.ts +580 -0
  89. package/dist/types/api.d.ts.map +1 -0
  90. package/dist/types/cart.d.ts +102 -0
  91. package/dist/types/cart.d.ts.map +1 -0
  92. package/dist/types/config.d.ts +18 -0
  93. package/dist/types/config.d.ts.map +1 -0
  94. package/dist/types/index.d.ts +7 -0
  95. package/dist/types/index.d.ts.map +1 -0
  96. package/dist/types/theme-config.d.ts +109 -0
  97. package/dist/types/theme-config.d.ts.map +1 -0
  98. package/dist/utils/format.d.ts +6 -0
  99. package/dist/utils/format.d.ts.map +1 -0
  100. package/dist/utils/storage.d.ts +10 -0
  101. package/dist/utils/storage.d.ts.map +1 -0
  102. package/dist/utils/storefront-custom-fields.d.ts +13 -0
  103. package/dist/utils/storefront-custom-fields.d.ts.map +1 -0
  104. package/package.json +38 -20
  105. package/CHANGELOG.md +0 -20
  106. package/LICENSE +0 -21
  107. package/dist/index.cjs +0 -18360
  108. package/dist/index.cjs.map +0 -1
  109. package/dist/index.d.cts +0 -1192
  110. package/dist/index.js +0 -18318
  111. package/dist/index.js.map +0 -1
package/README.md CHANGED
@@ -1,76 +1,235 @@
1
- # @shoppexio/storefront
1
+ # Shoppex Storefront SDK
2
2
 
3
- Official JavaScript storefront SDK for Shoppex.
3
+ Build custom storefronts with any framework using the Shoppex SDK.
4
4
 
5
- Use this package when you want to embed Shoppex products, cart behavior, and hosted checkout into a custom frontend.
5
+ ## Installation
6
6
 
7
- ## Good fit
7
+ ### CDN (Recommended for quick start)
8
8
 
9
- Use this package for:
9
+ ```html
10
+ <script src="https://cdn.shoppex.io/sdk/v0.3/shoppex.umd.js"></script>
11
+ ```
12
+
13
+ Use the moving minor channel for managed updates.
14
+ Simple example: `v0.3` moves to the latest `0.3.x` release.
10
15
 
11
- - product loading
12
- - cart state
13
- - checkout redirects
14
- - storefront helpers
16
+ If you need a locked production rollout, pin an exact version:
17
+
18
+ ```html
19
+ <script src="https://cdn.shoppex.io/sdk/<exact-version>/shoppex.umd.js"></script>
20
+ ```
15
21
 
16
- ## Install
22
+ `/sdk/latest/` stays available for internal and development usage only.
23
+
24
+ ### npm
17
25
 
18
26
  ```bash
19
27
  npm install @shoppexio/storefront
20
28
  ```
21
29
 
22
- ## Quick start
30
+ ## Quick Start
31
+
32
+ ```html
33
+ <script src="https://cdn.shoppex.io/sdk/v0.3/shoppex.umd.js"></script>
34
+ <script>
35
+ // Initialize with your store slug
36
+ shoppex.init('my-store');
37
+
38
+ // Get store info
39
+ shoppex.getStore().then(function(result) {
40
+ if (result.success) {
41
+ console.log('Store:', result.data.name);
42
+ }
43
+ });
44
+
45
+ // Add product to cart
46
+ shoppex.addToCart('product-id', 'variant-id', 2);
47
+
48
+ // Checkout (redirects to hosted checkout)
49
+ document.getElementById('checkout-btn').onclick = function() {
50
+ shoppex.checkout();
51
+ };
52
+ </script>
53
+ ```
23
54
 
24
- ```ts
25
- import shoppex from '@shoppexio/storefront';
55
+ ### ES Modules (with async/await)
26
56
 
27
- shoppex.init('my-store');
57
+ ```html
58
+ <script type="module">
59
+ import shoppex from 'https://cdn.shoppex.io/sdk/v0.3/shoppex.esm.js';
28
60
 
29
- const products = await shoppex.getProducts();
30
- shoppex.addToCart(products.data?.[0]?.uniqid ?? '', 'default', 1);
31
- await shoppex.checkout();
61
+ shoppex.init('my-store');
62
+
63
+ const store = await shoppex.getStore();
64
+ const products = await shoppex.getProducts();
65
+
66
+ shoppex.addToCart(products.data[0].uniqid, 'default', 1);
67
+
68
+ await shoppex.checkout();
69
+ </script>
32
70
  ```
33
71
 
34
- ## Coupon validation
72
+ ## API Reference
35
73
 
36
- Use the options form when validating a coupon for a selected product variant:
74
+ ### Initialization
37
75
 
38
- ```ts
39
- const result = await shoppex.validateCoupon('SAVE10', {
40
- productId: 'prod_abc123',
41
- variantId: 'variant_lifetime',
76
+ ```javascript
77
+ // Simple init
78
+ shoppex.init('store-slug');
79
+
80
+ // With options
81
+ shoppex.init({
82
+ storeId: 'store-slug',
83
+ locale: 'de',
84
+ currency: 'EUR'
42
85
  });
43
86
  ```
44
87
 
45
- Calling `validateCoupon(code)` without options validates against the current SDK cart. Affiliate/referral codes are separate and should use `validateAffiliateCode` or `applyAffiliateCode`. If `program_enabled` is false in an affiliate validation response, the shop-level affiliate program is disabled even if individual links exist.
88
+ ### Store
46
89
 
47
- ## Live online users
90
+ ```javascript
91
+ const store = await shoppex.getStore();
92
+ // → { success: true, data: { id, name, currency, ... } }
48
93
 
49
- The SDK can power a custom live online visitor counter. It provides the data; your storefront renders the badge.
94
+ const logoUrl = await shoppex.getStoreLogoUrl();
95
+ const bannerUrl = await shoppex.getStoreBannerUrl();
96
+ ```
50
97
 
51
- ```ts
52
- import shoppex from '@shoppexio/storefront';
98
+ ### Products
53
99
 
54
- shoppex.init('my-store');
100
+ ```javascript
101
+ const products = await shoppex.getProducts();
102
+ // → { success: true, data: [{ uniqid, title, price, images[], variants[], addons[], faqs[], feedback, ... }] }
103
+ // variants[] mirrors price_variants[] (legacy field); both are present for compatibility.
104
+ // images[] contains the full product gallery; the first entry is the primary image.
55
105
 
56
- async function refreshLiveUsers() {
57
- await shoppex.touchStorefrontPresence();
106
+ const product = await shoppex.getProduct('product-id-or-slug');
107
+ const categories = await shoppex.getCategories();
108
+ ```
109
+
110
+ ### Cart
111
+
112
+ ```javascript
113
+ // Simple add
114
+ shoppex.addToCart('productId', 'variantId', 2);
115
+
116
+ // With Shoppex features (addons, custom fields)
117
+ shoppex.addToCart('productId', 'variantId', 1, {
118
+ addons: [
119
+ { id: 'addon_gift_wrap', quantity: 1 }
120
+ ],
121
+ customFields: {
122
+ 'engraving_text': 'Happy Birthday!'
123
+ },
124
+ priceVariantId: 'price_premium'
125
+ });
126
+
127
+ // Get cart
128
+ const cart = shoppex.getCart();
129
+ const itemCount = shoppex.getCartItemCount();
130
+
131
+ // Manage cart
132
+ shoppex.removeFromCart('productId', 'variantId');
133
+ shoppex.clearCart();
134
+
135
+ // Backup/restore (useful for error recovery)
136
+ shoppex.createCartBackup();
137
+ shoppex.restoreCartFromBackup();
138
+ ```
139
+
140
+ ### Checkout
141
+
142
+ ```javascript
143
+ // Simple checkout (auto-redirects)
144
+ await shoppex.checkout();
145
+
146
+ // With coupon
147
+ await shoppex.checkout('SAVE20');
148
+
149
+ // Get URL without redirecting
150
+ const result = await shoppex.checkout('SAVE20', { autoRedirect: false });
151
+ console.log(result.redirectUrl);
152
+ ```
58
153
 
59
- const result = await shoppex.getStorefrontOnlineUsers();
60
- if (result.success && result.data) {
61
- console.log(`${result.data.count} online`);
62
- }
154
+ ### Coupons
155
+
156
+ ```javascript
157
+ const result = await shoppex.validateCoupon('SAVE20', {
158
+ productId: 'product-id',
159
+ variantId: 'variant-id',
160
+ });
161
+ // -> { success: true, data: { valid: true, discount: 20, restriction_scope: 'variants' } }
162
+ ```
163
+
164
+ ### Affiliate Codes
165
+
166
+ Affiliate/referral codes are separate from coupon codes. Validate and store them before checkout:
167
+
168
+ ```javascript
169
+ const affiliate = await shoppex.applyAffiliateCode('creator10');
170
+
171
+ if (affiliate.data?.program_enabled === false) {
172
+ throw new Error('Affiliate program is disabled for this shop');
63
173
  }
64
174
 
65
- await refreshLiveUsers();
66
- setInterval(refreshLiveUsers, 30_000);
175
+ await shoppex.checkout({
176
+ coupon: 'SAVE20',
177
+ affiliateCode: affiliate.data?.affiliate_code,
178
+ });
179
+ ```
180
+
181
+ ### Reviews
182
+
183
+ ```javascript
184
+ const reviews = await shoppex.getShopReviews();
185
+ // → { success: true, data: [{ rating, comment, ... }] }
186
+ ```
187
+
188
+ ### Invoices
189
+
190
+ ```javascript
191
+ const invoice = await shoppex.getInvoice('invoice-id');
192
+ const status = await shoppex.getInvoiceStatus('invoice-id');
67
193
  ```
68
194
 
69
- ## Not this package
195
+ ### Formatting
196
+
197
+ ```javascript
198
+ const formatter = shoppex.createFormatter('USD', 'en-US');
199
+ formatter.format(29.99); // → "$29.99"
200
+
201
+ // Or directly
202
+ shoppex.formatPrice(29.99, 'EUR', 'de-DE'); // → "29,99 €"
203
+ ```
204
+
205
+ ## Shoppex Features
206
+
207
+ The SDK supports Shoppex-specific features not found in competitors:
208
+
209
+ | Feature | Description |
210
+ |---------|-------------|
211
+ | **Product Addons** | Express shipping, gift wrap, etc. |
212
+ | **Custom Fields** | Customer input (engraving, gift message) |
213
+ | **Price Variants** | Different pricing tiers |
214
+ | **Multiple Gateways** | Stripe, PayPal, Crypto |
70
215
 
71
- If you want the authenticated Developer API wrapper for backend integrations, use `@shoppexio/sdk`. Do not ship `@shoppexio/sdk` in a browser bundle; use this Storefront SDK for headless storefronts.
216
+ ## Browser Support
217
+
218
+ - Chrome 80+
219
+ - Firefox 75+
220
+ - Safari 13+
221
+ - Edge 80+
222
+
223
+ ## TypeScript
224
+
225
+ Full TypeScript support with type definitions included.
226
+
227
+ ```typescript
228
+ import shoppex, { Product, CartItem } from '@shoppexio/storefront';
229
+
230
+ const products: Product[] = (await shoppex.getProducts()).data ?? [];
231
+ ```
72
232
 
73
- ## Docs
233
+ ## License
74
234
 
75
- - Storefront docs: [docs.shoppex.io/sdk/introduction](https://docs.shoppex.io/sdk/introduction)
76
- - Installation: [docs.shoppex.io/sdk/installation](https://docs.shoppex.io/sdk/installation)
235
+ MIT
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=affiliates.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affiliates.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/affiliates.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=analytics.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/analytics.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cache.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/cache.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cart.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cart.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/cart.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=checkout.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/checkout.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=client.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/client.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=config.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/config.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=coupons.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coupons.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/coupons.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=endpoint.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/endpoint.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=invoices.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoices.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/invoices.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=navigation.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/navigation.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pages.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pages.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/pages.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=products.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"products.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/products.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=reviews.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reviews.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/reviews.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sdk.smoke.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.smoke.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/sdk.smoke.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=store.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/store.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=storefront-custom-fields.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storefront-custom-fields.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/storefront-custom-fields.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=theme.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/theme.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * In-memory cache with pending request deduplication.
3
+ */
4
+ export interface CacheEntry<T> {
5
+ data: T;
6
+ expiresAt: number;
7
+ updatedAt: number;
8
+ ttl: number;
9
+ }
10
+ export interface CacheOptions {
11
+ ttl: number;
12
+ staleWhileRevalidate?: boolean;
13
+ }
14
+ export interface CacheStats {
15
+ hits: number;
16
+ misses: number;
17
+ pendingRequests: number;
18
+ entries: number;
19
+ }
20
+ export declare function getCacheStats(): CacheStats;
21
+ export declare function clearCache(): void;
22
+ export declare function invalidateCache(prefixOrKey: string): void;
23
+ export declare function setCacheEntry<T>(key: string, data: T, ttl: number): void;
24
+ export declare function getCacheEntry<T>(key: string): CacheEntry<T> | null;
25
+ export declare function getOrFetch<T>(key: string, fetcher: () => Promise<T>, options: CacheOptions, shouldCache?: (value: T) => boolean): Promise<T>;
26
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/core/cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC;IACR,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAcD,wBAAgB,aAAa,IAAI,UAAU,CAO1C;AAED,wBAAgB,UAAU,IAAI,IAAI,CAGjC;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAMzD;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAQxE;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAIlE;AAED,wBAAsB,UAAU,CAAC,CAAC,EAChC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACzB,OAAO,EAAE,YAAY,EACrB,WAAW,GAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAoB,GAC9C,OAAO,CAAC,CAAC,CAAC,CA8CZ"}
@@ -0,0 +1,17 @@
1
+ import { SDKResponse } from '../types';
2
+ import { CacheOptions } from './cache';
3
+ interface RequestOptions {
4
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
5
+ body?: unknown;
6
+ timeout?: number;
7
+ retries?: number;
8
+ baseUrl?: string;
9
+ cache?: (CacheOptions & {
10
+ key?: string;
11
+ }) | false;
12
+ }
13
+ export declare function request<T>(endpoint: string, options?: RequestOptions): Promise<SDKResponse<T>>;
14
+ export declare function get<T>(endpoint: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<SDKResponse<T>>;
15
+ export declare function post<T>(endpoint: string, body?: unknown, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<SDKResponse<T>>;
16
+ export {};
17
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAMxD,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,CAAC,YAAY,GAAG;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,KAAK,CAAC;CACnD;AAiBD,wBAAsB,OAAO,CAAC,CAAC,EAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAiIzB;AA6DD,wBAAsB,GAAG,CAAC,CAAC,EACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,MAAM,CAAC,GAChD,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAEzB;AAED,wBAAsB,IAAI,CAAC,CAAC,EAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,MAAM,CAAC,GAChD,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAEzB"}
@@ -0,0 +1,10 @@
1
+ import { ShoppexConfig, ShoppexInitOptions } from '../types';
2
+ export declare const DEFAULT_API_BASE_URL = "https://api.shoppex.io";
3
+ export declare const DEFAULT_CHECKOUT_BASE_URL = "https://checkout.shoppex.io";
4
+ export declare function initConfig(storeSlug: string, options?: ShoppexInitOptions): ShoppexConfig;
5
+ export declare function getConfig(): ShoppexConfig;
6
+ export declare function isInitialized(): boolean;
7
+ export declare function resetConfig(): void;
8
+ export declare function setShopId(shopId: string): void;
9
+ export declare function getShopId(): string | null;
10
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAIlE,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAK7D,eAAO,MAAM,yBAAyB,gCAAgC,CAAC;AAEvE,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,aAAa,CAgBf;AAED,wBAAgB,SAAS,IAAI,aAAa,CAKzC;AAED,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED,wBAAgB,WAAW,IAAI,IAAI,CAIlC;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,SAAS,IAAI,MAAM,GAAG,IAAI,CAEzC"}
@@ -0,0 +1,2 @@
1
+ export declare function buildEndpoint(template: string, params: Record<string, string | number | null | undefined>): string;
2
+ //# sourceMappingURL=endpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/core/endpoint.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GACzD,MAAM,CAcR"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * SDK Error Classes
3
+ */
4
+ export declare class ShoppexError extends Error {
5
+ readonly code: string;
6
+ readonly statusCode?: number;
7
+ constructor(message: string, code: string, statusCode?: number);
8
+ }
9
+ export declare class NotInitializedError extends ShoppexError {
10
+ constructor();
11
+ }
12
+ export declare class NetworkError extends ShoppexError {
13
+ constructor(message: string, statusCode?: number);
14
+ }
15
+ export declare class ValidationError extends ShoppexError {
16
+ readonly invalidFields?: string[];
17
+ constructor(message: string, invalidFields?: string[]);
18
+ }
19
+ export declare class CartError extends ShoppexError {
20
+ constructor(message: string);
21
+ }
22
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAO/D;AAED,qBAAa,mBAAoB,SAAQ,YAAY;;CASpD;AAED,qBAAa,YAAa,SAAQ,YAAY;gBAChC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAKjD;AAED,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,SAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;gBAE7B,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE;CAMtD;AAED,qBAAa,SAAU,SAAQ,YAAY;gBAC7B,OAAO,EAAE,MAAM;CAK5B"}
@@ -0,0 +1,20 @@
1
+ type VisibilityStateValue = 'hidden' | 'visible' | 'prerender' | 'unloaded';
2
+ type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
3
+ export interface StorefrontClientErrorPayload {
4
+ endpoint: string;
5
+ method: RequestMethod;
6
+ message: string;
7
+ statusCode?: number;
8
+ source?: 'sdk';
9
+ phase?: 'request';
10
+ attemptCount?: number;
11
+ responseReceived?: boolean;
12
+ pageUrl?: string;
13
+ requestUrl?: string;
14
+ online?: boolean;
15
+ visibilityState?: VisibilityStateValue;
16
+ }
17
+ export declare function getStorefrontConnectionId(storeSlug: string): string | null;
18
+ export declare function reportStorefrontClientError(payload: StorefrontClientErrorPayload): Promise<void>;
19
+ export {};
20
+ //# sourceMappingURL=telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/core/telemetry.ts"],"names":[],"mappings":"AAOA,KAAK,oBAAoB,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;AAC5E,KAAK,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEvD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,oBAAoB,CAAC;CACxC;AASD,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAY1E;AAwBD,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CAqDtG"}
@@ -0,0 +1,15 @@
1
+ import { createApiClient } from '@shoppex/contracts';
2
+ type ApiClient = ReturnType<typeof createApiClient>;
3
+ /**
4
+ * Return a typed OpenAPI client bound to the SDK's configured API base URL.
5
+ * The client is cached per base URL and recreated when the SDK is re-initialized
6
+ * against a different host.
7
+ */
8
+ export declare function getTypedClient(token?: string): ApiClient;
9
+ /**
10
+ * Reset the cached client. Called when the SDK is re-initialized so that a new
11
+ * `apiBaseUrl` takes effect immediately on the next `client()` call.
12
+ */
13
+ export declare function resetTypedClient(): void;
14
+ export {};
15
+ //# sourceMappingURL=typed-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-client.d.ts","sourceRoot":"","sources":["../../src/core/typed-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAKpD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAgBxD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC"}