@ecomiq/core 0.1.9 → 1.1.0
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/LICENSE +21 -0
- package/README.md +39 -2
- package/dist/_virtual/_rolldown/runtime-C6LprzCP.cjs +22 -0
- package/dist/api.cjs +117 -102
- package/dist/api.d.cts +33 -37
- package/dist/api.d.ts +33 -37
- package/dist/api.js +116 -100
- package/dist/client.cjs +499 -1676
- package/dist/client.d.cts +156 -15
- package/dist/client.d.ts +156 -15
- package/dist/client.js +500 -1675
- package/dist/index.cjs +344 -2092
- package/dist/index.d.cts +54 -1127
- package/dist/index.d.ts +54 -1127
- package/dist/index.js +53 -1895
- package/dist/libs/bounded-read-cache-Abmb5VnJ.js +41 -0
- package/dist/libs/bounded-read-cache-D4644LJo.cjs +41 -0
- package/dist/libs/catalog-link-key-B7l5KZsF.js +9 -0
- package/dist/libs/catalog-link-key-CZTHJBGD.cjs +9 -0
- package/dist/libs/catalog-link-key.d.cts +2 -0
- package/dist/libs/catalog-link-key.d.ts +2 -0
- package/dist/libs/graphql-_6Y8lR_Q.js +49 -0
- package/dist/libs/graphql-selection-Cj51WkJn.cjs +21 -0
- package/dist/libs/graphql-selection-H1RMh6VD.js +21 -0
- package/dist/libs/graphql-selection.d.cts +3 -0
- package/dist/libs/graphql-selection.d.ts +3 -0
- package/dist/libs/graphql-wJH7HaQU.cjs +50 -0
- package/dist/libs/graphql.d.cts +24 -0
- package/dist/libs/graphql.d.ts +24 -0
- package/dist/models/amounts-cKBCecl7.js +5 -0
- package/dist/models/amounts-lmg89eJQ.cjs +4 -0
- package/dist/models/articles-C-4JvT2Z.js +27 -0
- package/dist/models/articles-xHCXLKDK.cjs +30 -0
- package/dist/models/articles.d.cts +46 -0
- package/dist/models/articles.d.ts +46 -0
- package/dist/models/catalog-links-BzJeyBy4.js +80 -0
- package/dist/models/catalog-links-c4LADGf_.cjs +88 -0
- package/dist/models/catalog-links.d.cts +39 -0
- package/dist/models/catalog-links.d.ts +39 -0
- package/dist/models/categories-CKkJY8_P.js +42 -0
- package/dist/models/categories-DZ5i5kwi.cjs +45 -0
- package/dist/models/categories.d.cts +54 -0
- package/dist/models/categories.d.ts +54 -0
- package/dist/models/collections.cjs +13 -22
- package/dist/models/collections.d.cts +23 -56
- package/dist/models/collections.d.ts +23 -56
- package/dist/models/collections.js +12 -20
- package/dist/models/complaint-book-D5INpuI2.cjs +64 -0
- package/dist/models/complaint-book-QpQZe7Xl.js +58 -0
- package/dist/models/complaint-book.d.cts +71 -0
- package/dist/models/complaint-book.d.ts +71 -0
- package/dist/models/customer-address.cjs +39 -38
- package/dist/models/customer-address.d.cts +59 -158
- package/dist/models/customer-address.d.ts +59 -158
- package/dist/models/customer-address.js +38 -36
- package/dist/models/customer-order.cjs +183 -142
- package/dist/models/customer-order.d.cts +474 -857
- package/dist/models/customer-order.d.ts +474 -857
- package/dist/models/customer-order.js +180 -141
- package/dist/models/customer-profile.cjs +121 -118
- package/dist/models/customer-profile.d.cts +89 -174
- package/dist/models/customer-profile.d.ts +89 -174
- package/dist/models/customer-profile.js +121 -116
- package/dist/models/customer-registration-C13knqyv.js +28 -0
- package/dist/models/customer-registration-EZ0yZgGr.cjs +31 -0
- package/dist/models/customer-registration.d.cts +66 -0
- package/dist/models/customer-registration.d.ts +66 -0
- package/dist/models/customer-session-BiX0TXhO.js +41 -0
- package/dist/models/customer-session-JeQiC8Yx.cjs +45 -0
- package/dist/models/customer-session.d.cts +61 -0
- package/dist/models/customer-session.d.ts +61 -0
- package/dist/models/geo.cjs +52 -49
- package/dist/models/geo.d.cts +141 -270
- package/dist/models/geo.d.ts +141 -270
- package/dist/models/geo.js +51 -47
- package/dist/models/ids.cjs +8 -11
- package/dist/models/ids.d.cts +7 -10
- package/dist/models/ids.d.ts +7 -10
- package/dist/models/ids.js +7 -9
- package/dist/models/order-draft-C-2WRbjl.cjs +41 -0
- package/dist/models/order-draft-CSIWRIV0.js +39 -0
- package/dist/models/order-draft.d.cts +69 -0
- package/dist/models/order-draft.d.ts +69 -0
- package/dist/models/order-review--xGlZKtS.cjs +18 -0
- package/dist/models/order-review-egGeCaqB.js +17 -0
- package/dist/models/order-review.d.cts +22 -0
- package/dist/models/order-review.d.ts +22 -0
- package/dist/models/order-status-CS_OeSPY.cjs +66 -0
- package/dist/models/order-status-CgaLkU0M.js +60 -0
- package/dist/models/order-status.d.cts +307 -0
- package/dist/models/order-status.d.ts +307 -0
- package/dist/models/payment-methods--VUUZpMz.js +17 -0
- package/dist/models/payment-methods-CmK08zBM.cjs +19 -0
- package/dist/models/payment-methods.d.cts +28 -0
- package/dist/models/payment-methods.d.ts +28 -0
- package/dist/models/personalization-BPFmkdJ0.js +69 -0
- package/dist/models/personalization-CQosKg8O.cjs +77 -0
- package/dist/models/personalization.d.cts +83 -0
- package/dist/models/personalization.d.ts +83 -0
- package/dist/models/products.cjs +218 -194
- package/dist/models/products.d.cts +646 -1353
- package/dist/models/products.d.ts +646 -1353
- package/dist/models/products.js +214 -187
- package/dist/models/search.cjs +13 -23
- package/dist/models/search.d.cts +21 -51
- package/dist/models/search.d.ts +21 -51
- package/dist/models/search.js +12 -21
- package/dist/models/sellers.cjs +44 -0
- package/dist/models/sellers.d.cts +82 -0
- package/dist/models/sellers.d.ts +82 -0
- package/dist/models/sellers.js +38 -0
- package/dist/models/settings.cjs +205 -236
- package/dist/models/settings.d.cts +853 -6940
- package/dist/models/settings.d.ts +853 -6940
- package/dist/models/settings.js +213 -239
- package/dist/models/storefront-cart.cjs +152 -118
- package/dist/models/storefront-cart.d.cts +277 -706
- package/dist/models/storefront-cart.d.ts +277 -706
- package/dist/models/storefront-cart.js +148 -117
- package/dist/models/storefront-checkout.cjs +212 -297
- package/dist/models/storefront-checkout.d.cts +672 -2449
- package/dist/models/storefront-checkout.d.ts +672 -2449
- package/dist/models/storefront-checkout.js +208 -297
- package/dist/models/storefront-reviews.cjs +58 -43
- package/dist/models/storefront-reviews.d.cts +71 -139
- package/dist/models/storefront-reviews.d.ts +71 -139
- package/dist/models/storefront-reviews.js +55 -42
- package/dist/models/tracking-CiIAhQW0.js +33 -0
- package/dist/models/tracking-wNyzQ6Bp.cjs +36 -0
- package/dist/models/tracking.d.cts +26 -0
- package/dist/models/tracking.d.ts +26 -0
- package/dist/models/urls-B0ZODOwH.cjs +35 -0
- package/dist/models/urls-Dt_dTt4Q.js +33 -0
- package/dist/models/urls.d.cts +233 -0
- package/dist/models/urls.d.ts +233 -0
- package/dist/redirects.cjs +113 -0
- package/dist/redirects.d.cts +11 -0
- package/dist/redirects.d.ts +11 -0
- package/dist/redirects.js +108 -0
- package/dist/services/article.service-DBsOvflH.js +10 -0
- package/dist/services/article.service-zmTkbbPV.cjs +11 -0
- package/dist/services/article.service.d.cts +4 -0
- package/dist/services/article.service.d.ts +4 -0
- package/dist/services/cart.service-B0D8s6jI.cjs +37 -0
- package/dist/services/cart.service-yMCz9oQP.js +33 -0
- package/dist/services/cart.service.d.cts +572 -0
- package/dist/services/cart.service.d.ts +572 -0
- package/dist/services/catalog-link.service-BQ2d-EPX.js +8 -0
- package/dist/services/catalog-link.service-DiB-OVjn.cjs +8 -0
- package/dist/services/category.service-8tieYX2r.js +6 -0
- package/dist/services/category.service-BsSJZV2B.cjs +6 -0
- package/dist/services/checkout.service-CC-3tm2y.js +60 -0
- package/dist/services/checkout.service-CG8KrDNY.cjs +69 -0
- package/dist/services/checkout.service.d.cts +475 -0
- package/dist/services/checkout.service.d.ts +475 -0
- package/dist/services/collection.service-C4QETpuI.js +11 -0
- package/dist/services/collection.service-DHGN3rhs.cjs +12 -0
- package/dist/services/complaint-book.service-C7TxltQe.cjs +13 -0
- package/dist/services/complaint-book.service-DXiVyKdD.js +12 -0
- package/dist/services/complaint-book.service.d.cts +4 -0
- package/dist/services/complaint-book.service.d.ts +4 -0
- package/dist/services/customer-address.service-Ca4qla_R.cjs +51 -0
- package/dist/services/customer-address.service-xEThx7cQ.js +47 -0
- package/dist/services/customer-address.service.d.cts +19 -0
- package/dist/services/customer-address.service.d.ts +19 -0
- package/dist/services/customer-order.service-DLGgT0xa.cjs +54 -0
- package/dist/services/customer-order.service-qHoRBuyX.js +51 -0
- package/dist/services/customer-order.service.d.cts +34 -0
- package/dist/services/customer-order.service.d.ts +34 -0
- package/dist/services/customer-registration.service-C3BNyCHP.cjs +10 -0
- package/dist/services/customer-registration.service-CxcWD2hf.js +9 -0
- package/dist/services/customer-registration.service.d.cts +5 -0
- package/dist/services/customer-registration.service.d.ts +5 -0
- package/dist/services/customer-session.service-4YgfbWRB.js +16 -0
- package/dist/services/customer-session.service-Bd8pLC2v.cjs +19 -0
- package/dist/services/customer.service-BM0NrOxP.cjs +26 -0
- package/dist/services/customer.service-BoU6l2-R.js +25 -0
- package/dist/services/customer.service.d.cts +10 -0
- package/dist/services/customer.service.d.ts +10 -0
- package/dist/services/geo.service-C32R7N8W.js +39 -0
- package/dist/services/geo.service-JeTT3Wun.cjs +42 -0
- package/dist/services/geo.service.d.cts +10 -0
- package/dist/services/geo.service.d.ts +10 -0
- package/dist/services/layout.service-BkvLzl1g.cjs +50 -0
- package/dist/services/layout.service-DmbeMOkK.js +50 -0
- package/dist/services/layout.service.d.cts +9 -0
- package/dist/services/layout.service.d.ts +9 -0
- package/dist/services/order-draft.service-B0VcmWhn.js +13 -0
- package/dist/services/order-draft.service-Dlu6eEkV.cjs +14 -0
- package/dist/services/order-draft.service.d.cts +4 -0
- package/dist/services/order-draft.service.d.ts +4 -0
- package/dist/services/order-review.service-BEr-FB6_.cjs +11 -0
- package/dist/services/order-review.service-PdBPUsxE.js +11 -0
- package/dist/services/order-review.service.d.cts +7 -0
- package/dist/services/order-review.service.d.ts +7 -0
- package/dist/services/order-status.service-Cn7dsaJo.cjs +26 -0
- package/dist/services/order-status.service-MC9hVpP-.js +23 -0
- package/dist/services/order-status.service.d.cts +16 -0
- package/dist/services/order-status.service.d.ts +16 -0
- package/dist/services/page.service-CWhWCjMQ.js +7 -0
- package/dist/services/page.service-DmCSeMiR.cjs +7 -0
- package/dist/services/page.service.d.cts +4 -0
- package/dist/services/page.service.d.ts +4 -0
- package/dist/services/payment-method.service-CEt_nB4R.cjs +7 -0
- package/dist/services/payment-method.service-CjKbAsOh.js +7 -0
- package/dist/services/payment-method.service.d.cts +4 -0
- package/dist/services/payment-method.service.d.ts +4 -0
- package/dist/services/product.service-B05Qmbuh.js +35 -0
- package/dist/services/product.service-B7OFZWB1.cjs +37 -0
- package/dist/services/product.service.d.cts +256 -0
- package/dist/services/product.service.d.ts +256 -0
- package/dist/services/review.service-CO2icjpu.cjs +46 -0
- package/dist/services/review.service-De1YkhFp.js +43 -0
- package/dist/services/review.service.d.cts +28 -0
- package/dist/services/review.service.d.ts +28 -0
- package/dist/services/search.service-Bx1zbTHJ.cjs +10 -0
- package/dist/services/search.service-DSBMhaSY.js +10 -0
- package/dist/services/search.service.d.cts +9 -0
- package/dist/services/search.service.d.ts +9 -0
- package/dist/services/seller.service-D11WHhbC.cjs +10 -0
- package/dist/services/seller.service-DUptDTv4.js +9 -0
- package/dist/services/seller.service.d.cts +42 -0
- package/dist/services/seller.service.d.ts +42 -0
- package/dist/services/tracking.service-CPK1B69N.js +11 -0
- package/dist/services/tracking.service-DqOoi8qr.cjs +11 -0
- package/dist/services/tracking.service.d.cts +7 -0
- package/dist/services/tracking.service.d.ts +7 -0
- package/dist/services/url.service-B-nC14Ue.cjs +19 -0
- package/dist/services/url.service-CLW0Tc7S.js +18 -0
- package/dist/storefront-cache-revision.cjs +23 -0
- package/dist/storefront-cache-revision.d.cts +16 -0
- package/dist/storefront-cache-revision.d.ts +16 -0
- package/dist/storefront-cache-revision.js +17 -0
- package/dist/storefront-routes.cjs +14 -0
- package/dist/storefront-routes.d.cts +11 -0
- package/dist/storefront-routes.d.ts +11 -0
- package/dist/storefront-routes.js +12 -0
- package/dist/utils-CDEC5xcY.cjs +139 -0
- package/dist/utils-DK7qa54o.js +136 -0
- package/dist/utils.d.cts +3 -0
- package/dist/utils.d.ts +3 -0
- package/dist/video-links-CbRO0m8V.js +47 -0
- package/dist/video-links-ClryQjPH.cjs +47 -0
- package/dist/video-links.d.cts +7 -0
- package/dist/video-links.d.ts +7 -0
- package/package.json +28 -11
- package/dist/api.cjs.map +0 -1
- package/dist/api.js.map +0 -1
- package/dist/client-Ba1r_uiO.d.ts +0 -195
- package/dist/client-Cqcnv2tC.d.cts +0 -195
- package/dist/client.cjs.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/models/collections.cjs.map +0 -1
- package/dist/models/collections.js.map +0 -1
- package/dist/models/customer-address.cjs.map +0 -1
- package/dist/models/customer-address.js.map +0 -1
- package/dist/models/customer-order.cjs.map +0 -1
- package/dist/models/customer-order.js.map +0 -1
- package/dist/models/customer-profile.cjs.map +0 -1
- package/dist/models/customer-profile.js.map +0 -1
- package/dist/models/geo.cjs.map +0 -1
- package/dist/models/geo.js.map +0 -1
- package/dist/models/ids.cjs.map +0 -1
- package/dist/models/ids.js.map +0 -1
- package/dist/models/products.cjs.map +0 -1
- package/dist/models/products.js.map +0 -1
- package/dist/models/search.cjs.map +0 -1
- package/dist/models/search.js.map +0 -1
- package/dist/models/settings.cjs.map +0 -1
- package/dist/models/settings.js.map +0 -1
- package/dist/models/storefront-cart.cjs.map +0 -1
- package/dist/models/storefront-cart.js.map +0 -1
- package/dist/models/storefront-checkout.cjs.map +0 -1
- package/dist/models/storefront-checkout.js.map +0 -1
- package/dist/models/storefront-reviews.cjs.map +0 -1
- package/dist/models/storefront-reviews.js.map +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const StorefrontPaymentCodeSchema: z.ZodString;
|
|
3
|
+
export declare const StorefrontPaymentMethodSchema: z.ZodObject<{
|
|
4
|
+
code: z.ZodString;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
kind: z.ZodEnum<{
|
|
7
|
+
card: "card";
|
|
8
|
+
offline: "offline";
|
|
9
|
+
other: "other";
|
|
10
|
+
wallet: "wallet";
|
|
11
|
+
}>;
|
|
12
|
+
sortOrder: z.ZodNumber;
|
|
13
|
+
brands: z.ZodArray<z.ZodString>;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
export declare const StorefrontPaymentMethodsSchema: z.ZodArray<z.ZodObject<{
|
|
16
|
+
code: z.ZodString;
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
kind: z.ZodEnum<{
|
|
19
|
+
card: "card";
|
|
20
|
+
offline: "offline";
|
|
21
|
+
other: "other";
|
|
22
|
+
wallet: "wallet";
|
|
23
|
+
}>;
|
|
24
|
+
sortOrder: z.ZodNumber;
|
|
25
|
+
brands: z.ZodArray<z.ZodString>;
|
|
26
|
+
}, z.core.$strict>>;
|
|
27
|
+
export type StorefrontPaymentMethod = z.infer<typeof StorefrontPaymentMethodSchema>;
|
|
28
|
+
export type StorefrontPaymentMethods = z.infer<typeof StorefrontPaymentMethodsSchema>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { EntityIdSchema, NullableEntityIdSchema } from "./ids.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// src/models/personalization.ts
|
|
4
|
+
const ModifierSelectionTypeSchema = z.enum([
|
|
5
|
+
"single",
|
|
6
|
+
"multiple",
|
|
7
|
+
"text"
|
|
8
|
+
]);
|
|
9
|
+
const ModifierDisplaySchema = z.enum([
|
|
10
|
+
"list",
|
|
11
|
+
"color",
|
|
12
|
+
"image",
|
|
13
|
+
"font"
|
|
14
|
+
]);
|
|
15
|
+
const ModifierOptionItemSchema = z.object({
|
|
16
|
+
id: EntityIdSchema,
|
|
17
|
+
name: z.string(),
|
|
18
|
+
priceDelta: z.number(),
|
|
19
|
+
isDefault: z.boolean(),
|
|
20
|
+
color: z.string().nullable(),
|
|
21
|
+
fileUrl: z.string().nullable(),
|
|
22
|
+
fileName: z.string().nullable(),
|
|
23
|
+
tag: z.string().nullable(),
|
|
24
|
+
maxQuantity: z.number().int().positive()
|
|
25
|
+
});
|
|
26
|
+
const ModifierGroupItemSchema = z.object({
|
|
27
|
+
id: EntityIdSchema,
|
|
28
|
+
name: z.string(),
|
|
29
|
+
description: z.string().nullable(),
|
|
30
|
+
selectionType: ModifierSelectionTypeSchema,
|
|
31
|
+
display: ModifierDisplaySchema,
|
|
32
|
+
isRequired: z.boolean(),
|
|
33
|
+
minSelections: z.number().int().nonnegative(),
|
|
34
|
+
maxSelections: z.number().int().positive().nullable(),
|
|
35
|
+
maxLength: z.number().int().positive().nullable(),
|
|
36
|
+
priceDelta: z.number(),
|
|
37
|
+
options: z.array(ModifierOptionItemSchema)
|
|
38
|
+
});
|
|
39
|
+
const ItemModifierSchema = z.object({
|
|
40
|
+
modifierGroupId: EntityIdSchema,
|
|
41
|
+
modifierGroupName: z.string(),
|
|
42
|
+
modifierOptionId: NullableEntityIdSchema,
|
|
43
|
+
modifierOptionName: z.string().nullable(),
|
|
44
|
+
value: z.string().nullable(),
|
|
45
|
+
quantity: z.number().int().positive(),
|
|
46
|
+
priceDelta: z.number()
|
|
47
|
+
});
|
|
48
|
+
function roundMoney(value) {
|
|
49
|
+
return Math.round(value * 100) / 100;
|
|
50
|
+
}
|
|
51
|
+
/** Extra charged per unit for the line's customizations. */
|
|
52
|
+
function modifiersUnitPrice(modifiers) {
|
|
53
|
+
return roundMoney(modifiers.reduce((sum, modifier) => sum + modifier.priceDelta * modifier.quantity, 0));
|
|
54
|
+
}
|
|
55
|
+
/** Unit price of the line with its customizations. */
|
|
56
|
+
function lineUnitPrice(line) {
|
|
57
|
+
return roundMoney(line.unitPrice + modifiersUnitPrice(line.modifiers));
|
|
58
|
+
}
|
|
59
|
+
/** Line total with its customizations, before discounts. */
|
|
60
|
+
function lineTotal(line) {
|
|
61
|
+
return roundMoney(lineUnitPrice(line) * line.quantity);
|
|
62
|
+
}
|
|
63
|
+
/** What the buyer chose or typed, with the option quantity when it is more than one. */
|
|
64
|
+
function modifierLabel(modifier) {
|
|
65
|
+
const label = modifier.value ?? modifier.modifierOptionName ?? "";
|
|
66
|
+
if (modifier.quantity > 1) return `${label} × ${modifier.quantity}`;
|
|
67
|
+
return label;
|
|
68
|
+
}
|
|
69
|
+
export { ItemModifierSchema, ModifierDisplaySchema, ModifierGroupItemSchema, ModifierOptionItemSchema, ModifierSelectionTypeSchema, lineTotal, lineUnitPrice, modifierLabel, modifiersUnitPrice };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const require_models_ids = require("./ids.cjs");
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
// src/models/personalization.ts
|
|
4
|
+
const ModifierSelectionTypeSchema = zod.z.enum([
|
|
5
|
+
"single",
|
|
6
|
+
"multiple",
|
|
7
|
+
"text"
|
|
8
|
+
]);
|
|
9
|
+
const ModifierDisplaySchema = zod.z.enum([
|
|
10
|
+
"list",
|
|
11
|
+
"color",
|
|
12
|
+
"image",
|
|
13
|
+
"font"
|
|
14
|
+
]);
|
|
15
|
+
const ModifierOptionItemSchema = zod.z.object({
|
|
16
|
+
id: require_models_ids.EntityIdSchema,
|
|
17
|
+
name: zod.z.string(),
|
|
18
|
+
priceDelta: zod.z.number(),
|
|
19
|
+
isDefault: zod.z.boolean(),
|
|
20
|
+
color: zod.z.string().nullable(),
|
|
21
|
+
fileUrl: zod.z.string().nullable(),
|
|
22
|
+
fileName: zod.z.string().nullable(),
|
|
23
|
+
tag: zod.z.string().nullable(),
|
|
24
|
+
maxQuantity: zod.z.number().int().positive()
|
|
25
|
+
});
|
|
26
|
+
const ModifierGroupItemSchema = zod.z.object({
|
|
27
|
+
id: require_models_ids.EntityIdSchema,
|
|
28
|
+
name: zod.z.string(),
|
|
29
|
+
description: zod.z.string().nullable(),
|
|
30
|
+
selectionType: ModifierSelectionTypeSchema,
|
|
31
|
+
display: ModifierDisplaySchema,
|
|
32
|
+
isRequired: zod.z.boolean(),
|
|
33
|
+
minSelections: zod.z.number().int().nonnegative(),
|
|
34
|
+
maxSelections: zod.z.number().int().positive().nullable(),
|
|
35
|
+
maxLength: zod.z.number().int().positive().nullable(),
|
|
36
|
+
priceDelta: zod.z.number(),
|
|
37
|
+
options: zod.z.array(ModifierOptionItemSchema)
|
|
38
|
+
});
|
|
39
|
+
const ItemModifierSchema = zod.z.object({
|
|
40
|
+
modifierGroupId: require_models_ids.EntityIdSchema,
|
|
41
|
+
modifierGroupName: zod.z.string(),
|
|
42
|
+
modifierOptionId: require_models_ids.NullableEntityIdSchema,
|
|
43
|
+
modifierOptionName: zod.z.string().nullable(),
|
|
44
|
+
value: zod.z.string().nullable(),
|
|
45
|
+
quantity: zod.z.number().int().positive(),
|
|
46
|
+
priceDelta: zod.z.number()
|
|
47
|
+
});
|
|
48
|
+
function roundMoney(value) {
|
|
49
|
+
return Math.round(value * 100) / 100;
|
|
50
|
+
}
|
|
51
|
+
/** Extra charged per unit for the line's customizations. */
|
|
52
|
+
function modifiersUnitPrice(modifiers) {
|
|
53
|
+
return roundMoney(modifiers.reduce((sum, modifier) => sum + modifier.priceDelta * modifier.quantity, 0));
|
|
54
|
+
}
|
|
55
|
+
/** Unit price of the line with its customizations. */
|
|
56
|
+
function lineUnitPrice(line) {
|
|
57
|
+
return roundMoney(line.unitPrice + modifiersUnitPrice(line.modifiers));
|
|
58
|
+
}
|
|
59
|
+
/** Line total with its customizations, before discounts. */
|
|
60
|
+
function lineTotal(line) {
|
|
61
|
+
return roundMoney(lineUnitPrice(line) * line.quantity);
|
|
62
|
+
}
|
|
63
|
+
/** What the buyer chose or typed, with the option quantity when it is more than one. */
|
|
64
|
+
function modifierLabel(modifier) {
|
|
65
|
+
const label = modifier.value ?? modifier.modifierOptionName ?? "";
|
|
66
|
+
if (modifier.quantity > 1) return `${label} × ${modifier.quantity}`;
|
|
67
|
+
return label;
|
|
68
|
+
}
|
|
69
|
+
exports.ItemModifierSchema = ItemModifierSchema;
|
|
70
|
+
exports.ModifierDisplaySchema = ModifierDisplaySchema;
|
|
71
|
+
exports.ModifierGroupItemSchema = ModifierGroupItemSchema;
|
|
72
|
+
exports.ModifierOptionItemSchema = ModifierOptionItemSchema;
|
|
73
|
+
exports.ModifierSelectionTypeSchema = ModifierSelectionTypeSchema;
|
|
74
|
+
exports.lineTotal = lineTotal;
|
|
75
|
+
exports.lineUnitPrice = lineUnitPrice;
|
|
76
|
+
exports.modifierLabel = modifierLabel;
|
|
77
|
+
exports.modifiersUnitPrice = modifiersUnitPrice;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ModifierSelectionTypeSchema: z.ZodEnum<{
|
|
3
|
+
multiple: "multiple";
|
|
4
|
+
single: "single";
|
|
5
|
+
text: "text";
|
|
6
|
+
}>;
|
|
7
|
+
export declare const ModifierDisplaySchema: z.ZodEnum<{
|
|
8
|
+
color: "color";
|
|
9
|
+
font: "font";
|
|
10
|
+
image: "image";
|
|
11
|
+
list: "list";
|
|
12
|
+
}>;
|
|
13
|
+
export declare const ModifierOptionItemSchema: z.ZodObject<{
|
|
14
|
+
id: z.ZodString;
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
priceDelta: z.ZodNumber;
|
|
17
|
+
isDefault: z.ZodBoolean;
|
|
18
|
+
color: z.ZodNullable<z.ZodString>;
|
|
19
|
+
fileUrl: z.ZodNullable<z.ZodString>;
|
|
20
|
+
fileName: z.ZodNullable<z.ZodString>;
|
|
21
|
+
tag: z.ZodNullable<z.ZodString>;
|
|
22
|
+
maxQuantity: z.ZodNumber;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const ModifierGroupItemSchema: z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
description: z.ZodNullable<z.ZodString>;
|
|
28
|
+
selectionType: z.ZodEnum<{
|
|
29
|
+
multiple: "multiple";
|
|
30
|
+
single: "single";
|
|
31
|
+
text: "text";
|
|
32
|
+
}>;
|
|
33
|
+
display: z.ZodEnum<{
|
|
34
|
+
color: "color";
|
|
35
|
+
font: "font";
|
|
36
|
+
image: "image";
|
|
37
|
+
list: "list";
|
|
38
|
+
}>;
|
|
39
|
+
isRequired: z.ZodBoolean;
|
|
40
|
+
minSelections: z.ZodNumber;
|
|
41
|
+
maxSelections: z.ZodNullable<z.ZodNumber>;
|
|
42
|
+
maxLength: z.ZodNullable<z.ZodNumber>;
|
|
43
|
+
priceDelta: z.ZodNumber;
|
|
44
|
+
options: z.ZodArray<z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
priceDelta: z.ZodNumber;
|
|
48
|
+
isDefault: z.ZodBoolean;
|
|
49
|
+
color: z.ZodNullable<z.ZodString>;
|
|
50
|
+
fileUrl: z.ZodNullable<z.ZodString>;
|
|
51
|
+
fileName: z.ZodNullable<z.ZodString>;
|
|
52
|
+
tag: z.ZodNullable<z.ZodString>;
|
|
53
|
+
maxQuantity: z.ZodNumber;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
export declare const ItemModifierSchema: z.ZodObject<{
|
|
57
|
+
modifierGroupId: z.ZodString;
|
|
58
|
+
modifierGroupName: z.ZodString;
|
|
59
|
+
modifierOptionId: z.ZodNullable<z.ZodString>;
|
|
60
|
+
modifierOptionName: z.ZodNullable<z.ZodString>;
|
|
61
|
+
value: z.ZodNullable<z.ZodString>;
|
|
62
|
+
quantity: z.ZodNumber;
|
|
63
|
+
priceDelta: z.ZodNumber;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export type ModifierSelectionType = z.infer<typeof ModifierSelectionTypeSchema>;
|
|
66
|
+
export type ModifierDisplay = z.infer<typeof ModifierDisplaySchema>;
|
|
67
|
+
export type ModifierOptionItem = z.infer<typeof ModifierOptionItemSchema>;
|
|
68
|
+
export type ModifierGroupItem = z.infer<typeof ModifierGroupItemSchema>;
|
|
69
|
+
export type ItemModifier = z.infer<typeof ItemModifierSchema>;
|
|
70
|
+
type PricedLine = {
|
|
71
|
+
unitPrice: number;
|
|
72
|
+
quantity: number;
|
|
73
|
+
modifiers: readonly Pick<ItemModifier, 'priceDelta' | 'quantity'>[];
|
|
74
|
+
};
|
|
75
|
+
/** Extra charged per unit for the line's customizations. */
|
|
76
|
+
export declare function modifiersUnitPrice(modifiers: PricedLine['modifiers']): number;
|
|
77
|
+
/** Unit price of the line with its customizations. */
|
|
78
|
+
export declare function lineUnitPrice(line: Omit<PricedLine, 'quantity'>): number;
|
|
79
|
+
/** Line total with its customizations, before discounts. */
|
|
80
|
+
export declare function lineTotal(line: PricedLine): number;
|
|
81
|
+
/** What the buyer chose or typed, with the option quantity when it is more than one. */
|
|
82
|
+
export declare function modifierLabel(modifier: Pick<ItemModifier, 'value' | 'modifierOptionName' | 'quantity'>): string;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ModifierSelectionTypeSchema: z.ZodEnum<{
|
|
3
|
+
multiple: "multiple";
|
|
4
|
+
single: "single";
|
|
5
|
+
text: "text";
|
|
6
|
+
}>;
|
|
7
|
+
export declare const ModifierDisplaySchema: z.ZodEnum<{
|
|
8
|
+
color: "color";
|
|
9
|
+
font: "font";
|
|
10
|
+
image: "image";
|
|
11
|
+
list: "list";
|
|
12
|
+
}>;
|
|
13
|
+
export declare const ModifierOptionItemSchema: z.ZodObject<{
|
|
14
|
+
id: z.ZodString;
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
priceDelta: z.ZodNumber;
|
|
17
|
+
isDefault: z.ZodBoolean;
|
|
18
|
+
color: z.ZodNullable<z.ZodString>;
|
|
19
|
+
fileUrl: z.ZodNullable<z.ZodString>;
|
|
20
|
+
fileName: z.ZodNullable<z.ZodString>;
|
|
21
|
+
tag: z.ZodNullable<z.ZodString>;
|
|
22
|
+
maxQuantity: z.ZodNumber;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const ModifierGroupItemSchema: z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
description: z.ZodNullable<z.ZodString>;
|
|
28
|
+
selectionType: z.ZodEnum<{
|
|
29
|
+
multiple: "multiple";
|
|
30
|
+
single: "single";
|
|
31
|
+
text: "text";
|
|
32
|
+
}>;
|
|
33
|
+
display: z.ZodEnum<{
|
|
34
|
+
color: "color";
|
|
35
|
+
font: "font";
|
|
36
|
+
image: "image";
|
|
37
|
+
list: "list";
|
|
38
|
+
}>;
|
|
39
|
+
isRequired: z.ZodBoolean;
|
|
40
|
+
minSelections: z.ZodNumber;
|
|
41
|
+
maxSelections: z.ZodNullable<z.ZodNumber>;
|
|
42
|
+
maxLength: z.ZodNullable<z.ZodNumber>;
|
|
43
|
+
priceDelta: z.ZodNumber;
|
|
44
|
+
options: z.ZodArray<z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
priceDelta: z.ZodNumber;
|
|
48
|
+
isDefault: z.ZodBoolean;
|
|
49
|
+
color: z.ZodNullable<z.ZodString>;
|
|
50
|
+
fileUrl: z.ZodNullable<z.ZodString>;
|
|
51
|
+
fileName: z.ZodNullable<z.ZodString>;
|
|
52
|
+
tag: z.ZodNullable<z.ZodString>;
|
|
53
|
+
maxQuantity: z.ZodNumber;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
export declare const ItemModifierSchema: z.ZodObject<{
|
|
57
|
+
modifierGroupId: z.ZodString;
|
|
58
|
+
modifierGroupName: z.ZodString;
|
|
59
|
+
modifierOptionId: z.ZodNullable<z.ZodString>;
|
|
60
|
+
modifierOptionName: z.ZodNullable<z.ZodString>;
|
|
61
|
+
value: z.ZodNullable<z.ZodString>;
|
|
62
|
+
quantity: z.ZodNumber;
|
|
63
|
+
priceDelta: z.ZodNumber;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export type ModifierSelectionType = z.infer<typeof ModifierSelectionTypeSchema>;
|
|
66
|
+
export type ModifierDisplay = z.infer<typeof ModifierDisplaySchema>;
|
|
67
|
+
export type ModifierOptionItem = z.infer<typeof ModifierOptionItemSchema>;
|
|
68
|
+
export type ModifierGroupItem = z.infer<typeof ModifierGroupItemSchema>;
|
|
69
|
+
export type ItemModifier = z.infer<typeof ItemModifierSchema>;
|
|
70
|
+
type PricedLine = {
|
|
71
|
+
unitPrice: number;
|
|
72
|
+
quantity: number;
|
|
73
|
+
modifiers: readonly Pick<ItemModifier, 'priceDelta' | 'quantity'>[];
|
|
74
|
+
};
|
|
75
|
+
/** Extra charged per unit for the line's customizations. */
|
|
76
|
+
export declare function modifiersUnitPrice(modifiers: PricedLine['modifiers']): number;
|
|
77
|
+
/** Unit price of the line with its customizations. */
|
|
78
|
+
export declare function lineUnitPrice(line: Omit<PricedLine, 'quantity'>): number;
|
|
79
|
+
/** Line total with its customizations, before discounts. */
|
|
80
|
+
export declare function lineTotal(line: PricedLine): number;
|
|
81
|
+
/** What the buyer chose or typed, with the option quantity when it is more than one. */
|
|
82
|
+
export declare function modifierLabel(modifier: Pick<ItemModifier, 'value' | 'modifierOptionName' | 'quantity'>): string;
|
|
83
|
+
export {};
|