@liquidcommerce/elements-sdk 2.7.21 → 2.7.22

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 (31) hide show
  1. package/README.md +1 -1
  2. package/dist/index.checkout.esm.js +7176 -7115
  3. package/dist/index.esm.js +11572 -11515
  4. package/dist/types/core/pubsub/interfaces/address.interface.d.ts +3 -0
  5. package/dist/types/core/pubsub/interfaces/core.interface.d.ts +2 -2
  6. package/docs/v1/api/actions/address-actions.md +20 -15
  7. package/docs/v1/api/actions/cart-actions.md +22 -23
  8. package/docs/v1/api/actions/checkout-actions.md +72 -25
  9. package/docs/v1/api/actions/product-actions.md +61 -15
  10. package/docs/v1/api/client.md +38 -14
  11. package/docs/v1/api/configuration.md +5 -1
  12. package/docs/v1/api/injection-methods.md +8 -4
  13. package/docs/v1/api/typescript-types.md +6 -0
  14. package/docs/v1/examples/advanced-patterns.md +7 -6
  15. package/docs/v1/examples/checkout-flow.md +1 -2
  16. package/docs/v1/getting-started/concepts.md +20 -25
  17. package/docs/v1/getting-started/installation.md +4 -4
  18. package/docs/v1/guides/address-component.md +12 -8
  19. package/docs/v1/guides/best-practices.md +5 -5
  20. package/docs/v1/guides/cart-component.md +27 -39
  21. package/docs/v1/guides/checkout-component.md +27 -29
  22. package/docs/v1/guides/events.md +4 -4
  23. package/docs/v1/guides/product-component.md +42 -19
  24. package/docs/v1/guides/product-list-component.md +8 -9
  25. package/docs/v1/guides/theming.md +6 -9
  26. package/docs/v1/integration/proxy-setup.md +22 -5
  27. package/docs/v1/reference/browser-support.md +2 -1
  28. package/docs/v1/reference/error-handling.md +12 -7
  29. package/docs/v1/reference/performance.md +1 -3
  30. package/docs/v1/reference/troubleshooting.md +3 -3
  31. package/package.json +8 -17
@@ -183,7 +183,7 @@ For products with multiple retailers:
183
183
  - Select with one tap
184
184
 
185
185
  **Popup View**
186
- - "Choose Retailer" button
186
+ - "See Delivery Options" button (shows the available fulfillment count, e.g. "See Delivery Options (3)")
187
187
  - Modal with full retailer list
188
188
  - Filter and search capabilities
189
189
 
@@ -218,17 +218,38 @@ console.log(productData);
218
218
  // {
219
219
  // identifier: '00619947000020',
220
220
  // name: 'Premium Whiskey',
221
- // price: 4999,
222
- // selectedSize: { id: '750ml', upc: '00619947000020', ... },
221
+ // priceInfo: { currency: 'USD', minimum: 4999, average: 4999, maximum: 4999 },
222
+ // selectedSizeId: '750ml',
223
223
  // selectedFulfillmentType: 'shipping',
224
- // selectedRetailer: { id: 'retailer_123', name: 'Spirits Shop', ... },
225
- // quantity: 1,
224
+ // selectedFulfillmentId: 'fulfillment_123',
225
+ // productHasAvailability: true,
226
+ // fulfillmentHasAvailability: true,
227
+ // sizes: { '750ml': { ... } },
226
228
  // ...
227
229
  // }
228
230
  ```
229
231
 
230
232
  **Note:** The product must be injected and loaded before calling `getDetails()`. If the product hasn't been loaded, an error is thrown.
231
233
 
234
+ ### Get Product Availability by State
235
+
236
+ Check availability for one or more products in a given state. Returns a `Promise<IProductAvailabilityResponse>`:
237
+
238
+ ```javascript
239
+ const availability = await window.LiquidCommerce.elements.actions.product.getProductAvailabilityByState(
240
+ ['00619947000020', '08504405135'],
241
+ 'NY'
242
+ );
243
+
244
+ console.log(availability);
245
+ // {
246
+ // products: [...],
247
+ // retailers: { ... }
248
+ // }
249
+ ```
250
+
251
+ The `state` argument is optional; at least one product identifier is required.
252
+
232
253
  ## Events
233
254
 
234
255
  Listen for product-related events:
@@ -239,8 +260,8 @@ Fired when product data is successfully loaded:
239
260
 
240
261
  ```javascript
