@endora-commerce/contracts 0.110.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/admin-actions.d.ts +2 -0
- package/dist/admin-actions.js +18 -0
- package/dist/admin-contributions.d.ts +37 -5
- package/dist/admin-contributions.js +9 -2
- package/dist/admin-roles.d.ts +9 -0
- package/dist/admin.d.ts +37 -0
- package/dist/admin.js +19 -0
- package/dist/api-keys.d.ts +22 -0
- package/dist/api-keys.js +4 -0
- package/dist/assets-library.d.ts +19 -0
- package/dist/assets-library.js +14 -0
- package/dist/auth.d.ts +9 -0
- package/dist/auth.js +9 -0
- package/dist/carts.d.ts +30 -1
- package/dist/carts.js +20 -5
- package/dist/catalog.d.ts +61 -22
- package/dist/catalog.js +32 -6
- package/dist/cms.d.ts +33 -3
- package/dist/cms.js +15 -0
- package/dist/command-hooks.d.ts +301 -0
- package/dist/command-hooks.js +248 -0
- package/dist/comparisons.d.ts +14 -14
- package/dist/credit-limits.d.ts +21 -0
- package/dist/credit-limits.js +21 -0
- package/dist/crm.d.ts +81 -55
- package/dist/crm.js +15 -5
- package/dist/custom-fields.d.ts +403 -49
- package/dist/custom-fields.js +127 -0
- package/dist/customer-accounts.d.ts +138 -0
- package/dist/customer-accounts.js +4 -0
- package/dist/customer-notifications.d.ts +143 -0
- package/dist/customer-notifications.js +41 -0
- package/dist/customers.d.ts +52 -0
- package/dist/customers.js +53 -0
- package/dist/dictionary.d.ts +53 -0
- package/dist/dictionary.js +25 -0
- package/dist/document-templates.d.ts +4 -4
- package/dist/email.d.ts +34 -0
- package/dist/email.js +6 -0
- package/dist/errors.d.ts +312 -2
- package/dist/errors.js +377 -2
- package/dist/forms.d.ts +88 -88
- package/dist/i18n.d.ts +34 -0
- package/dist/i18n.js +15 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +12 -1
- package/dist/invoice-ledger.d.ts +6 -6
- package/dist/invoices.d.ts +126 -0
- package/dist/invoices.js +49 -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 +86 -0
- package/dist/mfa.js +90 -0
- package/dist/modules.d.ts +21 -5
- package/dist/modules.js +60 -3
- package/dist/orders.d.ts +141 -0
- package/dist/orders.js +80 -3
- package/dist/organization-hooks.d.ts +99 -0
- package/dist/organization-hooks.js +22 -0
- package/dist/organization-registry-lookup.d.ts +5 -5
- package/dist/organization-roles.d.ts +1 -0
- package/dist/organization-roles.js +7 -0
- package/dist/organizations.d.ts +954 -17
- package/dist/organizations.js +229 -8
- package/dist/price-books.d.ts +173 -25
- package/dist/price-books.js +41 -0
- package/dist/price-lists.d.ts +5 -2
- package/dist/product-feeds.d.ts +157 -8
- package/dist/product-feeds.js +41 -2
- package/dist/product-scopes.d.ts +17 -0
- package/dist/product-scopes.js +31 -5
- package/dist/projects.d.ts +61 -28
- package/dist/projects.js +47 -9
- package/dist/promotions.d.ts +157 -5
- package/dist/promotions.js +23 -1
- package/dist/pwa.d.ts +39 -0
- package/dist/quick-order.d.ts +9 -3
- package/dist/quick-order.js +4 -3
- package/dist/quote-requests.d.ts +168 -5
- package/dist/quote-requests.js +69 -8
- package/dist/record-references.d.ts +15 -15
- package/dist/returns.d.ts +6 -0
- package/dist/returns.js +4 -2
- package/dist/sales-channels.d.ts +34 -3
- package/dist/sales-channels.js +16 -1
- package/dist/schema-extensions.d.ts +36 -0
- package/dist/schema-extensions.js +29 -0
- package/dist/seo.d.ts +2 -2
- package/dist/settings.d.ts +44 -2
- package/dist/settings.js +17 -2
- package/dist/shopping-lists.d.ts +39 -1
- package/dist/shopping-lists.js +37 -3
- package/dist/storefront-cache-tags.d.ts +10 -0
- package/dist/tasks.d.ts +21 -21
- package/dist/taxes.d.ts +27 -0
- package/dist/taxes.js +4 -0
- package/dist/transactional-emails.d.ts +39 -13
- package/dist/webhooks.d.ts +75 -0
- package/dist/webhooks.js +24 -0
- package/package.json +4 -2
- 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/forms-logic.d.ts.map +0 -1
- package/dist/forms-logic.fixtures.d.ts.map +0 -1
- package/dist/forms-logic.fixtures.js.map +0 -1
- package/dist/forms-logic.js.map +0 -1
- package/dist/forms.d.ts.map +0 -1
- package/dist/forms.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/organization-registry-lookup.d.ts.map +0 -1
- package/dist/organization-registry-lookup.js.map +0 -1
- package/dist/organization-roles.d.ts.map +0 -1
- package/dist/organization-roles.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/pim-locale-mapping.d.ts.map +0 -1
- package/dist/pim-locale-mapping.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-model.d.ts.map +0 -1
- package/dist/product-scope-model.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-scoped-values.d.ts.map +0 -1
- package/dist/product-scoped-values.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-tax-rates.d.ts.map +0 -1
- package/dist/product-tax-rates.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-write-encoding.d.ts.map +0 -1
- package/dist/scoped-write-encoding.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
|
@@ -66,7 +66,7 @@ export type AddressKind = z.infer<typeof addressKindSchema>;
|
|
|
66
66
|
export declare const organizationSchema: z.ZodObject<{
|
|
67
67
|
id: z.ZodString;
|
|
68
68
|
name: z.ZodString;
|
|
69
|
-
taxId: z.ZodString
|
|
69
|
+
taxId: z.ZodNullable<z.ZodString>;
|
|
70
70
|
status: z.ZodEnum<{
|
|
71
71
|
active: "active";
|
|
72
72
|
rejected: "rejected";
|
|
@@ -107,6 +107,84 @@ export declare const organizationSchema: z.ZodObject<{
|
|
|
107
107
|
updatedAt: z.ZodString;
|
|
108
108
|
}, z.core.$strip>;
|
|
109
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>;
|
|
110
188
|
/**
|
|
111
189
|
* A single node in an organization subtree / ancestor chain. `depth` is the
|
|
112
190
|
* node's absolute depth in the tree (root = 0). Returned pre-order (subtree) or
|
|
@@ -195,6 +273,7 @@ export declare const customerAccountSchema: z.ZodObject<{
|
|
|
195
273
|
permissions: z.ZodArray<z.ZodString>;
|
|
196
274
|
emailVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
197
275
|
twoFactorEnabled: z.ZodBoolean;
|
|
276
|
+
preferredLanguage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
198
277
|
createdAt: z.ZodString;
|
|
199
278
|
updatedAt: z.ZodString;
|
|
200
279
|
}, z.core.$strip>;
|
|
@@ -215,10 +294,18 @@ export declare const addressSchema: z.ZodObject<{
|
|
|
215
294
|
isDefault: z.ZodBoolean;
|
|
216
295
|
}, z.core.$strip>;
|
|
217
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;
|
|
218
305
|
export declare const registerOrganizationRequestSchema: z.ZodObject<{
|
|
219
306
|
organization: z.ZodObject<{
|
|
220
307
|
name: z.ZodString;
|
|
221
|
-
taxId: z.ZodString
|
|
308
|
+
taxId: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
222
309
|
registeredAddress: z.ZodObject<{
|
|
223
310
|
street: z.ZodString;
|
|
224
311
|
city: z.ZodString;
|
|
@@ -230,12 +317,14 @@ export declare const registerOrganizationRequestSchema: z.ZodObject<{
|
|
|
230
317
|
vat_exempt: "vat_exempt";
|
|
231
318
|
reverse_charge: "reverse_charge";
|
|
232
319
|
}>>;
|
|
320
|
+
customFieldValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
233
321
|
}, z.core.$strip>;
|
|
234
322
|
firstUser: z.ZodObject<{
|
|
235
323
|
email: z.ZodString;
|
|
236
324
|
password: z.ZodString;
|
|
237
325
|
firstName: z.ZodString;
|
|
238
326
|
lastName: z.ZodString;
|
|
327
|
+
customFieldValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
239
328
|
}, z.core.$strip>;
|
|
240
329
|
acceptedTermsVersion: z.ZodString;
|
|
241
330
|
registryLookupId: z.ZodOptional<z.ZodString>;
|
|
@@ -327,6 +416,61 @@ export declare const customerLoginResponseSchema: z.ZodObject<{
|
|
|
327
416
|
}, z.core.$strip>;
|
|
328
417
|
}, z.core.$strip>;
|
|
329
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
|
+
}
|
|
330
474
|
export declare const changePasswordRequestSchema: z.ZodObject<{
|
|
331
475
|
currentPassword: z.ZodString;
|
|
332
476
|
newPassword: z.ZodString;
|
|
@@ -414,7 +558,7 @@ export declare const registerOrganizationResponseSchema: z.ZodObject<{
|
|
|
414
558
|
organization: z.ZodObject<{
|
|
415
559
|
id: z.ZodString;
|
|
416
560
|
name: z.ZodString;
|
|
417
|
-
taxId: z.ZodString
|
|
561
|
+
taxId: z.ZodNullable<z.ZodString>;
|
|
418
562
|
status: z.ZodEnum<{
|
|
419
563
|
active: "active";
|
|
420
564
|
rejected: "rejected";
|
|
@@ -472,12 +616,349 @@ export declare const registerOrganizationResponseSchema: z.ZodObject<{
|
|
|
472
616
|
permissions: z.ZodArray<z.ZodString>;
|
|
473
617
|
emailVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
474
618
|
twoFactorEnabled: z.ZodBoolean;
|
|
619
|
+
preferredLanguage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
475
620
|
createdAt: z.ZodString;
|
|
476
621
|
updatedAt: z.ZodString;
|
|
477
622
|
}, z.core.$strip>;
|
|
478
623
|
emailVerificationSent: z.ZodBoolean;
|
|
479
624
|
}, z.core.$strip>;
|
|
480
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>;
|
|
481
962
|
/**
|
|
482
963
|
* One row of the admin Organization picker.
|
|
483
964
|
*
|
|
@@ -574,7 +1055,12 @@ export interface OrganizationRecord {
|
|
|
574
1055
|
id: string;
|
|
575
1056
|
name: string;
|
|
576
1057
|
legalName: string | null;
|
|
577
|
-
|
|
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;
|
|
578
1064
|
status: OrganizationStatus;
|
|
579
1065
|
vatStatus: VatStatus;
|
|
580
1066
|
isPersonal: boolean;
|
|
@@ -602,6 +1088,187 @@ export interface OrganizationRecord {
|
|
|
602
1088
|
createdAt: Date;
|
|
603
1089
|
updatedAt: Date;
|
|
604
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;
|
|
605
1272
|
}
|
|
606
1273
|
/**
|
|
607
1274
|
* Container name: `organizationDetailsPort`. Owner: `organizations`.
|
|
@@ -641,11 +1308,226 @@ export interface OrganizationDetailsPort {
|
|
|
641
1308
|
searchByName(query: string, limit: number): Promise<OrganizationRecord[]>;
|
|
642
1309
|
/** The same search, ids only — for the order list's organisation filter. */
|
|
643
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;
|
|
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>>;
|
|
644
1524
|
}
|
|
645
1525
|
/**
|
|
646
1526
|
* The tax id a reader may print or hand out for an Organization: a company's,
|
|
647
|
-
* never a personal (B2C) Organization's
|
|
648
|
-
*
|
|
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
|
|
649
1531
|
* string — when there is nothing to show, so every renderer drops its tax-id
|
|
650
1532
|
* line rather than printing a label with no value.
|
|
651
1533
|
*
|
|
@@ -659,7 +1541,7 @@ export interface OrganizationDetailsPort {
|
|
|
659
1541
|
export declare function organizationCompanyTaxId(organization: {
|
|
660
1542
|
/** Absent reads as a company, as a session payload without the flag does. */
|
|
661
1543
|
readonly isPersonal?: boolean | undefined;
|
|
662
|
-
readonly taxId: string;
|
|
1544
|
+
readonly taxId: string | null;
|
|
663
1545
|
}): string | null;
|
|
664
1546
|
/**
|
|
665
1547
|
* Diacritic-insensitive normalisation for the organisation's `name_search`
|
|
@@ -802,8 +1684,10 @@ export interface PersonalOrganizationPort {
|
|
|
802
1684
|
* the authority check and the "an organisation keeps an administrator" guard
|
|
803
1685
|
* that must precede it are `customers`' policy.
|
|
804
1686
|
*
|
|
805
|
-
* Idempotent: the personal organisation
|
|
806
|
-
*
|
|
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.
|
|
807
1691
|
*/
|
|
808
1692
|
provisionPersonalOrganization(customerAccountId: string): Promise<ProvisionedPersonalOrganizationRecord>;
|
|
809
1693
|
/**
|
|
@@ -898,10 +1782,12 @@ export interface SalesRepAssignmentPort {
|
|
|
898
1782
|
}): Promise<boolean>;
|
|
899
1783
|
}
|
|
900
1784
|
/**
|
|
901
|
-
* 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).
|
|
902
1787
|
*
|
|
903
|
-
* The
|
|
904
|
-
*
|
|
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.
|
|
905
1791
|
*/
|
|
906
1792
|
export type AdminTenantScope = {
|
|
907
1793
|
readonly allowAll: true;
|
|
@@ -916,15 +1802,55 @@ export type AdminTenantScope = {
|
|
|
916
1802
|
* can only turn an answer into a refusal, never widen one.
|
|
917
1803
|
*/
|
|
918
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;
|
|
919
1842
|
};
|
|
920
1843
|
/**
|
|
921
1844
|
* Container name: `adminTenantScopePort`. Owner: `organizations`.
|
|
922
1845
|
*
|
|
923
1846
|
* The tenant reach of an authenticated admin, derived from the role the admin
|
|
924
|
-
* holds and never from request inputs (Principle XI). An admin whose role
|
|
925
|
-
*
|
|
926
|
-
*
|
|
927
|
-
*
|
|
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.
|
|
928
1854
|
*
|
|
929
1855
|
* **An admin with no role is refused, never widened.** An id that names no
|
|
930
1856
|
* live administrator, or an administrator holding no role, answers the empty
|
|
@@ -956,6 +1882,15 @@ export type AdminTenantScope = {
|
|
|
956
1882
|
*/
|
|
957
1883
|
export interface AdminTenantScopePort {
|
|
958
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>>;
|
|
959
1894
|
}
|
|
960
1895
|
/** The address a VAT registry hands back when it recognises the tax id. */
|
|
961
1896
|
export interface VatReturnedAddress {
|
|
@@ -1073,7 +2008,7 @@ export type OrganizationSalesChannelsUpdateBody = z.infer<typeof OrganizationSal
|
|
|
1073
2008
|
*/
|
|
1074
2009
|
export declare const AdminOrganizationCreateBodySchema: z.ZodObject<{
|
|
1075
2010
|
name: z.ZodString;
|
|
1076
|
-
taxId: z.ZodString
|
|
2011
|
+
taxId: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
1077
2012
|
registeredAddress: z.ZodObject<{
|
|
1078
2013
|
street: z.ZodString;
|
|
1079
2014
|
city: z.ZodString;
|
|
@@ -1085,11 +2020,13 @@ export declare const AdminOrganizationCreateBodySchema: z.ZodObject<{
|
|
|
1085
2020
|
vat_exempt: "vat_exempt";
|
|
1086
2021
|
reverse_charge: "reverse_charge";
|
|
1087
2022
|
}>>;
|
|
2023
|
+
customFieldValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1088
2024
|
status: z.ZodDefault<z.ZodEnum<{
|
|
1089
2025
|
active: "active";
|
|
1090
2026
|
pending_verification: "pending_verification";
|
|
1091
2027
|
}>>;
|
|
1092
2028
|
salesChannelIds: z.ZodArray<z.ZodString>;
|
|
2029
|
+
parentId: z.ZodOptional<z.ZodString>;
|
|
1093
2030
|
}, z.core.$strip>;
|
|
1094
2031
|
export type AdminOrganizationCreateBody = z.infer<typeof AdminOrganizationCreateBodySchema>;
|
|
1095
2032
|
export type AdminOrganizationCreateRequest = z.input<typeof AdminOrganizationCreateBodySchema>;
|