@unchainedshop/core 5.0.0-alpha.5 → 5.0.0-alpha.8
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 +92 -546
- package/lib/bulk-importer/handlers/product/create.d.ts +132 -29
- package/lib/bulk-importer/handlers/product/create.js +31 -14
- package/lib/bulk-importer/handlers/product/update.d.ts +60 -30
- package/lib/bulk-importer/handlers/product/update.js +5 -48
- package/lib/core-index.d.ts +1 -2
- package/lib/core-index.js +2 -18
- package/lib/directors/BaseDiscountAdapter.d.ts +3 -0
- package/lib/directors/BaseDiscountDirector.d.ts +2 -2
- package/lib/directors/BaseDiscountDirector.js +7 -9
- package/lib/directors/BasePricingDirector.d.ts +2 -2
- package/lib/directors/BasePricingDirector.js +3 -6
- package/lib/directors/DeliveryDirector.d.ts +1 -1
- package/lib/directors/DeliveryDirector.js +2 -12
- package/lib/directors/DeliveryPricingDirector.js +1 -10
- package/lib/directors/EnrollmentAdapter.js +0 -1
- package/lib/directors/EnrollmentDirector.d.ts +1 -1
- package/lib/directors/EnrollmentDirector.js +3 -15
- package/lib/directors/FileDirector.d.ts +4 -4
- package/lib/directors/FileDirector.js +2 -13
- package/lib/directors/FilterDirector.d.ts +1 -1
- package/lib/directors/FilterDirector.js +2 -14
- package/lib/directors/OrderDiscountDirector.d.ts +1 -15
- package/lib/directors/OrderDiscountDirector.js +1 -13
- package/lib/directors/OrderPricingDirector.js +1 -10
- package/lib/directors/OrderPricingSheet.d.ts +1 -0
- package/lib/directors/OrderPricingSheet.js +17 -17
- package/lib/directors/PaymentDirector.d.ts +1 -1
- package/lib/directors/PaymentDirector.js +2 -12
- package/lib/directors/PaymentPricingDirector.js +1 -10
- package/lib/directors/ProductDiscountDirector.d.ts +1 -15
- package/lib/directors/ProductDiscountDirector.js +1 -13
- package/lib/directors/ProductPricingDirector.js +1 -10
- package/lib/directors/QuotationDirector.d.ts +1 -1
- package/lib/directors/QuotationDirector.js +2 -14
- package/lib/directors/WarehousingDirector.js +16 -34
- package/lib/directors/WorkerDirector.d.ts +1 -1
- package/lib/directors/WorkerDirector.js +2 -14
- package/lib/directors/registryDirector.d.ts +2 -0
- package/lib/directors/registryDirector.js +6 -0
- package/lib/factory/registerVirtualWarehousing.js +1 -1
- package/lib/plugins/PluginRegistry.d.ts +1 -0
- package/lib/plugins/PluginRegistry.js +8 -1
- package/lib/services/checkoutOrder.js +4 -0
- package/lib/services/index.d.ts +2 -1
- package/lib/services/index.js +2 -1
- package/lib/services/reserveOrderDiscountsForCheckout.d.ts +5 -0
- package/lib/services/reserveOrderDiscountsForCheckout.js +34 -0
- package/lib/services/simulateProductDispatching.d.ts +3 -1
- package/lib/services/simulateProductDispatching.js +3 -3
- package/lib/services/simulateProductInventory.d.ts +3 -1
- package/lib/services/simulateProductInventory.js +3 -3
- package/lib/services/supportedDeliveryProviders.js +9 -0
- package/lib/services/supportedPaymentProviders.js +9 -0
- package/lib/services/supportedWarehousingProviders.js +9 -0
- package/package.json +22 -22
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import { z } from 'zod/v4-mini';
|
|
2
2
|
import type { Modules } from '../../../modules.ts';
|
|
3
3
|
import type { Services } from '../../../services/index.ts';
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
export declare const DateLikeSchema: z.ZodMiniUnion<readonly [z.ZodMiniDate<Date>, z.ZodMiniString<string>]>;
|
|
5
|
+
export declare const ProductTokenizationSchema: z.ZodMiniObject<{
|
|
6
|
+
contractAddress: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
7
|
+
contractStandard: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
8
|
+
readonly ERC721: "ERC721";
|
|
9
|
+
readonly ERC1155: "ERC1155";
|
|
10
|
+
}>>;
|
|
11
|
+
tokenId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
12
|
+
supply: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
13
|
+
ercMetadataProperties: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const ProductContentSchema: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
16
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
17
|
+
subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
18
|
+
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
19
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
20
|
+
brand: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
21
|
+
vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
22
|
+
labels: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
export declare const ProductSpecificationFields: {
|
|
12
25
|
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
13
26
|
status: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
|
|
14
27
|
readonly DRAFT: "DRAFT";
|
|
15
28
|
readonly ACTIVE: "ACTIVE";
|
|
16
29
|
readonly DELETED: "DELETED";
|
|
17
30
|
}>>>;
|
|
18
|
-
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
|
|
31
|
+
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniUnion<readonly [z.ZodMiniDate<Date>, z.ZodMiniString<string>]>>>;
|
|
19
32
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
20
33
|
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
21
34
|
pricing: z.ZodMiniArray<z.ZodMiniObject<{
|
|
@@ -37,6 +50,16 @@ export declare const ProductCreateSpecificationSchema: z.ZodMiniObject<{
|
|
|
37
50
|
lengthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
38
51
|
widthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
39
52
|
}, z.core.$strip>>;
|
|
53
|
+
tokenization: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
54
|
+
contractAddress: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
55
|
+
contractStandard: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
56
|
+
readonly ERC721: "ERC721";
|
|
57
|
+
readonly ERC1155: "ERC1155";
|
|
58
|
+
}>>;
|
|
59
|
+
tokenId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
60
|
+
supply: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
61
|
+
ercMetadataProperties: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
40
63
|
bundleItems: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
41
64
|
productId: z.ZodMiniString<string>;
|
|
42
65
|
quantity: z.ZodMiniNumber<number>;
|
|
@@ -46,6 +69,19 @@ export declare const ProductCreateSpecificationSchema: z.ZodMiniObject<{
|
|
|
46
69
|
}, z.core.$strip>>;
|
|
47
70
|
}, z.core.$strip>>>;
|
|
48
71
|
meta: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniAny, z.ZodMiniAny>>;
|
|
72
|
+
variationResolvers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
73
|
+
vector: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>;
|
|
74
|
+
productId: z.ZodMiniString<string>;
|
|
75
|
+
}, z.core.$strip>>>;
|
|
76
|
+
};
|
|
77
|
+
export declare const ProductCreateSpecificationSchema: z.ZodMiniObject<{
|
|
78
|
+
type: z.ZodMiniEnum<{
|
|
79
|
+
readonly SIMPLE_PRODUCT: "SIMPLE_PRODUCT";
|
|
80
|
+
readonly CONFIGURABLE_PRODUCT: "CONFIGURABLE_PRODUCT";
|
|
81
|
+
readonly BUNDLE_PRODUCT: "BUNDLE_PRODUCT";
|
|
82
|
+
readonly PLAN_PRODUCT: "PLAN_PRODUCT";
|
|
83
|
+
readonly TOKENIZED_PRODUCT: "TOKENIZED_PRODUCT";
|
|
84
|
+
}>;
|
|
49
85
|
content: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
50
86
|
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
51
87
|
subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -55,6 +91,53 @@ export declare const ProductCreateSpecificationSchema: z.ZodMiniObject<{
|
|
|
55
91
|
vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
56
92
|
labels: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
57
93
|
}, z.core.$strip>>;
|
|
94
|
+
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
95
|
+
status: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
|
|
96
|
+
readonly DRAFT: "DRAFT";
|
|
97
|
+
readonly ACTIVE: "ACTIVE";
|
|
98
|
+
readonly DELETED: "DELETED";
|
|
99
|
+
}>>>;
|
|
100
|
+
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniUnion<readonly [z.ZodMiniDate<Date>, z.ZodMiniString<string>]>>>;
|
|
101
|
+
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
102
|
+
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
103
|
+
pricing: z.ZodMiniArray<z.ZodMiniObject<{
|
|
104
|
+
amount: z.ZodMiniNumber<number>;
|
|
105
|
+
minQuantity: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
106
|
+
isTaxable: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
107
|
+
isNetPrice: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
108
|
+
currencyCode: z.ZodMiniString<string>;
|
|
109
|
+
countryCode: z.ZodMiniString<string>;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
}, z.core.$strip>>;
|
|
112
|
+
warehousing: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
113
|
+
sku: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
114
|
+
baseUnit: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
115
|
+
}, z.core.$strip>>;
|
|
116
|
+
supply: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
117
|
+
weightInGram: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
118
|
+
heightInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
119
|
+
lengthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
120
|
+
widthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
121
|
+
}, z.core.$strip>>;
|
|
122
|
+
tokenization: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
123
|
+
contractAddress: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
124
|
+
contractStandard: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
125
|
+
readonly ERC721: "ERC721";
|
|
126
|
+
readonly ERC1155: "ERC1155";
|
|
127
|
+
}>>;
|
|
128
|
+
tokenId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
129
|
+
supply: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
130
|
+
ercMetadataProperties: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>>;
|
|
131
|
+
}, z.core.$strip>>;
|
|
132
|
+
bundleItems: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
133
|
+
productId: z.ZodMiniString<string>;
|
|
134
|
+
quantity: z.ZodMiniNumber<number>;
|
|
135
|
+
configuration: z.ZodMiniArray<z.ZodMiniObject<{
|
|
136
|
+
key: z.ZodMiniString<string>;
|
|
137
|
+
value: z.ZodMiniString<string>;
|
|
138
|
+
}, z.core.$strip>>;
|
|
139
|
+
}, z.core.$strip>>>;
|
|
140
|
+
meta: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniAny, z.ZodMiniAny>>;
|
|
58
141
|
variationResolvers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
59
142
|
vector: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>;
|
|
60
143
|
productId: z.ZodMiniString<string>;
|
|
@@ -70,13 +153,22 @@ export declare const ProductCreatePayloadSchema: z.ZodMiniObject<{
|
|
|
70
153
|
readonly PLAN_PRODUCT: "PLAN_PRODUCT";
|
|
71
154
|
readonly TOKENIZED_PRODUCT: "TOKENIZED_PRODUCT";
|
|
72
155
|
}>;
|
|
156
|
+
content: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
157
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
158
|
+
subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
159
|
+
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
160
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
161
|
+
brand: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
162
|
+
vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
163
|
+
labels: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
164
|
+
}, z.core.$strip>>;
|
|
73
165
|
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
74
166
|
status: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
|
|
75
167
|
readonly DRAFT: "DRAFT";
|
|
76
168
|
readonly ACTIVE: "ACTIVE";
|
|
77
169
|
readonly DELETED: "DELETED";
|
|
78
170
|
}>>>;
|
|
79
|
-
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
|
|
171
|
+
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniUnion<readonly [z.ZodMiniDate<Date>, z.ZodMiniString<string>]>>>;
|
|
80
172
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
81
173
|
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
82
174
|
pricing: z.ZodMiniArray<z.ZodMiniObject<{
|
|
@@ -98,6 +190,16 @@ export declare const ProductCreatePayloadSchema: z.ZodMiniObject<{
|
|
|
98
190
|
lengthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
99
191
|
widthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
100
192
|
}, z.core.$strip>>;
|
|
193
|
+
tokenization: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
194
|
+
contractAddress: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
195
|
+
contractStandard: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
196
|
+
readonly ERC721: "ERC721";
|
|
197
|
+
readonly ERC1155: "ERC1155";
|
|
198
|
+
}>>;
|
|
199
|
+
tokenId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
200
|
+
supply: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
201
|
+
ercMetadataProperties: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>>;
|
|
202
|
+
}, z.core.$strip>>;
|
|
101
203
|
bundleItems: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
102
204
|
productId: z.ZodMiniString<string>;
|
|
103
205
|
quantity: z.ZodMiniNumber<number>;
|
|
@@ -107,15 +209,6 @@ export declare const ProductCreatePayloadSchema: z.ZodMiniObject<{
|
|
|
107
209
|
}, z.core.$strip>>;
|
|
108
210
|
}, z.core.$strip>>>;
|
|
109
211
|
meta: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniAny, z.ZodMiniAny>>;
|
|
110
|
-
content: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
111
|
-
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
112
|
-
subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
113
|
-
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
114
|
-
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
115
|
-
brand: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
116
|
-
vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
117
|
-
labels: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
118
|
-
}, z.core.$strip>>;
|
|
119
212
|
variationResolvers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
120
213
|
vector: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>;
|
|
121
214
|
productId: z.ZodMiniString<string>;
|
|
@@ -177,13 +270,22 @@ declare namespace createProduct {
|
|
|
177
270
|
readonly PLAN_PRODUCT: "PLAN_PRODUCT";
|
|
178
271
|
readonly TOKENIZED_PRODUCT: "TOKENIZED_PRODUCT";
|
|
179
272
|
}>;
|
|
273
|
+
content: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
274
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
275
|
+
subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
276
|
+
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
277
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
278
|
+
brand: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
279
|
+
vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
280
|
+
labels: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
281
|
+
}, z.core.$strip>>;
|
|
180
282
|
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
181
283
|
status: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
|
|
182
284
|
readonly DRAFT: "DRAFT";
|
|
183
285
|
readonly ACTIVE: "ACTIVE";
|
|
184
286
|
readonly DELETED: "DELETED";
|
|
185
287
|
}>>>;
|
|
186
|
-
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
|
|
288
|
+
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniUnion<readonly [z.ZodMiniDate<Date>, z.ZodMiniString<string>]>>>;
|
|
187
289
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
188
290
|
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
189
291
|
pricing: z.ZodMiniArray<z.ZodMiniObject<{
|
|
@@ -205,6 +307,16 @@ declare namespace createProduct {
|
|
|
205
307
|
lengthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
206
308
|
widthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
207
309
|
}, z.core.$strip>>;
|
|
310
|
+
tokenization: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
311
|
+
contractAddress: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
312
|
+
contractStandard: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
313
|
+
readonly ERC721: "ERC721";
|
|
314
|
+
readonly ERC1155: "ERC1155";
|
|
315
|
+
}>>;
|
|
316
|
+
tokenId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
317
|
+
supply: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
318
|
+
ercMetadataProperties: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>>;
|
|
319
|
+
}, z.core.$strip>>;
|
|
208
320
|
bundleItems: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
209
321
|
productId: z.ZodMiniString<string>;
|
|
210
322
|
quantity: z.ZodMiniNumber<number>;
|
|
@@ -214,15 +326,6 @@ declare namespace createProduct {
|
|
|
214
326
|
}, z.core.$strip>>;
|
|
215
327
|
}, z.core.$strip>>>;
|
|
216
328
|
meta: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniAny, z.ZodMiniAny>>;
|
|
217
|
-
content: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
218
|
-
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
219
|
-
subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
220
|
-
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
221
|
-
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
222
|
-
brand: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
223
|
-
vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
224
|
-
labels: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
225
|
-
}, z.core.$strip>>;
|
|
226
329
|
variationResolvers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
227
330
|
vector: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>;
|
|
228
331
|
productId: z.ZodMiniString<string>;
|
|
@@ -3,12 +3,31 @@ import upsertVariations, { ProductVariationSchema } from "./upsertVariations.js"
|
|
|
3
3
|
import upsertMedia from "./upsertMedia.js";
|
|
4
4
|
import { MediaSchema } from "../assortment/upsertMedia.js";
|
|
5
5
|
import convertTagsToLowerCase from "../utils/convertTagsToLowerCase.js";
|
|
6
|
-
import { ProductStatus, ProductType } from '@unchainedshop/core-products';
|
|
7
|
-
export const
|
|
8
|
-
|
|
6
|
+
import { ProductContractStandard, ProductStatus, ProductType, } from '@unchainedshop/core-products';
|
|
7
|
+
export const DateLikeSchema = z.union([
|
|
8
|
+
z.date(),
|
|
9
|
+
z.string().check(z.refine((value) => !Number.isNaN(new Date(value).getTime()), 'Invalid date')),
|
|
10
|
+
]);
|
|
11
|
+
export const ProductTokenizationSchema = z.object({
|
|
12
|
+
contractAddress: z.optional(z.string()),
|
|
13
|
+
contractStandard: z.optional(z.enum(ProductContractStandard)),
|
|
14
|
+
tokenId: z.optional(z.string()),
|
|
15
|
+
supply: z.optional(z.int().check(z.gte(0))),
|
|
16
|
+
ercMetadataProperties: z.optional(z.record(z.string(), z.any())),
|
|
17
|
+
});
|
|
18
|
+
export const ProductContentSchema = z.record(z.string(), z.object({
|
|
19
|
+
title: z.optional(z.string()),
|
|
20
|
+
subtitle: z.optional(z.string()),
|
|
21
|
+
slug: z.optional(z.string()),
|
|
22
|
+
description: z.optional(z.string()),
|
|
23
|
+
brand: z.optional(z.string()),
|
|
24
|
+
vendor: z.optional(z.string()),
|
|
25
|
+
labels: z.optional(z.array(z.string())),
|
|
26
|
+
}));
|
|
27
|
+
export const ProductSpecificationFields = {
|
|
9
28
|
sequence: z.optional(z.number()),
|
|
10
29
|
status: z.nullish(z.enum(ProductStatus)),
|
|
11
|
-
published: z.nullish(
|
|
30
|
+
published: z.nullish(DateLikeSchema),
|
|
12
31
|
tags: z.optional(z.array(z.string())),
|
|
13
32
|
commerce: z.optional(z.object({
|
|
14
33
|
pricing: z.array(z.object({
|
|
@@ -30,6 +49,7 @@ export const ProductCreateSpecificationSchema = z.object({
|
|
|
30
49
|
lengthInMillimeters: z.optional(z.number()),
|
|
31
50
|
widthInMillimeters: z.optional(z.number()),
|
|
32
51
|
})),
|
|
52
|
+
tokenization: z.optional(ProductTokenizationSchema),
|
|
33
53
|
bundleItems: z.optional(z.array(z.object({
|
|
34
54
|
productId: z.string(),
|
|
35
55
|
quantity: z.number(),
|
|
@@ -39,19 +59,15 @@ export const ProductCreateSpecificationSchema = z.object({
|
|
|
39
59
|
})),
|
|
40
60
|
}))),
|
|
41
61
|
meta: z.optional(z.record(z.any(), z.any())),
|
|
42
|
-
content: z.record(z.string(), z.object({
|
|
43
|
-
title: z.optional(z.string()),
|
|
44
|
-
subtitle: z.optional(z.string()),
|
|
45
|
-
slug: z.optional(z.string()),
|
|
46
|
-
description: z.optional(z.string()),
|
|
47
|
-
brand: z.optional(z.string()),
|
|
48
|
-
vendor: z.optional(z.string()),
|
|
49
|
-
labels: z.optional(z.array(z.string())),
|
|
50
|
-
})),
|
|
51
62
|
variationResolvers: z.optional(z.array(z.object({
|
|
52
63
|
vector: z.record(z.string(), z.any()),
|
|
53
64
|
productId: z.string(),
|
|
54
65
|
}))),
|
|
66
|
+
};
|
|
67
|
+
export const ProductCreateSpecificationSchema = z.object({
|
|
68
|
+
...ProductSpecificationFields,
|
|
69
|
+
type: z.enum(ProductType),
|
|
70
|
+
content: ProductContentSchema,
|
|
55
71
|
});
|
|
56
72
|
export const ProductCreatePayloadSchema = z.object({
|
|
57
73
|
_id: z.string(),
|
|
@@ -61,7 +77,7 @@ export const ProductCreatePayloadSchema = z.object({
|
|
|
61
77
|
});
|
|
62
78
|
const normalizeStatus = (status) => (status === ProductStatus.DRAFT ? null : status);
|
|
63
79
|
const transformSpecification = (specification) => {
|
|
64
|
-
const { variationResolvers: assignments, content, supply, warehousing, sequence, ...productData } = specification;
|
|
80
|
+
const { variationResolvers: assignments, content, supply, warehousing, sequence, tokenization, ...productData } = specification;
|
|
65
81
|
const tags = productData?.tags ? convertTagsToLowerCase(productData.tags) : [];
|
|
66
82
|
const proxy = assignments ? { assignments } : undefined;
|
|
67
83
|
return {
|
|
@@ -69,6 +85,7 @@ const transformSpecification = (specification) => {
|
|
|
69
85
|
...(sequence != null && { sequence }),
|
|
70
86
|
published: productData.published ? new Date(productData.published) : undefined,
|
|
71
87
|
...(productData.status !== undefined && { status: normalizeStatus(productData.status) }),
|
|
88
|
+
...(tokenization !== undefined && { tokenization: tokenization }),
|
|
72
89
|
tags,
|
|
73
90
|
warehousing,
|
|
74
91
|
supply,
|
|
@@ -3,13 +3,22 @@ import type { Modules } from '../../../modules.ts';
|
|
|
3
3
|
import type { Services } from '../../../services/index.ts';
|
|
4
4
|
export declare const ProductUpdateSpecificationSchema: z.ZodMiniObject<{
|
|
5
5
|
type: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
6
|
+
content: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
7
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
8
|
+
subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
9
|
+
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
10
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
11
|
+
brand: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
12
|
+
vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
13
|
+
labels: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
14
|
+
}, z.core.$strip>>>;
|
|
6
15
|
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
7
16
|
status: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
|
|
8
17
|
readonly DRAFT: "DRAFT";
|
|
9
18
|
readonly ACTIVE: "ACTIVE";
|
|
10
19
|
readonly DELETED: "DELETED";
|
|
11
20
|
}>>>;
|
|
12
|
-
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
|
|
21
|
+
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniUnion<readonly [z.ZodMiniDate<Date>, z.ZodMiniString<string>]>>>;
|
|
13
22
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
14
23
|
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
15
24
|
pricing: z.ZodMiniArray<z.ZodMiniObject<{
|
|
@@ -31,6 +40,16 @@ export declare const ProductUpdateSpecificationSchema: z.ZodMiniObject<{
|
|
|
31
40
|
lengthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
32
41
|
widthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
33
42
|
}, z.core.$strip>>;
|
|
43
|
+
tokenization: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
44
|
+
contractAddress: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
45
|
+
contractStandard: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
46
|
+
readonly ERC721: "ERC721";
|
|
47
|
+
readonly ERC1155: "ERC1155";
|
|
48
|
+
}>>;
|
|
49
|
+
tokenId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
50
|
+
supply: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
51
|
+
ercMetadataProperties: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>>;
|
|
52
|
+
}, z.core.$strip>>;
|
|
34
53
|
bundleItems: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
35
54
|
productId: z.ZodMiniString<string>;
|
|
36
55
|
quantity: z.ZodMiniNumber<number>;
|
|
@@ -40,15 +59,6 @@ export declare const ProductUpdateSpecificationSchema: z.ZodMiniObject<{
|
|
|
40
59
|
}, z.core.$strip>>;
|
|
41
60
|
}, z.core.$strip>>>;
|
|
42
61
|
meta: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniAny, z.ZodMiniAny>>;
|
|
43
|
-
content: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
44
|
-
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
45
|
-
subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
46
|
-
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
47
|
-
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
48
|
-
brand: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
49
|
-
vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
50
|
-
labels: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
51
|
-
}, z.core.$strip>>>;
|
|
52
62
|
variationResolvers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
53
63
|
vector: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>;
|
|
54
64
|
productId: z.ZodMiniString<string>;
|
|
@@ -58,13 +68,22 @@ export declare const ProductUpdatePayloadSchema: z.ZodMiniObject<{
|
|
|
58
68
|
_id: z.ZodMiniString<string>;
|
|
59
69
|
specification: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
60
70
|
type: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
71
|
+
content: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
72
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
73
|
+
subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
74
|
+
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
75
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
76
|
+
brand: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
77
|
+
vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
78
|
+
labels: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
79
|
+
}, z.core.$strip>>>;
|
|
61
80
|
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
62
81
|
status: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
|
|
63
82
|
readonly DRAFT: "DRAFT";
|
|
64
83
|
readonly ACTIVE: "ACTIVE";
|
|
65
84
|
readonly DELETED: "DELETED";
|
|
66
85
|
}>>>;
|
|
67
|
-
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
|
|
86
|
+
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniUnion<readonly [z.ZodMiniDate<Date>, z.ZodMiniString<string>]>>>;
|
|
68
87
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
69
88
|
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
70
89
|
pricing: z.ZodMiniArray<z.ZodMiniObject<{
|
|
@@ -86,6 +105,16 @@ export declare const ProductUpdatePayloadSchema: z.ZodMiniObject<{
|
|
|
86
105
|
lengthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
87
106
|
widthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
88
107
|
}, z.core.$strip>>;
|
|
108
|
+
tokenization: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
109
|
+
contractAddress: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
110
|
+
contractStandard: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
111
|
+
readonly ERC721: "ERC721";
|
|
112
|
+
readonly ERC1155: "ERC1155";
|
|
113
|
+
}>>;
|
|
114
|
+
tokenId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
115
|
+
supply: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
116
|
+
ercMetadataProperties: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>>;
|
|
117
|
+
}, z.core.$strip>>;
|
|
89
118
|
bundleItems: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
90
119
|
productId: z.ZodMiniString<string>;
|
|
91
120
|
quantity: z.ZodMiniNumber<number>;
|
|
@@ -95,15 +124,6 @@ export declare const ProductUpdatePayloadSchema: z.ZodMiniObject<{
|
|
|
95
124
|
}, z.core.$strip>>;
|
|
96
125
|
}, z.core.$strip>>>;
|
|
97
126
|
meta: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniAny, z.ZodMiniAny>>;
|
|
98
|
-
content: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
99
|
-
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
100
|
-
subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
101
|
-
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
102
|
-
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
103
|
-
brand: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
104
|
-
vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
105
|
-
labels: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
106
|
-
}, z.core.$strip>>>;
|
|
107
127
|
variationResolvers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
108
128
|
vector: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>;
|
|
109
129
|
productId: z.ZodMiniString<string>;
|
|
@@ -159,13 +179,22 @@ declare namespace updateProduct {
|
|
|
159
179
|
_id: z.ZodMiniString<string>;
|
|
160
180
|
specification: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
161
181
|
type: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
182
|
+
content: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
183
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
184
|
+
subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
185
|
+
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
186
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
187
|
+
brand: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
188
|
+
vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
189
|
+
labels: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
190
|
+
}, z.core.$strip>>>;
|
|
162
191
|
sequence: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
163
192
|
status: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
|
|
164
193
|
readonly DRAFT: "DRAFT";
|
|
165
194
|
readonly ACTIVE: "ACTIVE";
|
|
166
195
|
readonly DELETED: "DELETED";
|
|
167
196
|
}>>>;
|
|
168
|
-
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
|
|
197
|
+
published: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniUnion<readonly [z.ZodMiniDate<Date>, z.ZodMiniString<string>]>>>;
|
|
169
198
|
tags: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
170
199
|
commerce: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
171
200
|
pricing: z.ZodMiniArray<z.ZodMiniObject<{
|
|
@@ -187,6 +216,16 @@ declare namespace updateProduct {
|
|
|
187
216
|
lengthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
188
217
|
widthInMillimeters: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
189
218
|
}, z.core.$strip>>;
|
|
219
|
+
tokenization: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
220
|
+
contractAddress: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
221
|
+
contractStandard: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
222
|
+
readonly ERC721: "ERC721";
|
|
223
|
+
readonly ERC1155: "ERC1155";
|
|
224
|
+
}>>;
|
|
225
|
+
tokenId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
226
|
+
supply: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
227
|
+
ercMetadataProperties: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>>;
|
|
228
|
+
}, z.core.$strip>>;
|
|
190
229
|
bundleItems: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
191
230
|
productId: z.ZodMiniString<string>;
|
|
192
231
|
quantity: z.ZodMiniNumber<number>;
|
|
@@ -196,15 +235,6 @@ declare namespace updateProduct {
|
|
|
196
235
|
}, z.core.$strip>>;
|
|
197
236
|
}, z.core.$strip>>>;
|
|
198
237
|
meta: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniAny, z.ZodMiniAny>>;
|
|
199
|
-
content: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
200
|
-
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
201
|
-
subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
202
|
-
slug: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
203
|
-
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
204
|
-
brand: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
205
|
-
vendor: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
206
|
-
labels: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
207
|
-
}, z.core.$strip>>>;
|
|
208
238
|
variationResolvers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
209
239
|
vector: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniAny>;
|
|
210
240
|
productId: z.ZodMiniString<string>;
|
|
@@ -1,57 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod/v4-mini';
|
|
2
2
|
import upsertVariations, { ProductVariationSchema } from "./upsertVariations.js";
|
|
3
3
|
import upsertMedia, { MediaSchema } from "./upsertMedia.js";
|
|
4
|
-
import createProduct, { ProductCreatePayloadSchema } from "./create.js";
|
|
4
|
+
import createProduct, { ProductContentSchema, ProductCreatePayloadSchema, ProductSpecificationFields, } from "./create.js";
|
|
5
5
|
import convertTagsToLowerCase from "../utils/convertTagsToLowerCase.js";
|
|
6
6
|
import { ProductStatus } from '@unchainedshop/core-products';
|
|
7
7
|
export const ProductUpdateSpecificationSchema = z.object({
|
|
8
|
+
...ProductSpecificationFields,
|
|
8
9
|
type: z.optional(z.string()),
|
|
9
|
-
|
|
10
|
-
status: z.nullish(z.enum(ProductStatus)),
|
|
11
|
-
published: z.nullish(z.string().check(z.refine((value) => !Number.isNaN(new Date(value).getTime()), 'Invalid date'))),
|
|
12
|
-
tags: z.optional(z.array(z.string())),
|
|
13
|
-
commerce: z.optional(z.object({
|
|
14
|
-
pricing: z.array(z.object({
|
|
15
|
-
amount: z.number(),
|
|
16
|
-
minQuantity: z.optional(z.number().check(z.gte(0))),
|
|
17
|
-
isTaxable: z.optional(z.boolean()),
|
|
18
|
-
isNetPrice: z.optional(z.boolean()),
|
|
19
|
-
currencyCode: z.string().check(z.minLength(1, 'currencyCode is required')),
|
|
20
|
-
countryCode: z.string().check(z.minLength(1, 'countryCode is required')),
|
|
21
|
-
})),
|
|
22
|
-
})),
|
|
23
|
-
warehousing: z.optional(z.object({
|
|
24
|
-
sku: z.optional(z.string()),
|
|
25
|
-
baseUnit: z.optional(z.string()),
|
|
26
|
-
})),
|
|
27
|
-
supply: z.optional(z.object({
|
|
28
|
-
weightInGram: z.optional(z.number()),
|
|
29
|
-
heightInMillimeters: z.optional(z.number()),
|
|
30
|
-
lengthInMillimeters: z.optional(z.number()),
|
|
31
|
-
widthInMillimeters: z.optional(z.number()),
|
|
32
|
-
})),
|
|
33
|
-
bundleItems: z.optional(z.array(z.object({
|
|
34
|
-
productId: z.string(),
|
|
35
|
-
quantity: z.number(),
|
|
36
|
-
configuration: z.array(z.object({
|
|
37
|
-
key: z.string(),
|
|
38
|
-
value: z.string(),
|
|
39
|
-
})),
|
|
40
|
-
}))),
|
|
41
|
-
meta: z.optional(z.record(z.any(), z.any())),
|
|
42
|
-
content: z.optional(z.record(z.string(), z.object({
|
|
43
|
-
title: z.optional(z.string()),
|
|
44
|
-
subtitle: z.optional(z.string()),
|
|
45
|
-
slug: z.optional(z.string()),
|
|
46
|
-
description: z.optional(z.string()),
|
|
47
|
-
brand: z.optional(z.string()),
|
|
48
|
-
vendor: z.optional(z.string()),
|
|
49
|
-
labels: z.optional(z.array(z.string())),
|
|
50
|
-
}))),
|
|
51
|
-
variationResolvers: z.optional(z.array(z.object({
|
|
52
|
-
vector: z.record(z.string(), z.any()),
|
|
53
|
-
productId: z.string(),
|
|
54
|
-
}))),
|
|
10
|
+
content: z.optional(ProductContentSchema),
|
|
55
11
|
});
|
|
56
12
|
export const ProductUpdatePayloadSchema = z.object({
|
|
57
13
|
_id: z.string(),
|
|
@@ -61,13 +17,14 @@ export const ProductUpdatePayloadSchema = z.object({
|
|
|
61
17
|
});
|
|
62
18
|
const normalizeStatus = (status) => (status === ProductStatus.DRAFT ? null : status);
|
|
63
19
|
const transformSpecification = (specification) => {
|
|
64
|
-
const { variationResolvers: assignments, content, supply, warehousing, ...productData } = specification;
|
|
20
|
+
const { variationResolvers: assignments, content, supply, warehousing, tokenization, ...productData } = specification;
|
|
65
21
|
const tags = productData?.tags ? convertTagsToLowerCase(productData.tags) : [];
|
|
66
22
|
const proxy = assignments ? { assignments } : undefined;
|
|
67
23
|
return {
|
|
68
24
|
...productData,
|
|
69
25
|
published: productData.published ? new Date(productData.published) : undefined,
|
|
70
26
|
...(productData.status !== undefined && { status: normalizeStatus(productData.status) }),
|
|
27
|
+
...(tokenization !== undefined && { tokenization: tokenization }),
|
|
71
28
|
tags,
|
|
72
29
|
warehousing,
|
|
73
30
|
supply,
|
package/lib/core-index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { type mongodb, type MigrationRepository, type ModuleInput } from '@uncha
|
|
|
2
2
|
import { type CustomServices, type Services } from './services/index.ts';
|
|
3
3
|
import { type Modules, type ModuleOptions } from './modules.ts';
|
|
4
4
|
import { type BulkImporter, type BulkImportHandler } from './bulk-importer/index.ts';
|
|
5
|
-
import type { IBaseAdapter } from '@unchainedshop/utils';
|
|
6
5
|
import { type BulkExporter, type BulkExportHandler } from './bulk-exporter/index.ts';
|
|
7
6
|
export * from './bulk-importer/index.ts';
|
|
8
7
|
export * from './services/index.ts';
|
|
@@ -36,4 +35,4 @@ export interface UnchainedCore {
|
|
|
36
35
|
bulkExporter: BulkExporter;
|
|
37
36
|
}
|
|
38
37
|
export declare const initCore: ({ db, migrationRepository, bulkImporter: bulkImporterOptions, modules: customModules, services: customServices, options, bulkExporter: bulkExporterOptions, }: UnchainedCoreOptions) => Promise<UnchainedCore>;
|
|
39
|
-
export declare const getAllAdapters: () => IBaseAdapter[];
|
|
38
|
+
export declare const getAllAdapters: () => import("@unchainedshop/utils").IBaseAdapter[];
|
package/lib/core-index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {} from '@unchainedshop/mongodb';
|
|
|
2
2
|
import initServices, {} from "./services/index.js";
|
|
3
3
|
import initModules, {} from "./modules.js";
|
|
4
4
|
import createBulkImporterFactory, {} from "./bulk-importer/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { pluginRegistry } from "./plugins/PluginRegistry.js";
|
|
6
6
|
import createBulkExporterFactory, {} from "./bulk-exporter/index.js";
|
|
7
7
|
export * from "./bulk-importer/index.js";
|
|
8
8
|
export * from "./services/index.js";
|
|
@@ -26,20 +26,4 @@ export const initCore = async ({ db, migrationRepository, bulkImporter: bulkImpo
|
|
|
26
26
|
bulkExporter,
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
|
-
export const getAllAdapters = () =>
|
|
30
|
-
const worker = WorkerDirector.getAdapters();
|
|
31
|
-
const delivery = DeliveryDirector.getAdapters();
|
|
32
|
-
const deliveryPricing = DeliveryPricingDirector.getAdapters();
|
|
33
|
-
const enrollment = EnrollmentDirector.getAdapters();
|
|
34
|
-
const file = FileDirector.getAdapters();
|
|
35
|
-
const filter = FilterDirector.getAdapters();
|
|
36
|
-
const orderDiscount = OrderDiscountDirector.getAdapters();
|
|
37
|
-
const orderPricing = OrderPricingDirector.getAdapters();
|
|
38
|
-
const payment = PaymentDirector.getAdapters();
|
|
39
|
-
const paymentPricing = PaymentPricingDirector.getAdapters();
|
|
40
|
-
const productDiscount = ProductDiscountDirector.getAdapters();
|
|
41
|
-
const productPricing = ProductPricingDirector.getAdapters();
|
|
42
|
-
const quotation = QuotationDirector.getAdapters();
|
|
43
|
-
const warehousing = WarehousingDirector.getAdapters();
|
|
44
|
-
return [].concat(worker, delivery, deliveryPricing, enrollment, file, filter, orderDiscount, orderPricing, payment, paymentPricing, productDiscount, productPricing, quotation, warehousing);
|
|
45
|
-
};
|
|
29
|
+
export const getAllAdapters = () => pluginRegistry.getAllAdapters();
|
|
@@ -31,5 +31,8 @@ export interface DiscountAdapterActions<DiscountConfiguration> {
|
|
|
31
31
|
code?: string;
|
|
32
32
|
}) => Promise<any>;
|
|
33
33
|
release: () => Promise<void>;
|
|
34
|
+
reserveForCheckout?: () => Promise<{
|
|
35
|
+
release: () => Promise<void>;
|
|
36
|
+
}>;
|
|
34
37
|
}
|
|
35
38
|
export declare const BaseDiscountAdapter: Omit<IDiscountAdapter<unknown>, 'key' | 'label' | 'version'>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IBaseDirector } from '@unchainedshop/utils';
|
|
2
2
|
import type { DiscountContext, IDiscountAdapter } from './BaseDiscountAdapter.ts';
|
|
3
3
|
import type { Modules } from '../modules.ts';
|
|
4
4
|
export type IDiscountDirector<DiscountConfiguration> = IBaseDirector<IDiscountAdapter<DiscountConfiguration>> & {
|
|
@@ -11,4 +11,4 @@ export type IDiscountDirector<DiscountConfiguration> = IBaseDirector<IDiscountAd
|
|
|
11
11
|
findSystemDiscounts: () => Promise<string[]>;
|
|
12
12
|
}>;
|
|
13
13
|
};
|
|
14
|
-
export declare const BaseDiscountDirector: <DiscountConfigurationType>(
|
|
14
|
+
export declare const BaseDiscountDirector: <DiscountConfigurationType>(adapterType: symbol) => IDiscountDirector<DiscountConfigurationType>;
|