@endora-commerce/contracts 0.109.0 → 0.111.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/dist/accept-language.d.ts +31 -0
- package/dist/accept-language.js +64 -0
- package/dist/actor.d.ts +16 -0
- package/dist/addresses.d.ts +35 -0
- package/dist/addresses.js +8 -1
- package/dist/admin-actions.d.ts +2 -0
- package/dist/admin-actions.js +18 -0
- package/dist/admin-contributions.d.ts +99 -12
- package/dist/admin-contributions.js +36 -10
- package/dist/admin-roles.d.ts +17 -2
- package/dist/admin-users.d.ts +9 -0
- package/dist/admin.d.ts +114 -4
- package/dist/admin.js +98 -3
- package/dist/api-keys.d.ts +22 -0
- package/dist/api-keys.js +4 -0
- package/dist/assets-library.d.ts +45 -0
- package/dist/assets-library.js +20 -3
- package/dist/audit-logs.d.ts +12 -0
- package/dist/audit-logs.js +12 -0
- package/dist/auth.d.ts +9 -0
- package/dist/auth.js +9 -0
- package/dist/blog.d.ts +382 -22
- package/dist/blog.js +199 -17
- package/dist/carts.d.ts +423 -36
- package/dist/carts.js +150 -12
- package/dist/catalog.d.ts +379 -208
- package/dist/catalog.js +241 -163
- package/dist/cms-brand.d.ts +14 -14
- package/dist/cms.d.ts +71 -16
- package/dist/cms.js +15 -0
- package/dist/command-hooks.d.ts +301 -0
- package/dist/command-hooks.js +248 -0
- package/dist/common.d.ts +23 -6
- package/dist/common.js +25 -2
- package/dist/comparisons.d.ts +21 -14
- package/dist/comparisons.js +2 -1
- package/dist/credit-limits.d.ts +22 -0
- package/dist/credit-limits.js +35 -0
- package/dist/crm.d.ts +134 -78
- package/dist/crm.js +21 -5
- package/dist/custom-fields.d.ts +417 -49
- package/dist/custom-fields.js +142 -1
- package/dist/customer-accounts.d.ts +324 -22
- package/dist/customer-accounts.js +43 -0
- package/dist/customer-notifications.d.ts +143 -0
- package/dist/customer-notifications.js +41 -0
- package/dist/customers.d.ts +92 -73
- package/dist/customers.js +98 -10
- package/dist/dictionary.d.ts +53 -0
- package/dist/dictionary.js +25 -0
- package/dist/document-templates.d.ts +12 -12
- package/dist/email.d.ts +34 -0
- package/dist/email.js +6 -0
- package/dist/errors.d.ts +431 -3
- package/dist/errors.js +523 -3
- package/dist/forms-logic.d.ts +79 -0
- package/dist/forms-logic.fixtures.d.ts +52 -0
- package/dist/forms-logic.fixtures.js +610 -0
- package/dist/forms-logic.js +699 -0
- package/dist/forms.d.ts +9833 -0
- package/dist/forms.js +827 -0
- package/dist/i18n.d.ts +34 -0
- package/dist/i18n.js +15 -0
- package/dist/import-export.d.ts +180 -0
- package/dist/import-export.js +60 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.js +30 -1
- package/dist/inventory.d.ts +9 -9
- package/dist/invoice-ledger.d.ts +13 -13
- package/dist/invoices.d.ts +126 -0
- package/dist/invoices.js +53 -0
- package/dist/line-bounds.d.ts +53 -0
- package/dist/line-bounds.js +65 -0
- package/dist/megamenu.d.ts +27 -27
- package/dist/mfa.d.ts +210 -4
- package/dist/mfa.js +136 -0
- package/dist/modules.d.ts +56 -8
- package/dist/modules.js +128 -3
- package/dist/money-decimal.d.ts +54 -0
- package/dist/money-decimal.js +95 -0
- package/dist/newsletter.d.ts +4 -4
- package/dist/orders.d.ts +246 -12
- package/dist/orders.js +140 -7
- package/dist/organization-hooks.d.ts +99 -0
- package/dist/organization-hooks.js +22 -0
- package/dist/organization-registry-lookup.d.ts +362 -0
- package/dist/organization-registry-lookup.js +196 -0
- package/dist/organization-roles.d.ts +341 -0
- package/dist/organization-roles.js +218 -0
- package/dist/organizations.d.ts +1074 -103
- package/dist/organizations.js +293 -28
- package/dist/page-builder-props.d.ts +56 -56
- package/dist/pim-connector.d.ts +7 -3
- package/dist/pim-connector.js +6 -2
- package/dist/pim-field-path.d.ts +5 -1
- package/dist/pim-field-path.js +37 -81
- package/dist/pim-locale-mapping.d.ts +131 -0
- package/dist/pim-locale-mapping.js +193 -0
- package/dist/price-books.d.ts +215 -63
- package/dist/price-books.js +47 -2
- package/dist/price-lists.d.ts +13 -10
- package/dist/product-feeds.d.ts +249 -100
- package/dist/product-feeds.js +46 -2
- package/dist/product-scope-model.d.ts +161 -0
- package/dist/product-scope-model.js +161 -0
- package/dist/product-scope-overrides.d.ts +0 -103
- package/dist/product-scope-overrides.js +0 -54
- package/dist/product-scoped-values.d.ts +2610 -0
- package/dist/product-scoped-values.js +425 -0
- package/dist/product-scopes.d.ts +199 -64
- package/dist/product-scopes.js +120 -23
- package/dist/product-tax-rates.d.ts +38 -0
- package/dist/product-tax-rates.js +45 -0
- package/dist/product-url-keys.d.ts +51 -45
- package/dist/product-url-keys.js +73 -39
- package/dist/product-value-resolver.d.ts +37 -60
- package/dist/product-value-resolver.js +36 -96
- package/dist/projects.d.ts +76 -28
- package/dist/projects.js +53 -9
- package/dist/promotions.d.ts +163 -11
- package/dist/promotions.js +23 -1
- package/dist/pwa.d.ts +41 -2
- package/dist/quick-order.d.ts +159 -9
- package/dist/quick-order.js +79 -4
- package/dist/quote-requests.d.ts +231 -17
- package/dist/quote-requests.js +111 -9
- package/dist/record-references.d.ts +15 -15
- package/dist/record-references.js +2 -3
- package/dist/record-rich-text.js +2 -1
- package/dist/returns.d.ts +214 -52
- package/dist/returns.js +143 -28
- package/dist/sales-channels.d.ts +34 -3
- package/dist/sales-channels.js +16 -1
- package/dist/saved-list-views.d.ts +28 -0
- package/dist/saved-list-views.js +14 -1
- package/dist/schema-extensions.d.ts +36 -0
- package/dist/schema-extensions.js +29 -0
- package/dist/scoped-write-encoding.d.ts +100 -0
- package/dist/scoped-write-encoding.js +135 -0
- package/dist/search.d.ts +18 -16
- package/dist/seo.d.ts +83 -30
- package/dist/seo.js +8 -1
- package/dist/settings.d.ts +173 -2
- package/dist/settings.js +53 -2
- package/dist/shopping-lists.d.ts +63 -4
- package/dist/shopping-lists.js +57 -3
- package/dist/storefront-cache-tags.d.ts +22 -0
- package/dist/storefront-cache-tags.js +12 -0
- package/dist/storefront-value-overrides.d.ts +18 -56
- package/dist/storefront-value-overrides.js +11 -86
- package/dist/tasks.d.ts +27 -27
- package/dist/taxes.d.ts +27 -0
- package/dist/taxes.js +4 -0
- package/dist/transactional-emails.d.ts +48 -22
- package/dist/webhooks.d.ts +75 -0
- package/dist/webhooks.js +24 -0
- package/package.json +5 -3
- package/dist/actor.d.ts.map +0 -1
- package/dist/actor.js.map +0 -1
- package/dist/addresses.d.ts.map +0 -1
- package/dist/addresses.js.map +0 -1
- package/dist/admin-actions.d.ts.map +0 -1
- package/dist/admin-actions.js.map +0 -1
- package/dist/admin-contributions.d.ts.map +0 -1
- package/dist/admin-contributions.js.map +0 -1
- package/dist/admin-feedback.d.ts.map +0 -1
- package/dist/admin-feedback.js.map +0 -1
- package/dist/admin-i18n.d.ts.map +0 -1
- package/dist/admin-i18n.js.map +0 -1
- package/dist/admin-name.d.ts.map +0 -1
- package/dist/admin-name.js.map +0 -1
- package/dist/admin-notifications.d.ts.map +0 -1
- package/dist/admin-notifications.js.map +0 -1
- package/dist/admin-preferences.d.ts.map +0 -1
- package/dist/admin-preferences.js.map +0 -1
- package/dist/admin-roles.d.ts.map +0 -1
- package/dist/admin-roles.js.map +0 -1
- package/dist/admin-search.d.ts.map +0 -1
- package/dist/admin-search.js.map +0 -1
- package/dist/admin-users.d.ts.map +0 -1
- package/dist/admin-users.js.map +0 -1
- package/dist/admin.d.ts.map +0 -1
- package/dist/admin.js.map +0 -1
- package/dist/analytics.d.ts.map +0 -1
- package/dist/analytics.js.map +0 -1
- package/dist/api-keys.d.ts.map +0 -1
- package/dist/api-keys.js.map +0 -1
- package/dist/assets-library.d.ts.map +0 -1
- package/dist/assets-library.js.map +0 -1
- package/dist/audit-logs.d.ts.map +0 -1
- package/dist/audit-logs.js.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/blog.d.ts.map +0 -1
- package/dist/blog.js.map +0 -1
- package/dist/capabilities.d.ts.map +0 -1
- package/dist/capabilities.js.map +0 -1
- package/dist/carts.d.ts.map +0 -1
- package/dist/carts.js.map +0 -1
- package/dist/catalog.d.ts.map +0 -1
- package/dist/catalog.js.map +0 -1
- package/dist/cms-brand.d.ts.map +0 -1
- package/dist/cms-brand.js.map +0 -1
- package/dist/cms-contact-form.d.ts.map +0 -1
- package/dist/cms-contact-form.js.map +0 -1
- package/dist/cms.d.ts.map +0 -1
- package/dist/cms.js.map +0 -1
- package/dist/common.d.ts.map +0 -1
- package/dist/common.js.map +0 -1
- package/dist/comparisons.d.ts.map +0 -1
- package/dist/comparisons.js.map +0 -1
- package/dist/credentials.d.ts.map +0 -1
- package/dist/credentials.js.map +0 -1
- package/dist/credit-limits.d.ts.map +0 -1
- package/dist/credit-limits.js.map +0 -1
- package/dist/crm-rich-text.d.ts.map +0 -1
- package/dist/crm-rich-text.js.map +0 -1
- package/dist/crm.d.ts.map +0 -1
- package/dist/crm.js.map +0 -1
- package/dist/currencies.d.ts.map +0 -1
- package/dist/currencies.js.map +0 -1
- package/dist/custom-fields.d.ts.map +0 -1
- package/dist/custom-fields.js.map +0 -1
- package/dist/customer-accounts.d.ts.map +0 -1
- package/dist/customer-accounts.js.map +0 -1
- package/dist/customers.d.ts.map +0 -1
- package/dist/customers.js.map +0 -1
- package/dist/dictionary.d.ts.map +0 -1
- package/dist/dictionary.js.map +0 -1
- package/dist/document-templates.d.ts.map +0 -1
- package/dist/document-templates.js.map +0 -1
- package/dist/document-values.d.ts.map +0 -1
- package/dist/document-values.js.map +0 -1
- package/dist/email-address.d.ts.map +0 -1
- package/dist/email-address.js.map +0 -1
- package/dist/email.d.ts.map +0 -1
- package/dist/email.js.map +0 -1
- package/dist/envelopes.d.ts.map +0 -1
- package/dist/envelopes.js.map +0 -1
- package/dist/environment-inputs.d.ts.map +0 -1
- package/dist/environment-inputs.js.map +0 -1
- package/dist/erp-connector.d.ts.map +0 -1
- package/dist/erp-connector.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/google-analytics.d.ts.map +0 -1
- package/dist/google-analytics.js.map +0 -1
- package/dist/google-tag-manager.d.ts.map +0 -1
- package/dist/google-tag-manager.js.map +0 -1
- package/dist/i18n.d.ts.map +0 -1
- package/dist/i18n.js.map +0 -1
- package/dist/import-export.d.ts.map +0 -1
- package/dist/import-export.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inventory.d.ts.map +0 -1
- package/dist/inventory.js.map +0 -1
- package/dist/invoice-ledger.d.ts.map +0 -1
- package/dist/invoice-ledger.js.map +0 -1
- package/dist/invoices.d.ts.map +0 -1
- package/dist/invoices.js.map +0 -1
- package/dist/kernel.d.ts.map +0 -1
- package/dist/kernel.js.map +0 -1
- package/dist/languages.d.ts.map +0 -1
- package/dist/languages.js.map +0 -1
- package/dist/line-groups.d.ts.map +0 -1
- package/dist/line-groups.js.map +0 -1
- package/dist/linkedin-ads.d.ts.map +0 -1
- package/dist/linkedin-ads.js.map +0 -1
- package/dist/localized-name.d.ts.map +0 -1
- package/dist/localized-name.js.map +0 -1
- package/dist/megamenu.d.ts.map +0 -1
- package/dist/megamenu.js.map +0 -1
- package/dist/meta-ads.d.ts.map +0 -1
- package/dist/meta-ads.js.map +0 -1
- package/dist/mfa.d.ts.map +0 -1
- package/dist/mfa.js.map +0 -1
- package/dist/modules.d.ts.map +0 -1
- package/dist/modules.js.map +0 -1
- package/dist/money-decimal.d.ts.map +0 -1
- package/dist/money-decimal.js.map +0 -1
- package/dist/money-input.d.ts.map +0 -1
- package/dist/money-input.js.map +0 -1
- package/dist/newsletter.d.ts.map +0 -1
- package/dist/newsletter.js.map +0 -1
- package/dist/order-minimums.d.ts.map +0 -1
- package/dist/order-minimums.js.map +0 -1
- package/dist/orders.d.ts.map +0 -1
- package/dist/orders.js.map +0 -1
- package/dist/organizations.d.ts.map +0 -1
- package/dist/organizations.js.map +0 -1
- package/dist/page-builder-props.d.ts.map +0 -1
- package/dist/page-builder-props.js.map +0 -1
- package/dist/page-builder-values.d.ts.map +0 -1
- package/dist/page-builder-values.js.map +0 -1
- package/dist/pagination.d.ts.map +0 -1
- package/dist/pagination.js.map +0 -1
- package/dist/payment-methods.d.ts.map +0 -1
- package/dist/payment-methods.js.map +0 -1
- package/dist/payment-return-url.d.ts.map +0 -1
- package/dist/payment-return-url.js.map +0 -1
- package/dist/payments.d.ts.map +0 -1
- package/dist/payments.js.map +0 -1
- package/dist/pim-connector.d.ts.map +0 -1
- package/dist/pim-connector.js.map +0 -1
- package/dist/pim-field-path.d.ts.map +0 -1
- package/dist/pim-field-path.js.map +0 -1
- package/dist/platform-info.d.ts.map +0 -1
- package/dist/platform-info.js.map +0 -1
- package/dist/platform-language.d.ts.map +0 -1
- package/dist/platform-language.js.map +0 -1
- package/dist/price-book-decimal.d.ts.map +0 -1
- package/dist/price-book-decimal.js.map +0 -1
- package/dist/price-books.d.ts.map +0 -1
- package/dist/price-books.js.map +0 -1
- package/dist/price-lists.d.ts.map +0 -1
- package/dist/price-lists.js.map +0 -1
- package/dist/product-feeds.d.ts.map +0 -1
- package/dist/product-feeds.js.map +0 -1
- package/dist/product-scope-overrides.d.ts.map +0 -1
- package/dist/product-scope-overrides.js.map +0 -1
- package/dist/product-scopes.d.ts.map +0 -1
- package/dist/product-scopes.js.map +0 -1
- package/dist/product-summary-text.d.ts.map +0 -1
- package/dist/product-summary-text.js.map +0 -1
- package/dist/product-url-keys.d.ts.map +0 -1
- package/dist/product-url-keys.js.map +0 -1
- package/dist/product-value-resolver.d.ts.map +0 -1
- package/dist/product-value-resolver.js.map +0 -1
- package/dist/projects.d.ts.map +0 -1
- package/dist/projects.js.map +0 -1
- package/dist/promotions.d.ts.map +0 -1
- package/dist/promotions.js.map +0 -1
- package/dist/prompt-actions.d.ts.map +0 -1
- package/dist/prompt-actions.js.map +0 -1
- package/dist/pwa.d.ts.map +0 -1
- package/dist/pwa.js.map +0 -1
- package/dist/quick-order.d.ts.map +0 -1
- package/dist/quick-order.js.map +0 -1
- package/dist/quote-requests.d.ts.map +0 -1
- package/dist/quote-requests.js.map +0 -1
- package/dist/record-references.d.ts.map +0 -1
- package/dist/record-references.js.map +0 -1
- package/dist/record-rich-text.d.ts.map +0 -1
- package/dist/record-rich-text.js.map +0 -1
- package/dist/returns.d.ts.map +0 -1
- package/dist/returns.js.map +0 -1
- package/dist/sales-channels.d.ts.map +0 -1
- package/dist/sales-channels.js.map +0 -1
- package/dist/saved-list-views.d.ts.map +0 -1
- package/dist/saved-list-views.js.map +0 -1
- package/dist/scope-notice.d.ts.map +0 -1
- package/dist/scope-notice.js.map +0 -1
- package/dist/scoped-translations.d.ts +0 -48
- package/dist/scoped-translations.d.ts.map +0 -1
- package/dist/scoped-translations.js +0 -78
- package/dist/scoped-translations.js.map +0 -1
- package/dist/search.d.ts.map +0 -1
- package/dist/search.js.map +0 -1
- package/dist/seo.d.ts.map +0 -1
- package/dist/seo.js.map +0 -1
- package/dist/settings.d.ts.map +0 -1
- package/dist/settings.js.map +0 -1
- package/dist/shipments.d.ts.map +0 -1
- package/dist/shipments.js.map +0 -1
- package/dist/shipping-methods.d.ts.map +0 -1
- package/dist/shipping-methods.js.map +0 -1
- package/dist/shopping-lists.d.ts.map +0 -1
- package/dist/shopping-lists.js.map +0 -1
- package/dist/storefront-cache-tags.d.ts.map +0 -1
- package/dist/storefront-cache-tags.js.map +0 -1
- package/dist/storefront-language-path.d.ts.map +0 -1
- package/dist/storefront-language-path.js.map +0 -1
- package/dist/storefront-value-overrides.d.ts.map +0 -1
- package/dist/storefront-value-overrides.js.map +0 -1
- package/dist/tasks.d.ts.map +0 -1
- package/dist/tasks.js.map +0 -1
- package/dist/taxes.d.ts.map +0 -1
- package/dist/taxes.js.map +0 -1
- package/dist/text-normalization.d.ts.map +0 -1
- package/dist/text-normalization.js.map +0 -1
- package/dist/transactional-emails.d.ts.map +0 -1
- package/dist/transactional-emails.js.map +0 -1
- package/dist/webhooks.d.ts.map +0 -1
- package/dist/webhooks.js.map +0 -1
package/dist/orders.d.ts
CHANGED
|
@@ -73,6 +73,91 @@ export declare const orderPendingEffectSchema: z.ZodObject<{
|
|
|
73
73
|
lastAttemptAt: z.ZodNullable<z.ZodString>;
|
|
74
74
|
}, z.core.$strip>;
|
|
75
75
|
export type OrderPendingEffect = z.infer<typeof orderPendingEffectSchema>;
|
|
76
|
+
/**
|
|
77
|
+
* Where an external system — an ERP, a WMS, a fulfilment connector — stands
|
|
78
|
+
* with an order, as that system's integration last reported it: handed over
|
|
79
|
+
* and not answered yet, accepted, or refused.
|
|
80
|
+
*/
|
|
81
|
+
export declare const ORDER_EXTERNAL_REFERENCE_STATES: readonly ["pending", "synced", "error"];
|
|
82
|
+
export type OrderExternalReferenceState = (typeof ORDER_EXTERNAL_REFERENCE_STATES)[number];
|
|
83
|
+
/** The longest message an integration may record, in characters. */
|
|
84
|
+
export declare const ORDER_EXTERNAL_REFERENCE_MESSAGE_MAX = 1000;
|
|
85
|
+
/** The longest external reference (the other system's number), in characters. */
|
|
86
|
+
export declare const ORDER_EXTERNAL_REFERENCE_MAX = 255;
|
|
87
|
+
/**
|
|
88
|
+
* The stable key a writer records its references under — normally its own
|
|
89
|
+
* module id. Lower-case, starting with a letter, then letters, digits, `_`,
|
|
90
|
+
* `-` or `.`, at most 64 characters: it is shown to the operator as written
|
|
91
|
+
* and it is half of the row's identity, so it is a key and not a label.
|
|
92
|
+
*/
|
|
93
|
+
export declare const orderExternalReferenceSystemSchema: z.ZodString;
|
|
94
|
+
/**
|
|
95
|
+
* What a writer records through {@link OrderExternalReferencePort.set}.
|
|
96
|
+
*
|
|
97
|
+
* - `reference` — the other system's number for the order. **Omitted keeps
|
|
98
|
+
* the stored one** (a writer that only reports a new state need not repeat
|
|
99
|
+
* it); `null` clears it.
|
|
100
|
+
* - `message` — the other system's own words, normally on `error`. **Omitted
|
|
101
|
+
* means none**: the message describes the state being recorded, so a writer
|
|
102
|
+
* reporting `synced` after an `error` does not leave the refusal standing.
|
|
103
|
+
*/
|
|
104
|
+
export declare const orderExternalReferenceWriteSchema: z.ZodObject<{
|
|
105
|
+
reference: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
106
|
+
state: z.ZodEnum<{
|
|
107
|
+
error: "error";
|
|
108
|
+
pending: "pending";
|
|
109
|
+
synced: "synced";
|
|
110
|
+
}>;
|
|
111
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
export type OrderExternalReferenceWrite = z.infer<typeof orderExternalReferenceWriteSchema>;
|
|
114
|
+
/**
|
|
115
|
+
* One external system's reference on an order, as the admin order detail
|
|
116
|
+
* carries it (`GET /api/v1/admin/orders/:id`, `externalReferences`).
|
|
117
|
+
*/
|
|
118
|
+
export declare const adminOrderExternalReferenceSchema: z.ZodObject<{
|
|
119
|
+
system: z.ZodString;
|
|
120
|
+
reference: z.ZodNullable<z.ZodString>;
|
|
121
|
+
state: z.ZodEnum<{
|
|
122
|
+
error: "error";
|
|
123
|
+
pending: "pending";
|
|
124
|
+
synced: "synced";
|
|
125
|
+
}>;
|
|
126
|
+
message: z.ZodNullable<z.ZodString>;
|
|
127
|
+
updatedAt: z.ZodString;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
export type AdminOrderExternalReference = z.infer<typeof adminOrderExternalReferenceSchema>;
|
|
130
|
+
/**
|
|
131
|
+
* Issue #904 — the VAT method an order was placed under, as `orders.vat_method`
|
|
132
|
+
* stores it (`null`: placed before 0.108.0). `per_rate`: VAT per rate on the
|
|
133
|
+
* sum of the goods nets, with delivery and the payment surcharge at 0 %.
|
|
134
|
+
* `per_rate_charges`: the same method, with delivery and the surcharge taxed
|
|
135
|
+
* at the goods' rates as {@link orderChargeLineSchema} parts. Nothing places an
|
|
136
|
+
* order `per_rate_charges` yet (Phase A); the value is published so the
|
|
137
|
+
* readers can learn it before the placement switch.
|
|
138
|
+
*/
|
|
139
|
+
export declare const orderVatMethodSchema: z.ZodEnum<{
|
|
140
|
+
per_rate: "per_rate";
|
|
141
|
+
per_rate_charges: "per_rate_charges";
|
|
142
|
+
}>;
|
|
143
|
+
export type OrderVatMethod = z.infer<typeof orderVatMethodSchema>;
|
|
144
|
+
/**
|
|
145
|
+
* Issue #904 — one part of an order-level charge at one VAT rate, as
|
|
146
|
+
* `chargesByRate` answered it at placement and `orders.charge_lines` stores
|
|
147
|
+
* it: two-place decimal strings, the rate a fraction. A charge spread over
|
|
148
|
+
* two rates is two parts. Read, never recomputed, by every document the order
|
|
149
|
+
* produces.
|
|
150
|
+
*/
|
|
151
|
+
export declare const orderChargeLineSchema: z.ZodObject<{
|
|
152
|
+
kind: z.ZodEnum<{
|
|
153
|
+
delivery: "delivery";
|
|
154
|
+
payment_surcharge: "payment_surcharge";
|
|
155
|
+
}>;
|
|
156
|
+
rate: z.ZodString;
|
|
157
|
+
gross: z.ZodString;
|
|
158
|
+
net: z.ZodString;
|
|
159
|
+
}, z.core.$strip>;
|
|
160
|
+
export type OrderChargeLine = z.infer<typeof orderChargeLineSchema>;
|
|
76
161
|
export declare const orderSchema: z.ZodObject<{
|
|
77
162
|
id: z.ZodString;
|
|
78
163
|
businessId: z.ZodString;
|
|
@@ -171,6 +256,17 @@ export declare const orderSchema: z.ZodObject<{
|
|
|
171
256
|
currency: z.ZodString;
|
|
172
257
|
}, z.core.$strip>>>;
|
|
173
258
|
deliveryTotal: z.ZodNumber;
|
|
259
|
+
chargeLines: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
260
|
+
kind: z.ZodEnum<{
|
|
261
|
+
delivery: "delivery";
|
|
262
|
+
payment_surcharge: "payment_surcharge";
|
|
263
|
+
}>;
|
|
264
|
+
rate: z.ZodString;
|
|
265
|
+
gross: z.ZodString;
|
|
266
|
+
net: z.ZodString;
|
|
267
|
+
}, z.core.$strip>>>>;
|
|
268
|
+
deliveryNet: z.ZodOptional<z.ZodNumber>;
|
|
269
|
+
paymentSurchargeNet: z.ZodOptional<z.ZodNumber>;
|
|
174
270
|
total: z.ZodNumber;
|
|
175
271
|
currency: z.ZodString;
|
|
176
272
|
placedAt: z.ZodString;
|
|
@@ -312,6 +408,17 @@ export declare const adminOrderDetailSchema: z.ZodObject<{
|
|
|
312
408
|
currency: z.ZodString;
|
|
313
409
|
}, z.core.$strip>>>;
|
|
314
410
|
deliveryTotal: z.ZodNumber;
|
|
411
|
+
chargeLines: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
412
|
+
kind: z.ZodEnum<{
|
|
413
|
+
delivery: "delivery";
|
|
414
|
+
payment_surcharge: "payment_surcharge";
|
|
415
|
+
}>;
|
|
416
|
+
rate: z.ZodString;
|
|
417
|
+
gross: z.ZodString;
|
|
418
|
+
net: z.ZodString;
|
|
419
|
+
}, z.core.$strip>>>>;
|
|
420
|
+
deliveryNet: z.ZodOptional<z.ZodNumber>;
|
|
421
|
+
paymentSurchargeNet: z.ZodOptional<z.ZodNumber>;
|
|
315
422
|
total: z.ZodNumber;
|
|
316
423
|
currency: z.ZodString;
|
|
317
424
|
placedAt: z.ZodString;
|
|
@@ -347,7 +454,8 @@ export declare const adminOrderDetailSchema: z.ZodObject<{
|
|
|
347
454
|
id: z.ZodString;
|
|
348
455
|
name: z.ZodString;
|
|
349
456
|
legalName: z.ZodNullable<z.ZodString>;
|
|
350
|
-
taxId: z.ZodString
|
|
457
|
+
taxId: z.ZodNullable<z.ZodString>;
|
|
458
|
+
isPersonal: z.ZodBoolean;
|
|
351
459
|
vatStatus: z.ZodEnum<{
|
|
352
460
|
vat_payer: "vat_payer";
|
|
353
461
|
vat_exempt: "vat_exempt";
|
|
@@ -360,6 +468,17 @@ export declare const adminOrderDetailSchema: z.ZodObject<{
|
|
|
360
468
|
lastName: z.ZodString;
|
|
361
469
|
email: z.ZodString;
|
|
362
470
|
}, z.core.$strip>>;
|
|
471
|
+
externalReferences: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
472
|
+
system: z.ZodString;
|
|
473
|
+
reference: z.ZodNullable<z.ZodString>;
|
|
474
|
+
state: z.ZodEnum<{
|
|
475
|
+
error: "error";
|
|
476
|
+
pending: "pending";
|
|
477
|
+
synced: "synced";
|
|
478
|
+
}>;
|
|
479
|
+
message: z.ZodNullable<z.ZodString>;
|
|
480
|
+
updatedAt: z.ZodString;
|
|
481
|
+
}, z.core.$strip>>>;
|
|
363
482
|
}, z.core.$strip>;
|
|
364
483
|
export type AdminOrderDetail = z.infer<typeof adminOrderDetailSchema>;
|
|
365
484
|
/**
|
|
@@ -452,36 +571,44 @@ export type OrderPreviewTotalRequest = z.infer<typeof orderPreviewTotalRequestSc
|
|
|
452
571
|
* `410 QUOTE_VALIDITY_ENDED` and this value in `details.code`.
|
|
453
572
|
*/
|
|
454
573
|
export declare const quoteCommitmentRefusalSchema: z.ZodEnum<{
|
|
574
|
+
withdrawn: "withdrawn";
|
|
455
575
|
unavailable: "unavailable";
|
|
456
576
|
lapsed: "lapsed";
|
|
457
|
-
withdrawn: "withdrawn";
|
|
458
577
|
}>;
|
|
459
578
|
export type QuoteCommitmentRefusal = z.infer<typeof quoteCommitmentRefusalSchema>;
|
|
460
579
|
export declare const orderPreviewTotalResponseSchema: z.ZodObject<{
|
|
461
|
-
subtotal: z.ZodNumber;
|
|
462
|
-
taxTotal: z.ZodNumber;
|
|
463
|
-
deliveryTotal: z.ZodNumber;
|
|
464
|
-
paymentSurcharge: z.ZodNumber;
|
|
465
|
-
discountTotal: z.ZodNumber;
|
|
466
|
-
total: z.ZodNumber;
|
|
467
|
-
currency: z.ZodString;
|
|
468
580
|
belowMinimumLines: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
469
581
|
cartItemId: z.ZodString;
|
|
470
582
|
productId: z.ZodString;
|
|
471
583
|
productName: z.ZodOptional<z.ZodString>;
|
|
472
584
|
kind: z.ZodEnum<{
|
|
585
|
+
product_unavailable: "product_unavailable";
|
|
473
586
|
pieces: "pieces";
|
|
474
587
|
packaging_unit: "packaging_unit";
|
|
475
|
-
product_unavailable: "product_unavailable";
|
|
476
588
|
}>;
|
|
477
589
|
minimum: z.ZodOptional<z.ZodNumber>;
|
|
478
590
|
packagingUnitName: z.ZodOptional<z.ZodString>;
|
|
479
591
|
}, z.core.$strip>>>;
|
|
480
592
|
quoteCommitmentRefusal: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
593
|
+
withdrawn: "withdrawn";
|
|
481
594
|
unavailable: "unavailable";
|
|
482
595
|
lapsed: "lapsed";
|
|
483
|
-
withdrawn: "withdrawn";
|
|
484
596
|
}>>>;
|
|
597
|
+
deliveryNet: z.ZodOptional<z.ZodNumber>;
|
|
598
|
+
paymentSurchargeNet: z.ZodOptional<z.ZodNumber>;
|
|
599
|
+
vatRows: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
600
|
+
taxRate: z.ZodNumber;
|
|
601
|
+
netTotal: z.ZodNumber;
|
|
602
|
+
vatAmount: z.ZodNumber;
|
|
603
|
+
grossTotal: z.ZodNumber;
|
|
604
|
+
}, z.core.$strip>>>;
|
|
605
|
+
subtotal: z.ZodNumber;
|
|
606
|
+
taxTotal: z.ZodNumber;
|
|
607
|
+
deliveryTotal: z.ZodNumber;
|
|
608
|
+
paymentSurcharge: z.ZodNumber;
|
|
609
|
+
discountTotal: z.ZodNumber;
|
|
610
|
+
total: z.ZodNumber;
|
|
611
|
+
currency: z.ZodString;
|
|
485
612
|
}, z.core.$strip>;
|
|
486
613
|
export type OrderPreviewTotalResponse = z.infer<typeof orderPreviewTotalResponseSchema>;
|
|
487
614
|
export declare const adminOrderStatusTransitionSchema: z.ZodObject<{
|
|
@@ -858,6 +985,7 @@ export declare const adminCreateOrderRequestSchema: z.ZodObject<{
|
|
|
858
985
|
type: z.ZodString;
|
|
859
986
|
id: z.ZodString;
|
|
860
987
|
}, z.core.$strict>>;
|
|
988
|
+
customFieldValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
861
989
|
}, z.core.$strip>;
|
|
862
990
|
export type AdminCreateOrderRequest = z.infer<typeof adminCreateOrderRequestSchema>;
|
|
863
991
|
/**
|
|
@@ -949,9 +1077,10 @@ export declare const adminOrderPreviewLineSchema: z.ZodObject<{
|
|
|
949
1077
|
* `isProductVisibleTo` (catalog.ts) for why the two visibility/assortment codes are distinct here
|
|
950
1078
|
* and one answer on every buyer-facing seam.
|
|
951
1079
|
*/
|
|
952
|
-
export declare const ADMIN_ORDER_PREVIEW_MESSAGE_PRECEDENCE: readonly ["PRODUCT_NOT_FOUND", "PRODUCT_NOT_VISIBLE_TO_CUSTOMER", "PRODUCT_NOT_IN_SALES_CHANNEL", "QUOTE_ONLY", "UNPRICED", "BELOW_MINIMUM_QUANTITY"];
|
|
1080
|
+
export declare const ADMIN_ORDER_PREVIEW_MESSAGE_PRECEDENCE: readonly ["PRODUCT_NOT_FOUND", "PRODUCT_ARCHIVED", "PRODUCT_NOT_VISIBLE_TO_CUSTOMER", "PRODUCT_NOT_IN_SALES_CHANNEL", "QUOTE_ONLY", "UNPRICED", "BELOW_MINIMUM_QUANTITY"];
|
|
953
1081
|
export declare const adminOrderPreviewMessageCodeSchema: z.ZodEnum<{
|
|
954
1082
|
PRODUCT_NOT_FOUND: "PRODUCT_NOT_FOUND";
|
|
1083
|
+
PRODUCT_ARCHIVED: "PRODUCT_ARCHIVED";
|
|
955
1084
|
PRODUCT_NOT_VISIBLE_TO_CUSTOMER: "PRODUCT_NOT_VISIBLE_TO_CUSTOMER";
|
|
956
1085
|
PRODUCT_NOT_IN_SALES_CHANNEL: "PRODUCT_NOT_IN_SALES_CHANNEL";
|
|
957
1086
|
QUOTE_ONLY: "QUOTE_ONLY";
|
|
@@ -971,6 +1100,14 @@ export declare const adminOrderPreviewResponseSchema: z.ZodObject<{
|
|
|
971
1100
|
unavailable: z.ZodOptional<z.ZodBoolean>;
|
|
972
1101
|
}, z.core.$strip>>;
|
|
973
1102
|
summary: z.ZodObject<{
|
|
1103
|
+
deliveryNet: z.ZodOptional<z.ZodNumber>;
|
|
1104
|
+
paymentSurchargeNet: z.ZodOptional<z.ZodNumber>;
|
|
1105
|
+
vatRows: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1106
|
+
taxRate: z.ZodNumber;
|
|
1107
|
+
netTotal: z.ZodNumber;
|
|
1108
|
+
vatAmount: z.ZodNumber;
|
|
1109
|
+
grossTotal: z.ZodNumber;
|
|
1110
|
+
}, z.core.$strip>>>;
|
|
974
1111
|
subtotal: z.ZodNumber;
|
|
975
1112
|
taxTotal: z.ZodNumber;
|
|
976
1113
|
deliveryTotal: z.ZodNumber;
|
|
@@ -1206,6 +1343,12 @@ export interface OrderRecord {
|
|
|
1206
1343
|
taxTotal: string;
|
|
1207
1344
|
discountTotal: string;
|
|
1208
1345
|
deliveryTotal: string;
|
|
1346
|
+
/**
|
|
1347
|
+
* Issue #904 — the charges' parts per VAT rate, as the order stored them
|
|
1348
|
+
* (`orders.charge_lines`). `null` or absent: the charges carry no VAT, as on
|
|
1349
|
+
* every order placed before the placement switch.
|
|
1350
|
+
*/
|
|
1351
|
+
chargeLines?: OrderChargeLine[] | null;
|
|
1209
1352
|
total: string;
|
|
1210
1353
|
currency: string;
|
|
1211
1354
|
promotionCode: string | null;
|
|
@@ -1256,6 +1399,22 @@ export interface OrderItemRecord {
|
|
|
1256
1399
|
*/
|
|
1257
1400
|
export interface OrderReadPort {
|
|
1258
1401
|
findById(id: string): Promise<OrderRecord | null>;
|
|
1402
|
+
/**
|
|
1403
|
+
* The order with this id **if this customer may read it**, else `null` — the
|
|
1404
|
+
* rule `GET /api/v1/orders/:id` applies (`specs/170-organization-roles/`
|
|
1405
|
+
* FR-049): a member whose organization role holds `orders.view_organization`
|
|
1406
|
+
* (*Administrator* included) reaches every order of their Organization (or
|
|
1407
|
+
* of its roll-up subtree, through the tenant filter); anyone else only the
|
|
1408
|
+
* orders they placed.
|
|
1409
|
+
*
|
|
1410
|
+
* Published for `invoices`' buyer routes (issue #669), which used to accept
|
|
1411
|
+
* any order of the caller's Organization; `returns` judges the order a
|
|
1412
|
+
* return or complaint is started from with it too (FR-054). A consumer
|
|
1413
|
+
* serving a customer an order-scoped resource asks this rather than
|
|
1414
|
+
* restating the rule. `null` is the caller's 404, never a 403, so an order
|
|
1415
|
+
* the customer may not see is indistinguishable from one that does not exist.
|
|
1416
|
+
*/
|
|
1417
|
+
findByIdForCustomer(id: string, customer: Pick<OrderCustomerContext, 'customerAccountId' | 'organizationId'>): Promise<OrderRecord | null>;
|
|
1259
1418
|
findByIds(ids: readonly string[]): Promise<OrderRecord[]>;
|
|
1260
1419
|
/** Every order, newest first — for the bulk export adapter. */
|
|
1261
1420
|
listAll(): Promise<OrderRecord[]>;
|
|
@@ -1464,9 +1623,23 @@ export interface OrderPlacementPort {
|
|
|
1464
1623
|
* instead of their active basket, which the placement then never touches. The
|
|
1465
1624
|
* working basket ends `completed` against the order, or is removed when the
|
|
1466
1625
|
* placement is refused.
|
|
1626
|
+
*
|
|
1627
|
+
* `options.languageTag` (issue #1308) — the buyer request's scope language:
|
|
1628
|
+
* the channel language its `Accept-Language` asks for
|
|
1629
|
+
* (`requestScopeLanguage`). The basket's lines are judged for availability,
|
|
1630
|
+
* and the order's lines named, at (the order's channel, `languageTag`
|
|
1631
|
+
* resolved against that channel's own languages) — the language the same
|
|
1632
|
+
* request's `CartWritePort.addItems` judged them in, so a line it admitted
|
|
1633
|
+
* is not refused here for being off in the channel's default language.
|
|
1634
|
+
* Absent: the language `options.language` names on the channel, else the
|
|
1635
|
+
* channel's default, as before — the answer for a caller with no storefront
|
|
1636
|
+
* request (an API-key order, an operator naming a customer's channel). The
|
|
1637
|
+
* field is additive: an implementation outside this repository may ignore it
|
|
1638
|
+
* and keep that behaviour.
|
|
1467
1639
|
*/
|
|
1468
1640
|
placeOrder(ctx: OrderCustomerContext, req: PlaceOrderRequest, options?: {
|
|
1469
1641
|
language?: string;
|
|
1642
|
+
languageTag?: string;
|
|
1470
1643
|
workingBasketId?: string;
|
|
1471
1644
|
}): Promise<PlacedOrderRecord>;
|
|
1472
1645
|
}
|
|
@@ -1641,6 +1814,67 @@ export interface OrderTransitionPort {
|
|
|
1641
1814
|
*/
|
|
1642
1815
|
isTerminal(orderId: string): Promise<boolean | null>;
|
|
1643
1816
|
}
|
|
1817
|
+
/** The container name {@link OrderExternalReferencePort} is registered under. */
|
|
1818
|
+
export declare const ORDER_EXTERNAL_REFERENCE_PORT: "orderExternalReferencePort";
|
|
1819
|
+
/**
|
|
1820
|
+
* One external system's reference on an order, as
|
|
1821
|
+
* {@link OrderExternalReferencePort} answers it (issue #1030).
|
|
1822
|
+
*/
|
|
1823
|
+
export interface OrderExternalReference {
|
|
1824
|
+
orderId: string;
|
|
1825
|
+
/** The writer's stable key, e.g. its module id ({@link orderExternalReferenceSystemSchema}). */
|
|
1826
|
+
system: string;
|
|
1827
|
+
/** The external system's number for the order, once known. */
|
|
1828
|
+
reference: string | null;
|
|
1829
|
+
state: OrderExternalReferenceState;
|
|
1830
|
+
/** The external system's own words, plain text, at most 1000 characters. */
|
|
1831
|
+
message: string | null;
|
|
1832
|
+
/** When this system's entry last changed. A write that changed nothing does not move it. */
|
|
1833
|
+
updatedAt: Date;
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Container name: `orderExternalReferencePort`. Owner: `orders`
|
|
1837
|
+
* ({@link ORDER_EXTERNAL_REFERENCE_PORT}; issue #1030).
|
|
1838
|
+
*
|
|
1839
|
+
* What an integration that hands orders to another system — an ERP, a WMS, a
|
|
1840
|
+
* fulfilment connector — records **on the order**: that system's number for
|
|
1841
|
+
* it, where the hand-over stands, and the other system's words when it
|
|
1842
|
+
* refused. One entry per order and system. The operator reads them on the
|
|
1843
|
+
* admin order page, and the admin order list's search finds an order by its
|
|
1844
|
+
* reference. Buyer-facing reads never carry them.
|
|
1845
|
+
*
|
|
1846
|
+
* **Writes are audited Commands** (`order.external_reference.set`), each
|
|
1847
|
+
* recorded with the calling actor — so call it inside a tenant context, as a
|
|
1848
|
+
* worker does under `enterSystemScope`. A write that changes nothing records
|
|
1849
|
+
* nothing and does not move `updatedAt`, because a sync loop resends.
|
|
1850
|
+
*
|
|
1851
|
+
* **Refusals are thrown**, as the admin API's are: an order the caller cannot
|
|
1852
|
+
* see is `404 ORDER_NOT_FOUND`, and a write that fails
|
|
1853
|
+
* {@link orderExternalReferenceWriteSchema} or a system key that fails
|
|
1854
|
+
* {@link orderExternalReferenceSystemSchema} is `400 VALIDATION_FAILED`.
|
|
1855
|
+
* The reads answer an unknown order with `null` / `[]`.
|
|
1856
|
+
*
|
|
1857
|
+
* An entry outlives its writer: a system whose module is uninstalled leaves
|
|
1858
|
+
* its entries in place, as history. Every read and write is confined to the
|
|
1859
|
+
* orders the caller's tenant context can see.
|
|
1860
|
+
*
|
|
1861
|
+
* **Owner off:** the seam fails closed — resolving this port throws
|
|
1862
|
+
* `ModuleDisabledError` and the call answers 503 `MODULE_DISABLED`, so nothing
|
|
1863
|
+
* half-executes. Resolve it per use with `lazyPort`, and do not wrap the call
|
|
1864
|
+
* in a bare `catch`. Whether `orders` has an off state at all is its
|
|
1865
|
+
* manifest's `activation` to say, not this line's: a module declaring
|
|
1866
|
+
* `nonDeactivatable` never enters one.
|
|
1867
|
+
*/
|
|
1868
|
+
export interface OrderExternalReferencePort {
|
|
1869
|
+
/** Upsert this system's entry for the order: one Command, one audit row per actual change. */
|
|
1870
|
+
set(orderId: string, system: string, value: OrderExternalReferenceWrite): Promise<OrderExternalReference>;
|
|
1871
|
+
/** This system's entry for the order, or `null`. */
|
|
1872
|
+
get(orderId: string, system: string): Promise<OrderExternalReference | null>;
|
|
1873
|
+
/** Every system's entry for the order, ordered by system key. */
|
|
1874
|
+
listForOrder(orderId: string): Promise<OrderExternalReference[]>;
|
|
1875
|
+
/** The orders whose reference in `system` equals `reference` exactly (normally 0 or 1). */
|
|
1876
|
+
findOrderIds(system: string, reference: string): Promise<string[]>;
|
|
1877
|
+
}
|
|
1644
1878
|
/**
|
|
1645
1879
|
* The answer to a buyer-side claim on an order's GA4 `purchase` conversion
|
|
1646
1880
|
* (issue #277).
|
package/dist/orders.js
CHANGED
|
@@ -5,6 +5,8 @@ import { customFieldCarrySkipSchema, customFieldFiltersQueryParamSchema, customF
|
|
|
5
5
|
import { vatStatusSchema } from './organizations.js';
|
|
6
6
|
import { savedListViewColumnsSchema, savedListViewFiltersSchema, savedListViewNameSchema, savedListViewSchema, savedListViewSortSchema, } from './saved-list-views.js';
|
|
7
7
|
import { twoDecimalAmount } from './money-input.js';
|
|
8
|
+
import { lineQuantitySchema, REQUEST_LINE_ITEMS_MAX } from './line-bounds.js';
|
|
9
|
+
import { vatSummaryRowSchema } from './invoices.js';
|
|
8
10
|
/**
|
|
9
11
|
* Orders module contracts — Source of truth per Principle V.
|
|
10
12
|
* See specs/001-b2b-platform-foundation/contracts/orders.contract.md.
|
|
@@ -88,6 +90,105 @@ export const orderPendingEffectSchema = z.object({
|
|
|
88
90
|
attempts: z.number().int().nonnegative(),
|
|
89
91
|
lastAttemptAt: isoDateTimeSchema.nullable(),
|
|
90
92
|
});
|
|
93
|
+
// --- External references (issue #1030) ----------------------------------------
|
|
94
|
+
/**
|
|
95
|
+
* Where an external system — an ERP, a WMS, a fulfilment connector — stands
|
|
96
|
+
* with an order, as that system's integration last reported it: handed over
|
|
97
|
+
* and not answered yet, accepted, or refused.
|
|
98
|
+
*/
|
|
99
|
+
export const ORDER_EXTERNAL_REFERENCE_STATES = ['pending', 'synced', 'error'];
|
|
100
|
+
/** The longest message an integration may record, in characters. */
|
|
101
|
+
export const ORDER_EXTERNAL_REFERENCE_MESSAGE_MAX = 1000;
|
|
102
|
+
/** The longest external reference (the other system's number), in characters. */
|
|
103
|
+
export const ORDER_EXTERNAL_REFERENCE_MAX = 255;
|
|
104
|
+
/**
|
|
105
|
+
* The stable key a writer records its references under — normally its own
|
|
106
|
+
* module id. Lower-case, starting with a letter, then letters, digits, `_`,
|
|
107
|
+
* `-` or `.`, at most 64 characters: it is shown to the operator as written
|
|
108
|
+
* and it is half of the row's identity, so it is a key and not a label.
|
|
109
|
+
*/
|
|
110
|
+
export const orderExternalReferenceSystemSchema = z
|
|
111
|
+
.string()
|
|
112
|
+
.max(64)
|
|
113
|
+
.regex(/^[a-z][a-z0-9_.-]*$/, 'A system key is lower-case letters, digits, "_", "-" or "." and starts with a letter.');
|
|
114
|
+
/**
|
|
115
|
+
* Plain text: any character but a control character other than tab, line feed
|
|
116
|
+
* and carriage return. The admin renders it as text, never as markup.
|
|
117
|
+
*/
|
|
118
|
+
const CONTROL_CHARACTER = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/;
|
|
119
|
+
/**
|
|
120
|
+
* What a writer records through {@link OrderExternalReferencePort.set}.
|
|
121
|
+
*
|
|
122
|
+
* - `reference` — the other system's number for the order. **Omitted keeps
|
|
123
|
+
* the stored one** (a writer that only reports a new state need not repeat
|
|
124
|
+
* it); `null` clears it.
|
|
125
|
+
* - `message` — the other system's own words, normally on `error`. **Omitted
|
|
126
|
+
* means none**: the message describes the state being recorded, so a writer
|
|
127
|
+
* reporting `synced` after an `error` does not leave the refusal standing.
|
|
128
|
+
*/
|
|
129
|
+
export const orderExternalReferenceWriteSchema = z.object({
|
|
130
|
+
reference: z
|
|
131
|
+
.string()
|
|
132
|
+
.max(ORDER_EXTERNAL_REFERENCE_MAX)
|
|
133
|
+
.refine((value) => value.trim().length > 0, 'An external reference is not empty.')
|
|
134
|
+
.refine((value) => !CONTROL_CHARACTER.test(value), 'An external reference is plain text.')
|
|
135
|
+
.nullable()
|
|
136
|
+
.optional(),
|
|
137
|
+
state: z.enum(ORDER_EXTERNAL_REFERENCE_STATES),
|
|
138
|
+
message: z
|
|
139
|
+
.string()
|
|
140
|
+
.max(ORDER_EXTERNAL_REFERENCE_MESSAGE_MAX)
|
|
141
|
+
.refine((value) => !CONTROL_CHARACTER.test(value), 'A message is plain text.')
|
|
142
|
+
.nullable()
|
|
143
|
+
.optional(),
|
|
144
|
+
});
|
|
145
|
+
/**
|
|
146
|
+
* One external system's reference on an order, as the admin order detail
|
|
147
|
+
* carries it (`GET /api/v1/admin/orders/:id`, `externalReferences`).
|
|
148
|
+
*/
|
|
149
|
+
export const adminOrderExternalReferenceSchema = z.object({
|
|
150
|
+
system: z.string(),
|
|
151
|
+
reference: z.string().nullable(),
|
|
152
|
+
state: z.enum(ORDER_EXTERNAL_REFERENCE_STATES),
|
|
153
|
+
message: z.string().nullable(),
|
|
154
|
+
updatedAt: isoDateTimeSchema,
|
|
155
|
+
});
|
|
156
|
+
/**
|
|
157
|
+
* Issue #904 — the VAT method an order was placed under, as `orders.vat_method`
|
|
158
|
+
* stores it (`null`: placed before 0.108.0). `per_rate`: VAT per rate on the
|
|
159
|
+
* sum of the goods nets, with delivery and the payment surcharge at 0 %.
|
|
160
|
+
* `per_rate_charges`: the same method, with delivery and the surcharge taxed
|
|
161
|
+
* at the goods' rates as {@link orderChargeLineSchema} parts. Nothing places an
|
|
162
|
+
* order `per_rate_charges` yet (Phase A); the value is published so the
|
|
163
|
+
* readers can learn it before the placement switch.
|
|
164
|
+
*/
|
|
165
|
+
export const orderVatMethodSchema = z.enum(['per_rate', 'per_rate_charges']);
|
|
166
|
+
/**
|
|
167
|
+
* Issue #904 — one part of an order-level charge at one VAT rate, as
|
|
168
|
+
* `chargesByRate` answered it at placement and `orders.charge_lines` stores
|
|
169
|
+
* it: two-place decimal strings, the rate a fraction. A charge spread over
|
|
170
|
+
* two rates is two parts. Read, never recomputed, by every document the order
|
|
171
|
+
* produces.
|
|
172
|
+
*/
|
|
173
|
+
export const orderChargeLineSchema = z.object({
|
|
174
|
+
kind: z.enum(['delivery', 'payment_surcharge']),
|
|
175
|
+
rate: z.string(),
|
|
176
|
+
gross: z.string(),
|
|
177
|
+
net: z.string(),
|
|
178
|
+
});
|
|
179
|
+
/**
|
|
180
|
+
* Issue #904 — the net side of an order's charges, for a net-display summary.
|
|
181
|
+
* Optional and additive: absent wherever the charges carry no VAT, which is
|
|
182
|
+
* every order until the placement switch.
|
|
183
|
+
*/
|
|
184
|
+
const orderChargeNetFields = {
|
|
185
|
+
/** The delivery's net: the sum of its parts' nets. */
|
|
186
|
+
deliveryNet: z.number().finite().optional(),
|
|
187
|
+
/** The payment surcharge's net: the sum of its parts' nets. */
|
|
188
|
+
paymentSurchargeNet: z.number().finite().optional(),
|
|
189
|
+
/** The VAT per rate, goods and charges together. */
|
|
190
|
+
vatRows: z.array(vatSummaryRowSchema).optional(),
|
|
191
|
+
};
|
|
91
192
|
export const orderSchema = z.object({
|
|
92
193
|
id: uuidSchema,
|
|
93
194
|
/**
|
|
@@ -175,6 +276,13 @@ export const orderSchema = z.object({
|
|
|
175
276
|
}))
|
|
176
277
|
.default([]),
|
|
177
278
|
deliveryTotal: z.number().finite().nonnegative(),
|
|
279
|
+
/**
|
|
280
|
+
* Issue #904 — the charges' parts per VAT rate, as the order stored them.
|
|
281
|
+
* Absent or `null` on an order whose charges carry no VAT.
|
|
282
|
+
*/
|
|
283
|
+
chargeLines: z.array(orderChargeLineSchema).nullable().optional(),
|
|
284
|
+
deliveryNet: orderChargeNetFields.deliveryNet,
|
|
285
|
+
paymentSurchargeNet: orderChargeNetFields.paymentSurchargeNet,
|
|
178
286
|
total: z.number().finite().nonnegative(),
|
|
179
287
|
currency: z.string().length(3),
|
|
180
288
|
placedAt: isoDateTimeSchema,
|
|
@@ -225,7 +333,10 @@ export const adminOrderDetailSchema = orderSchema.extend({
|
|
|
225
333
|
id: uuidSchema,
|
|
226
334
|
name: z.string(),
|
|
227
335
|
legalName: z.string().nullable(),
|
|
228
|
-
|
|
336
|
+
/** `null` for a personal (B2C) Organization, whose tax id is an internal placeholder (#767). */
|
|
337
|
+
taxId: z.string().nullable(),
|
|
338
|
+
/** A personal (B2C) Organization: the panel labels it an individual customer (#767). */
|
|
339
|
+
isPersonal: z.boolean(),
|
|
229
340
|
vatStatus: vatStatusSchema,
|
|
230
341
|
})
|
|
231
342
|
.nullable(),
|
|
@@ -237,6 +348,12 @@ export const adminOrderDetailSchema = orderSchema.extend({
|
|
|
237
348
|
email: z.string(),
|
|
238
349
|
})
|
|
239
350
|
.nullable(),
|
|
351
|
+
/**
|
|
352
|
+
* Issue #1030 — what each external system has reported about this order,
|
|
353
|
+
* one entry per system, ordered by system key. Empty when none has; a reply
|
|
354
|
+
* from a server older than the field parses as empty.
|
|
355
|
+
*/
|
|
356
|
+
externalReferences: z.array(adminOrderExternalReferenceSchema).default([]),
|
|
240
357
|
});
|
|
241
358
|
/**
|
|
242
359
|
* What a status-changing order route answers when the change **committed** but
|
|
@@ -347,6 +464,7 @@ export const orderPreviewTotalResponseSchema = z.object({
|
|
|
347
464
|
discountTotal: z.number(),
|
|
348
465
|
total: z.number(),
|
|
349
466
|
currency: z.string(),
|
|
467
|
+
...orderChargeNetFields,
|
|
350
468
|
/**
|
|
351
469
|
* Feature 155 — basket lines placement will refuse. Exemptions apply only when the basket's quote
|
|
352
470
|
* source is confirmed valid now (FR-036); `product_unavailable` is a line whose product record is
|
|
@@ -583,7 +701,7 @@ export const updateOrderSavedViewRequestSchema = createOrderSavedViewRequestSche
|
|
|
583
701
|
export const adminCreateOrderItemSchema = z.object({
|
|
584
702
|
productId: uuidSchema,
|
|
585
703
|
variantId: uuidSchema.optional(),
|
|
586
|
-
quantity:
|
|
704
|
+
quantity: lineQuantitySchema,
|
|
587
705
|
});
|
|
588
706
|
/**
|
|
589
707
|
* A brand-new address typed inline on the admin create-order form, instead of
|
|
@@ -606,7 +724,7 @@ export const adminCreateOrderInlineAddressSchema = z.object({
|
|
|
606
724
|
* VALIDATION_FAILED`, `details: { code: 'too_many_items', maximum }`), deliberately not by
|
|
607
725
|
* a schema `.max()`, which would answer 400.
|
|
608
726
|
*/
|
|
609
|
-
export const ADMIN_ORDER_MAX_ITEMS =
|
|
727
|
+
export const ADMIN_ORDER_MAX_ITEMS = REQUEST_LINE_ITEMS_MAX;
|
|
610
728
|
/**
|
|
611
729
|
* Feature 159 — a line of the admin create request: the preview's item plus the
|
|
612
730
|
* `groups[].key` it belongs to (absent or `null` = ungrouped). The preview keeps
|
|
@@ -648,6 +766,11 @@ export const adminCreateOrderRequestSchema = z
|
|
|
648
766
|
* not returned. Only this admin request may carry it.
|
|
649
767
|
*/
|
|
650
768
|
origin: OriginReferenceSchema.optional(),
|
|
769
|
+
/**
|
|
770
|
+
* Feature 175 (FR-017) — the order's custom-field values, validated with
|
|
771
|
+
* the administrator's rules inside the creating Command.
|
|
772
|
+
*/
|
|
773
|
+
customFieldValues: customFieldValuesSchema.optional(),
|
|
651
774
|
})
|
|
652
775
|
.superRefine((val, ctx) => {
|
|
653
776
|
if ((val.deliveryAddressId == null) === (val.deliveryAddress == null)) {
|
|
@@ -692,7 +815,7 @@ export const apiPlaceOrderRequestSchema = z
|
|
|
692
815
|
lines: z
|
|
693
816
|
.array(z.object({
|
|
694
817
|
sku: z.string().min(1),
|
|
695
|
-
quantity:
|
|
818
|
+
quantity: lineQuantitySchema,
|
|
696
819
|
}))
|
|
697
820
|
.min(1),
|
|
698
821
|
deliveryMethodId: uuidSchema,
|
|
@@ -751,6 +874,13 @@ export const adminOrderPreviewLineSchema = z.object({
|
|
|
751
874
|
*/
|
|
752
875
|
export const ADMIN_ORDER_PREVIEW_MESSAGE_PRECEDENCE = [
|
|
753
876
|
'PRODUCT_NOT_FOUND',
|
|
877
|
+
/**
|
|
878
|
+
* Issue #829 — the product is archived (feature 163, FR-019). It equals
|
|
879
|
+
* `ERROR_CODES.PRODUCT_ARCHIVED`, the `409` admin order create answers for the same line
|
|
880
|
+
* and the reason an operator's quote request gives (FR-115). Archiving is product-wide,
|
|
881
|
+
* so it outranks the customer's visibility and the channel's assortment.
|
|
882
|
+
*/
|
|
883
|
+
'PRODUCT_ARCHIVED',
|
|
754
884
|
'PRODUCT_NOT_VISIBLE_TO_CUSTOMER',
|
|
755
885
|
'PRODUCT_NOT_IN_SALES_CHANNEL',
|
|
756
886
|
'QUOTE_ONLY',
|
|
@@ -770,13 +900,14 @@ export const adminOrderPreviewResponseSchema = z.object({
|
|
|
770
900
|
discountTotal: z.number(),
|
|
771
901
|
total: z.number(),
|
|
772
902
|
currency: z.string(),
|
|
903
|
+
...orderChargeNetFields,
|
|
773
904
|
}),
|
|
774
905
|
/**
|
|
775
906
|
* One entry per unavailable line, never more: its `code` is the first of
|
|
776
907
|
* {@link ADMIN_ORDER_PREVIEW_MESSAGE_PRECEDENCE} that applies —
|
|
777
|
-
* `PRODUCT_NOT_FOUND`, `
|
|
778
|
-
* `PRODUCT_NOT_IN_SALES_CHANNEL`, `QUOTE_ONLY`,
|
|
779
|
-
* 155, which alone carries `minimum`). `code` is deliberately a plain
|
|
908
|
+
* `PRODUCT_NOT_FOUND`, `PRODUCT_ARCHIVED` (issue #829),
|
|
909
|
+
* `PRODUCT_NOT_VISIBLE_TO_CUSTOMER`, `PRODUCT_NOT_IN_SALES_CHANNEL`, `QUOTE_ONLY`,
|
|
910
|
+
* `UNPRICED`, `BELOW_MINIMUM_QUANTITY` (feature 155, which alone carries `minimum`). `code` is deliberately a plain
|
|
780
911
|
* string, not {@link adminOrderPreviewMessageCodeSchema}: a newer server may
|
|
781
912
|
* add a code, and an older client must still parse the answer (treat an
|
|
782
913
|
* unknown code as unavailable).
|
|
@@ -866,6 +997,8 @@ export const cloneOrderToQuoteResponseSchema = z.object({
|
|
|
866
997
|
export const ORDER_STATUS_ON_HOLD = 'on_hold';
|
|
867
998
|
export const ORDER_STATUS_CANCELLED = 'cancelled';
|
|
868
999
|
export const ORDER_STATUS_INITIAL = 'new';
|
|
1000
|
+
/** The container name {@link OrderExternalReferencePort} is registered under. */
|
|
1001
|
+
export const ORDER_EXTERNAL_REFERENCE_PORT = 'orderExternalReferencePort';
|
|
869
1002
|
/**
|
|
870
1003
|
* The answer to a buyer-side claim on an order's GA4 `purchase` conversion
|
|
871
1004
|
* (issue #277).
|