241
262
  window.addEventListener('lce:actions.product_loaded', (event) => {
242
- const { identifier, name, price } = event.detail.data;
243
- console.log(`Product loaded: ${name} - $${price / 100}`);
263
+ const { identifier, name, priceInfo } = event.detail.data;
264
+ console.log(`Product loaded: ${name} - $${priceInfo.minimum / 100}`);
244
265
  });
245
266
  ```
246
267
 
@@ -250,8 +271,8 @@ Fired when user clicks "Add to Cart":
250
271
 
251
272
  ```javascript
252
273
  window.addEventListener('lce:actions.product_add_to_cart', (event) => {
253
- const { identifier, quantity, fulfillmentType } = event.detail.data;
254
- console.log(`Adding ${quantity}x ${identifier} (${fulfillmentType})`);
274
+ const { identifier, quantity, fulfillmentId } = event.detail.data;
275
+ console.log(`Adding ${quantity}x ${identifier} (${fulfillmentId})`);
255
276
  });
256
277
  ```
257
278
 
@@ -261,8 +282,8 @@ Fired when user selects a different size:
261
282
 
262
283
  ```javascript
263
284
  window.addEventListener('lce:actions.product_size_changed', (event) => {
264
- const { identifier, selectedSize, price } = event.detail.data;
265
- console.log(`Size changed to ${selectedSize.name}: $${price / 100}`);
285
+ const { identifier, selectedSizeId, selectedSize } = event.detail.data;
286
+ console.log(`Size changed to ${selectedSize} (${selectedSizeId})`);
266
287
  });
267
288
  ```
268
289
 
@@ -272,8 +293,8 @@ Fired when user switches between shipping and on-demand:
272
293
 
273
294
  ```javascript
274
295
  window.addEventListener('lce:actions.product_fulfillment_type_changed', (event) => {
275
- const { identifier, fulfillmentType } = event.detail.data;
276
- console.log(`Fulfillment type changed to: ${fulfillmentType}`);
296
+ const { identifier, selectedFulfillmentType } = event.detail.data;
297
+ console.log(`Fulfillment type changed to: ${selectedFulfillmentType}`);
277
298
  });
278
299
  ```
279
300
 
@@ -283,8 +304,8 @@ Fired when user selects a different retailer:
283
304
 
284
305
  ```javascript
285
306
  window.addEventListener('lce:actions.product_fulfillment_changed', (event) => {
286
- const { identifier, selectedRetailer, price } = event.detail.data;
287
- console.log(`Retailer changed to ${selectedRetailer.name}: $${price / 100}`);
307
+ const { identifier, selectedFulfillmentId, selectedFulfillmentType } = event.detail.data;
308
+ console.log(`Fulfillment changed to ${selectedFulfillmentId} (${selectedFulfillmentType})`);
288
309
  });
289
310
  ```
290
311
 
@@ -397,7 +418,8 @@ await window.LiquidCommerce.elements.actions.address.setAddressManually(
397
418
  two: 'Apt 4',
398
419
  city: 'New York',
399
420
  state: 'NY',
400
- zip: '10001'
421
+ zip: '10001',
422
+ country: 'US'
401
423
  },
402
424
  {
403
425
  latitude: 40.7128,
@@ -458,8 +480,9 @@ console.log(container); // <div id="product-1">...</div>
458
480
  If a product identifier doesn't exist:
459
481
 
460
482
  ```javascript
