@reactionary/core 0.11.2 → 0.12.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 (60) hide show
  1. package/analytics/context.js +173 -0
  2. package/analytics/dispatcher.js +181 -0
  3. package/analytics/index.js +6 -0
  4. package/analytics/legacy-adapter.js +48 -0
  5. package/analytics/origins.js +64 -0
  6. package/analytics/recording-subscriber.js +26 -0
  7. package/analytics/refs.js +14 -0
  8. package/capabilities/analytics.capability.js +265 -84
  9. package/capabilities/analytics.provider.js +13 -0
  10. package/capabilities/index.js +1 -0
  11. package/client/client-builder.js +45 -16
  12. package/index.js +1 -0
  13. package/package.json +1 -1
  14. package/schemas/models/analytics/consent.model.js +10 -0
  15. package/schemas/models/analytics/dispatch.model.js +15 -0
  16. package/schemas/models/analytics/envelope.model.js +38 -0
  17. package/schemas/models/analytics/event-parts.model.js +47 -0
  18. package/schemas/models/analytics/event.model.js +255 -0
  19. package/schemas/models/analytics/index.js +6 -0
  20. package/schemas/models/analytics/origin.model.js +113 -0
  21. package/schemas/models/analytics.model.js +0 -2
  22. package/schemas/models/index.js +1 -0
  23. package/schemas/mutations/analytics/events/account.mutation.js +66 -0
  24. package/schemas/mutations/analytics/events/base.mutation.js +10 -0
  25. package/schemas/mutations/analytics/events/browse.mutation.js +53 -0
  26. package/schemas/mutations/analytics/events/commerce.mutation.js +79 -0
  27. package/schemas/mutations/analytics/events/index.js +85 -0
  28. package/schemas/mutations/analytics/index.js +1 -0
  29. package/schemas/session.schema.js +3 -1
  30. package/src/analytics/context.d.ts +85 -0
  31. package/src/analytics/dispatcher.d.ts +71 -0
  32. package/src/analytics/index.d.ts +6 -0
  33. package/src/analytics/legacy-adapter.d.ts +10 -0
  34. package/src/analytics/origins.d.ts +25 -0
  35. package/src/analytics/recording-subscriber.d.ts +18 -0
  36. package/src/analytics/refs.d.ts +8 -0
  37. package/src/capabilities/analytics.capability.d.ts +64 -17
  38. package/src/capabilities/analytics.provider.d.ts +24 -0
  39. package/src/capabilities/index.d.ts +1 -0
  40. package/src/client/client-builder.d.ts +25 -2
  41. package/src/index.d.ts +1 -0
  42. package/src/schemas/capabilities.schema.d.ts +8 -1
  43. package/src/schemas/models/analytics/consent.model.d.ts +13 -0
  44. package/src/schemas/models/analytics/dispatch.model.d.ts +29 -0
  45. package/src/schemas/models/analytics/envelope.model.d.ts +565 -0
  46. package/src/schemas/models/analytics/event-parts.model.d.ts +248 -0
  47. package/src/schemas/models/analytics/event.model.d.ts +83182 -0
  48. package/src/schemas/models/analytics/index.d.ts +6 -0
  49. package/src/schemas/models/analytics/origin.model.d.ts +275 -0
  50. package/src/schemas/models/analytics.model.d.ts +1 -2
  51. package/src/schemas/models/index.d.ts +1 -0
  52. package/src/schemas/mutations/analytics/events/account.mutation.d.ts +1939 -0
  53. package/src/schemas/mutations/analytics/events/base.mutation.d.ts +121 -0
  54. package/src/schemas/mutations/analytics/events/browse.mutation.d.ts +1832 -0
  55. package/src/schemas/mutations/analytics/events/commerce.mutation.d.ts +30188 -0
  56. package/src/schemas/mutations/analytics/events/index.d.ts +33928 -0
  57. package/src/schemas/mutations/analytics/index.d.ts +1 -0
  58. package/src/schemas/mutations/checkout.mutation.d.ts +4 -4
  59. package/src/schemas/mutations/product-list.mutation.d.ts +2 -2
  60. package/src/schemas/session.schema.d.ts +8 -0
