@liquidcommerce/elements-sdk 2.2.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +1608 -557
  2. package/dist/index.esm.js +10170 -8144
  3. package/dist/types/core/auth.service.d.ts +10 -4
  4. package/dist/types/core/base-component.service.d.ts +3 -0
  5. package/dist/types/core/circuit-breaker.service.d.ts +54 -0
  6. package/dist/types/core/client/client-action.service.d.ts +13 -11
  7. package/dist/types/core/client/client-config.service.d.ts +5 -3
  8. package/dist/types/core/command/common-command.service.d.ts +2 -1
  9. package/dist/types/core/debug-panel/debug-panel.service.d.ts +43 -0
  10. package/dist/types/core/debug-panel/debug-panel.styles.d.ts +1 -0
  11. package/dist/types/core/fingerprint.service.d.ts +4 -9
  12. package/dist/types/core/google-tag-manager.service.d.ts +127 -2
  13. package/dist/types/core/logger/logger-factory.d.ts +3 -0
  14. package/dist/types/core/logger/logger.service.d.ts +8 -5
  15. package/dist/types/core/pubsub/interfaces/core.interface.d.ts +2 -3
  16. package/dist/types/core/pubsub/interfaces/product.interface.d.ts +0 -5
  17. package/dist/types/core/store/interfaces/cart.interface.d.ts +0 -1
  18. package/dist/types/core/store/interfaces/checkout.interface.d.ts +0 -1
  19. package/dist/types/core/store/interfaces/core.interface.d.ts +2 -2
  20. package/dist/types/core/store/interfaces/product.interface.d.ts +0 -1
  21. package/dist/types/core/store/store.service.d.ts +1 -0
  22. package/dist/types/core/telemetry/telemetry.interface.d.ts +80 -0
  23. package/dist/types/core/telemetry/telemetry.service.d.ts +27 -0
  24. package/dist/types/enums/core.enum.d.ts +0 -1
  25. package/dist/types/enums/debug.enum.d.ts +6 -0
  26. package/dist/types/enums/index.d.ts +1 -0
  27. package/dist/types/interfaces/core.interface.d.ts +2 -2
  28. package/dist/types/modules/address/address.command.d.ts +1 -3
  29. package/dist/types/modules/cart/cart.commands.d.ts +1 -1
  30. package/dist/types/modules/cart/cart.component.d.ts +1 -2
  31. package/dist/types/modules/cart/components/cart-footer.component.d.ts +1 -0
  32. package/dist/types/modules/cart/components/cart-item.component.d.ts +2 -6
  33. package/dist/types/modules/checkout/checkout.commands.d.ts +3 -2
  34. package/dist/types/modules/checkout/checkout.component.d.ts +1 -2
  35. package/dist/types/modules/checkout/components/checkout-summary-section.component.d.ts +2 -0
  36. package/dist/types/modules/checkout/components/information/checkout-delivery-information-form.component.d.ts +1 -1
  37. package/dist/types/modules/checkout/components/summary/checkout-item-quantity.component.d.ts +0 -2
  38. package/dist/types/modules/checkout/components/summary/checkout-item.component.d.ts +2 -1
  39. package/dist/types/modules/checkout/components/summary/checkout-items.component.d.ts +1 -0
  40. package/dist/types/modules/checkout/components/summary/checkout-place-order-button.component.d.ts +0 -1
  41. package/dist/types/modules/checkout/constant.d.ts +0 -1
  42. package/dist/types/modules/product/components/index.d.ts +1 -0
  43. package/dist/types/modules/product/components/product-add-to-cart-section.component.d.ts +1 -0
  44. package/dist/types/modules/product/components/product-interactions.component.d.ts +4 -1
  45. package/dist/types/modules/product/components/product-price.component.d.ts +1 -0
  46. package/dist/types/modules/product/components/product-retailers.component.d.ts +1 -0
  47. package/dist/types/modules/product/product.commands.d.ts +1 -1
  48. package/dist/types/modules/ui-components/engraving/engraving-form.component.d.ts +13 -11
  49. package/dist/types/modules/ui-components/engraving/engraving-view.component.d.ts +4 -9
  50. package/dist/types/static/icon/index.d.ts +0 -1
  51. package/dist/types/utils/format.d.ts +2 -1
  52. package/docs/ACTIONS.md +1235 -0
  53. package/docs/BROWSER_SUPPORT.md +279 -0
  54. package/docs/CONFIGURATION.md +613 -0
  55. package/docs/DOCUMENTATION_INDEX.md +311 -0
  56. package/docs/EVENTS.md +532 -0
  57. package/docs/PROXY.md +228 -0
  58. package/docs/THEMING.md +592 -0
  59. package/docs/TROUBLESHOOTING.md +755 -0
  60. package/package.json +17 -17
  61. package/umd/elements.js +1 -1
  62. package/dist/types/static/icon/completed.icon.d.ts +0 -2
