@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/organizations.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { addressSnapshotSchema, isoDateTimeSchema,
|
|
2
|
+
import { addressSnapshotSchema, isoDateTimeSchema, uuidSchema, } from './common.js';
|
|
3
3
|
import { fulfilmentStrategySchema } from './inventory.js';
|
|
4
|
+
import { organizationRoleRefSchema } from './organization-roles.js';
|
|
5
|
+
import { paginationSchema } from './pagination.js';
|
|
4
6
|
import { SalesChannelOptionSchema } from './sales-channels.js';
|
|
5
7
|
import { foldDiacritics } from './text-normalization.js';
|
|
8
|
+
import { registryLookupIdSchema, vatValidationOutcomeSchema, vatValidationProviderSchema, } from './organization-registry-lookup.js';
|
|
9
|
+
import { ExtensionAttributesSchema } from './schema-extensions.js';
|
|
10
|
+
import { customFieldValuesSchema } from './custom-fields.js';
|
|
6
11
|
/**
|
|
7
12
|
* Organizations, customer accounts, addresses, invitations — Source of truth
|
|
8
13
|
* per Principle V. Drives US2 + US3.
|
|
@@ -39,12 +44,36 @@ export const vatStatusSchema = z.enum(['vat_payer', 'vat_exempt', 'reverse_charg
|
|
|
39
44
|
* (`organizations.hierarchy.credit_inheritance_mode`, factory `shared_pool`).
|
|
40
45
|
*/
|
|
41
46
|
export const creditInheritanceModeSchema = z.enum(['shared_pool', 'independent_default']);
|
|
47
|
+
/**
|
|
48
|
+
* The codes a redacted `organization` audit row keeps (issue #844).
|
|
49
|
+
*
|
|
50
|
+
* Owner: `organizations`; **codes only** — see
|
|
51
|
+
* `CUSTOMER_ACCOUNT_AUDIT_KEEP_KEYS` for the rule they extend. This module's
|
|
52
|
+
* snapshots record codes under `provider` and `outcome` (a tax-id validation)
|
|
53
|
+
* and `creditInheritanceMode`; `blockSource` and `countryCode` are kept
|
|
54
|
+
* wherever a writer records them, as they are on the account and the address.
|
|
55
|
+
* `orderConfirmationEmailCount` is the count the `organization.anonymized` row
|
|
56
|
+
* records instead of the addresses: the retention sweep redacts after that row
|
|
57
|
+
* is written, and must leave it as its owner wrote it (issue #844).
|
|
58
|
+
*/
|
|
59
|
+
export const ORGANIZATION_AUDIT_KEEP_KEYS = [
|
|
60
|
+
'blockSource',
|
|
61
|
+
'countryCode',
|
|
62
|
+
'creditInheritanceMode',
|
|
63
|
+
'orderConfirmationEmailCount',
|
|
64
|
+
'outcome',
|
|
65
|
+
'provider',
|
|
66
|
+
];
|
|
42
67
|
export const addressKindSchema = z.enum(['delivery', 'billing']);
|
|
43
68
|
// --- Resources --------------------------------------------------------------
|
|
44
69
|
export const organizationSchema = z.object({
|
|
45
70
|
id: uuidSchema,
|
|
46
71
|
name: z.string(),
|
|
47
|
-
|
|
72
|
+
/**
|
|
73
|
+
* `specs/177-tax-id-scope/` — `null` for a personal (B2C) organization, which
|
|
74
|
+
* has no tax ID; a company organization always has one (FR-001, FR-004).
|
|
75
|
+
*/
|
|
76
|
+
taxId: z.string().nullable(),
|
|
48
77
|
status: organizationStatusSchema,
|
|
49
78
|
vatStatus: vatStatusSchema,
|
|
50
79
|
/** Feature 051 — true for a single-member personal (B2C) organization. */
|
|
@@ -74,6 +103,44 @@ export const organizationSchema = z.object({
|
|
|
74
103
|
createdAt: isoDateTimeSchema,
|
|
75
104
|
updatedAt: isoDateTimeSchema,
|
|
76
105
|
});
|
|
106
|
+
/**
|
|
107
|
+
* `specs/178-extensible-columns/` FR-051 — an Organization as the admin detail
|
|
108
|
+
* and list reads return it. `extensions` is present only when the request named
|
|
109
|
+
* modules with `?extensions=` (`ExtensionsQuerySchema`): per
|
|
110
|
+
* named module that declares columns on `organizations` with `adminReads` and is
|
|
111
|
+
* present, its declared keys and values; an absent, switched-off or
|
|
112
|
+
* non-exposing module is simply not a key (FR-052).
|
|
113
|
+
*/
|
|
114
|
+
export const adminOrganizationSchema = organizationSchema.extend({
|
|
115
|
+
/*
|
|
116
|
+
* Issue #599 — the keys every admin organization reply (the list, the detail
|
|
117
|
+
* and each write's answer) has carried, which the contract did not declare.
|
|
118
|
+
* The Admin UI's organization page reads them. Declared optional, so a client
|
|
119
|
+
* that does not read them is unaffected.
|
|
120
|
+
*/
|
|
121
|
+
legalName: z.string().nullable().optional(),
|
|
122
|
+
/** Feature 038 (US4) — additional addresses copied on this Organization's order confirmations. */
|
|
123
|
+
orderConfirmationEmails: z.array(z.string()).optional(),
|
|
124
|
+
/** The optimistic-concurrency token the moderation and restriction writes check. */
|
|
125
|
+
version: z.number().int().nonnegative().optional(),
|
|
126
|
+
blockedReason: z.string().nullable().optional(),
|
|
127
|
+
blockedAt: isoDateTimeSchema.nullable().optional(),
|
|
128
|
+
rejectedReason: z.string().nullable().optional(),
|
|
129
|
+
rejectedAt: isoDateTimeSchema.nullable().optional(),
|
|
130
|
+
approvedAt: isoDateTimeSchema.nullable().optional(),
|
|
131
|
+
approvedByAdminUserId: uuidSchema.nullable().optional(),
|
|
132
|
+
/** The latest tax-ID validation; each member is `null` while none has run. */
|
|
133
|
+
vatValidation: z
|
|
134
|
+
.object({
|
|
135
|
+
outcome: vatValidationOutcomeSchema.nullable(),
|
|
136
|
+
provider: vatValidationProviderSchema.nullable(),
|
|
137
|
+
validatedAt: isoDateTimeSchema.nullable(),
|
|
138
|
+
})
|
|
139
|
+
.optional(),
|
|
140
|
+
/** Feature 055 — this Organization's custom-field values. */
|
|
141
|
+
customFieldValues: customFieldValuesSchema.optional(),
|
|
142
|
+
extensions: ExtensionAttributesSchema.optional(),
|
|
143
|
+
});
|
|
77
144
|
// --- Hierarchy (feature 056) ------------------------------------------------
|
|
78
145
|
/**
|
|
79
146
|
* A single node in an organization subtree / ancestor chain. `depth` is the
|
|
@@ -116,9 +183,21 @@ export const customerAccountSchema = z.object({
|
|
|
116
183
|
email: z.string().email(),
|
|
117
184
|
firstName: z.string(),
|
|
118
185
|
lastName: z.string(),
|
|
119
|
-
|
|
186
|
+
/**
|
|
187
|
+
* The member's role (`specs/170-organization-roles/`, FR-008, FR-056); it
|
|
188
|
+
* replaced the legacy two-value `role`, removed by WP-12 (FR-073).
|
|
189
|
+
*/
|
|
190
|
+
organizationRole: organizationRoleRefSchema,
|
|
191
|
+
/** The member's effective organization permissions, sorted (FR-056). */
|
|
192
|
+
permissions: z.array(z.string()),
|
|
120
193
|
emailVerifiedAt: isoDateTimeSchema.nullable(),
|
|
121
194
|
twoFactorEnabled: z.boolean(),
|
|
195
|
+
/**
|
|
196
|
+
* Issue #652 (D-292) — the account's e-mail language, `null` while unknown
|
|
197
|
+
* (see `CustomerAccountRecord.preferredLanguage`). Answered by
|
|
198
|
+
* `GET /api/v1/me`; the registration and sign-in answers do not carry it.
|
|
199
|
+
*/
|
|
200
|
+
preferredLanguage: z.string().nullable().optional(),
|
|
122
201
|
createdAt: isoDateTimeSchema,
|
|
123
202
|
updatedAt: isoDateTimeSchema,
|
|
124
203
|
});
|
|
@@ -135,12 +214,24 @@ export const addressSchema = z.object({
|
|
|
135
214
|
isDefault: z.boolean(),
|
|
136
215
|
});
|
|
137
216
|
// --- Requests --------------------------------------------------------------
|
|
138
|
-
/**
|
|
139
|
-
|
|
217
|
+
/**
|
|
218
|
+
* `specs/177-tax-id-scope/` — the one normalisation a tax ID gets before it is
|
|
219
|
+
* stored or looked up: whitespace and dashes stripped, upper-cased. It is the
|
|
220
|
+
* admin boundary's rule (`organizations`' `schemas/organization.ts`), published
|
|
221
|
+
* so the lookups (`OrganizationDetailsPort.findByTaxId`) and the conversion body
|
|
222
|
+
* apply exactly the same one. Pure, so it is a function and not a port.
|
|
223
|
+
*/
|
|
224
|
+
export function normalizeTaxId(input) {
|
|
225
|
+
return input.replace(/[\s-]+/g, '').toUpperCase();
|
|
226
|
+
}
|
|
227
|
+
/** A tax ID as an operator types it, normalised, then held to the stored length (8–32). */
|
|
228
|
+
const normalizedTaxIdSchema = z.string().transform(normalizeTaxId).pipe(z.string().min(8).max(32));
|
|
140
229
|
export const registerOrganizationRequestSchema = z.object({
|
|
141
230
|
organization: z.object({
|
|
142
231
|
name: z.string().min(1).max(255),
|
|
143
|
-
|
|
232
|
+
// `specs/177-tax-id-scope/` — normalised, then held to the stored length,
|
|
233
|
+
// so `--------` is refused instead of storing an empty tax ID.
|
|
234
|
+
taxId: normalizedTaxIdSchema,
|
|
144
235
|
registeredAddress: z.object({
|
|
145
236
|
street: z.string().min(1).max(255),
|
|
146
237
|
city: z.string().min(1).max(120),
|
|
@@ -148,14 +239,35 @@ export const registerOrganizationRequestSchema = z.object({
|
|
|
148
239
|
country: z.string().length(2),
|
|
149
240
|
}),
|
|
150
241
|
vatStatus: vatStatusSchema.optional(),
|
|
242
|
+
/**
|
|
243
|
+
* Feature 175 — the Organization's custom-field values (entity type
|
|
244
|
+
* `organization`). On registration they are validated as BUYER input on
|
|
245
|
+
* the `organization.register` surface; on the admin create, which derives
|
|
246
|
+
* from this member (`AdminOrganizationCreateBodySchema`), with the
|
|
247
|
+
* administrator's rules — the two routes never share a validator (FR-023).
|
|
248
|
+
*/
|
|
249
|
+
customFieldValues: customFieldValuesSchema.optional(),
|
|
151
250
|
}),
|
|
152
251
|
firstUser: z.object({
|
|
153
252
|
email: z.string().email(),
|
|
154
253
|
password: z.string().min(12).max(256),
|
|
155
254
|
firstName: z.string().min(1).max(120),
|
|
156
255
|
lastName: z.string().min(1).max(120),
|
|
256
|
+
/**
|
|
257
|
+
* Feature 175 — the registering person's custom-field values (entity type
|
|
258
|
+
* `customer`), validated as buyer input on `organization.register`.
|
|
259
|
+
*/
|
|
260
|
+
customFieldValues: customFieldValuesSchema.optional(),
|
|
157
261
|
}),
|
|
158
262
|
acceptedTermsVersion: z.string(),
|
|
263
|
+
/**
|
|
264
|
+
* Feature 173 — the reference a registry lookup answered
|
|
265
|
+
* (`organization-registry-lookup.ts`). Top-level, not inside `organization`:
|
|
266
|
+
* `AdminOrganizationCreateBodySchema` is derived from that member and the
|
|
267
|
+
* admin create must not accept it. The snapshot is read from the platform's
|
|
268
|
+
* own store by this id, never from the client (FR-019).
|
|
269
|
+
*/
|
|
270
|
+
registryLookupId: registryLookupIdSchema.optional(),
|
|
159
271
|
});
|
|
160
272
|
export const emailVerificationRequestSchema = z.object({
|
|
161
273
|
token: z.string().min(10),
|
|
@@ -181,7 +293,12 @@ export const customerLoginRequestSchema = z.object({
|
|
|
181
293
|
* `'noop'`; see `cartMergeOutcomePublicSchema` below.
|
|
182
294
|
*/
|
|
183
295
|
export const cartMergeOutcomeSchema = z.object({
|
|
184
|
-
|
|
296
|
+
/**
|
|
297
|
+
* `skipped_permission` (owner ruling PR-12, `specs/170-organization-roles/`):
|
|
298
|
+
* the member's role lacks `carts.create`, so sign-in did not merge the guest
|
|
299
|
+
* basket. The HTTP narrowing reports it as `'noop'`.
|
|
300
|
+
*/
|
|
301
|
+
outcome: z.enum(['adopted', 'merged', 'noop_empty', 'noop_no_anon', 'skipped_permission']),
|
|
185
302
|
movedLineCount: z.number().int().min(0),
|
|
186
303
|
summedLineCount: z.number().int().min(0),
|
|
187
304
|
destinationCartId: uuidSchema,
|
|
@@ -208,7 +325,10 @@ export const customerLoginResponseSchema = z.object({
|
|
|
208
325
|
id: uuidSchema,
|
|
209
326
|
email: z.string().email(),
|
|
210
327
|
organizationId: uuidSchema.nullable(),
|
|
211
|
-
role
|
|
328
|
+
/** The member's role (FR-056); it replaced the legacy `role` (FR-073). */
|
|
329
|
+
organizationRole: organizationRoleRefSchema,
|
|
330
|
+
/** The member's effective organization permissions, sorted (FR-056). */
|
|
331
|
+
permissions: z.array(z.string()),
|
|
212
332
|
twoFactorEnabled: z.boolean(),
|
|
213
333
|
}),
|
|
214
334
|
cartMerge: cartMergeOutcomePublicSchema.nullable().optional(),
|
|
@@ -229,18 +349,11 @@ export const createAddressRequestSchema = z.object({
|
|
|
229
349
|
isDefault: z.boolean().optional(),
|
|
230
350
|
});
|
|
231
351
|
export const updateAddressRequestSchema = createAddressRequestSchema.partial();
|
|
232
|
-
export const inviteMemberRequestSchema = z.object({
|
|
233
|
-
email: z.string().email(),
|
|
234
|
-
role: organizationRoleSchema.optional(),
|
|
235
|
-
});
|
|
236
352
|
export const acceptInvitationRequestSchema = z.object({
|
|
237
353
|
password: z.string().min(12),
|
|
238
354
|
firstName: z.string().min(1).max(120),
|
|
239
355
|
lastName: z.string().min(1).max(120),
|
|
240
356
|
});
|
|
241
|
-
export const changeMemberRoleRequestSchema = z.object({
|
|
242
|
-
role: organizationRoleSchema,
|
|
243
|
-
});
|
|
244
357
|
/** Platform admin — PATCH `/admin/organizations/:id` */
|
|
245
358
|
export const adminPatchOrganizationRequestSchema = z.object({
|
|
246
359
|
name: z.string().min(1).max(255).optional(),
|
|
@@ -263,19 +376,6 @@ export const adminPatchOrganizationRequestSchema = z.object({
|
|
|
263
376
|
export const adminRecoverOrgAccessRequestSchema = z.object({
|
|
264
377
|
promoteCustomerAccountId: uuidSchema,
|
|
265
378
|
});
|
|
266
|
-
/** Platform admin — POST `/admin/organizations/:id/members` (direct create) */
|
|
267
|
-
export const adminDirectMemberRequestSchema = z.object({
|
|
268
|
-
email: z.string().email(),
|
|
269
|
-
firstName: z.string().min(1).max(120),
|
|
270
|
-
lastName: z.string().min(1).max(120),
|
|
271
|
-
password: z.string().min(12).max(256),
|
|
272
|
-
role: organizationRoleSchema.optional(),
|
|
273
|
-
});
|
|
274
|
-
/** Platform admin — PATCH member role */
|
|
275
|
-
export const adminPatchMemberRoleRequestSchema = z.object({
|
|
276
|
-
role: organizationRoleSchema,
|
|
277
|
-
expectedUpdatedAt: z.string().optional(),
|
|
278
|
-
});
|
|
279
379
|
/**
|
|
280
380
|
* Feature 056 (T032) — Platform admin — PATCH member roll-up capability.
|
|
281
381
|
* When enabled, this customer login sees/acts across its organization's subtree.
|
|
@@ -301,6 +401,81 @@ export const registerOrganizationResponseSchema = z.object({
|
|
|
301
401
|
customerAccount: customerAccountSchema,
|
|
302
402
|
emailVerificationSent: z.boolean(),
|
|
303
403
|
});
|
|
404
|
+
// --- Admin organization replies (issue #599) --------------------------------
|
|
405
|
+
/** `GET /api/v1/admin/organizations` — one page of Organizations. */
|
|
406
|
+
export const adminOrganizationListResponseSchema = z.object({
|
|
407
|
+
data: z.array(adminOrganizationSchema),
|
|
408
|
+
pagination: paginationSchema,
|
|
409
|
+
});
|
|
410
|
+
/**
|
|
411
|
+
* A member as the operator's screens show it: the detail's member roster and
|
|
412
|
+
* the answer of every admin member write (profile, roll-up, role, block,
|
|
413
|
+
* unblock). The role is `organizationRole` (`specs/170-organization-roles/`
|
|
414
|
+
* FR-008, FR-073); an operator view carries no effective permissions.
|
|
415
|
+
*/
|
|
416
|
+
export const adminOrganizationMemberSchema = z.object({
|
|
417
|
+
id: uuidSchema,
|
|
418
|
+
email: z.string().email(),
|
|
419
|
+
firstName: z.string(),
|
|
420
|
+
lastName: z.string(),
|
|
421
|
+
/** Feature 056 — this login sees and acts across its Organization's subtree. */
|
|
422
|
+
subtreeRollupEnabled: z.boolean(),
|
|
423
|
+
emailVerifiedAt: isoDateTimeSchema.nullable(),
|
|
424
|
+
twoFactorEnabled: z.boolean(),
|
|
425
|
+
lastLoginAt: isoDateTimeSchema.nullable(),
|
|
426
|
+
organizationRole: organizationRoleRefSchema,
|
|
427
|
+
createdAt: isoDateTimeSchema,
|
|
428
|
+
updatedAt: isoDateTimeSchema,
|
|
429
|
+
});
|
|
430
|
+
/**
|
|
431
|
+
* `GET /api/v1/admin/organizations/:id` — the Organization, its active members,
|
|
432
|
+
* and its two predefined roles, so the member role select can offer
|
|
433
|
+
* Administrator and Member to an operator who may assign roles but not read the
|
|
434
|
+
* role list (`specs/170-organization-roles/contracts/operator-api.md` §5).
|
|
435
|
+
*/
|
|
436
|
+
export const adminOrganizationDetailSchema = adminOrganizationSchema.extend({
|
|
437
|
+
members: z.array(adminOrganizationMemberSchema),
|
|
438
|
+
predefinedRoles: z.array(organizationRoleRefSchema),
|
|
439
|
+
});
|
|
440
|
+
// --- Buyer member and invitation replies (issue #599) -----------------------
|
|
441
|
+
/**
|
|
442
|
+
* A member as the buyer's roster shows it — `GET /api/v1/organizations/mine/members`
|
|
443
|
+
* and `PATCH …/mine/members/:id/role`. A session view (`customerAccountSchema`)
|
|
444
|
+
* adds the member's effective permissions; a roster row does not.
|
|
445
|
+
*/
|
|
446
|
+
export const organizationMemberSchema = z.object({
|
|
447
|
+
id: uuidSchema,
|
|
448
|
+
organizationId: uuidSchema,
|
|
449
|
+
email: z.string().email(),
|
|
450
|
+
firstName: z.string(),
|
|
451
|
+
lastName: z.string(),
|
|
452
|
+
organizationRole: organizationRoleRefSchema,
|
|
453
|
+
emailVerifiedAt: isoDateTimeSchema.nullable(),
|
|
454
|
+
twoFactorEnabled: z.boolean(),
|
|
455
|
+
createdAt: isoDateTimeSchema,
|
|
456
|
+
updatedAt: isoDateTimeSchema,
|
|
457
|
+
});
|
|
458
|
+
export const organizationMemberListResponseSchema = z.object({ data: z.array(organizationMemberSchema) });
|
|
459
|
+
/** A pending invitation — `GET /api/v1/organizations/mine/invitations`. */
|
|
460
|
+
export const organizationInvitationSchema = z.object({
|
|
461
|
+
id: uuidSchema,
|
|
462
|
+
organizationId: uuidSchema,
|
|
463
|
+
email: z.string().email(),
|
|
464
|
+
/** The role the invitee will hold (FR-008, FR-073). */
|
|
465
|
+
organizationRole: organizationRoleRefSchema,
|
|
466
|
+
invitedByCustomerAccountId: uuidSchema.nullable(),
|
|
467
|
+
expiresAt: isoDateTimeSchema,
|
|
468
|
+
createdAt: isoDateTimeSchema,
|
|
469
|
+
});
|
|
470
|
+
export const organizationInvitationListResponseSchema = z.object({ data: z.array(organizationInvitationSchema) });
|
|
471
|
+
/** `POST /api/v1/organizations/mine/invitations` — 201. */
|
|
472
|
+
export const inviteMemberResponseSchema = z.object({
|
|
473
|
+
data: z.object({ invitationId: uuidSchema, expiresAt: isoDateTimeSchema }),
|
|
474
|
+
});
|
|
475
|
+
/** `POST /api/v1/organizations/invitations/:token/accept` — the account the invitation created, as a session view. */
|
|
476
|
+
export const acceptInvitationResponseSchema = z.object({
|
|
477
|
+
data: z.object({ customerAccount: customerAccountSchema }),
|
|
478
|
+
});
|
|
304
479
|
// --- Organization picker (feature 091, P2) ----------------------------------
|
|
305
480
|
/**
|
|
306
481
|
* One row of the admin Organization picker.
|
|
@@ -355,6 +530,89 @@ export const salesRepOrganizationSchema = z.object({
|
|
|
355
530
|
openRfqCount: z.number().int().nonnegative(),
|
|
356
531
|
assignedAt: isoDateTimeSchema,
|
|
357
532
|
});
|
|
533
|
+
// --- Tax-ID scope (specs/177-tax-id-scope/) ----------------------------------
|
|
534
|
+
/**
|
|
535
|
+
* Where the same tax ID may appear twice (`contracts/tax-id-scope.md` §1):
|
|
536
|
+
* `global` — nowhere, every tax ID belongs to one organization (the default of
|
|
537
|
+
* every installation); `per-tree-root` — only inside one organization tree, so
|
|
538
|
+
* a head office and its branches may share it. Enforced by the database and
|
|
539
|
+
* changed only by the audited `organization.tax_id_scope.set` Command.
|
|
540
|
+
*/
|
|
541
|
+
export const taxIdScopeSchema = z.enum(['global', 'per-tree-root']);
|
|
542
|
+
/** `PUT /api/v1/admin/organizations/tax-id-scope` — the scope to switch to. */
|
|
543
|
+
export const adminTaxIdScopeSetBodySchema = z.object({ scope: taxIdScopeSchema });
|
|
544
|
+
/**
|
|
545
|
+
* `GET` / `PUT /api/v1/admin/organizations/tax-id-scope` — the installation's
|
|
546
|
+
* scope, who set it last, how many tax IDs are on more than one organization,
|
|
547
|
+
* and whether the database enforcement agrees with the stored scope
|
|
548
|
+
* (`mismatch` only after a hand edit; re-applying the scope repairs it).
|
|
549
|
+
*/
|
|
550
|
+
export const adminTaxIdScopeResponseSchema = z.object({
|
|
551
|
+
data: z.object({
|
|
552
|
+
scope: taxIdScopeSchema,
|
|
553
|
+
updatedAt: isoDateTimeSchema,
|
|
554
|
+
updatedByAdminUserId: uuidSchema.nullable(),
|
|
555
|
+
sharedTaxIdCount: z.number().int().nonnegative(),
|
|
556
|
+
enforcement: z.enum(['consistent', 'mismatch']),
|
|
557
|
+
}),
|
|
558
|
+
});
|
|
559
|
+
// --- Personal → company conversion (specs/177-tax-id-scope/) -----------------
|
|
560
|
+
/**
|
|
561
|
+
* `POST /api/v1/admin/organizations/:id/convert-to-company`
|
|
562
|
+
* (`contracts/convert-to-company.md` §2). The tax ID is normalised exactly as
|
|
563
|
+
* the admin boundary normalises it. `validateTaxId` is the route's own switch
|
|
564
|
+
* — a VAT validation after the conversion commits — and is not part of the
|
|
565
|
+
* Command's input.
|
|
566
|
+
*/
|
|
567
|
+
export const adminOrganizationConvertToCompanyBodySchema = z.object({
|
|
568
|
+
name: z.string().trim().min(1).max(255),
|
|
569
|
+
legalName: z.string().trim().min(1).max(255).optional(),
|
|
570
|
+
taxId: normalizedTaxIdSchema,
|
|
571
|
+
registeredAddress: z.object({
|
|
572
|
+
street: z.string().min(1).max(255),
|
|
573
|
+
city: z.string().min(1).max(120),
|
|
574
|
+
postalCode: z.string().min(1).max(20),
|
|
575
|
+
country: z.string().length(2),
|
|
576
|
+
}),
|
|
577
|
+
vatStatus: vatStatusSchema.default('vat_payer'),
|
|
578
|
+
validateTaxId: z.boolean().default(false),
|
|
579
|
+
});
|
|
580
|
+
// --- Tax-ID correction (issue #1040, follow-up to specs/177-tax-id-scope/) ----
|
|
581
|
+
/**
|
|
582
|
+
* `POST /api/v1/admin/organizations/:id/change-tax-id`. The tax ID is
|
|
583
|
+
* normalised exactly as the admin boundary normalises it on creation.
|
|
584
|
+
* `validateTaxId` is the route's own switch — a VAT validation after the change
|
|
585
|
+
* commits, whose failure never undoes it — and is not part of the Command's
|
|
586
|
+
* input.
|
|
587
|
+
*/
|
|
588
|
+
export const adminOrganizationChangeTaxIdBodySchema = z.object({
|
|
589
|
+
taxId: normalizedTaxIdSchema,
|
|
590
|
+
validateTaxId: z.boolean().default(false),
|
|
591
|
+
});
|
|
592
|
+
/** Container name of {@link OrganizationWritePort}. */
|
|
593
|
+
export const ORGANIZATION_WRITE_PORT = 'organizationWritePort';
|
|
594
|
+
/**
|
|
595
|
+
* The tax id a reader may print or hand out for an Organization: a company's,
|
|
596
|
+
* never a personal (B2C) Organization's. A personal Organization stores no tax
|
|
597
|
+
* id at all since `specs/177-tax-id-scope/` (it carried an internal 32-hex
|
|
598
|
+
* placeholder derived from the account id until then, issue #767), and the flag
|
|
599
|
+
* is still honoured for a payload written before that. `null` — not an empty
|
|
600
|
+
* string — when there is nothing to show, so every renderer drops its tax-id
|
|
601
|
+
* line rather than printing a label with no value.
|
|
602
|
+
*
|
|
603
|
+
* Published as a **function, not a port**, for the reason
|
|
604
|
+
* {@link normalizeOrganizationName} is: it is pure over its argument. Every
|
|
605
|
+
* module that prints an {@link OrganizationRecord}'s tax id asks it — the quote
|
|
606
|
+
* request document, the admin order and quote request panels, the price-book
|
|
607
|
+
* and push audience pickers, and the storefront's checkout — so the rule has
|
|
608
|
+
* one home.
|
|
609
|
+
*/
|
|
610
|
+
export function organizationCompanyTaxId(organization) {
|
|
611
|
+
if (organization.isPersonal)
|
|
612
|
+
return null;
|
|
613
|
+
const taxId = organization.taxId?.trim() ?? '';
|
|
614
|
+
return taxId === '' ? null : taxId;
|
|
615
|
+
}
|
|
358
616
|
/**
|
|
359
617
|
* Diacritic-insensitive normalisation for the organisation's `name_search`
|
|
360
618
|
* column and for any query string matched against it.
|
|
@@ -461,6 +719,13 @@ export const AdminOrganizationCreateBodySchema = registerOrganizationRequestSche
|
|
|
461
719
|
.extend({
|
|
462
720
|
status: z.enum(['active', 'pending_verification']).default('active'),
|
|
463
721
|
salesChannelIds: organizationSalesChannelIdsSchema,
|
|
722
|
+
/**
|
|
723
|
+
* `specs/177-tax-id-scope/` (FR-018) — create the organization as a branch
|
|
724
|
+
* under this parent, in the same Command, so that in `per-tree-root` it may
|
|
725
|
+
* carry the head office's tax ID. Naming a parent requires an unscoped
|
|
726
|
+
* platform administrator (D-260).
|
|
727
|
+
*/
|
|
728
|
+
parentId: uuidSchema.optional(),
|
|
464
729
|
});
|
|
465
730
|
/**
|
|
466
731
|
* `GET /api/v1/admin/organizations/sales-channel-options` — what the *New
|