@reactionary/provider-fake 0.3.18 → 0.6.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.
Files changed (69) hide show
  1. package/core/initialize.js +193 -37
  2. package/core/initialize.types.js +8 -0
  3. package/factories/cart/cart.factory.js +15 -0
  4. package/factories/category/category.factory.js +15 -0
  5. package/factories/checkout/checkout.factory.js +19 -0
  6. package/factories/identity/identity.factory.js +11 -0
  7. package/factories/index.js +14 -0
  8. package/factories/inventory/inventory.factory.js +11 -0
  9. package/factories/order/order.factory.js +11 -0
  10. package/factories/order-search/order-search.factory.js +11 -0
  11. package/factories/price/price.factory.js +11 -0
  12. package/factories/product/product.factory.js +11 -0
  13. package/factories/product-associations/product-associations.factory.js +11 -0
  14. package/factories/product-reviews/product-reviews.factory.js +19 -0
  15. package/factories/product-search/product-search.factory.js +11 -0
  16. package/factories/profile/profile.factory.js +11 -0
  17. package/factories/store/store.factory.js +11 -0
  18. package/index.js +2 -0
  19. package/package.json +2 -2
  20. package/providers/cart.provider.js +7 -6
  21. package/providers/category.provider.js +57 -74
  22. package/providers/checkout.provider.js +15 -10
  23. package/providers/identity.provider.js +15 -17
  24. package/providers/inventory.provider.js +11 -15
  25. package/providers/order-search.provider.js +4 -3
  26. package/providers/order.provider.js +9 -32
  27. package/providers/price.provider.js +9 -15
  28. package/providers/product-associations.provider.js +6 -5
  29. package/providers/product-reviews.provider.js +30 -29
  30. package/providers/product-search.provider.js +14 -29
  31. package/providers/product.provider.js +13 -14
  32. package/providers/profile.provider.js +37 -33
  33. package/providers/store.provider.js +21 -15
  34. package/schema/capabilities.schema.js +21 -0
  35. package/src/core/initialize.d.ts +3 -2
  36. package/src/core/initialize.types.d.ts +113 -0
  37. package/src/factories/cart/cart.factory.d.ts +9 -0
  38. package/src/factories/category/category.factory.d.ts +9 -0
  39. package/src/factories/checkout/checkout.factory.d.ts +11 -0
  40. package/src/factories/identity/identity.factory.d.ts +7 -0
  41. package/src/factories/index.d.ts +14 -0
  42. package/src/factories/inventory/inventory.factory.d.ts +7 -0
  43. package/src/factories/order/order.factory.d.ts +7 -0
  44. package/src/factories/order-search/order-search.factory.d.ts +7 -0
  45. package/src/factories/price/price.factory.d.ts +9 -0
  46. package/src/factories/product/product.factory.d.ts +7 -0
  47. package/src/factories/product-associations/product-associations.factory.d.ts +7 -0
  48. package/src/factories/product-reviews/product-reviews.factory.d.ts +11 -0
  49. package/src/factories/product-search/product-search.factory.d.ts +7 -0
  50. package/src/factories/profile/profile.factory.d.ts +7 -0
  51. package/src/factories/store/store.factory.d.ts +7 -0
  52. package/src/index.d.ts +2 -0
  53. package/src/providers/cart.provider.d.ts +12 -10
  54. package/src/providers/category.provider.d.ts +12 -11
  55. package/src/providers/checkout.provider.d.ts +14 -12
  56. package/src/providers/identity.provider.d.ts +9 -7
  57. package/src/providers/inventory.provider.d.ts +6 -4
  58. package/src/providers/order-search.provider.d.ts +6 -4
  59. package/src/providers/order.provider.d.ts +6 -4
  60. package/src/providers/price.provider.d.ts +7 -5
  61. package/src/providers/product-associations.provider.d.ts +9 -6
  62. package/src/providers/product-reviews.provider.d.ts +8 -7
  63. package/src/providers/product-search.provider.d.ts +6 -9
  64. package/src/providers/product.provider.d.ts +9 -7
  65. package/src/providers/profile.provider.d.ts +14 -20
  66. package/src/providers/store.provider.d.ts +6 -4
  67. package/src/schema/capabilities.schema.d.ts +115 -16
  68. package/src/test/client-builder-product-extension.example.d.ts +1 -0
  69. package/test/client-builder-product-extension.example.js +57 -0
