@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.d.ts
CHANGED
|
@@ -45,6 +45,19 @@ export declare const creditInheritanceModeSchema: z.ZodEnum<{
|
|
|
45
45
|
independent_default: "independent_default";
|
|
46
46
|
}>;
|
|
47
47
|
export type CreditInheritanceMode = z.infer<typeof creditInheritanceModeSchema>;
|
|
48
|
+
/**
|
|
49
|
+
* The codes a redacted `organization` audit row keeps (issue #844).
|
|
50
|
+
*
|
|
51
|
+
* Owner: `organizations`; **codes only** — see
|
|
52
|
+
* `CUSTOMER_ACCOUNT_AUDIT_KEEP_KEYS` for the rule they extend. This module's
|
|
53
|
+
* snapshots record codes under `provider` and `outcome` (a tax-id validation)
|
|
54
|
+
* and `creditInheritanceMode`; `blockSource` and `countryCode` are kept
|
|
55
|
+
* wherever a writer records them, as they are on the account and the address.
|
|
56
|
+
* `orderConfirmationEmailCount` is the count the `organization.anonymized` row
|
|
57
|
+
* records instead of the addresses: the retention sweep redacts after that row
|
|
58
|
+
* is written, and must leave it as its owner wrote it (issue #844).
|
|
59
|
+
*/
|
|
60
|
+
export declare const ORGANIZATION_AUDIT_KEEP_KEYS: readonly string[];
|
|
48
61
|
export declare const addressKindSchema: z.ZodEnum<{
|
|
49
62
|
delivery: "delivery";
|
|
50
63
|
billing: "billing";
|
|
@@ -53,7 +66,7 @@ export type AddressKind = z.infer<typeof addressKindSchema>;
|
|
|
53
66
|
export declare const organizationSchema: z.ZodObject<{
|
|
54
67
|
id: z.ZodString;
|
|
55
68
|
name: z.ZodString;
|
|
56
|
-
taxId: z.ZodString
|
|
69
|
+
taxId: z.ZodNullable<z.ZodString>;
|
|
57
70
|
status: z.ZodEnum<{
|
|
58
71
|
active: "active";
|
|
59
72
|
rejected: "rejected";
|
|
@@ -94,6 +107,84 @@ export declare const organizationSchema: z.ZodObject<{
|
|
|
94
107
|
updatedAt: z.ZodString;
|
|
95
108
|
}, z.core.$strip>;
|
|
96
109
|
export type Organization = z.infer<typeof organizationSchema>;
|
|
110
|
+
/**
|
|
111
|
+
* `specs/178-extensible-columns/` FR-051 — an Organization as the admin detail
|
|
112
|
+
* and list reads return it. `extensions` is present only when the request named
|
|
113
|
+
* modules with `?extensions=` (`ExtensionsQuerySchema`): per
|
|
114
|
+
* named module that declares columns on `organizations` with `adminReads` and is
|
|
115
|
+
* present, its declared keys and values; an absent, switched-off or
|
|
116
|
+
* non-exposing module is simply not a key (FR-052).
|
|
117
|
+
*/
|
|
118
|
+
export declare const adminOrganizationSchema: z.ZodObject<{
|
|
119
|
+
id: z.ZodString;
|
|
120
|
+
name: z.ZodString;
|
|
121
|
+
taxId: z.ZodNullable<z.ZodString>;
|
|
122
|
+
status: z.ZodEnum<{
|
|
123
|
+
active: "active";
|
|
124
|
+
rejected: "rejected";
|
|
125
|
+
blocked: "blocked";
|
|
126
|
+
pending_verification: "pending_verification";
|
|
127
|
+
}>;
|
|
128
|
+
vatStatus: z.ZodEnum<{
|
|
129
|
+
vat_payer: "vat_payer";
|
|
130
|
+
vat_exempt: "vat_exempt";
|
|
131
|
+
reverse_charge: "reverse_charge";
|
|
132
|
+
}>;
|
|
133
|
+
isPersonal: z.ZodOptional<z.ZodBoolean>;
|
|
134
|
+
registeredAddress: z.ZodObject<{
|
|
135
|
+
street: z.ZodString;
|
|
136
|
+
city: z.ZodString;
|
|
137
|
+
postalCode: z.ZodString;
|
|
138
|
+
country: z.ZodString;
|
|
139
|
+
companyName: z.ZodOptional<z.ZodString>;
|
|
140
|
+
taxId: z.ZodOptional<z.ZodString>;
|
|
141
|
+
recipientName: z.ZodOptional<z.ZodString>;
|
|
142
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
fulfilmentStrategy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
145
|
+
any: "any";
|
|
146
|
+
default_first: "default_first";
|
|
147
|
+
lowest_stock_first: "lowest_stock_first";
|
|
148
|
+
highest_stock_first: "highest_stock_first";
|
|
149
|
+
defined_order: "defined_order";
|
|
150
|
+
}>>>;
|
|
151
|
+
fulfilmentStrategyWarehouseOrder: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
152
|
+
parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
153
|
+
path: z.ZodOptional<z.ZodString>;
|
|
154
|
+
creditInheritanceMode: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
155
|
+
shared_pool: "shared_pool";
|
|
156
|
+
independent_default: "independent_default";
|
|
157
|
+
}>>>;
|
|
158
|
+
createdAt: z.ZodString;
|
|
159
|
+
updatedAt: z.ZodString;
|
|
160
|
+
legalName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
161
|
+
orderConfirmationEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
162
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
163
|
+
blockedReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
164
|
+
blockedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
165
|
+
rejectedReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
166
|
+
rejectedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
167
|
+
approvedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
168
|
+
approvedByAdminUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
169
|
+
vatValidation: z.ZodOptional<z.ZodObject<{
|
|
170
|
+
outcome: z.ZodNullable<z.ZodEnum<{
|
|
171
|
+
failed: "failed";
|
|
172
|
+
deferred: "deferred";
|
|
173
|
+
validated: "validated";
|
|
174
|
+
unverified: "unverified";
|
|
175
|
+
}>>;
|
|
176
|
+
provider: z.ZodNullable<z.ZodEnum<{
|
|
177
|
+
vies: "vies";
|
|
178
|
+
gus_pl: "gus_pl";
|
|
179
|
+
mf_pl: "mf_pl";
|
|
180
|
+
format_only: "format_only";
|
|
181
|
+
}>>;
|
|
182
|
+
validatedAt: z.ZodNullable<z.ZodString>;
|
|
183
|
+
}, z.core.$strip>>;
|
|
184
|
+
customFieldValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
185
|
+
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>>;
|
|
186
|
+
}, z.core.$strip>;
|
|
187
|
+
export type AdminOrganization = z.infer<typeof adminOrganizationSchema>;
|
|
97
188
|
/**
|
|
98
189
|
* A single node in an organization subtree / ancestor chain. `depth` is the
|
|
99
190
|
* node's absolute depth in the tree (root = 0). Returned pre-order (subtree) or
|
|
@@ -170,12 +261,19 @@ export declare const customerAccountSchema: z.ZodObject<{
|
|
|
170
261
|
email: z.ZodString;
|
|
171
262
|
firstName: z.ZodString;
|
|
172
263
|
lastName: z.ZodString;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
264
|
+
organizationRole: z.ZodObject<{
|
|
265
|
+
id: z.ZodString;
|
|
266
|
+
name: z.ZodString;
|
|
267
|
+
kind: z.ZodEnum<{
|
|
268
|
+
custom: "custom";
|
|
269
|
+
administrator: "administrator";
|
|
270
|
+
member: "member";
|
|
271
|
+
}>;
|
|
272
|
+
}, z.core.$strict>;
|
|
273
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
177
274
|
emailVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
178
275
|
twoFactorEnabled: z.ZodBoolean;
|
|
276
|
+
preferredLanguage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
179
277
|
createdAt: z.ZodString;
|
|
180
278
|
updatedAt: z.ZodString;
|
|
181
279
|
}, z.core.$strip>;
|
|
@@ -196,10 +294,18 @@ export declare const addressSchema: z.ZodObject<{
|
|
|
196
294
|
isDefault: z.ZodBoolean;
|
|
197
295
|
}, z.core.$strip>;
|
|
198
296
|
export type Address = z.infer<typeof addressSchema>;
|
|
297
|
+
/**
|
|
298
|
+
* `specs/177-tax-id-scope/` — the one normalisation a tax ID gets before it is
|
|
299
|
+
* stored or looked up: whitespace and dashes stripped, upper-cased. It is the
|
|
300
|
+
* admin boundary's rule (`organizations`' `schemas/organization.ts`), published
|
|
301
|
+
* so the lookups (`OrganizationDetailsPort.findByTaxId`) and the conversion body
|
|
302
|
+
* apply exactly the same one. Pure, so it is a function and not a port.
|
|
303
|
+
*/
|
|
304
|
+
export declare function normalizeTaxId(input: string): string;
|
|
199
305
|
export declare const registerOrganizationRequestSchema: z.ZodObject<{
|
|
200
306
|
organization: z.ZodObject<{
|
|
201
307
|
name: z.ZodString;
|
|
202
|
-
taxId: z.ZodString
|
|
308
|
+
taxId: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
203
309
|
registeredAddress: z.ZodObject<{
|
|
204
310
|
street: z.ZodString;
|
|
205
311
|
city: z.ZodString;
|
|
@@ -211,14 +317,17 @@ export declare const registerOrganizationRequestSchema: z.ZodObject<{
|
|
|
211
317
|
vat_exempt: "vat_exempt";
|
|
212
318
|
reverse_charge: "reverse_charge";
|
|
213
319
|
}>>;
|
|
320
|
+
customFieldValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
214
321
|
}, z.core.$strip>;
|
|
215
322
|
firstUser: z.ZodObject<{
|
|
216
323
|
email: z.ZodString;
|
|
217
324
|
password: z.ZodString;
|
|
218
325
|
firstName: z.ZodString;
|
|
219
326
|
lastName: z.ZodString;
|
|
327
|
+
customFieldValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
220
328
|
}, z.core.$strip>;
|
|
221
329
|
acceptedTermsVersion: z.ZodString;
|
|
330
|
+
registryLookupId: z.ZodOptional<z.ZodString>;
|
|
222
331
|
}, z.core.$strip>;
|
|
223
332
|
export type RegisterOrganizationRequest = z.infer<typeof registerOrganizationRequestSchema>;
|
|
224
333
|
export declare const emailVerificationRequestSchema: z.ZodObject<{
|
|
@@ -250,6 +359,7 @@ export declare const cartMergeOutcomeSchema: z.ZodObject<{
|
|
|
250
359
|
merged: "merged";
|
|
251
360
|
noop_empty: "noop_empty";
|
|
252
361
|
noop_no_anon: "noop_no_anon";
|
|
362
|
+
skipped_permission: "skipped_permission";
|
|
253
363
|
}>;
|
|
254
364
|
movedLineCount: z.ZodNumber;
|
|
255
365
|
summedLineCount: z.ZodNumber;
|
|
@@ -283,10 +393,16 @@ export declare const customerLoginResponseSchema: z.ZodObject<{
|
|
|
283
393
|
id: z.ZodString;
|
|
284
394
|
email: z.ZodString;
|
|
285
395
|
organizationId: z.ZodNullable<z.ZodString>;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
396
|
+
organizationRole: z.ZodObject<{
|
|
397
|
+
id: z.ZodString;
|
|
398
|
+
name: z.ZodString;
|
|
399
|
+
kind: z.ZodEnum<{
|
|
400
|
+
custom: "custom";
|
|
401
|
+
administrator: "administrator";
|
|
402
|
+
member: "member";
|
|
403
|
+
}>;
|
|
404
|
+
}, z.core.$strict>;
|
|
405
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
290
406
|
twoFactorEnabled: z.ZodBoolean;
|
|
291
407
|
}, z.core.$strip>;
|
|
292
408
|
cartMerge: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
@@ -300,6 +416,61 @@ export declare const customerLoginResponseSchema: z.ZodObject<{
|
|
|
300
416
|
}, z.core.$strip>;
|
|
301
417
|
}, z.core.$strip>;
|
|
302
418
|
export type CustomerLoginResponse = z.infer<typeof customerLoginResponseSchema>;
|
|
419
|
+
/**
|
|
420
|
+
* Issue #368 — what a completed customer sign-in does beyond issuing the
|
|
421
|
+
* session: the anonymous basket (`b2b_cart_anon`) is merged into the
|
|
422
|
+
* customer's and the anonymous comparison (`compare_token`) is adopted.
|
|
423
|
+
*
|
|
424
|
+
* `organizations` owns the step and runs it from its password sign-in; a route
|
|
425
|
+
* that establishes the session itself — `mfa`'s second-step verify, its
|
|
426
|
+
* enforced-enrolment completion and its federated sign-in exchange (issues
|
|
427
|
+
* #1188, #1279) — calls it through {@link CustomerSignInCompletionPort} once the
|
|
428
|
+
* session cookie is set.
|
|
429
|
+
*/
|
|
430
|
+
export interface CustomerSignInCompletionInput {
|
|
431
|
+
customerAccountId: string;
|
|
432
|
+
/** The sign-in request's cookies, as `@fastify/cookie` parsed them. */
|
|
433
|
+
cookies: Readonly<Record<string, string | undefined>>;
|
|
434
|
+
/**
|
|
435
|
+
* Issue #1188 — the sales channel the sign-in belongs to, where the route
|
|
436
|
+
* knows it better than its request does: the federated sign-in exchange
|
|
437
|
+
* (issue #1279) passes the channel its transaction was started on, which it
|
|
438
|
+
* has already required the request to be asked on. Only the anonymous
|
|
439
|
+
* basket of that store is merged (`specs/154-sales-channel-access/`
|
|
440
|
+
* contracts/basket-attribution.md §3). Absent or `null`: the request's
|
|
441
|
+
* resolved channel, as for every other sign-in.
|
|
442
|
+
*/
|
|
443
|
+
salesChannelId?: string | null;
|
|
444
|
+
/**
|
|
445
|
+
* Where a failed step is reported. The step is best-effort — a failed merge
|
|
446
|
+
* never breaks the sign-in (feature 037 FR-007/FR-008) — so a failure is
|
|
447
|
+
* logged here and answered as "nothing merged".
|
|
448
|
+
*/
|
|
449
|
+
log: {
|
|
450
|
+
error(details: object, message: string): void;
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
export interface CustomerSignInCompletion {
|
|
454
|
+
/** The merge as the storefront reads it; `null` when no basket was carried or the merge failed. */
|
|
455
|
+
cartMerge: CartMergeOutcomePublic | null;
|
|
456
|
+
/**
|
|
457
|
+
* Whether the response should clear `b2b_cart_anon`: the basket it pointed at
|
|
458
|
+
* was consumed or empty. A failure, no basket, and a skipped merge keep it.
|
|
459
|
+
*/
|
|
460
|
+
clearAnonymousCartCookie: boolean;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Container name: `customerSignInCompletionPort`. Owner: `organizations`.
|
|
464
|
+
*
|
|
465
|
+
* Reached with `lazyPort<CustomerSignInCompletionPort>(ctx, 'customerSignInCompletionPort')`
|
|
466
|
+
* and never captured into a singleton (issue #368). `complete` does not throw
|
|
467
|
+
* for a failed merge: it logs the failure and answers "nothing merged".
|
|
468
|
+
* Consumers: `mfa`'s second-step verify and enforced-enrolment completion
|
|
469
|
+
* (#368) and its federated sign-in exchange (#1188, #1279).
|
|
470
|
+
*/
|
|
471
|
+
export interface CustomerSignInCompletionPort {
|
|
472
|
+
complete(input: CustomerSignInCompletionInput): Promise<CustomerSignInCompletion>;
|
|
473
|
+
}
|
|
303
474
|
export declare const changePasswordRequestSchema: z.ZodObject<{
|
|
304
475
|
currentPassword: z.ZodString;
|
|
305
476
|
newPassword: z.ZodString;
|
|
@@ -332,24 +503,11 @@ export declare const updateAddressRequestSchema: z.ZodObject<{
|
|
|
332
503
|
isDefault: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
333
504
|
}, z.core.$strip>;
|
|
334
505
|
export type UpdateAddressRequest = z.infer<typeof updateAddressRequestSchema>;
|
|
335
|
-
export declare const inviteMemberRequestSchema: z.ZodObject<{
|
|
336
|
-
email: z.ZodString;
|
|
337
|
-
role: z.ZodOptional<z.ZodEnum<{
|
|
338
|
-
organization_admin: "organization_admin";
|
|
339
|
-
regular_user: "regular_user";
|
|
340
|
-
}>>;
|
|
341
|
-
}, z.core.$strip>;
|
|
342
506
|
export declare const acceptInvitationRequestSchema: z.ZodObject<{
|
|
343
507
|
password: z.ZodString;
|
|
344
508
|
firstName: z.ZodString;
|
|
345
509
|
lastName: z.ZodString;
|
|
346
510
|
}, z.core.$strip>;
|
|
347
|
-
export declare const changeMemberRoleRequestSchema: z.ZodObject<{
|
|
348
|
-
role: z.ZodEnum<{
|
|
349
|
-
organization_admin: "organization_admin";
|
|
350
|
-
regular_user: "regular_user";
|
|
351
|
-
}>;
|
|
352
|
-
}, z.core.$strip>;
|
|
353
511
|
/** Platform admin — PATCH `/admin/organizations/:id` */
|
|
354
512
|
export declare const adminPatchOrganizationRequestSchema: z.ZodObject<{
|
|
355
513
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -380,25 +538,6 @@ export declare const adminPatchOrganizationRequestSchema: z.ZodObject<{
|
|
|
380
538
|
export declare const adminRecoverOrgAccessRequestSchema: z.ZodObject<{
|
|
381
539
|
promoteCustomerAccountId: z.ZodString;
|
|
382
540
|
}, z.core.$strip>;
|
|
383
|
-
/** Platform admin — POST `/admin/organizations/:id/members` (direct create) */
|
|
384
|
-
export declare const adminDirectMemberRequestSchema: z.ZodObject<{
|
|
385
|
-
email: z.ZodString;
|
|
386
|
-
firstName: z.ZodString;
|
|
387
|
-
lastName: z.ZodString;
|
|
388
|
-
password: z.ZodString;
|
|
389
|
-
role: z.ZodOptional<z.ZodEnum<{
|
|
390
|
-
organization_admin: "organization_admin";
|
|
391
|
-
regular_user: "regular_user";
|
|
392
|
-
}>>;
|
|
393
|
-
}, z.core.$strip>;
|
|
394
|
-
/** Platform admin — PATCH member role */
|
|
395
|
-
export declare const adminPatchMemberRoleRequestSchema: z.ZodObject<{
|
|
396
|
-
role: z.ZodEnum<{
|
|
397
|
-
organization_admin: "organization_admin";
|
|
398
|
-
regular_user: "regular_user";
|
|
399
|
-
}>;
|
|
400
|
-
expectedUpdatedAt: z.ZodOptional<z.ZodString>;
|
|
401
|
-
}, z.core.$strip>;
|
|
402
541
|
/**
|
|
403
542
|
* Feature 056 (T032) — Platform admin — PATCH member roll-up capability.
|
|
404
543
|
* When enabled, this customer login sees/acts across its organization's subtree.
|
|
@@ -419,7 +558,7 @@ export declare const registerOrganizationResponseSchema: z.ZodObject<{
|
|
|
419
558
|
organization: z.ZodObject<{
|
|
420
559
|
id: z.ZodString;
|
|
421
560
|
name: z.ZodString;
|
|
422
|
-
taxId: z.ZodString
|
|
561
|
+
taxId: z.ZodNullable<z.ZodString>;
|
|
423
562
|
status: z.ZodEnum<{
|
|
424
563
|
active: "active";
|
|
425
564
|
rejected: "rejected";
|
|
@@ -465,18 +604,361 @@ export declare const registerOrganizationResponseSchema: z.ZodObject<{
|
|
|
465
604
|
email: z.ZodString;
|
|
466
605
|
firstName: z.ZodString;
|
|
467
606
|
lastName: z.ZodString;
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
607
|
+
organizationRole: z.ZodObject<{
|
|
608
|
+
id: z.ZodString;
|
|
609
|
+
name: z.ZodString;
|
|
610
|
+
kind: z.ZodEnum<{
|
|
611
|
+
custom: "custom";
|
|
612
|
+
administrator: "administrator";
|
|
613
|
+
member: "member";
|
|
614
|
+
}>;
|
|
615
|
+
}, z.core.$strict>;
|
|
616
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
472
617
|
emailVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
473
618
|
twoFactorEnabled: z.ZodBoolean;
|
|
619
|
+
preferredLanguage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
474
620
|
createdAt: z.ZodString;
|
|
475
621
|
updatedAt: z.ZodString;
|
|
476
622
|
}, z.core.$strip>;
|
|
477
623
|
emailVerificationSent: z.ZodBoolean;
|
|
478
624
|
}, z.core.$strip>;
|
|
479
625
|
export type RegisterOrganizationResponse = z.infer<typeof registerOrganizationResponseSchema>;
|
|
626
|
+
/** `GET /api/v1/admin/organizations` — one page of Organizations. */
|
|
627
|
+
export declare const adminOrganizationListResponseSchema: z.ZodObject<{
|
|
628
|
+
data: z.ZodArray<z.ZodObject<{
|
|
629
|
+
id: z.ZodString;
|
|
630
|
+
name: z.ZodString;
|
|
631
|
+
taxId: z.ZodNullable<z.ZodString>;
|
|
632
|
+
status: z.ZodEnum<{
|
|
633
|
+
active: "active";
|
|
634
|
+
rejected: "rejected";
|
|
635
|
+
blocked: "blocked";
|
|
636
|
+
pending_verification: "pending_verification";
|
|
637
|
+
}>;
|
|
638
|
+
vatStatus: z.ZodEnum<{
|
|
639
|
+
vat_payer: "vat_payer";
|
|
640
|
+
vat_exempt: "vat_exempt";
|
|
641
|
+
reverse_charge: "reverse_charge";
|
|
642
|
+
}>;
|
|
643
|
+
isPersonal: z.ZodOptional<z.ZodBoolean>;
|
|
644
|
+
registeredAddress: z.ZodObject<{
|
|
645
|
+
street: z.ZodString;
|
|
646
|
+
city: z.ZodString;
|
|
647
|
+
postalCode: z.ZodString;
|
|
648
|
+
country: z.ZodString;
|
|
649
|
+
companyName: z.ZodOptional<z.ZodString>;
|
|
650
|
+
taxId: z.ZodOptional<z.ZodString>;
|
|
651
|
+
recipientName: z.ZodOptional<z.ZodString>;
|
|
652
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
653
|
+
}, z.core.$strip>;
|
|
654
|
+
fulfilmentStrategy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
655
|
+
any: "any";
|
|
656
|
+
default_first: "default_first";
|
|
657
|
+
lowest_stock_first: "lowest_stock_first";
|
|
658
|
+
highest_stock_first: "highest_stock_first";
|
|
659
|
+
defined_order: "defined_order";
|
|
660
|
+
}>>>;
|
|
661
|
+
fulfilmentStrategyWarehouseOrder: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
662
|
+
parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
663
|
+
path: z.ZodOptional<z.ZodString>;
|
|
664
|
+
creditInheritanceMode: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
665
|
+
shared_pool: "shared_pool";
|
|
666
|
+
independent_default: "independent_default";
|
|
667
|
+
}>>>;
|
|
668
|
+
createdAt: z.ZodString;
|
|
669
|
+
updatedAt: z.ZodString;
|
|
670
|
+
legalName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
671
|
+
orderConfirmationEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
672
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
673
|
+
blockedReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
674
|
+
blockedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
675
|
+
rejectedReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
676
|
+
rejectedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
677
|
+
approvedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
678
|
+
approvedByAdminUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
679
|
+
vatValidation: z.ZodOptional<z.ZodObject<{
|
|
680
|
+
outcome: z.ZodNullable<z.ZodEnum<{
|
|
681
|
+
failed: "failed";
|
|
682
|
+
deferred: "deferred";
|
|
683
|
+
validated: "validated";
|
|
684
|
+
unverified: "unverified";
|
|
685
|
+
}>>;
|
|
686
|
+
provider: z.ZodNullable<z.ZodEnum<{
|
|
687
|
+
vies: "vies";
|
|
688
|
+
gus_pl: "gus_pl";
|
|
689
|
+
mf_pl: "mf_pl";
|
|
690
|
+
format_only: "format_only";
|
|
691
|
+
}>>;
|
|
692
|
+
validatedAt: z.ZodNullable<z.ZodString>;
|
|
693
|
+
}, z.core.$strip>>;
|
|
694
|
+
customFieldValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
695
|
+
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>>;
|
|
696
|
+
}, z.core.$strip>>;
|
|
697
|
+
pagination: z.ZodObject<{
|
|
698
|
+
cursor: z.ZodNullable<z.ZodString>;
|
|
699
|
+
hasMore: z.ZodBoolean;
|
|
700
|
+
limit: z.ZodNumber;
|
|
701
|
+
}, z.core.$strip>;
|
|
702
|
+
}, z.core.$strip>;
|
|
703
|
+
export type AdminOrganizationListResponse = z.infer<typeof adminOrganizationListResponseSchema>;
|
|
704
|
+
/**
|
|
705
|
+
* A member as the operator's screens show it: the detail's member roster and
|
|
706
|
+
* the answer of every admin member write (profile, roll-up, role, block,
|
|
707
|
+
* unblock). The role is `organizationRole` (`specs/170-organization-roles/`
|
|
708
|
+
* FR-008, FR-073); an operator view carries no effective permissions.
|
|
709
|
+
*/
|
|
710
|
+
export declare const adminOrganizationMemberSchema: z.ZodObject<{
|
|
711
|
+
id: z.ZodString;
|
|
712
|
+
email: z.ZodString;
|
|
713
|
+
firstName: z.ZodString;
|
|
714
|
+
lastName: z.ZodString;
|
|
715
|
+
subtreeRollupEnabled: z.ZodBoolean;
|
|
716
|
+
emailVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
717
|
+
twoFactorEnabled: z.ZodBoolean;
|
|
718
|
+
lastLoginAt: z.ZodNullable<z.ZodString>;
|
|
719
|
+
organizationRole: z.ZodObject<{
|
|
720
|
+
id: z.ZodString;
|
|
721
|
+
name: z.ZodString;
|
|
722
|
+
kind: z.ZodEnum<{
|
|
723
|
+
custom: "custom";
|
|
724
|
+
administrator: "administrator";
|
|
725
|
+
member: "member";
|
|
726
|
+
}>;
|
|
727
|
+
}, z.core.$strict>;
|
|
728
|
+
createdAt: z.ZodString;
|
|
729
|
+
updatedAt: z.ZodString;
|
|
730
|
+
}, z.core.$strip>;
|
|
731
|
+
export type AdminOrganizationMember = z.infer<typeof adminOrganizationMemberSchema>;
|
|
732
|
+
/**
|
|
733
|
+
* `GET /api/v1/admin/organizations/:id` — the Organization, its active members,
|
|
734
|
+
* and its two predefined roles, so the member role select can offer
|
|
735
|
+
* Administrator and Member to an operator who may assign roles but not read the
|
|
736
|
+
* role list (`specs/170-organization-roles/contracts/operator-api.md` §5).
|
|
737
|
+
*/
|
|
738
|
+
export declare const adminOrganizationDetailSchema: z.ZodObject<{
|
|
739
|
+
id: z.ZodString;
|
|
740
|
+
name: z.ZodString;
|
|
741
|
+
taxId: z.ZodNullable<z.ZodString>;
|
|
742
|
+
status: z.ZodEnum<{
|
|
743
|
+
active: "active";
|
|
744
|
+
rejected: "rejected";
|
|
745
|
+
blocked: "blocked";
|
|
746
|
+
pending_verification: "pending_verification";
|
|
747
|
+
}>;
|
|
748
|
+
vatStatus: z.ZodEnum<{
|
|
749
|
+
vat_payer: "vat_payer";
|
|
750
|
+
vat_exempt: "vat_exempt";
|
|
751
|
+
reverse_charge: "reverse_charge";
|
|
752
|
+
}>;
|
|
753
|
+
isPersonal: z.ZodOptional<z.ZodBoolean>;
|
|
754
|
+
registeredAddress: z.ZodObject<{
|
|
755
|
+
street: z.ZodString;
|
|
756
|
+
city: z.ZodString;
|
|
757
|
+
postalCode: z.ZodString;
|
|
758
|
+
country: z.ZodString;
|
|
759
|
+
companyName: z.ZodOptional<z.ZodString>;
|
|
760
|
+
taxId: z.ZodOptional<z.ZodString>;
|
|
761
|
+
recipientName: z.ZodOptional<z.ZodString>;
|
|
762
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
763
|
+
}, z.core.$strip>;
|
|
764
|
+
fulfilmentStrategy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
765
|
+
any: "any";
|
|
766
|
+
default_first: "default_first";
|
|
767
|
+
lowest_stock_first: "lowest_stock_first";
|
|
768
|
+
highest_stock_first: "highest_stock_first";
|
|
769
|
+
defined_order: "defined_order";
|
|
770
|
+
}>>>;
|
|
771
|
+
fulfilmentStrategyWarehouseOrder: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
772
|
+
parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
773
|
+
path: z.ZodOptional<z.ZodString>;
|
|
774
|
+
creditInheritanceMode: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
775
|
+
shared_pool: "shared_pool";
|
|
776
|
+
independent_default: "independent_default";
|
|
777
|
+
}>>>;
|
|
778
|
+
createdAt: z.ZodString;
|
|
779
|
+
updatedAt: z.ZodString;
|
|
780
|
+
legalName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
781
|
+
orderConfirmationEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
782
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
783
|
+
blockedReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
784
|
+
blockedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
785
|
+
rejectedReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
786
|
+
rejectedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
787
|
+
approvedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
788
|
+
approvedByAdminUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
789
|
+
vatValidation: z.ZodOptional<z.ZodObject<{
|
|
790
|
+
outcome: z.ZodNullable<z.ZodEnum<{
|
|
791
|
+
failed: "failed";
|
|
792
|
+
deferred: "deferred";
|
|
793
|
+
validated: "validated";
|
|
794
|
+
unverified: "unverified";
|
|
795
|
+
}>>;
|
|
796
|
+
provider: z.ZodNullable<z.ZodEnum<{
|
|
797
|
+
vies: "vies";
|
|
798
|
+
gus_pl: "gus_pl";
|
|
799
|
+
mf_pl: "mf_pl";
|
|
800
|
+
format_only: "format_only";
|
|
801
|
+
}>>;
|
|
802
|
+
validatedAt: z.ZodNullable<z.ZodString>;
|
|
803
|
+
}, z.core.$strip>>;
|
|
804
|
+
customFieldValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
805
|
+
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>>;
|
|
806
|
+
members: z.ZodArray<z.ZodObject<{
|
|
807
|
+
id: z.ZodString;
|
|
808
|
+
email: z.ZodString;
|
|
809
|
+
firstName: z.ZodString;
|
|
810
|
+
lastName: z.ZodString;
|
|
811
|
+
subtreeRollupEnabled: z.ZodBoolean;
|
|
812
|
+
emailVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
813
|
+
twoFactorEnabled: z.ZodBoolean;
|
|
814
|
+
lastLoginAt: z.ZodNullable<z.ZodString>;
|
|
815
|
+
organizationRole: z.ZodObject<{
|
|
816
|
+
id: z.ZodString;
|
|
817
|
+
name: z.ZodString;
|
|
818
|
+
kind: z.ZodEnum<{
|
|
819
|
+
custom: "custom";
|
|
820
|
+
administrator: "administrator";
|
|
821
|
+
member: "member";
|
|
822
|
+
}>;
|
|
823
|
+
}, z.core.$strict>;
|
|
824
|
+
createdAt: z.ZodString;
|
|
825
|
+
updatedAt: z.ZodString;
|
|
826
|
+
}, z.core.$strip>>;
|
|
827
|
+
predefinedRoles: z.ZodArray<z.ZodObject<{
|
|
828
|
+
id: z.ZodString;
|
|
829
|
+
name: z.ZodString;
|
|
830
|
+
kind: z.ZodEnum<{
|
|
831
|
+
custom: "custom";
|
|
832
|
+
administrator: "administrator";
|
|
833
|
+
member: "member";
|
|
834
|
+
}>;
|
|
835
|
+
}, z.core.$strict>>;
|
|
836
|
+
}, z.core.$strip>;
|
|
837
|
+
export type AdminOrganizationDetail = z.infer<typeof adminOrganizationDetailSchema>;
|
|
838
|
+
/**
|
|
839
|
+
* A member as the buyer's roster shows it — `GET /api/v1/organizations/mine/members`
|
|
840
|
+
* and `PATCH …/mine/members/:id/role`. A session view (`customerAccountSchema`)
|
|
841
|
+
* adds the member's effective permissions; a roster row does not.
|
|
842
|
+
*/
|
|
843
|
+
export declare const organizationMemberSchema: z.ZodObject<{
|
|
844
|
+
id: z.ZodString;
|
|
845
|
+
organizationId: z.ZodString;
|
|
846
|
+
email: z.ZodString;
|
|
847
|
+
firstName: z.ZodString;
|
|
848
|
+
lastName: z.ZodString;
|
|
849
|
+
organizationRole: z.ZodObject<{
|
|
850
|
+
id: z.ZodString;
|
|
851
|
+
name: z.ZodString;
|
|
852
|
+
kind: z.ZodEnum<{
|
|
853
|
+
custom: "custom";
|
|
854
|
+
administrator: "administrator";
|
|
855
|
+
member: "member";
|
|
856
|
+
}>;
|
|
857
|
+
}, z.core.$strict>;
|
|
858
|
+
emailVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
859
|
+
twoFactorEnabled: z.ZodBoolean;
|
|
860
|
+
createdAt: z.ZodString;
|
|
861
|
+
updatedAt: z.ZodString;
|
|
862
|
+
}, z.core.$strip>;
|
|
863
|
+
export type OrganizationMember = z.infer<typeof organizationMemberSchema>;
|
|
864
|
+
export declare const organizationMemberListResponseSchema: z.ZodObject<{
|
|
865
|
+
data: z.ZodArray<z.ZodObject<{
|
|
866
|
+
id: z.ZodString;
|
|
867
|
+
organizationId: z.ZodString;
|
|
868
|
+
email: z.ZodString;
|
|
869
|
+
firstName: z.ZodString;
|
|
870
|
+
lastName: z.ZodString;
|
|
871
|
+
organizationRole: z.ZodObject<{
|
|
872
|
+
id: z.ZodString;
|
|
873
|
+
name: z.ZodString;
|
|
874
|
+
kind: z.ZodEnum<{
|
|
875
|
+
custom: "custom";
|
|
876
|
+
administrator: "administrator";
|
|
877
|
+
member: "member";
|
|
878
|
+
}>;
|
|
879
|
+
}, z.core.$strict>;
|
|
880
|
+
emailVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
881
|
+
twoFactorEnabled: z.ZodBoolean;
|
|
882
|
+
createdAt: z.ZodString;
|
|
883
|
+
updatedAt: z.ZodString;
|
|
884
|
+
}, z.core.$strip>>;
|
|
885
|
+
}, z.core.$strip>;
|
|
886
|
+
export type OrganizationMemberListResponse = z.infer<typeof organizationMemberListResponseSchema>;
|
|
887
|
+
/** A pending invitation — `GET /api/v1/organizations/mine/invitations`. */
|
|
888
|
+
export declare const organizationInvitationSchema: z.ZodObject<{
|
|
889
|
+
id: z.ZodString;
|
|
890
|
+
organizationId: z.ZodString;
|
|
891
|
+
email: z.ZodString;
|
|
892
|
+
organizationRole: z.ZodObject<{
|
|
893
|
+
id: z.ZodString;
|
|
894
|
+
name: z.ZodString;
|
|
895
|
+
kind: z.ZodEnum<{
|
|
896
|
+
custom: "custom";
|
|
897
|
+
administrator: "administrator";
|
|
898
|
+
member: "member";
|
|
899
|
+
}>;
|
|
900
|
+
}, z.core.$strict>;
|
|
901
|
+
invitedByCustomerAccountId: z.ZodNullable<z.ZodString>;
|
|
902
|
+
expiresAt: z.ZodString;
|
|
903
|
+
createdAt: z.ZodString;
|
|
904
|
+
}, z.core.$strip>;
|
|
905
|
+
export type OrganizationInvitation = z.infer<typeof organizationInvitationSchema>;
|
|
906
|
+
export declare const organizationInvitationListResponseSchema: z.ZodObject<{
|
|
907
|
+
data: z.ZodArray<z.ZodObject<{
|
|
908
|
+
id: z.ZodString;
|
|
909
|
+
organizationId: z.ZodString;
|
|
910
|
+
email: z.ZodString;
|
|
911
|
+
organizationRole: z.ZodObject<{
|
|
912
|
+
id: z.ZodString;
|
|
913
|
+
name: z.ZodString;
|
|
914
|
+
kind: z.ZodEnum<{
|
|
915
|
+
custom: "custom";
|
|
916
|
+
administrator: "administrator";
|
|
917
|
+
member: "member";
|
|
918
|
+
}>;
|
|
919
|
+
}, z.core.$strict>;
|
|
920
|
+
invitedByCustomerAccountId: z.ZodNullable<z.ZodString>;
|
|
921
|
+
expiresAt: z.ZodString;
|
|
922
|
+
createdAt: z.ZodString;
|
|
923
|
+
}, z.core.$strip>>;
|
|
924
|
+
}, z.core.$strip>;
|
|
925
|
+
export type OrganizationInvitationListResponse = z.infer<typeof organizationInvitationListResponseSchema>;
|
|
926
|
+
/** `POST /api/v1/organizations/mine/invitations` — 201. */
|
|
927
|
+
export declare const inviteMemberResponseSchema: z.ZodObject<{
|
|
928
|
+
data: z.ZodObject<{
|
|
929
|
+
invitationId: z.ZodString;
|
|
930
|
+
expiresAt: z.ZodString;
|
|
931
|
+
}, z.core.$strip>;
|
|
932
|
+
}, z.core.$strip>;
|
|
933
|
+
export type InviteMemberResponse = z.infer<typeof inviteMemberResponseSchema>;
|
|
934
|
+
/** `POST /api/v1/organizations/invitations/:token/accept` — the account the invitation created, as a session view. */
|
|
935
|
+
export declare const acceptInvitationResponseSchema: z.ZodObject<{
|
|
936
|
+
data: z.ZodObject<{
|
|
937
|
+
customerAccount: z.ZodObject<{
|
|
938
|
+
id: z.ZodString;
|
|
939
|
+
organizationId: z.ZodString;
|
|
940
|
+
email: z.ZodString;
|
|
941
|
+
firstName: z.ZodString;
|
|
942
|
+
lastName: z.ZodString;
|
|
943
|
+
organizationRole: z.ZodObject<{
|
|
944
|
+
id: z.ZodString;
|
|
945
|
+
name: z.ZodString;
|
|
946
|
+
kind: z.ZodEnum<{
|
|
947
|
+
custom: "custom";
|
|
948
|
+
administrator: "administrator";
|
|
949
|
+
member: "member";
|
|
950
|
+
}>;
|
|
951
|
+
}, z.core.$strict>;
|
|
952
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
953
|
+
emailVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
954
|
+
twoFactorEnabled: z.ZodBoolean;
|
|
955
|
+
preferredLanguage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
956
|
+
createdAt: z.ZodString;
|
|
957
|
+
updatedAt: z.ZodString;
|
|
958
|
+
}, z.core.$strip>;
|
|
959
|
+
}, z.core.$strip>;
|
|
960
|
+
}, z.core.$strip>;
|
|
961
|
+
export type AcceptInvitationResponse = z.infer<typeof acceptInvitationResponseSchema>;
|
|
480
962
|
/**
|
|
481
963
|
* One row of the admin Organization picker.
|
|
482
964
|
*
|
|
@@ -553,7 +1035,8 @@ export declare const salesRepOrganizationSchema: z.ZodObject<{
|
|
|
553
1035
|
assignedAt: z.ZodString;
|
|
554
1036
|
}, z.core.$strip>;
|
|
555
1037
|
export type SalesRepOrganization = z.infer<typeof salesRepOrganizationSchema>;
|
|
556
|
-
|
|
1038
|
+
/** `gus_pl` — feature 173: the GUS REGON registry, written by a registration-time lookup. */
|
|
1039
|
+
export type VatValidationProvider = 'vies' | 'mf_pl' | 'format_only' | 'gus_pl';
|
|
557
1040
|
export type VatValidationOutcome = 'validated' | 'failed' | 'deferred' | 'unverified';
|
|
558
1041
|
/** The JSONB snapshot the organisation's registered address is stored as. */
|
|
559
1042
|
export interface OrganizationRegisteredAddress {
|
|
@@ -572,7 +1055,12 @@ export interface OrganizationRecord {
|
|
|
572
1055
|
id: string;
|
|
573
1056
|
name: string;
|
|
574
1057
|
legalName: string | null;
|
|
575
|
-
|
|
1058
|
+
/**
|
|
1059
|
+
* `null` for a personal (B2C) organization (`specs/177-tax-id-scope/`,
|
|
1060
|
+
* FR-004): it used to carry a 32-hex placeholder derived from its account id.
|
|
1061
|
+
* Print it through {@link organizationCompanyTaxId}.
|
|
1062
|
+
*/
|
|
1063
|
+
taxId: string | null;
|
|
576
1064
|
status: OrganizationStatus;
|
|
577
1065
|
vatStatus: VatStatus;
|
|
578
1066
|
isPersonal: boolean;
|
|
@@ -588,7 +1076,6 @@ export interface OrganizationRecord {
|
|
|
588
1076
|
rejectedAt: Date | null;
|
|
589
1077
|
approvedAt: Date | null;
|
|
590
1078
|
approvedByAdminUserId: string | null;
|
|
591
|
-
requiresCartApproval: boolean;
|
|
592
1079
|
fulfilmentStrategy: FulfilmentStrategy | null;
|
|
593
1080
|
fulfilmentStrategyWarehouseOrder: string[] | null;
|
|
594
1081
|
parentId: string | null;
|
|
@@ -601,6 +1088,187 @@ export interface OrganizationRecord {
|
|
|
601
1088
|
createdAt: Date;
|
|
602
1089
|
updatedAt: Date;
|
|
603
1090
|
deletedAt: Date | null;
|
|
1091
|
+
/**
|
|
1092
|
+
* When `organization.convert_to_company` turned this personal organization
|
|
1093
|
+
* into a company (`specs/177-tax-id-scope/`, FR-039); `null` for one that was
|
|
1094
|
+
* never converted. Set once, never cleared — `returns` reads it to keep a
|
|
1095
|
+
* consumer's withdrawal right for orders placed before it (FR-040).
|
|
1096
|
+
*/
|
|
1097
|
+
convertedToCompanyAt: Date | null;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Where the same tax ID may appear twice (`contracts/tax-id-scope.md` §1):
|
|
1101
|
+
* `global` — nowhere, every tax ID belongs to one organization (the default of
|
|
1102
|
+
* every installation); `per-tree-root` — only inside one organization tree, so
|
|
1103
|
+
* a head office and its branches may share it. Enforced by the database and
|
|
1104
|
+
* changed only by the audited `organization.tax_id_scope.set` Command.
|
|
1105
|
+
*/
|
|
1106
|
+
export declare const taxIdScopeSchema: z.ZodEnum<{
|
|
1107
|
+
global: "global";
|
|
1108
|
+
"per-tree-root": "per-tree-root";
|
|
1109
|
+
}>;
|
|
1110
|
+
export type TaxIdScope = z.infer<typeof taxIdScopeSchema>;
|
|
1111
|
+
/** `PUT /api/v1/admin/organizations/tax-id-scope` — the scope to switch to. */
|
|
1112
|
+
export declare const adminTaxIdScopeSetBodySchema: z.ZodObject<{
|
|
1113
|
+
scope: z.ZodEnum<{
|
|
1114
|
+
global: "global";
|
|
1115
|
+
"per-tree-root": "per-tree-root";
|
|
1116
|
+
}>;
|
|
1117
|
+
}, z.core.$strip>;
|
|
1118
|
+
export type AdminTaxIdScopeSetBody = z.infer<typeof adminTaxIdScopeSetBodySchema>;
|
|
1119
|
+
/**
|
|
1120
|
+
* `GET` / `PUT /api/v1/admin/organizations/tax-id-scope` — the installation's
|
|
1121
|
+
* scope, who set it last, how many tax IDs are on more than one organization,
|
|
1122
|
+
* and whether the database enforcement agrees with the stored scope
|
|
1123
|
+
* (`mismatch` only after a hand edit; re-applying the scope repairs it).
|
|
1124
|
+
*/
|
|
1125
|
+
export declare const adminTaxIdScopeResponseSchema: z.ZodObject<{
|
|
1126
|
+
data: z.ZodObject<{
|
|
1127
|
+
scope: z.ZodEnum<{
|
|
1128
|
+
global: "global";
|
|
1129
|
+
"per-tree-root": "per-tree-root";
|
|
1130
|
+
}>;
|
|
1131
|
+
updatedAt: z.ZodString;
|
|
1132
|
+
updatedByAdminUserId: z.ZodNullable<z.ZodString>;
|
|
1133
|
+
sharedTaxIdCount: z.ZodNumber;
|
|
1134
|
+
enforcement: z.ZodEnum<{
|
|
1135
|
+
consistent: "consistent";
|
|
1136
|
+
mismatch: "mismatch";
|
|
1137
|
+
}>;
|
|
1138
|
+
}, z.core.$strip>;
|
|
1139
|
+
}, z.core.$strip>;
|
|
1140
|
+
export type AdminTaxIdScopeResponse = z.infer<typeof adminTaxIdScopeResponseSchema>;
|
|
1141
|
+
/**
|
|
1142
|
+
* What {@link OrganizationDetailsPort.resolveByTaxId} answers. `one` carries the
|
|
1143
|
+
* tree's root (all matches share it in both scopes); `ambiguous` — matches in
|
|
1144
|
+
* more than one tree — is unreachable in `global` and `per-tree-root` alike and
|
|
1145
|
+
* is typed for a later scope, so a caller handles it today.
|
|
1146
|
+
*/
|
|
1147
|
+
export type TaxIdResolution = {
|
|
1148
|
+
kind: 'none';
|
|
1149
|
+
} | {
|
|
1150
|
+
kind: 'one';
|
|
1151
|
+
organization: OrganizationRecord;
|
|
1152
|
+
} | {
|
|
1153
|
+
kind: 'ambiguous';
|
|
1154
|
+
organizations: OrganizationRecord[];
|
|
1155
|
+
};
|
|
1156
|
+
/**
|
|
1157
|
+
* `POST /api/v1/admin/organizations/:id/convert-to-company`
|
|
1158
|
+
* (`contracts/convert-to-company.md` §2). The tax ID is normalised exactly as
|
|
1159
|
+
* the admin boundary normalises it. `validateTaxId` is the route's own switch
|
|
1160
|
+
* — a VAT validation after the conversion commits — and is not part of the
|
|
1161
|
+
* Command's input.
|
|
1162
|
+
*/
|
|
1163
|
+
export declare const adminOrganizationConvertToCompanyBodySchema: z.ZodObject<{
|
|
1164
|
+
name: z.ZodString;
|
|
1165
|
+
legalName: z.ZodOptional<z.ZodString>;
|
|
1166
|
+
taxId: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
1167
|
+
registeredAddress: z.ZodObject<{
|
|
1168
|
+
street: z.ZodString;
|
|
1169
|
+
city: z.ZodString;
|
|
1170
|
+
postalCode: z.ZodString;
|
|
1171
|
+
country: z.ZodString;
|
|
1172
|
+
}, z.core.$strip>;
|
|
1173
|
+
vatStatus: z.ZodDefault<z.ZodEnum<{
|
|
1174
|
+
vat_payer: "vat_payer";
|
|
1175
|
+
vat_exempt: "vat_exempt";
|
|
1176
|
+
reverse_charge: "reverse_charge";
|
|
1177
|
+
}>>;
|
|
1178
|
+
validateTaxId: z.ZodDefault<z.ZodBoolean>;
|
|
1179
|
+
}, z.core.$strip>;
|
|
1180
|
+
export type AdminOrganizationConvertToCompanyBody = z.infer<typeof adminOrganizationConvertToCompanyBodySchema>;
|
|
1181
|
+
export type OrganizationConvertToCompanyInput = Omit<AdminOrganizationConvertToCompanyBody, 'validateTaxId'>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Container name: `organizationCommandPort`. Owner: `organizations`
|
|
1184
|
+
* (`specs/177-tax-id-scope/` `contracts/convert-to-company.md` §4).
|
|
1185
|
+
*
|
|
1186
|
+
* Server-side writes on the Organization aggregate, each one audited Command.
|
|
1187
|
+
* **No permission is checked here** — the caller is the gate: an admin route
|
|
1188
|
+
* behind `organizations:convert-to-company` and the reach rule, or
|
|
1189
|
+
* operator-run server code. Never resolve it for a customer-facing route.
|
|
1190
|
+
*/
|
|
1191
|
+
export interface OrganizationCommandPort {
|
|
1192
|
+
/**
|
|
1193
|
+
* Runs `organization.convert_to_company` as one Command with the ambient
|
|
1194
|
+
* actor (an administrator inside an admin request; the system under
|
|
1195
|
+
* `withSystemScope` in a worker). For admin routes and server code — an ERP
|
|
1196
|
+
* import — and never for a customer-facing route. No VAT validation: trigger
|
|
1197
|
+
* one after it resolves if you need it. Refusals: `404 NOT_FOUND`,
|
|
1198
|
+
* `409 ORGANIZATION_CONVERSION_REFUSED`, `409 ORGANIZATION_TAX_ID_EXISTS`,
|
|
1199
|
+
* and whatever a command hook on the action vetoes with. `options.extensions`
|
|
1200
|
+
* reaches those hooks (issue #1057).
|
|
1201
|
+
*/
|
|
1202
|
+
convertToCompany(organizationId: string, input: OrganizationConvertToCompanyInput, options?: OrganizationCommandPortOptions): Promise<OrganizationRecord>;
|
|
1203
|
+
/**
|
|
1204
|
+
* Issue #1040 — runs `organization.tax_id.change` as one Command with the
|
|
1205
|
+
* ambient actor: corrects a live company organization's tax ID in place (same
|
|
1206
|
+
* id, members, roles and orders). The value is normalised and checked in the
|
|
1207
|
+
* active tax-ID scope inside the write; the organization's VAT validation is
|
|
1208
|
+
* reset to unverified. The same value after normalisation changes nothing and
|
|
1209
|
+
* is not audited, unless a command hook on the action noted a write of its
|
|
1210
|
+
* own; `options.extensions` reaches those hooks (issue #1057). No VAT validation runs: trigger one after it resolves if you
|
|
1211
|
+
* need it. Refusals: `404 NOT_FOUND`, `409 ORGANIZATION_TAX_ID_CHANGE_REFUSED`
|
|
1212
|
+
* (`not_company` | `deleted`), `409 ORGANIZATION_TAX_ID_EXISTS`,
|
|
1213
|
+
* `409 ORGANIZATION_WRITE_CONTENDED`.
|
|
1214
|
+
*/
|
|
1215
|
+
changeTaxId(organizationId: string, input: OrganizationChangeTaxIdInput, options?: OrganizationCommandPortOptions): Promise<OrganizationRecord>;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* What a server-side caller may hand either {@link OrganizationCommandPort}
|
|
1219
|
+
* method besides its input (issue #1057, as `OrganizationCustomFieldWriteOptions`
|
|
1220
|
+
* for the custom-field port).
|
|
1221
|
+
*
|
|
1222
|
+
* `extensions` is extension input for the command-hook modules on
|
|
1223
|
+
* `organization.convert_to_company` / `organization.tax_id.change`, keyed by
|
|
1224
|
+
* module id; each hook sees only its own module's key. A key no present hook
|
|
1225
|
+
* module claims is refused `422 COMMAND_EXTENSION_UNCLAIMED` before anything is
|
|
1226
|
+
* written. No HTTP body carries it — that field is spec 178's.
|
|
1227
|
+
*/
|
|
1228
|
+
export interface OrganizationCommandPortOptions {
|
|
1229
|
+
readonly extensions?: Readonly<Record<string, unknown>>;
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* `POST /api/v1/admin/organizations/:id/change-tax-id`. The tax ID is
|
|
1233
|
+
* normalised exactly as the admin boundary normalises it on creation.
|
|
1234
|
+
* `validateTaxId` is the route's own switch — a VAT validation after the change
|
|
1235
|
+
* commits, whose failure never undoes it — and is not part of the Command's
|
|
1236
|
+
* input.
|
|
1237
|
+
*/
|
|
1238
|
+
export declare const adminOrganizationChangeTaxIdBodySchema: z.ZodObject<{
|
|
1239
|
+
taxId: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
1240
|
+
validateTaxId: z.ZodDefault<z.ZodBoolean>;
|
|
1241
|
+
}, z.core.$strip>;
|
|
1242
|
+
export type AdminOrganizationChangeTaxIdBody = z.infer<typeof adminOrganizationChangeTaxIdBodySchema>;
|
|
1243
|
+
export type OrganizationChangeTaxIdInput = Omit<AdminOrganizationChangeTaxIdBody, 'validateTaxId'>;
|
|
1244
|
+
/**
|
|
1245
|
+
* `organization.tax_id_changed.v1` — emitted once, after the change commits,
|
|
1246
|
+
* never on rollback and never for a same-value no-op. Carries neither the old
|
|
1247
|
+
* nor the new tax ID (the precedent of
|
|
1248
|
+
* {@link OrganizationConvertedToCompanyEvent}): a tax ID is personal data for a
|
|
1249
|
+
* sole trader, and a subscriber that needs the current value reads it through
|
|
1250
|
+
* {@link OrganizationDetailsPort}.
|
|
1251
|
+
*/
|
|
1252
|
+
export interface OrganizationTaxIdChangedEvent {
|
|
1253
|
+
eventId: string;
|
|
1254
|
+
/** ISO-8601. */
|
|
1255
|
+
occurredAt: string;
|
|
1256
|
+
organizationId: string;
|
|
1257
|
+
/** ISO-8601 — when the change committed its write. */
|
|
1258
|
+
changedAt: string;
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* `organization.converted_to_company.v1` — emitted once, after the conversion
|
|
1262
|
+
* commits, never on rollback (FR-039). Carries no name and no tax ID: a
|
|
1263
|
+
* subscriber has the id and {@link OrganizationDetailsPort}.
|
|
1264
|
+
*/
|
|
1265
|
+
export interface OrganizationConvertedToCompanyEvent {
|
|
1266
|
+
eventId: string;
|
|
1267
|
+
/** ISO-8601. */
|
|
1268
|
+
occurredAt: string;
|
|
1269
|
+
organizationId: string;
|
|
1270
|
+
/** ISO-8601 — the organization's `convertedToCompanyAt`. */
|
|
1271
|
+
convertedAt: string;
|
|
604
1272
|
}
|
|
605
1273
|
/**
|
|
606
1274
|
* Container name: `organizationDetailsPort`. Owner: `organizations`.
|
|
@@ -640,7 +1308,241 @@ export interface OrganizationDetailsPort {
|
|
|
640
1308
|
searchByName(query: string, limit: number): Promise<OrganizationRecord[]>;
|
|
641
1309
|
/** The same search, ids only — for the order list's organisation filter. */
|
|
642
1310
|
searchIdsByName(query: string): Promise<string[]>;
|
|
1311
|
+
/**
|
|
1312
|
+
* `specs/177-tax-id-scope/` (FR-023) — every live organization holding this
|
|
1313
|
+
* tax ID: the tree's root first, then by depth, creation time and id. The
|
|
1314
|
+
* input is normalised with {@link normalizeTaxId}; an input with nothing left
|
|
1315
|
+
* answers `[]`. Soft-deleted rows are excluded unless `includeDeleted`.
|
|
1316
|
+
* In `global` there is at most one; in `per-tree-root` a head office and its
|
|
1317
|
+
* branches. Never matches a personal organization, which has no tax ID.
|
|
1318
|
+
*/
|
|
1319
|
+
findByTaxId(taxId: string, options?: {
|
|
1320
|
+
includeDeleted?: boolean;
|
|
1321
|
+
}): Promise<OrganizationRecord[]>;
|
|
1322
|
+
/**
|
|
1323
|
+
* The single organization a tax ID resolves to — the root of the tree that
|
|
1324
|
+
* holds it (the live root, else the oldest live match), `none` when no live
|
|
1325
|
+
* organization holds it. See {@link TaxIdResolution} for `ambiguous`.
|
|
1326
|
+
*/
|
|
1327
|
+
resolveByTaxId(taxId: string): Promise<TaxIdResolution>;
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Container name: `organizationCustomFieldWritePort`. Owner: `organizations`.
|
|
1331
|
+
*
|
|
1332
|
+
* The server-side write of an Organization's custom-field values — for code
|
|
1333
|
+
* with no admin request to ride on: a subscriber on
|
|
1334
|
+
* `organization.registered.v1`, an overlay module, an integration worker. The
|
|
1335
|
+
* case it was published for is an `audience: internal` field (an acquisition
|
|
1336
|
+
* source, say) set after self-registration, which by design cannot travel
|
|
1337
|
+
* through the buyer's registration input. Before it the only ways were the
|
|
1338
|
+
* admin HTTP API or a native `UPDATE organizations SET custom_field_values`,
|
|
1339
|
+
* and the second breaks Principle I.
|
|
1340
|
+
*
|
|
1341
|
+
* A port of its own rather than a method on the read-only
|
|
1342
|
+
* {@link OrganizationDetailsPort}, mirroring
|
|
1343
|
+
* `CustomerAccountLifecycleWritePort.setCustomFieldValues` on the account side.
|
|
1344
|
+
*
|
|
1345
|
+
* **The merge is the caller's.** The owner loads the Organization, calls
|
|
1346
|
+
* `merge` with its current bag and stores what `merge` returns — inside **one
|
|
1347
|
+
* transaction, as one Command (`organization.set_custom_field_values`) with one
|
|
1348
|
+
* audit row** naming the keys that changed (`changedCustomFields`), never
|
|
1349
|
+
* their values (`specs/conventions/audit-state.md`). It is a callback rather
|
|
1350
|
+
* than a pre-merged bag because the read, the validation and the write have
|
|
1351
|
+
* to share that transaction, or a concurrent write is silently lost.
|
|
1352
|
+
*
|
|
1353
|
+
* **The owner does not validate.** Whatever `merge` returns is stored, so the
|
|
1354
|
+
* caller validates inside it through `CustomFieldValuePort.validateAndMerge`
|
|
1355
|
+
* (the administrator's rules — an `internal` field is accepted, unknown keys
|
|
1356
|
+
* are dropped, every `required` definition is enforced):
|
|
1357
|
+
*
|
|
1358
|
+
* ```ts
|
|
1359
|
+
* await organizationCustomFieldWritePort.setCustomFieldValues(organizationId, (current) =>
|
|
1360
|
+
* customFieldValueService.validateAndMerge('organization', current, { acquisition_source: 'trade_fair' }),
|
|
1361
|
+
* );
|
|
1362
|
+
* ```
|
|
1363
|
+
*
|
|
1364
|
+
* **Failures propagate unchanged.** A throwing `merge` — `custom_fields`'
|
|
1365
|
+
* validation failure included — rolls the transaction back, stores nothing,
|
|
1366
|
+
* records nothing, and reaches the caller as it was thrown. An unknown or
|
|
1367
|
+
* soft-deleted Organization (or an id that is not a uuid) throws the platform's
|
|
1368
|
+
* `404 NOT_FOUND` HTTP error before `merge` is called, as the account port does.
|
|
1369
|
+
*
|
|
1370
|
+
* **The actor is the ambient one.** The Command Bus records the actor of the
|
|
1371
|
+
* caller's tenant context, never one passed in: an administrator inside an
|
|
1372
|
+
* admin request, and a null actor (system) for a subscriber or a worker. A
|
|
1373
|
+
* subscriber runs in its emitter's context, and `organization.registered.v1` is
|
|
1374
|
+
* emitted by the anonymous registration request, which the platform scopes as
|
|
1375
|
+
* system — so the entry records no actor. With no tenant context at all the bus
|
|
1376
|
+
* refuses before `merge` runs (`MissingTenantContextError`); a detached caller
|
|
1377
|
+
* (a timer, a script) opens one with `enterSystemScope`.
|
|
1378
|
+
*
|
|
1379
|
+
* **It is not transactional with registration.** Called from an
|
|
1380
|
+
* `organization.registered.v1` subscriber it runs after the registration
|
|
1381
|
+
* committed, in a transaction of its own: best effort. A failure leaves the
|
|
1382
|
+
* Organization registered without the value, and the event bus logs a
|
|
1383
|
+
* subscriber's error rather than surfacing it to the buyer.
|
|
1384
|
+
*
|
|
1385
|
+
* When `organizations` is off the method fails closed (503 `MODULE_DISABLED`);
|
|
1386
|
+
* the module is the platform's one tenant concept, so in practice the gate
|
|
1387
|
+
* cannot close.
|
|
1388
|
+
*/
|
|
1389
|
+
export interface OrganizationCustomFieldWritePort {
|
|
1390
|
+
setCustomFieldValues(organizationId: string, merge: (current: Record<string, unknown>) => Promise<Record<string, unknown>>, options?: OrganizationCustomFieldWriteOptions): Promise<OrganizationRecord>;
|
|
1391
|
+
}
|
|
1392
|
+
/** Container name of {@link OrganizationWritePort}. */
|
|
1393
|
+
export declare const ORGANIZATION_WRITE_PORT: "organizationWritePort";
|
|
1394
|
+
/** What {@link OrganizationWritePort.create} writes — the admin create's fields, plus the legal name. */
|
|
1395
|
+
export interface OrganizationWriteCreateInput {
|
|
1396
|
+
name: string;
|
|
1397
|
+
legalName?: string | null;
|
|
1398
|
+
/** Normalised with {@link normalizeTaxId} and stored in that form, as on every creation path. */
|
|
1399
|
+
taxId: string;
|
|
1400
|
+
/** Defaults to `vat_payer`, as on every other creation path. */
|
|
1401
|
+
vatStatus?: VatStatus;
|
|
1402
|
+
registeredAddress: OrganizationRegisteredAddress;
|
|
1403
|
+
/** The stores its members may shop on, bound in the creating transaction. */
|
|
1404
|
+
salesChannelIds: readonly [string, ...string[]];
|
|
1405
|
+
/** The statuses an operator may create an Organization in. */
|
|
1406
|
+
status: 'active' | 'pending_verification';
|
|
1407
|
+
/**
|
|
1408
|
+
* Create it as a branch under this live Organization, in the same Command.
|
|
1409
|
+
* In the `per-tree-root` tax-ID scope a branch may carry the tax ID its tree
|
|
1410
|
+
* already holds. No permission is checked: the caller is the gate.
|
|
1411
|
+
*/
|
|
1412
|
+
parentId?: string;
|
|
1413
|
+
/** Custom-field values, validated with the administrator's rules, as the admin create does. */
|
|
1414
|
+
customFieldValues?: Record<string, unknown>;
|
|
1415
|
+
}
|
|
1416
|
+
/**
|
|
1417
|
+
* The identity and contact fields {@link OrganizationWritePort.update} may
|
|
1418
|
+
* change; an absent key is left as it is. The tax ID is not among them: a
|
|
1419
|
+
* correction is `OrganizationCommandPort.changeTaxId`.
|
|
1420
|
+
*/
|
|
1421
|
+
export interface OrganizationWriteUpdatePatch {
|
|
1422
|
+
name?: string;
|
|
1423
|
+
/** `null` clears it. */
|
|
1424
|
+
legalName?: string | null;
|
|
1425
|
+
vatStatus?: VatStatus;
|
|
1426
|
+
/** Replaces the whole address. */
|
|
1427
|
+
registeredAddress?: OrganizationRegisteredAddress;
|
|
1428
|
+
/** Replaces the whole list. */
|
|
1429
|
+
orderConfirmationEmails?: string[];
|
|
1430
|
+
}
|
|
1431
|
+
export interface OrganizationWriteUpdateOptions {
|
|
1432
|
+
/**
|
|
1433
|
+
* The {@link OrganizationRecord.version} the caller read. When given and the
|
|
1434
|
+
* row has moved on, the write is refused with `409 VERSION_CONFLICT`.
|
|
1435
|
+
*/
|
|
1436
|
+
expectedVersion?: number;
|
|
643
1437
|
}
|
|
1438
|
+
/**
|
|
1439
|
+
* Container name: `organizationWritePort` ({@link ORGANIZATION_WRITE_PORT}).
|
|
1440
|
+
* Owner: `organizations`. Issue #1029.
|
|
1441
|
+
*
|
|
1442
|
+
* Find, create and update an Organization's own identity and contact fields
|
|
1443
|
+
* from another module — the case it was published for is a connector that
|
|
1444
|
+
* synchronises an external system's customer master (an ERP, a CRM): it looks
|
|
1445
|
+
* an Organization up by tax ID, creates it when there is none, and applies a
|
|
1446
|
+
* later change of name or address to the same row. Before it the only ways were
|
|
1447
|
+
* the admin HTTP API or a native write to this module's table.
|
|
1448
|
+
*
|
|
1449
|
+
* **Scope.** Identity and contact fields. Moderation (approve, reject, block),
|
|
1450
|
+
* re-parenting, roles, members, credit and sales-channel changes after
|
|
1451
|
+
* creation stay with their existing owners and surfaces; a tax-ID correction
|
|
1452
|
+
* and the personal-to-company conversion are {@link OrganizationCommandPort}'s;
|
|
1453
|
+
* custom-field values after creation are {@link OrganizationCustomFieldWritePort}'s;
|
|
1454
|
+
* addresses beyond the registered one are `addressServicePort`'s.
|
|
1455
|
+
*
|
|
1456
|
+
* **Each write is one Command with one audit entry.** `create` runs
|
|
1457
|
+
* `organization.create` — the Command the admin create runs — and `update`
|
|
1458
|
+
* runs `organization.update`. Both entries carry names and codes, never the
|
|
1459
|
+
* Organization's values (`specs/conventions/audit-state.md`): `update` records
|
|
1460
|
+
* the VAT status code and the sorted names of the fields it changed. An
|
|
1461
|
+
* `update` that changes nothing writes nothing and records nothing. The actor
|
|
1462
|
+
* is the ambient one, never passed in: an administrator inside an admin
|
|
1463
|
+
* request, a null actor for a worker in `withSystemScope`, the administrator a
|
|
1464
|
+
* worker acts for in `withSystemScopeActingFor`. With no tenant context the bus
|
|
1465
|
+
* refuses before writing (`MissingTenantContextError`).
|
|
1466
|
+
*
|
|
1467
|
+
* **Refusals are the platform's `HttpError`, typed by `code`**, so a caller can
|
|
1468
|
+
* record an issue for one record and go on to the next:
|
|
1469
|
+
*
|
|
1470
|
+
* - `422 VALIDATION_FAILED` — an input outside the admin API's own limits
|
|
1471
|
+
* (an empty name, a tax ID that is not 8–32 characters once normalised, a
|
|
1472
|
+
* country that is not two letters, an empty or duplicated channel list, an
|
|
1473
|
+
* invalid e-mail);
|
|
1474
|
+
* - `409 DICTIONARY_ENTRY_NOT_FOUND` / `DICTIONARY_ENTRY_INACTIVE` — a country
|
|
1475
|
+
* an operator has not made available, checked as the admin create checks it
|
|
1476
|
+
* (on `update`, only when the country changes);
|
|
1477
|
+
* - `409 ORGANIZATION_TAX_ID_EXISTS` — `create` with a tax ID the active scope
|
|
1478
|
+
* does not allow: in `global`, any other row holds it; in `per-tree-root`, a
|
|
1479
|
+
* row outside the new Organization's tree does. Soft-deleted rows count, so
|
|
1480
|
+
* `findByTaxId` may answer `[]` and `create` still refuse;
|
|
1481
|
+
* - `422 UNKNOWN_SALES_CHANNEL` — `create` naming a channel that does not exist;
|
|
1482
|
+
* - `422 CUSTOM_FIELD_VALUE_INVALID` — `create` with custom-field values the
|
|
1483
|
+
* administrator's rules refuse;
|
|
1484
|
+
* - `404 NOT_FOUND` — `create` under an unknown or deleted parent; `update` of
|
|
1485
|
+
* an unknown or soft-deleted Organization, or an id that is not a uuid;
|
|
1486
|
+
* - `422 ORGANIZATION_TREE_INVALID` — `create` under a parent at the depth bound;
|
|
1487
|
+
* - `409 VERSION_CONFLICT` — `update` with an `expectedVersion` the row has
|
|
1488
|
+
* moved past, or a concurrent write that won the race;
|
|
1489
|
+
* - `409 ORGANIZATION_WRITE_CONTENDED` — a lock lost to a concurrent write; retry.
|
|
1490
|
+
*
|
|
1491
|
+
* When `organizations` is off every method fails closed (503
|
|
1492
|
+
* `MODULE_DISABLED`); the module is the platform's one tenant concept and
|
|
1493
|
+
* declares itself non-deactivatable, so in practice the gate cannot close.
|
|
1494
|
+
* Callers resolve it per use with `lazyPort`.
|
|
1495
|
+
*/
|
|
1496
|
+
export interface OrganizationWritePort {
|
|
1497
|
+
/**
|
|
1498
|
+
* Every live Organization holding this tax ID — exactly
|
|
1499
|
+
* {@link OrganizationDetailsPort.findByTaxId}: the input normalised with
|
|
1500
|
+
* {@link normalizeTaxId}, the tree's root first, then by depth, creation time
|
|
1501
|
+
* and id; `[]` for none. A list because in the `per-tree-root` scope a head
|
|
1502
|
+
* office and its branches share one tax ID; in `global` it holds at most one.
|
|
1503
|
+
* A caller that needs the single match uses
|
|
1504
|
+
* {@link OrganizationDetailsPort.resolveByTaxId}.
|
|
1505
|
+
*/
|
|
1506
|
+
findByTaxId(taxId: string): Promise<OrganizationRecord[]>;
|
|
1507
|
+
/** Runs `organization.create`, the same Command the admin create uses. */
|
|
1508
|
+
create(input: OrganizationWriteCreateInput): Promise<OrganizationRecord>;
|
|
1509
|
+
/** Updates identity and contact fields only, through the `organization.update` Command. */
|
|
1510
|
+
update(id: string, patch: OrganizationWriteUpdatePatch, options?: OrganizationWriteUpdateOptions): Promise<OrganizationRecord>;
|
|
1511
|
+
}
|
|
1512
|
+
/**
|
|
1513
|
+
* What a server-side caller may hand `setCustomFieldValues` besides the merge
|
|
1514
|
+
* (`specs/176-command-hooks-outbox/` FR-018, architect ruling on #1055 Q2).
|
|
1515
|
+
*
|
|
1516
|
+
* `extensions` is extension input for the command-hook modules on
|
|
1517
|
+
* `organization.set_custom_field_values`, keyed by module id; each hook sees only
|
|
1518
|
+
* its own module's key. A key no present hook module claims is refused
|
|
1519
|
+
* `422 COMMAND_EXTENSION_UNCLAIMED` before the merge runs. No HTTP body carries
|
|
1520
|
+
* it — that field is spec 178's.
|
|
1521
|
+
*/
|
|
1522
|
+
export interface OrganizationCustomFieldWriteOptions {
|
|
1523
|
+
readonly extensions?: Readonly<Record<string, unknown>>;
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* The tax id a reader may print or hand out for an Organization: a company's,
|
|
1527
|
+
* never a personal (B2C) Organization's. A personal Organization stores no tax
|
|
1528
|
+
* id at all since `specs/177-tax-id-scope/` (it carried an internal 32-hex
|
|
1529
|
+
* placeholder derived from the account id until then, issue #767), and the flag
|
|
1530
|
+
* is still honoured for a payload written before that. `null` — not an empty
|
|
1531
|
+
* string — when there is nothing to show, so every renderer drops its tax-id
|
|
1532
|
+
* line rather than printing a label with no value.
|
|
1533
|
+
*
|
|
1534
|
+
* Published as a **function, not a port**, for the reason
|
|
1535
|
+
* {@link normalizeOrganizationName} is: it is pure over its argument. Every
|
|
1536
|
+
* module that prints an {@link OrganizationRecord}'s tax id asks it — the quote
|
|
1537
|
+
* request document, the admin order and quote request panels, the price-book
|
|
1538
|
+
* and push audience pickers, and the storefront's checkout — so the rule has
|
|
1539
|
+
* one home.
|
|
1540
|
+
*/
|
|
1541
|
+
export declare function organizationCompanyTaxId(organization: {
|
|
1542
|
+
/** Absent reads as a company, as a session payload without the flag does. */
|
|
1543
|
+
readonly isPersonal?: boolean | undefined;
|
|
1544
|
+
readonly taxId: string | null;
|
|
1545
|
+
}): string | null;
|
|
644
1546
|
/**
|
|
645
1547
|
* Diacritic-insensitive normalisation for the organisation's `name_search`
|
|
646
1548
|
* column and for any query string matched against it.
|
|
@@ -713,39 +1615,6 @@ export interface OrganizationCreditOwner {
|
|
|
713
1615
|
export interface OrganizationInheritancePort {
|
|
714
1616
|
creditOwner(organizationId: string): Promise<OrganizationCreditOwner>;
|
|
715
1617
|
}
|
|
716
|
-
/** What a cart-approval-policy write answers with. */
|
|
717
|
-
export interface CartApprovalPolicyWriteResult {
|
|
718
|
-
readonly organization: OrganizationRecord;
|
|
719
|
-
/**
|
|
720
|
-
* `false` when the row already carried the requested value, so nothing was
|
|
721
|
-
* written and nothing was audited. It is part of the return type rather than
|
|
722
|
-
* something the caller re-derives from a read, because the caller's cascade
|
|
723
|
-
* hangs off it: `carts` resets its pending and approved carts when — and only
|
|
724
|
-
* when — the policy actually moved to `false`.
|
|
725
|
-
*/
|
|
726
|
-
readonly changed: boolean;
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Container name: `organizationCartApprovalWritePort`. Owner: `organizations`.
|
|
730
|
-
*
|
|
731
|
-
* The per-organisation "an Org Admin must approve a cart before checkout"
|
|
732
|
-
* policy (feature 027 US4). `carts` drives both surfaces that flip it — the
|
|
733
|
-
* platform-admin route and the Org-Admin self-service one — but the column is
|
|
734
|
-
* this module's, so the operation is (issue #175, D-78 step 1).
|
|
735
|
-
*
|
|
736
|
-
* The write runs through `CommandBus.run`, so it carries the audit row it had
|
|
737
|
-
* never had while `carts` was writing the column directly, with the actor
|
|
738
|
-
* derived from the caller's ambient context (Constitution XIII). The cart
|
|
739
|
-
* cascade that follows a switch-off stays with `carts`: those are its rows, and
|
|
740
|
-
* they are audited in its own per-cart trail.
|
|
741
|
-
*
|
|
742
|
-
* This module is non-deactivatable, so the gate the port registration applies
|
|
743
|
-
* cannot be reached; the registration is a `providePort` anyway, for the reason
|
|
744
|
-
* its siblings give.
|
|
745
|
-
*/
|
|
746
|
-
export interface OrganizationCartApprovalWritePort {
|
|
747
|
-
setCartApprovalPolicy(organizationId: string, requiresCartApproval: boolean): Promise<CartApprovalPolicyWriteResult>;
|
|
748
|
-
}
|
|
749
1618
|
/** The three allow-list kinds an organisation can restrict. */
|
|
750
1619
|
export type OrganizationAllowListKind = 'paymentMethodIds' | 'deliveryMethodIds' | 'warehouseIds';
|
|
751
1620
|
/**
|
|
@@ -767,6 +1636,15 @@ export type OrganizationAllowListKind = 'paymentMethodIds' | 'deliveryMethodIds'
|
|
|
767
1636
|
export interface OrganizationRestrictionPort {
|
|
768
1637
|
allowedIdsFor(organizationId: string, kind: OrganizationAllowListKind): Promise<string[] | null>;
|
|
769
1638
|
}
|
|
1639
|
+
/**
|
|
1640
|
+
* A personal organisation as {@link PersonalOrganizationPort.provisionPersonalOrganization}
|
|
1641
|
+
* answers it: the record, and the id of its *Administrator* role — the role
|
|
1642
|
+
* its single member holds (`specs/170-organization-roles/`, owner ruling PR-3,
|
|
1643
|
+
* research R-34), which a caller moving the account there writes with it.
|
|
1644
|
+
*/
|
|
1645
|
+
export interface ProvisionedPersonalOrganizationRecord extends OrganizationRecord {
|
|
1646
|
+
administratorRoleId: string;
|
|
1647
|
+
}
|
|
770
1648
|
/**
|
|
771
1649
|
* Container name: `personalOrganizationPort`. Owner: `organizations`.
|
|
772
1650
|
*
|
|
@@ -806,27 +1684,67 @@ export interface PersonalOrganizationPort {
|
|
|
806
1684
|
* the authority check and the "an organisation keeps an administrator" guard
|
|
807
1685
|
* that must precede it are `customers`' policy.
|
|
808
1686
|
*
|
|
809
|
-
* Idempotent: the personal organisation
|
|
810
|
-
*
|
|
1687
|
+
* Idempotent by the account link: the personal organisation records the
|
|
1688
|
+
* account it was provisioned for (`specs/177-tax-id-scope/`, FR-003), so a
|
|
1689
|
+
* second call re-finds the row rather than creating a second one. It has no
|
|
1690
|
+
* tax ID.
|
|
811
1691
|
*/
|
|
812
|
-
provisionPersonalOrganization(customerAccountId: string): Promise<
|
|
1692
|
+
provisionPersonalOrganization(customerAccountId: string): Promise<ProvisionedPersonalOrganizationRecord>;
|
|
813
1693
|
/**
|
|
814
1694
|
* Feature 051, the other end of the same rule — the retention sweep's
|
|
815
1695
|
* cascade. Once the single member of a personal organisation has been
|
|
816
|
-
*
|
|
1696
|
+
* soft-deleted, the organisation is left with no live member and its name is
|
|
817
1697
|
* derived from that person's name, so it is scrubbed and soft-deleted too.
|
|
818
1698
|
*
|
|
819
|
-
*
|
|
820
|
-
*
|
|
821
|
-
*
|
|
822
|
-
*
|
|
823
|
-
*
|
|
824
|
-
*
|
|
1699
|
+
* **Convergent** (issue #800). The sweep calls this *before* it anonymises
|
|
1700
|
+
* the account, and calls it again on the next tick if anything after it
|
|
1701
|
+
* failed. It writes only what part of the scrub is still missing (the name,
|
|
1702
|
+
* the registered address, the legal name, the order-confirmation e-mails,
|
|
1703
|
+
* every custom field value, the block and rejection reasons (issue #843:
|
|
1704
|
+
* set to `null`, while the status and its dates stay), `deletedAt` — an
|
|
1705
|
+
* existing `deletedAt` is kept),
|
|
1706
|
+
* in one transaction with its audit row, and records nothing when nothing
|
|
1707
|
+
* was missing. The audit row names none of the erased data (issue #802).
|
|
1708
|
+
* It answers the organisation **whether or not it wrote anything**,
|
|
1709
|
+
* so a repeat call still tells the caller which saved addresses to clear.
|
|
825
1710
|
*
|
|
826
|
-
*
|
|
827
|
-
*
|
|
1711
|
+
* Answers `null`, and writes nothing, only where the cascade does not apply:
|
|
1712
|
+
* an org-less account, an organisation that is not personal, and one that
|
|
1713
|
+
* still has a live member. That is why it takes the **account** id rather
|
|
1714
|
+
* than the organisation's — the caller (`customers`' anonymisation sweep)
|
|
1715
|
+
* knows which customer it is scrubbing and must not be the one deciding
|
|
1716
|
+
* whether the organisation qualifies.
|
|
828
1717
|
*/
|
|
829
1718
|
anonymizeIfOrphaned(customerAccountId: string): Promise<OrganizationRecord | null>;
|
|
1719
|
+
/**
|
|
1720
|
+
* Issue #923 — the ids of the personal organisations a scrub has reached
|
|
1721
|
+
* (they carry its name) that do not yet hold all of the **current** scrub:
|
|
1722
|
+
* one an earlier release scrubbed before the rule grew, or one a crash left
|
|
1723
|
+
* half-written. The retention sweep runs each one's anonymised member
|
|
1724
|
+
* through the cascade again, and {@link anonymizeIfOrphaned} writes what is
|
|
1725
|
+
* missing, so a field added to the scrub reaches every earlier subject on
|
|
1726
|
+
* the next run with no backfill.
|
|
1727
|
+
*
|
|
1728
|
+
* The selection is free of any retention cutoff: a subject already
|
|
1729
|
+
* anonymised is finished whatever the window reads today. It agrees field by
|
|
1730
|
+
* field with the owner's own "fully scrubbed" test, which stays the
|
|
1731
|
+
* in-transaction re-check; a live organisation that merely carries the name
|
|
1732
|
+
* may be listed, and is left alone because it still has a live member.
|
|
1733
|
+
*
|
|
1734
|
+
* Reads only the owner's rows; writes nothing. Unbounded, like
|
|
1735
|
+
* `CustomerAccountLifecycleWritePort.listDueForAnonymization`: in steady
|
|
1736
|
+
* state it answers an empty list.
|
|
1737
|
+
*/
|
|
1738
|
+
listIncompletelyScrubbed(): Promise<string[]>;
|
|
1739
|
+
/**
|
|
1740
|
+
* Whether {@link listIncompletelyScrubbed} would list anything — **yes or
|
|
1741
|
+
* no, and nothing else**. The retention sweep's scheduled tick asks it with
|
|
1742
|
+
* no tenant context, before it enters the system scope, beside
|
|
1743
|
+
* `CustomerAccountLifecycleWritePort.hasDueForAnonymization`, so that a tick
|
|
1744
|
+
* with organisation-side residue to finish is not taken for an idle one. It
|
|
1745
|
+
* is the list's own row source; no id, row or count leaves it.
|
|
1746
|
+
*/
|
|
1747
|
+
hasIncompletelyScrubbed(): Promise<boolean>;
|
|
830
1748
|
}
|
|
831
1749
|
/** One sales-rep ↔ organisation assignment row. */
|
|
832
1750
|
export interface SalesRepAssignmentRow {
|
|
@@ -864,10 +1782,12 @@ export interface SalesRepAssignmentPort {
|
|
|
864
1782
|
}): Promise<boolean>;
|
|
865
1783
|
}
|
|
866
1784
|
/**
|
|
867
|
-
* Which organizations an admin's requests may reach: every one,
|
|
1785
|
+
* Which organizations an admin's requests may reach: every one, a named set, or
|
|
1786
|
+
* every one but a named set (issue #305).
|
|
868
1787
|
*
|
|
869
|
-
* The
|
|
870
|
-
*
|
|
1788
|
+
* The platform turns it into the ambient tenant context, and the admin lists
|
|
1789
|
+
* read their scope from that context, so the two cannot disagree about one
|
|
1790
|
+
* admin.
|
|
871
1791
|
*/
|
|
872
1792
|
export type AdminTenantScope = {
|
|
873
1793
|
readonly allowAll: true;
|
|
@@ -882,15 +1802,55 @@ export type AdminTenantScope = {
|
|
|
882
1802
|
* can only turn an answer into a refusal, never widen one.
|
|
883
1803
|
*/
|
|
884
1804
|
readonly unresolved?: Error;
|
|
1805
|
+
} | {
|
|
1806
|
+
/**
|
|
1807
|
+
* Issue #305 — a sales representative's reach, described by its
|
|
1808
|
+
* **complement**: every Organization except those governed by somebody
|
|
1809
|
+
* else. Under the reach rule a representative sees every Organization
|
|
1810
|
+
* nobody is assigned to (B2C personal organizations included, which can
|
|
1811
|
+
* never carry an assignment), so the reachable set grows with the
|
|
1812
|
+
* customer base while the excluded one is bounded by the B2B book.
|
|
1813
|
+
*/
|
|
1814
|
+
readonly allowAll: false;
|
|
1815
|
+
readonly reach: 'excluding';
|
|
1816
|
+
/**
|
|
1817
|
+
* Issue #955 (architect ruling, Q2; owner ruling of 2026-11-10) — the excluded organizations as one
|
|
1818
|
+
* uncorrelated SELECT of a single non-null uuid column, read live in each
|
|
1819
|
+
* statement's own snapshot. Built by the owner from the authenticated
|
|
1820
|
+
* admin's identity and permissions only — never from request input. The
|
|
1821
|
+
* platform renders it on the filtered row's own organization column as
|
|
1822
|
+
* `col is not null and col not in (<sql>)`; no module reads it.
|
|
1823
|
+
*/
|
|
1824
|
+
readonly excludedOrganizationsQuery: {
|
|
1825
|
+
readonly sql: string;
|
|
1826
|
+
readonly params: readonly (string | boolean)[];
|
|
1827
|
+
};
|
|
1828
|
+
/**
|
|
1829
|
+
* Issue #955 Phase 2 (owner ruling of 2026-11-10) — the lists, on demand:
|
|
1830
|
+
* the organizations governed by another representative, and the
|
|
1831
|
+
* representative's own assignments (roll-up expanded; ranking and "mine"
|
|
1832
|
+
* filters only, never a filter input). They replaced the
|
|
1833
|
+
* `excludedOrganizationIds` / `assignedOrganizationIds` fields, which made
|
|
1834
|
+
* every admin request compute them. The owner memoises the call once per
|
|
1835
|
+
* answered scope; a failure rejects, which refuses rather than widens.
|
|
1836
|
+
*/
|
|
1837
|
+
readonly loadReach: () => Promise<{
|
|
1838
|
+
readonly excludedOrganizationIds: readonly string[];
|
|
1839
|
+
readonly assignedOrganizationIds: readonly string[];
|
|
1840
|
+
}>;
|
|
1841
|
+
readonly unresolved?: Error;
|
|
885
1842
|
};
|
|
886
1843
|
/**
|
|
887
1844
|
* Container name: `adminTenantScopePort`. Owner: `organizations`.
|
|
888
1845
|
*
|
|
889
1846
|
* The tenant reach of an authenticated admin, derived from the role the admin
|
|
890
|
-
* holds and never from request inputs (Principle XI). An admin whose role
|
|
891
|
-
*
|
|
892
|
-
*
|
|
893
|
-
*
|
|
1847
|
+
* holds and never from request inputs (Principle XI). An admin whose role is
|
|
1848
|
+
* the sales-representative one answers the `excluding` reach (issue #305): every
|
|
1849
|
+
* Organization except those governed by another representative — the reach
|
|
1850
|
+
* rule of `SalesRepAssignmentPort.canSeeOrganization`, assigned, roll-up and
|
|
1851
|
+
* the unassigned fallback — and an admin holding any other role answers
|
|
1852
|
+
* `allowAll`. The `allowedOrganizationIds` member remains for the customer
|
|
1853
|
+
* roll-up and API keys, which name their set.
|
|
894
1854
|
*
|
|
895
1855
|
* **An admin with no role is refused, never widened.** An id that names no
|
|
896
1856
|
* live administrator, or an administrator holding no role, answers the empty
|
|
@@ -922,6 +1882,15 @@ export type AdminTenantScope = {
|
|
|
922
1882
|
*/
|
|
923
1883
|
export interface AdminTenantScopePort {
|
|
924
1884
|
resolveForAdmin(adminUserId: string): Promise<AdminTenantScope>;
|
|
1885
|
+
/**
|
|
1886
|
+
* {@link resolveForAdmin} for many administrators at once, in a fixed number
|
|
1887
|
+
* of reads: every id asked has an entry, the scope `resolveForAdmin` answers
|
|
1888
|
+
* for it. Not the request-scope hook's — a caller judging what **other**
|
|
1889
|
+
* administrators may see (who may be mentioned on a Project) asks it.
|
|
1890
|
+
*
|
|
1891
|
+
* Added for issue #461.
|
|
1892
|
+
*/
|
|
1893
|
+
resolveForAdmins(adminUserIds: readonly string[]): Promise<Map<string, AdminTenantScope>>;
|
|
925
1894
|
}
|
|
926
1895
|
/** The address a VAT registry hands back when it recognises the tax id. */
|
|
927
1896
|
export interface VatReturnedAddress {
|
|
@@ -1039,7 +2008,7 @@ export type OrganizationSalesChannelsUpdateBody = z.infer<typeof OrganizationSal
|
|
|
1039
2008
|
*/
|
|
1040
2009
|
export declare const AdminOrganizationCreateBodySchema: z.ZodObject<{
|
|
1041
2010
|
name: z.ZodString;
|
|
1042
|
-
taxId: z.ZodString
|
|
2011
|
+
taxId: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
1043
2012
|
registeredAddress: z.ZodObject<{
|
|
1044
2013
|
street: z.ZodString;
|
|
1045
2014
|
city: z.ZodString;
|
|
@@ -1051,11 +2020,13 @@ export declare const AdminOrganizationCreateBodySchema: z.ZodObject<{
|
|
|
1051
2020
|
vat_exempt: "vat_exempt";
|
|
1052
2021
|
reverse_charge: "reverse_charge";
|
|
1053
2022
|
}>>;
|
|
2023
|
+
customFieldValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1054
2024
|
status: z.ZodDefault<z.ZodEnum<{
|
|
1055
2025
|
active: "active";
|
|
1056
2026
|
pending_verification: "pending_verification";
|
|
1057
2027
|
}>>;
|
|
1058
2028
|
salesChannelIds: z.ZodArray<z.ZodString>;
|
|
2029
|
+
parentId: z.ZodOptional<z.ZodString>;
|
|
1059
2030
|
}, z.core.$strip>;
|
|
1060
2031
|
export type AdminOrganizationCreateBody = z.infer<typeof AdminOrganizationCreateBodySchema>;
|
|
1061
2032
|
export type AdminOrganizationCreateRequest = z.input<typeof AdminOrganizationCreateBodySchema>;
|