@@ -0,0 +1,613 @@
1
+ # Configuration Reference
2
+
3
+ Complete reference for all LiquidCommerce Elements SDK configuration options.
4
+
5
+ ## Basic Configuration
6
+
7
+ ```javascript
8
+ const client = await Elements('YOUR_API_KEY', {
9
+ env: 'production',
10
+ debugMode: 'none',
11
+ isBuilder: false,
12
+ customTheme: {},
13
+ proxy: {},
14
+ promoTicker: []
15
+ });
16
+ ```
17
+
18
+ ## Configuration Options
19
+
20
+ ### `env` (required)
21
+
22
+ **Type:** `'local' | 'development' | 'staging' | 'production'`
23
+ **Default:** `'production'`
24
+
25
+ Specifies the API environment to use.
26
+
27
+ ```javascript
28
+ env: 'production' // Live environment
29
+ env: 'staging' // Pre-production testing
30
+ env: 'development' // Development with extra logging
31
+ env: 'local' // Local development
32
+ ```
33
+
34
+ **Environment URLs:**
35
+ - `production`: `https://elements.liquidcommerce.us`
36
+ - `staging`: `https://staging-elements.liquidcommerce.us`
37
+ - `development`: `https://dev-elements.liquidcommerce.us`
38
+ - `local`: `http://localhost:3000`
39
+
40
+ ### `debugMode`
41
+
42
+ **Type:** `'none' | 'console' | 'panel'`
43
+ **Default:** `'none'`
44
+
45
+ Controls logging and debugging output.
46
+
47
+ ```javascript
48
+ debugMode: 'none' // No logging (production)
49
+ debugMode: 'console' // Console logs only
50
+ debugMode: 'panel' // Visual debug panel + console
51
+ ```
52
+
53
+ **Debug panel features:**
54
+ - Real-time event stream
55
+ - API call inspector
56
+ - State viewer
57
+ - Performance metrics
58
+
59
+ **Note:** Automatically disabled in production environment regardless of setting.
60
+
61
+ ### `isBuilder`
62
+
63
+ **Type:** `boolean`
64
+ **Default:** `false`
65
+
66
+ Enables builder mode for theme development and testing.
67
+
68
+ ```javascript
69
+ isBuilder: true // Enables builder.* methods
70
+ ```
71
+
72
+ **Builder mode provides:**
73
+ - `client.builder.updateComponentGlobalConfigs()`
74
+ - `client.builder.updateProductComponent()`
75
+ - `client.builder.updateCartComponent()`
76
+ - `client.builder.updateCheckoutComponent()`
77
+ - `client.builder.updateAddressComponent()`
78
+
79
+ **Use case:** Theme customization and testing.
80
+
81
+ ### `customTheme`
82
+
83
+ **Type:** `object`
84
+ **Default:** `{}`
85
+
86
+ Custom theme configuration. See [`THEMING.md`](./THEMING.md) for complete reference.
87
+
88
+ ```javascript
89
+ customTheme: {
90
+ global: {
91
+ colors: {
92
+ primary: '#007bff',
93
+ secondary: '#6c757d'
94
+ },
95
+ typography: {
96
+ fontFamily: 'Inter, sans-serif',
97
+ fontSize: '16px'
98
+ },
99
+ layout: {
100
+ enablePersonalization: true,
101
+ personalizationText: 'Personalize your product',
102
+ personalizationCardStyle: 'outlined',
103
+ allowPromoCodes: true,
104
+ inputFieldStyle: 'outlined',
105
+ poweredByMode: 'light' // Can be customized
106
+ // Note: showPoweredBy cannot be customized (controlled by LiquidCommerce)
107
+ }
108
+ },
109
+ product: { /* product theme */ },
110
+ cart: { /* cart theme */ },
111
+ checkout: { /* checkout theme */ },
112
+ address: { /* address theme */ }
113
+ }
114
+ ```
115
+
116
+ **Key Theme Categories:**
117
+
118
+ - **`global`**: Affects all components (colors, fonts, personalization settings)
119
+ - **`product`**: Product display customization
120
+ - **`cart`**: Cart drawer and item display
121
+ - **`checkout`**: Checkout flow and completion screen
122
+ - **`address`**: Address input and selection
123
+
124
+ **Personalization (Engraving) Settings:**
125
+
126
+ The personalization feature is configured in `global.layout`:
127
+
128
+ ```javascript
129
+ customTheme: {
130
+ global: {
131
+ layout: {
132
+ enablePersonalization: true, // Enable/disable engraving globally
133
+ personalizationText: 'Make it yours', // Button text for adding personalization
134
+ personalizationCardStyle: 'outlined' // Style: 'outlined' | 'filled'
135
+ }
136
+ }
137
+ }
138
+ ```
139
+
140
+ - **`enablePersonalization`**: Master switch for engraving feature
141
+ - **`personalizationText`**: Call-to-action text on product pages
142
+ - **`personalizationCardStyle`**: Visual style in cart/checkout ('outlined' or 'filled')
143
+ - **`poweredByMode`**: Visual mode for "Powered by" branding ('light' or 'dark')
144
+
145
+ **Protected Setting:**
146
+ ⚠️ **`showPoweredBy`** is a read-only setting controlled by LiquidCommerce. This paid feature cannot be customized through the `customTheme` configuration and is managed via your LiquidCommerce dashboard. However, you can customize `poweredByMode` to match your site's theme.
147
+
148
+ ### `proxy`
149
+
150
+ **Type:** `object`
151
+ **Default:** `null`
152
+
153
+ Proxy configuration for routing API requests through your server.
154
+
155
+ ```javascript
156
+ proxy: {
157
+ baseUrl: 'https://yourdomain.com/api/liquidcommerce',
158
+ headers: {
159
+ 'X-Custom-Header': 'value'
160
+ }
161
+ }
162
+ ```
163
+
164
+ **Properties:**
165
+
166
+ #### `proxy.baseUrl`
167
+
168
+ **Type:** `string` (required)
169
+
170
+ Base URL for your proxy endpoint.
171
+
172
+ ```javascript
173
+ baseUrl: 'https://yourdomain.com/api/liquidcommerce'
174
+ ```
175
+
176
+ The SDK automatically appends API paths: `/api/products`, `/api/cart`, etc.
177
+
178
+ #### `proxy.headers`
179
+
180
+ **Type:** `object` (optional)
181
+
182
+ Custom headers to include in proxied requests.
183
+
184
+ ```javascript
185
+ headers: {
186
+ 'X-Custom-Auth': 'your-token',
187
+ 'X-Request-Id': 'unique-id'
188
+ }
189
+ ```
190
+
191
+ See [`PROXY.md`](./PROXY.md) for implementation guide.
192
+
193
+ ### `promoTicker`
194
+
195
+ **Type:** `array`
196
+ **Default:** `[]`
197
+
198
+ Promotional ticker configuration for rotating messages.
199
+
200
+ ```javascript
201
+ promoTicker: [
202
+ {
203
+ promoCode: 'FREESHIP',
204
+ text: ['Free Shipping Today!', 'Use code FREESHIP'],
205
+ separator: '•',
206
+ activeFrom: '2025-01-01T00:00:00Z',
207
+ activeUntil: '2025-12-31T23:59:59Z'
208
+ }
209
+ ]
210
+ ```
211
+
212
+ **Properties:**
213
+
214
+ #### `promoCode` (required)
215
+
216
+ **Type:** `string`
217
+
218
+ The promo code to apply when clicked.
219
+
220
+ #### `text` (required)
221
+
222
+ **Type:** `string[]`
223
+
224
+ Array of messages to rotate through.
225
+
226
+ ```javascript
227
+ text: ['Message 1', 'Message 2', 'Message 3']
228
+ ```
229
+
230
+ #### `separator` (optional)
231
+
232
+ **Type:** `string`
233
+ **Default:** `'•'`
234
+
235
+ Separator between rotating messages.
236
+
237
+ ```javascript
238
+ separator: '•' // Bullet
239
+ separator: '|' // Pipe
240
+ separator: '→' // Arrow
241
+ ```
242
+
243
+ #### `activeFrom` (optional)
244
+
245
+ **Type:** `string` (ISO 8601)
246
+
247
+ Start date/time for the promotion.
248
+
249
+ ```javascript
250
+ activeFrom: '2025-01-01T00:00:00Z'
251
+ ```
252
+
253
+ #### `activeUntil` (optional)
254
+
255
+ **Type:** `string` (ISO 8601)
256
+
257
+ End date/time for the promotion.
258
+
259
+ ```javascript
260
+ activeUntil: '2025-12-31T23:59:59Z'
261
+ ```
262
+
263
+ **Note:** Only active promotions are displayed.
264
+
265
+ ## Auto-Initialization Configuration
266
+
267
+ When using auto-initialization, configure via `data-` attributes on the script tag.
268
+
269
+ ### Required Attributes
270
+
271
+ ```html
272
+ <script
273
+ data-liquid-commerce-elements
274
+ data-token="YOUR_API_KEY"
275
+ src="https://assets-elements.liquidcommerce.us/all/elements.js"
276
+ ></script>
277
+ ```
278
+
279
+ #### `data-liquid-commerce-elements`
280
+
281
+ **Type:** flag (no value)
282
+
283
+ Enables auto-initialization.
284
+
285
+ #### `data-token`
286
+
287
+ **Type:** `string` (required)
288
+
289
+ Your LiquidCommerce API key.
290
+
291
+ ### Optional Attributes
292
+
293
+ #### `data-env`
294
+
295
+ **Type:** `'production' | 'staging' | 'development' | 'local'`
296
+ **Default:** `'production'`
297
+
298
+ ```html
299
+ data-env="production"
300
+ ```
301
+
302
+ #### `data-debug-mode`
303
+
304
+ **Type:** `'console' | 'panel'`
305
+ **Default:** Not set
306
+
307
+ ```html
308
+ data-debug-mode="console"
309
+ ```
310
+
311
+ #### `data-cart-id`
312
+
313
+ **Type:** `string`
314
+
315
+ Container ID for cart button.
316
+
317
+ ```html
318
+ data-cart-id="header-cart"
319
+ ```
320
+
321
+ #### `data-show-cart-items`
322
+
323
+ **Type:** flag (no value)
324
+
325
+ Show item count on cart button.
326
+
327
+ ```html
328
+ data-show-cart-items
329
+ ```
330
+
331
+ #### `data-hide-cart-floating-button`
332
+
333
+ **Type:** flag (no value)
334
+
335
+ Hide the default floating cart button.
336
+
337
+ ```html
338
+ data-hide-cart-floating-button
339
+ ```
340
+
341
+ ### Product Configuration
342
+
343
+ #### Method 1: Direct Attributes
344
+
345
+ ```html
346
+ data-container-1="product-1"
347
+ data-product-1="00619947000020"
348
+ data-container-2="product-2"
349
+ data-product-2="00832889005513"
350
+ ```
351
+
352
+ #### Method 2: JSON Configuration
353
+
354
+ ```html
355
+ <script data-liquid-commerce-elements-products type="application/json">
356
+ [
357
+ { "containerId": "product-1", "identifier": "00619947000020" },
358
+ { "containerId": "product-2", "identifier": "00832889005513" }
359
+ ]
360
+ </script>
361
+ ```
362
+
363
+ #### Method 3: Annotated Elements
364
+
365
+ ```html
366
+ <div data-lce-product="00619947000020"></div>
367
+ <div data-lce-product="00832889005513"></div>
368
+ ```
369
+
370
+ ### URL Parameter Configuration
371
+
372
+ #### `data-product-param`
373
+
374
+ **Type:** `string`
375
+
376
+ URL parameter name for auto-adding products to cart.
377
+
378
+ ```html
379
+ data-product-param="lce_product"
380
+ ```
381
+
382
+ **Usage:** `?lce_product=00619947000020&lce_fulfillment=shipping`
383
+
384
+ #### `data-product-fulfillment-type-param`
385
+
386
+ **Type:** `string`
387
+
388
+ URL parameter name for fulfillment type.
389
+
390
+ ```html
391
+ data-product-fulfillment-type-param="lce_fulfillment"
392
+ ```
393
+
394
+ **Values:** `shipping` or `onDemand`
395
+
396
+ #### `data-promo-code-param`
397
+
398
+ **Type:** `string`
399
+
400
+ URL parameter name for auto-applying promo codes.
401
+
402
+ ```html
403
+ data-promo-code-param="lce_promo"
404
+ ```
405
+
406
+ **Usage:** `?lce_promo=SUMMER20`
407
+
408
+ ### Promo Ticker Configuration
409
+
410
+ #### `data-promo-code`
411
+
412
+ **Type:** `string`
413
+
414
+ Promo code to apply.
415
+
416
+ ```html
417
+ data-promo-code="FREESHIP"
418
+ ```
419
+
420
+ #### `data-promo-text`
421
+
422
+ **Type:** `string` (pipe-separated)
423
+
424
+ Messages to display.
425
+
426
+ ```html
427
+ data-promo-text="Free Shipping Today!|Use code FREESHIP"
428
+ ```
429
+
430
+ #### `data-promo-separator`
431
+
432
+ **Type:** `string`
433
+ **Default:** `'•'`
434
+
435
+ ```html
436
+ data-promo-separator="•"
437
+ ```
438
+
439
+ #### `data-promo-active-from`
440
+
441
+ **Type:** `string` (ISO 8601)
442
+
443
+ ```html
444
+ data-promo-active-from="2025-01-01T00:00:00Z"
445
+ ```
446
+
447
+ #### `data-promo-active-until`
448
+
449
+ **Type:** `string` (ISO 8601)
450
+
451
+ ```html
452
+ data-promo-active-until="2025-12-31T23:59:59Z"
453
+ ```
454
+
455
+ ## TypeScript Types
456
+
457
+ ### `ILiquidCommerceElementsConfig`
458
+
459
+ ```typescript
460
+ interface ILiquidCommerceElementsConfig {
461
+ env?: 'local' | 'development' | 'staging' | 'production';
462
+ debugMode?: 'none' | 'console' | 'panel';
463
+ isBuilder?: boolean;
464
+ customTheme?: IClientCustomThemeConfig;
465
+ proxy?: IElementsProxyConfig;
466
+ promoTicker?: IPromoTicker[];
467
+ }
468
+ ```
469
+
470
+ ### `IElementsProxyConfig`
471
+
472
+ ```typescript
473
+ interface IElementsProxyConfig {
474
+ baseUrl: string;
475
+ headers?: Record<string, string>;
476
+ }
477
+ ```
478
+
479
+ ### `IPromoTicker`
480
+
481
+ ```typescript
482
+ interface IPromoTicker {
483
+ promoCode: string;
484
+ text: string[];
485
+ separator: string;
486
+ activeFrom: string; // ISO 8601 UTC format
487
+ activeUntil: string; // ISO 8601 UTC format
488
+ }
489
+ ```
490
+
491
+ ## Configuration Examples
492
+
493
+ ### Production Setup
494
+
495
+ ```javascript
496
+ const client = await Elements('YOUR_PRODUCTION_API_KEY', {
497
+ env: 'production',
498
+ debugMode: 'none',
499
+ proxy: {
500
+ baseUrl: 'https://yourdomain.com/api/liquidcommerce'
501
+ },
502
+ customTheme: {
503
+ global: {
504
+ colors: {
505
+ primary: '#007bff'
506
+ }
507
+ }
508
+ }
509
+ });
510
+ ```
511
+
512
+ ### Development Setup
513
+
514
+ ```javascript
515
+ const client = await Elements('YOUR_DEV_API_KEY', {
516
+ env: 'development',
517
+ debugMode: 'panel',
518
+ isBuilder: true,
519
+ customTheme: {
520
+ global: {
521
+ colors: {
522
+ primary: '#ff6b6b'
523
+ }
524
+ }
525
+ }
526
+ });
527
+ ```
528
+
529
+ ### With Promo Ticker
530
+
531
+ ```javascript
532
+ const client = await Elements('YOUR_API_KEY', {
533
+ env: 'production',
534
+ promoTicker: [
535
+ {
536
+ promoCode: 'SUMMER20',
537
+ text: ['20% Off Summer Sale!', 'Use code SUMMER20'],
538
+ separator: '•',
539
+ activeFrom: '2025-06-01T00:00:00Z',
540
+ activeUntil: '2025-08-31T23:59:59Z'
541
+ }
542
+ ]
543
+ });
544
+ ```
545
+
546
+ ## Configuration Validation
547
+
548
+ The SDK validates configuration on initialization:
549
+
550
+ ```javascript
551
+ try {
552
+ const client = await Elements('YOUR_API_KEY', {
553
+ env: 'invalid' // ❌ Will throw error
554
+ });
555
+ } catch (error) {
556
+ console.error('Invalid configuration:', error);
557
+ }
558
+ ```
559
+
560
+ **Common validation errors:**
561
+ - Invalid environment value
562
+ - Missing API key
563
+ - Invalid proxy baseUrl
564
+ - Malformed promo ticker dates
565
+
566
+ ## Environment Variables
567
+
568
+ For framework integrations, use environment variables:
569
+
570
+ ### React / Next.js
571
+
572
+ ```javascript
573
+ const client = await Elements(process.env.REACT_APP_LCE_API_KEY, {
574
+ env: process.env.REACT_APP_LCE_ENV || 'production'
575
+ });
576
+ ```
577
+
578
+ ### Vue
579
+
580
+ ```javascript
581
+ const client = await Elements(process.env.VUE_APP_LCE_API_KEY, {
582
+ env: process.env.VUE_APP_LCE_ENV || 'production'
583
+ });
584
+ ```
585
+
586
+ ### Node.js / Server-Side
587
+
588
+ ```javascript
589
+ const client = await Elements(process.env.LCE_API_KEY, {
590
+ env: process.env.NODE_ENV === 'production' ? 'production' : 'development'
591
+ });
592
+ ```
593
+
594
+ ## Configuration Best Practices
595
+
596
+ 1. **Use environment variables** for API keys (never hardcode)
597
+ 2. **Enable debug mode only in development** (security risk in production)
598
+ 3. **Pin to specific version** in production for stability
599
+ 4. **Configure proxy** if targeting ad blocker-heavy audiences
600
+ 5. **Use minimal theme overrides** for optimal performance
601
+ 6. **Set GTM container ID** for analytics tracking
602
+ 7. **Test configuration** in staging before production
603
+ 8. **Validate promo dates** to avoid expired promotions
604
+ 9. **Use builder mode** only in development (performance overhead)
605
+ 10. **Monitor proxy** health if using custom proxy
606
+
607
+ ## Related Documentation
608
+
609
+ - [Theming Guide](./THEMING.md) - Complete theme configuration reference
610
+ - [Proxy Setup](./PROXY.md) - Proxy implementation guide
611
+ - [Actions Reference](./ACTIONS.md) - Programmatic control API
612
+ - [Events Reference](./EVENTS.md) - Event system and tracking
613
+