@@ -1,5 +1,28 @@
1
+ import {
2
+ CartIdentifierSchema as CoreCartIdentifierSchema,
3
+ CartSchema as CoreCartSchema,
4
+ CategoryPaginatedResultSchema as CoreCategoryPaginatedResultSchema,
5
+ CategorySchema as CoreCategorySchema,
6
+ CheckoutSchema as CoreCheckoutSchema,
7
+ IdentitySchema as CoreIdentitySchema,
8
+ InventorySchema as CoreInventorySchema,
9
+ OrderSchema as CoreOrderSchema,
10
+ OrderSearchResultSchema as CoreOrderSearchResultSchema,
11
+ PaymentMethodSchema as CorePaymentMethodSchema,
12
+ PriceSchema as CorePriceSchema,
13
+ ProductAssociationSchema as CoreProductAssociationSchema,
14
+ ProductRatingSummarySchema as CoreProductRatingSummarySchema,
15
+ ProductReviewPaginatedResultSchema as CoreProductReviewPaginatedResultSchema,
16
+ ProductReviewSchema as CoreProductReviewSchema,
17
+ ProductSchema as CoreProductSchema,
18
+ ProductSearchResultSchema as CoreProductSearchResultSchema,
19
+ ProfileSchema as CoreProfileSchema,
20
+ ShippingMethodSchema as CoreShippingMethodSchema,
21
+ StoreSchema as CoreStoreSchema
22
+ } from "@reactionary/core";
1
23
  import { FakeProductProvider } from "../providers/product.provider.js";
2
24
  import { FakeSearchProvider } from "../providers/product-search.provider.js";
25
+ import { FakeCapabilitiesSchema } from "../schema/capabilities.schema.js";
3
26
  import { FakeCategoryProvider } from "../providers/category.provider.js";