461
- // An error view is shown in the container
462
- // Console logs: [LiquidCommerce Elements] Product not found: invalid_id
483
+ // An error view is shown in the container, and the store entry's `error`
484
+ // is set to 'Product data not found'. In debug/logging mode the SDK warns:
485
+ // "No product data found for the provided product IDs."
463
486
  ```
464
487
 
465
488
  ### No Availability
@@ -535,7 +558,7 @@ window.addEventListener('lce:actions.product_loaded', (event) => {
535
558
  items: [{
536
559
  item_id: event.detail.data.identifier,
537
560
  item_name: event.detail.data.name,
538
- price: event.detail.data.price / 100
561
+ price: event.detail.data.priceInfo.minimum / 100
539
562
  }]
540
563
  });
541
564
  });
@@ -39,7 +39,7 @@ Use data attributes to configure the product list:
39
39
 
40
40
  **Attributes:**
41
41
  - `data-liquid-commerce-elements-products-list`: Product list container; value is the collection slug
42
- - `data-rows`: Number of rows to display (default: 3)
42
+ - `data-rows`: Number of rows to display (default: 4)
43
43
  - `data-columns`: Number of columns (default: 4)
44
44
  - `data-filters`: Comma-separated filter types
45
45
  - `data-product-url`: URL pattern for product detail pages (optional)
@@ -138,8 +138,8 @@ Only filter keys that are configured for the list are honored — anything else
138
138
 
139
139
  1. `data-filters` on `<div data-liquid-commerce-elements-products-list>` (use this when the page does **not** mount a filters UI but you still want URL filtering — e.g. a curated category page).
140
140
  2. `data-filters` on the matching `<... -products-list-filters>` container (the common case when a filters panel is mounted).
141
- 3. `availableFilters` from the theme config for the list slug.
142
- 4. `filters` array passed to `injectProductList(...)` programmatically.
141
+ 3. `filters` array passed to `injectProductList(...)` programmatically.
142
+ 4. `availableFilters` from the theme config for the list slug (fallback only).
143
143
 
144
144
  ### Supported formats
145
145
 
@@ -190,10 +190,9 @@ The search component provides full-text search across:
190
190
 
191
191
  ### Search Behavior
192
192
 
193
- - Real-time search as user types (debounced)
194
- - Minimum 2 characters to trigger search
195
- - Highlights matching terms in results
196
- - Shows result count
193
+ - Real-time search as user types (500ms debounce; fires on any non-empty input — no minimum character count)
194
+ - Input is limited to 100 characters; allowed characters: letters, numbers, spaces, and `- _ ' . , & ( )`
195
+ - Server-side filtering by the search term
197
196
  - "Clear search" button appears when active
198
197
 
199
198
  ### Programmatic Search
@@ -262,7 +261,7 @@ Each product card shows:
262
261
  - Brand
263
262
  - Price (or price range for multiple sizes)
264
263
  - Rating (if available)
265
- - "Quick View" or "View Details" button
264
+ - Clickable image/card linking to the product detail page (when `productUrl` is configured)
266
265
  - "Add to Cart" button (optional)
267
266
  - Availability indicator
268
267
 
@@ -619,7 +618,7 @@ await client.injectProductList({
619
618
 
620
619
  ### Search Not Finding Products
621
620
 
622
- 1. Verify minimum character count is met (2 chars)
621
+ 1. Verify the input uses allowed characters and is under the 100-character limit
623
622
  2. Check search is not case-sensitive (it shouldn't be)
624
623
  3. Ensure products have searchable text fields
625
624
  4. Look for API errors in network tab
@@ -77,8 +77,7 @@ customTheme: {
77
77
  personalizationCardStyle: 'outlined', // or 'filled'
78
78
  allowPromoCodes: true,
79
79
  inputFieldStyle: 'outlined', // or 'filled'
80
- showPoweredBy: true,
81
- poweredByMode: 'light' // or 'dark'
80
+ poweredByMode: 'light' // or 'dark' (note: showPoweredBy is controlled server-side and cannot be overridden via customTheme)
82
81
  }
83
82
  }
84
83
  }
@@ -152,16 +151,15 @@ customTheme: {
152
151
  text: 'Receive SMS updates about your order and exclusive deals.'
153
152
  },
154
153
  allowGiftCards: true,
155
- legalMessage: 'By placing your order, you agree to our Terms of Service and Privacy Policy.',
154
+ legalMessage: { show: true, text: 'By placing your order, you agree to our Terms of Service and Privacy Policy.' },
156
155
  continueShoppingUrl: 'https://yoursite.com/shop',
157
156
  exitUrl: 'https://yoursite.com',
158
157
  thankYouButtonText: 'Continue Shopping',
159
158
  drawerHeaderText: 'Checkout',
160
159
  placeOrderButtonText: 'Place Order',
161
160
  checkoutCompleted: {
162
- customLogo: 'https://yoursite.com/logo.png',
163
- customText: 'Thank you for your purchase! Your order has been received.'
164
- }
161
+ customLogo: 'https://yoursite.com/logo.png',
162
+ customText: 'Thank you for your purchase! Your order has been received.'
165
163
  }
