@reactionary/core 0.0.37 → 0.0.39

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 (48) hide show
  1. package/index.js +3 -8
  2. package/package.json +2 -3
  3. package/providers/analytics.provider.js +3 -0
  4. package/providers/base.provider.js +20 -1
  5. package/providers/cart.provider.js +3 -0
  6. package/providers/category.provider.js +9 -0
  7. package/providers/identity.provider.js +3 -0
  8. package/providers/inventory.provider.js +3 -0
  9. package/providers/price.provider.js +26 -0
  10. package/providers/product.provider.js +3 -0
  11. package/providers/search.provider.js +3 -0
  12. package/schemas/capabilities.schema.js +2 -1
  13. package/schemas/models/base.model.js +24 -1
  14. package/schemas/models/cart.model.js +24 -3
  15. package/schemas/models/category.model.js +16 -0
  16. package/schemas/models/identifiers.model.js +18 -1
  17. package/schemas/models/inventory.model.js +5 -1
  18. package/schemas/models/price.model.js +9 -3
  19. package/schemas/queries/category.query.js +27 -0
  20. package/schemas/queries/index.js +9 -0
  21. package/schemas/queries/inventory.query.js +7 -2
  22. package/schemas/session.schema.js +11 -1
  23. package/src/client/client.d.ts +2 -0
  24. package/src/index.d.ts +3 -8
  25. package/src/providers/analytics.provider.d.ts +1 -0
  26. package/src/providers/base.provider.d.ts +11 -2
  27. package/src/providers/cart.provider.d.ts +1 -0
  28. package/src/providers/category.provider.d.ts +67 -0
  29. package/src/providers/identity.provider.d.ts +1 -0
  30. package/src/providers/inventory.provider.d.ts +1 -0
  31. package/src/providers/price.provider.d.ts +29 -0
  32. package/src/providers/product.provider.d.ts +1 -0
  33. package/src/providers/search.provider.d.ts +1 -0
  34. package/src/schemas/capabilities.schema.d.ts +1 -0
  35. package/src/schemas/models/base.model.d.ts +51 -0
  36. package/src/schemas/models/cart.model.d.ts +4584 -0
  37. package/src/schemas/models/category.model.d.ts +130 -0
  38. package/src/schemas/models/identifiers.model.d.ts +49 -0
  39. package/src/schemas/models/inventory.model.d.ts +28 -0
  40. package/src/schemas/models/price.model.d.ts +394 -3
  41. package/src/schemas/mutations/analytics.mutation.d.ts +4 -4
  42. package/src/schemas/queries/category.query.d.ts +94 -0
  43. package/src/schemas/queries/index.d.ts +9 -0
  44. package/src/schemas/queries/inventory.query.d.ts +39 -3
  45. package/src/schemas/queries/search.query.d.ts +1 -1
  46. package/src/schemas/session.schema.d.ts +386 -0
  47. package/decorators/trpc.decorators.js +0 -66
  48. package/src/decorators/trpc.decorators.d.ts +0 -88
@@ -1,7 +1,36 @@
1
+ import { Currency } from '../schemas/models/currency.model';
1
2
  import { Price } from '../schemas/models/price.model';
2
3
  import { PriceQueryBySku } from '../schemas/queries/price.query';
3
4
  import { Session } from '../schemas/session.schema';
4
5
  import { BaseProvider } from './base.provider';
5
6
  export declare abstract class PriceProvider<T extends Price = Price> extends BaseProvider<T> {
7
+ /**
8
+ * Get a price by SKU.
9
+ *
10
+ * Note: This does not include any discounts or promotions that may apply.
11
+ * For B2B scenarios, this will be the base price, and any customer specific pricing
12
+ *
13
+ * Usecase: You are rendering a product page, and you need to show the price for a SKU.
14
+ * @param payload The SKU to query
15
+ * @param session The session information
16
+ */
6
17
  abstract getBySKU(payload: PriceQueryBySku, session: Session): Promise<T>;
18
+ /**
19
+ * Fetch prices for multiple SKUs in one go.
20
+ *
21
+ * Usecase: You are rendering a product grid, and you need to show prices for multiple SKUs.
22
+ * @param payload The SKUs to query
23
+ * @param session The session information
24
+ */
25
+ abstract getBySKUs(payload: PriceQueryBySku[], session: Session): Promise<T[]>;
26
+ /**
27
+ * Utility function to create an empty price result, with a value of -1.
28
+ * This is used when no price is found for a given SKU + currency combination.
29
+ * You should check for meta.placeholder to see if this is a real price or a placeholder.
30
+ * @param sku
31
+ * @param currency
32
+ * @returns
33
+ */
34
+ protected getEmptyPriceResult(sku: string, currency: Currency): T;
35
+ protected getResourceName(): string;
7
36
  }