4
27
  import {
5
28
  FakeCartProvider,
@@ -14,62 +37,195 @@ import { FakeOrderProvider } from "../providers/order.provider.js";
14
37
  import { FakeProfileProvider } from "../providers/profile.provider.js";
15
38
  import { FakeProductReviewsProvider } from "../providers/product-reviews.provider.js";
16
39
  import { FakeProductAssociationsProvider } from "../providers/product-associations.provider.js";
40
+ import {
41
+ FakeCartFactory,
42
+ FakeCategoryFactory,
43
+ FakeCheckoutFactory,
44
+ FakeIdentityFactory,
45
+ FakeInventoryFactory,
46
+ FakeOrderFactory,
47
+ FakeOrderSearchFactory,
48
+ FakePriceFactory,
49
+ FakeProductAssociationsFactory,
50
+ FakeProductFactory,
51
+ FakeProductReviewsFactory,
52
+ FakeProductSearchFactory,
53
+ FakeProfileFactory,
54
+ FakeStoreFactory
55
+ } from "../factories/index.js";
56
+ import {
57
+ resolveCapabilityProvider
58
+ } from "./initialize.types.js";
17
59
  function withFakeCapabilities(configuration, capabilities) {
18
60
  return (cache, context) => {
19
61
  const client = {};
20
- if (capabilities.product) {
21
- client.product = new FakeProductProvider(configuration, cache, context);
62
+ const caps = FakeCapabilitiesSchema.parse(capabilities);
63
+ const buildProviderArgs = (factory) => ({
64
+ cache,
65
+ context,
66
+ config: configuration,
67
+ factory
68
+ });
69
+ if (caps.product?.enabled) {
70
+ client.product = resolveCapabilityProvider(
71
+ capabilities.product,
72
+ {
73
+ factory: new FakeProductFactory(CoreProductSchema),
74
+ provider: (args) => new FakeProductProvider(args.config, args.cache, args.context, args.factory)
75
+ },
76
+ buildProviderArgs
77
+ );
22
78
  }
23
- if (capabilities.productSearch) {
24
- client.productSearch = new FakeSearchProvider(
25
- configuration,
26
- cache,
27
- context
79
+ if (caps.productSearch?.enabled) {
80
+ client.productSearch = resolveCapabilityProvider(
81
+ capabilities.productSearch,
82
+ {
83
+ factory: new FakeProductSearchFactory(CoreProductSearchResultSchema),
84
+ provider: (args) => new FakeSearchProvider(args.config, args.cache, args.context, args.factory)
85
+ },
86
+ buildProviderArgs
28
87
  );
29
88
  }
30
- if (capabilities.category) {
31
- client.category = new FakeCategoryProvider(configuration, cache, context);
89
+ if (caps.category?.enabled) {
90
+ client.category = resolveCapabilityProvider(
91
+ capabilities.category,
92
+ {
93
+ factory: new FakeCategoryFactory(
94
+ CoreCategorySchema,
95
+ CoreCategoryPaginatedResultSchema
96
+ ),
97
+ provider: (args) => new FakeCategoryProvider(args.config, args.cache, args.context, args.factory)
98
+ },
99
+ buildProviderArgs
100
+ );
32
101
  }
33
- if (capabilities.cart) {
34
- client.cart = new FakeCartProvider(configuration, cache, context);
102
+ if (caps.cart?.enabled) {
103
+ client.cart = resolveCapabilityProvider(
104
+ capabilities.cart,
105
+ {
106
+ factory: new FakeCartFactory(CoreCartSchema, CoreCartIdentifierSchema),
107
+ provider: (args) => new FakeCartProvider(args.config, args.cache, args.context, args.factory)
108
+ },
109
+ buildProviderArgs
110
+ );
35
111
  }
36
- if (capabilities.inventory) {
37
- client.inventory = new FakeInventoryProvider(
38
- configuration,
39
- cache,
40
- context
112
+ if (caps.inventory?.enabled) {
113
+ client.inventory = resolveCapabilityProvider(
114
+ capabilities.inventory,
115
+ {
116
+ factory: new FakeInventoryFactory(CoreInventorySchema),
117
+ provider: (args) => new FakeInventoryProvider(args.config, args.cache, args.context, args.factory)
118
+ },
119
+ buildProviderArgs
41
120
  );
42
121
  }
43
- if (capabilities.store) {
44
- client.store = new FakeStoreProvider(configuration, cache, context);
122
+ if (caps.store?.enabled) {
123
+ client.store = resolveCapabilityProvider(
124
+ capabilities.store,
125
+ {
126
+ factory: new FakeStoreFactory(CoreStoreSchema),
127
+ provider: (args) => new FakeStoreProvider(args.config, args.cache, args.context, args.factory)
128
+ },
129
+ buildProviderArgs
130
+ );
45
131
  }
46
- if (capabilities.price) {
47
- client.price = new FakePriceProvider(configuration, cache, context);
132
+ if (caps.price?.enabled) {
133
+ client.price = resolveCapabilityProvider(
134
+ capabilities.price,
135
+ {
136
+ factory: new FakePriceFactory(CorePriceSchema),
137
+ provider: (args) => new FakePriceProvider(args.config, args.cache, args.context, args.factory)
138
+ },
139
+ buildProviderArgs
140
+ );
48
141
  }
49
- if (capabilities.identity) {
50
- client.identity = new FakeIdentityProvider(configuration, cache, context);
142
+ if (caps.identity?.enabled) {
143
+ client.identity = resolveCapabilityProvider(
144
+ capabilities.identity,
145
+ {
146
+ factory: new FakeIdentityFactory(CoreIdentitySchema),
147
+ provider: (args) => new FakeIdentityProvider(args.config, args.cache, args.context, args.factory)
148
+ },
149
+ buildProviderArgs
150
+ );
51
151
  }
52
- if (capabilities.checkout) {
53
- client.checkout = new FakeCheckoutProvider(configuration, cache, context);
152
+ if (caps.checkout?.enabled) {
153
+ client.checkout = resolveCapabilityProvider(
154
+ capabilities.checkout,
155
+ {
156
+ factory: new FakeCheckoutFactory(
157
+ CoreCheckoutSchema,
158
+ CoreShippingMethodSchema,
159
+ CorePaymentMethodSchema
160
+ ),
161
+ provider: (args) => new FakeCheckoutProvider(args.config, args.cache, args.context, args.factory)
162
+ },
163
+ buildProviderArgs
164
+ );
54
165
  }
55
- if (capabilities.orderSearch) {
56
- client.orderSearch = new FakeOrderSearchProvider(
57
- configuration,
58
- cache,
59
- context
166
+ if (caps.orderSearch?.enabled) {
167
+ client.orderSearch = resolveCapabilityProvider(
168
+ capabilities.orderSearch,
169
+ {
170
+ factory: new FakeOrderSearchFactory(CoreOrderSearchResultSchema),
171
+ provider: (args) => new FakeOrderSearchProvider(args.config, args.cache, args.context, args.factory)
172
+ },
173
+ buildProviderArgs
60
174
  );
61
175
  }
62
- if (capabilities.order) {
63
- client.order = new FakeOrderProvider(configuration, cache, context);
176
+ if (caps.order?.enabled) {
177
+ client.order = resolveCapabilityProvider(
178
+ capabilities.order,
179
+ {
180
+ factory: new FakeOrderFactory(CoreOrderSchema),
181
+ provider: (args) => new FakeOrderProvider(args.config, args.cache, args.context, args.factory)
182
+ },
183
+ buildProviderArgs
184
+ );
64
185
  }
65
- if (capabilities.profile) {
66
- client.profile = new FakeProfileProvider(configuration, cache, context);
186
+ if (caps.profile?.enabled) {
187
+ client.profile = resolveCapabilityProvider(
188
+ capabilities.profile,
189
+ {
190
+ factory: new FakeProfileFactory(CoreProfileSchema),
191
+ provider: (args) => new FakeProfileProvider(args.config, args.cache, args.context, args.factory)
192
+ },
193
+ buildProviderArgs
194
+ );
67
195
  }
68
- if (capabilities.productReviews) {
69
- client.productReviews = new FakeProductReviewsProvider(configuration, cache, context);
196
+ if (caps.productReviews?.enabled) {
197
+ client.productReviews = resolveCapabilityProvider(
198
+ capabilities.productReviews,
199
+ {
200
+ factory: new FakeProductReviewsFactory(
201
+ CoreProductRatingSummarySchema,
202
+ CoreProductReviewSchema,
203
+ CoreProductReviewPaginatedResultSchema
204
+ ),
205
+ provider: (args) => new FakeProductReviewsProvider(
206
+ args.config,
207
+ args.cache,
208
+ args.context,
209
+ args.factory
210
+ )
211
+ },
212
+ buildProviderArgs
213
+ );
70
214
  }
71
- if (capabilities.productAssociations) {
72
- client.productAssociations = new FakeProductAssociationsProvider(configuration, cache, context);
215
+ if (caps.productAssociations?.enabled) {
216
+ client.productAssociations = resolveCapabilityProvider(
217
+ capabilities.productAssociations,
218
+ {
219
+ factory: new FakeProductAssociationsFactory(CoreProductAssociationSchema),
220
+ provider: (args) => new FakeProductAssociationsProvider(
221
+ args.config,
222
+ args.cache,
223
+ args.context,
224
+ args.factory
225
+ )
226
+ },
227
+ buildProviderArgs
228
+ );
73
229
  }
74
230
  return client;
75
231
  };
@@ -0,0 +1,8 @@
1
+ function resolveCapabilityProvider(capability, defaults, buildProviderArgs) {
2
+ const factory = capability?.factory ?? defaults.factory;
3
+ const provider = capability?.provider ?? defaults.provider;
4
+ return provider(buildProviderArgs(factory));
5
+ }
6
+ export {
7
+ resolveCapabilityProvider
8
+ };
@@ -0,0 +1,15 @@
1
+ class FakeCartFactory {
2
+ constructor(cartSchema, cartIdentifierSchema) {
3
+ this.cartSchema = cartSchema;
4
+ this.cartIdentifierSchema = cartIdentifierSchema;
5
+ }
6
+ parseCart(_context, data) {
7
+ return this.cartSchema.parse(data);
8
+ }
9
+ parseCartIdentifier(_context, data) {
10
+ return this.cartIdentifierSchema.parse(data);
11
+ }
12
+ }
13
+ export {
14
+ FakeCartFactory
15
+ };
@@ -0,0 +1,15 @@
1
+ class FakeCategoryFactory {
2
+ constructor(categorySchema, categoryPaginatedResultSchema) {
3
+ this.categorySchema = categorySchema;
4
+ this.categoryPaginatedResultSchema = categoryPaginatedResultSchema;
5
+ }
6
+ parseCategory(_context, data) {
7
+ return this.categorySchema.parse(data);
8
+ }
9
+ parseCategoryPaginatedResult(_context, data) {
10
+ return this.categoryPaginatedResultSchema.parse(data);
11
+ }
12
+ }
13
+ export {
14
+ FakeCategoryFactory
15
+ };
@@ -0,0 +1,19 @@
1
+ class FakeCheckoutFactory {
2
+ constructor(checkoutSchema, shippingMethodSchema, paymentMethodSchema) {
3
+ this.checkoutSchema = checkoutSchema;
4
+ this.shippingMethodSchema = shippingMethodSchema;
5
+ this.paymentMethodSchema = paymentMethodSchema;
6
+ }
7
+ parseCheckout(_context, data) {
8
+ return this.checkoutSchema.parse(data);
9
+ }
10
+ parseShippingMethod(_context, data) {
11
+ return this.shippingMethodSchema.parse(data);
12
+ }
13
+ parsePaymentMethod(_context, data) {
14
+ return this.paymentMethodSchema.parse(data);
15
+ }
16
+ }
17
+ export {
18
+ FakeCheckoutFactory
19
+ };
@@ -0,0 +1,11 @@
1
+ class FakeIdentityFactory {
2
+ constructor(identitySchema) {
3
+ this.identitySchema = identitySchema;
4
+ }
5
+ parseIdentity(_context, data) {
6
+ return this.identitySchema.parse(data);
7
+ }
8
+ }
9
+ export {
10
+ FakeIdentityFactory
11
+ };
@@ -0,0 +1,14 @@
1
+ export * from "./cart/cart.factory.js";
2
+ export * from "./category/category.factory.js";
3
+ export * from "./checkout/checkout.factory.js";
4
+ export * from "./identity/identity.factory.js";
5
+ export * from "./inventory/inventory.factory.js";
6
+ export * from "./order-search/order-search.factory.js";
7
+ export * from "./order/order.factory.js";
8
+ export * from "./price/price.factory.js";
9
+ export * from "./product-associations/product-associations.factory.js";
10
+ export * from "./product-reviews/product-reviews.factory.js";
11
+ export * from "./product-search/product-search.factory.js";
12
+ export * from "./product/product.factory.js";
13
+ export * from "./profile/profile.factory.js";
14
+ export * from "./store/store.factory.js";
@@ -0,0 +1,11 @@
1
+ class FakeInventoryFactory {
2
+ constructor(inventorySchema) {
3
+ this.inventorySchema = inventorySchema;
4
+ }
5
+ parseInventory(_context, data) {
6
+ return this.inventorySchema.parse(data);
7
+ }
8
+ }
9
+ export {
10
+ FakeInventoryFactory
11
+ };
@@ -0,0 +1,11 @@
1
+ class FakeOrderFactory {
2
+ constructor(orderSchema) {
3
+ this.orderSchema = orderSchema;
4
+ }
5
+ parseOrder(_context, data) {
6
+ return this.orderSchema.parse(data);
7
+ }
8
+ }
9
+ export {
10
+ FakeOrderFactory
11
+ };
@@ -0,0 +1,11 @@
1
+ class FakeOrderSearchFactory {
2
+ constructor(orderSearchResultSchema) {
3
+ this.orderSearchResultSchema = orderSearchResultSchema;
4
+ }
5
+ parseOrderSearchResult(_context, data, _query) {
6
+ return this.orderSearchResultSchema.parse(data);
7
+ }
8
+ }
9
+ export {
10
+ FakeOrderSearchFactory
11
+ };
@@ -0,0 +1,11 @@
1
+ class FakePriceFactory {
2
+ constructor(priceSchema) {
3
+ this.priceSchema = priceSchema;
4
+ }
5
+ parsePrice(_context, data, _options) {
6
+ return this.priceSchema.parse(data);
7
+ }
8
+ }
9
+ export {
10
+ FakePriceFactory
11
+ };
@@ -0,0 +1,11 @@
1
+ class FakeProductFactory {
2
+ constructor(productSchema) {
3
+ this.productSchema = productSchema;
4
+ }
5
+ parseProduct(_context, data) {
6
+ return this.productSchema.parse(data);
7
+ }
8
+ }
9
+ export {
10
+ FakeProductFactory
11
+ };
@@ -0,0 +1,11 @@
1
+ class FakeProductAssociationsFactory {
2
+ constructor(productAssociationSchema) {
3
+ this.productAssociationSchema = productAssociationSchema;
4
+ }
5
+ parseAssociation(_context, data) {
6
+ return this.productAssociationSchema.parse(data);
7
+ }
8
+ }
9
+ export {
10
+ FakeProductAssociationsFactory
11
+ };
@@ -0,0 +1,19 @@
1
+ class FakeProductReviewsFactory {
2
+ constructor(ratingSummarySchema, reviewSchema, reviewPaginatedSchema) {
3
+ this.ratingSummarySchema = ratingSummarySchema;
4
+ this.reviewSchema = reviewSchema;
5
+ this.reviewPaginatedSchema = reviewPaginatedSchema;
6
+ }
7
+ parseRatingSummary(_context, data) {
8
+ return this.ratingSummarySchema.parse(data);
9
+ }
10
+ parseReview(_context, data) {
11
+ return this.reviewSchema.parse(data);
12
+ }
13
+ parseReviewPaginatedResult(_context, data) {
14
+ return this.reviewPaginatedSchema.parse(data);
15
+ }
16
+ }
17
+ export {
18
+ FakeProductReviewsFactory
19
+ };
@@ -0,0 +1,11 @@
1
+ class FakeProductSearchFactory {
2
+ constructor(productSearchResultSchema) {
3
+ this.productSearchResultSchema = productSearchResultSchema;
4
+ }
5
+ parseSearchResult(_context, data, _query) {
6
+ return this.productSearchResultSchema.parse(data);
7
+ }
8
+ }
9
+ export {
10
+ FakeProductSearchFactory
11
+ };
@@ -0,0 +1,11 @@
1
+ class FakeProfileFactory {
2
+ constructor(profileSchema) {
3
+ this.profileSchema = profileSchema;
4
+ }
5
+ parseProfile(_context, data) {
6
+ return this.profileSchema.parse(data);
7
+ }
8
+ }
9
+ export {
10
+ FakeProfileFactory
11
+ };
@@ -0,0 +1,11 @@
1
+ class FakeStoreFactory {
2
+ constructor(storeSchema) {
3
+ this.storeSchema = storeSchema;
4
+ }
5
+ parseStore(_context, data) {
6
+ return this.storeSchema.parse(data);
7
+ }
8
+ }
9
+ export {
10
+ FakeStoreFactory
11
+ };
package/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from "./core/initialize.js";
2
+ export * from "./core/initialize.types.js";
2
3
  export * from "./providers/index.js";
4
+ export * from "./factories/index.js";
3
5
  export * from "./schema/capabilities.schema.js";
4
6
  export * from "./schema/configuration.schema.js";
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@reactionary/provider-fake",
3
- "version": "0.3.18",
3
+ "version": "0.6.2",
4
4
  "main": "index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "dependencies": {
7
- "@reactionary/core": "0.3.18",
7
+ "@reactionary/core": "0.6.2",
8
8
  "zod": "4.1.9",
9
9
  "@faker-js/faker": "^9.8.0"
10
10
  },
@@ -28,7 +28,7 @@ import {
28
28
  } from "@reactionary/core";
29
29
  import { Faker, en, base } from "@faker-js/faker";
30
30
  class FakeCartProvider extends CartProvider {
31
- constructor(config, cache, context) {
31
+ constructor(config, cache, context, factory) {
32
32
  super(cache, context);
33
33
  this.carts = /* @__PURE__ */ new Map();
34
34
  this.generator = new Faker({
@@ -36,6 +36,7 @@ class FakeCartProvider extends CartProvider {
36
36
  seed: config.seeds.product
37
37
  });
38
38
  this.config = config;
39
+ this.factory = factory;
39
40
  }
40
41
  async getById(payload) {
41
42
  const cartId = payload.cart.key;
@@ -54,7 +55,7 @@ class FakeCartProvider extends CartProvider {
54
55
  if (!cart) {
55
56
  throw new Error(`Cart with id ${cartId} not found`);
56
57
  }
57
- return success(cart);
58
+ return success(this.factory.parseCart(this.context, cart));
58
59
  }
59
60
  async add(payload) {
60
61
  const cartId = payload?.cart?.key || `cart-${this.generator.string.uuid()}`;
@@ -99,7 +100,7 @@ class FakeCartProvider extends CartProvider {
99
100
  });
100
101
  }
101
102
  this.recalculateCart(cart);
102
- return success(cart);
103
+ return success(this.factory.parseCart(this.context, cart));
103
104
  }
104
105
  async remove(payload) {
105
106
  const cartId = payload.cart.key || `cart-${this.generator.string.uuid()}`;
@@ -108,7 +109,7 @@ class FakeCartProvider extends CartProvider {
108
109
  (item) => item.identifier.key !== payload.item.key
109
110
  );
110
111
  this.recalculateCart(cart);
111
- return success(cart);
112
+ return success(this.factory.parseCart(this.context, cart));
112
113
  }
113
114
  async changeQuantity(payload) {
114
115
  const cartId = payload.cart.key || `cart-${this.generator.string.uuid()}`;
@@ -117,13 +118,13 @@ class FakeCartProvider extends CartProvider {
117
118
  (item2) => item2.identifier.key === payload.item.key
118
119
  );
119
120
  if (payload.quantity < 1) {
120
- return success(cart);
121
+ return success(this.factory.parseCart(this.context, cart));
121
122
  }
122
123
  if (item) {
123
124
  item.quantity = payload.quantity;
124
125
  }
125
126
  this.recalculateCart(cart);
126
- return success(cart);
127
+ return success(this.factory.parseCart(this.context, cart));
127
128
  }
128
129
  getActiveCartId() {
129
130
  throw new Error("Method not implemented.");