@@ -0,0 +1,255 @@
1
+ import * as z from "zod";
2
+ import {
3
+ AnalyticsMutationPageViewedSchema,
4
+ AnalyticsMutationSearchResultsViewedSchema,
5
+ AnalyticsMutationAutocompleteSuggestionSelectedSchema,
6
+ AnalyticsMutationCategoryViewedSchema,
7
+ AnalyticsMutationProductCarouselViewedSchema,
8
+ AnalyticsMutationProductClickedSchema,
9
+ AnalyticsMutationProductViewedSchema,
10
+ AnalyticsMutationPromotionViewedSchema,
11
+ AnalyticsMutationPromotionClickedSchema,
12
+ AnalyticsMutationCartItemAddedSchema,
13
+ AnalyticsMutationCartItemRemovedSchema,
14
+ AnalyticsMutationCartItemQuantityChangedSchema,
15
+ AnalyticsMutationCartViewedSchema,
16
+ AnalyticsMutationCouponAppliedSchema,
17
+ AnalyticsMutationCouponRejectedSchema,
18
+ AnalyticsMutationCheckoutStartedSchema,
19
+ AnalyticsMutationShippingInfoAddedSchema,
20
+ AnalyticsMutationPaymentInfoAddedSchema,
21
+ AnalyticsMutationOrderPlacedSchema,
22
+ AnalyticsMutationQuoteRequestedSchema,
23
+ AnalyticsMutationOrderReorderedSchema,
24
+ AnalyticsMutationCompanyRegisteredSchema,
25
+ AnalyticsMutationUserLoggedInSchema,
26
+ AnalyticsMutationUserLoggedOutSchema,
27
+ AnalyticsMutationUserRegisteredSchema,
28
+ AnalyticsMutationProfileUpdatedSchema,
29
+ AnalyticsMutationConsentChangedSchema,
30
+ AnalyticsMutationNewsletterSubscribedSchema,
31
+ AnalyticsMutationWishlistItemAddedSchema,
32
+ AnalyticsMutationWishlistItemRemovedSchema,
33
+ AnalyticsMutationBackInStockRequestedSchema,
34
+ AnalyticsMutationReviewSubmittedSchema,
35
+ AnalyticsMutationStoreSelectedSchema,
36
+ AnalyticsMutationProductSharedSchema,
37
+ AnalyticsMutationCustomSchema
38
+ } from "../../mutations/analytics/events/index.js";
39
+ import { AnalyticsEventEnvelopeSchema } from "./envelope.model.js";
40
+ const omitEnvelopeFields = { origin: true, properties: true };
41
+ const AnalyticsEventPageViewedSchema = AnalyticsEventEnvelopeSchema.extend({
42
+ type: z.literal("page-viewed"),
43
+ payload: AnalyticsMutationPageViewedSchema.omit(omitEnvelopeFields)
44
+ });
45
+ const AnalyticsEventSearchResultsViewedSchema = AnalyticsEventEnvelopeSchema.extend({
46
+ type: z.literal("search-results-viewed"),
47
+ payload: AnalyticsMutationSearchResultsViewedSchema.omit(omitEnvelopeFields)
48
+ });
49
+ const AnalyticsEventAutocompleteSuggestionSelectedSchema = AnalyticsEventEnvelopeSchema.extend({
50
+ type: z.literal("autocomplete-suggestion-selected"),
51
+ payload: AnalyticsMutationAutocompleteSuggestionSelectedSchema.omit(omitEnvelopeFields)
52
+ });
53
+ const AnalyticsEventCategoryViewedSchema = AnalyticsEventEnvelopeSchema.extend({
54
+ type: z.literal("category-viewed"),
55
+ payload: AnalyticsMutationCategoryViewedSchema.omit(omitEnvelopeFields)
56
+ });
57
+ const AnalyticsEventProductCarouselViewedSchema = AnalyticsEventEnvelopeSchema.extend({
58
+ type: z.literal("product-carousel-viewed"),
59
+ payload: AnalyticsMutationProductCarouselViewedSchema.omit(omitEnvelopeFields)
60
+ });
61
+ const AnalyticsEventProductClickedSchema = AnalyticsEventEnvelopeSchema.extend({
62
+ type: z.literal("product-clicked"),
63
+ payload: AnalyticsMutationProductClickedSchema.omit(omitEnvelopeFields)
64
+ });
65
+ const AnalyticsEventProductViewedSchema = AnalyticsEventEnvelopeSchema.extend({
66
+ type: z.literal("product-viewed"),
67
+ payload: AnalyticsMutationProductViewedSchema.omit(omitEnvelopeFields)
68
+ });
69
+ const AnalyticsEventPromotionViewedSchema = AnalyticsEventEnvelopeSchema.extend({
70
+ type: z.literal("promotion-viewed"),
71
+ payload: AnalyticsMutationPromotionViewedSchema.omit(omitEnvelopeFields)
72
+ });
73
+ const AnalyticsEventPromotionClickedSchema = AnalyticsEventEnvelopeSchema.extend({
74
+ type: z.literal("promotion-clicked"),
75
+ payload: AnalyticsMutationPromotionClickedSchema.omit(omitEnvelopeFields)
76
+ });
77
+ const AnalyticsEventCartItemAddedSchema = AnalyticsEventEnvelopeSchema.extend({
78
+ type: z.literal("cart-item-added"),
79
+ payload: AnalyticsMutationCartItemAddedSchema.omit(omitEnvelopeFields)
80
+ });
81
+ const AnalyticsEventCartItemRemovedSchema = AnalyticsEventEnvelopeSchema.extend({
82
+ type: z.literal("cart-item-removed"),
83
+ payload: AnalyticsMutationCartItemRemovedSchema.omit(omitEnvelopeFields)
84
+ });
85
+ const AnalyticsEventCartItemQuantityChangedSchema = AnalyticsEventEnvelopeSchema.extend({
86
+ type: z.literal("cart-item-quantity-changed"),
87
+ payload: AnalyticsMutationCartItemQuantityChangedSchema.omit(omitEnvelopeFields)
88
+ });
89
+ const AnalyticsEventCartViewedSchema = AnalyticsEventEnvelopeSchema.extend({
90
+ type: z.literal("cart-viewed"),
91
+ payload: AnalyticsMutationCartViewedSchema.omit(omitEnvelopeFields)
92
+ });
93
+ const AnalyticsEventCouponAppliedSchema = AnalyticsEventEnvelopeSchema.extend({
94
+ type: z.literal("coupon-applied"),
95
+ payload: AnalyticsMutationCouponAppliedSchema.omit(omitEnvelopeFields)
96
+ });
97
+ const AnalyticsEventCouponRejectedSchema = AnalyticsEventEnvelopeSchema.extend({
98
+ type: z.literal("coupon-rejected"),
99
+ payload: AnalyticsMutationCouponRejectedSchema.omit(omitEnvelopeFields)
100
+ });
101
+ const AnalyticsEventCheckoutStartedSchema = AnalyticsEventEnvelopeSchema.extend({
102
+ type: z.literal("checkout-started"),
103
+ payload: AnalyticsMutationCheckoutStartedSchema.omit(omitEnvelopeFields)
104
+ });
105
+ const AnalyticsEventShippingInfoAddedSchema = AnalyticsEventEnvelopeSchema.extend({
106
+ type: z.literal("shipping-info-added"),
107
+ payload: AnalyticsMutationShippingInfoAddedSchema.omit(omitEnvelopeFields)
108
+ });
109
+ const AnalyticsEventPaymentInfoAddedSchema = AnalyticsEventEnvelopeSchema.extend({
110
+ type: z.literal("payment-info-added"),
111
+ payload: AnalyticsMutationPaymentInfoAddedSchema.omit(omitEnvelopeFields)
112
+ });
113
+ const AnalyticsEventOrderPlacedSchema = AnalyticsEventEnvelopeSchema.extend({
114
+ type: z.literal("order-placed"),
115
+ payload: AnalyticsMutationOrderPlacedSchema.omit(omitEnvelopeFields)
116
+ });
117
+ const AnalyticsEventQuoteRequestedSchema = AnalyticsEventEnvelopeSchema.extend({
118
+ type: z.literal("quote-requested"),
119
+ payload: AnalyticsMutationQuoteRequestedSchema.omit(omitEnvelopeFields)
120
+ });
121
+ const AnalyticsEventOrderReorderedSchema = AnalyticsEventEnvelopeSchema.extend({
122
+ type: z.literal("order-reordered"),
123
+ payload: AnalyticsMutationOrderReorderedSchema.omit(omitEnvelopeFields)
124
+ });
125
+ const AnalyticsEventCompanyRegisteredSchema = AnalyticsEventEnvelopeSchema.extend({
126
+ type: z.literal("company-registered"),
127
+ payload: AnalyticsMutationCompanyRegisteredSchema.omit(omitEnvelopeFields)
128
+ });
129
+ const AnalyticsEventUserLoggedInSchema = AnalyticsEventEnvelopeSchema.extend({
130
+ type: z.literal("user-logged-in"),
131
+ payload: AnalyticsMutationUserLoggedInSchema.omit(omitEnvelopeFields)
132
+ });
133
+ const AnalyticsEventUserLoggedOutSchema = AnalyticsEventEnvelopeSchema.extend({
134
+ type: z.literal("user-logged-out"),
135
+ payload: AnalyticsMutationUserLoggedOutSchema.omit(omitEnvelopeFields)
136
+ });
137
+ const AnalyticsEventUserRegisteredSchema = AnalyticsEventEnvelopeSchema.extend({
138
+ type: z.literal("user-registered"),
139
+ payload: AnalyticsMutationUserRegisteredSchema.omit(omitEnvelopeFields)
140
+ });
141
+ const AnalyticsEventProfileUpdatedSchema = AnalyticsEventEnvelopeSchema.extend({
142
+ type: z.literal("profile-updated"),
143
+ payload: AnalyticsMutationProfileUpdatedSchema.omit(omitEnvelopeFields)
144
+ });
145
+ const AnalyticsEventConsentChangedSchema = AnalyticsEventEnvelopeSchema.extend({
146
+ type: z.literal("consent-changed"),
147
+ payload: AnalyticsMutationConsentChangedSchema.omit(omitEnvelopeFields)
148
+ });
149
+ const AnalyticsEventNewsletterSubscribedSchema = AnalyticsEventEnvelopeSchema.extend({
150
+ type: z.literal("newsletter-subscribed"),
151
+ payload: AnalyticsMutationNewsletterSubscribedSchema.omit(omitEnvelopeFields)
152
+ });
153
+ const AnalyticsEventWishlistItemAddedSchema = AnalyticsEventEnvelopeSchema.extend({
154
+ type: z.literal("wishlist-item-added"),
155
+ payload: AnalyticsMutationWishlistItemAddedSchema.omit(omitEnvelopeFields)
156
+ });
157
+ const AnalyticsEventWishlistItemRemovedSchema = AnalyticsEventEnvelopeSchema.extend({
158
+ type: z.literal("wishlist-item-removed"),
159
+ payload: AnalyticsMutationWishlistItemRemovedSchema.omit(omitEnvelopeFields)
160
+ });
161
+ const AnalyticsEventBackInStockRequestedSchema = AnalyticsEventEnvelopeSchema.extend({
162
+ type: z.literal("back-in-stock-requested"),
163
+ payload: AnalyticsMutationBackInStockRequestedSchema.omit(omitEnvelopeFields)
164
+ });
165
+ const AnalyticsEventReviewSubmittedSchema = AnalyticsEventEnvelopeSchema.extend({
166
+ type: z.literal("review-submitted"),
167
+ payload: AnalyticsMutationReviewSubmittedSchema.omit(omitEnvelopeFields)
168
+ });
169
+ const AnalyticsEventStoreSelectedSchema = AnalyticsEventEnvelopeSchema.extend({
170
+ type: z.literal("store-selected"),
171
+ payload: AnalyticsMutationStoreSelectedSchema.omit(omitEnvelopeFields)
172
+ });
173
+ const AnalyticsEventProductSharedSchema = AnalyticsEventEnvelopeSchema.extend({
174
+ type: z.literal("product-shared"),
175
+ payload: AnalyticsMutationProductSharedSchema.omit(omitEnvelopeFields)
176
+ });
177
+ const AnalyticsEventCustomSchema = AnalyticsEventEnvelopeSchema.extend({
178
+ type: z.literal("custom"),
179
+ payload: AnalyticsMutationCustomSchema.omit(omitEnvelopeFields)
180
+ });
181
+ const AnalyticsEventSchema = z.discriminatedUnion("type", [
182
+ AnalyticsEventPageViewedSchema,
183
+ AnalyticsEventSearchResultsViewedSchema,
184
+ AnalyticsEventAutocompleteSuggestionSelectedSchema,
185
+ AnalyticsEventCategoryViewedSchema,
186
+ AnalyticsEventProductCarouselViewedSchema,
187
+ AnalyticsEventProductClickedSchema,
188
+ AnalyticsEventProductViewedSchema,
189
+ AnalyticsEventPromotionViewedSchema,
190
+ AnalyticsEventPromotionClickedSchema,
191
+ AnalyticsEventCartItemAddedSchema,
192
+ AnalyticsEventCartItemRemovedSchema,
193
+ AnalyticsEventCartItemQuantityChangedSchema,
194
+ AnalyticsEventCartViewedSchema,
195
+ AnalyticsEventCouponAppliedSchema,
196
+ AnalyticsEventCouponRejectedSchema,
197
+ AnalyticsEventCheckoutStartedSchema,
198
+ AnalyticsEventShippingInfoAddedSchema,
199
+ AnalyticsEventPaymentInfoAddedSchema,
200
+ AnalyticsEventOrderPlacedSchema,
201
+ AnalyticsEventQuoteRequestedSchema,
202
+ AnalyticsEventOrderReorderedSchema,
203
+ AnalyticsEventCompanyRegisteredSchema,
204
+ AnalyticsEventUserLoggedInSchema,
205
+ AnalyticsEventUserLoggedOutSchema,
206
+ AnalyticsEventUserRegisteredSchema,
207
+ AnalyticsEventProfileUpdatedSchema,
208
+ AnalyticsEventConsentChangedSchema,
209
+ AnalyticsEventNewsletterSubscribedSchema,
210
+ AnalyticsEventWishlistItemAddedSchema,
211
+ AnalyticsEventWishlistItemRemovedSchema,
212
+ AnalyticsEventBackInStockRequestedSchema,
213
+ AnalyticsEventReviewSubmittedSchema,
214
+ AnalyticsEventStoreSelectedSchema,
215
+ AnalyticsEventProductSharedSchema,
216
+ AnalyticsEventCustomSchema
217
+ ]);
218
+ export {
219
+ AnalyticsEventAutocompleteSuggestionSelectedSchema,
220
+ AnalyticsEventBackInStockRequestedSchema,
221
+ AnalyticsEventCartItemAddedSchema,
222
+ AnalyticsEventCartItemQuantityChangedSchema,
223
+ AnalyticsEventCartItemRemovedSchema,
224
+ AnalyticsEventCartViewedSchema,
225
+ AnalyticsEventCategoryViewedSchema,
226
+ AnalyticsEventCheckoutStartedSchema,
227
+ AnalyticsEventCompanyRegisteredSchema,
228
+ AnalyticsEventConsentChangedSchema,
229
+ AnalyticsEventCouponAppliedSchema,
230
+ AnalyticsEventCouponRejectedSchema,
231
+ AnalyticsEventCustomSchema,
232
+ AnalyticsEventNewsletterSubscribedSchema,
233
+ AnalyticsEventOrderPlacedSchema,
234
+ AnalyticsEventOrderReorderedSchema,
235
+ AnalyticsEventPageViewedSchema,
236
+ AnalyticsEventPaymentInfoAddedSchema,
237
+ AnalyticsEventProductCarouselViewedSchema,
238
+ AnalyticsEventProductClickedSchema,
239
+ AnalyticsEventProductSharedSchema,
240
+ AnalyticsEventProductViewedSchema,
241
+ AnalyticsEventProfileUpdatedSchema,
242
+ AnalyticsEventPromotionClickedSchema,
243
+ AnalyticsEventPromotionViewedSchema,
244
+ AnalyticsEventQuoteRequestedSchema,
245
+ AnalyticsEventReviewSubmittedSchema,
246
+ AnalyticsEventSchema,
247
+ AnalyticsEventSearchResultsViewedSchema,
248
+ AnalyticsEventShippingInfoAddedSchema,
249
+ AnalyticsEventStoreSelectedSchema,
250
+ AnalyticsEventUserLoggedInSchema,
251
+ AnalyticsEventUserLoggedOutSchema,
252
+ AnalyticsEventUserRegisteredSchema,
253
+ AnalyticsEventWishlistItemAddedSchema,
254
+ AnalyticsEventWishlistItemRemovedSchema
255
+ };
@@ -0,0 +1,6 @@
1
+ export * from "./consent.model.js";
2
+ export * from "./dispatch.model.js";
3
+ export * from "./envelope.model.js";
4
+ export * from "./event-parts.model.js";
5
+ export * from "./event.model.js";
6
+ export * from "./origin.model.js";
@@ -0,0 +1,113 @@
1
+ import * as z from "zod";
2
+ import {
3
+ CategoryIdentifierSchema,
4
+ FacetValueIdentifierSchema,
5
+ OrderIdentifierSchema,
6
+ ProductIdentifierSchema,
7
+ ProductListIdentifierSchema,
8
+ ProductRecommendationIdentifierSchema,
9
+ ProductSearchIdentifierSchema,
10
+ PromotionIdentifierSchema
11
+ } from "../identifiers.model.js";
12
+ const PositionSchema = z.int().min(0).meta({ description: "Absolute 0-based index of the item across all pages of the originating list." });
13
+ const AssociationKindSchema = z.enum(["related", "cross-sell", "upsell", "accessories"]).meta({ description: "The kind of product association the visitor came from." });
14
+ const CartOriginKindSchema = z.enum(["page", "mini-cart", "upsell"]).meta({ description: "Which cart surface the visitor came from." });
15
+ const QuickOrderKindSchema = z.enum(["sku-entry", "csv", "scan"]).meta({ description: "How the items were entered in the quick order flow." });
16
+ const OriginSearchSchema = z.looseObject({
17
+ type: z.literal("search"),
18
+ identifier: ProductSearchIdentifierSchema.meta({ description: "The search the visitor came from, including term, facets and paging. Vendor query ids ride on provider subtypes of this identifier." }),
19
+ position: PositionSchema
20
+ });
21
+ const OriginAutocompleteSchema = z.looseObject({
22
+ type: z.literal("autocomplete"),
23
+ term: z.string().meta({ description: "The autocomplete term." }),
24
+ position: PositionSchema
25
+ });
26
+ const OriginCategorySchema = z.looseObject({
27
+ type: z.literal("category"),
28
+ categoryId: CategoryIdentifierSchema,
29
+ filters: z.array(FacetValueIdentifierSchema).default(() => []).meta({ description: "Facet values active on the category listing." }),
30
+ position: PositionSchema
31
+ });
32
+ const OriginListSchema = z.looseObject({
33
+ type: z.literal("list"),
34
+ recommendationId: ProductRecommendationIdentifierSchema.optional().meta({ description: "The recommendation the carousel was built from, if any." }),
35
+ carouselName: z.string().meta({ description: "Storefront name of the recommendation or merchandised carousel." }),
36
+ position: PositionSchema
37
+ });
38
+ const OriginAssociationsSchema = z.looseObject({
39
+ type: z.literal("associations"),
40
+ productId: ProductIdentifierSchema.meta({ description: "The product whose associations were shown." }),
41
+ kind: AssociationKindSchema,
42
+ position: PositionSchema
43
+ });
44
+ const OriginProductListSchema = z.looseObject({
45
+ type: z.literal("product-list"),
46
+ listId: ProductListIdentifierSchema,
47
+ position: PositionSchema
48
+ });
49
+ const OriginPromotionSchema = z.looseObject({
50
+ type: z.literal("promotion"),
51
+ promotionId: PromotionIdentifierSchema,
52
+ slot: z.string().meta({ description: "The placement of the promotion." })
53
+ });
54
+ const OriginContentSchema = z.looseObject({
55
+ type: z.literal("content"),
56
+ contentId: z.string(),
57
+ slot: z.string().optional()
58
+ });
59
+ const OriginCartSchema = z.looseObject({
60
+ type: z.literal("cart"),
61
+ kind: CartOriginKindSchema.optional()
62
+ });
63
+ const OriginOrderSchema = z.looseObject({
64
+ type: z.literal("order"),
65
+ orderId: OrderIdentifierSchema.meta({ description: "The order the items were reordered from." })
66
+ });
67
+ const OriginQuickOrderSchema = z.looseObject({
68
+ type: z.literal("quick-order"),
69
+ kind: QuickOrderKindSchema.optional()
70
+ });
71
+ const OriginDirectSchema = z.looseObject({
72
+ type: z.literal("direct")
73
+ });
74
+ const OriginPdpSchema = z.looseObject({
75
+ type: z.literal("pdp"),
76
+ get upstream() {
77
+ return OriginSchema.optional().meta({ description: "The origin of the visit to the product detail page, so conversions stay attributed to the list that led there." });
78
+ }
79
+ });
80
+ const OriginSchema = z.discriminatedUnion("type", [
81
+ OriginSearchSchema,
82
+ OriginAutocompleteSchema,
83
+ OriginCategorySchema,
84
+ OriginListSchema,
85
+ OriginAssociationsSchema,
86
+ OriginProductListSchema,
87
+ OriginPromotionSchema,
88
+ OriginContentSchema,
89
+ OriginCartSchema,
90
+ OriginOrderSchema,
91
+ OriginQuickOrderSchema,
92
+ OriginPdpSchema,
93
+ OriginDirectSchema
94
+ ]).meta({ description: "Where the visitor encountered the item or surface an event relates to." });
95
+ export {
96
+ AssociationKindSchema,
97
+ CartOriginKindSchema,
98
+ OriginAssociationsSchema,
99
+ OriginAutocompleteSchema,
100
+ OriginCartSchema,
101
+ OriginCategorySchema,
102
+ OriginContentSchema,
103
+ OriginDirectSchema,
104
+ OriginListSchema,
105
+ OriginOrderSchema,
106
+ OriginPdpSchema,
107
+ OriginProductListSchema,
108
+ OriginPromotionSchema,
109
+ OriginQuickOrderSchema,
110
+ OriginSchema,
111
+ OriginSearchSchema,
112
+ QuickOrderKindSchema
113
+ };
@@ -1,6 +1,5 @@
1
1
  import * as z from "zod";
