@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/returns.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { isoDateTimeSchema, uuidSchema } from './common.js';
|
|
3
3
|
import { twoDecimalAmount } from './money-input.js';
|
|
4
|
+
import { lineQuantitySchema, REQUEST_LINE_ITEMS_MAX } from './line-bounds.js';
|
|
4
5
|
/**
|
|
5
6
|
* Returns & Complaints (Refunds, RMA) — feature 046.
|
|
6
7
|
*
|
|
@@ -15,6 +16,33 @@ import { twoDecimalAmount } from './money-input.js';
|
|
|
15
16
|
export const returnKindSchema = z.enum(['return', 'complaint']);
|
|
16
17
|
/** Settlement resolution chosen by the admin. */
|
|
17
18
|
export const resolutionTypeSchema = z.enum(['refund', 'credit', 'replacement', 'repair']);
|
|
19
|
+
/**
|
|
20
|
+
* The resolutions that settle a consumer withdrawal otherwise than by a refund
|
|
21
|
+
* (issue #905, design D1). A consumer who withdraws is reimbursed by the same
|
|
22
|
+
* means of payment unless they expressly agree otherwise (Directive 2011/83
|
|
23
|
+
* art. 13(1)), so each needs the consumer's consent on record first.
|
|
24
|
+
*/
|
|
25
|
+
export const alternativeResolutionSchema = z.enum(['credit', 'replacement', 'repair']);
|
|
26
|
+
/**
|
|
27
|
+
* Who put the consent on record. `operator_recorded` is the only source today:
|
|
28
|
+
* the consumer agrees by e-mail or telephone and an operator records it with
|
|
29
|
+
* the evidence. `consumer_storefront` is reserved for a consumer's own click on
|
|
30
|
+
* the storefront, should that be required later.
|
|
31
|
+
*/
|
|
32
|
+
export const alternativeConsentSourceSchema = z.enum(['operator_recorded', 'consumer_storefront']);
|
|
33
|
+
/**
|
|
34
|
+
* The consumer's consent to settle a withdrawal as `resolution` (issue #905,
|
|
35
|
+
* design D1). `note` (the evidence) and `byAdminUserId` are the operator's:
|
|
36
|
+
* the buyer's view of a case leaves both out.
|
|
37
|
+
*/
|
|
38
|
+
export const alternativeResolutionConsentSchema = z.object({
|
|
39
|
+
resolution: alternativeResolutionSchema,
|
|
40
|
+
/** When the consumer gave the consent, as the operator recorded it. */
|
|
41
|
+
at: isoDateTimeSchema,
|
|
42
|
+
note: z.string().optional(),
|
|
43
|
+
byAdminUserId: uuidSchema.nullable().optional(),
|
|
44
|
+
source: alternativeConsentSourceSchema,
|
|
45
|
+
});
|
|
18
46
|
/** State of a recorded refund's money movement. */
|
|
19
47
|
export const settlementStateSchema = z.enum(['issued', 'pending_manual', 'failed']);
|
|
20
48
|
/** Who bears the return shipping cost. */
|
|
@@ -104,6 +132,16 @@ export const returnCaseSummarySchema = z.object({
|
|
|
104
132
|
totalRefundAmount: z.number().finite(),
|
|
105
133
|
currency: z.string().length(3),
|
|
106
134
|
submittedAt: isoDateTimeSchema,
|
|
135
|
+
/**
|
|
136
|
+
* Who filed the case (`specs/170-organization-roles/` FR-053, research R-41
|
|
137
|
+
* item 6). A buyer whose role holds `returns.view_organization` lists the
|
|
138
|
+
* Organization's cases, so the summary names its filer — as the order summary
|
|
139
|
+
* carries `placedByCustomerAccountId` — and the storefront can tell a
|
|
140
|
+
* colleague's case, whose follow-up actions stay the filer's, from the
|
|
141
|
+
* caller's own. Additive: the detail always carried it, and the operator's
|
|
142
|
+
* row (`adminReturnRowSchema`) inherits it through `.extend`.
|
|
143
|
+
*/
|
|
144
|
+
customerAccountId: uuidSchema,
|
|
107
145
|
});
|
|
108
146
|
/**
|
|
109
147
|
* What became of the corrective invoice for a settled case (D-92, issue #156).
|
|
@@ -150,6 +188,23 @@ export const returnCaseDetailSchema = returnCaseSummarySchema.extend({
|
|
|
150
188
|
* "not requested" (D-92).
|
|
151
189
|
*/
|
|
152
190
|
correctiveInvoice: returnCaseCorrectiveInvoiceSchema.nullable(),
|
|
191
|
+
/**
|
|
192
|
+
* Issue #876 — the order's delivery cost and payment surcharge this case
|
|
193
|
+
* refunds: a consumer's withdrawal from the whole sale refunds both
|
|
194
|
+
* (Directive 2011/83 art. 13(1)) on the case that completes it. The approved
|
|
195
|
+
* amounts — provisional until the case is settled — and `0` on every other
|
|
196
|
+
* case. Optional on the wire, so an older producer still parses.
|
|
197
|
+
*/
|
|
198
|
+
chargeRefunds: z.object({ delivery: z.number().finite(), surcharge: z.number().finite() }).optional(),
|
|
199
|
+
/**
|
|
200
|
+
* Whether the case is a consumer's withdrawal from a distance contract (issue
|
|
201
|
+
* #905, design §2): a `return` by a personal Organization, filed while the
|
|
202
|
+
* withdrawal function was available for the order. Fixed when the case is
|
|
203
|
+
* filed. `null` for a case filed before the classification existed.
|
|
204
|
+
*/
|
|
205
|
+
consumerWithdrawal: z.boolean().nullable(),
|
|
206
|
+
/** The consumer's consent to a resolution other than a refund, when one is on record (design D1). */
|
|
207
|
+
alternativeResolutionConsent: alternativeResolutionConsentSchema.nullable(),
|
|
153
208
|
});
|
|
154
209
|
// ---------------------------------------------------------------------------
|
|
155
210
|
// Customer requests (US1)
|
|
@@ -188,11 +243,12 @@ export const createReturnCaseRequestSchema = z.object({
|
|
|
188
243
|
lines: z
|
|
189
244
|
.array(z.object({
|
|
190
245
|
orderItemId: uuidSchema,
|
|
191
|
-
quantity:
|
|
246
|
+
quantity: lineQuantitySchema,
|
|
192
247
|
reasonId: uuidSchema,
|
|
193
248
|
description: z.string().max(2000).optional(),
|
|
194
249
|
}))
|
|
195
|
-
.min(1)
|
|
250
|
+
.min(1)
|
|
251
|
+
.max(REQUEST_LINE_ITEMS_MAX),
|
|
196
252
|
attachmentAssetIds: z.array(uuidSchema).optional(),
|
|
197
253
|
comment: z.string().max(2000).optional(),
|
|
198
254
|
});
|
|
@@ -228,9 +284,33 @@ export const adminReturnRowSchema = returnCaseSummarySchema.extend({
|
|
|
228
284
|
// ---------------------------------------------------------------------------
|
|
229
285
|
// Settlement (US5)
|
|
230
286
|
// ---------------------------------------------------------------------------
|
|
287
|
+
/** One order charge a settlement may refund (issue #876): the most that may be approved, and the amount prefilled. */
|
|
288
|
+
export const settlementChargeSchema = z.object({
|
|
289
|
+
cap: z.number().finite(),
|
|
290
|
+
approved: z.number().finite(),
|
|
291
|
+
});
|
|
231
292
|
export const settlementPrefillSchema = z.object({
|
|
232
293
|
currency: z.string().length(3),
|
|
294
|
+
/**
|
|
295
|
+
* Every resolution, always: a client that predates the consent gate keeps
|
|
296
|
+
* working, and the settlement's `422` is the boundary
|
|
297
|
+
* (`RETURN_ALTERNATIVE_RESOLUTION_CONSENT_REQUIRED`).
|
|
298
|
+
*/
|
|
233
299
|
resolutionOptions: z.array(resolutionTypeSchema),
|
|
300
|
+
/** The resolution the form starts on (issue #905): `refund`. */
|
|
301
|
+
defaultResolution: resolutionTypeSchema,
|
|
302
|
+
/**
|
|
303
|
+
* The resolutions this case cannot settle as until the consumer's consent is
|
|
304
|
+
* recorded (issue #905, design D1): on a consumer withdrawal, every one but a
|
|
305
|
+
* refund and the one consented to; empty on any other case.
|
|
306
|
+
*/
|
|
307
|
+
consentRequiredFor: z.array(resolutionTypeSchema),
|
|
308
|
+
/**
|
|
309
|
+
* The order's own payment method, which a refund proposes (Directive 2011/83
|
|
310
|
+
* art. 13(1), "the same means of payment"). `null` when the order cannot be
|
|
311
|
+
* read.
|
|
312
|
+
*/
|
|
313
|
+
defaultRefundPaymentMethodId: uuidSchema.nullable(),
|
|
234
314
|
items: z.array(z.object({
|
|
235
315
|
returnCaseItemId: uuidSchema,
|
|
236
316
|
productName: z.string(),
|
|
@@ -238,6 +318,23 @@ export const settlementPrefillSchema = z.object({
|
|
|
238
318
|
defaultRefundAmount: z.number().finite(),
|
|
239
319
|
approvedRefundAmount: z.number().finite(),
|
|
240
320
|
})),
|
|
321
|
+
/**
|
|
322
|
+
* Issue #876 — the order's charges the case may refund: present only on a
|
|
323
|
+
* consumer's withdrawal that completes the order, and each charge only when
|
|
324
|
+
* its cap is above 0. `cap` is what was paid for it less what earlier cases
|
|
325
|
+
* refunded — the most the operator may approve; `approved` is what settles
|
|
326
|
+
* if the field is omitted: the cap within the withdrawal window (the
|
|
327
|
+
* statutory 14 days or the channel's longer free-return window), `0`
|
|
328
|
+
* outside it. On a settled case `cap` equals `approved`, and a charge settled
|
|
329
|
+
* at 0 is left out; the cap at settlement is recorded in the
|
|
330
|
+
* `return.settled` audit entry.
|
|
331
|
+
*/
|
|
332
|
+
charges: z
|
|
333
|
+
.object({
|
|
334
|
+
delivery: settlementChargeSchema.optional(),
|
|
335
|
+
surcharge: settlementChargeSchema.optional(),
|
|
336
|
+
})
|
|
337
|
+
.optional(),
|
|
241
338
|
});
|
|
242
339
|
export const settlementRequestSchema = z.object({
|
|
243
340
|
resolutionType: resolutionTypeSchema,
|
|
@@ -261,6 +358,31 @@ export const settlementRequestSchema = z.object({
|
|
|
261
358
|
.default([]),
|
|
262
359
|
refundPaymentMethodId: uuidSchema.optional(),
|
|
263
360
|
createCorrectiveInvoice: z.boolean().optional(),
|
|
361
|
+
/**
|
|
362
|
+
* Issue #876 — what the case refunds of the order's delivery cost and of its
|
|
363
|
+
* payment surcharge (ruling Q2 on PR #965):
|
|
364
|
+
* - omitted: the default recomputed under the order's lock (the full amount
|
|
365
|
+
* within the withdrawal window, 0 outside it);
|
|
366
|
+
* - present: settled exactly as sent, 0 included, when it is at most the cap
|
|
367
|
+
* (art. 13(2): a premium delivery reduced to the standard one);
|
|
368
|
+
* - above the cap: refused `422 refund_exceeds_paid`, with nothing written.
|
|
369
|
+
* Only a consumer's withdrawal that completes the order, settled with a
|
|
370
|
+
* refund or a credit, has a cap above 0. This deliberately differs from the
|
|
371
|
+
* line rule, where an amount equal to a default means the default approved.
|
|
372
|
+
*/
|
|
373
|
+
deliveryRefundAmount: twoDecimalAmount(z.number().finite().nonnegative()).optional(),
|
|
374
|
+
surchargeRefundAmount: twoDecimalAmount(z.number().finite().nonnegative()).optional(),
|
|
375
|
+
});
|
|
376
|
+
/**
|
|
377
|
+
* `POST /api/v1/admin/returns/:id/alternative-consent` (issue #905, design D1):
|
|
378
|
+
* the operator records that the consumer agreed to `resolution`, when, and the
|
|
379
|
+
* evidence. The moment may not be in the future, nor before the case was filed.
|
|
380
|
+
*/
|
|
381
|
+
export const recordAlternativeConsentRequestSchema = z.object({
|
|
382
|
+
resolution: alternativeResolutionSchema,
|
|
383
|
+
consentGivenAt: isoDateTimeSchema,
|
|
384
|
+
/** Where the consent is documented, e.g. "Customer's e-mail of 10 Nov 2026, ticket #123". */
|
|
385
|
+
note: z.string().trim().min(1).max(2000),
|
|
264
386
|
});
|
|
265
387
|
/**
|
|
266
388
|
* What became of the corrective invoice a settlement asked for (#135).
|
|
@@ -395,30 +517,23 @@ export const bulkTransitionResultSchema = z.object({
|
|
|
395
517
|
moved: z.array(uuidSchema),
|
|
396
518
|
skipped: z.array(z.object({ id: uuidSchema, reason: z.string() })),
|
|
397
519
|
});
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
export const returnSavedViewUpdateSchema = z.object({
|
|
418
|
-
name: z.string().min(1).max(200).optional(),
|
|
419
|
-
shared: z.boolean().optional(),
|
|
420
|
-
filters: z.record(z.string(), z.unknown()).optional(),
|
|
421
|
-
sort: returnSavedViewSortSchema.optional(),
|
|
422
|
-
visibleColumns: z.array(z.string()).nullable().optional(),
|
|
423
|
-
});
|
|
520
|
+
/**
|
|
521
|
+
* The key of the transaction-scoped advisory lock (`pg_advisory_xact_lock(hashtext(key))`)
|
|
522
|
+
* that serialises the writes about one order's returns. Owner: `returns`.
|
|
523
|
+
*
|
|
524
|
+
* `returns` takes it to create a case and to settle one; `invoices` takes it to
|
|
525
|
+
* issue an invoice (review of PR #865, F3), so an invoice is never issued from
|
|
526
|
+
* a case a settlement has moved money for but not yet recorded as resolved —
|
|
527
|
+
* it waits, and then lists only the kept lines.
|
|
528
|
+
*/
|
|
529
|
+
export function returnCaseOrderLockKey(orderId) {
|
|
530
|
+
return `return_cases:${orderId}`;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* What a corrective-invoice line documents (issue #885). `returned_goods`: the
|
|
534
|
+
* units came back and are credited. `price_reduction`: a complaint settled with
|
|
535
|
+
* money (art. 106j ust. 1 pkt 2 of the Polish VAT Act), so the buyer keeps the
|
|
536
|
+
* goods and only their price is reduced.
|
|
537
|
+
*/
|
|
538
|
+
export const CORRECTION_LINE_BASES = ['returned_goods', 'price_reduction'];
|
|
424
539
|
//# sourceMappingURL=returns.js.map
|
package/dist/sales-channels.d.ts
CHANGED
|
@@ -198,9 +198,9 @@ export type SalesChannelListResponse = z.infer<typeof SalesChannelListResponseSc
|
|
|
198
198
|
/** Channel-scoped entity types tracked by the M:N membership service. */
|
|
199
199
|
export declare const ChannelMemberEntityTypeSchema: z.ZodEnum<{
|
|
200
200
|
customer: "customer";
|
|
201
|
-
product: "product";
|
|
202
201
|
category: "category";
|
|
203
202
|
organization: "organization";
|
|
203
|
+
product: "product";
|
|
204
204
|
"payment-method": "payment-method";
|
|
205
205
|
"delivery-method": "delivery-method";
|
|
206
206
|
tax: "tax";
|
|
@@ -209,7 +209,34 @@ export declare const ChannelMemberEntityTypeSchema: z.ZodEnum<{
|
|
|
209
209
|
"price-list": "price-list";
|
|
210
210
|
}>;
|
|
211
211
|
export type ChannelMemberEntityType = z.infer<typeof ChannelMemberEntityTypeSchema>;
|
|
212
|
-
/** `GET /api/v1/admin/sales-channels/{code}/{entityType}` —
|
|
212
|
+
/** `GET /api/v1/admin/sales-channels/{code}/{entityType}` — the ids of one entity type's members of a channel, paginated (`page` is 0-based). */
|
|
213
|
+
export declare const ChannelMemberIdListResponseSchema: z.ZodObject<{
|
|
214
|
+
salesChannelCode: z.ZodString;
|
|
215
|
+
entityType: z.ZodEnum<{
|
|
216
|
+
customer: "customer";
|
|
217
|
+
category: "category";
|
|
218
|
+
organization: "organization";
|
|
219
|
+
product: "product";
|
|
220
|
+
"payment-method": "payment-method";
|
|
221
|
+
"delivery-method": "delivery-method";
|
|
222
|
+
tax: "tax";
|
|
223
|
+
promotion: "promotion";
|
|
224
|
+
"cms-page": "cms-page";
|
|
225
|
+
"price-list": "price-list";
|
|
226
|
+
}>;
|
|
227
|
+
entityIds: z.ZodArray<z.ZodString>;
|
|
228
|
+
page: z.ZodNumber;
|
|
229
|
+
pageSize: z.ZodNumber;
|
|
230
|
+
total: z.ZodNumber;
|
|
231
|
+
}, z.core.$strip>;
|
|
232
|
+
export type ChannelMemberIdListResponse = z.infer<typeof ChannelMemberIdListResponseSchema>;
|
|
233
|
+
/**
|
|
234
|
+
* A `{ channels }` list of channel summaries. No route answers this shape; the
|
|
235
|
+
* entity-side list is {@link EntityMembershipListResponseSchema}.
|
|
236
|
+
*
|
|
237
|
+
* @deprecated Since issue #1160 — it never described the route it names: that route answers
|
|
238
|
+
* {@link ChannelMemberIdListResponseSchema}. Kept for one minor release, then removed (issue #1162).
|
|
239
|
+
*/
|
|
213
240
|
export declare const ChannelMembershipListResponseSchema: z.ZodObject<{
|
|
214
241
|
channels: z.ZodArray<z.ZodObject<{
|
|
215
242
|
id: z.ZodString;
|
|
@@ -228,14 +255,18 @@ export declare const ChannelMembershipListResponseSchema: z.ZodObject<{
|
|
|
228
255
|
updatedAt: z.ZodString;
|
|
229
256
|
}, z.core.$strip>>;
|
|
230
257
|
}, z.core.$strip>;
|
|
258
|
+
/**
|
|
259
|
+
* @deprecated Since issue #1160 — it never described the route it names: that route answers
|
|
260
|
+
* {@link ChannelMemberIdListResponse}. Kept for one minor release, then removed (issue #1162).
|
|
261
|
+
*/
|
|
231
262
|
export type ChannelMembershipListResponse = z.infer<typeof ChannelMembershipListResponseSchema>;
|
|
232
263
|
/** `GET /api/v1/admin/{entityType}/{id}/sales-channels` — list channels of an entity. */
|
|
233
264
|
export declare const EntityMembershipListResponseSchema: z.ZodObject<{
|
|
234
265
|
entityType: z.ZodEnum<{
|
|
235
266
|
customer: "customer";
|
|
236
|
-
product: "product";
|
|
237
267
|
category: "category";
|
|
238
268
|
organization: "organization";
|
|
269
|
+
product: "product";
|
|
239
270
|
"payment-method": "payment-method";
|
|
240
271
|
"delivery-method": "delivery-method";
|
|
241
272
|
tax: "tax";
|
package/dist/sales-channels.js
CHANGED
|
@@ -235,7 +235,22 @@ export const ChannelMemberEntityTypeSchema = z.enum([
|
|
|
235
235
|
// Feature 160 (D-287 P1) — a price book's channel set, `sales_channel_price_lists`.
|
|
236
236
|
'price-list',
|
|
237
237
|
]);
|
|
238
|
-
/** `GET /api/v1/admin/sales-channels/{code}/{entityType}` —
|
|
238
|
+
/** `GET /api/v1/admin/sales-channels/{code}/{entityType}` — the ids of one entity type's members of a channel, paginated (`page` is 0-based). */
|
|
239
|
+
export const ChannelMemberIdListResponseSchema = z.object({
|
|
240
|
+
salesChannelCode: SalesChannelCodeSchema,
|
|
241
|
+
entityType: ChannelMemberEntityTypeSchema,
|
|
242
|
+
entityIds: z.array(uuidSchema),
|
|
243
|
+
page: z.number().int().nonnegative(),
|
|
244
|
+
pageSize: z.number().int().positive(),
|
|
245
|
+
total: z.number().int().nonnegative(),
|
|
246
|
+
});
|
|
247
|
+
/**
|
|
248
|
+
* A `{ channels }` list of channel summaries. No route answers this shape; the
|
|
249
|
+
* entity-side list is {@link EntityMembershipListResponseSchema}.
|
|
250
|
+
*
|
|
251
|
+
* @deprecated Since issue #1160 — it never described the route it names: that route answers
|
|
252
|
+
* {@link ChannelMemberIdListResponseSchema}. Kept for one minor release, then removed (issue #1162).
|
|
253
|
+
*/
|
|
239
254
|
export const ChannelMembershipListResponseSchema = z.object({
|
|
240
255
|
channels: z.array(SalesChannelSummarySchema),
|
|
241
256
|
});
|
|
@@ -165,4 +165,32 @@ export declare const updateTaskSavedViewRequestSchema: z.ZodObject<{
|
|
|
165
165
|
visibleColumns: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>>;
|
|
166
166
|
}, z.core.$strip>;
|
|
167
167
|
export type UpdateTaskSavedViewRequest = z.infer<typeof updateTaskSavedViewRequestSchema>;
|
|
168
|
+
export declare const createReturnSavedViewRequestSchema: z.ZodObject<{
|
|
169
|
+
name: z.ZodString;
|
|
170
|
+
shared: z.ZodBoolean;
|
|
171
|
+
filters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
172
|
+
sort: z.ZodObject<{
|
|
173
|
+
field: z.ZodString;
|
|
174
|
+
dir: z.ZodEnum<{
|
|
175
|
+
asc: "asc";
|
|
176
|
+
desc: "desc";
|
|
177
|
+
}>;
|
|
178
|
+
}, z.core.$strip>;
|
|
179
|
+
visibleColumns: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
180
|
+
}, z.core.$strip>;
|
|
181
|
+
export type CreateReturnSavedViewRequest = z.infer<typeof createReturnSavedViewRequestSchema>;
|
|
182
|
+
export declare const updateReturnSavedViewRequestSchema: z.ZodObject<{
|
|
183
|
+
name: z.ZodOptional<z.ZodString>;
|
|
184
|
+
shared: z.ZodOptional<z.ZodBoolean>;
|
|
185
|
+
filters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
186
|
+
sort: z.ZodOptional<z.ZodObject<{
|
|
187
|
+
field: z.ZodString;
|
|
188
|
+
dir: z.ZodEnum<{
|
|
189
|
+
asc: "asc";
|
|
190
|
+
desc: "desc";
|
|
191
|
+
}>;
|
|
192
|
+
}, z.core.$strip>>;
|
|
193
|
+
visibleColumns: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>>;
|
|
194
|
+
}, z.core.$strip>;
|
|
195
|
+
export type UpdateReturnSavedViewRequest = z.infer<typeof updateReturnSavedViewRequestSchema>;
|
|
168
196
|
//# sourceMappingURL=saved-list-views.d.ts.map
|
package/dist/saved-list-views.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { uuidSchema } from './common.js';
|
|
3
3
|
// Saved list views — the shapes every admin list's saved-view endpoints share
|
|
4
|
-
// (orders, products, quote requests, tasks). Orders keeps its own exported names in
|
|
4
|
+
// (orders, products, quote requests, returns, tasks). Orders keeps its own exported names in
|
|
5
5
|
// `orders.ts`, built on these.
|
|
6
6
|
export const SAVED_LIST_VIEW_NAME_MAX = 160;
|
|
7
7
|
/** UTF-8 bytes of `JSON.stringify(filters)`. */
|
|
@@ -118,4 +118,17 @@ export const createTaskSavedViewRequestSchema = z.object({
|
|
|
118
118
|
visibleColumns: savedListViewColumnsSchema.nullable().optional(),
|
|
119
119
|
});
|
|
120
120
|
export const updateTaskSavedViewRequestSchema = createTaskSavedViewRequestSchema.partial();
|
|
121
|
+
// --- Returns: filters, sort and column selection (#312)
|
|
122
|
+
//
|
|
123
|
+
// The return list's table predates these rules, so like the order list's its
|
|
124
|
+
// views always carry a sort, and rows saved before them keep their names as
|
|
125
|
+
// stored (see `savedListViewSchema.name`).
|
|
126
|
+
export const createReturnSavedViewRequestSchema = z.object({
|
|
127
|
+
name: savedListViewNameSchema,
|
|
128
|
+
shared: z.boolean(),
|
|
129
|
+
filters: savedListViewFiltersSchema,
|
|
130
|
+
sort: savedListViewSortSchema,
|
|
131
|
+
visibleColumns: savedListViewColumnsSchema.nullable().optional(),
|
|
132
|
+
});
|
|
133
|
+
export const updateReturnSavedViewRequestSchema = createReturnSavedViewRequestSchema.partial();
|
|
121
134
|
//# sourceMappingURL=saved-list-views.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CUSTOM_FIELD_HOST_BINDINGS } from './custom-fields.js';
|
|
3
|
+
/**
|
|
4
|
+
* Declared extension columns on core tables (`specs/178-extensible-columns/`)
|
|
5
|
+
* — the wire half (FR-050, data-model §7).
|
|
6
|
+
*
|
|
7
|
+
* An installed module package may declare additive `x_<moduleId>_*` columns on
|
|
8
|
+
* a custom-field host table. The declaration API, the generated DDL and the
|
|
9
|
+
* accessor are `@endora-commerce/platform/kernel`'s; what lives here is what a
|
|
10
|
+
* consumer of an admin read sees: the `?extensions=` query parameter and the
|
|
11
|
+
* `extensions` attribute a host record gains when it names a module.
|
|
12
|
+
*/
|
|
13
|
+
/** A table an extension may declare columns on — derived from {@link CUSTOM_FIELD_HOST_BINDINGS}. */
|
|
14
|
+
export type ExtensibleHostTable = (typeof CUSTOM_FIELD_HOST_BINDINGS)[keyof typeof CUSTOM_FIELD_HOST_BINDINGS]['table'];
|
|
15
|
+
/**
|
|
16
|
+
* Every extensible host table, derived and never listed (OD-15): every
|
|
17
|
+
* custom-field host table is extensible. Which of them the platform has rolled
|
|
18
|
+
* out is the platform's, not this package's.
|
|
19
|
+
*/
|
|
20
|
+
export declare const EXTENSIBLE_HOST_TABLES: readonly ExtensibleHostTable[];
|
|
21
|
+
/**
|
|
22
|
+
* `?extensions=<moduleId>[,<moduleId>…]`, at most eight, merged into an
|
|
23
|
+
* extensible host's admin detail and list query schemas (FR-051).
|
|
24
|
+
*/
|
|
25
|
+
export declare const ExtensionsQuerySchema: z.ZodObject<{
|
|
26
|
+
extensions: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export type ExtensionsQuery = z.infer<typeof ExtensionsQuerySchema>;
|
|
29
|
+
/**
|
|
30
|
+
* `extensions` on a host record: per requested module, its declared keys and
|
|
31
|
+
* their values. Present only when the request named the module and the module
|
|
32
|
+
* exposes the host on admin reads (FR-052).
|
|
33
|
+
*/
|
|
34
|
+
export declare const ExtensionAttributesSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
35
|
+
export type ExtensionAttributes = z.infer<typeof ExtensionAttributesSchema>;
|
|
36
|
+
//# sourceMappingURL=schema-extensions.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CUSTOM_FIELD_HOST_BINDINGS } from './custom-fields.js';
|
|
3
|
+
/**
|
|
4
|
+
* Every extensible host table, derived and never listed (OD-15): every
|
|
5
|
+
* custom-field host table is extensible. Which of them the platform has rolled
|
|
6
|
+
* out is the platform's, not this package's.
|
|
7
|
+
*/
|
|
8
|
+
export const EXTENSIBLE_HOST_TABLES = [
|
|
9
|
+
...new Set(Object.values(CUSTOM_FIELD_HOST_BINDINGS).map((binding) => binding.table)),
|
|
10
|
+
];
|
|
11
|
+
/** A module id as an extension names it — the manifest id grammar without a leading underscore. */
|
|
12
|
+
const extensionModuleIdSchema = z.string().regex(/^[a-z][a-z0-9_]*$/);
|
|
13
|
+
/**
|
|
14
|
+
* `?extensions=<moduleId>[,<moduleId>…]`, at most eight, merged into an
|
|
15
|
+
* extensible host's admin detail and list query schemas (FR-051).
|
|
16
|
+
*/
|
|
17
|
+
export const ExtensionsQuerySchema = z.object({
|
|
18
|
+
extensions: z
|
|
19
|
+
.string()
|
|
20
|
+
.regex(/^[a-z][a-z0-9_]*(,[a-z][a-z0-9_]*){0,7}$/)
|
|
21
|
+
.optional(),
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* `extensions` on a host record: per requested module, its declared keys and
|
|
25
|
+
* their values. Present only when the request named the module and the module
|
|
26
|
+
* exposes the host on admin reads (FR-052).
|
|
27
|
+
*/
|
|
28
|
+
export const ExtensionAttributesSchema = z.record(extensionModuleIdSchema, z.record(z.string(), z.json()));
|
|
29
|
+
//# sourceMappingURL=schema-extensions.js.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature 174 (`specs/174-product-editor-scope-switcher/contracts/write-encoding.md`; research R3;
|
|
3
|
+
* FR-110…FR-118) — the **one** write encoding of scoped product values, for JSON (the admin API,
|
|
4
|
+
* the connector port) and CSV (import and export).
|
|
5
|
+
*
|
|
6
|
+
* | Intent | JSON | CSV |
|
|
7
|
+
* | --- | --- | --- |
|
|
8
|
+
* | No change | absent, or `""` | empty cell |
|
|
9
|
+
* | Empty override (at Global: no value) | `null` | `NULL` |
|
|
10
|
+
* | Remove the own value, inherit | `{ "inherit": true }` | `INHERIT` |
|
|
11
|
+
* | A value | the value | the text (`\` escapes a token) |
|
|
12
|
+
*
|
|
13
|
+
* This differs from JSON Merge Patch (`null` = remove the member) and from Magento's
|
|
14
|
+
* `__EMPTY__VALUE__` (FR-115). Applies to scoped product values only (FR-117). Adding a token
|
|
15
|
+
* later is additive; changing a meaning is a breaking, versioned change (FR-111).
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import type { FieldScopeSpec, ScopeLevel } from './product-scope-model.js';
|
|
19
|
+
export declare const INHERIT_TOKEN = "INHERIT";
|
|
20
|
+
export declare const EMPTY_TOKEN = "NULL";
|
|
21
|
+
/** A decoded scoped write. Absent (no change) is `undefined`, never an op. */
|
|
22
|
+
export type ScopedWriteOp<T> = {
|
|
23
|
+
op: 'set';
|
|
24
|
+
value: T;
|
|
25
|
+
} | {
|
|
26
|
+
op: 'empty';
|
|
27
|
+
} | {
|
|
28
|
+
op: 'inherit';
|
|
29
|
+
};
|
|
30
|
+
/** The JSON marker that removes the own value. Strict: `{ inherit: true }` and nothing else. */
|
|
31
|
+
export declare const inheritMarkerSchema: z.ZodObject<{
|
|
32
|
+
inherit: z.ZodLiteral<true>;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
export type InheritMarker = z.infer<typeof inheritMarkerSchema>;
|
|
35
|
+
/** The wire form of a scoped write of `T`: the value, `null` (empty) or `{ inherit: true }`. */
|
|
36
|
+
export type ScopedWrite<T> = T | null | InheritMarker;
|
|
37
|
+
/**
|
|
38
|
+
* The Zod schema of one scoped write: `null | { inherit: true } | valueSchema`, optional, with
|
|
39
|
+
* `""` read as absent (no change). `null` and the marker are tried before the value schema, so a
|
|
40
|
+
* permissive value schema never swallows them.
|
|
41
|
+
*/
|
|
42
|
+
export declare function scopedWrite<S extends z.ZodType>(valueSchema: S): z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodUnion<readonly [z.ZodNull, z.ZodObject<{
|
|
43
|
+
inherit: z.ZodLiteral<true>;
|
|
44
|
+
}, z.core.$strict>, S]>>>;
|
|
45
|
+
/** The op a parsed {@link scopedWrite} value means; `undefined` = no change. */
|
|
46
|
+
export declare function toScopedWriteOp<T>(raw: T | null | InheritMarker | undefined): ScopedWriteOp<T> | undefined;
|
|
47
|
+
/** The wire form of an op — the inverse of {@link toScopedWriteOp}. */
|
|
48
|
+
export declare function fromScopedWriteOp<T>(op: ScopedWriteOp<T>): ScopedWrite<T>;
|
|
49
|
+
export type CsvCell = {
|
|
50
|
+
kind: 'no_change';
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'empty';
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'inherit';
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'text';
|
|
57
|
+
text: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Which rule set a column takes: `text` columns get the formula-injection guard (§3a, FR-118);
|
|
61
|
+
* `value` columns (numbers, booleans, dates, selects) do not.
|
|
62
|
+
*/
|
|
63
|
+
export interface CsvColumnOptions {
|
|
64
|
+
column: 'text' | 'value';
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Decode one CSV cell (§3, §3a). Tokens are matched on the raw, whole cell; then, in a text
|
|
68
|
+
* column, one leading `'` is dropped; then a cell of backslashes before a token loses one
|
|
69
|
+
* backslash. Anything else is text, verbatim.
|
|
70
|
+
*/
|
|
71
|
+
export declare function decodeCsvScopedCell(cell: string, options?: CsvColumnOptions): CsvCell;
|
|
72
|
+
/**
|
|
73
|
+
* Encode one CSV cell — the inverse of {@link decodeCsvScopedCell}: `decode(encode(x)) = x` for
|
|
74
|
+
* every non-empty text. An empty text has no CSV form (an empty cell means no change); write the
|
|
75
|
+
* empty override as `{ kind: 'empty' }` instead.
|
|
76
|
+
*/
|
|
77
|
+
export declare function encodeCsvScopedCell(cell: {
|
|
78
|
+
kind: 'empty';
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'inherit';
|
|
81
|
+
} | {
|
|
82
|
+
kind: 'text';
|
|
83
|
+
text: string;
|
|
84
|
+
}, options?: CsvColumnOptions): string;
|
|
85
|
+
export type ScopedWriteRefusal = 'required_empty' | 'not_emptyable' | 'inherit_at_global';
|
|
86
|
+
/**
|
|
87
|
+
* The one place an op is refused for what it means (FR-062, FR-113): `inherit` at Global for
|
|
88
|
+
* every field; `empty` on a required field (name, URL key, required attribute), then on a field
|
|
89
|
+
* that takes no empty override (single selects, booleans). Value shapes and lengths are the
|
|
90
|
+
* value schema's; the scope set is the caller's `FIELD_NOT_AT_SCOPE` check.
|
|
91
|
+
*/
|
|
92
|
+
export declare function validateScopedWrite(field: Pick<FieldScopeSpec, 'required' | 'emptyable'>, op: ScopedWriteOp<unknown>, level: ScopeLevel): ScopedWriteRefusal | null;
|
|
93
|
+
/**
|
|
94
|
+
* `products.scope_version` as the client echoes it: digits within the bigint range, so an
|
|
95
|
+
* over-long token is a 400 and never a database overflow (C2/C3 security review). It lives in this leaf
|
|
96
|
+
* file so `catalog.ts` (the product `PATCH`) and `product-scoped-values.ts` both import it
|
|
97
|
+
* without an import cycle.
|
|
98
|
+
*/
|
|
99
|
+
export declare const scopeVersionTokenSchema: z.ZodString;
|
|
100
|
+
//# sourceMappingURL=scoped-write-encoding.d.ts.map
|