166
164
  }
167
165
  }
@@ -191,8 +189,7 @@ const client = await Elements('YOUR_API_KEY', {
191
189
  },
192
190
  layout: {
193
191
  allowPromoCodes: true,
194
- inputFieldStyle: 'outlined',
195
- showPoweredBy: false
192
+ inputFieldStyle: 'outlined'
196
193
  }
197
194
  },
198
195
  product: {
@@ -203,7 +200,7 @@ const client = await Elements('YOUR_API_KEY', {
203
200
  },
204
201
  cart: {
205
202
  layout: {
206
- checkoutButtonText: 'Checkout Now'
203
+ goToCheckoutButtonText: 'Checkout Now'
207
204
  }
208
205
  }
209
206
  }
@@ -12,7 +12,12 @@ import { Elements } from '@liquidcommerce/elements-sdk';
12
12
  const client = await Elements('YOUR_API_KEY', {
13
13
  env: 'production',
14
14
  proxy: {
15
- baseUrl: 'https://yoursite.com/api/elements-proxy'
15
+ // Must be an ABSOLUTE URL ending with a trailing slash — the SDK resolves
16
+ // each request as `new URL('api' + path, baseUrl)`, so a missing trailing
17
+ // slash drops the last path segment.
18
+ baseUrl: 'https://yoursite.com/api/elements-proxy/',
19
+ // Optional: extra headers merged into every proxied request (e.g. credentials)
20
+ headers: { 'X-My-Auth': '...' }
16
21
  }
17
22
  });
18
23
  ```
@@ -30,7 +35,8 @@ export default function ProductPage() {
30
35
  (async () => {
31
36
  const client = await Elements('YOUR_API_KEY', {
32
37
  env: 'production',
33
- proxy: { baseUrl: '/api/elements-proxy' }
38
+ // Absolute URL with a trailing slash (see note above)
39
+ proxy: { baseUrl: 'https://yoursite.com/api/elements-proxy/' }
34
40
  });
35
41
 
36
42
  await client.injectProductElement([
@@ -47,6 +53,8 @@ export default function ProductPage() {
47
53
 
48
54
  Your endpoint should forward requests to the LiquidCommerce Elements API, preserving method, headers, and body.
49
55
 
56
+ The SDK does not hardcode the upstream host in the proxy path. Instead, it sends the correct environment-specific upstream base URL in the `X-Liquid-Proxy-Target` request header (along with `X-Liquid-Proxy: true`). Forward to that header value rather than to a literal host — this keeps the proxy environment-agnostic. The SDK calls your proxy at `<baseUrl>/api/<endpoint>`, so the path captured after your proxy mount is exactly the `api/<endpoint>` to append to the target.
57
+
50
58
  ### Minimal Express Example
51
59
 
52
60
  ```javascript
@@ -56,15 +64,24 @@ import fetch from 'node-fetch';
56
64
  const app = express();
57
65
  app.use(express.json());
58
66
 
67
+ // Proxy is mounted at the path of your proxy.baseUrl ('/api/elements-proxy/').
59
68
  app.all('/api/elements-proxy/*', async (req, res) => {
60
- const targetPath = req.params[0];
61
- const targetUrl = `https://api.liquidcommerce.us/${targetPath}`;
69
+ // Upstream base URL the SDK wants this request forwarded to
70
+ // (e.g. https://elements-services-production-948630220003.us-central1.run.app)
71
+ const upstream = req.headers['x-liquid-proxy-target'];
72
+ if (!upstream) {
73
+ return res.status(400).send('Missing X-Liquid-Proxy-Target header');
74
+ }
75
+
76
+ // Everything after the proxy mount, e.g. 'api/auth/authenticate'
77
+ const forwardedPath = req.params[0];
78
+ const targetUrl = `${upstream}/${forwardedPath}`;
62
79
 
63
80
  const response = await fetch(targetUrl, {
64
81
  method: req.method,
65
82
  headers: {
66
83
  ...req.headers,
67
- host: 'api.liquidcommerce.us'
84
+ host: new URL(upstream).host
68
85
  },
69
86
  body: ['GET', 'HEAD'].includes(req.method) ? undefined : JSON.stringify(req.body)
70
87
  });
@@ -15,7 +15,8 @@ The Elements SDK requires modern browser features (Web Components + Shadow DOM).
15
15
  - Shadow DOM
16
16
  - ES2018 JavaScript
17
17
  - Fetch API
18
- - LocalStorage
18
+
19
+ **LocalStorage (optional, recommended):** used as a fast path for session persistence (cart/address). When unavailable (incognito, Safari/Firefox private mode, in-app webviews, cross-origin iframes), the SDK falls back to a generated device fingerprint plus server-side session persistence, so functionality is preserved.
19
20
 
20
21
  ## Server-Side Rendering (SSR)
21
22
 
@@ -19,9 +19,9 @@ class SDKError extends Error {
19
19
 
20
20
  ```javascript
21
21
  try {
22
- await window.LiquidCommerce.elements.injectProductElement([
23
- { containerId: 'product', identifier: 'invalid_id' }
24
- ]);
22
+ // Structural input errors throw a catchable SDKError — e.g. a non-array
23
+ // argument or an empty array:
24
+ await window.LiquidCommerce.elements.injectProductElement([]);
25
25
  } catch (error) {
26
26
  if (error.name === 'SDKError') {
27
27
  console.error('SDK Error:', error);
@@ -29,13 +29,18 @@ try {
29
29
  }
30
30
  ```
31
31
 
32
+ > A well-formed entry with an invalid product identifier does **not** throw — it renders an error view inside the component and sets an error in the store. `try/catch` here only catches structural input errors (a non-array argument or an empty array).
33
+
32
34
  ## Error Isolation
33
35
 
34
- The SDK catches and contains its own errors so your app keeps running:
36
+ Component failures are contained — a component that fails to load renders an error view and logs to the console without crashing your page. Action methods (like `cart.addProduct`) emit a `*_FAILED` event on failure, and re-throw only on an unexpected error; several soft-failure paths (e.g. no product found, no items added) emit the failure event but still resolve. Wrap calls in try/catch **and** listen for the corresponding `*_failed` event to reliably detect failures:
35
37
 
36
38
  ```javascript
37
- window.LiquidCommerce.elements.actions.cart.addProduct([/* invalid */]);
38
- console.log('App still working');
39
+ try {
40
+ await window.LiquidCommerce.elements.actions.cart.addProduct([/* invalid */]);
41
+ } catch (error) {
42
+ console.log('Handled add-to-cart failure');
43
+ }
39
44
  ```
40
45
 
41
46
  ## Error Events
@@ -55,7 +60,7 @@ window.addEventListener('lce:actions.address_failed', (event) => {
55
60
 
56
61
  // Checkout submit failed
57
62
  window.addEventListener('lce:actions.checkout_submit_failed', (event) => {
58
- console.error('Checkout failed:', event.detail.data.error);
63
+ console.error('Checkout failed:', event.detail.data.message);
59
64
  });
60
65
  ```
61
66
 
@@ -44,9 +44,7 @@ setTimeout(async () => {
44
44
  ## 5) Let the SDK Handle Media Optimization
45
45
 
46
46
  The SDK automatically:
47
- - Lazy loads images
48
- - Uses responsive image sizes
49
- - Virtualizes carousel images
47
+ - Lazy loads carousel/thumbnail images (native `loading="lazy"`)
50
48
 
51
49
  ## Related Docs
52
50
 
@@ -60,7 +60,7 @@ Common setup issues and how to resolve them.
60
60
 
61
61
  **Symptoms:** Console warning "This SDK is designed for the browser. Calls made during SSR return null."
62
62
 
63
- This is expected behavior. The SDK ships an SSR stub that is automatically resolved when bundled for Node.js (via the `node` export condition in `package.json`). The stub exports all types and enums for TypeScript compatibility and returns `null` from factory functions (`Elements`, `ElementsBuilder`, `ElementsCheckout`).
63
+ This is expected behavior. The SDK ships SSR stubs that are automatically resolved when bundled for Node.js (via the `node` export condition in `package.json`). There are two: the main build's stub (the `.` export) provides `Elements` and `ElementsBuilder` and warns with the `[LiquidCommerce Elements]` prefix; the checkout build's stub (the `./checkout` export) provides `ElementsCheckout` and warns with the `[LiquidCommerce Checkout]` prefix. Both re-export their types and enums for TypeScript compatibility and return `null` from the factory functions.
64
64
 
65
65
  **No action required** — initialize the SDK in a client-only lifecycle hook (`useEffect`, `onMounted`, etc.) and the real client will activate in the browser.
66
66
 
@@ -72,8 +72,8 @@ This is expected behavior. The SDK ships an SSR stub that is automatically resol
72
72
 
73
73
  **Fixes:**
74
74
  - Use `customTheme` in the client configuration to style components -- external CSS cannot penetrate Shadow DOM.
75
- - For debugging, enable `development.openShadowDom: true` to disable Shadow DOM temporarily.
76
- - Use the debug panel (`debugMode: 'panel'`) to inspect component state.
75
+ - For debugging, enable `development.openShadowDom: true` to make the shadow root open (`mode: 'open'`) so you can inspect component internals in DevTools (via `element.shadowRoot`). This does **not** disable style isolation — external CSS still cannot reach the components; use `customTheme` to style them. (Forced off in production.)
76
+ - Use the debug panel (`debugMode: 'panel'`) to inspect SDK logs, events, and GTM activity in real time — it surfaces a live stream of logger output and pubsub/GTM events (not component internal state), and auto-enables only in non-production environments.
77
77
 
78
78
  ## Component Not Updating After Data Changes
79
79
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "LiquidCommerce Elements SDK",
4
4
  "license": "UNLICENSED",
5
5
  "author": "LiquidCommerce Team",
6
- "version": "2.7.21",
6
+ "version": "2.7.22",
7
7
  "homepage": "https://docs.liquidcommerce.co/elements-sdk",
8
8
  "repository": {
9
9
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "module": "./dist/index.esm.js",
16
16
  "types": "./dist/types/index.d.ts",
17
- "packageManager": "pnpm@10.33.4",
17
+ "packageManager": "pnpm@11.8.0",
18
18
  "exports": {
19
19
  ".": {
20
20
  "types": "./dist/types/index.d.ts",
@@ -77,7 +77,7 @@
77
77
  "embeddable commerce"
78
78
  ],
79
79
  "devDependencies": {
80
- "@biomejs/biome": "^2.4.16",
80
+ "@biomejs/biome": "^2.5.0",
81
81
  "@commitlint/cli": "^21.0.2",
82
82
  "@commitlint/config-conventional": "^21.0.2",
83
83
  "@rollup/plugin-alias": "^6.0.0",
@@ -93,27 +93,18 @@
93
93
  "@semantic-release/npm": "^13.1.5",
94
94
  "@semantic-release/release-notes-generator": "^14.1.1",
95
95
  "@types/core-js": "^2.5.8",
96
- "@types/node": "^25.9.1",
97
- "conventional-changelog": "^7.2.0",
96
+ "@types/node": "^26.0.0",
97
+ "conventional-changelog": "^7.2.1",
98
98
  "husky": "^9.1.7",
99
99
  "process": "^0.11.10",
100
- "rollup": "^4.61.0",
100
+ "rollup": "^4.62.2",
101
101
  "rollup-obfuscator": "^4.1.1",
102
102
  "rollup-plugin-typescript2": "^0.37.0",
103
- "semantic-release": "^25.0.3",
103
+ "semantic-release": "^25.0.5",
104
104
  "ts-node": "^10.9.2",
105
- "typescript": "5.9.3"
105
+ "typescript": "6.0.3"
106
106
  },
107
107
  "engines": {
108
108
  "node": ">=22"
109
- },
110
- "pnpm": {
111
- "peerDependencyRules": {
112
- "ignoreMissing": []
113
- },
114
- "onlyBuiltDependencies": [
115
- "@biomejs/biome",
116
- "javascript-obfuscator"
117
- ]
118
109
  }
119
110
  }