@reactionary/source 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.
- package/README.md +28 -14
- package/core/src/client/client-builder.ts +54 -6
- package/core/src/factories/cart.factory.ts +40 -0
- package/core/src/factories/category.factory.ts +40 -0
- package/core/src/factories/checkout.factory.ts +59 -0
- package/core/src/factories/identity.factory.ts +26 -0
- package/core/src/factories/index.ts +15 -0
- package/core/src/factories/inventory.factory.ts +26 -0
- package/core/src/factories/order-search.factory.ts +33 -0
- package/core/src/factories/order.factory.ts +21 -0
- package/core/src/factories/price.factory.ts +29 -0
- package/core/src/factories/product-associations.factory.ts +30 -0
- package/core/src/factories/product-list.factory.ts +82 -0
- package/core/src/factories/product-reviews.factory.ts +58 -0
- package/core/src/factories/product-search.factory.ts +31 -0
- package/core/src/factories/product.factory.ts +21 -0
- package/core/src/factories/profile.factory.ts +23 -0
- package/core/src/factories/store.factory.ts +21 -0
- package/core/src/index.ts +3 -1
- package/core/src/providers/cart.provider.ts +12 -10
- package/core/src/providers/category.provider.ts +9 -7
- package/core/src/providers/checkout.provider.ts +14 -10
- package/core/src/providers/identity.provider.ts +7 -7
- package/core/src/providers/inventory.provider.ts +4 -4
- package/core/src/providers/order-search.provider.ts +4 -2
- package/core/src/providers/order.provider.ts +4 -4
- package/core/src/providers/price.provider.ts +5 -5
- package/core/src/providers/product-associations.provider.ts +6 -4
- package/core/src/providers/product-list.provider.ts +13 -8
- package/core/src/providers/product-reviews.provider.ts +8 -4
- package/core/src/providers/product-search.provider.ts +15 -28
- package/core/src/providers/product.provider.ts +6 -6
- package/core/src/providers/profile.provider.ts +8 -8
- package/core/src/providers/store.provider.ts +2 -2
- package/core/src/test/client-builder.spec.ts +81 -0
- package/examples/node/package.json +7 -7
- package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +10 -4
- package/examples/node/src/basic/basic-node-provider-query-extension.spec.ts +8 -2
- package/examples/node/src/basic/basic-node-setup.spec.ts +5 -1
- package/examples/node/src/basic/client-creation.spec.ts +3 -3
- package/examples/node/src/utils.ts +41 -41
- package/examples/node/tsconfig.lib.json +2 -1
- package/package.json +1 -1
- package/providers/algolia/src/core/initialize.ts +76 -21
- package/providers/algolia/src/core/initialize.types.ts +107 -0
- package/providers/algolia/src/factories/index.ts +1 -0
- package/providers/algolia/src/factories/product-search/product-search.factory.ts +182 -0
- package/providers/algolia/src/index.ts +2 -2
- package/providers/algolia/src/providers/analytics.provider.ts +4 -4
- package/providers/algolia/src/providers/product-search.provider.ts +67 -184
- package/providers/algolia/src/schema/capabilities.schema.ts +81 -7
- package/providers/algolia/src/test/analytics.spec.ts +9 -1
- package/providers/algolia/src/test/client-builder-product-search-extension.example.ts +85 -0
- package/providers/commercetools/src/core/capability-descriptors.ts +324 -0
- package/providers/commercetools/src/core/initialize.ts +35 -151
- package/providers/commercetools/src/core/initialize.types.ts +174 -0
- package/providers/commercetools/src/factories/cart/cart.factory.ts +142 -0
- package/providers/commercetools/src/factories/category/category.factory.ts +77 -0
- package/providers/commercetools/src/factories/checkout/checkout-initializer-overrides.example.ts +94 -0
- package/providers/commercetools/src/factories/checkout/checkout.factory.ts +338 -0
- package/providers/commercetools/src/factories/identity/identity.factory.ts +26 -0
- package/providers/commercetools/src/factories/inventory/inventory.factory.ts +49 -0
- package/providers/commercetools/src/factories/order/order.factory.ts +149 -0
- package/providers/commercetools/src/factories/order-search/order-search.factory.ts +108 -0
- package/providers/commercetools/src/factories/price/price.factory.ts +76 -0
- package/providers/commercetools/src/factories/product/product-factory-baseline.example.ts +14 -0
- package/providers/commercetools/src/factories/product/product-factory-schema-and-parse-extension.example.ts +35 -0
- package/providers/commercetools/src/factories/product/product-factory-schema-extension.example.ts +23 -0
- package/providers/commercetools/src/factories/product/product-initializer-factory-extension.example.ts +41 -0
- package/providers/commercetools/src/factories/product/product-provider-custom-method-only.example.ts +47 -0
- package/providers/commercetools/src/factories/product/product-provider-schema-signature-extension.example.ts +61 -0
- package/providers/commercetools/src/factories/product/product.factory.ts +220 -0
- package/providers/commercetools/src/factories/product/utils.example.ts +9 -0
- package/providers/commercetools/src/factories/product-associations/product-associations.factory.ts +103 -0
- package/providers/commercetools/src/factories/product-list/product-list.factory.ts +122 -0
- package/providers/commercetools/src/factories/product-reviews/product-reviews.factory.ts +81 -0
- package/providers/commercetools/src/factories/product-search/product-search.factory.ts +182 -0
- package/providers/commercetools/src/factories/profile/profile.factory.ts +94 -0
- package/providers/commercetools/src/factories/store/store.factory.ts +49 -0
- package/providers/commercetools/src/index.ts +15 -0
- package/providers/commercetools/src/providers/cart.provider.ts +67 -193
- package/providers/commercetools/src/providers/category.provider.ts +24 -64
- package/providers/commercetools/src/providers/checkout.provider.ts +50 -322
- package/providers/commercetools/src/providers/identity.provider.ts +35 -15
- package/providers/commercetools/src/providers/inventory.provider.ts +13 -31
- package/providers/commercetools/src/providers/order-search.provider.ts +16 -110
- package/providers/commercetools/src/providers/order.provider.ts +13 -144
- package/providers/commercetools/src/providers/price.provider.ts +37 -51
- package/providers/commercetools/src/providers/product-associations.provider.ts +39 -104
- package/providers/commercetools/src/providers/product-list.provider.ts +38 -23
- package/providers/commercetools/src/providers/product-reviews.provider.ts +34 -14
- package/providers/commercetools/src/providers/product-search.provider.ts +17 -170
- package/providers/commercetools/src/providers/product.provider.ts +20 -199
- package/providers/commercetools/src/providers/profile.provider.ts +27 -73
- package/providers/commercetools/src/providers/store.provider.ts +13 -31
- package/providers/commercetools/src/schema/capabilities.schema.ts +258 -20
- package/providers/commercetools/src/test/caching.spec.ts +18 -2
- package/providers/commercetools/src/test/client-builder-merge-extensions.example.ts +125 -0
- package/providers/fake/src/core/initialize.ts +213 -44
- package/providers/fake/src/core/initialize.types.ts +164 -0
- package/providers/fake/src/factories/cart/cart.factory.ts +34 -0
- package/providers/fake/src/factories/category/category.factory.ts +40 -0
- package/providers/fake/src/factories/checkout/checkout.factory.ts +53 -0
- package/providers/fake/src/factories/identity/identity.factory.ts +25 -0
- package/providers/fake/src/factories/index.ts +14 -0
- package/providers/fake/src/factories/inventory/inventory.factory.ts +25 -0
- package/providers/fake/src/factories/order/order.factory.ts +22 -0
- package/providers/fake/src/factories/order-search/order-search.factory.ts +27 -0
- package/providers/fake/src/factories/price/price.factory.ts +26 -0
- package/providers/fake/src/factories/product/product.factory.ts +22 -0
- package/providers/fake/src/factories/product-associations/product-associations.factory.ts +25 -0
- package/providers/fake/src/factories/product-reviews/product-reviews.factory.ts +53 -0
- package/providers/fake/src/factories/product-search/product-search.factory.ts +27 -0
- package/providers/fake/src/factories/profile/profile.factory.ts +22 -0
- package/providers/fake/src/factories/store/store.factory.ts +22 -0
- package/providers/fake/src/index.ts +2 -0
- package/providers/fake/src/providers/cart.provider.ts +23 -14
- package/providers/fake/src/providers/category.provider.ts +120 -105
- package/providers/fake/src/providers/checkout.provider.ts +39 -20
- package/providers/fake/src/providers/identity.provider.ts +40 -34
- package/providers/fake/src/providers/inventory.provider.ts +26 -24
- package/providers/fake/src/providers/order-search.provider.ts +38 -30
- package/providers/fake/src/providers/order.provider.ts +21 -37
- package/providers/fake/src/providers/price.provider.ts +42 -34
- package/providers/fake/src/providers/product-associations.provider.ts +23 -10
- package/providers/fake/src/providers/product-reviews.provider.ts +71 -69
- package/providers/fake/src/providers/product-search.provider.ts +43 -70
- package/providers/fake/src/providers/product.provider.ts +34 -32
- package/providers/fake/src/providers/profile.provider.ts +62 -55
- package/providers/fake/src/providers/store.provider.ts +38 -22
- package/providers/fake/src/schema/capabilities.schema.ts +175 -18
- package/providers/fake/src/test/cart.provider.spec.ts +20 -3
- package/providers/fake/src/test/category.provider.spec.ts +4 -1
- package/providers/fake/src/test/checkout.provider.spec.ts +12 -2
- package/providers/fake/src/test/client-builder-product-extension.example.ts +75 -0
- package/providers/fake/src/test/order-search.provider.spec.ts +4 -7
- package/providers/fake/src/test/order.provider.spec.ts +4 -6
- package/providers/fake/src/test/price.provider.spec.ts +3 -1
- package/providers/fake/src/test/product.provider.spec.ts +8 -2
- package/providers/fake/src/test/profile.provider.spec.ts +4 -2
- package/providers/google-analytics/src/core/initialize.ts +37 -12
- package/providers/google-analytics/src/core/initialize.types.ts +47 -0
- package/providers/google-analytics/src/index.ts +1 -0
- package/providers/google-analytics/src/schema/capabilities.schema.ts +31 -5
- package/providers/medusa/src/core/initialize.ts +324 -81
- package/providers/medusa/src/core/initialize.types.ts +184 -0
- package/providers/medusa/src/factories/cart/cart.factory.ts +34 -0
- package/providers/medusa/src/factories/category/category.factory.ts +37 -0
- package/providers/medusa/src/factories/checkout/checkout.factory.ts +50 -0
- package/providers/medusa/src/factories/identity/identity.factory.ts +22 -0
- package/providers/medusa/src/factories/index.ts +12 -0
- package/providers/medusa/src/factories/inventory/inventory.factory.ts +25 -0
- package/providers/medusa/src/factories/order/order.factory.ts +22 -0
- package/providers/medusa/src/factories/order-search/order-search.factory.ts +27 -0
- package/providers/medusa/src/factories/price/price.factory.ts +26 -0
- package/providers/medusa/src/factories/product/product.factory.ts +22 -0
- package/providers/medusa/src/factories/product-associations/product-associations.factory.ts +25 -0
- package/providers/medusa/src/factories/product-search/product-search.factory.ts +27 -0
- package/providers/medusa/src/factories/profile/profile.factory.ts +22 -0
- package/providers/medusa/src/index.ts +2 -0
- package/providers/medusa/src/providers/cart.provider.ts +33 -20
- package/providers/medusa/src/providers/category.provider.ts +30 -12
- package/providers/medusa/src/providers/checkout.provider.ts +42 -17
- package/providers/medusa/src/providers/identity.provider.ts +1 -1
- package/providers/medusa/src/providers/inventory.provider.ts +21 -7
- package/providers/medusa/src/providers/order-search.provider.ts +16 -5
- package/providers/medusa/src/providers/order.provider.ts +17 -5
- package/providers/medusa/src/providers/price.provider.ts +26 -7
- package/providers/medusa/src/providers/product-associations.provider.ts +19 -8
- package/providers/medusa/src/providers/product-search.provider.ts +19 -31
- package/providers/medusa/src/providers/product.provider.ts +47 -11
- package/providers/medusa/src/providers/profile.provider.ts +35 -11
- package/providers/medusa/src/schema/capabilities.schema.ts +229 -18
- package/providers/medusa/src/test/cart.provider.spec.ts +18 -2
- package/providers/medusa/src/test/category.provider.spec.ts +4 -1
- package/providers/medusa/src/test/checkout.spec.ts +9 -9
- package/providers/medusa/src/test/inventory.provider.spec.ts +3 -1
- package/providers/medusa/src/test/large-cart.provider.spec.ts +8 -2
- package/providers/medusa/src/test/price.provider.spec.ts +8 -1
- package/providers/medusa/src/test/product.provider.spec.ts +3 -1
- package/providers/medusa/src/test/search.provider.spec.ts +16 -3
- package/providers/meilisearch/src/core/initialize.ts +88 -21
- package/providers/meilisearch/src/core/initialize.types.ts +119 -0
- package/providers/meilisearch/src/factories/index.ts +2 -0
- package/providers/meilisearch/src/factories/order-search/order-search.factory.ts +27 -0
- package/providers/meilisearch/src/factories/product-search/product-search.factory.ts +27 -0
- package/providers/meilisearch/src/index.ts +2 -0
- package/providers/meilisearch/src/providers/index.ts +1 -0
- package/providers/meilisearch/src/providers/order-search.provider.ts +21 -6
- package/providers/meilisearch/src/providers/product-search.provider.ts +24 -8
- package/providers/meilisearch/src/schema/capabilities.schema.ts +95 -8
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClientBuilder,
|
|
3
|
+
createInitialRequestContext,
|
|
4
|
+
NoOpCache,
|
|
5
|
+
ProductSchema,
|
|
6
|
+
StoreSchema,
|
|
7
|
+
type RequestContext,
|
|
8
|
+
} from '@reactionary/core';
|
|
9
|
+
import type { ProductProjection, Channel } from '@commercetools/platform-sdk';
|
|
10
|
+
import * as z from 'zod';
|
|
11
|
+
import type { CommercetoolsConfiguration } from '../schema/configuration.schema.js';
|
|
12
|
+
import { withCommercetoolsCapabilities } from '../core/initialize.js';
|
|
13
|
+
import { CommercetoolsProductFactory } from '../factories/product/product.factory.js';
|
|
14
|
+
import { CommercetoolsStoreFactory } from '../factories/store/store.factory.js';
|
|
15
|
+
import { assertNotAny, assertType } from '../factories/product/utils.example.js';
|
|
16
|
+
|
|
17
|
+
const ExtendedProductSchema = ProductSchema.safeExtend({
|
|
18
|
+
extendedProductValue: z.string(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
class ExtendedCommercetoolsProductFactory extends CommercetoolsProductFactory<
|
|
22
|
+
typeof ExtendedProductSchema
|
|
23
|
+
> {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(ExtendedProductSchema);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public override parseProduct(context: RequestContext, data: ProductProjection) {
|
|
29
|
+
const base = super.parseProduct(context, data);
|
|
30
|
+
return this.productSchema.parse({
|
|
31
|
+
...base,
|
|
32
|
+
extendedProductValue: 'from-product-factory',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ExtendedStoreSchema = StoreSchema.safeExtend({
|
|
38
|
+
extendedStoreValue: z.string(),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
class ExtendedCommercetoolsStoreFactory extends CommercetoolsStoreFactory<
|
|
42
|
+
typeof ExtendedStoreSchema
|
|
43
|
+
> {
|
|
44
|
+
constructor() {
|
|
45
|
+
super(ExtendedStoreSchema);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public override parseStore(context: RequestContext, data: Channel) {
|
|
49
|
+
const base = super.parseStore(context, data);
|
|
50
|
+
return this.storeSchema.parse({
|
|
51
|
+
...base,
|
|
52
|
+
extendedStoreValue: 'from-store-factory',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const config = {
|
|
58
|
+
apiUrl: 'https://api.example.invalid',
|
|
59
|
+
authUrl: 'https://auth.example.invalid',
|
|
60
|
+
clientId: 'test-client',
|
|
61
|
+
clientSecret: 'test-secret',
|
|
62
|
+
projectKey: 'test-project',
|
|
63
|
+
scopes: [],
|
|
64
|
+
paymentMethods: [],
|
|
65
|
+
facetFieldsForSearch: [],
|
|
66
|
+
} satisfies CommercetoolsConfiguration;
|
|
67
|
+
|
|
68
|
+
function createMergedClientExample() {
|
|
69
|
+
const cache = new NoOpCache();
|
|
70
|
+
const context = createInitialRequestContext();
|
|
71
|
+
|
|
72
|
+
const withProduct = withCommercetoolsCapabilities(config, {
|
|
73
|
+
product: {
|
|
74
|
+
enabled: true,
|
|
75
|
+
factory: new ExtendedCommercetoolsProductFactory(),
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const withStore = withCommercetoolsCapabilities(config, {
|
|
80
|
+
store: {
|
|
81
|
+
enabled: true,
|
|
82
|
+
factory: new ExtendedCommercetoolsStoreFactory(),
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const client = new ClientBuilder(context)
|
|
87
|
+
.withCache(cache)
|
|
88
|
+
.withCapability(withProduct)
|
|
89
|
+
.withCapability(withStore)
|
|
90
|
+
.build();
|
|
91
|
+
|
|
92
|
+
client.product
|
|
93
|
+
.getById({
|
|
94
|
+
identifier: { key: 'p-1' },
|
|
95
|
+
})
|
|
96
|
+
.then((result) => {
|
|
97
|
+
assertNotAny(result);
|
|
98
|
+
if (result.success) {
|
|
99
|
+
assertNotAny(result.value);
|
|
100
|
+
assertNotAny(result.value.extendedProductValue);
|
|
101
|
+
assertType<string>(result.value.extendedProductValue);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
client.store
|
|
106
|
+
.queryByProximity({
|
|
107
|
+
longitude: 10.0,
|
|
108
|
+
latitude: 56.0,
|
|
109
|
+
distance: 50,
|
|
110
|
+
limit: 5,
|
|
111
|
+
})
|
|
112
|
+
.then((result) => {
|
|
113
|
+
assertNotAny(result);
|
|
114
|
+
if (result.success) {
|
|
115
|
+
const first = result.value[0];
|
|
116
|
+
assertNotAny(first);
|
|
117
|
+
assertNotAny(first.extendedStoreValue);
|
|
118
|
+
assertType<string>(first.extendedStoreValue);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
return client;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
void createMergedClientExample;
|
|
@@ -1,12 +1,31 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { Cache as ReactinaryCache, RequestContext } from '@reactionary/core';
|
|
2
|
+
import {
|
|
3
|
+
CartIdentifierSchema as CoreCartIdentifierSchema,
|
|
4
|
+
CartSchema as CoreCartSchema,
|
|
5
|
+
CategoryPaginatedResultSchema as CoreCategoryPaginatedResultSchema,
|
|
6
|
+
CategorySchema as CoreCategorySchema,
|
|
7
|
+
CheckoutSchema as CoreCheckoutSchema,
|
|
8
|
+
IdentitySchema as CoreIdentitySchema,
|
|
9
|
+
InventorySchema as CoreInventorySchema,
|
|
10
|
+
OrderSchema as CoreOrderSchema,
|
|
11
|
+
OrderSearchResultSchema as CoreOrderSearchResultSchema,
|
|
12
|
+
PaymentMethodSchema as CorePaymentMethodSchema,
|
|
13
|
+
PriceSchema as CorePriceSchema,
|
|
14
|
+
ProductAssociationSchema as CoreProductAssociationSchema,
|
|
15
|
+
ProductRatingSummarySchema as CoreProductRatingSummarySchema,
|
|
16
|
+
ProductReviewPaginatedResultSchema as CoreProductReviewPaginatedResultSchema,
|
|
17
|
+
ProductReviewSchema as CoreProductReviewSchema,
|
|
18
|
+
ProductSchema as CoreProductSchema,
|
|
19
|
+
ProductSearchResultSchema as CoreProductSearchResultSchema,
|
|
20
|
+
ProfileSchema as CoreProfileSchema,
|
|
21
|
+
ShippingMethodSchema as CoreShippingMethodSchema,
|
|
22
|
+
StoreSchema as CoreStoreSchema,
|
|
5
23
|
} from '@reactionary/core';
|
|
6
24
|
import { FakeProductProvider } from '../providers/product.provider.js';
|
|
7
25
|
import { FakeSearchProvider } from '../providers/product-search.provider.js';
|
|
8
26
|
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
9
27
|
import type { FakeCapabilities } from '../schema/capabilities.schema.js';
|
|
28
|
+
import { FakeCapabilitiesSchema } from '../schema/capabilities.schema.js';
|
|
10
29
|
import { FakeCategoryProvider } from '../providers/category.provider.js';
|
|
11
30
|
import {
|
|
12
31
|
FakeCartProvider,
|
|
@@ -21,83 +40,233 @@ import { FakeOrderProvider } from '../providers/order.provider.js';
|
|
|
21
40
|
import { FakeProfileProvider } from '../providers/profile.provider.js';
|
|
22
41
|
import { FakeProductReviewsProvider } from '../providers/product-reviews.provider.js';
|
|
23
42
|
import { FakeProductAssociationsProvider } from '../providers/product-associations.provider.js';
|
|
43
|
+
import {
|
|
44
|
+
FakeCartFactory,
|
|
45
|
+
FakeCategoryFactory,
|
|
46
|
+
FakeCheckoutFactory,
|
|
47
|
+
FakeIdentityFactory,
|
|
48
|
+
FakeInventoryFactory,
|
|
49
|
+
FakeOrderFactory,
|
|
50
|
+
FakeOrderSearchFactory,
|
|
51
|
+
FakePriceFactory,
|
|
52
|
+
FakeProductAssociationsFactory,
|
|
53
|
+
FakeProductFactory,
|
|
54
|
+
FakeProductReviewsFactory,
|
|
55
|
+
FakeProductSearchFactory,
|
|
56
|
+
FakeProfileFactory,
|
|
57
|
+
FakeStoreFactory,
|
|
58
|
+
} from '../factories/index.js';
|
|
59
|
+
import {
|
|
60
|
+
type FakeClientFromCapabilities,
|
|
61
|
+
resolveCapabilityProvider,
|
|
62
|
+
} from './initialize.types.js';
|
|
24
63
|
|
|
25
64
|
export function withFakeCapabilities<T extends FakeCapabilities>(
|
|
26
65
|
configuration: FakeConfiguration,
|
|
27
|
-
capabilities: T
|
|
66
|
+
capabilities: T,
|
|
28
67
|
) {
|
|
29
68
|
return (
|
|
30
69
|
cache: ReactinaryCache,
|
|
31
|
-
context: RequestContext
|
|
32
|
-
):
|
|
70
|
+
context: RequestContext,
|
|
71
|
+
): FakeClientFromCapabilities<T> => {
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
73
|
const client: any = {};
|
|
74
|
+
const caps = FakeCapabilitiesSchema.parse(capabilities);
|
|
75
|
+
|
|
76
|
+
const buildProviderArgs = <TFactory,>(factory: TFactory) => ({
|
|
77
|
+
cache,
|
|
78
|
+
context,
|
|
79
|
+
config: configuration,
|
|
80
|
+
factory,
|
|
81
|
+
});
|
|
34
82
|
|
|
35
|
-
if (
|
|
36
|
-
client.product =
|
|
83
|
+
if (caps.product?.enabled) {
|
|
84
|
+
client.product = resolveCapabilityProvider(
|
|
85
|
+
capabilities.product,
|
|
86
|
+
{
|
|
87
|
+
factory: new FakeProductFactory(CoreProductSchema),
|
|
88
|
+
provider: (args) =>
|
|
89
|
+
new FakeProductProvider(args.config, args.cache, args.context, args.factory),
|
|
90
|
+
},
|
|
91
|
+
buildProviderArgs,
|
|
92
|
+
);
|
|
37
93
|
}
|
|
38
94
|
|
|
39
|
-
if (
|
|
40
|
-
client.productSearch =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
95
|
+
if (caps.productSearch?.enabled) {
|
|
96
|
+
client.productSearch = resolveCapabilityProvider(
|
|
97
|
+
capabilities.productSearch,
|
|
98
|
+
{
|
|
99
|
+
factory: new FakeProductSearchFactory(CoreProductSearchResultSchema),
|
|
100
|
+
provider: (args) =>
|
|
101
|
+
new FakeSearchProvider(args.config, args.cache, args.context, args.factory),
|
|
102
|
+
},
|
|
103
|
+
buildProviderArgs,
|
|
44
104
|
);
|
|
45
105
|
}
|
|
46
106
|
|
|
47
|
-
if (
|
|
48
|
-
client.category =
|
|
107
|
+
if (caps.category?.enabled) {
|
|
108
|
+
client.category = resolveCapabilityProvider(
|
|
109
|
+
capabilities.category,
|
|
110
|
+
{
|
|
111
|
+
factory: new FakeCategoryFactory(
|
|
112
|
+
CoreCategorySchema,
|
|
113
|
+
CoreCategoryPaginatedResultSchema,
|
|
114
|
+
),
|
|
115
|
+
provider: (args) =>
|
|
116
|
+
new FakeCategoryProvider(args.config, args.cache, args.context, args.factory),
|
|
117
|
+
},
|
|
118
|
+
buildProviderArgs,
|
|
119
|
+
);
|
|
49
120
|
}
|
|
50
121
|
|
|
51
|
-
if (
|
|
52
|
-
client.cart =
|
|
122
|
+
if (caps.cart?.enabled) {
|
|
123
|
+
client.cart = resolveCapabilityProvider(
|
|
124
|
+
capabilities.cart,
|
|
125
|
+
{
|
|
126
|
+
factory: new FakeCartFactory(CoreCartSchema, CoreCartIdentifierSchema),
|
|
127
|
+
provider: (args) =>
|
|
128
|
+
new FakeCartProvider(args.config, args.cache, args.context, args.factory),
|
|
129
|
+
},
|
|
130
|
+
buildProviderArgs,
|
|
131
|
+
);
|
|
53
132
|
}
|
|
54
133
|
|
|
55
|
-
if (
|
|
56
|
-
client.inventory =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
134
|
+
if (caps.inventory?.enabled) {
|
|
135
|
+
client.inventory = resolveCapabilityProvider(
|
|
136
|
+
capabilities.inventory,
|
|
137
|
+
{
|
|
138
|
+
factory: new FakeInventoryFactory(CoreInventorySchema),
|
|
139
|
+
provider: (args) =>
|
|
140
|
+
new FakeInventoryProvider(args.config, args.cache, args.context, args.factory),
|
|
141
|
+
},
|
|
142
|
+
buildProviderArgs,
|
|
60
143
|
);
|
|
61
144
|
}
|
|
62
145
|
|
|
63
|
-
if (
|
|
64
|
-
client.store =
|
|
146
|
+
if (caps.store?.enabled) {
|
|
147
|
+
client.store = resolveCapabilityProvider(
|
|
148
|
+
capabilities.store,
|
|
149
|
+
{
|
|
150
|
+
factory: new FakeStoreFactory(CoreStoreSchema),
|
|
151
|
+
provider: (args) =>
|
|
152
|
+
new FakeStoreProvider(args.config, args.cache, args.context, args.factory),
|
|
153
|
+
},
|
|
154
|
+
buildProviderArgs,
|
|
155
|
+
);
|
|
65
156
|
}
|
|
66
157
|
|
|
67
|
-
if (
|
|
68
|
-
client.price =
|
|
158
|
+
if (caps.price?.enabled) {
|
|
159
|
+
client.price = resolveCapabilityProvider(
|
|
160
|
+
capabilities.price,
|
|
161
|
+
{
|
|
162
|
+
factory: new FakePriceFactory(CorePriceSchema),
|
|
163
|
+
provider: (args) =>
|
|
164
|
+
new FakePriceProvider(args.config, args.cache, args.context, args.factory),
|
|
165
|
+
},
|
|
166
|
+
buildProviderArgs,
|
|
167
|
+
);
|
|
69
168
|
}
|
|
70
169
|
|
|
71
|
-
if (
|
|
72
|
-
client.identity =
|
|
170
|
+
if (caps.identity?.enabled) {
|
|
171
|
+
client.identity = resolveCapabilityProvider(
|
|
172
|
+
capabilities.identity,
|
|
173
|
+
{
|
|
174
|
+
factory: new FakeIdentityFactory(CoreIdentitySchema),
|
|
175
|
+
provider: (args) =>
|
|
176
|
+
new FakeIdentityProvider(args.config, args.cache, args.context, args.factory),
|
|
177
|
+
},
|
|
178
|
+
buildProviderArgs,
|
|
179
|
+
);
|
|
73
180
|
}
|
|
74
181
|
|
|
75
|
-
if (
|
|
76
|
-
client.checkout =
|
|
182
|
+
if (caps.checkout?.enabled) {
|
|
183
|
+
client.checkout = resolveCapabilityProvider(
|
|
184
|
+
capabilities.checkout,
|
|
185
|
+
{
|
|
186
|
+
factory: new FakeCheckoutFactory(
|
|
187
|
+
CoreCheckoutSchema,
|
|
188
|
+
CoreShippingMethodSchema,
|
|
189
|
+
CorePaymentMethodSchema,
|
|
190
|
+
),
|
|
191
|
+
provider: (args) =>
|
|
192
|
+
new FakeCheckoutProvider(args.config, args.cache, args.context, args.factory),
|
|
193
|
+
},
|
|
194
|
+
buildProviderArgs,
|
|
195
|
+
);
|
|
77
196
|
}
|
|
78
197
|
|
|
79
|
-
if (
|
|
80
|
-
client.orderSearch =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
198
|
+
if (caps.orderSearch?.enabled) {
|
|
199
|
+
client.orderSearch = resolveCapabilityProvider(
|
|
200
|
+
capabilities.orderSearch,
|
|
201
|
+
{
|
|
202
|
+
factory: new FakeOrderSearchFactory(CoreOrderSearchResultSchema),
|
|
203
|
+
provider: (args) =>
|
|
204
|
+
new FakeOrderSearchProvider(args.config, args.cache, args.context, args.factory),
|
|
205
|
+
},
|
|
206
|
+
buildProviderArgs,
|
|
84
207
|
);
|
|
85
208
|
}
|
|
86
209
|
|
|
87
|
-
if (
|
|
88
|
-
client.order =
|
|
210
|
+
if (caps.order?.enabled) {
|
|
211
|
+
client.order = resolveCapabilityProvider(
|
|
212
|
+
capabilities.order,
|
|
213
|
+
{
|
|
214
|
+
factory: new FakeOrderFactory(CoreOrderSchema),
|
|
215
|
+
provider: (args) =>
|
|
216
|
+
new FakeOrderProvider(args.config, args.cache, args.context, args.factory),
|
|
217
|
+
},
|
|
218
|
+
buildProviderArgs,
|
|
219
|
+
);
|
|
89
220
|
}
|
|
90
221
|
|
|
91
|
-
if (
|
|
92
|
-
client.profile =
|
|
222
|
+
if (caps.profile?.enabled) {
|
|
223
|
+
client.profile = resolveCapabilityProvider(
|
|
224
|
+
capabilities.profile,
|
|
225
|
+
{
|
|
226
|
+
factory: new FakeProfileFactory(CoreProfileSchema),
|
|
227
|
+
provider: (args) =>
|
|
228
|
+
new FakeProfileProvider(args.config, args.cache, args.context, args.factory),
|
|
229
|
+
},
|
|
230
|
+
buildProviderArgs,
|
|
231
|
+
);
|
|
93
232
|
}
|
|
94
233
|
|
|
95
|
-
if (
|
|
96
|
-
client.productReviews =
|
|
234
|
+
if (caps.productReviews?.enabled) {
|
|
235
|
+
client.productReviews = resolveCapabilityProvider(
|
|
236
|
+
capabilities.productReviews,
|
|
237
|
+
{
|
|
238
|
+
factory: new FakeProductReviewsFactory(
|
|
239
|
+
CoreProductRatingSummarySchema,
|
|
240
|
+
CoreProductReviewSchema,
|
|
241
|
+
CoreProductReviewPaginatedResultSchema,
|
|
242
|
+
),
|
|
243
|
+
provider: (args) =>
|
|
244
|
+
new FakeProductReviewsProvider(
|
|
245
|
+
args.config,
|
|
246
|
+
args.cache,
|
|
247
|
+
args.context,
|
|
248
|
+
args.factory,
|
|
249
|
+
),
|
|
250
|
+
},
|
|
251
|
+
buildProviderArgs,
|
|
252
|
+
);
|
|
97
253
|
}
|
|
98
254
|
|
|
99
|
-
if (
|
|
100
|
-
client.productAssociations =
|
|
255
|
+
if (caps.productAssociations?.enabled) {
|
|
256
|
+
client.productAssociations = resolveCapabilityProvider(
|
|
257
|
+
capabilities.productAssociations,
|
|
258
|
+
{
|
|
259
|
+
factory: new FakeProductAssociationsFactory(CoreProductAssociationSchema),
|
|
260
|
+
provider: (args) =>
|
|
261
|
+
new FakeProductAssociationsProvider(
|
|
262
|
+
args.config,
|
|
263
|
+
args.cache,
|
|
264
|
+
args.context,
|
|
265
|
+
args.factory,
|
|
266
|
+
),
|
|
267
|
+
},
|
|
268
|
+
buildProviderArgs,
|
|
269
|
+
);
|
|
101
270
|
}
|
|
102
271
|
|
|
103
272
|
return client;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CartFactory,
|
|
3
|
+
CategoryFactory,
|
|
4
|
+
CheckoutFactory,
|
|
5
|
+
ClientFromCapabilities,
|
|
6
|
+
IdentityFactory,
|
|
7
|
+
InventoryFactory,
|
|
8
|
+
OrderFactory,
|
|
9
|
+
OrderSearchFactory,
|
|
10
|
+
PriceFactory,
|
|
11
|
+
ProductAssociationsFactory,
|
|
12
|
+
ProductFactory,
|
|
13
|
+
ProductReviewsFactory,
|
|
14
|
+
ProductSearchFactory,
|
|
15
|
+
ProfileFactory,
|
|
16
|
+
StoreFactory,
|
|
17
|
+
} from '@reactionary/core';
|
|
18
|
+
import type { FakeCapabilities } from '../schema/capabilities.schema.js';
|
|
19
|
+
import type { FakeCartFactory } from '../factories/cart/cart.factory.js';
|
|
20
|
+
import type { FakeCategoryFactory } from '../factories/category/category.factory.js';
|
|
21
|
+
import type { FakeCheckoutFactory } from '../factories/checkout/checkout.factory.js';
|
|
22
|
+
import type { FakeIdentityFactory } from '../factories/identity/identity.factory.js';
|
|
23
|
+
import type { FakeInventoryFactory } from '../factories/inventory/inventory.factory.js';
|
|
24
|
+
import type { FakeOrderFactory } from '../factories/order/order.factory.js';
|
|
25
|
+
import type { FakeOrderSearchFactory } from '../factories/order-search/order-search.factory.js';
|
|
26
|
+
import type { FakePriceFactory } from '../factories/price/price.factory.js';
|
|
27
|
+
import type { FakeProductAssociationsFactory } from '../factories/product-associations/product-associations.factory.js';
|
|
28
|
+
import type { FakeProductFactory } from '../factories/product/product.factory.js';
|
|
29
|
+
import type { FakeProductReviewsFactory } from '../factories/product-reviews/product-reviews.factory.js';
|
|
30
|
+
import type { FakeProductSearchFactory } from '../factories/product-search/product-search.factory.js';
|
|
31
|
+
import type { FakeProfileFactory } from '../factories/profile/profile.factory.js';
|
|
32
|
+
import type { FakeStoreFactory } from '../factories/store/store.factory.js';
|
|
33
|
+
import type { FakeCartProvider } from '../providers/cart.provider.js';
|
|
34
|
+
import type { FakeCategoryProvider } from '../providers/category.provider.js';
|
|
35
|
+
import type { FakeCheckoutProvider } from '../providers/checkout.provider.js';
|
|
36
|
+
import type { FakeIdentityProvider } from '../providers/identity.provider.js';
|
|
37
|
+
import type { FakeInventoryProvider } from '../providers/inventory.provider.js';
|
|
38
|
+
import type { FakeOrderProvider } from '../providers/order.provider.js';
|
|
39
|
+
import type { FakeOrderSearchProvider } from '../providers/order-search.provider.js';
|
|
40
|
+
import type { FakePriceProvider } from '../providers/price.provider.js';
|
|
41
|
+
import type { FakeProductAssociationsProvider } from '../providers/product-associations.provider.js';
|
|
42
|
+
import type { FakeProductProvider } from '../providers/product.provider.js';
|
|
43
|
+
import type { FakeProductReviewsProvider } from '../providers/product-reviews.provider.js';
|
|
44
|
+
import type { FakeSearchProvider } from '../providers/product-search.provider.js';
|
|
45
|
+
import type { FakeProfileProvider } from '../providers/profile.provider.js';
|
|
46
|
+
import type { FakeStoreProvider } from '../providers/store.provider.js';
|
|
47
|
+
|
|
48
|
+
type FakeCapabilityKey = keyof FakeCapabilities;
|
|
49
|
+
|
|
50
|
+
type EnabledCapability<TCapability> =
|
|
51
|
+
TCapability extends { enabled: true } ? true : false;
|
|
52
|
+
|
|
53
|
+
type NormalizeConfiguredCapabilities<T extends FakeCapabilities> = {
|
|
54
|
+
[K in FakeCapabilityKey]?: EnabledCapability<T[K]>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
type ExtractCapabilityFactory<TCapability, TContract, TDefaultFactory> =
|
|
58
|
+
TCapability extends { enabled: true; factory?: infer TFactory }
|
|
59
|
+
? TFactory extends TContract
|
|
60
|
+
? TFactory
|
|
61
|
+
: TDefaultFactory
|
|
62
|
+
: TDefaultFactory;
|
|
63
|
+
|
|
64
|
+
type ExtractCapabilityProvider<TCapability, TDefaultProvider> =
|
|
65
|
+
TCapability extends { enabled: true; provider?: infer TProviderFactory }
|
|
66
|
+
? TProviderFactory extends (...args: unknown[]) => infer TProvider
|
|
67
|
+
? TProvider
|
|
68
|
+
: TDefaultProvider
|
|
69
|
+
: TDefaultProvider;
|
|
70
|
+
|
|
71
|
+
type FactoryContractMap = {
|
|
72
|
+
product: ProductFactory;
|
|
73
|
+
productSearch: ProductSearchFactory;
|
|
74
|
+
identity: IdentityFactory;
|
|
75
|
+
category: CategoryFactory;
|
|
76
|
+
cart: CartFactory;
|
|
77
|
+
inventory: InventoryFactory;
|
|
78
|
+
store: StoreFactory;
|
|
79
|
+
price: PriceFactory;
|
|
80
|
+
checkout: CheckoutFactory;
|
|
81
|
+
order: OrderFactory;
|
|
82
|
+
orderSearch: OrderSearchFactory;
|
|
83
|
+
profile: ProfileFactory;
|
|
84
|
+
productReviews: ProductReviewsFactory;
|
|
85
|
+
productAssociations: ProductAssociationsFactory;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
type DefaultFactoryMap = {
|
|
89
|
+
product: FakeProductFactory;
|
|
90
|
+
productSearch: FakeProductSearchFactory;
|
|
91
|
+
identity: FakeIdentityFactory;
|
|
92
|
+
category: FakeCategoryFactory;
|
|
93
|
+
cart: FakeCartFactory;
|
|
94
|
+
inventory: FakeInventoryFactory;
|
|
95
|
+
store: FakeStoreFactory;
|
|
96
|
+
price: FakePriceFactory;
|
|
97
|
+
checkout: FakeCheckoutFactory;
|
|
98
|
+
order: FakeOrderFactory;
|
|
99
|
+
orderSearch: FakeOrderSearchFactory;
|
|
100
|
+
profile: FakeProfileFactory;
|
|
101
|
+
productReviews: FakeProductReviewsFactory;
|
|
102
|
+
productAssociations: FakeProductAssociationsFactory;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
type ResolvedFactoryMap<T extends FakeCapabilities> = {
|
|
106
|
+
[K in FakeCapabilityKey]: ExtractCapabilityFactory<
|
|
107
|
+
T[K],
|
|
108
|
+
FactoryContractMap[K],
|
|
109
|
+
DefaultFactoryMap[K]
|
|
110
|
+
>;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
type DefaultProviderMap<T extends FakeCapabilities> = {
|
|
114
|
+
product: FakeProductProvider<ResolvedFactoryMap<T>['product']>;
|
|
115
|
+
productSearch: FakeSearchProvider<ResolvedFactoryMap<T>['productSearch']>;
|
|
116
|
+
identity: FakeIdentityProvider<ResolvedFactoryMap<T>['identity']>;
|
|
117
|
+
category: FakeCategoryProvider<ResolvedFactoryMap<T>['category']>;
|
|
118
|
+
cart: FakeCartProvider<ResolvedFactoryMap<T>['cart']>;
|
|
119
|
+
inventory: FakeInventoryProvider<ResolvedFactoryMap<T>['inventory']>;
|
|
120
|
+
store: FakeStoreProvider<ResolvedFactoryMap<T>['store']>;
|
|
121
|
+
price: FakePriceProvider<ResolvedFactoryMap<T>['price']>;
|
|
122
|
+
checkout: FakeCheckoutProvider<ResolvedFactoryMap<T>['checkout']>;
|
|
123
|
+
order: FakeOrderProvider<ResolvedFactoryMap<T>['order']>;
|
|
124
|
+
orderSearch: FakeOrderSearchProvider<ResolvedFactoryMap<T>['orderSearch']>;
|
|
125
|
+
profile: FakeProfileProvider<ResolvedFactoryMap<T>['profile']>;
|
|
126
|
+
productReviews: FakeProductReviewsProvider<ResolvedFactoryMap<T>['productReviews']>;
|
|
127
|
+
productAssociations: FakeProductAssociationsProvider<
|
|
128
|
+
ResolvedFactoryMap<T>['productAssociations']
|
|
129
|
+
>;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
type CapabilityProviderTypeMap<T extends FakeCapabilities> = {
|
|
133
|
+
[K in FakeCapabilityKey]: ExtractCapabilityProvider<T[K], DefaultProviderMap<T>[K]>;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
type EnabledCapabilityOverrideMap<T extends FakeCapabilities> = {
|
|
137
|
+
[K in FakeCapabilityKey as T[K] extends { enabled: true } ? K : never]:
|
|
138
|
+
CapabilityProviderTypeMap<T>[K];
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export type FakeClientFromCapabilities<T extends FakeCapabilities> = Omit<
|
|
142
|
+
ClientFromCapabilities<NormalizeConfiguredCapabilities<T>>,
|
|
143
|
+
FakeCapabilityKey
|
|
144
|
+
> &
|
|
145
|
+
EnabledCapabilityOverrideMap<T>;
|
|
146
|
+
|
|
147
|
+
export function resolveCapabilityProvider<TFactory, TProvider, TProviderArgs>(
|
|
148
|
+
capability:
|
|
149
|
+
| {
|
|
150
|
+
factory?: TFactory;
|
|
151
|
+
provider?: (args: TProviderArgs) => TProvider;
|
|
152
|
+
}
|
|
153
|
+
| undefined,
|
|
154
|
+
defaults: {
|
|
155
|
+
factory: TFactory;
|
|
156
|
+
provider: (args: TProviderArgs) => TProvider;
|
|
157
|
+
},
|
|
158
|
+
buildProviderArgs: (factory: TFactory) => TProviderArgs,
|
|
159
|
+
): TProvider {
|
|
160
|
+
const factory = capability?.factory ?? defaults.factory;
|
|
161
|
+
const provider = capability?.provider ?? defaults.provider;
|
|
162
|
+
|
|
163
|
+
return provider(buildProviderArgs(factory));
|
|
164
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnyCartIdentifierSchema,
|
|
3
|
+
AnyCartSchema,
|
|
4
|
+
CartFactory,
|
|
5
|
+
CartIdentifierSchema,
|
|
6
|
+
CartSchema,
|
|
7
|
+
RequestContext,
|
|
8
|
+
} from '@reactionary/core';
|
|
9
|
+
import type * as z from 'zod';
|
|
10
|
+
|
|
11
|
+
export class FakeCartFactory<
|
|
12
|
+
TCartSchema extends AnyCartSchema = typeof CartSchema,
|
|
13
|
+
TCartIdentifierSchema extends AnyCartIdentifierSchema = typeof CartIdentifierSchema,
|
|
14
|
+
> implements CartFactory<TCartSchema, TCartIdentifierSchema>
|
|
15
|
+
{
|
|
16
|
+
public readonly cartSchema: TCartSchema;
|
|
17
|
+
public readonly cartIdentifierSchema: TCartIdentifierSchema;
|
|
18
|
+
|
|
19
|
+
constructor(cartSchema: TCartSchema, cartIdentifierSchema: TCartIdentifierSchema) {
|
|
20
|
+
this.cartSchema = cartSchema;
|
|
21
|
+
this.cartIdentifierSchema = cartIdentifierSchema;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public parseCart(_context: RequestContext, data: unknown): z.output<TCartSchema> {
|
|
25
|
+
return this.cartSchema.parse(data);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public parseCartIdentifier(
|
|
29
|
+
_context: RequestContext,
|
|
30
|
+
data: unknown,
|
|
31
|
+
): z.output<TCartIdentifierSchema> {
|
|
32
|
+
return this.cartIdentifierSchema.parse(data);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnyCategoryPaginatedResultSchema,
|
|
3
|
+
AnyCategorySchema,
|
|
4
|
+
CategoryFactory,
|
|
5
|
+
CategoryPaginatedResultSchema,
|
|
6
|
+
CategorySchema,
|
|
7
|
+
RequestContext,
|
|
8
|
+
} from '@reactionary/core';
|
|
9
|
+
import type * as z from 'zod';
|
|
10
|
+
|
|
11
|
+
export class FakeCategoryFactory<
|
|
12
|
+
TCategorySchema extends AnyCategorySchema = typeof CategorySchema,
|
|
13
|
+
TCategoryPaginatedSchema extends AnyCategoryPaginatedResultSchema = typeof CategoryPaginatedResultSchema,
|
|
14
|
+
> implements CategoryFactory<TCategorySchema, TCategoryPaginatedSchema>
|
|
15
|
+
{
|
|
16
|
+
public readonly categorySchema: TCategorySchema;
|
|
17
|
+
public readonly categoryPaginatedResultSchema: TCategoryPaginatedSchema;
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
categorySchema: TCategorySchema,
|
|
21
|
+
categoryPaginatedResultSchema: TCategoryPaginatedSchema,
|
|
22
|
+
) {
|
|
23
|
+
this.categorySchema = categorySchema;
|
|
24
|
+
this.categoryPaginatedResultSchema = categoryPaginatedResultSchema;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public parseCategory(
|
|
28
|
+
_context: RequestContext,
|
|
29
|
+
data: unknown,
|
|
30
|
+
): z.output<TCategorySchema> {
|
|
31
|
+
return this.categorySchema.parse(data);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public parseCategoryPaginatedResult(
|
|
35
|
+
_context: RequestContext,
|
|
36
|
+
data: unknown,
|
|
37
|
+
): z.output<TCategoryPaginatedSchema> {
|
|
38
|
+
return this.categoryPaginatedResultSchema.parse(data);
|
|
39
|
+
}
|
|
40
|
+
}
|