@reactionary/core 0.2.19 → 0.3.1

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 (37) hide show
  1. package/client/client-builder.js +3 -4
  2. package/decorators/reactionary.decorator.js +2 -2
  3. package/initialization.js +7 -1
  4. package/package.json +1 -1
  5. package/providers/analytics.provider.js +62 -1
  6. package/schemas/errors/invalid-input.error.js +1 -1
  7. package/schemas/errors/invalid-output.error.js +1 -1
  8. package/schemas/models/order.model.js +1 -1
  9. package/schemas/mutations/analytics/index.js +21 -0
  10. package/schemas/mutations/analytics/product-add-to-cart.mutation.js +19 -0
  11. package/schemas/mutations/analytics/product-details-view.mutation.js +10 -0
  12. package/schemas/mutations/analytics/product-summary-click.mutation.js +20 -0
  13. package/schemas/mutations/analytics/product-summary-view.mutation.js +19 -0
  14. package/schemas/mutations/analytics/purchase.mutation.js +10 -0
  15. package/schemas/mutations/index.js +1 -1
  16. package/schemas/session.schema.js +10 -2
  17. package/src/client/client.d.ts +2 -3
  18. package/src/initialization.d.ts +1 -1
  19. package/src/providers/analytics.provider.d.ts +14 -0
  20. package/src/providers/cart.provider.d.ts +3 -0
  21. package/src/providers/category.provider.d.ts +1 -0
  22. package/src/schemas/errors/invalid-input.error.d.ts +1 -1
  23. package/src/schemas/errors/invalid-output.error.d.ts +1 -1
  24. package/src/schemas/models/identifiers.model.d.ts +3 -0
  25. package/src/schemas/models/order.model.d.ts +1 -1
  26. package/src/schemas/mutations/analytics/index.d.ts +2441 -0
  27. package/src/schemas/mutations/analytics/product-add-to-cart.mutation.d.ts +32 -0
  28. package/src/schemas/mutations/analytics/product-details-view.mutation.d.ts +9 -0
  29. package/src/schemas/mutations/analytics/product-summary-click.mutation.d.ts +33 -0
  30. package/src/schemas/mutations/analytics/product-summary-view.mutation.d.ts +32 -0
  31. package/src/schemas/mutations/analytics/purchase.mutation.d.ts +2346 -0
  32. package/src/schemas/mutations/index.d.ts +1 -1
  33. package/src/schemas/queries/order-search.query.d.ts +3 -0
  34. package/src/schemas/session.schema.d.ts +43 -6
  35. package/src/zod-utils.d.ts +4 -1
  36. package/schemas/mutations/analytics.mutation.js +0 -20
  37. package/src/schemas/mutations/analytics.mutation.d.ts +0 -110
@@ -1,4 +1,4 @@
1
- export * from './analytics.mutation.js';
1
+ export * from './analytics/index.js';
2
2
  export * from './base.mutation.js';
3
3
  export * from './cart.mutation.js';
4
4
  export * from './identity.mutation.js';
@@ -1,4 +1,7 @@
1
1
  import type { InferType } from "../../zod-utils.js";
