@ekomerc/storefront 0.1.0 → 0.1.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.d.ts CHANGED
@@ -1,16 +1,55 @@
1
+ import { GtmStandardEventName } from '@ekomerc/tracking-policy';
1
2
  import { Result } from 'neverthrow';
3
+ import { TrackingPolicyEventType } from '@ekomerc/tracking-policy';
4
+ import { TrackingProvider } from '@ekomerc/tracking-policy';
2
5
 
3
6
  export declare interface AccountOperations {
7
+ /**
8
+ * Fetch paginated orders for the authenticated customer.
9
+ *
10
+ * @param args - Forward or backward pagination options.
11
+ * @returns Paginated customer orders.
12
+ */
4
13
  orders(args?: {
5
14
  first?: number;
6
15
  after?: string;
7
16
  last?: number;
8
17
  before?: string;
9
18
  }): Promise<Result<PaginatedResult<CustomerOrder>, StorefrontError>>;
19
+ /**
20
+ * Fetch saved addresses for the authenticated customer.
21
+ *
22
+ * @returns Customer addresses.
23
+ */
10
24
  addresses(): Promise<Result<CustomerAddress[], StorefrontError>>;
25
+ /**
26
+ * Create a saved customer address.
27
+ *
28
+ * @param input - Address fields to create.
29
+ * @returns The created address.
30
+ */
11
31
  createAddress(input: CustomerAddressInput): Promise<Result<CustomerAddress, StorefrontError>>;
32
+ /**
33
+ * Update a saved customer address.
34
+ *
35
+ * @param addressId - Address identifier to update.
36
+ * @param input - Address fields to change.
37
+ * @returns The updated address.
38
+ */
12
39
  updateAddress(addressId: string, input: CustomerAddressUpdateInput): Promise<Result<CustomerAddress, StorefrontError>>;
40
+ /**
41
+ * Delete a saved customer address.
42
+ *
43
+ * @param addressId - Address identifier to delete.
44
+ * @returns The deleted address identifier.
45
+ */
13
46
  deleteAddress(addressId: string): Promise<Result<string, StorefrontError>>;
47
+ /**
48
+ * Update the authenticated customer's profile fields.
49
+ *
50
+ * @param input - Customer fields to update.
51
+ * @returns The updated customer profile.
52
+ */
14
53
  update(input: CustomerUpdateInput): Promise<Result<Customer, StorefrontError>>;
15
54
  }
16
55
 