@@ -5,4 +5,5 @@ import { ProductQueryById, ProductQueryBySlug } from '../schemas/queries/product
5
5
  export declare abstract class ProductProvider<T extends Product = Product> extends BaseProvider<T> {
6
6
  abstract getById(payload: ProductQueryById, session: Session): Promise<T>;
7
7
  abstract getBySlug(payload: ProductQueryBySlug, session: Session): Promise<T>;
8
+ protected getResourceName(): string;
8
9
  }
@@ -4,4 +4,5 @@ import { Session } from '../schemas/session.schema';
4
4
  import { BaseProvider } from './base.provider';
5
5
  export declare abstract class SearchProvider<T extends SearchResult = SearchResult> extends BaseProvider<T> {
6
6
  abstract queryByTerm(payload: SearchQueryByTerm, session: Session): Promise<SearchResult>;
7
+ protected getResourceName(): string;
7
8
  }
@@ -7,6 +7,7 @@ export declare const CapabilitiesSchema: z.ZodInterface<{
7
7
  cart: z.ZodBoolean;
8
8
  inventory: z.ZodBoolean;
9
9
  price: z.ZodBoolean;
10
+ category: z.ZodBoolean;
10
11
  }, {
11
12
  optional: never;
12
13
  defaulted: never;
@@ -46,3 +46,54 @@ export declare const BaseModelSchema: z.ZodInterface<{
46
46
  export type CacheInformation = z.infer<typeof CacheInformationSchema>;
47
47
  export type Meta = z.infer<typeof MetaSchema>;
48
48
  export type BaseModel = z.infer<typeof BaseModelSchema>;
49
+ export declare const PaginationOptionsSchema: z.ZodInterface<{
50
+ pageNumber: z.ZodDefault<z.ZodNumber>;
51
+ pageSize: z.ZodDefault<z.ZodNumber>;
52
+ }, {
53
+ optional: never;
54
+ defaulted: never;
55
+ extra: Record<string, unknown>;
56
+ }>;
57
+ export type PaginationOptions = z.infer<typeof PaginationOptionsSchema>;
58
+ /**
59
+ * This seemed like the right way to do it, but we need to be able to pass in the item schema even later than this
60
+ *
61
+ **/
62
+ export declare function createPaginatedResponseSchema<ItemType extends z.ZodTypeAny>(itemSchema: ItemType): z.ZodObject<{
63
+ meta: z.ZodDefault<z.ZodInterface<{
64
+ cache: z.ZodDefault<z.ZodInterface<{
65
+ hit: z.ZodDefault<z.ZodBoolean>;
66
+ key: z.ZodDefault<z.ZodString>;
67
+ }, {
68
+ optional: never;
69
+ defaulted: never;
70
+ extra: Record<string, unknown>;
71
+ }>>;
72
+ placeholder: z.ZodDefault<z.ZodBoolean>;
73
+ }, {
74
+ optional: never;
75
+ defaulted: never;
76
+ extra: Record<string, unknown>;
77
+ }>>;
78
+ pageNumber: z.ZodNumber;
79
+ pageSize: z.ZodNumber;
80
+ totalCount: z.ZodNumber;
81
+ totalPages: z.ZodNumber;
82
+ items: z.ZodArray<ItemType>;
83
+ }, {}>;
84
+ /**
85
+ * I posit, we should not have final urls in this, but rather assume the frontend has some kind of image transcoding/resizing service it will use to pass the image through, so
86
+ * what we really need is the original source url, and then some metadata about the image.
87
+ * Ie, rather than having distinct thumbnail and image fields, we just have a list of images, and the frontend will generate its own thumbnails as needed?
88
+ */
89
+ export declare const ImageSchema: z.ZodInterface<{
90
+ sourceUrl: z.ZodDefault<z.ZodString>;
91
+ altText: z.ZodDefault<z.ZodString>;
92
+ width: z.ZodOptional<z.ZodNumber>;
93
+ height: z.ZodOptional<z.ZodNumber>;
94
+ }, {
95
+ optional: never;
96
+ defaulted: never;
97
+ extra: Record<string, unknown>;
98
+ }>;
99
+ export type Image = z.infer<typeof ImageSchema>;