2
+ /**
3
+ * Foo
4
+ */
2
5
  export declare const OrderSearchQueryByTermSchema: import("zod").ZodObject<{
3
6
  search: import("zod").ZodObject<{
4
7
  term: import("zod").ZodString;
@@ -188,7 +188,22 @@ export declare const LanguageContextSchema: z.ZodObject<{
188
188
  ZWL: "ZWL";
189
189
  }>>;
190
190
  }, z.core.$loose>;
191
- export declare const SessionSchema: z.ZodRecord<z.ZodString, z.ZodAny>;
191
+ export declare const IdentityContextSchema: z.ZodObject<{
192
+ identifier: z.ZodObject<{
193
+ userId: z.ZodString;
194
+ }, z.core.$loose>;
195
+ personalizationKey: z.ZodString;
196
+ lastUpdated: z.ZodDate;
197
+ }, z.core.$loose>;
198
+ export declare const SessionSchema: z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodObject<{
199
+ identityContext: z.ZodObject<{
200
+ identifier: z.ZodObject<{
201
+ userId: z.ZodString;
202
+ }, z.core.$loose>;
203
+ personalizationKey: z.ZodString;
204
+ lastUpdated: z.ZodDate;
205
+ }, z.core.$loose>;
206
+ }, z.core.$strip>>;
192
207
  export declare const TaxJurisdictionSchema: z.ZodObject<{
193
208
  countryCode: z.ZodDefault<z.ZodString>;
194
209
  stateCode: z.ZodDefault<z.ZodString>;
@@ -196,7 +211,15 @@ export declare const TaxJurisdictionSchema: z.ZodObject<{
196
211
  cityCode: z.ZodDefault<z.ZodString>;
197
212
  }, z.core.$strip>;
198
213
  export declare const RequestContextSchema: z.ZodObject<{
199
- session: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
214
+ session: z.ZodDefault<z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodObject<{
215
+ identityContext: z.ZodObject<{
216
+ identifier: z.ZodObject<{
217
+ userId: z.ZodString;
218
+ }, z.core.$loose>;
219
+ personalizationKey: z.ZodString;
220
+ lastUpdated: z.ZodDate;
221
+ }, z.core.$loose>;
222
+ }, z.core.$strip>>>;
200
223
  languageContext: z.ZodDefault<z.ZodObject<{
201
224
  locale: z.ZodDefault<z.ZodString>;
202
225
  currencyCode: z.ZodDefault<z.ZodEnum<{
@@ -398,7 +421,21 @@ export declare const RequestContextSchema: z.ZodObject<{
398
421
  userAgent: z.ZodDefault<z.ZodString>;
399
422
  referrer: z.ZodDefault<z.ZodString>;
400
423
  }, z.core.$loose>;
401
- export type Session = z.infer<typeof SessionSchema>;
402
- export type LanguageContext = z.infer<typeof LanguageContextSchema>;
403
- export type RequestContext = z.infer<typeof RequestContextSchema>;
404
- export type TaxJurisdiction = z.infer<typeof TaxJurisdictionSchema>;
424
+ /**
425
+ * @see {@link SessionSchema}
426
+ */
427
+ export type Session = z.infer<typeof SessionSchema> & {
428
+ _?: never;
429
+ };
430
+ export type LanguageContext = z.infer<typeof LanguageContextSchema> & {
431
+ _?: never;
432
+ };
433
+ export type RequestContext = z.infer<typeof RequestContextSchema> & {
434
+ _?: never;
435
+ };
436
+ export type TaxJurisdiction = z.infer<typeof TaxJurisdictionSchema> & {
437
+ _?: never;
438
+ };
439
+ export type IdentityContext = z.infer<typeof IdentityContextSchema> & {
440
+ _?: never;
441
+ };
@@ -2,4 +2,7 @@ import type z from "zod";
2
2
  export type StripIndexSignature<T> = T extends (infer U)[] ? StripIndexSignature<U>[] : T extends readonly (infer U)[] ? readonly StripIndexSignature<U>[] : T extends Set<infer U> ? Set<StripIndexSignature<U>> : T extends Map<infer K, infer V> ? Map<StripIndexSignature<K>, StripIndexSignature<V>> : T extends Promise<infer U> ? Promise<StripIndexSignature<U>> : T extends object ? {
3
3
  [K in keyof T as K extends string ? string extends K ? never : K : K]: StripIndexSignature<T[K]>;
4
4
  } : T;
5
- export type InferType<T extends z.ZodTypeAny> = StripIndexSignature<z.infer<T>>;
5
+ export type AvoidSimplification<T> = T & {
6
+ _?: never;
7
+ };
8
+ export type InferType<T extends z.ZodTypeAny> = AvoidSimplification<StripIndexSignature<z.infer<T>>>;
@@ -1,20 +0,0 @@
1
- import { z } from "zod";
2
- import { BaseMutationSchema } from "./base.mutation.js";
3
- import { ProductIdentifierSchema, ProductSearchIdentifierSchema } from "../models/identifiers.model.js";
4
- const AnalyticsMutationSearchEventSchema = BaseMutationSchema.extend({
5
- mutation: z.literal("search"),
6
- search: ProductSearchIdentifierSchema,
7
- products: z.array(ProductIdentifierSchema)
8
- });
9
- const AnalyticsMutationSearchProductClickEventSchema = BaseMutationSchema.extend({
10
- mutation: z.literal("product-search-click"),
11
- search: ProductSearchIdentifierSchema,
12
- product: ProductIdentifierSchema,
13
- position: z.number().min(0)
14
- });
15
- const AnalyticsMutationSchema = z.union([AnalyticsMutationSearchEventSchema, AnalyticsMutationSearchProductClickEventSchema]);
16
- export {
17
- AnalyticsMutationSchema,
18
- AnalyticsMutationSearchEventSchema,
19
- AnalyticsMutationSearchProductClickEventSchema
20
- };
@@ -1,110 +0,0 @@
1
- import { z } from 'zod';
2
- import type { InferType } from '../../zod-utils.js';
3
- export declare const AnalyticsMutationSearchEventSchema: z.ZodObject<{
4
- mutation: z.ZodLiteral<"search">;
5
- search: z.ZodObject<{
6
- term: z.ZodString;
7
- facets: z.ZodArray<z.ZodObject<{
8
- facet: z.ZodObject<{
9
- key: z.ZodString;
10
- }, z.core.$loose>;
11
- key: z.ZodString;
12
- }, z.core.$strip>>;
13
- filters: z.ZodArray<z.ZodString>;
14
- paginationOptions: z.ZodObject<{
15
- pageNumber: z.ZodDefault<z.ZodNumber>;
16
- pageSize: z.ZodDefault<z.ZodNumber>;
17
- }, z.core.$loose>;
18
- categoryFilter: z.ZodOptional<z.ZodObject<{
19
- facet: z.ZodObject<{
20
- key: z.ZodString;
21
- }, z.core.$loose>;
22
- key: z.ZodString;
23
- }, z.core.$strip>>;
24
- }, z.core.$loose>;
25
- products: z.ZodArray<z.ZodObject<{
26
- key: z.ZodString;
27
- }, z.core.$loose>>;
28
- }, z.core.$loose>;
29
- export declare const AnalyticsMutationSearchProductClickEventSchema: z.ZodObject<{
30
- mutation: z.ZodLiteral<"product-search-click">;
31
- search: z.ZodObject<{
32
- term: z.ZodString;
33
- facets: z.ZodArray<z.ZodObject<{
34
- facet: z.ZodObject<{
35
- key: z.ZodString;
36
- }, z.core.$loose>;
37
- key: z.ZodString;
38
- }, z.core.$strip>>;
39
- filters: z.ZodArray<z.ZodString>;
40
- paginationOptions: z.ZodObject<{
41
- pageNumber: z.ZodDefault<z.ZodNumber>;
42
- pageSize: z.ZodDefault<z.ZodNumber>;
43
- }, z.core.$loose>;
44
- categoryFilter: z.ZodOptional<z.ZodObject<{
45
- facet: z.ZodObject<{
46
- key: z.ZodString;
47
- }, z.core.$loose>;
48
- key: z.ZodString;
49
- }, z.core.$strip>>;
50
- }, z.core.$loose>;
51
- product: z.ZodObject<{
52
- key: z.ZodString;
53
- }, z.core.$loose>;
54
- position: z.ZodNumber;
55
- }, z.core.$loose>;
56
- export declare const AnalyticsMutationSchema: z.ZodUnion<readonly [z.ZodObject<{
57
- mutation: z.ZodLiteral<"search">;
58
- search: z.ZodObject<{
59
- term: z.ZodString;
60
- facets: z.ZodArray<z.ZodObject<{
61
- facet: z.ZodObject<{
62
- key: z.ZodString;
63
- }, z.core.$loose>;
64
- key: z.ZodString;
65
- }, z.core.$strip>>;
66
- filters: z.ZodArray<z.ZodString>;
67
- paginationOptions: z.ZodObject<{
68
- pageNumber: z.ZodDefault<z.ZodNumber>;
69
- pageSize: z.ZodDefault<z.ZodNumber>;
70
- }, z.core.$loose>;
71
- categoryFilter: z.ZodOptional<z.ZodObject<{
72
- facet: z.ZodObject<{
73
- key: z.ZodString;
74
- }, z.core.$loose>;
75
- key: z.ZodString;
76
- }, z.core.$strip>>;
77
- }, z.core.$loose>;
78
- products: z.ZodArray<z.ZodObject<{
79
- key: z.ZodString;
80
- }, z.core.$loose>>;
81
- }, z.core.$loose>, z.ZodObject<{
82
- mutation: z.ZodLiteral<"product-search-click">;
83
- search: z.ZodObject<{
84
- term: z.ZodString;
85
- facets: z.ZodArray<z.ZodObject<{
86
- facet: z.ZodObject<{
87
- key: z.ZodString;
88
- }, z.core.$loose>;
89
- key: z.ZodString;
90
- }, z.core.$strip>>;
91
- filters: z.ZodArray<z.ZodString>;
92
- paginationOptions: z.ZodObject<{
93
- pageNumber: z.ZodDefault<z.ZodNumber>;
94
- pageSize: z.ZodDefault<z.ZodNumber>;
95
- }, z.core.$loose>;
96
- categoryFilter: z.ZodOptional<z.ZodObject<{
97
- facet: z.ZodObject<{
98
- key: z.ZodString;
99
- }, z.core.$loose>;
100
- key: z.ZodString;
101
- }, z.core.$strip>>;
102
- }, z.core.$loose>;
103
- product: z.ZodObject<{
104
- key: z.ZodString;
105
- }, z.core.$loose>;
106
- position: z.ZodNumber;
107
- }, z.core.$loose>]>;
108
- export type AnalyticsMutation = InferType<typeof AnalyticsMutationSchema>;
109
- export type AnalyticsMutationSearchEvent = InferType<typeof AnalyticsMutationSearchEventSchema>;
110
- export type AnalyticsMutationSearchProductClickEvent = InferType<typeof AnalyticsMutationSearchProductClickEventSchema>;