@reactionary/source 0.6.1 → 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 +14 -11
- 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
package/README.md
CHANGED
|
@@ -144,18 +144,8 @@ Vendors: Commercetools
|
|
|
144
144
|
- Add to Shopping List
|
|
145
145
|
|
|
146
146
|
|
|
147
|
-
### Roadmap to V0.7
|
|
148
|
-
Usecase: As a B2B user i want to shop using my own prices
|
|
149
|
-
Vendors: Commercetools, Medusa
|
|
150
|
-
|
|
151
|
-
- PDP / PLP
|
|
152
|
-
- [ ] External Pricing
|
|
153
|
-
- [ ] Customer specific pricing
|
|
154
|
-
- [ ] Organizational/Entitlement Context. Choose to shop private or for company?
|
|
155
|
-
- [ ] Multi currency/Multi lingual
|
|
156
|
-
|
|
157
147
|
|
|
158
|
-
### Roadmap to V0.
|
|
148
|
+
### Roadmap to V0.7
|
|
159
149
|
Usecase: As a B2B user i want to see my organization data
|
|
160
150
|
Vendors: Commercetools, Medusa
|
|
161
151
|
|
|
@@ -167,6 +157,19 @@ Vendors: Commercetools, Medusa
|
|
|
167
157
|
- [ ] Self management of users and roles
|
|
168
158
|
|
|
169
159
|
|
|
160
|
+
### Roadmap to V0.8
|
|
161
|
+
Usecase: As a B2B user i want to shop using my own prices
|
|
162
|
+
Vendors: Commercetools, Medusa
|
|
163
|
+
|
|
164
|
+
- PDP / PLP
|
|
165
|
+
- [ ] External Pricing / Pushed prices
|
|
166
|
+
- [ ] Customer specific pricing
|
|
167
|
+
- [ ] Organizational/Entitlement Context. Choose to shop private or for company?
|
|
168
|
+
- [ ] Multi currency/Multi lingual
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
170
173
|
### Roadmap to V0.9
|
|
171
174
|
Usecase: As a B2B user i want have multiple carts and requisition lists
|
|
172
175
|
Vendors: Commercetools
|
|
@@ -8,14 +8,23 @@ import {
|
|
|
8
8
|
} from '../schemas/session.schema.js';
|
|
9
9
|
import { MulticastProductRecommendationsProvider, type ProductRecommendationsProvider } from '../providers/product-recommendations.provider.js';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
export interface ClientBuilderFactoryArgs {
|
|
12
|
+
cache: Cache;
|
|
13
|
+
context: RequestContext;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type CapabilityFactory<T> =
|
|
17
|
+
| ((cache: Cache, context: RequestContext) => T)
|
|
18
|
+
| ((args: ClientBuilderFactoryArgs) => T);
|
|
12
19
|
|
|
13
20
|
type MergeCapabilities<Acc, New> = Omit<Acc, keyof New> & New;
|
|
21
|
+
export type CapabilityCollisionStrategy = 'last-wins' | 'first-wins' | 'throw';
|
|
14
22
|
|
|
15
23
|
export class ClientBuilder<TClient = Client> {
|
|
16
24
|
private factories: Array<CapabilityFactory<Partial<Client>>> = [];
|
|
17
25
|
private cache: Cache | undefined;
|
|
18
26
|
private context: RequestContext;
|
|
27
|
+
private collisionStrategy: CapabilityCollisionStrategy = 'last-wins';
|
|
19
28
|
|
|
20
29
|
constructor(context: RequestContext) {
|
|
21
30
|
this.context = context;
|
|
@@ -28,6 +37,7 @@ export class ClientBuilder<TClient = Client> {
|
|
|
28
37
|
newBuilder.factories = [...this.factories, factory];
|
|
29
38
|
newBuilder.cache = this.cache;
|
|
30
39
|
newBuilder.context = this.context;
|
|
40
|
+
newBuilder.collisionStrategy = this.collisionStrategy;
|
|
31
41
|
return newBuilder;
|
|
32
42
|
}
|
|
33
43
|
|
|
@@ -36,6 +46,16 @@ export class ClientBuilder<TClient = Client> {
|
|
|
36
46
|
newBuilder.factories = [...this.factories];
|
|
37
47
|
newBuilder.cache = cache;
|
|
38
48
|
newBuilder.context = this.context;
|
|
49
|
+
newBuilder.collisionStrategy = this.collisionStrategy;
|
|
50
|
+
return newBuilder;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
withCollisionStrategy(strategy: CapabilityCollisionStrategy): ClientBuilder<TClient> {
|
|
54
|
+
const newBuilder = new ClientBuilder<TClient>(this.context);
|
|
55
|
+
newBuilder.factories = [...this.factories];
|
|
56
|
+
newBuilder.cache = this.cache;
|
|
57
|
+
newBuilder.context = this.context;
|
|
58
|
+
newBuilder.collisionStrategy = strategy;
|
|
39
59
|
return newBuilder;
|
|
40
60
|
}
|
|
41
61
|
|
|
@@ -56,11 +76,8 @@ export class ClientBuilder<TClient = Client> {
|
|
|
56
76
|
const mergedProductRecommendationsProviders: ProductRecommendationsProvider[] = [];
|
|
57
77
|
|
|
58
78
|
for (const factory of this.factories) {
|
|
59
|
-
const provider = factory
|
|
60
|
-
client =
|
|
61
|
-
...client,
|
|
62
|
-
...provider,
|
|
63
|
-
};
|
|
79
|
+
const provider = this.resolveFactory(factory, sharedCache, this.context);
|
|
80
|
+
client = this.mergeProviders(client, provider as Partial<TClient>);
|
|
64
81
|
|
|
65
82
|
if (provider.analytics) {
|
|
66
83
|
mergedAnalytics.push(provider.analytics);
|
|
@@ -81,4 +98,35 @@ export class ClientBuilder<TClient = Client> {
|
|
|
81
98
|
|
|
82
99
|
return completeClient;
|
|
83
100
|
}
|
|
101
|
+
|
|
102
|
+
private resolveFactory<TNew extends Partial<Client>>(
|
|
103
|
+
factory: CapabilityFactory<TNew>,
|
|
104
|
+
cache: Cache,
|
|
105
|
+
context: RequestContext,
|
|
106
|
+
): TNew {
|
|
107
|
+
if (factory.length <= 1) {
|
|
108
|
+
return (factory as (args: ClientBuilderFactoryArgs) => TNew)({ cache, context });
|
|
109
|
+
}
|
|
110
|
+
return (factory as (cache: Cache, context: RequestContext) => TNew)(cache, context);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private mergeProviders(
|
|
114
|
+
target: TClient,
|
|
115
|
+
source: Partial<TClient>,
|
|
116
|
+
): TClient {
|
|
117
|
+
const result = { ...target } as Record<string, unknown>;
|
|
118
|
+
for (const key of Object.keys(source as object)) {
|
|
119
|
+
const hasExisting = Object.prototype.hasOwnProperty.call(result, key);
|
|
120
|
+
if (hasExisting) {
|
|
121
|
+
if (this.collisionStrategy === 'first-wins') {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (this.collisionStrategy === 'throw') {
|
|
125
|
+
throw new Error(`Capability collision detected for "${key}"`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
result[key] = (source as Record<string, unknown>)[key];
|
|
129
|
+
}
|
|
130
|
+
return result as TClient;
|
|
131
|
+
}
|
|
84
132
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { CartSchema } from '../schemas/models/cart.model.js';
|
|
3
|
+
import type { CartIdentifierSchema } from '../schemas/models/identifiers.model.js';
|
|
4
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
5
|
+
|
|
6
|
+
export type AnyCartSchema = z.ZodType<z.output<typeof CartSchema>>;
|
|
7
|
+
export type AnyCartIdentifierSchema = z.ZodType<
|
|
8
|
+
z.output<typeof CartIdentifierSchema>
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
export interface CartFactory<
|
|
12
|
+
TCartSchema extends AnyCartSchema = AnyCartSchema,
|
|
13
|
+
TCartIdentifierSchema extends AnyCartIdentifierSchema = AnyCartIdentifierSchema,
|
|
14
|
+
> {
|
|
15
|
+
cartSchema: TCartSchema;
|
|
16
|
+
cartIdentifierSchema: TCartIdentifierSchema;
|
|
17
|
+
parseCart(context: RequestContext, data: unknown): z.output<TCartSchema>;
|
|
18
|
+
parseCartIdentifier(
|
|
19
|
+
context: RequestContext,
|
|
20
|
+
data: unknown,
|
|
21
|
+
): z.output<TCartIdentifierSchema>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type CartFactoryCartOutput<TFactory extends CartFactory> = ReturnType<
|
|
25
|
+
TFactory['parseCart']
|
|
26
|
+
>;
|
|
27
|
+
export type CartFactoryIdentifierOutput<TFactory extends CartFactory> = ReturnType<
|
|
28
|
+
TFactory['parseCartIdentifier']
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
export type CartFactoryWithOutput<TFactory extends CartFactory> = Omit<
|
|
32
|
+
TFactory,
|
|
33
|
+
'parseCart' | 'parseCartIdentifier'
|
|
34
|
+
> & {
|
|
35
|
+
parseCart(context: RequestContext, data: unknown): CartFactoryCartOutput<TFactory>;
|
|
36
|
+
parseCartIdentifier(
|
|
37
|
+
context: RequestContext,
|
|
38
|
+
data: unknown,
|
|
39
|
+
): CartFactoryIdentifierOutput<TFactory>;
|
|
40
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { CategoryPaginatedResultSchema, CategorySchema } from '../schemas/models/category.model.js';
|
|
3
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
4
|
+
|
|
5
|
+
export type AnyCategorySchema = z.ZodType<z.output<typeof CategorySchema>>;
|
|
6
|
+
export type AnyCategoryPaginatedResultSchema = z.ZodType<
|
|
7
|
+
z.output<typeof CategoryPaginatedResultSchema>
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export interface CategoryFactory<
|
|
11
|
+
TCategorySchema extends AnyCategorySchema = AnyCategorySchema,
|
|
12
|
+
TCategoryPaginatedSchema extends AnyCategoryPaginatedResultSchema = AnyCategoryPaginatedResultSchema,
|
|
13
|
+
> {
|
|
14
|
+
categorySchema: TCategorySchema;
|
|
15
|
+
categoryPaginatedResultSchema: TCategoryPaginatedSchema;
|
|
16
|
+
parseCategory(context: RequestContext, data: unknown): z.output<TCategorySchema>;
|
|
17
|
+
parseCategoryPaginatedResult(
|
|
18
|
+
context: RequestContext,
|
|
19
|
+
data: unknown,
|
|
20
|
+
): z.output<TCategoryPaginatedSchema>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type CategoryFactoryCategoryOutput<TFactory extends CategoryFactory> =
|
|
24
|
+
ReturnType<TFactory['parseCategory']>;
|
|
25
|
+
export type CategoryFactoryPaginatedOutput<TFactory extends CategoryFactory> =
|
|
26
|
+
ReturnType<TFactory['parseCategoryPaginatedResult']>;
|
|
27
|
+
|
|
28
|
+
export type CategoryFactoryWithOutput<TFactory extends CategoryFactory> = Omit<
|
|
29
|
+
TFactory,
|
|
30
|
+
'parseCategory' | 'parseCategoryPaginatedResult'
|
|
31
|
+
> & {
|
|
32
|
+
parseCategory(
|
|
33
|
+
context: RequestContext,
|
|
34
|
+
data: unknown,
|
|
35
|
+
): CategoryFactoryCategoryOutput<TFactory>;
|
|
36
|
+
parseCategoryPaginatedResult(
|
|
37
|
+
context: RequestContext,
|
|
38
|
+
data: unknown,
|
|
39
|
+
): CategoryFactoryPaginatedOutput<TFactory>;
|
|
40
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { CheckoutSchema } from '../schemas/models/checkout.model.js';
|
|
3
|
+
import type { PaymentMethodSchema } from '../schemas/models/payment.model.js';
|
|
4
|
+
import type { ShippingMethodSchema } from '../schemas/models/shipping-method.model.js';
|
|
5
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
6
|
+
|
|
7
|
+
export type AnyCheckoutSchema = z.ZodType<z.output<typeof CheckoutSchema>>;
|
|
8
|
+
export type AnyShippingMethodSchema = z.ZodType<
|
|
9
|
+
z.output<typeof ShippingMethodSchema>
|
|
10
|
+
>;
|
|
11
|
+
export type AnyPaymentMethodSchema = z.ZodType<
|
|
12
|
+
z.output<typeof PaymentMethodSchema>
|
|
13
|
+
>;
|
|
14
|
+
|
|
15
|
+
export interface CheckoutFactory<
|
|
16
|
+
TCheckoutSchema extends AnyCheckoutSchema = AnyCheckoutSchema,
|
|
17
|
+
TShippingMethodSchema extends AnyShippingMethodSchema = AnyShippingMethodSchema,
|
|
18
|
+
TPaymentMethodSchema extends AnyPaymentMethodSchema = AnyPaymentMethodSchema,
|
|
19
|
+
> {
|
|
20
|
+
checkoutSchema: TCheckoutSchema;
|
|
21
|
+
shippingMethodSchema: TShippingMethodSchema;
|
|
22
|
+
paymentMethodSchema: TPaymentMethodSchema;
|
|
23
|
+
parseCheckout(context: RequestContext, data: unknown): z.output<TCheckoutSchema>;
|
|
24
|
+
parseShippingMethod(
|
|
25
|
+
context: RequestContext,
|
|
26
|
+
data: unknown,
|
|
27
|
+
): z.output<TShippingMethodSchema>;
|
|
28
|
+
parsePaymentMethod(
|
|
29
|
+
context: RequestContext,
|
|
30
|
+
data: unknown,
|
|
31
|
+
): z.output<TPaymentMethodSchema>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type CheckoutFactoryCheckoutOutput<TFactory extends CheckoutFactory> =
|
|
35
|
+
ReturnType<TFactory['parseCheckout']>;
|
|
36
|
+
export type CheckoutFactoryShippingMethodOutput<
|
|
37
|
+
TFactory extends CheckoutFactory,
|
|
38
|
+
> = ReturnType<TFactory['parseShippingMethod']>;
|
|
39
|
+
export type CheckoutFactoryPaymentMethodOutput<
|
|
40
|
+
TFactory extends CheckoutFactory,
|
|
41
|
+
> = ReturnType<TFactory['parsePaymentMethod']>;
|
|
42
|
+
|
|
43
|
+
export type CheckoutFactoryWithOutput<TFactory extends CheckoutFactory> = Omit<
|
|
44
|
+
TFactory,
|
|
45
|
+
'parseCheckout' | 'parseShippingMethod' | 'parsePaymentMethod'
|
|
46
|
+
> & {
|
|
47
|
+
parseCheckout(
|
|
48
|
+
context: RequestContext,
|
|
49
|
+
data: unknown,
|
|
50
|
+
): CheckoutFactoryCheckoutOutput<TFactory>;
|
|
51
|
+
parseShippingMethod(
|
|
52
|
+
context: RequestContext,
|
|
53
|
+
data: unknown,
|
|
54
|
+
): CheckoutFactoryShippingMethodOutput<TFactory>;
|
|
55
|
+
parsePaymentMethod(
|
|
56
|
+
context: RequestContext,
|
|
57
|
+
data: unknown,
|
|
58
|
+
): CheckoutFactoryPaymentMethodOutput<TFactory>;
|
|
59
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { IdentitySchema } from '../schemas/models/identity.model.js';
|
|
3
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
4
|
+
|
|
5
|
+
export type AnyIdentitySchema = z.ZodType<z.output<typeof IdentitySchema>>;
|
|
6
|
+
|
|
7
|
+
export interface IdentityFactory<
|
|
8
|
+
TIdentitySchema extends AnyIdentitySchema = AnyIdentitySchema,
|
|
9
|
+
> {
|
|
10
|
+
identitySchema: TIdentitySchema;
|
|
11
|
+
parseIdentity(context: RequestContext, data: unknown): z.output<TIdentitySchema>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type IdentityFactoryOutput<TFactory extends IdentityFactory> = ReturnType<
|
|
15
|
+
TFactory['parseIdentity']
|
|
16
|
+
>;
|
|
17
|
+
|
|
18
|
+
export type IdentityFactoryWithOutput<TFactory extends IdentityFactory> = Omit<
|
|
19
|
+
TFactory,
|
|
20
|
+
'parseIdentity'
|
|
21
|
+
> & {
|
|
22
|
+
parseIdentity(
|
|
23
|
+
context: RequestContext,
|
|
24
|
+
data: unknown,
|
|
25
|
+
): IdentityFactoryOutput<TFactory>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './cart.factory.js';
|
|
2
|
+
export * from './category.factory.js';
|
|
3
|
+
export * from './checkout.factory.js';
|
|
4
|
+
export * from './identity.factory.js';
|
|
5
|
+
export * from './inventory.factory.js';
|
|
6
|
+
export * from './order.factory.js';
|
|
7
|
+
export * from './order-search.factory.js';
|
|
8
|
+
export * from './price.factory.js';
|
|
9
|
+
export * from './product.factory.js';
|
|
10
|
+
export * from './product-associations.factory.js';
|
|
11
|
+
export * from './product-list.factory.js';
|
|
12
|
+
export * from './product-reviews.factory.js';
|
|
13
|
+
export * from './product-search.factory.js';
|
|
14
|
+
export * from './profile.factory.js';
|
|
15
|
+
export * from './store.factory.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { InventorySchema } from '../schemas/models/inventory.model.js';
|
|
3
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
4
|
+
|
|
5
|
+
export type AnyInventorySchema = z.ZodType<z.output<typeof InventorySchema>>;
|
|
6
|
+
|
|
7
|
+
export interface InventoryFactory<
|
|
8
|
+
TInventorySchema extends AnyInventorySchema = AnyInventorySchema,
|
|
9
|
+
> {
|
|
10
|
+
inventorySchema: TInventorySchema;
|
|
11
|
+
parseInventory(context: RequestContext, data: unknown): z.output<TInventorySchema>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type InventoryFactoryOutput<TFactory extends InventoryFactory> = ReturnType<
|
|
15
|
+
TFactory['parseInventory']
|
|
16
|
+
>;
|
|
17
|
+
|
|
18
|
+
export type InventoryFactoryWithOutput<TFactory extends InventoryFactory> = Omit<
|
|
19
|
+
TFactory,
|
|
20
|
+
'parseInventory'
|
|
21
|
+
> & {
|
|
22
|
+
parseInventory(
|
|
23
|
+
context: RequestContext,
|
|
24
|
+
data: unknown,
|
|
25
|
+
): InventoryFactoryOutput<TFactory>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { OrderSearchResultSchema } from '../schemas/models/order-search.model.js';
|
|
3
|
+
import type { OrderSearchQueryByTerm } from '../schemas/queries/order-search.query.js';
|
|
4
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
5
|
+
|
|
6
|
+
export type AnyOrderSearchResultSchema = z.ZodType<
|
|
7
|
+
z.output<typeof OrderSearchResultSchema>
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export interface OrderSearchFactory<
|
|
11
|
+
TOrderSearchResultSchema extends AnyOrderSearchResultSchema = AnyOrderSearchResultSchema,
|
|
12
|
+
> {
|
|
13
|
+
orderSearchResultSchema: TOrderSearchResultSchema;
|
|
14
|
+
parseOrderSearchResult(
|
|
15
|
+
context: RequestContext,
|
|
16
|
+
data: unknown,
|
|
17
|
+
query: OrderSearchQueryByTerm,
|
|
18
|
+
): z.output<TOrderSearchResultSchema>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type OrderSearchFactoryOutput<TFactory extends OrderSearchFactory> =
|
|
22
|
+
ReturnType<TFactory['parseOrderSearchResult']>;
|
|
23
|
+
|
|
24
|
+
export type OrderSearchFactoryWithOutput<TFactory extends OrderSearchFactory> = Omit<
|
|
25
|
+
TFactory,
|
|
26
|
+
'parseOrderSearchResult'
|
|
27
|
+
> & {
|
|
28
|
+
parseOrderSearchResult(
|
|
29
|
+
context: RequestContext,
|
|
30
|
+
data: unknown,
|
|
31
|
+
query: OrderSearchQueryByTerm,
|
|
32
|
+
): OrderSearchFactoryOutput<TFactory>;
|
|
33
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { OrderSchema } from '../schemas/models/order.model.js';
|
|
3
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
4
|
+
|
|
5
|
+
export type AnyOrderSchema = z.ZodType<z.output<typeof OrderSchema>>;
|
|
6
|
+
|
|
7
|
+
export interface OrderFactory<TOrderSchema extends AnyOrderSchema = AnyOrderSchema> {
|
|
8
|
+
orderSchema: TOrderSchema;
|
|
9
|
+
parseOrder(context: RequestContext, data: unknown): z.output<TOrderSchema>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type OrderFactoryOutput<TFactory extends OrderFactory> = ReturnType<
|
|
13
|
+
TFactory['parseOrder']
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
export type OrderFactoryWithOutput<TFactory extends OrderFactory> = Omit<
|
|
17
|
+
TFactory,
|
|
18
|
+
'parseOrder'
|
|
19
|
+
> & {
|
|
20
|
+
parseOrder(context: RequestContext, data: unknown): OrderFactoryOutput<TFactory>;
|
|
21
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { PriceSchema } from '../schemas/models/price.model.js';
|
|
3
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
4
|
+
|
|
5
|
+
export type AnyPriceSchema = z.ZodType<z.output<typeof PriceSchema>>;
|
|
6
|
+
|
|
7
|
+
export interface PriceFactory<TPriceSchema extends AnyPriceSchema = AnyPriceSchema> {
|
|
8
|
+
priceSchema: TPriceSchema;
|
|
9
|
+
parsePrice(
|
|
10
|
+
context: RequestContext,
|
|
11
|
+
data: unknown,
|
|
12
|
+
options?: { includeDiscounts: boolean },
|
|
13
|
+
): z.output<TPriceSchema>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type PriceFactoryOutput<TFactory extends PriceFactory> = ReturnType<
|
|
17
|
+
TFactory['parsePrice']
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
export type PriceFactoryWithOutput<TFactory extends PriceFactory> = Omit<
|
|
21
|
+
TFactory,
|
|
22
|
+
'parsePrice'
|
|
23
|
+
> & {
|
|
24
|
+
parsePrice(
|
|
25
|
+
context: RequestContext,
|
|
26
|
+
data: unknown,
|
|
27
|
+
options?: { includeDiscounts: boolean },
|
|
28
|
+
): PriceFactoryOutput<TFactory>;
|
|
29
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { ProductAssociationSchema } from '../schemas/models/product-associations.model.js';
|
|
3
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
4
|
+
|
|
5
|
+
export type AnyProductAssociationSchema = z.ZodType<
|
|
6
|
+
z.output<typeof ProductAssociationSchema>
|
|
7
|
+
>;
|
|
8
|
+
|
|
9
|
+
export interface ProductAssociationsFactory<
|
|
10
|
+
TProductAssociationSchema extends AnyProductAssociationSchema = AnyProductAssociationSchema,
|
|
11
|
+
> {
|
|
12
|
+
productAssociationSchema: TProductAssociationSchema;
|
|
13
|
+
parseAssociation(
|
|
14
|
+
context: RequestContext,
|
|
15
|
+
data: unknown,
|
|
16
|
+
): z.output<TProductAssociationSchema>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type ProductAssociationsFactoryOutput<
|
|
20
|
+
TFactory extends ProductAssociationsFactory,
|
|
21
|
+
> = ReturnType<TFactory['parseAssociation']>;
|
|
22
|
+
|
|
23
|
+
export type ProductAssociationsFactoryWithOutput<
|
|
24
|
+
TFactory extends ProductAssociationsFactory,
|
|
25
|
+
> = Omit<TFactory, 'parseAssociation'> & {
|
|
26
|
+
parseAssociation(
|
|
27
|
+
context: RequestContext,
|
|
28
|
+
data: unknown,
|
|
29
|
+
): ProductAssociationsFactoryOutput<TFactory>;
|
|
30
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type {
|
|
3
|
+
ProductListItemPaginatedResultsSchema,
|
|
4
|
+
ProductListItemSchema,
|
|
5
|
+
ProductListPaginatedResultsSchema,
|
|
6
|
+
ProductListSchema,
|
|
7
|
+
} from '../schemas/models/product-list.model.js';
|
|
8
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
9
|
+
|
|
10
|
+
export type AnyProductListSchema = z.ZodType<z.output<typeof ProductListSchema>>;
|
|
11
|
+
export type AnyProductListItemSchema = z.ZodType<
|
|
12
|
+
z.output<typeof ProductListItemSchema>
|
|
13
|
+
>;
|
|
14
|
+
export type AnyProductListPaginatedSchema = z.ZodType<
|
|
15
|
+
z.output<typeof ProductListPaginatedResultsSchema>
|
|
16
|
+
>;
|
|
17
|
+
export type AnyProductListItemPaginatedSchema = z.ZodType<
|
|
18
|
+
z.output<typeof ProductListItemPaginatedResultsSchema>
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
export interface ProductListFactory<
|
|
22
|
+
TProductListSchema extends AnyProductListSchema = AnyProductListSchema,
|
|
23
|
+
TProductListItemSchema extends AnyProductListItemSchema = AnyProductListItemSchema,
|
|
24
|
+
TProductListPaginatedSchema extends AnyProductListPaginatedSchema = AnyProductListPaginatedSchema,
|
|
25
|
+
TProductListItemPaginatedSchema extends AnyProductListItemPaginatedSchema = AnyProductListItemPaginatedSchema,
|
|
26
|
+
> {
|
|
27
|
+
productListSchema: TProductListSchema;
|
|
28
|
+
productListItemSchema: TProductListItemSchema;
|
|
29
|
+
productListPaginatedSchema: TProductListPaginatedSchema;
|
|
30
|
+
productListItemPaginatedSchema: TProductListItemPaginatedSchema;
|
|
31
|
+
parseProductList(
|
|
32
|
+
context: RequestContext,
|
|
33
|
+
data: unknown,
|
|
34
|
+
): z.output<TProductListSchema>;
|
|
35
|
+
parseProductListItem(
|
|
36
|
+
context: RequestContext,
|
|
37
|
+
data: unknown,
|
|
38
|
+
): z.output<TProductListItemSchema>;
|
|
39
|
+
parseProductListPaginatedResult(
|
|
40
|
+
context: RequestContext,
|
|
41
|
+
data: unknown,
|
|
42
|
+
): z.output<TProductListPaginatedSchema>;
|
|
43
|
+
parseProductListItemPaginatedResult(
|
|
44
|
+
context: RequestContext,
|
|
45
|
+
data: unknown,
|
|
46
|
+
): z.output<TProductListItemPaginatedSchema>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type ProductListFactoryListOutput<TFactory extends ProductListFactory> =
|
|
50
|
+
ReturnType<TFactory['parseProductList']>;
|
|
51
|
+
export type ProductListFactoryItemOutput<TFactory extends ProductListFactory> =
|
|
52
|
+
ReturnType<TFactory['parseProductListItem']>;
|
|
53
|
+
export type ProductListFactoryListPaginatedOutput<TFactory extends ProductListFactory> =
|
|
54
|
+
ReturnType<TFactory['parseProductListPaginatedResult']>;
|
|
55
|
+
export type ProductListFactoryItemPaginatedOutput<TFactory extends ProductListFactory> =
|
|
56
|
+
ReturnType<TFactory['parseProductListItemPaginatedResult']>;
|
|
57
|
+
|
|
58
|
+
export type ProductListFactoryWithOutput<TFactory extends ProductListFactory> =
|
|
59
|
+
Omit<
|
|
60
|
+
TFactory,
|
|
61
|
+
| 'parseProductList'
|
|
62
|
+
| 'parseProductListItem'
|
|
63
|
+
| 'parseProductListPaginatedResult'
|
|
64
|
+
| 'parseProductListItemPaginatedResult'
|
|
65
|
+
> & {
|
|
66
|
+
parseProductList(
|
|
67
|
+
context: RequestContext,
|
|
68
|
+
data: unknown,
|
|
69
|
+
): ProductListFactoryListOutput<TFactory>;
|
|
70
|
+
parseProductListItem(
|
|
71
|
+
context: RequestContext,
|
|
72
|
+
data: unknown,
|
|
73
|
+
): ProductListFactoryItemOutput<TFactory>;
|
|
74
|
+
parseProductListPaginatedResult(
|
|
75
|
+
context: RequestContext,
|
|
76
|
+
data: unknown,
|
|
77
|
+
): ProductListFactoryListPaginatedOutput<TFactory>;
|
|
78
|
+
parseProductListItemPaginatedResult(
|
|
79
|
+
context: RequestContext,
|
|
80
|
+
data: unknown,
|
|
81
|
+
): ProductListFactoryItemPaginatedOutput<TFactory>;
|
|
82
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type {
|
|
3
|
+
ProductRatingSummarySchema,
|
|
4
|
+
ProductReviewPaginatedResultSchema,
|
|
5
|
+
ProductReviewSchema,
|
|
6
|
+
} from '../schemas/models/product-reviews.model.js';
|
|
7
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
8
|
+
|
|
9
|
+
export type AnyProductRatingSummarySchema = z.ZodType<
|
|
10
|
+
z.output<typeof ProductRatingSummarySchema>
|
|
11
|
+
>;
|
|
12
|
+
export type AnyProductReviewSchema = z.ZodType<z.output<typeof ProductReviewSchema>>;
|
|
13
|
+
export type AnyProductReviewPaginatedSchema = z.ZodType<
|
|
14
|
+
z.output<typeof ProductReviewPaginatedResultSchema>
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
export interface ProductReviewsFactory<
|
|
18
|
+
TRatingSummarySchema extends AnyProductRatingSummarySchema = AnyProductRatingSummarySchema,
|
|
19
|
+
TReviewSchema extends AnyProductReviewSchema = AnyProductReviewSchema,
|
|
20
|
+
TReviewPaginatedSchema extends AnyProductReviewPaginatedSchema = AnyProductReviewPaginatedSchema,
|
|
21
|
+
> {
|
|
22
|
+
ratingSummarySchema: TRatingSummarySchema;
|
|
23
|
+
reviewSchema: TReviewSchema;
|
|
24
|
+
reviewPaginatedSchema: TReviewPaginatedSchema;
|
|
25
|
+
parseRatingSummary(
|
|
26
|
+
context: RequestContext,
|
|
27
|
+
data: unknown,
|
|
28
|
+
): z.output<TRatingSummarySchema>;
|
|
29
|
+
parseReview(context: RequestContext, data: unknown): z.output<TReviewSchema>;
|
|
30
|
+
parseReviewPaginatedResult(
|
|
31
|
+
context: RequestContext,
|
|
32
|
+
data: unknown,
|
|
33
|
+
): z.output<TReviewPaginatedSchema>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type ProductReviewsFactoryRatingOutput<TFactory extends ProductReviewsFactory> =
|
|
37
|
+
ReturnType<TFactory['parseRatingSummary']>;
|
|
38
|
+
export type ProductReviewsFactoryReviewOutput<TFactory extends ProductReviewsFactory> =
|
|
39
|
+
ReturnType<TFactory['parseReview']>;
|
|
40
|
+
export type ProductReviewsFactoryReviewPaginatedOutput<
|
|
41
|
+
TFactory extends ProductReviewsFactory,
|
|
42
|
+
> = ReturnType<TFactory['parseReviewPaginatedResult']>;
|
|
43
|
+
|
|
44
|
+
export type ProductReviewsFactoryWithOutput<TFactory extends ProductReviewsFactory> =
|
|
45
|
+
Omit<TFactory, 'parseRatingSummary' | 'parseReview' | 'parseReviewPaginatedResult'> & {
|
|
46
|
+
parseRatingSummary(
|
|
47
|
+
context: RequestContext,
|
|
48
|
+
data: unknown,
|
|
49
|
+
): ProductReviewsFactoryRatingOutput<TFactory>;
|
|
50
|
+
parseReview(
|
|
51
|
+
context: RequestContext,
|
|
52
|
+
data: unknown,
|
|
53
|
+
): ProductReviewsFactoryReviewOutput<TFactory>;
|
|
54
|
+
parseReviewPaginatedResult(
|
|
55
|
+
context: RequestContext,
|
|
56
|
+
data: unknown,
|
|
57
|
+
): ProductReviewsFactoryReviewPaginatedOutput<TFactory>;
|
|
58
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { ProductSearchResultSchema } from '../schemas/models/product-search.model.js';
|
|
3
|
+
import type { ProductSearchQueryByTerm } from '../schemas/queries/product-search.query.js';
|
|
4
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
5
|
+
|
|
6
|
+
export type AnyProductSearchResultSchema = z.ZodType<
|
|
7
|
+
z.output<typeof ProductSearchResultSchema>
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export interface ProductSearchFactory<
|
|
11
|
+
TProductSearchResultSchema extends AnyProductSearchResultSchema = AnyProductSearchResultSchema,
|
|
12
|
+
> {
|
|
13
|
+
productSearchResultSchema: TProductSearchResultSchema;
|
|
14
|
+
parseSearchResult(
|
|
15
|
+
context: RequestContext,
|
|
16
|
+
data: unknown,
|
|
17
|
+
query: ProductSearchQueryByTerm,
|
|
18
|
+
): z.output<TProductSearchResultSchema>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type ProductSearchFactoryOutput<TFactory extends ProductSearchFactory> =
|
|
22
|
+
ReturnType<TFactory['parseSearchResult']>;
|
|
23
|
+
|
|
24
|
+
export type ProductSearchFactoryWithOutput<TFactory extends ProductSearchFactory> =
|
|
25
|
+
Omit<TFactory, 'parseSearchResult'> & {
|
|
26
|
+
parseSearchResult(
|
|
27
|
+
context: RequestContext,
|
|
28
|
+
data: unknown,
|
|
29
|
+
query: ProductSearchQueryByTerm,
|
|
30
|
+
): ProductSearchFactoryOutput<TFactory>;
|
|
31
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type * as z from 'zod';
|
|
2
|
+
import type { ProductSchema } from '../schemas/models/product.model.js';
|
|
3
|
+
import type { RequestContext } from '../schemas/session.schema.js';
|
|
4
|
+
|
|
5
|
+
export type AnyProductSchema = z.ZodType<z.output<typeof ProductSchema>>;
|
|
6
|
+
|
|
7
|
+
export interface ProductFactory<TProductSchema extends AnyProductSchema = AnyProductSchema> {
|
|
8
|
+
productSchema: TProductSchema;
|
|
9
|
+
parseProduct(context: RequestContext, data: unknown): z.output<TProductSchema>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type ProductFactoryOutput<TFactory extends ProductFactory> = ReturnType<
|
|
13
|
+
TFactory['parseProduct']
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
export type ProductFactoryWithOutput<TFactory extends ProductFactory> = Omit<
|
|
17
|
+
TFactory,
|
|
18
|
+
'parseProduct'
|
|
19
|
+
> & {
|
|
20
|
+
parseProduct(context: RequestContext, data: unknown): ProductFactoryOutput<TFactory>;
|
|
21
|
+
};
|