@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/catalog.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { isoDateTimeSchema, moneySchema, multilingualStringSchema, productVisibilitySchema, uuidSchema, } from './common.js';
|
|
3
|
+
import { customFieldAdminAccessSchema, customFieldValuesSchema, } from './custom-fields.js';
|
|
3
4
|
import { ORDER_MINIMUM_MAX } from './order-minimums.js';
|
|
5
|
+
import { lineQuantitySchema, REQUEST_LINE_ITEMS_MAX } from './line-bounds.js';
|
|
4
6
|
import { productPagePathsSchema } from './product-url-keys.js';
|
|
5
|
-
import {
|
|
7
|
+
import { scopeVersionTokenSchema } from './scoped-write-encoding.js';
|
|
6
8
|
/**
|
|
7
9
|
* Catalog module contracts — Source of truth per Principle V.
|
|
8
10
|
* See specs/001-b2b-platform-foundation/contracts/catalog.contract.md.
|
|
@@ -57,6 +59,8 @@ export const attributeValueTypeSchema = z.enum([
|
|
|
57
59
|
'multiselect',
|
|
58
60
|
'price',
|
|
59
61
|
'select',
|
|
62
|
+
// Feature 172 (research R-4) — a Page Builder document per language.
|
|
63
|
+
'page_builder',
|
|
60
64
|
]);
|
|
61
65
|
/**
|
|
62
66
|
* API-facing attribute type form for feature 002 contracts. Maps onto
|
|
@@ -69,6 +73,8 @@ export const apiAttributeTypeSchema = z.enum([
|
|
|
69
73
|
'multiselect',
|
|
70
74
|
'price',
|
|
71
75
|
'slider',
|
|
76
|
+
// Feature 172 (research R-4) — the same name in all three vocabularies.
|
|
77
|
+
'page_builder',
|
|
72
78
|
]);
|
|
73
79
|
/**
|
|
74
80
|
* The API-form type of a stored attribute, derived from the pair the catalogue
|
|
@@ -99,6 +105,8 @@ export function apiAttributeTypeOf(valueType, displayAsSlider) {
|
|
|
99
105
|
case 'boolean':
|
|
100
106
|
case 'date':
|
|
101
107
|
return 'input';
|
|
108
|
+
case 'page_builder':
|
|
109
|
+
return 'page_builder';
|
|
102
110
|
}
|
|
103
111
|
}
|
|
104
112
|
export const assetKindSchema = z.enum(['image', 'video', 'pdf', 'certificate', 'other']);
|
|
@@ -115,6 +123,10 @@ export const attributeOptionSchema = z.object({
|
|
|
115
123
|
createdAt: isoDateTimeSchema,
|
|
116
124
|
updatedAt: isoDateTimeSchema,
|
|
117
125
|
});
|
|
126
|
+
/** `GET /api/v1/admin/catalog/attributes/:attributeId/options` — the attribute's options, in order (issue #599). */
|
|
127
|
+
export const attributeOptionListResponseSchema = z.object({
|
|
128
|
+
data: z.object({ items: z.array(attributeOptionSchema) }),
|
|
129
|
+
});
|
|
118
130
|
export const createAttributeOptionRequestSchema = z.object({
|
|
119
131
|
value: z.string().regex(attributeOptionValueRegex),
|
|
120
132
|
label: z.record(z.string().min(2), z.string().min(1).max(200)).optional(),
|
|
@@ -256,6 +268,21 @@ export const productSummarySchema = z.object({
|
|
|
256
268
|
* producer written before it still compiles).
|
|
257
269
|
*/
|
|
258
270
|
resolvedPrice: productResolvedPriceSchema.nullable().optional(),
|
|
271
|
+
/**
|
|
272
|
+
* Issue #852 — the VAT rate this buyer is charged for this product, as a
|
|
273
|
+
* fraction (`0.08` = 8 %), resolved by the rule the cart and the order use
|
|
274
|
+
* (`createProductTaxRateResolver`): the product's tax class against the
|
|
275
|
+
* Organization's VAT status and registered country; `0` for a VAT-exempt or
|
|
276
|
+
* reverse-charge Organization; a buyer with no Organization is a VAT payer in
|
|
277
|
+
* PL. A storefront derives a single product's gross price from it.
|
|
278
|
+
*
|
|
279
|
+
* `null` where the resolution failed; absent from producers that do not
|
|
280
|
+
* resolve one (an older backend, the external namespace). Either way a
|
|
281
|
+
* consumer derives **no** gross and shows the net, labelled net — never a
|
|
282
|
+
* gross at an assumed rate. A variant shares its product's tax class, and so
|
|
283
|
+
* its rate.
|
|
284
|
+
*/
|
|
285
|
+
vatRate: z.number().finite().nonnegative().nullable().optional(),
|
|
259
286
|
});
|
|
260
287
|
// --- Product variant --------------------------------------------------------
|
|
261
288
|
export const productVariantSchema = z.object({
|
|
@@ -279,6 +306,28 @@ export const seoMetaSchema = z.object({
|
|
|
279
306
|
* The exported `productLinkSummarySchema` below is the canonical name —
|
|
280
307
|
* this `*Inline` alias exists only to avoid a circular import.
|
|
281
308
|
*/
|
|
309
|
+
/** One language's Page Builder document. Opaque beyond being a JSON object. */
|
|
310
|
+
const pageBuilderTreeSchema = z.record(z.string(), z.unknown());
|
|
311
|
+
/**
|
|
312
|
+
* Feature 172 — one content attribute as the product page renders it: the
|
|
313
|
+
* attribute's key, the language its document was resolved to (FR-033), and
|
|
314
|
+
* that one document. No label: the storefront prints no heading of its own
|
|
315
|
+
* (OR-4, FR-037).
|
|
316
|
+
*/
|
|
317
|
+
export const productPageContentAttributeSchema = z.object({
|
|
318
|
+
key: z.string(),
|
|
319
|
+
language: z.string(),
|
|
320
|
+
content: pageBuilderTreeSchema,
|
|
321
|
+
});
|
|
322
|
+
/**
|
|
323
|
+
* Feature 172 (research R-11) — the query of `GET /api/v1/catalog/products/:idOrSlug`.
|
|
324
|
+
* `include=content` asks for `contentAttributes`; without it the response is
|
|
325
|
+
* what it was before content attributes existed. Not strict: the route's
|
|
326
|
+
* other query parameters are not this schema's to judge.
|
|
327
|
+
*/
|
|
328
|
+
export const productDetailQuerySchema = z.object({
|
|
329
|
+
include: z.enum(['content']).optional(),
|
|
330
|
+
});
|
|
282
331
|
const productLinkSummarySchemaInline = z.object({
|
|
283
332
|
id: uuidSchema,
|
|
284
333
|
kind: z.enum(['related', 'up_sell', 'cross_sell']),
|
|
@@ -339,9 +388,11 @@ export const productDetailSchema = productSummarySchema.extend({
|
|
|
339
388
|
url: z.string(),
|
|
340
389
|
}),
|
|
341
390
|
/**
|
|
342
|
-
* Feature 163 (FR-077)
|
|
343
|
-
* the
|
|
344
|
-
*
|
|
391
|
+
* Feature 163 (FR-077), feature 174 (`data-model.md` §6, T035) — the image's alt text
|
|
392
|
+
* at the request's (channel, language): its override there, else its Global alt text,
|
|
393
|
+
* else the asset's. `''` = an empty override — a decorative image, rendered `alt=""`;
|
|
394
|
+
* `null` = none at all. Optional so other builders of the DTO keep compiling;
|
|
395
|
+
* `catalog` always emits it.
|
|
345
396
|
*/
|
|
346
397
|
altText: z.string().nullable().optional(),
|
|
347
398
|
}))
|
|
@@ -452,6 +503,14 @@ export const productDetailSchema = productSummarySchema.extend({
|
|
|
452
503
|
valueRendered: z.string(),
|
|
453
504
|
}))
|
|
454
505
|
.optional(),
|
|
506
|
+
/**
|
|
507
|
+
* Feature 172 (FR-030, FR-036) — the product's Page Builder content
|
|
508
|
+
* attributes, each already resolved to one language, in attribute-set
|
|
509
|
+
* position order. Present **only** when the request asked for it with
|
|
510
|
+
* `?include=content`; `[]` when asked and nothing renders. No label is
|
|
511
|
+
* carried (FR-037).
|
|
512
|
+
*/
|
|
513
|
+
contentAttributes: z.array(productPageContentAttributeSchema).optional(),
|
|
455
514
|
/**
|
|
456
515
|
* Feature 043 — named packaging units (e.g. "Paleta" = 480 pieces) the
|
|
457
516
|
* buyer can order by. Present only for eligible product types
|
|
@@ -480,10 +539,10 @@ export const catalogBulkPriceRequestSchema = z.object({
|
|
|
480
539
|
lines: z
|
|
481
540
|
.array(z.object({
|
|
482
541
|
sku: z.string().min(1),
|
|
483
|
-
quantity:
|
|
542
|
+
quantity: lineQuantitySchema,
|
|
484
543
|
}))
|
|
485
544
|
.min(1)
|
|
486
|
-
.max(
|
|
545
|
+
.max(REQUEST_LINE_ITEMS_MAX),
|
|
487
546
|
});
|
|
488
547
|
export const catalogBulkPriceMissReasonSchema = z.enum([
|
|
489
548
|
'sku_not_in_assortment',
|
|
@@ -549,14 +608,23 @@ export const filterDefinitionSchema = z.object({
|
|
|
549
608
|
filterPosition: z.number().int().min(0).default(0),
|
|
550
609
|
});
|
|
551
610
|
// --- Admin write-surface requests -------------------------------------------
|
|
611
|
+
/** Feature 174 (R21) — the longest product name at any scope. */
|
|
612
|
+
export const PRODUCT_NAME_MAX = 255;
|
|
613
|
+
/** Feature 174 (R21) — the longest product description at any scope. */
|
|
614
|
+
export const PRODUCT_DESCRIPTION_MAX = 20_000;
|
|
552
615
|
// Base shape (no cross-field refine) so updateProductRequestSchema can
|
|
553
616
|
// `.partial()` it. The cross-field rule for virtual download fields is
|
|
554
617
|
// applied as a separate refine on the create variant below.
|
|
555
618
|
const baseProductRequestObject = z.object({
|
|
556
619
|
sku: z.string().min(1).max(255),
|
|
557
620
|
type: productTypeSchema,
|
|
558
|
-
|
|
559
|
-
|
|
621
|
+
/**
|
|
622
|
+
* Feature 174 (FR-014) — the Global name, one string. Channel and Channel × language
|
|
623
|
+
* values are written through `PUT …/products/:id/scoped-values`.
|
|
624
|
+
*/
|
|
625
|
+
name: z.string().min(1).max(PRODUCT_NAME_MAX),
|
|
626
|
+
/** Feature 174 (FR-014) — the Global description; `null` = none. */
|
|
627
|
+
description: z.string().max(PRODUCT_DESCRIPTION_MAX).nullable(),
|
|
560
628
|
categoryIds: z.array(uuidSchema),
|
|
561
629
|
attributeValues: z.record(z.string(), z.unknown()),
|
|
562
630
|
stockMode: stockModeSchema.optional(),
|
|
@@ -609,7 +677,7 @@ const baseProductRequestObject = z.object({
|
|
|
609
677
|
fulfilmentStrategyWarehouseOrder: z.array(uuidSchema).nullable().optional(),
|
|
610
678
|
/**
|
|
611
679
|
* Feature 155 — pieces minimum; `null` clears. Simple / configurable only (else
|
|
612
|
-
* 422
|
|
680
|
+
* 422 MIN_ORDER_QUANTITY_NOT_SUPPORTED_FOR_TYPE, `details.field`, from the service).
|
|
613
681
|
*/
|
|
614
682
|
minOrderQuantity: z.number().int().min(1).max(ORDER_MINIMUM_MAX).nullable().optional(),
|
|
615
683
|
/** Feature 155 — may `return`-kind cases include this product? Every type. */
|
|
@@ -627,7 +695,8 @@ export const createProductRequestSchema = baseProductRequestObject.refine((v) =>
|
|
|
627
695
|
});
|
|
628
696
|
// `type` is immutable after creation (409 FIELD_IMMUTABLE if sent).
|
|
629
697
|
// Feature 012 / FR-016 — `sku` is now editable. Collision with another
|
|
630
|
-
// product's SKU is refused with
|
|
698
|
+
// product's or variant's SKU is refused with 409 SKU_ALREADY_EXISTS (tokens
|
|
699
|
+
// `held_by_product` / `held_by_variant`, issue #624); snapshot tables on
|
|
631
700
|
// orders / quote-requests / invoices keep displaying the SKU value
|
|
632
701
|
// frozen at snapshot time.
|
|
633
702
|
export const updateProductRequestSchema = baseProductRequestObject
|
|
@@ -641,6 +710,11 @@ export const updateProductRequestSchema = baseProductRequestObject
|
|
|
641
710
|
*/
|
|
642
711
|
publishFrom: isoDateTimeSchema.nullable().optional(),
|
|
643
712
|
publishUntil: isoDateTimeSchema.nullable().optional(),
|
|
713
|
+
/**
|
|
714
|
+
* Feature 174 (R7) — optional precondition: the `products.scope_version` the caller read
|
|
715
|
+
* (`GET …/scoped-values`, opaque). When sent and stale → `409 VERSION_CONFLICT`.
|
|
716
|
+
*/
|
|
717
|
+
version: scopeVersionTokenSchema.optional(),
|
|
644
718
|
});
|
|
645
719
|
// Admin batch-by-id lookup. The body carries the id set (deduped server-
|
|
646
720
|
// side) plus optional pagination so callers can stream large lookups
|
|
@@ -916,12 +990,23 @@ export const PRICE_FIELDS_REFUSED_ON_VARIANTS = ['priceOverride', 'defaultPrice'
|
|
|
916
990
|
* underlying DB `valueType` is `number` or `price`.
|
|
917
991
|
*/
|
|
918
992
|
export const numericKindSchema = z.enum(['number', 'price']);
|
|
993
|
+
/**
|
|
994
|
+
* The shape of an attribute key — the one rule an attribute is created with,
|
|
995
|
+
* and the one a listing's `filter[attr.<key>]` is held to (issue #687): the
|
|
996
|
+
* key is interpolated into the Meilisearch filter expression, so a key no
|
|
997
|
+
* attribute could have is refused before either listing backend sees it.
|
|
998
|
+
*/
|
|
999
|
+
export const attributeKeyShapeSchema = z
|
|
1000
|
+
.string()
|
|
1001
|
+
.min(1)
|
|
1002
|
+
.max(64)
|
|
1003
|
+
.regex(/^[a-z][a-z0-9_]*$/, 'must be snake_case, start with a letter');
|
|
1004
|
+
/** Whether `key` has the shape of an attribute key ({@link attributeKeyShapeSchema}). */
|
|
1005
|
+
export function isAttributeKey(key) {
|
|
1006
|
+
return attributeKeyShapeSchema.safeParse(key).success;
|
|
1007
|
+
}
|
|
919
1008
|
const baseCreateAttributeObject = z.object({
|
|
920
|
-
key:
|
|
921
|
-
.string()
|
|
922
|
-
.min(1)
|
|
923
|
-
.max(64)
|
|
924
|
-
.regex(/^[a-z][a-z0-9_]*$/, 'must be snake_case, start with a letter'),
|
|
1009
|
+
key: attributeKeyShapeSchema,
|
|
925
1010
|
label: multilingualStringSchema,
|
|
926
1011
|
/**
|
|
927
1012
|
* Feature 002 — preferred API form. When `type` is present it wins over
|
|
@@ -976,20 +1061,11 @@ const baseCreateAttributeObject = z.object({
|
|
|
976
1061
|
/** Feature 012 — gates inclusion in the storefront PDP "Parametry produktu" tab. */
|
|
977
1062
|
isVisibleOnProductPage: z.boolean().optional(),
|
|
978
1063
|
/**
|
|
979
|
-
* Feature
|
|
980
|
-
* overrides. Default `false` (
|
|
981
|
-
*
|
|
982
|
-
* scopes (`global` / `language` / `channel` / `channel+language`).
|
|
983
|
-
*/
|
|
984
|
-
channelScoped: z.boolean().optional(),
|
|
985
|
-
/**
|
|
986
|
-
* Feature 023 — when `true` the attribute's value is keyed by
|
|
987
|
-
* language at every slot. For user-defined attributes the baseline
|
|
988
|
-
* is stored as `Record<lang, value>` in `products.attribute_values`;
|
|
989
|
-
* for the system Name / Description attributes this flag is pinned
|
|
990
|
-
* `true` by SYSTEM_ATTRIBUTE_SCOPES.
|
|
1064
|
+
* Feature 174 (FR-012, R15) — the attribute may carry Channel overrides and, for a text
|
|
1065
|
+
* (`string`) attribute, Channel × language overrides. Default `false` (Global only). The
|
|
1066
|
+
* Global value is always one value, never a language map.
|
|
991
1067
|
*/
|
|
992
|
-
|
|
1068
|
+
scopable: z.boolean().optional(),
|
|
993
1069
|
/**
|
|
994
1070
|
* Feature 022 (products bulk edit) — makes the attribute available in
|
|
995
1071
|
* the Products Bulk Edit dialog's attribute field list. Default false;
|
|
@@ -998,6 +1074,12 @@ const baseCreateAttributeObject = z.object({
|
|
|
998
1074
|
massEditable: z.boolean().optional(),
|
|
999
1075
|
/** Feature 039 — values participate in Quick Order search. Default false. */
|
|
1000
1076
|
quickSearchable: z.boolean().optional(),
|
|
1077
|
+
/**
|
|
1078
|
+
* Feature 175 (FR-036) — how the admin panel offers the attribute's backing
|
|
1079
|
+
* custom-field definition: `edit` (default), `read` or `hidden`. A panel
|
|
1080
|
+
* convenience, not access control; a required attribute stays `edit`.
|
|
1081
|
+
*/
|
|
1082
|
+
adminAccess: customFieldAdminAccessSchema.optional(),
|
|
1001
1083
|
/**
|
|
1002
1084
|
* Feature 012 — rich option list for select / enum / multiselect types.
|
|
1003
1085
|
* When supplied alongside the legacy `enumValues`, this wins. The
|
|
@@ -1058,14 +1140,14 @@ export const updateAttributeRequestSchema = z
|
|
|
1058
1140
|
filterPosition: z.number().int().min(0).max(10000).optional(),
|
|
1059
1141
|
/** Feature 012 — gates inclusion in the storefront PDP "Parametry produktu" tab. */
|
|
1060
1142
|
isVisibleOnProductPage: z.boolean().optional(),
|
|
1061
|
-
/** Feature
|
|
1062
|
-
|
|
1063
|
-
/** Feature 023 — see `baseCreateAttributeObject.languageScoped`. */
|
|
1064
|
-
languageScoped: z.boolean().optional(),
|
|
1143
|
+
/** Feature 174 — see `baseCreateAttributeObject.scopable`. */
|
|
1144
|
+
scopable: z.boolean().optional(),
|
|
1065
1145
|
/** Feature 022 (products bulk edit) — toggles bulk-editability. */
|
|
1066
1146
|
massEditable: z.boolean().optional(),
|
|
1067
1147
|
/** Feature 039 — values participate in Quick Order search. */
|
|
1068
1148
|
quickSearchable: z.boolean().optional(),
|
|
1149
|
+
/** Feature 175 — see `baseCreateAttributeObject.adminAccess`. */
|
|
1150
|
+
adminAccess: customFieldAdminAccessSchema.optional(),
|
|
1069
1151
|
})
|
|
1070
1152
|
.strict()
|
|
1071
1153
|
.refine((v) => (v.type === 'slider' ? v.numericKind !== undefined : true), {
|
|
@@ -1107,12 +1189,17 @@ export const adminAttributeResponseSchema = z.object({
|
|
|
1107
1189
|
/** Feature 061 (additive) — id of the backing product-host Custom Field definition. */
|
|
1108
1190
|
customFieldDefinitionId: uuidSchema,
|
|
1109
1191
|
/**
|
|
1110
|
-
* Feature
|
|
1111
|
-
*
|
|
1192
|
+
* Feature 174 (R15) — the scope flag and the levels it derives with the value type
|
|
1193
|
+
* (`attributeScopeSet`). Optional so other builders of the DTO keep compiling; `catalog`
|
|
1112
1194
|
* always emits both.
|
|
1113
1195
|
*/
|
|
1114
|
-
|
|
1115
|
-
|
|
1196
|
+
scopable: z.boolean().optional(),
|
|
1197
|
+
scopeLevels: z.array(z.enum(['G', 'C', 'CL'])).optional(),
|
|
1198
|
+
/**
|
|
1199
|
+
* Feature 175 — the backing definition's admin access. Optional so other
|
|
1200
|
+
* builders of the DTO keep compiling; `catalog` always emits it.
|
|
1201
|
+
*/
|
|
1202
|
+
adminAccess: customFieldAdminAccessSchema.optional(),
|
|
1116
1203
|
createdAt: isoDateTimeSchema,
|
|
1117
1204
|
updatedAt: isoDateTimeSchema,
|
|
1118
1205
|
});
|
|
@@ -1132,6 +1219,11 @@ export const createCategoryRequestSchema = z.object({
|
|
|
1132
1219
|
* first import never exposes a source hierarchy to customers.
|
|
1133
1220
|
*/
|
|
1134
1221
|
isActive: z.boolean().optional(),
|
|
1222
|
+
/**
|
|
1223
|
+
* Feature 175 (FR-016) — the category's custom-field values, validated with
|
|
1224
|
+
* the administrator's rules inside the creating Command.
|
|
1225
|
+
*/
|
|
1226
|
+
customFieldValues: customFieldValuesSchema.optional(),
|
|
1135
1227
|
});
|
|
1136
1228
|
export const updateCategoryRequestSchema = z
|
|
1137
1229
|
.object({
|
|
@@ -1158,15 +1250,22 @@ export const updateCategoryRequestSchema = z
|
|
|
1158
1250
|
.strict();
|
|
1159
1251
|
// --- Category page content ---------------------------------------------------
|
|
1160
1252
|
/**
|
|
1161
|
-
* The ceiling on one
|
|
1162
|
-
*
|
|
1253
|
+
* The ceiling on one stored Page Builder content envelope — a category's
|
|
1254
|
+
* content, or one product × content attribute value — in UTF-8 bytes of its
|
|
1255
|
+
* JSON serialisation, every language together.
|
|
1163
1256
|
*
|
|
1164
1257
|
* One mebibyte, because that is what a CMS page is held to today: the CMS
|
|
1165
1258
|
* declares no limit of its own and is bounded by the HTTP layer's default body
|
|
1166
1259
|
* limit, which is this number. Stated here so the bound also holds for a
|
|
1167
1260
|
* caller that does not arrive over HTTP.
|
|
1168
1261
|
*/
|
|
1169
|
-
export const
|
|
1262
|
+
export const PAGE_BUILDER_CONTENT_MAX_BYTES = 1_048_576;
|
|
1263
|
+
/**
|
|
1264
|
+
* The category content ceiling — {@link PAGE_BUILDER_CONTENT_MAX_BYTES}, kept
|
|
1265
|
+
* under its own name for its existing readers. Product content (feature 172)
|
|
1266
|
+
* is held to the same number.
|
|
1267
|
+
*/
|
|
1268
|
+
export const CATEGORY_CONTENT_MAX_BYTES = PAGE_BUILDER_CONTENT_MAX_BYTES;
|
|
1170
1269
|
/**
|
|
1171
1270
|
* The UTF-8 length of a string, counted rather than encoded: this package
|
|
1172
1271
|
* compiles for the admin, the storefront and the backend alike and declares
|
|
@@ -1195,8 +1294,6 @@ function utf8ByteLength(text) {
|
|
|
1195
1294
|
}
|
|
1196
1295
|
return bytes;
|
|
1197
1296
|
}
|
|
1198
|
-
/** One language's Page Builder document. Opaque beyond being a JSON object. */
|
|
1199
|
-
const pageBuilderTreeSchema = z.record(z.string(), z.unknown());
|
|
1200
1297
|
/**
|
|
1201
1298
|
* The content an operator authors for a category's storefront page: one Page
|
|
1202
1299
|
* Builder document per language, keyed like the category's `name`.
|
|
@@ -1239,6 +1336,63 @@ export const categoryPageContentSchema = z.object({
|
|
|
1239
1336
|
language: z.string().nullable(),
|
|
1240
1337
|
content: pageBuilderTreeSchema.nullable(),
|
|
1241
1338
|
});
|
|
1339
|
+
// --- Product content attributes (feature 172) -------------------------------
|
|
1340
|
+
/**
|
|
1341
|
+
* One product × content attribute value: a Page Builder document per
|
|
1342
|
+
* language, the category envelope under the same ceiling. `null` means no
|
|
1343
|
+
* value. The writer drops a language with no block and stores nothing when
|
|
1344
|
+
* none remains (FR-013), so a stored envelope always holds a block.
|
|
1345
|
+
*/
|
|
1346
|
+
export const productContentEnvelopeSchema = z
|
|
1347
|
+
.object({
|
|
1348
|
+
languages: z.record(z.string().min(2).max(35), pageBuilderTreeSchema),
|
|
1349
|
+
})
|
|
1350
|
+
.strict()
|
|
1351
|
+
.refine((envelope) => utf8ByteLength(JSON.stringify(envelope)) <= PAGE_BUILDER_CONTENT_MAX_BYTES, { message: `Product content must not exceed ${PAGE_BUILDER_CONTENT_MAX_BYTES} bytes.` })
|
|
1352
|
+
.nullable();
|
|
1353
|
+
/** `PUT /api/v1/admin/catalog/products/:id/content/:attributeKey` — replaces the value. */
|
|
1354
|
+
export const putProductContentRequestSchema = z
|
|
1355
|
+
.object({ content: productContentEnvelopeSchema })
|
|
1356
|
+
.strict();
|
|
1357
|
+
/** The single read and the write's answer: the whole stored (normalised) envelope. */
|
|
1358
|
+
export const adminProductContentSchema = z.object({
|
|
1359
|
+
productId: uuidSchema,
|
|
1360
|
+
attributeKey: z.string(),
|
|
1361
|
+
content: productContentEnvelopeSchema,
|
|
1362
|
+
});
|
|
1363
|
+
/** One stored language of a content value, as the product form's card shows it — never the document. */
|
|
1364
|
+
export const adminProductContentLanguageStatusSchema = z.object({
|
|
1365
|
+
language: z.string(),
|
|
1366
|
+
filled: z.boolean(),
|
|
1367
|
+
blocks: z.number().int().nonnegative(),
|
|
1368
|
+
excerpt: z.string().nullable(),
|
|
1369
|
+
});
|
|
1370
|
+
/** One content attribute of the product's saved attribute set, with its stored languages. */
|
|
1371
|
+
export const adminProductContentAttributeSchema = z.object({
|
|
1372
|
+
/** `product_attributes.id`. */
|
|
1373
|
+
attributeId: uuidSchema,
|
|
1374
|
+
key: z.string(),
|
|
1375
|
+
label: z.record(z.string(), z.string()),
|
|
1376
|
+
labelDefault: z.string(),
|
|
1377
|
+
position: z.number().int().nonnegative(),
|
|
1378
|
+
languages: z.array(adminProductContentLanguageStatusSchema),
|
|
1379
|
+
});
|
|
1380
|
+
/** `GET /api/v1/admin/catalog/products/:id/content` — the cards, by position then key. */
|
|
1381
|
+
export const adminProductContentListSchema = z.object({
|
|
1382
|
+
productId: uuidSchema,
|
|
1383
|
+
attributeSetId: uuidSchema.nullable(),
|
|
1384
|
+
attributes: z.array(adminProductContentAttributeSchema),
|
|
1385
|
+
});
|
|
1386
|
+
/**
|
|
1387
|
+
* `GET /api/v1/admin/catalog/attributes/:idOrKey/usage` — what deleting an
|
|
1388
|
+
* attribute of any type would meet (feature 172, FR-007). `productValueCount`
|
|
1389
|
+
* is the count the delete guard refuses on, from the same query.
|
|
1390
|
+
*/
|
|
1391
|
+
export const adminAttributeUsageSchema = z.object({
|
|
1392
|
+
attributeSetCount: z.number().int().nonnegative(),
|
|
1393
|
+
productValueCount: z.number().int().nonnegative(),
|
|
1394
|
+
productContentCount: z.number().int().nonnegative(),
|
|
1395
|
+
});
|
|
1242
1396
|
// --- Storefront list/query ---------------------------------------------------
|
|
1243
1397
|
/**
|
|
1244
1398
|
* The orderings the storefront listing accepts.
|
|
@@ -1374,12 +1528,9 @@ export const attributeSetAssignedAttributeSchema = z.object({
|
|
|
1374
1528
|
label: multilingualStringSchema,
|
|
1375
1529
|
valueType: attributeValueTypeSchema,
|
|
1376
1530
|
position: z.number().int().nonnegative(),
|
|
1377
|
-
/**
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
* overwrite protection) per language rather than once for the attribute.
|
|
1381
|
-
*/
|
|
1382
|
-
languageScoped: z.boolean(),
|
|
1531
|
+
/** Feature 174 (R15) — the attribute's scope flag and the levels it derives. */
|
|
1532
|
+
scopable: z.boolean(),
|
|
1533
|
+
scopeLevels: z.array(z.enum(['G', 'C', 'CL'])),
|
|
1383
1534
|
});
|
|
1384
1535
|
export const attributeSetDetailSchema = attributeSetSchema.extend({
|
|
1385
1536
|
attributes: z.array(attributeSetAssignedAttributeSchema),
|
|
@@ -1411,10 +1562,8 @@ export const assignAttributesRequestSchema = z
|
|
|
1411
1562
|
.strict();
|
|
1412
1563
|
// --- Feature 002 — Gallery (US3) --------------------------------------------
|
|
1413
1564
|
export const galleryLabelSchema = z.enum(['base_image', 'small_image', 'thumbnail']);
|
|
1414
|
-
/** Feature 163
|
|
1565
|
+
/** Feature 163 / 174 — the longest alt text of one image at one scope. */
|
|
1415
1566
|
export const GALLERY_ALT_TEXT_MAX = 255;
|
|
1416
|
-
/** Feature 163 — the most channels one write names. */
|
|
1417
|
-
export const SCOPED_CHANNELS_MAX = 256;
|
|
1418
1567
|
export const galleryItemSchema = z.object({
|
|
1419
1568
|
id: uuidSchema,
|
|
1420
1569
|
productId: uuidSchema,
|
|
@@ -1422,13 +1571,13 @@ export const galleryItemSchema = z.object({
|
|
|
1422
1571
|
position: z.number().int().nonnegative(),
|
|
1423
1572
|
labels: z.array(galleryLabelSchema),
|
|
1424
1573
|
/**
|
|
1425
|
-
* Feature
|
|
1426
|
-
*
|
|
1427
|
-
*
|
|
1574
|
+
* Feature 174 (data-model §6) — the Global alt text (`null` = none: the asset's own alt text
|
|
1575
|
+
* is the derived fallback) and the Global hidden flag. Read-only here: every scope of both is
|
|
1576
|
+
* written through `PUT …/products/:id/scoped-values`. Optional so other builders of the DTO
|
|
1577
|
+
* keep compiling; `catalog` always emits both.
|
|
1428
1578
|
*/
|
|
1429
|
-
altText: z.
|
|
1430
|
-
|
|
1431
|
-
hiddenInChannels: z.array(uuidSchema).optional(),
|
|
1579
|
+
altText: z.string().nullable().optional(),
|
|
1580
|
+
hidden: z.boolean().optional(),
|
|
1432
1581
|
createdAt: isoDateTimeSchema,
|
|
1433
1582
|
updatedAt: isoDateTimeSchema,
|
|
1434
1583
|
});
|
|
@@ -1439,52 +1588,21 @@ export const createGalleryItemRequestSchema = z
|
|
|
1439
1588
|
labels: z.array(galleryLabelSchema).optional(),
|
|
1440
1589
|
})
|
|
1441
1590
|
.strict();
|
|
1591
|
+
/**
|
|
1592
|
+
* Feature 174 (`contracts/scoped-values-api.md` §6) — a collection operation only: the item's
|
|
1593
|
+
* position. Its roles (`galleryRole:<label>`), alt text and hidden flag are scoped fields, written
|
|
1594
|
+
* at every scope, Global included, through `PUT …/products/:id/scoped-values`.
|
|
1595
|
+
*/
|
|
1442
1596
|
export const updateGalleryItemRequestSchema = z
|
|
1443
1597
|
.object({
|
|
1444
1598
|
position: z.number().int().nonnegative().optional(),
|
|
1445
|
-
labels: z.array(galleryLabelSchema).optional(),
|
|
1446
|
-
/**
|
|
1447
|
-
* Feature 163 (FR-077) — per-language alt text: the named languages are set, an
|
|
1448
|
-
* empty string removes one, an unnamed one is left as it is.
|
|
1449
|
-
*/
|
|
1450
|
-
altText: translationMapPatchSchema(GALLERY_ALT_TEXT_MAX).optional(),
|
|
1451
|
-
/** Feature 163 (FR-076) — the channels the image is hidden in; replaces the set. */
|
|
1452
|
-
hiddenInChannels: z.array(uuidSchema).max(SCOPED_CHANNELS_MAX).optional(),
|
|
1453
1599
|
})
|
|
1454
1600
|
.strict();
|
|
1455
|
-
|
|
1456
|
-
* Feature
|
|
1457
|
-
*
|
|
1458
|
-
*
|
|
1459
|
-
* The keys are the camelCase names of the gallery labels (`baseImage` = the
|
|
1460
|
-
* `base_image` label, `smallImage` = `small_image`, `thumbnail` = `thumbnail`); the
|
|
1461
|
-
* label spelling stays a value (`galleryLabelSchema`), never an API key.
|
|
1462
|
-
*/
|
|
1463
|
-
export const galleryChannelRolesSchema = z.object({
|
|
1464
|
-
channelId: uuidSchema,
|
|
1465
|
-
roles: z.object({
|
|
1466
|
-
baseImage: uuidSchema.nullable(),
|
|
1467
|
-
smallImage: uuidSchema.nullable(),
|
|
1468
|
-
thumbnail: uuidSchema.nullable(),
|
|
1469
|
-
}),
|
|
1470
|
-
});
|
|
1471
|
-
/**
|
|
1472
|
-
* `PUT …/gallery/channel-roles` — a role named with an item id moves to that item in
|
|
1473
|
-
* the channel, `null` = use inherited (the global holder), an absent role is left as
|
|
1474
|
-
* it is.
|
|
1601
|
+
/*
|
|
1602
|
+
* Feature 174 (`contracts/scoped-values-api.md` §6) — 163's `GET` / `PUT …/gallery/channel-roles`
|
|
1603
|
+
* are retired: a gallery role at G, C or C×L is the scoped field `galleryRole:<label>`, written
|
|
1604
|
+
* through `PUT …/products/:id/scoped-values` (`null` = no image holds the role at the scope).
|
|
1475
1605
|
*/
|
|
1476
|
-
export const putGalleryChannelRolesRequestSchema = z
|
|
1477
|
-
.object({
|
|
1478
|
-
channelId: uuidSchema,
|
|
1479
|
-
roles: z
|
|
1480
|
-
.object({
|
|
1481
|
-
baseImage: uuidSchema.nullable().optional(),
|
|
1482
|
-
smallImage: uuidSchema.nullable().optional(),
|
|
1483
|
-
thumbnail: uuidSchema.nullable().optional(),
|
|
1484
|
-
})
|
|
1485
|
-
.strict(),
|
|
1486
|
-
})
|
|
1487
|
-
.strict();
|
|
1488
1606
|
export const reorderGalleryRequestSchema = z
|
|
1489
1607
|
.object({
|
|
1490
1608
|
orderedGalleryItemIds: z.array(uuidSchema).min(1),
|
|
@@ -1527,9 +1645,9 @@ export const updateAttachmentTypeRequestSchema = z
|
|
|
1527
1645
|
position: z.number().int().nonnegative().optional(),
|
|
1528
1646
|
})
|
|
1529
1647
|
.strict();
|
|
1530
|
-
/** Feature 163
|
|
1648
|
+
/** Feature 163 / 174 — the longest attachment description at a Channel or Channel × language scope. */
|
|
1531
1649
|
export const ATTACHMENT_DESCRIPTION_TRANSLATION_MAX = 4000;
|
|
1532
|
-
/** Feature 163
|
|
1650
|
+
/** Feature 163 / 174 — an attachment name at any scope, as long as the Global one. */
|
|
1533
1651
|
export const ATTACHMENT_NAME_MAX = 160;
|
|
1534
1652
|
export const productAttachmentSchema = z.object({
|
|
1535
1653
|
id: uuidSchema,
|
|
@@ -1540,14 +1658,11 @@ export const productAttachmentSchema = z.object({
|
|
|
1540
1658
|
description: z.string().nullable(),
|
|
1541
1659
|
position: z.number().int().nonnegative(),
|
|
1542
1660
|
/**
|
|
1543
|
-
* Feature
|
|
1544
|
-
*
|
|
1545
|
-
* the DTO keep compiling; `catalog` always emits
|
|
1661
|
+
* Feature 174 (data-model §7) — hidden at Global. Channel and Channel × language values of the
|
|
1662
|
+
* name, description and hidden flag are written through `PUT …/products/:id/scoped-values`.
|
|
1663
|
+
* Optional so other builders of the DTO keep compiling; `catalog` always emits it.
|
|
1546
1664
|
*/
|
|
1547
|
-
|
|
1548
|
-
descriptionTranslations: z.record(z.string(), z.string()).optional(),
|
|
1549
|
-
/** Feature 163 (FR-078) — the channels the attachment is hidden in, sorted. Always emitted by `catalog`. */
|
|
1550
|
-
hiddenInChannels: z.array(uuidSchema).optional(),
|
|
1665
|
+
hidden: z.boolean().optional(),
|
|
1551
1666
|
createdAt: isoDateTimeSchema,
|
|
1552
1667
|
updatedAt: isoDateTimeSchema,
|
|
1553
1668
|
});
|
|
@@ -1558,34 +1673,21 @@ export const createAttachmentRequestSchema = z
|
|
|
1558
1673
|
name: z.string().min(1).max(160),
|
|
1559
1674
|
description: z.string().nullable().optional(),
|
|
1560
1675
|
position: z.number().int().nonnegative().optional(),
|
|
1561
|
-
/**
|
|
1562
|
-
* Feature 163 (FR-078) — the name and description per language: the named
|
|
1563
|
-
* languages are set, an empty string removes one, an unnamed one is left as it is.
|
|
1564
|
-
*/
|
|
1565
|
-
nameTranslations: translationMapPatchSchema(ATTACHMENT_NAME_MAX).optional(),
|
|
1566
|
-
descriptionTranslations: translationMapPatchSchema(ATTACHMENT_DESCRIPTION_TRANSLATION_MAX).optional(),
|
|
1567
|
-
/** Feature 163 (FR-078) — the channels the attachment is hidden in; replaces the set. */
|
|
1568
|
-
hiddenInChannels: z.array(uuidSchema).max(SCOPED_CHANNELS_MAX).optional(),
|
|
1569
1676
|
})
|
|
1570
1677
|
.strict();
|
|
1678
|
+
/**
|
|
1679
|
+
* Feature 174 (`contracts/scoped-values-api.md` §6) — the attachment's type and position. Its
|
|
1680
|
+
* name, description and hidden flag are scoped fields, written at every scope, Global included,
|
|
1681
|
+
* through `PUT …/products/:id/scoped-values`.
|
|
1682
|
+
*/
|
|
1571
1683
|
export const updateAttachmentRequestSchema = z
|
|
1572
1684
|
.object({
|
|
1573
1685
|
attachmentTypeId: uuidSchema.optional(),
|
|
1574
|
-
name: z.string().min(1).max(160).optional(),
|
|
1575
|
-
description: z.string().nullable().optional(),
|
|
1576
1686
|
position: z.number().int().nonnegative().optional(),
|
|
1577
|
-
/**
|
|
1578
|
-
* Feature 163 (FR-078) — the name and description per language: the named
|
|
1579
|
-
* languages are set, an empty string removes one, an unnamed one is left as it is.
|
|
1580
|
-
*/
|
|
1581
|
-
nameTranslations: translationMapPatchSchema(ATTACHMENT_NAME_MAX).optional(),
|
|
1582
|
-
descriptionTranslations: translationMapPatchSchema(ATTACHMENT_DESCRIPTION_TRANSLATION_MAX).optional(),
|
|
1583
|
-
/** Feature 163 (FR-078) — the channels the attachment is hidden in; replaces the set. */
|
|
1584
|
-
hiddenInChannels: z.array(uuidSchema).max(SCOPED_CHANNELS_MAX).optional(),
|
|
1585
1687
|
})
|
|
1586
1688
|
.strict();
|
|
1587
1689
|
// --- Packaging Units (Feature 043) ------------------------------------------
|
|
1588
|
-
/** The longest packaging-unit name
|
|
1690
|
+
/** The longest packaging-unit name at any scope. */
|
|
1589
1691
|
export const PACKAGING_UNIT_NAME_MAX = 160;
|
|
1590
1692
|
/**
|
|
1591
1693
|
* A named ordering unit attached to a product (e.g. "Paleta" = 480 pieces).
|
|
@@ -1595,13 +1697,8 @@ export const PACKAGING_UNIT_NAME_MAX = 160;
|
|
|
1595
1697
|
export const packagingUnitSchema = z.object({
|
|
1596
1698
|
id: uuidSchema,
|
|
1597
1699
|
productId: uuidSchema,
|
|
1700
|
+
/** The Global name; Channel and Channel × language names go through `…/scoped-values` (feature 174). */
|
|
1598
1701
|
name: z.string().min(1).max(160),
|
|
1599
|
-
/**
|
|
1600
|
-
* Feature 163 (FR-079, R16) — the name per language; a language absent here shows
|
|
1601
|
-
* `name`. Optional so other builders of the DTO keep compiling; `catalog` always
|
|
1602
|
-
* emits it.
|
|
1603
|
-
*/
|
|
1604
|
-
nameTranslations: z.record(z.string(), z.string()).optional(),
|
|
1605
1702
|
baseQuantity: z.number().int().positive(),
|
|
1606
1703
|
position: z.number().int().nonnegative(),
|
|
1607
1704
|
isDefault: z.boolean(),
|
|
@@ -1616,31 +1713,26 @@ export const packagingUnitSchema = z.object({
|
|
|
1616
1713
|
export const createPackagingUnitRequestSchema = z
|
|
1617
1714
|
.object({
|
|
1618
1715
|
name: z.string().trim().min(1).max(160),
|
|
1619
|
-
|
|
1716
|
+
/** Issue #351 — a unit's pieces are a line quantity: at most `LINE_QUANTITY_MAX`. */
|
|
1717
|
+
baseQuantity: lineQuantitySchema,
|
|
1620
1718
|
isDefault: z.boolean().optional(),
|
|
1621
1719
|
position: z.number().int().nonnegative().optional(),
|
|
1622
1720
|
/** Feature 155 — minimum number of this unit per order of the product; `null` clears. */
|
|
1623
1721
|
minOrderUnits: z.number().int().min(1).max(ORDER_MINIMUM_MAX).nullable().optional(),
|
|
1624
|
-
/**
|
|
1625
|
-
* Feature 163 (FR-079) — the name per language: the named languages are set, an
|
|
1626
|
-
* empty string removes one, an unnamed one is left as it is.
|
|
1627
|
-
*/
|
|
1628
|
-
nameTranslations: translationMapPatchSchema(PACKAGING_UNIT_NAME_MAX).optional(),
|
|
1629
1722
|
})
|
|
1630
1723
|
.strict();
|
|
1724
|
+
/**
|
|
1725
|
+
* Feature 174 (`contracts/scoped-values-api.md` §6) — base quantity, default flag, position and
|
|
1726
|
+
* minimum. The unit's name is a scoped field, written at every scope, Global included, through
|
|
1727
|
+
* `PUT …/products/:id/scoped-values`.
|
|
1728
|
+
*/
|
|
1631
1729
|
export const updatePackagingUnitRequestSchema = z
|
|
1632
1730
|
.object({
|
|
1633
|
-
|
|
1634
|
-
baseQuantity: z.number().int().positive().optional(),
|
|
1731
|
+
baseQuantity: lineQuantitySchema.optional(),
|
|
1635
1732
|
isDefault: z.boolean().optional(),
|
|
1636
1733
|
position: z.number().int().nonnegative().optional(),
|
|
1637
1734
|
/** Feature 155 — minimum number of this unit per order of the product; `null` clears. */
|
|
1638
1735
|
minOrderUnits: z.number().int().min(1).max(ORDER_MINIMUM_MAX).nullable().optional(),
|
|
1639
|
-
/**
|
|
1640
|
-
* Feature 163 (FR-079) — the name per language: the named languages are set, an
|
|
1641
|
-
* empty string removes one, an unnamed one is left as it is.
|
|
1642
|
-
*/
|
|
1643
|
-
nameTranslations: translationMapPatchSchema(PACKAGING_UNIT_NAME_MAX).optional(),
|
|
1644
1736
|
})
|
|
1645
1737
|
.strict();
|
|
1646
1738
|
export const reorderPackagingUnitsRequestSchema = z
|
|
@@ -1946,17 +2038,9 @@ export function isProductVisibleTo(product, audience) {
|
|
|
1946
2038
|
return audience.authenticated;
|
|
1947
2039
|
return true;
|
|
1948
2040
|
}
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
return languageCode === null ? `status@${channelCode}` : `status@${channelCode}/${languageCode}`;
|
|
1953
|
-
}
|
|
1954
|
-
/** The scope a products-file column names, or `null` when it is not a scoped-status column. */
|
|
1955
|
-
export function parseScopedStatusColumn(column) {
|
|
1956
|
-
const match = SCOPED_STATUS_COLUMN.exec(column.trim());
|
|
1957
|
-
if (!match)
|
|
1958
|
-
return null;
|
|
1959
|
-
return { channelCode: match[1], languageCode: match[2] ?? null };
|
|
2041
|
+
/** The products-file column of a scope: `<field>@<channel code>` or `<field>@<channel code>/<language>`. */
|
|
2042
|
+
export function scopedColumn(field, channelCode, languageCode) {
|
|
2043
|
+
return languageCode === null ? `${field}@${channelCode}` : `${field}@${channelCode}/${languageCode}`;
|
|
1960
2044
|
}
|
|
1961
2045
|
/**
|
|
1962
2046
|
* Scope flags for the **system** product attributes — the ones that are not
|
|
@@ -1973,8 +2057,8 @@ export function parseScopedStatusColumn(column) {
|
|
|
1973
2057
|
* — enforced at write time by the override-service validator.
|
|
1974
2058
|
*/
|
|
1975
2059
|
export const SYSTEM_ATTRIBUTE_SCOPES = {
|
|
1976
|
-
name: {
|
|
1977
|
-
description: {
|
|
2060
|
+
name: { scopable: true },
|
|
2061
|
+
description: { scopable: true },
|
|
1978
2062
|
};
|
|
1979
2063
|
export function isSystemAttributeKey(key) {
|
|
1980
2064
|
return Object.prototype.hasOwnProperty.call(SYSTEM_ATTRIBUTE_SCOPES, key);
|
|
@@ -1992,13 +2076,7 @@ export function getAttributeScope(attributeKey, productAttributeRow) {
|
|
|
1992
2076
|
// index signature still widens under `noUncheckedIndexedAccess`.
|
|
1993
2077
|
return SYSTEM_ATTRIBUTE_SCOPES[attributeKey];
|
|
1994
2078
|
}
|
|
1995
|
-
|
|
1996
|
-
return {
|
|
1997
|
-
channelScoped: productAttributeRow.channelScoped,
|
|
1998
|
-
languageScoped: productAttributeRow.languageScoped,
|
|
1999
|
-
};
|
|
2000
|
-
}
|
|
2001
|
-
return { channelScoped: false, languageScoped: false };
|
|
2079
|
+
return { scopable: productAttributeRow?.scopable ?? false };
|
|
2002
2080
|
}
|
|
2003
2081
|
// ---------------------------------------------------------------------------
|
|
2004
2082
|
// Events offered to outbound webhooks
|