2
2
  import { BaseModelSchema } from "./base.model.js";
3
- const AnalyticsEventSchema = BaseModelSchema.extend({});
4
3
  const AnalyticsOutcomeSchema = z.enum(["accepted", "ignored", "rejected"]);
5
4
  const AnalyticsProviderOutcomeSchema = z.object({
6
5
  provider: z.string(),
@@ -10,7 +9,6 @@ const AnalyticsResultSchema = BaseModelSchema.extend({
10
9
  outcomes: z.array(AnalyticsProviderOutcomeSchema)
11
10
  });
12
11
  export {
13
- AnalyticsEventSchema,
14
12
  AnalyticsOutcomeSchema,
15
13
  AnalyticsProviderOutcomeSchema,
16
14
  AnalyticsResultSchema
@@ -1,4 +1,5 @@
1
1
  export * from "./analytics.model.js";
2
+ export * from "./analytics/index.js";
2
3
  export * from "./base.model.js";
3
4
  export * from "./cart.model.js";
4
5
  export * from "./category.model.js";
@@ -0,0 +1,66 @@
1
+ import * as z from "zod";
2
+ import { AnalyticsConsentSchema } from "../../../models/analytics/consent.model.js";
3
+ import { AnalyticsChannelSchema, AnalyticsProductRefSchema, AnalyticsStoreRefSchema } from "../../../models/analytics/event-parts.model.js";
4
+ import { IdentitySchema } from "../../../models/identity.model.js";
5
+ import { PersonalizationProfileIdentifierSchema, ProductListIdentifierSchema, ProductVariantIdentifierSchema } from "../../../models/identifiers.model.js";
6
+ import { ProfileSchema } from "../../../models/profile.model.js";
7
+ import { AnalyticsEventMutationBaseSchema } from "./base.mutation.js";
8
+ const AnalyticsMutationUserLoggedInSchema = AnalyticsEventMutationBaseSchema.extend({
9
+ identity: IdentitySchema.meta({ description: "The identity after login." }),
10
+ previousMarketingId: PersonalizationProfileIdentifierSchema.optional().meta({ description: "The marketing identifier the visitor had before logging in, so CDPs can merge profiles. Login does not rotate the marketing identifier in core, so the storefront supplies it when it knows it." })
11
+ });
12
+ const AnalyticsMutationUserLoggedOutSchema = AnalyticsEventMutationBaseSchema.extend({});
13
+ const AnalyticsMutationUserRegisteredSchema = AnalyticsEventMutationBaseSchema.extend({
14
+ identity: IdentitySchema
15
+ });
16
+ const AnalyticsMutationProfileUpdatedSchema = AnalyticsEventMutationBaseSchema.extend({
17
+ profile: ProfileSchema,
18
+ changedFields: z.array(z.string()).optional()
19
+ });
20
+ const AnalyticsMutationConsentChangedSchema = AnalyticsEventMutationBaseSchema.extend({
21
+ consent: AnalyticsConsentSchema.meta({ description: "The new consent. Also applies to subsequent events in this request." })
22
+ });
23
+ const AnalyticsMutationNewsletterSubscribedSchema = AnalyticsEventMutationBaseSchema.extend({
24
+ channel: AnalyticsChannelSchema.optional()
25
+ });
26
+ const AnalyticsMutationWishlistItemAddedSchema = AnalyticsEventMutationBaseSchema.extend({
27
+ list: ProductListIdentifierSchema,
28
+ variant: ProductVariantIdentifierSchema
29
+ });
30
+ const AnalyticsMutationWishlistItemRemovedSchema = AnalyticsEventMutationBaseSchema.extend({
31
+ list: ProductListIdentifierSchema,
32
+ variant: ProductVariantIdentifierSchema
33
+ });
34
+ const AnalyticsMutationBackInStockRequestedSchema = AnalyticsEventMutationBaseSchema.extend({
35
+ variant: ProductVariantIdentifierSchema
36
+ });
37
+ const AnalyticsMutationReviewSubmittedSchema = AnalyticsEventMutationBaseSchema.extend({
38
+ product: AnalyticsProductRefSchema,
39
+ rating: z.number().min(0)
40
+ });
41
+ const AnalyticsMutationStoreSelectedSchema = AnalyticsEventMutationBaseSchema.extend({
42
+ store: AnalyticsStoreRefSchema
43
+ });
44
+ const AnalyticsMutationProductSharedSchema = AnalyticsEventMutationBaseSchema.extend({
45
+ product: AnalyticsProductRefSchema,
46
+ channel: AnalyticsChannelSchema.optional()
47
+ });
48
+ const AnalyticsMutationCustomSchema = AnalyticsEventMutationBaseSchema.extend({
49
+ name: z.string().min(1).meta({ description: "The custom event name. Providers ignore names they do not recognise." }),
50
+ payload: z.record(z.string(), z.unknown())
51
+ });
52
+ export {
53
+ AnalyticsMutationBackInStockRequestedSchema,
54
+ AnalyticsMutationConsentChangedSchema,
55
+ AnalyticsMutationCustomSchema,
56
+ AnalyticsMutationNewsletterSubscribedSchema,
57
+ AnalyticsMutationProductSharedSchema,
58
+ AnalyticsMutationProfileUpdatedSchema,
59
+ AnalyticsMutationReviewSubmittedSchema,
60
+ AnalyticsMutationStoreSelectedSchema,
61
+ AnalyticsMutationUserLoggedInSchema,
62
+ AnalyticsMutationUserLoggedOutSchema,
63
+ AnalyticsMutationUserRegisteredSchema,
64
+ AnalyticsMutationWishlistItemAddedSchema,
65
+ AnalyticsMutationWishlistItemRemovedSchema
66
+ };
@@ -0,0 +1,10 @@
1
+ import * as z from "zod";
2
+ import { OriginSchema } from "../../../models/analytics/origin.model.js";
3
+ import { BaseMutationSchema } from "../../base.mutation.js";
4
+ const AnalyticsEventMutationBaseSchema = BaseMutationSchema.extend({
5
+ origin: OriginSchema.optional().meta({ description: "Where the visitor encountered the item or surface. Meaningful on product-centred events." }),
6
+ properties: z.record(z.string(), z.unknown()).optional().meta({ description: "Storefront-only knowledge such as an experiment variant. Not a channel for product data; providers look that up." })
7
+ });
8
+ export {
9
+ AnalyticsEventMutationBaseSchema
10
+ };
@@ -0,0 +1,53 @@
1
+ import * as z from "zod";
2
+ import {
3
+ AnalyticsAutocompleteSuggestionSchema,
4
+ AnalyticsCarouselSchema,
5
+ AnalyticsCategoryRefSchema,
6
+ AnalyticsPageViewSchema,
7
+ AnalyticsProductRefSchema,
8
+ AnalyticsPromotionSchema
9
+ } from "../../../models/analytics/event-parts.model.js";
10
+ import { ProductSearchIdentifierSchema } from "../../../models/identifiers.model.js";
11
+ import { AnalyticsEventMutationBaseSchema } from "./base.mutation.js";
12
+ const AnalyticsMutationPageViewedSchema = AnalyticsEventMutationBaseSchema.extend({
13
+ page: AnalyticsPageViewSchema
14
+ });
15
+ const AnalyticsMutationSearchResultsViewedSchema = AnalyticsEventMutationBaseSchema.extend({
16
+ search: ProductSearchIdentifierSchema.meta({ description: "The search that produced the results." }),
17
+ products: z.array(AnalyticsProductRefSchema).meta({ description: "The products shown. An empty list means zero results." })
18
+ });
19
+ const AnalyticsMutationAutocompleteSuggestionSelectedSchema = AnalyticsEventMutationBaseSchema.extend({
20
+ suggestion: AnalyticsAutocompleteSuggestionSchema,
21
+ position: z.int().min(0)
22
+ });
23
+ const AnalyticsMutationCategoryViewedSchema = AnalyticsEventMutationBaseSchema.extend({
24
+ category: AnalyticsCategoryRefSchema,
25
+ products: z.array(AnalyticsProductRefSchema).optional()
26
+ });
27
+ const AnalyticsMutationProductCarouselViewedSchema = AnalyticsEventMutationBaseSchema.extend({
28
+ carousel: AnalyticsCarouselSchema,
29
+ products: z.array(AnalyticsProductRefSchema)
30
+ });
31
+ const AnalyticsMutationProductClickedSchema = AnalyticsEventMutationBaseSchema.extend({
32
+ product: AnalyticsProductRefSchema
33
+ });
34
+ const AnalyticsMutationProductViewedSchema = AnalyticsEventMutationBaseSchema.extend({
35
+ product: AnalyticsProductRefSchema
36
+ });
37
+ const AnalyticsMutationPromotionViewedSchema = AnalyticsEventMutationBaseSchema.extend({
38
+ promotion: AnalyticsPromotionSchema
39
+ });
40
+ const AnalyticsMutationPromotionClickedSchema = AnalyticsEventMutationBaseSchema.extend({
41
+ promotion: AnalyticsPromotionSchema
42
+ });
43
+ export {
44
+ AnalyticsMutationAutocompleteSuggestionSelectedSchema,
45
+ AnalyticsMutationCategoryViewedSchema,
46
+ AnalyticsMutationPageViewedSchema,
47
+ AnalyticsMutationProductCarouselViewedSchema,
48
+ AnalyticsMutationProductClickedSchema,
49
+ AnalyticsMutationProductViewedSchema,
50
+ AnalyticsMutationPromotionClickedSchema,
51
+ AnalyticsMutationPromotionViewedSchema,
52
+ AnalyticsMutationSearchResultsViewedSchema
53
+ };
@@ -0,0 +1,79 @@
1
+ import * as z from "zod";
2
+ import { AnalyticsCouponRejectionReasonSchema, AnalyticsStoreRefSchema } from "../../../models/analytics/event-parts.model.js";
3
+ import { CartItemSchema, CartSchema } from "../../../models/cart.model.js";
4
+ import { CompanySchema } from "../../../models/company.model.js";
5
+ import { ProductVariantIdentifierSchema } from "../../../models/identifiers.model.js";
6
+ import { OrderSchema } from "../../../models/order.model.js";
7
+ import { PaymentMethodSchema } from "../../../models/payment.model.js";
8
+ import { ShippingMethodSchema } from "../../../models/shipping-method.model.js";
9
+ import { AnalyticsEventMutationBaseSchema } from "./base.mutation.js";
10
+ const quantity = () => z.number().positive();
11
+ const AnalyticsMutationCartItemAddedSchema = AnalyticsEventMutationBaseSchema.extend({
12
+ cart: CartSchema.meta({ description: "The cart after the item was added." }),
13
+ variant: ProductVariantIdentifierSchema,
14
+ quantity: quantity().meta({ description: "The quantity that was added." })
15
+ });
16
+ const AnalyticsMutationCartItemRemovedSchema = AnalyticsEventMutationBaseSchema.extend({
17
+ cart: CartSchema.meta({ description: "The cart after the item was removed." }),
18
+ // Identifier first: CartItemSchema defaults throw on input that lacks required keys instead of failing the union branch.
19
+ removed: z.union([ProductVariantIdentifierSchema, CartItemSchema]).meta({ description: "The line the storefront rendered, or its sku. The line is gone from the resulting cart." }),
20
+ quantity: quantity().optional().meta({ description: "The quantity removed. Defaults to the full quantity of the removed line when that is known." })
21
+ });
22
+ const AnalyticsMutationCartItemQuantityChangedSchema = AnalyticsEventMutationBaseSchema.extend({
23
+ cart: CartSchema,
24
+ variant: ProductVariantIdentifierSchema,
25
+ previousQuantity: z.number().min(0),
26
+ newQuantity: z.number().min(0)
27
+ });
28
+ const AnalyticsMutationCartViewedSchema = AnalyticsEventMutationBaseSchema.extend({
29
+ cart: CartSchema
30
+ });
31
+ const AnalyticsMutationCouponAppliedSchema = AnalyticsEventMutationBaseSchema.extend({
32
+ cart: CartSchema,
33
+ code: z.string()
34
+ });
35
+ const AnalyticsMutationCouponRejectedSchema = AnalyticsEventMutationBaseSchema.extend({
36
+ cart: CartSchema,
37
+ code: z.string(),
38
+ reason: AnalyticsCouponRejectionReasonSchema.optional()
39
+ });
40
+ const AnalyticsMutationCheckoutStartedSchema = AnalyticsEventMutationBaseSchema.extend({
41
+ cart: CartSchema
42
+ });
43
+ const AnalyticsMutationShippingInfoAddedSchema = AnalyticsEventMutationBaseSchema.extend({
44
+ cart: CartSchema,
45
+ shippingMethod: ShippingMethodSchema.optional(),
46
+ store: AnalyticsStoreRefSchema.optional().meta({ description: "The pickup store, for click and collect." })
47
+ });
48
+ const AnalyticsMutationPaymentInfoAddedSchema = AnalyticsEventMutationBaseSchema.extend({
49
+ cart: CartSchema,
50
+ paymentMethod: PaymentMethodSchema
51
+ });
52
+ const AnalyticsMutationOrderPlacedSchema = AnalyticsEventMutationBaseSchema.extend({
53
+ order: OrderSchema
54
+ });
55
+ const AnalyticsMutationQuoteRequestedSchema = AnalyticsEventMutationBaseSchema.extend({
56
+ cart: CartSchema
57
+ });
58
+ const AnalyticsMutationOrderReorderedSchema = AnalyticsEventMutationBaseSchema.extend({
59
+ order: OrderSchema.meta({ description: "The order the items were reordered from." }),
60
+ cart: CartSchema.meta({ description: "The cart the items were added to." })
61
+ });
62
+ const AnalyticsMutationCompanyRegisteredSchema = AnalyticsEventMutationBaseSchema.extend({
63
+ company: CompanySchema
64
+ });
65
+ export {
66
+ AnalyticsMutationCartItemAddedSchema,
67
+ AnalyticsMutationCartItemQuantityChangedSchema,
68
+ AnalyticsMutationCartItemRemovedSchema,
69
+ AnalyticsMutationCartViewedSchema,
70
+ AnalyticsMutationCheckoutStartedSchema,
71
+ AnalyticsMutationCompanyRegisteredSchema,
72
+ AnalyticsMutationCouponAppliedSchema,
73
+ AnalyticsMutationCouponRejectedSchema,
74
+ AnalyticsMutationOrderPlacedSchema,
75
+ AnalyticsMutationOrderReorderedSchema,
76
+ AnalyticsMutationPaymentInfoAddedSchema,
77
+ AnalyticsMutationQuoteRequestedSchema,
78
+ AnalyticsMutationShippingInfoAddedSchema
79
+ };