@reactionary/provider-fake 0.1.13 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@reactionary/provider-fake",
3
- "version": "0.1.13",
3
+ "version": "0.2.2",
4
4
  "main": "index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "dependencies": {
7
- "@reactionary/core": "0.1.13",
7
+ "@reactionary/core": "0.2.2",
8
8
  "zod": "4.1.9",
9
9
  "@faker-js/faker": "^9.8.0"
10
10
  },
@@ -21,7 +21,10 @@ import {
21
21
  CartProvider,
22
22
  CartQueryByIdSchema,
23
23
  CartSchema,
24
- Reactionary
24
+ Reactionary,
25
+ error,
26
+ success,
27
+ unwrapValue
25
28
  } from "@reactionary/core";
26
29
  import { Faker, en, base } from "@faker-js/faker";
27
30
  class FakeCartProvider extends CartProvider {
@@ -37,7 +40,10 @@ class FakeCartProvider extends CartProvider {
37
40
  async getById(payload) {
38
41
  const cartId = payload.cart.key;
39
42
  if (payload.cart.key === "") {
40
- return this.createEmptyCart();
43
+ return error({
44
+ type: "NotFound",
45
+ identifier: cartId
46
+ });
41
47
  }
42
48
  if (!this.carts.has(cartId)) {
43
49
  const cart2 = this.createEmptyCart();
@@ -48,14 +54,13 @@ class FakeCartProvider extends CartProvider {
48
54
  if (!cart) {
49
55
  throw new Error(`Cart with id ${cartId} not found`);
50
56
  }
51
- return cart;
57
+ return success(cart);
52
58
  }
53
59
  async add(payload) {
54
- const cartId = payload.cart.key || `cart-${this.generator.string.uuid()}`;
55
- const cart = await this.getById({ cart: { key: cartId } });
56
- if (cart.meta.placeholder) {
60
+ const cartId = payload?.cart?.key || `cart-${this.generator.string.uuid()}`;
61
+ const cart = unwrapValue(await this.getById({ cart: { key: cartId } }));
62
+ if (cart.identifier.key === "") {
57
63
  cart.identifier.key = cartId;
58
- cart.meta.placeholder = false;
59
64
  this.carts.set(cartId, cart);
60
65
  }
61
66
  const existingItemIndex = cart.items.findIndex(
@@ -94,31 +99,31 @@ class FakeCartProvider extends CartProvider {
94
99
  });
95
100
  }
96
101
  this.recalculateCart(cart);
97
- return cart;
102
+ return success(cart);
98
103
  }
99
104
  async remove(payload) {
100
105
  const cartId = payload.cart.key || `cart-${this.generator.string.uuid()}`;
101
- const cart = await this.getById({ cart: { key: cartId } });
106
+ const cart = unwrapValue(await this.getById({ cart: { key: cartId } }));
102
107
  cart.items = cart.items.filter(
103
108
  (item) => item.identifier.key !== payload.item.key
104
109
  );
105
110
  this.recalculateCart(cart);
106
- return cart;
111
+ return success(cart);
107
112
  }
108
113
  async changeQuantity(payload) {
109
114
  const cartId = payload.cart.key || `cart-${this.generator.string.uuid()}`;
110
- const cart = await this.getById({ cart: { key: cartId } });
115
+ const cart = unwrapValue(await this.getById({ cart: { key: cartId } }));
111
116
  const item = cart.items.find(
112
117
  (item2) => item2.identifier.key === payload.item.key
113
118
  );
114
119
  if (payload.quantity < 1) {
115
- return cart;
120
+ return success(cart);
116
121
  }
117
122
  if (item) {
118
123
  item.quantity = payload.quantity;
119
124
  }
120
125
  this.recalculateCart(cart);
121
- return cart;
126
+ return success(cart);
122
127
  }
123
128
  getActiveCartId() {
124
129
  throw new Error("Method not implemented.");
@@ -140,14 +145,58 @@ class FakeCartProvider extends CartProvider {
140
145
  item.price.totalPrice.value = item.price.unitPrice.value * item.quantity;
141
146
  });
142
147
  cart.price.totalProductPrice = {
143
- value: cart.items.reduce((sum, item) => sum + item.price.totalPrice.value, 0),
148
+ value: cart.items.reduce(
149
+ (sum, item) => sum + item.price.totalPrice.value,
150
+ 0
151
+ ),
144
152
  currency: cart.items[0]?.price.unitPrice.currency || "USD"
145
153
  };
146
154
  cart.price.grandTotal = {
147
- value: cart.items.reduce((sum, item) => sum + item.price.totalPrice.value, 0),
155
+ value: cart.items.reduce(
156
+ (sum, item) => sum + item.price.totalPrice.value,
157
+ 0
158
+ ),
148
159
  currency: cart.items[0]?.price.unitPrice.currency || "USD"
149
160
  };
150
161
  }
162
+ createEmptyCart() {
163
+ const cart = {
164
+ identifier: { key: "" },
165
+ description: "",
166
+ items: [],
167
+ name: "",
168
+ price: {
169
+ grandTotal: {
170
+ value: 0,
171
+ currency: "XXX"
172
+ },
173
+ totalDiscount: {
174
+ value: 0,
175
+ currency: "XXX"
176
+ },
177
+ totalProductPrice: {
178
+ value: 0,
179
+ currency: "XXX"
180
+ },
181
+ totalShipping: {
182
+ value: 0,
183
+ currency: "XXX"
184
+ },
185
+ totalSurcharge: {
186
+ value: 0,
187
+ currency: "XXX"
188
+ },
189
+ totalTax: {
190
+ value: 0,
191
+ currency: "XXX"
192
+ }
193
+ },
194
+ userId: {
195
+ userId: ""
196
+ }
197
+ };
198
+ return cart;
199
+ }
151
200
  }
152
201
  __decorateClass([
153
202
  Reactionary({
@@ -9,7 +9,7 @@ var __decorateClass = (decorators, target, key, kind) => {
9
9
  __defProp(target, key, result);
10
10
  return result;
11
11
  };
12
- import { CategoryPaginatedResultSchema, CategoryProvider, CategoryQueryByIdSchema, CategoryQueryBySlugSchema, CategoryQueryForBreadcrumbSchema, CategoryQueryForChildCategoriesSchema, CategoryQueryForTopCategoriesSchema, CategorySchema, Reactionary } from "@reactionary/core";
12
+ import { success, error, CategoryPaginatedResultSchema, CategoryProvider, CategoryQueryByIdSchema, CategoryQueryBySlugSchema, CategoryQueryForBreadcrumbSchema, CategoryQueryForChildCategoriesSchema, CategoryQueryForTopCategoriesSchema, CategorySchema, Reactionary } from "@reactionary/core";
13
13
  import z from "zod";
14
14
  import { Faker, en, base } from "@faker-js/faker";
15
15
  class FakeCategoryProvider extends CategoryProvider {
@@ -59,13 +59,6 @@ class FakeCategoryProvider extends CategoryProvider {
59
59
  const category = {
60
60
  identifier,
61
61
  images: [],
62
- meta: {
63
- cache: {
64
- hit: false,
65
- key: ""
66
- },
67
- placeholder: false
68
- },
69
62
  name,
70
63
  slug,
71
64
  text,
@@ -77,19 +70,25 @@ class FakeCategoryProvider extends CategoryProvider {
77
70
  async getById(payload) {
78
71
  const category = this.allCategories.get(payload.id.key);
79
72
  if (!category) {
80
- throw new Error("This should not happen...");
73
+ return error({
74
+ type: "NotFound",
75
+ identifier: payload
76
+ });
81
77
  }
82
- return category;
78
+ return success(category);
83
79
  }
84
- getBySlug(payload) {
80
+ async getBySlug(payload) {
85
81
  for (const p of this.allCategories.values()) {
86
82
  if (p.slug === payload.slug) {
87
- return Promise.resolve(p);
83
+ return success(p);
88
84
  }
89
85
  }
90
- return Promise.resolve(null);
86
+ return error({
87
+ type: "NotFound",
88
+ identifier: payload
89
+ });
91
90
  }
92
- getBreadcrumbPathToCategory(payload) {
91
+ async getBreadcrumbPathToCategory(payload) {
93
92
  const path = new Array();
94
93
  let category = this.allCategories.get(payload.id.key);
95
94
  path.push(category);
@@ -99,7 +98,7 @@ class FakeCategoryProvider extends CategoryProvider {
99
98
  path.unshift(category);
100
99
  }
101
100
  }
102
- return Promise.resolve(path);
101
+ return success(path);
103
102
  }
104
103
  async findChildCategories(payload) {
105
104
  const children = this.childCategories.get(payload.parentId.key);
@@ -118,9 +117,9 @@ class FakeCategoryProvider extends CategoryProvider {
118
117
  pageSize: payload.paginationOptions.pageSize,
119
118
  totalPages: children ? Math.ceil(children.length / payload.paginationOptions.pageSize) : 1
120
119
  };
121
- return Promise.resolve(res);
120
+ return success(res);
122
121
  }
123
- findTopCategories(payload) {
122
+ async findTopCategories(payload) {
124
123
  const children = this.topCategories;
125
124
  const page = children?.slice((payload.paginationOptions.pageNumber - 1) * payload.paginationOptions.pageSize, payload.paginationOptions.pageNumber * payload.paginationOptions.pageSize);
126
125
  const res = {
@@ -137,7 +136,7 @@ class FakeCategoryProvider extends CategoryProvider {
137
136
  pageSize: payload.paginationOptions.pageSize,
138
137
  totalPages: children ? Math.ceil(children.length / payload.paginationOptions.pageSize) : 1
139
138
  };
140
- return Promise.resolve(res);
139
+ return success(res);
141
140
  }
142
141
  }
143
142
  __decorateClass([
@@ -16,7 +16,8 @@ import {
16
16
  IdentitySchema,
17
17
  IdentityMutationLogoutSchema,
18
18
  IdentityMutationLoginSchema,
19
- IdentityQuerySelfSchema
19
+ IdentityQuerySelfSchema,
20
+ success
20
21
  } from "@reactionary/core";
21
22
  import { base, en, Faker } from "@faker-js/faker";
22
23
  class FakeIdentityProvider extends IdentityProvider {
@@ -28,18 +29,11 @@ class FakeIdentityProvider extends IdentityProvider {
28
29
  async getSelf(_payload) {
29
30
  if (!this.currentIdentity) {
30
31
  const model = {
31
- type: "Anonymous",
32
- meta: {
33
- cache: {
34
- hit: false,
35
- key: "anonymous"
36
- },
37
- placeholder: false
38
- }
32
+ type: "Anonymous"
39
33
  };
40
34
  this.currentIdentity = model;
41
35
  }
42
- return this.currentIdentity;
36
+ return success(this.currentIdentity);
43
37
  }
44
38
  async login(payload) {
45
39
  const generator = new Faker({
@@ -50,31 +44,17 @@ class FakeIdentityProvider extends IdentityProvider {
50
44
  type: "Registered",
51
45
  id: {
52
46
  userId: generator.string.alphanumeric(32)
53
- },
54
- meta: {
55
- cache: {
56
- hit: false,
57
- key: payload.username
58
- },
59
- placeholder: false
60
47
  }
61
48
  };
62
49
  this.currentIdentity = model;
63
- return this.currentIdentity;
50
+ return success(this.currentIdentity);
64
51
  }
65
52
  async logout(_payload) {
66
53
  const model = {
67
- type: "Anonymous",
68
- meta: {
69
- cache: {
70
- hit: false,
71
- key: "anonymous"
72
- },
73
- placeholder: false
74
- }
54
+ type: "Anonymous"
75
55
  };
76
56
  this.currentIdentity = model;
77
- return this.currentIdentity;
57
+ return success(this.currentIdentity);
78
58
  }
79
59
  register(payload) {
80
60
  throw new Error("Method not implemented.");
@@ -14,7 +14,8 @@ import {
14
14
  InventoryProvider,
15
15
  InventoryQueryBySKUSchema,
16
16
  InventorySchema,
17
- Reactionary
17
+ Reactionary,
18
+ success
18
19
  } from "@reactionary/core";
19
20
  class FakeInventoryProvider extends InventoryProvider {
20
21
  constructor(config, cache, context) {
@@ -41,20 +42,12 @@ class FakeInventoryProvider extends InventoryProvider {
41
42
  if (quantity > 0) {
42
43
  status = "inStock";
43
44
  }
44
- const meta = {
45
- cache: {
46
- hit: false,
47
- key: this.generateCacheKeySingle(identifier)
48
- },
49
- placeholder: false
50
- };
51
45
  const result = {
52
46
  identifier,
53
- meta,
54
47
  quantity,
55
48
  status
56
49
  };
57
- return result;
50
+ return success(result);
58
51
  }
59
52
  }
60
53
  __decorateClass([
@@ -14,7 +14,9 @@ import {
14
14
  Reactionary,
15
15
  CustomerPriceQuerySchema,
16
16
  PriceSchema,
17
- ListPriceQuerySchema
17
+ ListPriceQuerySchema,
18
+ error,
19
+ success
18
20
  } from "@reactionary/core";
19
21
  import { base, en, Faker } from "@faker-js/faker";
20
22
  class FakePriceProvider extends PriceProvider {
@@ -24,7 +26,7 @@ class FakePriceProvider extends PriceProvider {
24
26
  }
25
27
  async getListPrice(payload) {
26
28
  if (payload.variant.sku === "unknown-sku") {
27
- return this.createEmptyPriceResult(payload.variant.sku);
29
+ return success(this.createEmptyPriceResult(payload.variant.sku));
28
30
  }
29
31
  let hash = 0;
30
32
  const skuString = payload.variant.sku;
@@ -43,13 +45,6 @@ class FakePriceProvider extends PriceProvider {
43
45
  unitPrice: {
44
46
  value: generator.number.int({ min: 300, max: 1e5 }) / 100,
45
47
  currency: this.context.languageContext.currencyCode
46
- },
47
- meta: {
48
- cache: {
49
- hit: false,
50
- key: payload.variant.sku
51
- },
52
- placeholder: false
53
48
  }
54
49
  };
55
50
  if (skuString.includes("with-tiers")) {
@@ -75,11 +70,11 @@ class FakePriceProvider extends PriceProvider {
75
70
  } else {
76
71
  model.tieredPrices = [];
77
72
  }
78
- return model;
73
+ return success(model);
79
74
  }
80
75
  async getCustomerPrice(payload) {
81
76
  if (payload.variant.sku === "unknown-sku") {
82
- return this.createEmptyPriceResult(payload.variant.sku);
77
+ return success(this.createEmptyPriceResult(payload.variant.sku));
83
78
  }
84
79
  let hash = 0;
85
80
  const skuString = payload.variant.sku;
@@ -98,13 +93,6 @@ class FakePriceProvider extends PriceProvider {
98
93
  unitPrice: {
99
94
  value: generator.number.int({ min: 300, max: 1e5 }) / 100,
100
95
  currency: this.context.languageContext.currencyCode
101
- },
102
- meta: {
103
- cache: {
104
- hit: false,
105
- key: payload.variant.sku
106
- },
107
- placeholder: false
108
96
  }
109
97
  };
110
98
  if (skuString.includes("with-tiers")) {
@@ -130,7 +118,7 @@ class FakePriceProvider extends PriceProvider {
130
118
  } else {
131
119
  model.tieredPrices = [];
132
120
  }
133
- return model;
121
+ return success(model);
134
122
  }
135
123
  }
136
124
  __decorateClass([
@@ -15,7 +15,9 @@ import {
15
15
  ProductSearchQueryByTermSchema,
16
16
  ProductSearchResultItemSchema,
17
17
  ProductSearchResultSchema,
18
- Reactionary
18
+ Reactionary,
19
+ success,
20
+ error
19
21
  } from "@reactionary/core";
20
22
  import { Faker, en, base } from "@faker-js/faker";
21
23
  import { jitter } from "../utilities/jitter.js";
@@ -32,15 +34,20 @@ class FakeSearchProvider extends ProductSearchProvider {
32
34
  facet: facetIdentifier,
33
35
  key: payload.categoryPath[payload.categoryPath.length - 1].identifier.key
34
36
  };
35
- return facetValueIdentifier;
37
+ return success(facetValueIdentifier);
36
38
  }
37
39
  async queryByTerm(payload) {
38
40
  await jitter(this.config.jitter.mean, this.config.jitter.deviation);
39
41
  const query = payload.search;
40
42
  const querySpecificity = 20 - query.term.length - query.paginationOptions.pageNumber - query.facets.length;
41
43
  const totalProducts = 10 * querySpecificity;
42
- const totalPages = Math.ceil(totalProducts / query.paginationOptions.pageSize);
43
- const productsOnPage = Math.min(totalProducts, query.paginationOptions.pageSize);
44
+ const totalPages = Math.ceil(
45
+ totalProducts / query.paginationOptions.pageSize
46
+ );
47
+ const productsOnPage = Math.min(
48
+ totalProducts,
49
+ query.paginationOptions.pageSize
50
+ );
44
51
  const productGenerator = new Faker({
45
52
  seed: querySpecificity,
46
53
  locale: [en, base]
@@ -65,22 +72,22 @@ class FakeSearchProvider extends ProductSearchProvider {
65
72
  width: 300
66
73
  });
67
74
  products.push(
68
- ProductSearchResultItemSchema.parse(
69
- {
70
- identifier: {
71
- key: "product_" + productGenerator.commerce.isbn()
72
- },
73
- name: productGenerator.commerce.productName(),
74
- slug: productGenerator.lorem.slug(),
75
- variants: [{
75
+ ProductSearchResultItemSchema.parse({
76
+ identifier: {
77
+ key: "product_" + productGenerator.commerce.isbn()
78
+ },
79
+ name: productGenerator.commerce.productName(),
80
+ slug: productGenerator.lorem.slug(),
81
+ variants: [
82
+ {
76
83
  variant: {
77
84
  sku: productGenerator.commerce.isbn()
78
85
  },
79
86
  image: img,
80
87
  options: void 0
81
- }]
82
- }
83
- )
88
+ }
89
+ ]
90
+ })
84
91
  );
85
92
  }
86
93
  const facetBase = ["color", "size"];
@@ -126,17 +133,9 @@ class FakeSearchProvider extends ProductSearchProvider {
126
133
  pageNumber: query.paginationOptions.pageNumber,
127
134
  pageSize: query.paginationOptions.pageSize,
128
135
  totalCount: totalProducts,
129
- totalPages,
130
- meta: {
131
- cache: {
132
- hit: false,
133
- key: ""
134
- },
135
- placeholder: false
136
- }
136
+ totalPages
137
137
  });
138
- const foo = this.childFunction();
139
- return result;
138
+ return success(result);
140
139
  }
141
140
  parseFacetValue(facetValueIdentifier, label, count) {
142
141
  throw new Error("Method not implemented.");
@@ -147,10 +146,6 @@ class FakeSearchProvider extends ProductSearchProvider {
147
146
  parseVariant(variant, product) {
148
147
  throw new Error("Method not implemented.");
149
148
  }
150
- childFunction() {
151
- const foo = 42;
152
- return foo;
153
- }
154
149
  }
155
150
  __decorateClass([
156
151
  Reactionary({
@@ -15,7 +15,9 @@ import {
15
15
  ProductQueryByIdSchema,
16
16
  ProductSchema,
17
17
  ProductQueryBySlugSchema,
18
- ProductQueryBySKUSchema
18
+ ProductQueryBySKUSchema,
19
+ error,
20
+ success
19
21
  } from "@reactionary/core";
20
22
  import { base, en, Faker } from "@faker-js/faker";
21
23
  class FakeProductProvider extends ProductProvider {
@@ -24,13 +26,13 @@ class FakeProductProvider extends ProductProvider {
24
26
  this.config = config;
25
27
  }
26
28
  async getById(payload) {
27
- return this.parseSingle(payload.identifier.key);
29
+ return success(this.parseSingle(payload.identifier.key));
28
30
  }
29
31
  async getBySlug(payload) {
30
- return this.parseSingle(payload.slug);
32
+ return success(this.parseSingle(payload.slug));
31
33
  }
32
34
  async getBySKU(payload) {
33
- return this.parseSingle(payload.variant.sku);
35
+ return success(this.parseSingle(payload.variant.sku));
34
36
  }
35
37
  parseSingle(body) {
36
38
  const generator = new Faker({
@@ -64,14 +66,7 @@ class FakeProductProvider extends ProductProvider {
64
66
  parentCategories: [],
65
67
  published: true,
66
68
  sharedAttributes: [],
67
- variants: [],
68
- meta: {
69
- cache: {
70
- hit: false,
71
- key
72
- },
73
- placeholder: false
74
- }
69
+ variants: []
75
70
  };
76
71
  return result;
77
72
  }
@@ -9,7 +9,7 @@ var __decorateClass = (decorators, target, key, kind) => {
9
9
  __defProp(target, key, result);
10
10
  return result;
11
11
  };
12
- import { Reactionary, StoreProvider, StoreQueryByProximitySchema, StoreSchema } from "@reactionary/core";
12
+ import { Reactionary, StoreProvider, StoreQueryByProximitySchema, StoreSchema, success } from "@reactionary/core";
13
13
  import z from "zod";
14
14
  import { base, en, Faker } from "@faker-js/faker";
15
15
  class FakeStoreProvider extends StoreProvider {
@@ -31,21 +31,13 @@ class FakeStoreProvider extends StoreProvider {
31
31
  const fulfillmentCenter = {
32
32
  key: "" + i
33
33
  };
34
- const meta = {
35
- cache: {
36
- hit: false,
37
- key: "" + i
38
- },
39
- placeholder: false
40
- };
41
34
  results.push({
42
35
  fulfillmentCenter,
43
36
  identifier,
44
- meta,
45
37
  name
46
38
  });
47
39
  }
48
- return results;
40
+ return success(results);
49
41
  }
50
42
  }
51
43
  __decorateClass([
@@ -1,4 +1,4 @@
1
- import type { Cart, CartQueryById, CartMutationItemAdd, CartMutationItemRemove, CartMutationItemQuantityChange, RequestContext, Cache, CartIdentifier, CartMutationApplyCoupon, CartMutationChangeCurrency, CartMutationDeleteCart, CartMutationRemoveCoupon } from '@reactionary/core';
1
+ import type { Cart, CartQueryById, CartMutationItemAdd, CartMutationItemRemove, CartMutationItemQuantityChange, RequestContext, Cache, CartIdentifier, CartMutationApplyCoupon, CartMutationChangeCurrency, CartMutationDeleteCart, CartMutationRemoveCoupon, Result, NotFoundError } from '@reactionary/core';
2
2
  import { CartProvider } from '@reactionary/core';
3
3
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
4
4
  export declare class FakeCartProvider extends CartProvider {
@@ -6,14 +6,15 @@ export declare class FakeCartProvider extends CartProvider {
6
6
  private carts;
7
7
  private generator;
8
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>;
13
- getActiveCartId(): Promise<CartIdentifier>;
14
- deleteCart(payload: CartMutationDeleteCart): Promise<Cart>;
15
- applyCouponCode(payload: CartMutationApplyCoupon): Promise<Cart>;
16
- removeCouponCode(payload: CartMutationRemoveCoupon): Promise<Cart>;
17
- changeCurrency(payload: CartMutationChangeCurrency): Promise<Cart>;
9
+ getById(payload: CartQueryById): Promise<Result<Cart, NotFoundError>>;
10
+ add(payload: CartMutationItemAdd): Promise<Result<Cart>>;
11
+ remove(payload: CartMutationItemRemove): Promise<Result<Cart>>;
12
+ changeQuantity(payload: CartMutationItemQuantityChange): Promise<Result<Cart>>;
13
+ getActiveCartId(): Promise<Result<CartIdentifier, NotFoundError>>;
14
+ deleteCart(payload: CartMutationDeleteCart): Promise<Result<void>>;
15
+ applyCouponCode(payload: CartMutationApplyCoupon): Promise<Result<Cart>>;
16
+ removeCouponCode(payload: CartMutationRemoveCoupon): Promise<Result<Cart>>;
17
+ changeCurrency(payload: CartMutationChangeCurrency): Promise<Result<Cart>>;
18
18
  protected recalculateCart(cart: Cart): void;
19
+ protected createEmptyCart(): Cart;
19
20
  }
@@ -1,4 +1,4 @@
1
- import type { Category, CategoryPaginatedResult, CategoryQueryById, CategoryQueryBySlug, CategoryQueryForBreadcrumb, CategoryQueryForChildCategories, CategoryQueryForTopCategories, RequestContext } from "@reactionary/core";
1
+ import type { Result, NotFoundError, 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";
@@ -6,13 +6,6 @@ import { Faker } from '@faker-js/faker';
6
6
  export declare class FakeCategoryProvider extends CategoryProvider {
7
7
  protected config: FakeConfiguration;
8
8
  protected topCategories: {
9
- meta: {
10
- cache: {
11
- hit: boolean;
12
- key: string;
13
- };
14
- placeholder: boolean;
15
- };
16
9
  identifier: {
17
10
  key: string;
18
11
  };
@@ -30,13 +23,6 @@ export declare class FakeCategoryProvider extends CategoryProvider {
30
23
  } | undefined;
31
24
  }[];
32
25
  protected childCategories: Map<string, {
33
- meta: {
34
- cache: {
35
- hit: boolean;
36
- key: string;
37
- };
38
- placeholder: boolean;
39
- };
40
26
  identifier: {
41
27
  key: string;
42
28
  };
@@ -54,13 +40,6 @@ export declare class FakeCategoryProvider extends CategoryProvider {
54
40
  } | undefined;
55
41
  }[]>;
56
42
  protected allCategories: Map<string, {
57
- meta: {
58
- cache: {
59
- hit: boolean;
60
- key: string;
61
- };
62
- placeholder: boolean;
63
- };
64
43
  identifier: {
65
44
  key: string;
66
45
  };
@@ -80,9 +59,9 @@ export declare class FakeCategoryProvider extends CategoryProvider {
80
59
  protected categoryGenerator: Faker;
81
60
  protected generateFakeCategory(parent: Category | undefined, index: number): Category;
82
61
  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>;
62
+ getById(payload: CategoryQueryById): Promise<Result<Category, NotFoundError>>;
63
+ getBySlug(payload: CategoryQueryBySlug): Promise<Result<Category, NotFoundError>>;
64
+ getBreadcrumbPathToCategory(payload: CategoryQueryForBreadcrumb): Promise<Result<Category[]>>;
65
+ findChildCategories(payload: CategoryQueryForChildCategories): Promise<Result<CategoryPaginatedResult>>;
66
+ findTopCategories(payload: CategoryQueryForTopCategories): Promise<Result<CategoryPaginatedResult>>;
88
67
  }
@@ -1,11 +1,11 @@
1
- import { type Identity, type IdentityQuerySelf, type IdentityMutationLogin, type IdentityMutationLogout, type RequestContext, type Cache, IdentityProvider, type IdentityMutationRegister } from '@reactionary/core';
1
+ import { type Identity, type IdentityQuerySelf, type IdentityMutationLogin, type IdentityMutationLogout, type RequestContext, type Cache, IdentityProvider, type IdentityMutationRegister, type Result } from '@reactionary/core';
2
2
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
3
3
  export declare class FakeIdentityProvider extends IdentityProvider {
4
4
  protected config: FakeConfiguration;
5
5
  private currentIdentity;
6
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>;
7
+ getSelf(_payload: IdentityQuerySelf): Promise<Result<Identity>>;
8
+ login(payload: IdentityMutationLogin): Promise<Result<Identity>>;
9
+ logout(_payload: IdentityMutationLogout): Promise<Result<Identity>>;
10
+ register(payload: IdentityMutationRegister): Promise<Result<Identity>>;
11
11
  }
@@ -1,8 +1,8 @@
1
- import type { Cache, Inventory, InventoryQueryBySKU, RequestContext } from '@reactionary/core';
1
+ import type { Cache, Inventory, InventoryQueryBySKU, NotFoundError, RequestContext, Result } from '@reactionary/core';
2
2
  import { InventoryProvider } from '@reactionary/core';
3
3
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
4
4
  export declare class FakeInventoryProvider extends InventoryProvider {
5
5
  protected config: FakeConfiguration;
6
6
  constructor(config: FakeConfiguration, cache: Cache, context: RequestContext);
7
- getBySKU(payload: InventoryQueryBySKU): Promise<Inventory>;
7
+ getBySKU(payload: InventoryQueryBySKU): Promise<Result<Inventory, NotFoundError>>;
8
8
  }
@@ -1,8 +1,8 @@
1
- import { type RequestContext, type Cache, PriceProvider, type CustomerPriceQuery, type ListPriceQuery, type Price } from '@reactionary/core';
1
+ import { type RequestContext, type Cache, PriceProvider, type CustomerPriceQuery, type ListPriceQuery, type Price, type Result } from '@reactionary/core';
2
2
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
3
3
  export declare class FakePriceProvider extends PriceProvider {
4
4
  protected config: FakeConfiguration;
5
5
  constructor(config: FakeConfiguration, cache: Cache, context: RequestContext);
6
- getListPrice(payload: ListPriceQuery): Promise<Price>;
7
- getCustomerPrice(payload: CustomerPriceQuery): Promise<Price>;
6
+ getListPrice(payload: ListPriceQuery): Promise<Result<Price>>;
7
+ getCustomerPrice(payload: CustomerPriceQuery): Promise<Result<Price>>;
8
8
  }
@@ -1,14 +1,13 @@
1
1
  import { ProductSearchProvider } from '@reactionary/core';
2
- import type { ProductSearchResult, ProductSearchResultFacet, Cache as ReactionaryCache, FacetIdentifier, FacetValueIdentifier, ProductSearchResultFacetValue, ProductSearchResultItemVariant, ProductSearchQueryCreateNavigationFilter } from '@reactionary/core';
2
+ import type { ProductSearchResult, ProductSearchResultFacet, Cache as ReactionaryCache, FacetIdentifier, FacetValueIdentifier, ProductSearchResultFacetValue, ProductSearchResultItemVariant, ProductSearchQueryCreateNavigationFilter, Result } from '@reactionary/core';
3
3
  import type { RequestContext, ProductSearchQueryByTerm } from '@reactionary/core';
4
4
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
5
5
  export declare class FakeSearchProvider extends ProductSearchProvider {
6
6
  protected config: FakeConfiguration;
7
7
  constructor(config: FakeConfiguration, cache: ReactionaryCache, context: RequestContext);
8
- createCategoryNavigationFilter(payload: ProductSearchQueryCreateNavigationFilter): Promise<FacetValueIdentifier>;
9
- queryByTerm(payload: ProductSearchQueryByTerm): Promise<ProductSearchResult>;
8
+ createCategoryNavigationFilter(payload: ProductSearchQueryCreateNavigationFilter): Promise<Result<FacetValueIdentifier>>;
9
+ queryByTerm(payload: ProductSearchQueryByTerm): Promise<Result<ProductSearchResult>>;
10
10
  protected parseFacetValue(facetValueIdentifier: FacetValueIdentifier, label: string, count: number): ProductSearchResultFacetValue;
11
11
  protected parseFacet(facetIdentifier: FacetIdentifier, facetValue: unknown): ProductSearchResultFacet;
12
12
  protected parseVariant(variant: unknown, product: unknown): ProductSearchResultItemVariant;
13
- protected childFunction(): number;
14
13
  }
@@ -1,10 +1,10 @@
1
- import { type ProductQueryById, type ProductQueryBySlug, type RequestContext, type Cache as ReactinaryCache, ProductProvider, type ProductQueryBySKU, type Product } from '@reactionary/core';
1
+ import { type ProductQueryById, type ProductQueryBySlug, type RequestContext, type Cache as ReactinaryCache, ProductProvider, type ProductQueryBySKU, type Product, type Result, type NotFoundError } from '@reactionary/core';
2
2
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
3
3
  export declare class FakeProductProvider extends ProductProvider {
4
4
  protected config: FakeConfiguration;
5
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>;
6
+ getById(payload: ProductQueryById): Promise<Result<Product>>;
7
+ getBySlug(payload: ProductQueryBySlug): Promise<Result<Product, NotFoundError>>;
8
+ getBySKU(payload: ProductQueryBySKU): Promise<Result<Product>>;
9
9
  protected parseSingle(body: string): Product;
10
10
  }
@@ -1,8 +1,8 @@
1
- import type { Cache, RequestContext, Store, StoreQueryByProximity } from '@reactionary/core';
1
+ import type { Cache, RequestContext, Store, StoreQueryByProximity, Result } from '@reactionary/core';
2
2
  import { StoreProvider } from '@reactionary/core';
3
3
  import type { FakeConfiguration } from '../schema/configuration.schema.js';
4
4
  export declare class FakeStoreProvider extends StoreProvider {
5
5
  protected config: FakeConfiguration;
6
6
  constructor(config: FakeConfiguration, cache: Cache, context: RequestContext);
7
- queryByProximity(payload: StoreQueryByProximity): Promise<Store[]>;
7
+ queryByProximity(payload: StoreQueryByProximity): Promise<Result<Store[]>>;
8
8
  }
@@ -2,11 +2,11 @@ import type { z } from 'zod';
2
2
  export declare const FakeCapabilitiesSchema: z.ZodObject<{
3
3
  price: z.ZodOptional<z.ZodBoolean>;
4
4
  product: z.ZodOptional<z.ZodBoolean>;
5
- identity: z.ZodOptional<z.ZodBoolean>;
6
5
  cart: z.ZodOptional<z.ZodBoolean>;
7
- productSearch: z.ZodOptional<z.ZodBoolean>;
6
+ identity: z.ZodOptional<z.ZodBoolean>;
8
7
  inventory: z.ZodOptional<z.ZodBoolean>;
9
8
  category: z.ZodOptional<z.ZodBoolean>;
10
9
  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>;