@reactionary/provider-fake 0.0.81 → 0.0.83

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.
@@ -22,7 +22,6 @@ function withFakeCapabilities(configuration, capabilities) {
22
22
  if (capabilities.product) {
23
23
  client.product = new FakeProductProvider(
24
24
  configuration,
25
- ProductSchema,
26
25
  cache,
27
26
  context
28
27
  );
@@ -30,7 +29,6 @@ function withFakeCapabilities(configuration, capabilities) {
30
29
  if (capabilities.productSearch) {
31
30
  client.productSearch = new FakeSearchProvider(
32
31
  configuration,
33
- ProductSearchResultItemSchema,
34
32
  cache,
35
33
  context
36
34
  );
@@ -38,27 +36,25 @@ function withFakeCapabilities(configuration, capabilities) {
38
36
  if (capabilities.category) {
39
37
  client.category = new FakeCategoryProvider(
40
38
  configuration,
41
- CategorySchema,
42
39
  cache,
43
40
  context
44
41
  );
45
42
  }
46
43
  if (capabilities.cart) {
47
- client.cart = new FakeCartProvider(configuration, CartSchema, cache, context);
44
+ client.cart = new FakeCartProvider(configuration, cache, context);
48
45
  }
49
46
  if (capabilities.inventory) {
50
47
  client.inventory = new FakeInventoryProvider(
51
48
  configuration,
52
- InventorySchema,
53
49
  cache,
54
50
  context
55
51
  );
56
52
  }
57
53
  if (capabilities.store) {
58
- client.store = new FakeStoreProvider(configuration, StoreSchema, cache, context);
54
+ client.store = new FakeStoreProvider(configuration, cache, context);
59
55
  }
60
56
  if (capabilities.price) {
61
- client.price = new FakePriceProvider(configuration, PriceSchema, cache, context);
57
+ client.price = new FakePriceProvider(configuration, cache, context);
62
58
  }
63
59
  return client;
64
60
  };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@reactionary/provider-fake",
3
- "version": "0.0.81",
3
+ "version": "0.0.83",
4
4
  "main": "index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "dependencies": {
7
- "@reactionary/core": "0.0.81",
7
+ "@reactionary/core": "0.0.83",
8
8
  "zod": "4.1.9",
9
9
  "@faker-js/faker": "^9.8.0"
10
10
  },
@@ -2,8 +2,8 @@ import {
2
2
  AnalyticsProvider
3
3
  } from "@reactionary/core";
4
4
  class FakeAnalyticsProvider extends AnalyticsProvider {
5
- constructor(config, schema, cache, context) {
6
- super(schema, cache, context);
5
+ constructor(config, cache, context) {
6
+ super(cache, context);
7
7
  this.config = config;
8
8
  }
9
9
  }
@@ -1,10 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
1
12
  import {
2
- CartProvider
13
+ CartIdentifierSchema,
14
+ CartMutationApplyCouponSchema,
15
+ CartMutationChangeCurrencySchema,
16
+ CartMutationDeleteCartSchema,
17
+ CartMutationItemAddSchema,
18
+ CartMutationItemQuantityChangeSchema,
19
+ CartMutationItemRemoveSchema,
20
+ CartMutationRemoveCouponSchema,
21
+ CartProvider,
22
+ CartQueryByIdSchema,
23
+ CartSchema,
24
+ Reactionary
3
25
  } from "@reactionary/core";
4
26
  import { Faker, en, base } from "@faker-js/faker";
5
27
  class FakeCartProvider extends CartProvider {
6
- constructor(config, schema, cache, context) {
7
- super(schema, cache, context);
28
+ constructor(config, cache, context) {
29
+ super(cache, context);
8
30
  this.carts = /* @__PURE__ */ new Map();
9
31
  this.generator = new Faker({
10
32
  locale: [en, base],
@@ -15,27 +37,12 @@ class FakeCartProvider extends CartProvider {
15
37
  async getById(payload) {
16
38
  const cartId = payload.cart.key;
17
39
  if (payload.cart.key === "") {
18
- const result = this.newModel();
19
- result.meta = {
20
- cache: { hit: false, key: "empty" },
21
- placeholder: true
22
- };
23
- return this.assert(result);
40
+ return this.createEmptyCart();
24
41
  }
25
42
  if (!this.carts.has(cartId)) {
26
- const model = this.newModel();
27
- Object.assign(model, {
28
- identifier: { key: cartId },
29
- items: [],
30
- meta: {
31
- cache: {
32
- hit: false,
33
- key: cartId
34
- },
35
- placeholder: false
36
- }
37
- });
38
- this.carts.set(cartId, this.assert(model));
43
+ const cart2 = this.createEmptyCart();
44
+ cart2.identifier.key = cartId;
45
+ this.carts.set(cartId, cart2);
39
46
  }
40
47
  const cart = this.carts.get(cartId);
41
48
  if (!cart) {
@@ -82,7 +89,7 @@ class FakeCartProvider extends CartProvider {
82
89
  });
83
90
  }
84
91
  this.recalculateCart(cart);
85
- return this.assert(cart);
92
+ return cart;
86
93
  }
87
94
  async remove(payload) {
88
95
  const cartId = payload.cart.key || `cart-${this.generator.string.uuid()}`;
@@ -91,7 +98,7 @@ class FakeCartProvider extends CartProvider {
91
98
  (item) => item.identifier.key !== payload.item.key
92
99
  );
93
100
  this.recalculateCart(cart);
94
- return this.assert(cart);
101
+ return cart;
95
102
  }
96
103
  async changeQuantity(payload) {
97
104
  const cartId = payload.cart.key || `cart-${this.generator.string.uuid()}`;
@@ -106,7 +113,7 @@ class FakeCartProvider extends CartProvider {
106
113
  item.quantity = payload.quantity;
107
114
  }
108
115
  this.recalculateCart(cart);
109
- return this.assert(cart);
116
+ return cart;
110
117
  }
111
118
  getActiveCartId() {
112
119
  throw new Error("Method not implemented.");
@@ -137,6 +144,59 @@ class FakeCartProvider extends CartProvider {
137
144
  };
138
145
  }
139
146
  }
147
+ __decorateClass([
148
+ Reactionary({
149
+ inputSchema: CartQueryByIdSchema,
150
+ outputSchema: CartSchema
151
+ })
152
+ ], FakeCartProvider.prototype, "getById", 1);
153
+ __decorateClass([
154
+ Reactionary({
155
+ inputSchema: CartMutationItemAddSchema,
156
+ outputSchema: CartSchema
157
+ })
158
+ ], FakeCartProvider.prototype, "add", 1);
159
+ __decorateClass([
160
+ Reactionary({
161
+ inputSchema: CartMutationItemRemoveSchema,
162
+ outputSchema: CartSchema
163
+ })
164
+ ], FakeCartProvider.prototype, "remove", 1);
165
+ __decorateClass([
166
+ Reactionary({
167
+ inputSchema: CartMutationItemQuantityChangeSchema,
168
+ outputSchema: CartSchema
169
+ })
170
+ ], FakeCartProvider.prototype, "changeQuantity", 1);
171
+ __decorateClass([
172
+ Reactionary({
173
+ outputSchema: CartIdentifierSchema
174
+ })
175
+ ], FakeCartProvider.prototype, "getActiveCartId", 1);
176
+ __decorateClass([
177
+ Reactionary({
178
+ inputSchema: CartMutationDeleteCartSchema,
179
+ outputSchema: CartSchema
180
+ })
181
+ ], FakeCartProvider.prototype, "deleteCart", 1);
182
+ __decorateClass([
183
+ Reactionary({
184
+ inputSchema: CartMutationApplyCouponSchema,
185
+ outputSchema: CartSchema
186
+ })
187
+ ], FakeCartProvider.prototype, "applyCouponCode", 1);
188
+ __decorateClass([
189
+ Reactionary({
190
+ inputSchema: CartMutationRemoveCouponSchema,
191
+ outputSchema: CartSchema
192
+ })
193
+ ], FakeCartProvider.prototype, "removeCouponCode", 1);
194
+ __decorateClass([
195
+ Reactionary({
196
+ inputSchema: CartMutationChangeCurrencySchema,
197
+ outputSchema: CartSchema
198
+ })
199
+ ], FakeCartProvider.prototype, "changeCurrency", 1);
140
200
  export {
141
201
  FakeCartProvider
142
202
  };
@@ -9,11 +9,12 @@ var __decorateClass = (decorators, target, key, kind) => {
9
9
  __defProp(target, key, result);
10
10
  return result;
11
11
  };
12
- import { CategoryProvider, Reactionary } from "@reactionary/core";
12
+ import { CategoryPaginatedResultSchema, CategoryProvider, CategoryQueryByIdSchema, CategoryQueryBySlugSchema, CategoryQueryForBreadcrumbSchema, CategoryQueryForChildCategoriesSchema, CategoryQueryForTopCategoriesSchema, CategorySchema, Reactionary } from "@reactionary/core";
13
+ import z from "zod";
13
14
  import { Faker, en, base } from "@faker-js/faker";
14
15
  class FakeCategoryProvider extends CategoryProvider {
15
- constructor(config, schema, cache, context) {
16
- super(schema, cache, context);
16
+ constructor(config, cache, context) {
17
+ super(cache, context);
17
18
  this.topCategories = new Array();
18
19
  this.childCategories = /* @__PURE__ */ new Map();
19
20
  this.allCategories = /* @__PURE__ */ new Map();
@@ -48,24 +49,35 @@ class FakeCategoryProvider extends CategoryProvider {
48
49
  } else {
49
50
  name = `${parent.name}-${index}`;
50
51
  }
51
- const category = this.newModel();
52
- category.identifier = { key: name.toLowerCase().replace(/\s+/g, "-") };
53
- category.name = name;
54
- category.text = this.categoryGenerator.lorem.sentences(3);
55
- category.slug = category.identifier.key + "-slug";
52
+ const identifier = { key: name.toLowerCase().replace(/\s+/g, "-") };
53
+ const text = this.categoryGenerator.lorem.sentences(3);
54
+ const slug = identifier.key + "-slug";
55
+ let parentCategory;
56
56
  if (parent) {
57
- category.parentCategory = parent.identifier;
57
+ parentCategory = parent.identifier;
58
58
  }
59
- this.allCategories.set(category.identifier.key, category);
59
+ const category = {
60
+ identifier,
61
+ images: [],
62
+ meta: {
63
+ cache: {
64
+ hit: false,
65
+ key: ""
66
+ },
67
+ placeholder: false
68
+ },
69
+ name,
70
+ slug,
71
+ text,
72
+ parentCategory
73
+ };
74
+ this.allCategories.set(identifier.key, category);
60
75
  return category;
61
76
  }
62
77
  async getById(payload) {
63
78
  const category = this.allCategories.get(payload.id.key);
64
79
  if (!category) {
65
- const dummyCategory = this.newModel();
66
- dummyCategory.meta.placeholder = true;
67
- dummyCategory.identifier = { key: payload.id.key };
68
- return dummyCategory;
80
+ throw new Error("This should not happen...");
69
81
  }
70
82
  return category;
71
83
  }
@@ -129,14 +141,35 @@ class FakeCategoryProvider extends CategoryProvider {
129
141
  }
130
142
  }
131
143
  __decorateClass([
132
- Reactionary({})
144
+ Reactionary({
145
+ inputSchema: CategoryQueryByIdSchema,
146
+ outputSchema: CategorySchema
147
+ })
133
148
  ], FakeCategoryProvider.prototype, "getById", 1);
134
149
  __decorateClass([
135
- Reactionary({})
150
+ Reactionary({
151
+ inputSchema: CategoryQueryBySlugSchema,
152
+ outputSchema: CategorySchema
153
+ })
136
154
  ], FakeCategoryProvider.prototype, "getBySlug", 1);
137
155
  __decorateClass([
138
- Reactionary({})
156
+ Reactionary({
157
+ inputSchema: CategoryQueryForBreadcrumbSchema,
158
+ outputSchema: z.array(CategorySchema)
159
+ })
139
160
  ], FakeCategoryProvider.prototype, "getBreadcrumbPathToCategory", 1);
161
+ __decorateClass([
162
+ Reactionary({
163
+ inputSchema: CategoryQueryForChildCategoriesSchema,
164
+ outputSchema: CategoryPaginatedResultSchema
165
+ })
166
+ ], FakeCategoryProvider.prototype, "findChildCategories", 1);
167
+ __decorateClass([
168
+ Reactionary({
169
+ inputSchema: CategoryQueryForTopCategoriesSchema,
170
+ outputSchema: CategoryPaginatedResultSchema
171
+ })
172
+ ], FakeCategoryProvider.prototype, "findTopCategories", 1);
140
173
  export {
141
174
  FakeCategoryProvider
142
175
  };
@@ -1,22 +1,34 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
1
12
  import {
2
- IdentityProvider
13
+ IdentityProvider,
14
+ Reactionary,
15
+ IdentityMutationRegisterSchema,
16
+ IdentitySchema,
17
+ IdentityMutationLogoutSchema,
18
+ IdentityMutationLoginSchema,
19
+ IdentityQuerySelfSchema
3
20
  } from "@reactionary/core";
4
21
  import { base, en, Faker } from "@faker-js/faker";
5
22
  class FakeIdentityProvider extends IdentityProvider {
6
- constructor(config, schema, cache, context) {
7
- super(schema, cache, context);
23
+ constructor(config, cache, context) {
24
+ super(cache, context);
8
25
  this.currentIdentity = null;
9
26
  this.config = config;
10
27
  }
11
28
  async getSelf(_payload) {
12
29
  if (!this.currentIdentity) {
13
- const model = this.newModel();
14
- Object.assign(model, {
15
- id: "anonymous",
30
+ const model = {
16
31
  type: "Anonymous",
17
- issued: /* @__PURE__ */ new Date(),
18
- expiry: new Date(Date.now() + 24 * 60 * 60 * 1e3),
19
- // 24 hours from now
20
32
  meta: {
21
33
  cache: {
22
34
  hit: false,
@@ -24,8 +36,8 @@ class FakeIdentityProvider extends IdentityProvider {
24
36
  },
25
37
  placeholder: false
26
38
  }
27
- });
28
- this.currentIdentity = this.assert(model);
39
+ };
40
+ this.currentIdentity = model;
29
41
  }
30
42
  return this.currentIdentity;
31
43
  }
@@ -34,14 +46,11 @@ class FakeIdentityProvider extends IdentityProvider {
34
46
  seed: 42,
35
47
  locale: [en, base]
36
48
  });
37
- const model = this.newModel();
38
- Object.assign(model, {
39
- id: generator.string.uuid(),
49
+ const model = {
40
50
  type: "Registered",
41
- token: generator.string.alphanumeric(32),
42
- issued: /* @__PURE__ */ new Date(),
43
- expiry: new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3),
44
- // 7 days from now
51
+ id: {
52
+ userId: generator.string.alphanumeric(32)
53
+ },
45
54
  meta: {
46
55
  cache: {
47
56
  hit: false,
@@ -49,18 +58,13 @@ class FakeIdentityProvider extends IdentityProvider {
49
58
  },
50
59
  placeholder: false
51
60
  }
52
- });
53
- this.currentIdentity = this.assert(model);
61
+ };
62
+ this.currentIdentity = model;
54
63
  return this.currentIdentity;
55
64
  }
56
65
  async logout(_payload) {
57
- const model = this.newModel();
58
- Object.assign(model, {
59
- id: "anonymous",
66
+ const model = {
60
67
  type: "Anonymous",
61
- issued: /* @__PURE__ */ new Date(),
62
- expiry: new Date(Date.now() + 24 * 60 * 60 * 1e3),
63
- // 24 hours from now
64
68
  meta: {
65
69
  cache: {
66
70
  hit: false,
@@ -68,14 +72,38 @@ class FakeIdentityProvider extends IdentityProvider {
68
72
  },
69
73
  placeholder: false
70
74
  }
71
- });
72
- this.currentIdentity = this.assert(model);
75
+ };
76
+ this.currentIdentity = model;
73
77
  return this.currentIdentity;
74
78
  }
75
79
  register(payload) {
76
80
  throw new Error("Method not implemented.");
77
81
  }
78
82
  }
83
+ __decorateClass([
84
+ Reactionary({
85
+ inputSchema: IdentityQuerySelfSchema,
86
+ outputSchema: IdentitySchema
87
+ })
88
+ ], FakeIdentityProvider.prototype, "getSelf", 1);
89
+ __decorateClass([
90
+ Reactionary({
91
+ inputSchema: IdentityMutationLoginSchema,
92
+ outputSchema: IdentitySchema
93
+ })
94
+ ], FakeIdentityProvider.prototype, "login", 1);
95
+ __decorateClass([
96
+ Reactionary({
97
+ inputSchema: IdentityMutationLogoutSchema,
98
+ outputSchema: IdentitySchema
99
+ })
100
+ ], FakeIdentityProvider.prototype, "logout", 1);
101
+ __decorateClass([
102
+ Reactionary({
103
+ inputSchema: IdentityMutationRegisterSchema,
104
+ outputSchema: IdentitySchema
105
+ })
106
+ ], FakeIdentityProvider.prototype, "register", 1);
79
107
  export {
80
108
  FakeIdentityProvider
81
109
  };
@@ -1,11 +1,24 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
1
12
  import { base, en, Faker } from "@faker-js/faker";
2
13
  import {
3
- InventoryIdentifierSchema,
4
- InventoryProvider
14
+ InventoryProvider,
15
+ InventoryQueryBySKUSchema,
16
+ InventorySchema,
17
+ Reactionary
5
18
  } from "@reactionary/core";
6
19
  class FakeInventoryProvider extends InventoryProvider {
7
- constructor(config, schema, cache, context) {
8
- super(schema, cache, context);
20
+ constructor(config, cache, context) {
21
+ super(cache, context);
9
22
  this.config = config;
10
23
  }
11
24
  async getBySKU(payload) {
@@ -19,27 +32,37 @@ class FakeInventoryProvider extends InventoryProvider {
19
32
  seed: hash || 42,
20
33
  locale: [en, base]
21
34
  });
22
- const model = this.newModel();
23
- model.identifier = InventoryIdentifierSchema.parse({
35
+ const identifier = {
24
36
  variant: payload.variant,
25
37
  fulfillmentCenter: payload.fulfilmentCenter
26
- });
27
- model.quantity = generator.number.int({ min: 0, max: 100 });
28
- if (model.quantity > 0) {
29
- model.status = "inStock";
30
- } else {
31
- model.status = "outOfStock";
38
+ };
39
+ const quantity = generator.number.int({ min: 0, max: 100 });
40
+ let status = "outOfStock";
41
+ if (quantity > 0) {
42
+ status = "inStock";
32
43
  }
33
- model.meta = {
44
+ const meta = {
34
45
  cache: {
35
46
  hit: false,
36
- key: this.generateCacheKeySingle(model.identifier)
47
+ key: this.generateCacheKeySingle(identifier)
37
48
  },
38
49
  placeholder: false
39
50
  };
40
- return this.assert(model);
51
+ const result = {
52
+ identifier,
53
+ meta,
54
+ quantity,
55
+ status
56
+ };
57
+ return result;
41
58
  }
42
59
  }
60
+ __decorateClass([
61
+ Reactionary({
62
+ inputSchema: InventoryQueryBySKUSchema,
63
+ outputSchema: InventorySchema
64
+ })
65
+ ], FakeInventoryProvider.prototype, "getBySKU", 1);
43
66
  export {
44
67
  FakeInventoryProvider
45
68
  };
@@ -1,10 +1,25 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
1
12
  import {
2
- PriceProvider
13
+ PriceProvider,
14
+ Reactionary,
15
+ CustomerPriceQuerySchema,
16
+ PriceSchema,
17
+ ListPriceQuerySchema
3
18
  } from "@reactionary/core";
4
19
  import { base, en, Faker } from "@faker-js/faker";
5
20
  class FakePriceProvider extends PriceProvider {
6
- constructor(config, schema, cache, context) {
7
- super(schema, cache, context);
21
+ constructor(config, cache, context) {
22
+ super(cache, context);
8
23
  this.config = config;
9
24
  }
10
25
  async getListPrice(payload) {
@@ -21,8 +36,7 @@ class FakePriceProvider extends PriceProvider {
21
36
  seed: hash || 42,
22
37
  locale: [en, base]
23
38
  });
24
- const model = this.newModel();
25
- Object.assign(model, {
39
+ const model = {
26
40
  identifier: {
27
41
  variant: payload.variant
28
42
  },
@@ -37,7 +51,7 @@ class FakePriceProvider extends PriceProvider {
37
51
  },
38
52
  placeholder: false
39
53
  }
40
- });
54
+ };
41
55
  if (skuString.includes("with-tiers")) {
42
56
  const unitPrice = model.unitPrice?.value || 0;
43
57
  const tier1Price = unitPrice * 0.8;
@@ -61,7 +75,7 @@ class FakePriceProvider extends PriceProvider {
61
75
  } else {
62
76
  model.tieredPrices = [];
63
77
  }
64
- return this.assert(model);
78
+ return model;
65
79
  }
66
80
  async getCustomerPrice(payload) {
67
81
  if (payload.variant.sku === "unknown-sku") {
@@ -77,8 +91,7 @@ class FakePriceProvider extends PriceProvider {
77
91
  seed: hash || 42,
78
92
  locale: [en, base]
79
93
  });
80
- const model = this.newModel();
81
- Object.assign(model, {
94
+ const model = {
82
95
  identifier: {
83
96
  variant: payload.variant
84
97
  },
@@ -93,7 +106,7 @@ class FakePriceProvider extends PriceProvider {
93
106
  },
94
107
  placeholder: false
95
108
  }
96
- });
109
+ };
97
110
  if (skuString.includes("with-tiers")) {
98
111
  const unitPrice = model.unitPrice?.value || 0;
99
112
  const tier1Price = unitPrice * 0.8;
@@ -117,9 +130,21 @@ class FakePriceProvider extends PriceProvider {
117
130
  } else {
118
131
  model.tieredPrices = [];
119
132
  }
120
- return this.assert(model);
133
+ return model;
121
134
  }
122
135
  }
136
+ __decorateClass([
137
+ Reactionary({
138
+ inputSchema: ListPriceQuerySchema,
139
+ outputSchema: PriceSchema
140
+ })
141
+ ], FakePriceProvider.prototype, "getListPrice", 1);
142
+ __decorateClass([
143
+ Reactionary({
144
+ inputSchema: CustomerPriceQuerySchema,
145
+ outputSchema: PriceSchema
146
+ })
147
+ ], FakePriceProvider.prototype, "getCustomerPrice", 1);
123
148
  export {
124
149
  FakePriceProvider
125
150
  };
@@ -1,14 +1,27 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
1
12
  import {
2
13
  ImageSchema,
3
14
  ProductSearchProvider,
15
+ ProductSearchQueryByTermSchema,
4
16
  ProductSearchResultItemSchema,
5
- ProductSearchResultSchema
17
+ ProductSearchResultSchema,
18
+ Reactionary
6
19
  } from "@reactionary/core";
7
20
  import { Faker, en, base } from "@faker-js/faker";
8
21
  import { jitter } from "../utilities/jitter.js";
9
22
  class FakeSearchProvider extends ProductSearchProvider {
10
- constructor(config, schema, cache, context) {
11
- super(schema, cache, context);
23
+ constructor(config, cache, context) {
24
+ super(cache, context);
12
25
  this.config = config;
13
26
  }
14
27
  async queryByTerm(payload) {
@@ -47,7 +60,6 @@ class FakeSearchProvider extends ProductSearchProvider {
47
60
  identifier: {
48
61
  key: "product_" + productGenerator.commerce.isbn()
49
62
  },
50
- image: img,
51
63
  name: productGenerator.commerce.productName(),
52
64
  slug: productGenerator.lorem.slug(),
53
65
  variants: [{
@@ -130,6 +142,12 @@ class FakeSearchProvider extends ProductSearchProvider {
130
142
  return foo;
131
143
  }
132
144
  }
145
+ __decorateClass([
146
+ Reactionary({
147
+ inputSchema: ProductSearchQueryByTermSchema,
148
+ outputSchema: ProductSearchResultSchema
149
+ })
150
+ ], FakeSearchProvider.prototype, "queryByTerm", 1);
133
151
  export {
134
152
  FakeSearchProvider
135
153
  };
@@ -11,12 +11,16 @@ var __decorateClass = (decorators, target, key, kind) => {
11
11
  };
12
12
  import {
13
13
  ProductProvider,
14
- Reactionary
14
+ Reactionary,
15
+ ProductQueryByIdSchema,
16
+ ProductSchema,
17
+ ProductQueryBySlugSchema,
18
+ ProductQueryBySKUSchema
15
19
  } from "@reactionary/core";
16
20
  import { base, en, Faker } from "@faker-js/faker";
17
21
  class FakeProductProvider extends ProductProvider {
18
- constructor(config, schema, cache, context) {
19
- super(schema, cache, context);
22
+ constructor(config, cache, context) {
23
+ super(cache, context);
20
24
  this.config = config;
21
25
  }
22
26
  async getById(payload) {
@@ -34,40 +38,60 @@ class FakeProductProvider extends ProductProvider {
34
38
  locale: [en, base]
35
39
  });
36
40
  const key = body;
37
- const model = this.newModel();
38
- Object.assign(model, {
41
+ const result = {
39
42
  identifier: {
40
43
  key
41
44
  },
42
45
  name: generator.commerce.productName(),
43
46
  slug: key,
44
- attributes: [],
47
+ brand: "",
48
+ longDescription: "",
49
+ mainVariant: {
50
+ barcode: "",
51
+ ean: "",
52
+ gtin: "",
53
+ identifier: {
54
+ sku: ""
55
+ },
56
+ images: [],
57
+ name: "",
58
+ options: [],
59
+ upc: ""
60
+ },
45
61
  description: generator.commerce.productDescription(),
46
- image: generator.image.urlPicsumPhotos({
47
- width: 600,
48
- height: 600
49
- }),
50
- images: [],
62
+ manufacturer: "",
63
+ options: [],
64
+ parentCategories: [],
65
+ published: true,
66
+ sharedAttributes: [],
51
67
  meta: {
52
68
  cache: {
53
69
  hit: false,
54
70
  key
55
71
  },
56
72
  placeholder: false
57
- },
58
- skus: []
59
- });
60
- return this.assert(model);
73
+ }
74
+ };
75
+ return result;
61
76
  }
62
77
  }
63
78
  __decorateClass([
64
- Reactionary({})
79
+ Reactionary({
80
+ inputSchema: ProductQueryByIdSchema,
81
+ outputSchema: ProductSchema
82
+ })
65
83
  ], FakeProductProvider.prototype, "getById", 1);
66
84
  __decorateClass([
67
- Reactionary({})
85
+ Reactionary({
86
+ inputSchema: ProductQueryBySlugSchema,
87
+ outputSchema: ProductSchema
88
+ })
68
89
  ], FakeProductProvider.prototype, "getBySlug", 1);
69
90
  __decorateClass([
70
- Reactionary({})
91
+ Reactionary({
92
+ inputSchema: ProductQueryBySKUSchema,
93
+ outputSchema: ProductSchema
94
+ })
71
95
  ], FakeProductProvider.prototype, "getBySKU", 1);
72
96
  export {
73
97
  FakeProductProvider
@@ -1,8 +1,20 @@
1
- import { StoreProvider } from "@reactionary/core";
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ import { Reactionary, StoreProvider, StoreQueryByProximitySchema, StoreSchema } from "@reactionary/core";
13
+ import z from "zod";
2
14
  import { base, en, Faker } from "@faker-js/faker";
3
15
  class FakeStoreProvider extends StoreProvider {
4
- constructor(config, schema, cache, context) {
5
- super(schema, cache, context);
16
+ constructor(config, cache, context) {
17
+ super(cache, context);
6
18
  this.config = config;
7
19
  }
8
20
  async queryByProximity(payload) {
@@ -10,17 +22,38 @@ class FakeStoreProvider extends StoreProvider {
10
22
  seed: 42,
11
23
  locale: [en, base]
12
24
  });
13
- const results = [];
25
+ const results = new Array();
14
26
  for (let i = 0; i < payload.limit; i++) {
15
- const model = this.newModel();
16
- model.name = generator.company.name();
17
- model.identifier.key = "" + i;
18
- model.fulfillmentCenter.key = "" + i;
19
- results.push(model);
27
+ const name = generator.company.name();
28
+ const identifier = {
29
+ key: "" + i
30
+ };
31
+ const fulfillmentCenter = {
32
+ key: "" + i
33
+ };
34
+ const meta = {
35
+ cache: {
36
+ hit: false,
37
+ key: "" + i
38
+ },
39
+ placeholder: false
40
+ };
41
+ results.push({
42
+ fulfillmentCenter,
43
+ identifier,
44
+ meta,
45
+ name
46
+ });
20
47
  }
21
48
  return results;
22
49
  }
23
50
  }
51
+ __decorateClass([
52
+ Reactionary({
53
+ inputSchema: StoreQueryByProximitySchema,
54
+ outputSchema: z.array(StoreSchema)
55
+ })
56
+ ], FakeStoreProvider.prototype, "queryByProximity", 1);
24
57
  export {
25
58
  FakeStoreProvider
26
59
  };
@@ -1,8 +1,7 @@
1
- import type { BaseModel, Cache, RequestContext } from '@reactionary/core';
1
+ import type { Cache, RequestContext } from '@reactionary/core';
2
2
  import { AnalyticsProvider } from '@reactionary/core';
3
- import type z from 'zod';
4
3
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
5
- export declare class FakeAnalyticsProvider<T extends BaseModel = BaseModel> extends AnalyticsProvider<T> {
4
+ export declare class FakeAnalyticsProvider extends AnalyticsProvider {
6
5
  protected config: FakeConfiguration;
7
- constructor(config: FakeConfiguration, schema: z.ZodType<T>, cache: Cache, context: RequestContext);
6
+ constructor(config: FakeConfiguration, cache: Cache, context: RequestContext);
8
7
  }
@@ -1,20 +1,19 @@
1
1
  import type { Cart, CartQueryById, CartMutationItemAdd, CartMutationItemRemove, CartMutationItemQuantityChange, RequestContext, Cache, CartIdentifier, CartMutationApplyCoupon, CartMutationChangeCurrency, CartMutationDeleteCart, CartMutationRemoveCoupon } from '@reactionary/core';
2
2
  import { CartProvider } from '@reactionary/core';
3
- import type z from 'zod';
4
3
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
5
- export declare class FakeCartProvider<T extends Cart = Cart> extends CartProvider<T> {
4
+ export declare class FakeCartProvider extends CartProvider {
6
5
  protected config: FakeConfiguration;
7
6
  private carts;
8
7
  private generator;
9
- constructor(config: FakeConfiguration, schema: z.ZodType<T>, cache: Cache, context: RequestContext);
10
- getById(payload: CartQueryById): Promise<T>;
11
- add(payload: CartMutationItemAdd): Promise<T>;
12
- remove(payload: CartMutationItemRemove): Promise<T>;
13
- changeQuantity(payload: CartMutationItemQuantityChange): Promise<T>;
8
+ constructor(config: FakeConfiguration, cache: Cache, context: RequestContext);
9
+ getById(payload: CartQueryById): Promise<Cart>;
10
+ add(payload: CartMutationItemAdd): Promise<Cart>;
11
+ remove(payload: CartMutationItemRemove): Promise<Cart>;
12
+ changeQuantity(payload: CartMutationItemQuantityChange): Promise<Cart>;
14
13
  getActiveCartId(): Promise<CartIdentifier>;
15
- deleteCart(payload: CartMutationDeleteCart): Promise<T>;
16
- applyCouponCode(payload: CartMutationApplyCoupon): Promise<T>;
17
- removeCouponCode(payload: CartMutationRemoveCoupon): Promise<T>;
18
- changeCurrency(payload: CartMutationChangeCurrency): Promise<T>;
19
- protected recalculateCart(cart: T): void;
14
+ deleteCart(payload: CartMutationDeleteCart): Promise<Cart>;
15
+ applyCouponCode(payload: CartMutationApplyCoupon): Promise<Cart>;
16
+ removeCouponCode(payload: CartMutationRemoveCoupon): Promise<Cart>;
17
+ changeCurrency(payload: CartMutationChangeCurrency): Promise<Cart>;
18
+ protected recalculateCart(cart: Cart): void;
20
19
  }
@@ -1,20 +1,88 @@
1
- import type { Category, CategoryQueryById, CategoryQueryBySlug, CategoryQueryForBreadcrumb, CategoryQueryForChildCategories, CategoryQueryForTopCategories, RequestContext } from "@reactionary/core";
1
+ import type { Category, CategoryPaginatedResult, CategoryQueryById, CategoryQueryBySlug, CategoryQueryForBreadcrumb, CategoryQueryForChildCategories, CategoryQueryForTopCategories, RequestContext } from "@reactionary/core";
2
2
  import { CategoryProvider } from "@reactionary/core";
3
3
  import type { FakeConfiguration } from "../schema/configuration.schema.js";
4
4
  import type { Cache as ReactionaryCache } from "@reactionary/core";
5
- import type z from "zod";
6
5
  import { Faker } from '@faker-js/faker';
7
- export declare class FakeCategoryProvider<T extends Category = Category> extends CategoryProvider<T> {
6
+ export declare class FakeCategoryProvider extends CategoryProvider {
8
7
  protected config: FakeConfiguration;
9
- protected topCategories: T[];
10
- protected childCategories: Map<string, T[]>;
11
- protected allCategories: Map<string, T>;
8
+ protected topCategories: {
9
+ meta: {
10
+ cache: {
11
+ hit: boolean;
12
+ key: string;
13
+ };
14
+ placeholder: boolean;
15
+ };
16
+ identifier: {
17
+ key: string;
18
+ };
19
+ name: string;
20
+ slug: string;
21
+ text: string;
22
+ images: {
23
+ sourceUrl: string;
24
+ altText: string;
25
+ width: number;
26
+ height: number;
27
+ }[];
28
+ parentCategory?: {
29
+ key: string;
30
+ } | undefined;
31
+ }[];
32
+ protected childCategories: Map<string, {
33
+ meta: {
34
+ cache: {
35
+ hit: boolean;
36
+ key: string;
37
+ };
38
+ placeholder: boolean;
39
+ };
40
+ identifier: {
41
+ key: string;
42
+ };
43
+ name: string;
44
+ slug: string;
45
+ text: string;
46
+ images: {
47
+ sourceUrl: string;
48
+ altText: string;
49
+ width: number;
50
+ height: number;
51
+ }[];
52
+ parentCategory?: {
53
+ key: string;
54
+ } | undefined;
55
+ }[]>;
56
+ protected allCategories: Map<string, {
57
+ meta: {
58
+ cache: {
59
+ hit: boolean;
60
+ key: string;
61
+ };
62
+ placeholder: boolean;
63
+ };
64
+ identifier: {
65
+ key: string;
66
+ };
67
+ name: string;
68
+ slug: string;
69
+ text: string;
70
+ images: {
71
+ sourceUrl: string;
72
+ altText: string;
73
+ width: number;
74
+ height: number;
75
+ }[];
76
+ parentCategory?: {
77
+ key: string;
78
+ } | undefined;
79
+ }>;
12
80
  protected categoryGenerator: Faker;
13
- protected generateFakeCategory(parent: Category | undefined, index: number): T;
14
- constructor(config: FakeConfiguration, schema: z.ZodType<T>, cache: ReactionaryCache, context: RequestContext);
15
- getById(payload: CategoryQueryById): Promise<T>;
16
- getBySlug(payload: CategoryQueryBySlug): Promise<T | null>;
17
- getBreadcrumbPathToCategory(payload: CategoryQueryForBreadcrumb): Promise<T[]>;
18
- findChildCategories(payload: CategoryQueryForChildCategories): Promise<ReturnType<typeof this.parsePaginatedResult>>;
19
- findTopCategories(payload: CategoryQueryForTopCategories): Promise<ReturnType<typeof this.parsePaginatedResult>>;
81
+ protected generateFakeCategory(parent: Category | undefined, index: number): Category;
82
+ constructor(config: FakeConfiguration, cache: ReactionaryCache, context: RequestContext);
83
+ getById(payload: CategoryQueryById): Promise<Category>;
84
+ getBySlug(payload: CategoryQueryBySlug): Promise<Category | null>;
85
+ getBreadcrumbPathToCategory(payload: CategoryQueryForBreadcrumb): Promise<Category[]>;
86
+ findChildCategories(payload: CategoryQueryForChildCategories): Promise<CategoryPaginatedResult>;
87
+ findTopCategories(payload: CategoryQueryForTopCategories): Promise<CategoryPaginatedResult>;
20
88
  }
@@ -1,12 +1,11 @@
1
1
  import { type Identity, type IdentityQuerySelf, type IdentityMutationLogin, type IdentityMutationLogout, type RequestContext, type Cache, IdentityProvider, type IdentityMutationRegister } from '@reactionary/core';
2
- import type z from 'zod';
3
2
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
4
- export declare class FakeIdentityProvider<T extends Identity = Identity> extends IdentityProvider<T> {
3
+ export declare class FakeIdentityProvider extends IdentityProvider {
5
4
  protected config: FakeConfiguration;
6
5
  private currentIdentity;
7
- constructor(config: FakeConfiguration, schema: z.ZodType<T>, cache: Cache, context: RequestContext);
8
- getSelf(_payload: IdentityQuerySelf): Promise<T>;
9
- login(payload: IdentityMutationLogin): Promise<T>;
10
- logout(_payload: IdentityMutationLogout): Promise<T>;
11
- register(payload: IdentityMutationRegister): Promise<T>;
6
+ constructor(config: FakeConfiguration, cache: Cache, context: RequestContext);
7
+ getSelf(_payload: IdentityQuerySelf): Promise<Identity>;
8
+ login(payload: IdentityMutationLogin): Promise<Identity>;
9
+ logout(_payload: IdentityMutationLogout): Promise<Identity>;
10
+ register(payload: IdentityMutationRegister): Promise<Identity>;
12
11
  }
@@ -1,9 +1,8 @@
1
1
  import type { Cache, Inventory, InventoryQueryBySKU, RequestContext } from '@reactionary/core';
2
2
  import { InventoryProvider } from '@reactionary/core';
3
- import type z from 'zod';
4
3
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
5
- export declare class FakeInventoryProvider<T extends Inventory = Inventory> extends InventoryProvider<T> {
4
+ export declare class FakeInventoryProvider extends InventoryProvider {
6
5
  protected config: FakeConfiguration;
7
- constructor(config: FakeConfiguration, schema: z.ZodType<T>, cache: Cache, context: RequestContext);
8
- getBySKU(payload: InventoryQueryBySKU): Promise<T>;
6
+ constructor(config: FakeConfiguration, cache: Cache, context: RequestContext);
7
+ getBySKU(payload: InventoryQueryBySKU): Promise<Inventory>;
9
8
  }
@@ -1,9 +1,8 @@
1
- import { type Price, type RequestContext, type Cache, PriceProvider, type CustomerPriceQuery, type ListPriceQuery } from '@reactionary/core';
2
- import type z from 'zod';
1
+ import { type RequestContext, type Cache, PriceProvider, type CustomerPriceQuery, type ListPriceQuery, type Price } from '@reactionary/core';
3
2
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
4
- export declare class FakePriceProvider<T extends Price = Price> extends PriceProvider<T> {
3
+ export declare class FakePriceProvider extends PriceProvider {
5
4
  protected config: FakeConfiguration;
6
- constructor(config: FakeConfiguration, schema: z.ZodType<T>, cache: Cache, context: RequestContext);
7
- getListPrice(payload: ListPriceQuery): Promise<T>;
8
- getCustomerPrice(payload: CustomerPriceQuery): Promise<T>;
5
+ constructor(config: FakeConfiguration, cache: Cache, context: RequestContext);
6
+ getListPrice(payload: ListPriceQuery): Promise<Price>;
7
+ getCustomerPrice(payload: CustomerPriceQuery): Promise<Price>;
9
8
  }
@@ -1,11 +1,10 @@
1
1
  import { ProductSearchProvider } from '@reactionary/core';
2
- import type { ProductSearchResult, ProductSearchResultFacet, ProductSearchResultItem, Cache as ReactionaryCache, FacetIdentifier, FacetValueIdentifier, ProductSearchResultFacetValue, ProductSearchResultItemVariant } from '@reactionary/core';
2
+ import type { ProductSearchResult, ProductSearchResultFacet, Cache as ReactionaryCache, FacetIdentifier, FacetValueIdentifier, ProductSearchResultFacetValue, ProductSearchResultItemVariant } from '@reactionary/core';
3
3
  import type { RequestContext, ProductSearchQueryByTerm } from '@reactionary/core';
4
- import type z from 'zod';
5
4
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
6
- export declare class FakeSearchProvider<T extends ProductSearchResultItem = ProductSearchResultItem> extends ProductSearchProvider<T> {
5
+ export declare class FakeSearchProvider extends ProductSearchProvider {
7
6
  protected config: FakeConfiguration;
8
- constructor(config: FakeConfiguration, schema: z.ZodType<T>, cache: ReactionaryCache, context: RequestContext);
7
+ constructor(config: FakeConfiguration, cache: ReactionaryCache, context: RequestContext);
9
8
  queryByTerm(payload: ProductSearchQueryByTerm): Promise<ProductSearchResult>;
10
9
  protected parseFacetValue(facetValueIdentifier: FacetValueIdentifier, label: string, count: number): ProductSearchResultFacetValue;
11
10
  protected parseFacet(facetIdentifier: FacetIdentifier, facetValue: unknown): ProductSearchResultFacet;
@@ -1,11 +1,10 @@
1
- import { type Product, type ProductQueryById, type ProductQueryBySlug, type RequestContext, type Cache as ReactinaryCache, ProductProvider, type ProductQueryBySKU } from '@reactionary/core';
2
- import type z from 'zod';
1
+ import { type ProductQueryById, type ProductQueryBySlug, type RequestContext, type Cache as ReactinaryCache, ProductProvider, type ProductQueryBySKU, type Product } from '@reactionary/core';
3
2
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
4
- export declare class FakeProductProvider<T extends Product = Product> extends ProductProvider<T> {
3
+ export declare class FakeProductProvider extends ProductProvider {
5
4
  protected config: FakeConfiguration;
6
- constructor(config: FakeConfiguration, schema: z.ZodType<T>, cache: ReactinaryCache, context: RequestContext);
7
- getById(payload: ProductQueryById): Promise<T>;
8
- getBySlug(payload: ProductQueryBySlug): Promise<T>;
9
- getBySKU(payload: ProductQueryBySKU): Promise<T>;
10
- protected parseSingle(body: string): T;
5
+ constructor(config: FakeConfiguration, cache: ReactinaryCache, context: RequestContext);
6
+ getById(payload: ProductQueryById): Promise<Product>;
7
+ getBySlug(payload: ProductQueryBySlug): Promise<Product>;
8
+ getBySKU(payload: ProductQueryBySKU): Promise<Product>;
9
+ protected parseSingle(body: string): Product;
11
10
  }
@@ -1,9 +1,8 @@
1
- import type { Cache, RequestContext, StoreQueryByProximity, Store } from '@reactionary/core';
1
+ import type { Cache, RequestContext, Store, StoreQueryByProximity } from '@reactionary/core';
2
2
  import { StoreProvider } from '@reactionary/core';
3
- import type z from 'zod';
4
3
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
5
- export declare class FakeStoreProvider<T extends Store = Store> extends StoreProvider<T> {
4
+ export declare class FakeStoreProvider extends StoreProvider {
6
5
  protected config: FakeConfiguration;
7
- constructor(config: FakeConfiguration, schema: z.ZodType<T>, cache: Cache, context: RequestContext);
8
- queryByProximity(payload: StoreQueryByProximity): Promise<T[]>;
6
+ constructor(config: FakeConfiguration, cache: Cache, context: RequestContext);
7
+ queryByProximity(payload: StoreQueryByProximity): Promise<Store[]>;
9
8
  }
@@ -4,9 +4,9 @@ export declare const FakeCapabilitiesSchema: z.ZodObject<{
4
4
  product: z.ZodOptional<z.ZodBoolean>;
5
5
  identity: z.ZodOptional<z.ZodBoolean>;
6
6
  cart: z.ZodOptional<z.ZodBoolean>;
7
+ productSearch: z.ZodOptional<z.ZodBoolean>;
7
8
  inventory: z.ZodOptional<z.ZodBoolean>;
8
9
  category: z.ZodOptional<z.ZodBoolean>;
9
10
  store: z.ZodOptional<z.ZodBoolean>;
10
- productSearch: z.ZodOptional<z.ZodBoolean>;
11
11
  }, z.core.$loose>;
12
12
  export type FakeCapabilities = z.infer<typeof FakeCapabilitiesSchema>;