@@ -18,8 +57,8 @@ export declare interface Address {
18
57
  firstName: string | null;
19
58
  lastName: string | null;
20
59
  company: string | null;
21
- address1: string;
22
- address2: string | null;
60
+ addressLine1: string;
61
+ addressLine2: string | null;
23
62
  city: string;
24
63
  province: string | null;
25
64
  provinceCode: string | null;
@@ -29,7 +68,76 @@ export declare interface Address {
29
68
  phone: string | null;
30
69
  }
31
70
 
32
- declare interface AnalyticsClickIds {
71
+ /**
72
+ * Input provided to a browser adapter when dispatching an analytics event.
73
+ */
74
+ export declare interface AnalyticsAdapterDispatchInput {
75
+ event: AnalyticsBrowserEvent;
76
+ consent: AnalyticsConsentUpdate;
77
+ }
78
+
79
+ /**
80
+ * Result returned by browser adapter dispatch and consent-update hooks.
81
+ */
82
+ export declare type AnalyticsAdapterOperationResult = void | {
83
+ status: "success";
84
+ } | AnalyticsAdapterOperationSkippedResult;
85
+
86
+ /**
87
+ * Structured result returned when a browser adapter intentionally skips dispatch.
88
+ */
89
+ export declare interface AnalyticsAdapterOperationSkippedResult {
90
+ status: "skipped";
91
+ reason: "runtime_unavailable";
92
+ }
93
+
94
+ /**
95
+ * Reasons a browser adapter may skip dispatch instead of throwing.
96
+ */
97
+ export declare type AnalyticsAdapterSkipReason = "unsupported_event" | "consent_blocked" | "runtime_unavailable";
98
+
99
+ /**
100
+ * Browser-side analytics adapter contract for GTM, Meta, TikTok, or custom integrations.
101
+ */
102
+ export declare interface AnalyticsBrowserAdapter {
103
+ provider: TrackingProvider;
104
+ dispatch(input: AnalyticsAdapterDispatchInput): AnalyticsAdapterOperationResult | Promise<AnalyticsAdapterOperationResult>;
105
+ updateConsent?(input: AnalyticsConsentUpdate): AnalyticsAdapterOperationResult | Promise<AnalyticsAdapterOperationResult>;
106
+ }
107
+
108
+ /**
109
+ * Canonical browser analytics event shape used by the storefront SDK.
110
+ */
111
+ export declare interface AnalyticsBrowserEvent {
112
+ schemaVersion: 1;
113
+ eventId: string;
114
+ eventType: TrackingPolicyEventType;
115
+ occurredAt: string;
116
+ sessionId: string;
117
+ visitorId: string;
118
+ customerId: string | null;
119
+ consentState: AnalyticsConsentState;
120
+ context: AnalyticsEventContextPayload;
121
+ referrer: string | null;
122
+ utm: AnalyticsUtm;
123
+ clickIds: AnalyticsClickIds;
124
+ device: AnalyticsBrowserEventDevice;
125
+ properties: AnalyticsProperties;
126
+ }
127
+
128
+ /**
129
+ * Best-effort browser device fingerprint attached to an analytics event.
130
+ */
131
+ export declare interface AnalyticsBrowserEventDevice {
132
+ deviceType: string;
133
+ deviceOs: string | null;
134
+ deviceBrowser: string | null;
135
+ }
136
+
137
+ /**
138
+ * Click identifiers captured from ad platforms and passed through analytics events.
139
+ */
140
+ export declare interface AnalyticsClickIds {
33
141
  schemaVersion: 1;
34
142
  capturedAt: string | null;
35
143
  gclid: string | null;
@@ -39,13 +147,23 @@ declare interface AnalyticsClickIds {
39
147
  fbclid: string | null;
40
148
  }
41
149
 
42
- declare type AnalyticsConsentState = "granted" | "denied" | "unknown";
150
+ /**
151
+ * Consent states emitted with browser-side analytics events.
152
+ */
153
+ export declare type AnalyticsConsentState = "granted" | "denied" | "unknown";
154
+
155
+ /**
156
+ * Consent state payload passed to browser adapters and diagnostics.
157
+ */
158
+ export declare interface AnalyticsConsentUpdate {
159
+ consentState: AnalyticsConsentState;
160
+ dispatchOnUnknownConsent: AnalyticsDispatchOnUnknownConsent;
161
+ }
43
162
 
44
163
  /**
45
164
  * Optional context overrides for a tracking call.
46
165
  */
47
166
  export declare interface AnalyticsContext {
48
- storeSlug?: string;
49
167
  path?: string;
50
168
  referrer?: string | null;
51
169
  occurredAt?: Date | string;
@@ -64,6 +182,88 @@ export declare interface AnalyticsContext {
64
182
  deviceBrowser?: string | null;
65
183
  }
66
184
 
185
+ /**
186
+ * Diagnostic events emitted by the analytics runtime for ingest and adapter activity.
187
+ */
188
+ export declare type AnalyticsDiagnostic = {
189
+ target: "ingest";
190
+ status: "success";
191
+ event: AnalyticsBrowserEvent;
192
+ response: {
193
+ acceptedCount: number;
194
+ duplicateCount: number;
195
+ rejectedCount: number;
196
+ };
197
+ } | {
198
+ target: "ingest";
199
+ status: "error";
200
+ event: AnalyticsBrowserEvent;
201
+ error: Error;
202
+ } | {
203
+ target: "ingest";
204
+ status: "accepted_unknown";
205
+ event: AnalyticsBrowserEvent;
206
+ } | {
207
+ target: "queue";
208
+ status: "enqueued";
209
+ event: AnalyticsBrowserEvent;
210
+ } | {
211
+ target: "queue";
212
+ status: "flushed";
213
+ count: number;
214
+ } | {
215
+ target: "queue";
216
+ status: "evicted_full";
217
+ event: AnalyticsBrowserEvent;
218
+ } | {
219
+ target: "queue";
220
+ status: "evicted_expired";
221
+ eventId: string;
222
+ } | {
223
+ target: "adapter";
224
+ status: "success";
225
+ provider: TrackingProvider;
226
+ event: AnalyticsBrowserEvent;
227
+ } | {
228
+ target: "adapter";
229
+ status: "skipped";
230
+ provider: TrackingProvider;
231
+ event: AnalyticsBrowserEvent;
232
+ reason: AnalyticsAdapterSkipReason;
233
+ } | {
234
+ target: "adapter";
235
+ status: "error";
236
+ provider: TrackingProvider;
237
+ event: AnalyticsBrowserEvent;
238
+ error: Error;
239
+ } | {
240
+ target: "consent_bridge";
241
+ status: "success";
242
+ provider: TrackingProvider;
243
+ consent: AnalyticsConsentUpdate;
244
+ } | {
245
+ target: "consent_bridge";
246
+ status: "skipped";
247
+ provider: TrackingProvider;
248
+ consent: AnalyticsConsentUpdate;
249
+ reason: "runtime_unavailable";
250
+ } | {
251
+ target: "consent_bridge";
252
+ status: "error";
253
+ provider: TrackingProvider;
254
+ consent: AnalyticsConsentUpdate;
255
+ error: Error;
256
+ } | {
257
+ target: "consent";
258
+ status: "error";
259
+ error: Error;
260
+ };
261
+
262
+ /**
263
+ * Runtime policies controlling how consent gates browser event dispatch.
264
+ */
265
+ export declare type AnalyticsDispatchOnUnknownConsent = boolean;
266
+
67
267
  /**
68
268
  * Error detail for a single ingest payload item.
69
269
  */
@@ -86,10 +286,18 @@ export declare interface AnalyticsErrorItem {
86
286
  message: string;
87
287
  }
88
288
 
289
+ /**
290
+ * Request context attached to each browser analytics event.
291
+ */
292
+ export declare interface AnalyticsEventContextPayload {
293
+ schemaVersion: 1;
294
+ path: string;
295
+ }
296
+
89
297
  /**
90
298
  * Canonical analytics event type values accepted by the storefront ingest endpoint.
91
299
  */
92
- export declare type AnalyticsEventType = "analytics.page_view" | "analytics.product_view" | "analytics.collection_view" | "analytics.search_performed" | "analytics.add_to_cart" | "analytics.remove_from_cart" | "analytics.checkout_started" | "analytics.checkout_step_completed" | "analytics.checkout_completed" | "analytics.custom";
300
+ export declare type AnalyticsEventType = TrackingPolicyEventType;
93
301
 
94
302
  /**
95
303
  * Response summary from the analytics ingest endpoint.
@@ -113,13 +321,17 @@ export declare interface AnalyticsIngestResponse {
113
321
  errors: AnalyticsErrorItem[];
114
322
  }
115
323
 
324
+ export declare interface AnalyticsInitOptions {
325
+ stripUrl?: boolean;
326
+ }
327
+
116
328
  /**
117
- * Primitive value allowed in analytics custom event properties.
329
+ * Primitive JSON values supported inside analytics properties.
118
330
  */
119
331
  export declare type AnalyticsJsonPrimitive = string | number | boolean | null;
120
332
 
121
333
  /**
122
- * Recursive JSON value allowed in analytics custom event properties.
334
+ * Recursive JSON value shape supported by analytics event properties.
123
335
  */
124
336
  export declare type AnalyticsJsonValue = AnalyticsJsonPrimitive | AnalyticsJsonValue[] | {
125
337
  [key: string]: AnalyticsJsonValue;
@@ -186,7 +398,7 @@ export declare interface AnalyticsOperations {
186
398
  export declare type AnalyticsPresetEventName = "page_view" | "product_view" | "collection_view" | "search_performed" | "add_to_cart" | "remove_from_cart" | "checkout_started" | "checkout_step_completed" | "checkout_completed";
187
399
 
188
400
  /**
189
- * Generic analytics event property bag.
401
+ * Arbitrary analytics event properties sent to ingest and browser adapters.
190
402
  */
191
403
  export declare interface AnalyticsProperties {
192
404
  [key: string]: AnalyticsJsonValue;
@@ -197,7 +409,19 @@ export declare interface AnalyticsProperties {
197
409
  * Preset names (e.g. `product_view`) are normalized to `analytics.*` types.
198
410
  * Unknown names are sent as `analytics.custom` with `{ eventName: <name> }`.
199
411
  */
200
- export declare type AnalyticsTrackEventName = AnalyticsPresetEventName | AnalyticsEventType | string;
412
+ export declare type AnalyticsTrackEventName = AnalyticsPresetEventName | AnalyticsEventType;
413
+
414
+ /**
415
+ * UTM parameters captured for a visitor session.
416
+ */
417
+ export declare interface AnalyticsUtm {
418
+ schemaVersion: 1;
419
+ source: string | null;
420
+ medium: string | null;
421
+ campaign: string | null;
422
+ term: string | null;
423
+ content: string | null;
424
+ }
201
425
 
202
426
  export declare interface AppliedDiscount {
203
427
  promotionId: string;
@@ -225,6 +449,12 @@ export declare class AuthError extends StorefrontError {
225
449
  }
226
450
 
227
451
  export declare interface AuthOperations {
452
+ /**
453
+ * Register a customer account and store the returned auth token.
454
+ *
455
+ * @param input - Registration credentials and optional name.
456
+ * @returns The authenticated customer and token.
457
+ */
228
458
  register(input: {
229
459
  email: string;
230
460
  password: string;
@@ -233,6 +463,12 @@ export declare interface AuthOperations {
233
463
  customer: Customer;
234
464
  token: string;
235
465
  }, StorefrontError>>;
466
+ /**
467
+ * Log in an existing customer and store the returned auth token.
468
+ *
469
+ * @param input - Customer login credentials.
470
+ * @returns The authenticated customer and token.
471
+ */
236
472
  login(input: {
237
473
  email: string;
238
474
  password: string;
@@ -240,18 +476,49 @@ export declare interface AuthOperations {
240
476
  customer: Customer;
241
477
  token: string;
242
478
  }, StorefrontError>>;
479
+ /**
480
+ * Remove the stored customer auth token.
481
+ */
243
482
  logout(): void;
483
+ /**
484
+ * Request a password reset email for a customer account.
485
+ *
486
+ * @param email - Customer email address.
487
+ * @returns Reset request success state.
488
+ */
244
489
  requestPasswordReset(email: string): Promise<Result<{
245
490
  success: boolean;
246
491
  }, StorefrontError>>;
492
+ /**
493
+ * Reset a customer password with a reset token.
494
+ *
495
+ * @param input - Reset token and new password.
496
+ * @returns Reset success state.
497
+ */
247
498
  resetPassword(input: {
248
499
  token: string;
249
500
  newPassword: string;
250
501
  }): Promise<Result<{
251
502
  success: boolean;
252
503
  }, StorefrontError>>;
504
+ /**
505
+ * Verify a customer email address with a verification token.
506
+ *
507
+ * @param token - Verification token from email.
508
+ * @returns The verified customer.
509
+ */
253
510
  verifyEmail(token: string): Promise<Result<Customer, StorefrontError>>;
511
+ /**
512
+ * Fetch the currently authenticated customer.
513
+ *
514
+ * @returns The signed-in customer, or `null` when unauthenticated.
515
+ */
254
516
  me(): Promise<Result<Customer | null, StorefrontError>>;
517
+ /**
518
+ * Check whether a customer token is currently stored.
519
+ *
520
+ * @returns `true` when a customer session exists.
521
+ */
255
522
  isLoggedIn(): boolean;
256
523
  }
257
524
 
@@ -261,7 +528,34 @@ export declare interface AvailablePaymentMethod {
261
528
  additionalFee: number;
262
529
  }
263
530
 
531
+ /**
532
+ * Browser-side tracking configuration returned by the storefront `store` query.
533
+ */
534
+ export declare interface BrowserTrackingConfig {
535
+ gtm: GtmBrowserTrackingConfig;
536
+ }
537
+
538
+ /**
539
+ * Converts storefront consent state into a GTM consent-mode update payload.
540
+ */
541
+ export declare function buildGtmConsentModeUpdate({ consentState }: AnalyticsConsentUpdate): GtmConsentModeUpdate;
542
+
543
+ /**
544
+ * Maps a storefront analytics event to a GTM `dataLayer.push()` payload.
545
+ */
546
+ export declare function buildGtmDataLayerEvent(input: AnalyticsAdapterDispatchInput): GtmDataLayerEvent | null;
547
+
548
+ export declare interface BulletListDetailSection extends DetailSectionBase {
549
+ sectionType: "BULLET_LIST";
550
+ content: {
551
+ items: string[];
552
+ };
553
+ }
554
+
264
555
  export declare interface CacheHelpers {
556
+ /**
557
+ * Clear all cached query results for this client instance.
558
+ */
265
559
  clear(): void;
266
560
  }
267
561
 
@@ -305,22 +599,91 @@ export declare interface CartItem {
305
599
  }
306
600
 
307
601
  export declare interface CartOperations {
602
+ /**
603
+ * Load the current cart from the stored cart token.
604
+ *
605
+ * @returns The current cart, or `null` when no cart exists.
606
+ */
308
607
  get(): Promise<Result<Cart | null, StorefrontError>>;
608
+ /**
609
+ * Create a new active cart and persist its token.
610
+ *
611
+ * @returns The newly created cart.
612
+ */
309
613
  create(): Promise<Result<Cart, StorefrontError>>;
614
+ /**
615
+ * Add a product variant to the active cart.
616
+ *
617
+ * @param variantId - Product variant GID (global ID).
618
+ * @param quantity - Quantity to add.
619
+ * @returns The updated cart.
620
+ */
310
621
  addItem(variantId: string, quantity: number): Promise<Result<Cart, StorefrontError>>;
622
+ /**
623
+ * Update the quantity of an existing cart item.
624
+ *
625
+ * @param variantId - Product variant GID (global ID).
626
+ * @param quantity - New quantity for the item.
627
+ * @returns The updated cart.
628
+ */
311
629
  updateItem(variantId: string, quantity: number): Promise<Result<Cart, StorefrontError>>;
630
+ /**
631
+ * Remove a product variant from the cart.
632
+ *
633
+ * @param variantId - Product variant GID (global ID).
634
+ * @returns The updated cart.
635
+ */
312
636
  removeItem(variantId: string): Promise<Result<Cart, StorefrontError>>;
637
+ /**
638
+ * Remove all items from the active cart.
639
+ *
640
+ * @returns The emptied cart.
641
+ */
313
642
  clear(): Promise<Result<Cart, StorefrontError>>;
643
+ /**
644
+ * Apply a promo code to the active cart.
645
+ *
646
+ * @param code - Promo code to validate and apply.
647
+ * @returns The updated cart with discount data.
648
+ */
314
649
  applyPromoCode(code: string): Promise<Result<Cart, StorefrontError>>;
650
+ /**
651
+ * Remove the currently applied promo code from the cart.
652
+ *
653
+ * @returns The updated cart.
654
+ */
315
655
  removePromoCode(): Promise<Result<Cart, StorefrontError>>;
316
656
  }
317
657
 
318
- export declare type CartStatus = "active" | "checkout" | "converted" | "abandoned" | "expired";
658
+ export declare type CartStatus = "active" | "checkout" | "converted" | "expired";
319
659
 
320
660
  export declare interface CategoriesOperations {
661
+ /**
662
+ * Fetch the nested storefront category tree.
663
+ *
664
+ * @returns Categories with their child hierarchy.
665
+ */
321
666
  tree(): Promise<Result<Category[], StorefrontError>>;
667
+ /**
668
+ * Fetch categories flattened into a parent-aware list.
669
+ *
670
+ * @returns Flat categories with depth and parent metadata.
671
+ */
322
672
  flat(): Promise<Result<FlatCategory[], StorefrontError>>;
673
+ /**
674
+ * Fetch a single category by GID or handle.
675
+ *
676
+ * @param idOrHandle - Category GID or handle.
677
+ * @returns The matching category.
678
+ */
323
679
  get(idOrHandle: string): Promise<Result<Category, StorefrontError>>;
680
+ /**
681
+ * Fetch products assigned to a category.
682
+ *
683
+ * @param idOrHandle - Category GID or handle.
684
+ * @param options - Pagination and descendant-inclusion options.
685
+ * @returns Paginated products for the category.
686
+ */
324
687
  getProducts(idOrHandle: string, options?: CategoryProductsOptions): Promise<Result<PaginatedResult<Product>, StorefrontError>>;
325
688
  }
326
689
 
@@ -361,9 +724,30 @@ export declare interface CheckoutData {
361
724
  }
362
725
 
363
726
  export declare interface CheckoutOperations {
727
+ /**
728
+ * Start checkout for the current active cart.
729
+ *
730
+ * @returns The cart in checkout state.
731
+ */
364
732
  start(): Promise<Result<Cart, StorefrontError>>;
733
+ /**
734
+ * Update checkout customer, shipping, and payment details.
735
+ *
736
+ * @param data - Checkout fields to update.
737
+ * @returns The updated checkout cart.
738
+ */
365
739
  update(data: CheckoutData): Promise<Result<Cart, StorefrontError>>;
740
+ /**
741
+ * Complete checkout and convert the cart into an order.
742
+ *
743
+ * @returns The created order.
744
+ */
366
745
  complete(): Promise<Result<Order, StorefrontError>>;
746
+ /**
747
+ * Abandon checkout and return the cart to an active state.
748
+ *
749
+ * @returns The reactivated cart.
750
+ */
367
751
  abandon(): Promise<Result<Cart, StorefrontError>>;
368
752
  }
369
753
 
@@ -405,8 +789,27 @@ export declare interface CollectionsListOptions {
405
789
  }
406
790
 
407
791
  export declare interface CollectionsOperations {
792
+ /**
793
+ * List collections with cursor pagination and optional search.
794
+ *
795
+ * @param options - Pagination and search options.
796
+ * @returns Paginated storefront collections.
797
+ */
408
798
  list(options?: CollectionsListOptions): Promise<Result<PaginatedResult<Collection>, StorefrontError>>;
799
+ /**
800
+ * Fetch a single collection by GID or handle.
801
+ *
802
+ * @param idOrHandle - Collection GID or handle.
803
+ * @returns The matching collection.
804
+ */
409
805
  get(idOrHandle: string): Promise<Result<Collection, StorefrontError>>;
806
+ /**
807
+ * Fetch products that belong to a collection.
808
+ *
809
+ * @param idOrHandle - Collection GID or handle.
810
+ * @param options - Pagination and collection product options.
811
+ * @returns Paginated products for the collection.
812
+ */
410
813
  getProducts(idOrHandle: string, options?: CollectionProductsOptions): Promise<Result<PaginatedResult<Product>, StorefrontError>>;
411
814
  }
412
815
 
@@ -419,6 +822,11 @@ export declare type CollectionType = "manual" | "intelligent";
419
822
  */
420
823
  export declare function createDefaultAdapter(): StorageAdapter;
421
824
 
825
+ /**
826
+ * Creates a GTM browser adapter that pushes storefront analytics events into `window.dataLayer`.
827
+ */
828
+ export declare function createGtmBrowserAdapter(config: GtmBrowserTrackingConfig, options?: GtmBrowserAdapterOptions): AnalyticsBrowserAdapter | null;
829
+
422
830
  /**
423
831
  * localStorage adapter for browser environments
424
832
  */
@@ -477,7 +885,7 @@ export declare interface CustomerAddress {
477
885
  addressLine1: string;
478
886
  addressLine2: string | null;
479
887
  city: string;
480
- postalCode: string | null;
888
+ zip: string | null;
481
889
  phone: string | null;
482
890
  isDefault: boolean;
483
891
  createdAt: string;
@@ -490,7 +898,7 @@ export declare interface CustomerAddressInput {
490
898
  addressLine1: string;
491
899
  addressLine2?: string;
492
900
  city: string;
493
- postalCode?: string;
901
+ zip?: string;
494
902
  phone?: string;
495
903
  isDefault?: boolean;
496
904
  }
@@ -502,7 +910,7 @@ export declare interface CustomerAddressUpdateInput {
502
910
  addressLine1?: string;
503
911
  addressLine2?: string;
504
912
  city?: string;
505
- postalCode?: string;
913
+ zip?: string;
506
914
  phone?: string;
507
915
  isDefault?: boolean;
508
916
  }
@@ -537,6 +945,17 @@ export declare interface CustomerUpdateInput {
537
945
  newPassword?: string;
538
946
  }
539
947
 
948
+ export declare type DetailSection = RichTextDetailSection | BulletListDetailSection | TableDetailSection;
949
+
950
+ declare interface DetailSectionBase {
951
+ id: string;
952
+ title: string;
953
+ displayIntent: DisplayIntent;
954
+ position: number;
955
+ }
956
+
957
+ export declare type DisplayIntent = "ACCORDION" | "SPECIFICATIONS" | "BOTH";
958
+
540
959
  /**
541
960
  * Extract userErrors from mutation result and convert to ValidationError if present
542
961
  */
@@ -598,6 +1017,101 @@ export declare interface GraphQLResponse<T = unknown> {
598
1017
  }>;
599
1018
  }
600
1019
 
1020
+ /**
1021
+ * GTM attribution payload copied from captured UTM and click ID data.
1022
+ */
1023
+ export declare interface GtmAttributionPayload {
1024
+ utm_source: string | null;
1025
+ utm_medium: string | null;
1026
+ utm_campaign: string | null;
1027
+ utm_term: string | null;
1028
+ utm_content: string | null;
1029
+ gclid: string | null;
1030
+ gbraid: string | null;
1031
+ wbraid: string | null;
1032
+ fbclid: string | null;
1033
+ ttclid: string | null;
1034
+ }
1035
+
1036
+ /**
1037
+ * Optional runtime overrides for the GTM browser adapter.
1038
+ */
1039
+ export declare interface GtmBrowserAdapterOptions {
1040
+ dataLayerName?: string;
1041
+ getWindow?: () => object | null;
1042
+ }
1043
+
1044
+ /**
1045
+ * Public GTM settings returned by the storefront `store` query.
1046
+ */
1047
+ export declare interface GtmBrowserTrackingConfig {
1048
+ enabled: boolean;
1049
+ containerId: string | null;
1050
+ }
1051
+
1052
+ /**
1053
+ * GTM consent-mode update payload derived from storefront consent state.
1054
+ */
1055
+ export declare interface GtmConsentModeUpdate {
1056
+ analytics_storage: "granted" | "denied";
1057
+ ad_storage: "granted" | "denied";
1058
+ ad_user_data: "granted" | "denied";
1059
+ ad_personalization: "granted" | "denied";
1060
+ }
1061
+
1062
+ /**
1063
+ * GTM page context payload copied from the storefront analytics event.
1064
+ */
1065
+ export declare interface GtmContextPayload {
1066
+ path: string;
1067
+ referrer: string | null;
1068
+ }
1069
+
1070
+ /**
1071
+ * Full object pushed to the configured GTM data layer.
1072
+ */
1073
+ export declare interface GtmDataLayerEvent {
1074
+ event: GtmNamespacedEventName;
1075
+ ekomerc: GtmEcommercePayload;
1076
+ }
1077
+
1078
+ /**
1079
+ * GTM `ekomerc` payload pushed alongside each `dataLayer` event.
1080
+ */
1081
+ export declare interface GtmEcommercePayload {
1082
+ event_name: GtmNamespacedEventName;
1083
+ event_id: string;
1084
+ consent_state: AnalyticsConsentState;
1085
+ context: GtmContextPayload;
1086
+ attribution: GtmAttributionPayload;
1087
+ currency?: string;
1088
+ value?: number;
1089
+ order_id?: string;
1090
+ cart_id?: string;
1091
+ quantity?: number;
1092
+ items_count?: number;
1093
+ search_term?: string;
1094
+ results_count?: number;
1095
+ items?: GtmItem[];
1096
+ }
1097
+
1098
+ /**
1099
+ * GTM ecommerce item payload derived from storefront analytics properties.
1100
+ */
1101
+ export declare interface GtmItem {
1102
+ product_id: string;
1103
+ variant_id?: string;
1104
+ quantity: number;
1105
+ unit_price: number;
1106
+ line_total: number;
1107
+ currency: string;
1108
+ }
1109
+
1110
+ /**
1111
+ * Namespaced GTM event names emitted by the storefront adapter.
1112
+ */
1113
+ export declare type GtmNamespacedEventName = `ekomerc.${GtmStandardEventName}`;
1114
+
601
1115
  /**
602
1116
  * Network error - fetch failed, connection issues
603
1117
  */
@@ -662,11 +1176,16 @@ export declare interface PaymentInstructions {
662
1176
  }
663
1177
 
664
1178
  export declare interface PaymentsOperations {
1179
+ /**
1180
+ * Fetch payment methods currently available for checkout.
1181
+ *
1182
+ * @returns Available storefront payment methods.
1183
+ */
665
1184
  getAvailableMethods(): Promise<Result<AvailablePaymentMethod[], StorefrontError>>;
666
1185
  }
667
1186
 
668
1187
  declare type PresetEventProperties = {
669
- page_view: {};
1188
+ page_view: Record<string, never>;
670
1189
  product_view: {
671
1190
  productId: string;
672
1191
  variantId?: string | null;
@@ -724,6 +1243,7 @@ export declare interface Product {
724
1243
  categories: Category[];
725
1244
  primaryCategory: Category | null;
726
1245
  tags: Tag[];
1246
+ detailSections: DetailSection[];
727
1247
  }
728
1248
 
729
1249
  export declare interface ProductFilter {
@@ -769,8 +1289,26 @@ export declare interface ProductsListOptions {
769
1289
  }
770
1290
 
771
1291
  export declare interface ProductsOperations {
1292
+ /**
1293
+ * List products with cursor pagination and optional filters.
1294
+ *
1295
+ * @param options - Pagination, search, and sort options.
1296
+ * @returns Paginated storefront products.
1297
+ */
772
1298
  list(options?: ProductsListOptions): Promise<Result<PaginatedResult<Product>, StorefrontError>>;
1299
+ /**
1300
+ * Fetch a single product by GID or handle.
1301
+ *
1302
+ * @param idOrHandle - Product GID or handle.
1303
+ * @returns The matching product.
1304
+ */
773
1305
  get(idOrHandle: string): Promise<Result<Product, StorefrontError>>;
1306
+ /**
1307
+ * Fetch multiple products by handle in request order.
1308
+ *
1309
+ * @param handles - Product handles to resolve.
1310
+ * @returns Products for each requested handle, with `null` for missing entries.
1311
+ */
774
1312
  getByHandles(handles: string[]): Promise<Result<(Product | null)[], StorefrontError>>;
775
1313
  }
776
1314
 
@@ -804,7 +1342,34 @@ export declare interface QueryCache {
804
1342
  clear(): void;
805
1343
  }
806
1344
 
1345
+ export declare interface ResolvedStorefrontAnalyticsConfig {
1346
+ enabled: boolean;
1347
+ dispatchOnUnknownConsent: boolean;
1348
+ gtm: {
1349
+ enabled: boolean;
1350
+ containerId: string | null;
1351
+ };
1352
+ }
1353
+
1354
+ export declare interface ResolvedStorefrontInitConfig {
1355
+ analytics: ResolvedStorefrontAnalyticsConfig;
1356
+ }
1357
+
1358
+ export declare interface RichTextDetailSection extends DetailSectionBase {
1359
+ sectionType: "RICH_TEXT";
1360
+ content: {
1361
+ html: string;
1362
+ };
1363
+ }
1364
+
1365
+ export declare type SectionType = "RICH_TEXT" | "BULLET_LIST" | "TABLE";
1366
+
807
1367
  export declare interface ShippingOperations {
1368
+ /**
1369
+ * Fetch shipping rates currently available for checkout.
1370
+ *
1371
+ * @returns Available shipping rates.
1372
+ */
808
1373
  getAvailableRates(): Promise<Result<ShippingRate[], StorefrontError>>;
809
1374
  }
810
1375
 
@@ -853,14 +1418,29 @@ export declare interface Store {
853
1418
  currency: string;
854
1419
  timezone: string;
855
1420
  logoUrl: string | null;
1421
+ contactEmail: string | null;
856
1422
  contactPhone: string | null;
1423
+ trackingDispatchOnUnknownConsent: boolean;
1424
+ browserTrackingConfig: BrowserTrackingConfig;
1425
+ analytics: StoreAnalyticsConfig;
857
1426
  socialLinks: SocialLinks;
858
1427
  }
859
1428
 
1429
+ export declare interface StoreAnalyticsConfig {
1430
+ enabled: boolean;
1431
+ dispatchOnUnknownConsent: boolean;
1432
+ gtm: GtmBrowserTrackingConfig;
1433
+ }
1434
+
1435
+ export declare interface StorefrontAnalyticsInitConfig extends StorefrontTrackingRuntimeConfig {
1436
+ stripUrl?: boolean;
1437
+ }
1438
+
860
1439
  export declare interface StorefrontClient {
861
1440
  readonly config: StorefrontClientConfig;
862
1441
  readonly cache: CacheHelpers;
863
1442
  readonly products: ProductsOperations;
1443
+ readonly store: StoreOperations;
864
1444
  readonly collections: CollectionsOperations;
865
1445
  readonly categories: CategoriesOperations;
866
1446
  readonly cart: CartOperations;
@@ -870,6 +1450,7 @@ export declare interface StorefrontClient {
870
1450
  readonly account: AccountOperations;
871
1451
  readonly shipping: ShippingOperations;
872
1452
  readonly analytics: AnalyticsOperations;
1453
+ init(options?: StorefrontInitOptions): Promise<Result<ResolvedStorefrontInitConfig, StorefrontError>>;
873
1454
  /**
874
1455
  * Execute a GraphQL query with optional caching
875
1456
  */
@@ -911,7 +1492,15 @@ export declare interface StorefrontClientConfig {
911
1492
  apiKey: string;
912
1493
  storage?: StorageAdapter;
913
1494
  cacheTTL?: number;
914
- storeSlug?: string;
1495
+ /**
1496
+ * How long stored landing attribution remains valid, in milliseconds.
1497
+ * Defaults to 30 days.
1498
+ */
1499
+ trackingAttributionTTL?: number;
1500
+ /**
1501
+ * Deprecated. Pass runtime analytics hooks to `client.init({ analytics: ... })`.
1502
+ */
1503
+ tracking?: StorefrontTrackingRuntimeConfig;
915
1504
  }
916
1505
 
917
1506
  /**
@@ -924,13 +1513,75 @@ export declare class StorefrontError extends Error {
924
1513
  });
925
1514
  }
926
1515
 
1516
+ export declare interface StorefrontInitOptions {
1517
+ analytics?: StorefrontAnalyticsInitConfig;
1518
+ }
1519
+
927
1520
  export declare type StorefrontResult<T> = Result<T, StorefrontError>;
928
1521
 
1522
+ /**
1523
+ * Optional browser analytics runtime hooks passed to `createStorefrontClient()`.
1524
+ */
1525
+ export declare interface StorefrontTrackingRuntimeConfig {
1526
+ dispatchOnUnknownConsent?: AnalyticsDispatchOnUnknownConsent;
1527
+ resolveConsentState?: () => AnalyticsConsentState | Promise<AnalyticsConsentState>;
1528
+ adapters?: AnalyticsBrowserAdapter[];
1529
+ onDiagnostic?: (diagnostic: AnalyticsDiagnostic) => void;
1530
+ }
1531
+
1532
+ /**
1533
+ * Store-level read operations exposed by the storefront SDK.
1534
+ */
1535
+ export declare interface StoreOperations {
1536
+ get(options?: {
1537
+ cache?: boolean;
1538
+ }): Promise<StorefrontResult<Store>>;
1539
+ }
1540
+
1541
+ export declare interface TableDetailSection extends DetailSectionBase {
1542
+ sectionType: "TABLE";
1543
+ content: {
1544
+ rows: [string, string][];
1545
+ };
1546
+ }
1547
+
929
1548
  export declare interface Tag {
930
1549
  id: string;
931
1550
  name: string;
932
1551
  }
933
1552
 
1553
+ export declare const TRACKING_ATTRIBUTION_QUERY_PARAM_KEYS: readonly ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "gclid", "gbraid", "wbraid", "ttclid", "fbclid"];
1554
+
1555
+ export declare interface TrackingAttributionOptions {
1556
+ ttlMs?: number;
1557
+ }
1558
+
1559
+ export declare interface TrackingAttributionSnapshot {
1560
+ schemaVersion: 1;
1561
+ capturedAt: string;
1562
+ utm: TrackingUtmSnapshot;
1563
+ clickIds: TrackingClickIdsSnapshot;
1564
+ }
1565
+
1566
+ declare interface TrackingClickIdsSnapshot {
1567
+ schemaVersion: 1;
1568
+ capturedAt: string | null;
1569
+ gclid: string | null;
1570
+ gbraid: string | null;
1571
+ wbraid: string | null;
1572
+ ttclid: string | null;
1573
+ fbclid: string | null;
1574
+ }
1575
+
1576
+ declare interface TrackingUtmSnapshot {
1577
+ schemaVersion: 1;
1578
+ source: string | null;
1579
+ medium: string | null;
1580
+ campaign: string | null;
1581
+ term: string | null;
1582
+ content: string | null;
1583
+ }
1584
+
934
1585
  /**
935
1586
  * Validation error - userErrors from mutations
936
1587
  */