@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/custom-fields.js
CHANGED
|
@@ -30,6 +30,41 @@ export const supportedEntityTypeSchema = z.enum([
|
|
|
30
30
|
// while that module is present.
|
|
31
31
|
'task',
|
|
32
32
|
]);
|
|
33
|
+
/**
|
|
34
|
+
* The one custom-field host binding registry (`specs/178-extensible-columns/`
|
|
35
|
+
* FR-010, research R-8).
|
|
36
|
+
*
|
|
37
|
+
* Moved here from `custom_fields`' module-internal storage binding so that two
|
|
38
|
+
* readers can share one answer: `custom_fields` reads it for the table and the
|
|
39
|
+
* value column its host probes and list filters build against, and the platform
|
|
40
|
+
* derives its extensible host list from it — every custom-field host table is
|
|
41
|
+
* extensible (OD-15), so a second list of them would be a second answer waiting
|
|
42
|
+
* to disagree. Purely a storage binding: no host logic lives here, and neither
|
|
43
|
+
* the table nor the column ever comes from a caller.
|
|
44
|
+
*/
|
|
45
|
+
export const CUSTOM_FIELD_HOST_BINDINGS = {
|
|
46
|
+
category: { table: 'categories', valueColumn: 'custom_field_values', ownerModuleId: 'catalog' },
|
|
47
|
+
order: { table: 'orders', valueColumn: 'custom_field_values', ownerModuleId: 'orders' },
|
|
48
|
+
organization: {
|
|
49
|
+
table: 'organizations',
|
|
50
|
+
valueColumn: 'custom_field_values',
|
|
51
|
+
ownerModuleId: 'organizations',
|
|
52
|
+
},
|
|
53
|
+
customer: {
|
|
54
|
+
table: 'customer_accounts',
|
|
55
|
+
valueColumn: 'custom_field_values',
|
|
56
|
+
ownerModuleId: 'customer_accounts',
|
|
57
|
+
},
|
|
58
|
+
quote_request: {
|
|
59
|
+
table: 'quote_requests',
|
|
60
|
+
valueColumn: 'custom_field_values',
|
|
61
|
+
ownerModuleId: 'quote_requests',
|
|
62
|
+
},
|
|
63
|
+
product: { table: 'products', valueColumn: 'attribute_values', ownerModuleId: 'catalog' },
|
|
64
|
+
opportunity: { table: 'crm_opportunities', valueColumn: 'custom_field_values', ownerModuleId: 'crm' },
|
|
65
|
+
project: { table: 'projects', valueColumn: 'custom_field_values', ownerModuleId: 'projects' },
|
|
66
|
+
task: { table: 'tasks', valueColumn: 'custom_field_values', ownerModuleId: 'tasks' },
|
|
67
|
+
};
|
|
33
68
|
/**
|
|
34
69
|
* The set of runtime value types. `text` is stored as a string; `select` stores one option value; `multiselect` an array.
|
|
35
70
|
*
|
|
@@ -62,6 +97,23 @@ export const customFieldValueTypeSchema = z.enum([
|
|
|
62
97
|
* already being answered.
|
|
63
98
|
*/
|
|
64
99
|
export const customFieldAudienceSchema = z.enum(['customer', 'internal']);
|
|
100
|
+
/**
|
|
101
|
+
* Feature 175 — the forms on which a BUYER may supply a custom-field value
|
|
102
|
+
* (`specs/175-buyer-input-custom-fields/`, OD-3). A closed vocabulary: the
|
|
103
|
+
* next surface is a release, not data an operator types. A definition names
|
|
104
|
+
* the surfaces it is open on (`customerInput`); an entity type's registry entry
|
|
105
|
+
* names the surfaces it offers at all.
|
|
106
|
+
*/
|
|
107
|
+
export const customFieldInputSurfaceSchema = z.enum(['organization.register']);
|
|
108
|
+
/**
|
|
109
|
+
* Feature 175 — how the admin custom-field panel offers a field: `edit`
|
|
110
|
+
* (an input), `read` (the value, no input) or `hidden` (not rendered).
|
|
111
|
+
*
|
|
112
|
+
* **A panel convenience, not access control** (OD-8, FR-007): no API endpoint
|
|
113
|
+
* reads it, so what the admin API accepts, answers, filters, exports and
|
|
114
|
+
* audits is the same at every level. A `required` field is always `edit`.
|
|
115
|
+
*/
|
|
116
|
+
export const customFieldAdminAccessSchema = z.enum(['edit', 'read', 'hidden']);
|
|
65
117
|
export const localizedLabelSchema = z.record(z.string(), z.string());
|
|
66
118
|
/** A select/multiselect option. `id` absent on create. */
|
|
67
119
|
export const customFieldOptionSchema = z.object({
|
|
@@ -124,10 +176,27 @@ export const customFieldDefinitionSchema = z.object({
|
|
|
124
176
|
listFilter: z.boolean(),
|
|
125
177
|
/** See {@link customFieldCarryToSchema} (feature 162). */
|
|
126
178
|
carryTo: customFieldCarryToSchema,
|
|
179
|
+
/**
|
|
180
|
+
* Feature 175 — the input surfaces a buyer may supply this field's value on
|
|
181
|
+
* ({@link customFieldInputSurfaceSchema}). Only surfaces the entity type
|
|
182
|
+
* offers ({@link customFieldEntityTypeInfoSchema}); non-empty only with the
|
|
183
|
+
* `customer` audience and never for `page_builder`. Stored deduplicated and
|
|
184
|
+
* sorted.
|
|
185
|
+
*/
|
|
186
|
+
customerInput: z.array(customFieldInputSurfaceSchema),
|
|
187
|
+
/** Feature 175 — see {@link customFieldAdminAccessSchema}. */
|
|
188
|
+
adminAccess: customFieldAdminAccessSchema,
|
|
127
189
|
options: z.array(customFieldOptionSchema).default([]),
|
|
128
190
|
createdAt: isoDateTimeSchema,
|
|
129
191
|
updatedAt: isoDateTimeSchema,
|
|
130
192
|
});
|
|
193
|
+
/**
|
|
194
|
+
* `GET /api/v1/admin/custom-fields/definitions` — the definitions, optionally of
|
|
195
|
+
* one entity type, whose type's owner module is present (issue #599).
|
|
196
|
+
*/
|
|
197
|
+
export const customFieldDefinitionListResponseSchema = z.object({
|
|
198
|
+
data: z.array(customFieldDefinitionSchema),
|
|
199
|
+
});
|
|
131
200
|
/** Create a definition. `entityType` + `key` are immutable after create. */
|
|
132
201
|
export const createCustomFieldDefinitionSchema = customFieldDefinitionSchema
|
|
133
202
|
.omit({ id: true, createdAt: true, updatedAt: true })
|
|
@@ -136,10 +205,14 @@ export const createCustomFieldDefinitionSchema = customFieldDefinitionSchema
|
|
|
136
205
|
// A definition created without `listFilter` is not a list filter; the
|
|
137
206
|
// server reads the absence as `false` rather than the schema defaulting it.
|
|
138
207
|
// A definition created without `carryTo` carries nothing (feature 162).
|
|
208
|
+
// Feature 175 — one created without `customerInput` is open on no surface,
|
|
209
|
+
// and one without `adminAccess` is editable in the admin panel.
|
|
139
210
|
.extend({
|
|
140
211
|
audience: customFieldAudienceSchema.default('internal'),
|
|
141
212
|
listFilter: z.boolean().optional(),
|
|
142
213
|
carryTo: customFieldCarryToSchema.default([]),
|
|
214
|
+
customerInput: z.array(customFieldInputSurfaceSchema).default([]),
|
|
215
|
+
adminAccess: customFieldAdminAccessSchema.default('edit'),
|
|
143
216
|
});
|
|
144
217
|
/** Patch a definition. `entityType` and `key` cannot change once records may hold values. */
|
|
145
218
|
export const updateCustomFieldDefinitionSchema = createCustomFieldDefinitionSchema
|
|
@@ -155,6 +228,8 @@ export const updateCustomFieldDefinitionSchema = createCustomFieldDefinitionSche
|
|
|
155
228
|
config: z.record(z.string(), z.unknown()).optional(),
|
|
156
229
|
listFilter: z.boolean().optional(),
|
|
157
230
|
carryTo: customFieldCarryToSchema.optional(),
|
|
231
|
+
customerInput: z.array(customFieldInputSurfaceSchema).optional(),
|
|
232
|
+
adminAccess: customFieldAdminAccessSchema.optional(),
|
|
158
233
|
});
|
|
159
234
|
/**
|
|
160
235
|
* One supported host entity type as served by the admin entity-types listing
|
|
@@ -180,6 +255,16 @@ export const customFieldEntityTypeInfoSchema = z.object({
|
|
|
180
255
|
* (feature 162), filtered to targets whose owner module is present.
|
|
181
256
|
*/
|
|
182
257
|
carryTargets: z.array(supportedEntityTypeSchema).default([]),
|
|
258
|
+
/**
|
|
259
|
+
* Feature 175 — the input surfaces definitions of this type may be opened
|
|
260
|
+
* on; the definition editor offers the buyer-input option only when it is
|
|
261
|
+
* non-empty (FR-035).
|
|
262
|
+
*/
|
|
263
|
+
customerInputSurfaces: z.array(customFieldInputSurfaceSchema).default([]),
|
|
264
|
+
});
|
|
265
|
+
/** `GET /api/v1/admin/custom-fields/entity-types` — the served entity types (issue #599). */
|
|
266
|
+
export const customFieldEntityTypeListResponseSchema = z.object({
|
|
267
|
+
data: z.array(customFieldEntityTypeInfoSchema),
|
|
183
268
|
});
|
|
184
269
|
/** A validated value bag keyed by definition `key`. Values are typed by their definition's `valueType`. */
|
|
185
270
|
export const customFieldValuesSchema = z.record(z.string(), z.unknown());
|
|
@@ -192,6 +277,12 @@ export const customFieldValidationErrorSchema = z.object({
|
|
|
192
277
|
'unknown_option',
|
|
193
278
|
'out_of_range',
|
|
194
279
|
'duplicate_option',
|
|
280
|
+
// Feature 175 — a buyer-supplied key that is not a live definition open on
|
|
281
|
+
// the surface (also every key when the value port is not composed).
|
|
282
|
+
'not_open_for_input',
|
|
283
|
+
// Feature 175 — more than 50 keys in one buyer-supplied group; `field` is
|
|
284
|
+
// the group's name, not a key.
|
|
285
|
+
'too_many_keys',
|
|
195
286
|
]),
|
|
196
287
|
message: z.string(),
|
|
197
288
|
});
|
|
@@ -335,6 +426,33 @@ export const customFieldListFilterFieldSchema = z
|
|
|
335
426
|
options: z.array(z.object({ value: z.string(), label: localizedLabelSchema, labelDefault: z.string() })),
|
|
336
427
|
})
|
|
337
428
|
.strict();
|
|
429
|
+
/**
|
|
430
|
+
* Feature 175 — one field open on a buyer input surface, as the public read
|
|
431
|
+
* `GET /api/v1/custom-fields/input-surfaces/:surface` answers it
|
|
432
|
+
* (`specs/175-buyer-input-custom-fields/contracts/input-surface-read.md`).
|
|
433
|
+
* Labels are resolved in the request's language with `labelDefault` as the
|
|
434
|
+
* fallback. Never a stored value, the audience, the admin access level or
|
|
435
|
+
* `config`; never a `page_builder` field.
|
|
436
|
+
*/
|
|
437
|
+
export const inputSurfaceFieldSchema = z.object({
|
|
438
|
+
key: z.string(),
|
|
439
|
+
valueType: customFieldValueTypeSchema.exclude(['page_builder']),
|
|
440
|
+
required: z.boolean(),
|
|
441
|
+
label: z.string(),
|
|
442
|
+
/** `[]` unless the field is `select` / `multiselect`. */
|
|
443
|
+
options: z.array(z.object({ value: z.string(), label: z.string() })),
|
|
444
|
+
sortOrder: z.number().int(),
|
|
445
|
+
});
|
|
446
|
+
/**
|
|
447
|
+
* The fields open on one surface, per entity type in display order. An
|
|
448
|
+
* unknown surface, or one no entity type declares, answers `entities: {}`.
|
|
449
|
+
*/
|
|
450
|
+
export const inputSurfaceFieldsResponseSchema = z.object({
|
|
451
|
+
data: z.object({
|
|
452
|
+
surface: z.string(),
|
|
453
|
+
entities: z.partialRecord(supportedEntityTypeSchema, z.array(inputSurfaceFieldSchema)),
|
|
454
|
+
}),
|
|
455
|
+
});
|
|
338
456
|
export const customFieldListFilterFieldsResponseSchema = z.object({
|
|
339
457
|
data: z.array(customFieldListFilterFieldSchema),
|
|
340
458
|
});
|
|
@@ -402,6 +520,15 @@ export const CUSTOM_FIELD_DEFINITION_ERROR_CODES = [
|
|
|
402
520
|
'carry_incompatible',
|
|
403
521
|
// Feature 172 — a value type the definition's entity type does not offer (`page_builder` off `product`).
|
|
404
522
|
'value_type_unsupported',
|
|
523
|
+
// Feature 175 (research R-4) — the four refusals of the buyer-input and
|
|
524
|
+
// admin-access attributes, each judged on the RESULTING definition: a
|
|
525
|
+
// surface the entity type does not offer; an open field whose audience is
|
|
526
|
+
// not `customer`; an open `page_builder` field; a `required` field that is
|
|
527
|
+
// not `edit` in the admin.
|
|
528
|
+
'customer_input_unsupported',
|
|
529
|
+
'customer_input_audience',
|
|
530
|
+
'customer_input_value_type',
|
|
531
|
+
'admin_access_required',
|
|
405
532
|
];
|
|
406
533
|
/**
|
|
407
534
|
* Whether `error` is a refused definition write, narrowed by shape.
|
|
@@ -34,6 +34,18 @@ export declare const customerGroupSchema: z.ZodObject<{
|
|
|
34
34
|
updatedAt: z.ZodString;
|
|
35
35
|
}, z.core.$strip>;
|
|
36
36
|
export type CustomerGroup = z.infer<typeof customerGroupSchema>;
|
|
37
|
+
/** `GET /api/v1/admin/customer-groups` — every group (issue #599). */
|
|
38
|
+
export declare const customerGroupListResponseSchema: z.ZodObject<{
|
|
39
|
+
data: z.ZodArray<z.ZodObject<{
|
|
40
|
+
id: z.ZodString;
|
|
41
|
+
code: z.ZodString;
|
|
42
|
+
name: z.ZodString;
|
|
43
|
+
description: z.ZodNullable<z.ZodString>;
|
|
44
|
+
createdAt: z.ZodString;
|
|
45
|
+
updatedAt: z.ZodString;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export type CustomerGroupListResponse = z.infer<typeof customerGroupListResponseSchema>;
|
|
37
49
|
export declare const upsertCustomerGroupRequestSchema: z.ZodObject<{
|
|
38
50
|
code: z.ZodString;
|
|
39
51
|
name: z.ZodString;
|
|
@@ -125,6 +137,25 @@ export interface CustomerAccountRecord {
|
|
|
125
137
|
blockedByCustomerAccountId: string | null;
|
|
126
138
|
deletionRequestedByAdminUserId: string | null;
|
|
127
139
|
anonymizedAt: Date | null;
|
|
140
|
+
/**
|
|
141
|
+
* Issue #652 (D-292) — the language the account's owner reads: one BCP-47
|
|
142
|
+
* content-language tag, spelled as the sales channel that captured it spells
|
|
143
|
+
* it (`pl-PL`, `en-US`). Captured at account creation and, while still
|
|
144
|
+
* `null`, at sign-in, from the request's channel and its `Accept-Language`;
|
|
145
|
+
* overwritten only by the owner's own choice on the storefront account page.
|
|
146
|
+
*
|
|
147
|
+
* A message composed outside a request resolves it against the channel it
|
|
148
|
+
* is rendered for — `scopeLanguageOf(renderChannel, preferredLanguage)`:
|
|
149
|
+
* the exact language, else one of the same base language, else that
|
|
150
|
+
* channel's default — so a value the channel no longer offers falls back
|
|
151
|
+
* rather than failing. Inside a request the `Accept-Language` header still
|
|
152
|
+
* decides the response language (D-131).
|
|
153
|
+
*
|
|
154
|
+
* `null` means unknown: the account predates the field and has not signed in
|
|
155
|
+
* since, or was created by an operator. Personal data (D-288 list 2): never
|
|
156
|
+
* written into an audit state, cleared by the anonymisation sweep.
|
|
157
|
+
*/
|
|
158
|
+
preferredLanguage: string | null;
|
|
128
159
|
}
|
|
129
160
|
/**
|
|
130
161
|
* Which accounts a lookup should consider. Soft-deleted accounts still resolve
|
|
@@ -238,6 +269,19 @@ export interface CustomerAccountCreateInput {
|
|
|
238
269
|
* the admin direct-create do not.
|
|
239
270
|
*/
|
|
240
271
|
emailVerified?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Feature 175 — the account's custom-field values, ALREADY VALIDATED by the
|
|
274
|
+
* caller through custom_fields' value port (the caller owns the surface and
|
|
275
|
+
* must validate before its first write). Stored as given; `{}` when absent.
|
|
276
|
+
*/
|
|
277
|
+
customFieldValues?: Record<string, unknown>;
|
|
278
|
+
/**
|
|
279
|
+
* Issue #652 (D-292) — the language captured from the creating request:
|
|
280
|
+
* `requestScopeLanguage(requestChannel, Accept-Language)`, so a
|
|
281
|
+
* tag the channel spells. Absent or `null` stores `null` — the admin
|
|
282
|
+
* direct-create, which has no buyer request to read it from.
|
|
283
|
+
*/
|
|
284
|
+
preferredLanguage?: string | null;
|
|
241
285
|
}
|
|
242
286
|
/** Absent fields are left unchanged. */
|
|
243
287
|
export interface CustomerAccountProfilePatch {
|
|
@@ -250,6 +294,37 @@ export interface CustomerAccountProfilePatch {
|
|
|
250
294
|
firstName?: string;
|
|
251
295
|
lastName?: string;
|
|
252
296
|
}
|
|
297
|
+
/** Where a preferred-language write comes from (issue #652, D-292). */
|
|
298
|
+
export type CustomerPreferredLanguageSource = 'self_service' | 'sign_in';
|
|
299
|
+
/**
|
|
300
|
+
* Container name: `customerAccountPreferencePort`. Owner: `customer_accounts`.
|
|
301
|
+
*
|
|
302
|
+
* Issue #652 (D-292) — the account's preferred language, the customer twin of
|
|
303
|
+
* `AdminUserPreferencePort`. Two methods, because there are two writers:
|
|
304
|
+
*
|
|
305
|
+
* - `setPreferredLanguage` — the owner's explicit choice on the storefront
|
|
306
|
+
* account page (`customers`' `PATCH /api/v1/me/customer/preferred-language`),
|
|
307
|
+
* the only write that overwrites a stored value. The caller has already
|
|
308
|
+
* checked the tag against the request channel's languages and passes it in
|
|
309
|
+
* that channel's spelling; this port stores it as given. Throws HTTP 404
|
|
310
|
+
* `NOT_FOUND` for an id no live account has.
|
|
311
|
+
* - `captureIfUnset` — a sign-in's capture (federated sign-in through `mfa`):
|
|
312
|
+
* writes only while the account has no value, and does nothing at all —
|
|
313
|
+
* no write, no audit entry — when it already has one or the id is unknown.
|
|
314
|
+
*
|
|
315
|
+
* Both run `customer_account.set_preferred_language` on the Command Bus. Its
|
|
316
|
+
* audit entry names the field and the source and never the tag (D-288 list 2):
|
|
317
|
+
* `{ changedFields: ['preferredLanguage'], source }`.
|
|
318
|
+
*
|
|
319
|
+
* **Owner off:** the seam fails closed — resolving this port throws
|
|
320
|
+
* `ModuleDisabledError` and the call answers 503 `MODULE_DISABLED`. Whether
|
|
321
|
+
* `customer_accounts` has an off state at all is its manifest's `activation` to
|
|
322
|
+
* say, not this line's: a module declaring `nonDeactivatable` never enters one.
|
|
323
|
+
*/
|
|
324
|
+
export interface CustomerAccountPreferencePort {
|
|
325
|
+
setPreferredLanguage(customerAccountId: string, preferredLanguage: string): Promise<CustomerAccountRecord>;
|
|
326
|
+
captureIfUnset(customerAccountId: string, preferredLanguage: string): Promise<void>;
|
|
327
|
+
}
|
|
253
328
|
/**
|
|
254
329
|
* Container name: `customerAccountMemberWritePort`. Owner: `customer_accounts`.
|
|
255
330
|
*
|
|
@@ -345,6 +420,14 @@ export interface CustomerLoginInput extends CustomerAuthenticationOrigin {
|
|
|
345
420
|
ip?: string;
|
|
346
421
|
userAgent?: string;
|
|
347
422
|
salesChannelId?: string | null;
|
|
423
|
+
/**
|
|
424
|
+
* Issue #652 (D-292) — the sign-in request's language, already resolved
|
|
425
|
+
* against its channel (`scopeLanguageOf`). Stored on the account only while
|
|
426
|
+
* the account has none, and only once the password, the block and the
|
|
427
|
+
* channel access have been accepted; a refused sign-in stores nothing.
|
|
428
|
+
* Absent or `null` stores nothing.
|
|
429
|
+
*/
|
|
430
|
+
language?: string | null;
|
|
348
431
|
}
|
|
349
432
|
/** Where a customer's attempt came from, as far as the caller knows. */
|
|
350
433
|
export interface CustomerAuthenticationOrigin {
|
|
@@ -666,6 +749,59 @@ export interface CustomerAccountRoleCommandPort {
|
|
|
666
749
|
changeRole(input: CustomerAccountRoleChangeInput): CustomerAccountRoleChangeCommand;
|
|
667
750
|
holdersOf(organizationId: string, roleId: string): Promise<string[]>;
|
|
668
751
|
}
|
|
752
|
+
/**
|
|
753
|
+
* `customer_account.create` as the platform's Command Bus runs it, named
|
|
754
|
+
* structurally for the reason {@link CustomerAccountRoleChangeCommand} is: the
|
|
755
|
+
* platform's `Command<CustomerAccountRecord>` is assignable to it and it to
|
|
756
|
+
* that, so a caller hands it to `commandBus.run` or, as a child, to `ctx.run`
|
|
757
|
+
* unchanged. Its `run` belongs to the bus.
|
|
758
|
+
*/
|
|
759
|
+
export interface CustomerAccountCreateCommand {
|
|
760
|
+
readonly action: string;
|
|
761
|
+
readonly objectType: string;
|
|
762
|
+
readonly objectId: string;
|
|
763
|
+
run(ctx: never): Promise<{
|
|
764
|
+
readonly result: CustomerAccountRecord;
|
|
765
|
+
}>;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* What {@link CustomerAccountMemberCommandPort.prepareCreate} takes: an account's
|
|
769
|
+
* creation input without the two ids a caller may only know inside its own
|
|
770
|
+
* transaction — a registration learns its Organization's *Administrator* role
|
|
771
|
+
* id from the row the Organization's insert wrote.
|
|
772
|
+
*/
|
|
773
|
+
export type CustomerAccountCreatePreparation = Omit<CustomerAccountCreateInput, 'organizationId' | 'organizationRoleId'>;
|
|
774
|
+
/** A prepared account creation: the password is hashed, the Command not yet built. */
|
|
775
|
+
export interface PreparedCustomerAccountCreate {
|
|
776
|
+
/** The `customer_account.create` Command for that Organization and role. */
|
|
777
|
+
command(target: {
|
|
778
|
+
organizationId: string;
|
|
779
|
+
organizationRoleId: string;
|
|
780
|
+
}): CustomerAccountCreateCommand;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Container name: `customerAccountMemberCommandPort`. Owner: `customer_accounts`.
|
|
784
|
+
*
|
|
785
|
+
* The account creation as a **Command factory** (`specs/176-command-hooks-outbox/`
|
|
786
|
+
* FR-002, FR-005, `contracts/registration-command.md`): `organizations` creates
|
|
787
|
+
* a registration's first account as a **child** of `organization.register`
|
|
788
|
+
* through `ctx.run`, so the Organization and its administrator commit together
|
|
789
|
+
* or not at all, each with its own audit entry. No `EntityManager` crosses.
|
|
790
|
+
*
|
|
791
|
+
* `prepareCreate` hashes the password **now**, outside any transaction — the
|
|
792
|
+
* hash's cost is deliberate and must never run while a transaction holds the
|
|
793
|
+
* caller's rows — and the Command it later builds only writes. The Command
|
|
794
|
+
* refuses `409 EMAIL_ALREADY_REGISTERED` from its pre-check and from the unique
|
|
795
|
+
* index, inside its run.
|
|
796
|
+
*
|
|
797
|
+
* {@link CustomerAccountMemberWritePort.create} runs this same Command,
|
|
798
|
+
* top-level, so the creation has one implementation (FR-004).
|
|
799
|
+
*
|
|
800
|
+
* **Owner off:** the seam fails closed, as {@link CustomerAccountRoleCommandPort} does.
|
|
801
|
+
*/
|
|
802
|
+
export interface CustomerAccountMemberCommandPort {
|
|
803
|
+
prepareCreate(input: CustomerAccountCreatePreparation): Promise<PreparedCustomerAccountCreate>;
|
|
804
|
+
}
|
|
669
805
|
/**
|
|
670
806
|
* A standalone (org-less) self-registration, as `customers` asks for one.
|
|
671
807
|
*
|
|
@@ -687,6 +823,8 @@ export interface CustomerAccountStandaloneCreateInput {
|
|
|
687
823
|
password: string;
|
|
688
824
|
firstName: string;
|
|
689
825
|
lastName: string;
|
|
826
|
+
/** Issue #652 — as {@link CustomerAccountCreateInput.preferredLanguage}. */
|
|
827
|
+
preferredLanguage?: string | null;
|
|
690
828
|
}
|
|
691
829
|
/**
|
|
692
830
|
* The request the write was made from, stamped onto its audit row.
|
|
@@ -50,6 +50,10 @@ export const customerGroupSchema = z.object({
|
|
|
50
50
|
createdAt: isoDateTimeSchema,
|
|
51
51
|
updatedAt: isoDateTimeSchema,
|
|
52
52
|
});
|
|
53
|
+
/** `GET /api/v1/admin/customer-groups` — every group (issue #599). */
|
|
54
|
+
export const customerGroupListResponseSchema = z.object({
|
|
55
|
+
data: z.array(customerGroupSchema),
|
|
56
|
+
});
|
|
53
57
|
export const upsertCustomerGroupRequestSchema = z.object({
|
|
54
58
|
code: z.string().min(1).max(64),
|
|
55
59
|
name: z.string().min(1).max(160),
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* `customer_notifications` module contracts — the buyer's notification centre on
|
|
4
|
+
* the storefront (`specs/179-rfq-and-customer-notifications/`).
|
|
5
|
+
*
|
|
6
|
+
* Two halves:
|
|
7
|
+
* (1) the in-process port producers record entries through
|
|
8
|
+
* (`contracts/delivery-and-ports.md` §1) — plain TypeScript, as in
|
|
9
|
+
* `admin-notifications.ts`, because it describes an in-process call;
|
|
10
|
+
* (2) the storefront API shapes (`contracts/customer-notifications-storefront-api.md` §2)
|
|
11
|
+
* — Zod schemas, the source of truth for the HTTP boundary (Principle II).
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* A translatable sentence: the bundle (`scope`, a module id), the key in it and
|
|
15
|
+
* the `{name}` placeholders' values — strings and numbers only, drawn as text.
|
|
16
|
+
* The same shape as `AdminNotificationMessage`, deliberately (research R-13):
|
|
17
|
+
* an entry is translated when it is read, in the reader's language, and the
|
|
18
|
+
* English sentence stored beside it is shown when the key does not resolve.
|
|
19
|
+
*/
|
|
20
|
+
export interface CustomerNotificationMessage {
|
|
21
|
+
scope: string;
|
|
22
|
+
key: string;
|
|
23
|
+
params?: Record<string, string | number>;
|
|
24
|
+
}
|
|
25
|
+
export interface RecordCustomerNotificationInput {
|
|
26
|
+
organizationId: string;
|
|
27
|
+
customerAccountId: string;
|
|
28
|
+
/** The channel the entry concerns; `null` = shown on every channel. */
|
|
29
|
+
salesChannelId: string | null;
|
|
30
|
+
/** The producing module's id; the list hides entries whose producer is absent. */
|
|
31
|
+
sourceModule: string;
|
|
32
|
+
/** Unique per `sourceModule`; a second record with the same key is refused (see the port). */
|
|
33
|
+
sourceKey: string;
|
|
34
|
+
/** E.g. `quote_requests.approved`; consumers branch on it, never on the sentence. */
|
|
35
|
+
kind: string;
|
|
36
|
+
subjectType?: string | null;
|
|
37
|
+
subjectId?: string | null;
|
|
38
|
+
/** The finished English sentence — always, also beside `titleMessage`. */
|
|
39
|
+
title: string;
|
|
40
|
+
titleMessage: CustomerNotificationMessage;
|
|
41
|
+
body?: string | null;
|
|
42
|
+
/** `body`, translatable. Rejected without a `body` to fall back to. */
|
|
43
|
+
bodyMessage?: CustomerNotificationMessage | null;
|
|
44
|
+
/** Storefront-relative: starts with one `/`, no scheme, no `//` (FR-047). */
|
|
45
|
+
linkPath?: string | null;
|
|
46
|
+
}
|
|
47
|
+
/** What was recorded, for a caller that wants to correlate its own log. */
|
|
48
|
+
export interface CustomerNotificationRecord {
|
|
49
|
+
id: string;
|
|
50
|
+
createdAt: Date;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Container name: `customerNotificationRecordPort`. Owner: `customer_notifications`
|
|
54
|
+
* (`specs/179-rfq-and-customer-notifications/`).
|
|
55
|
+
*
|
|
56
|
+
* Owner off: the gate fails closed (`ModuleDisabledError`). Callers decide
|
|
57
|
+
* presence in front of it (`effectiveState.isPresent('customer_notifications')`)
|
|
58
|
+
* and never catch the refusal (D-60).
|
|
59
|
+
*
|
|
60
|
+
* `recordWithin` persists into the caller's unit of work, with no fork and no
|
|
61
|
+
* flush, and commits or rolls back with it — the admin bell's `recordWithin`
|
|
62
|
+
* semantics. It validates before persisting and throws a plain `Error` on
|
|
63
|
+
* invalid input (link, params, body/bodyMessage pairing): a programming error,
|
|
64
|
+
* not a delivery outcome.
|
|
65
|
+
*
|
|
66
|
+
* Idempotency: `(sourceModule, sourceKey)` is unique in the database.
|
|
67
|
+
* `recordWithin` relies on the caller's own idempotency (`quote_requests`
|
|
68
|
+
* closes its delivery record in the same transaction, so a second call for the
|
|
69
|
+
* same record cannot happen); `record` answers the existing entry when the key
|
|
70
|
+
* is already present.
|
|
71
|
+
*
|
|
72
|
+
* `EM` is the caller's MikroORM `EntityManager`, a type parameter because this
|
|
73
|
+
* package holds no `@mikro-orm` import (the `AdminNotificationRecordPort`
|
|
74
|
+
* precedent). A consumer writes `CustomerNotificationRecordPort<EntityManager>`.
|
|
75
|
+
*/
|
|
76
|
+
export interface CustomerNotificationRecordPort<EM = unknown> {
|
|
77
|
+
record(input: RecordCustomerNotificationInput): Promise<CustomerNotificationRecord>;
|
|
78
|
+
recordWithin(em: EM, input: RecordCustomerNotificationInput): CustomerNotificationRecord;
|
|
79
|
+
}
|
|
80
|
+
/** One entry as the signed-in buyer reads it. */
|
|
81
|
+
export declare const customerNotificationSchema: z.ZodObject<{
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
kind: z.ZodString;
|
|
84
|
+
title: z.ZodString;
|
|
85
|
+
body: z.ZodNullable<z.ZodString>;
|
|
86
|
+
subject: z.ZodNullable<z.ZodObject<{
|
|
87
|
+
type: z.ZodString;
|
|
88
|
+
id: z.ZodString;
|
|
89
|
+
}, z.core.$strip>>;
|
|
90
|
+
linkPath: z.ZodNullable<z.ZodString>;
|
|
91
|
+
createdAt: z.ZodString;
|
|
92
|
+
readAt: z.ZodNullable<z.ZodString>;
|
|
93
|
+
}, z.core.$strict>;
|
|
94
|
+
export type CustomerNotification = z.infer<typeof customerNotificationSchema>;
|
|
95
|
+
/** `GET /api/v1/storefront/notifications` — newest first, keyset-paged. */
|
|
96
|
+
export declare const customerNotificationListResponseSchema: z.ZodObject<{
|
|
97
|
+
data: z.ZodObject<{
|
|
98
|
+
items: z.ZodArray<z.ZodObject<{
|
|
99
|
+
id: z.ZodString;
|
|
100
|
+
kind: z.ZodString;
|
|
101
|
+
title: z.ZodString;
|
|
102
|
+
body: z.ZodNullable<z.ZodString>;
|
|
103
|
+
subject: z.ZodNullable<z.ZodObject<{
|
|
104
|
+
type: z.ZodString;
|
|
105
|
+
id: z.ZodString;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
linkPath: z.ZodNullable<z.ZodString>;
|
|
108
|
+
createdAt: z.ZodString;
|
|
109
|
+
readAt: z.ZodNullable<z.ZodString>;
|
|
110
|
+
}, z.core.$strict>>;
|
|
111
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
112
|
+
unreadCount: z.ZodNumber;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
export type CustomerNotificationListResponse = z.infer<typeof customerNotificationListResponseSchema>;
|
|
116
|
+
/**
|
|
117
|
+
* `GET /api/v1/storefront/notifications/:id` — one entry, under the same three
|
|
118
|
+
* visibility predicates as the list; read-only, it marks nothing.
|
|
119
|
+
*/
|
|
120
|
+
export declare const customerNotificationResponseSchema: z.ZodObject<{
|
|
121
|
+
data: z.ZodObject<{
|
|
122
|
+
id: z.ZodString;
|
|
123
|
+
kind: z.ZodString;
|
|
124
|
+
title: z.ZodString;
|
|
125
|
+
body: z.ZodNullable<z.ZodString>;
|
|
126
|
+
subject: z.ZodNullable<z.ZodObject<{
|
|
127
|
+
type: z.ZodString;
|
|
128
|
+
id: z.ZodString;
|
|
129
|
+
}, z.core.$strip>>;
|
|
130
|
+
linkPath: z.ZodNullable<z.ZodString>;
|
|
131
|
+
createdAt: z.ZodString;
|
|
132
|
+
readAt: z.ZodNullable<z.ZodString>;
|
|
133
|
+
}, z.core.$strict>;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
export type CustomerNotificationResponse = z.infer<typeof customerNotificationResponseSchema>;
|
|
136
|
+
/** `GET /api/v1/storefront/notifications/unread-count`. */
|
|
137
|
+
export declare const customerNotificationUnreadCountResponseSchema: z.ZodObject<{
|
|
138
|
+
data: z.ZodObject<{
|
|
139
|
+
unreadCount: z.ZodNumber;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
}, z.core.$strip>;
|
|
142
|
+
export type CustomerNotificationUnreadCountResponse = z.infer<typeof customerNotificationUnreadCountResponseSchema>;
|
|
143
|
+
//# sourceMappingURL=customer-notifications.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { isoDateTimeSchema, uuidSchema } from './common.js';
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// (2) Storefront API — `/api/v1/storefront/notifications*`
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
/** One entry as the signed-in buyer reads it. */
|
|
7
|
+
export const customerNotificationSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
id: uuidSchema,
|
|
10
|
+
kind: z.string(),
|
|
11
|
+
/** Rendered in the request's language; the stored English sentence when the key does not resolve. */
|
|
12
|
+
title: z.string(),
|
|
13
|
+
body: z.string().nullable(),
|
|
14
|
+
subject: z.object({ type: z.string(), id: uuidSchema }).nullable(),
|
|
15
|
+
/** Storefront-relative, without locale prefix; the storefront localises it. */
|
|
16
|
+
linkPath: z.string().nullable(),
|
|
17
|
+
createdAt: isoDateTimeSchema,
|
|
18
|
+
readAt: isoDateTimeSchema.nullable(),
|
|
19
|
+
})
|
|
20
|
+
.strict();
|
|
21
|
+
/** `GET /api/v1/storefront/notifications` — newest first, keyset-paged. */
|
|
22
|
+
export const customerNotificationListResponseSchema = z.object({
|
|
23
|
+
data: z.object({
|
|
24
|
+
items: z.array(customerNotificationSchema),
|
|
25
|
+
/** Opaque keyset cursor over `(created_at desc, id desc)`, base64url; `null` on the last page. */
|
|
26
|
+
nextCursor: z.string().nullable(),
|
|
27
|
+
unreadCount: z.number().int().nonnegative(),
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* `GET /api/v1/storefront/notifications/:id` — one entry, under the same three
|
|
32
|
+
* visibility predicates as the list; read-only, it marks nothing.
|
|
33
|
+
*/
|
|
34
|
+
export const customerNotificationResponseSchema = z.object({
|
|
35
|
+
data: customerNotificationSchema,
|
|
36
|
+
});
|
|
37
|
+
/** `GET /api/v1/storefront/notifications/unread-count`. */
|
|
38
|
+
export const customerNotificationUnreadCountResponseSchema = z.object({
|
|
39
|
+
data: z.object({ unreadCount: z.number().int().nonnegative() }),
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=customer-notifications.js.map
|
package/dist/customers.d.ts
CHANGED
|
@@ -156,6 +156,7 @@ export declare const customerSelfProfileSchema: z.ZodObject<{
|
|
|
156
156
|
organizationId: z.ZodNullable<z.ZodString>;
|
|
157
157
|
customerGroupId: z.ZodNullable<z.ZodString>;
|
|
158
158
|
twoFactorEnabled: z.ZodBoolean;
|
|
159
|
+
preferredLanguage: z.ZodNullable<z.ZodString>;
|
|
159
160
|
organizationRole: z.ZodObject<{
|
|
160
161
|
id: z.ZodString;
|
|
161
162
|
name: z.ZodString;
|
|
@@ -168,6 +169,29 @@ export declare const customerSelfProfileSchema: z.ZodObject<{
|
|
|
168
169
|
permissions: z.ZodArray<z.ZodString>;
|
|
169
170
|
}, z.core.$strip>;
|
|
170
171
|
export type CustomerSelfProfile = z.infer<typeof customerSelfProfileSchema>;
|
|
172
|
+
/**
|
|
173
|
+
* The longest language tag a preferred language may be — RFC 5646 §4.4.1's
|
|
174
|
+
* recommended minimum buffer, and the width of `customer_accounts.preferred_language`.
|
|
175
|
+
*/
|
|
176
|
+
export declare const CUSTOMER_PREFERRED_LANGUAGE_MAX_LENGTH = 35;
|
|
177
|
+
/**
|
|
178
|
+
* `PATCH /api/v1/me/customer/preferred-language` — the buyer's explicit choice
|
|
179
|
+
* of the language their e-mails are written in (issue #652, D-292). Not
|
|
180
|
+
* nullable: the account page always submits a language. A tag the request's
|
|
181
|
+
* sales channel does not offer is refused `422 PREFERRED_LANGUAGE_NOT_OFFERED`;
|
|
182
|
+
* an offered one is stored in the channel's spelling, matched
|
|
183
|
+
* case-insensitively.
|
|
184
|
+
*/
|
|
185
|
+
export declare const patchCustomerPreferredLanguageBodySchema: z.ZodObject<{
|
|
186
|
+
preferredLanguage: z.ZodString;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
export type PatchCustomerPreferredLanguageBody = z.infer<typeof patchCustomerPreferredLanguageBodySchema>;
|
|
189
|
+
export declare const patchCustomerPreferredLanguageResponseSchema: z.ZodObject<{
|
|
190
|
+
data: z.ZodObject<{
|
|
191
|
+
preferredLanguage: z.ZodString;
|
|
192
|
+
}, z.core.$strip>;
|
|
193
|
+
}, z.core.$strip>;
|
|
194
|
+
export type PatchCustomerPreferredLanguageResponse = z.infer<typeof patchCustomerPreferredLanguageResponseSchema>;
|
|
171
195
|
export declare const adminCustomerListItemSchema: z.ZodObject<{
|
|
172
196
|
id: z.ZodString;
|
|
173
197
|
email: z.ZodString;
|
|
@@ -183,6 +207,33 @@ export declare const adminCustomerListItemSchema: z.ZodObject<{
|
|
|
183
207
|
lastLoginAt: z.ZodNullable<z.ZodString>;
|
|
184
208
|
}, z.core.$strip>;
|
|
185
209
|
export type AdminCustomerListItem = z.infer<typeof adminCustomerListItemSchema>;
|
|
210
|
+
/**
|
|
211
|
+
* `GET /api/v1/admin/customers` — one page of the admin list (issue #599).
|
|
212
|
+
* Offset paging: `page` is 1-based, `pageSize` 1–100, `total` the rows the
|
|
213
|
+
* filters match across every page.
|
|
214
|
+
*/
|
|
215
|
+
export declare const adminCustomerListResponseSchema: z.ZodObject<{
|
|
216
|
+
data: z.ZodArray<z.ZodObject<{
|
|
217
|
+
id: z.ZodString;
|
|
218
|
+
email: z.ZodString;
|
|
219
|
+
firstName: z.ZodString;
|
|
220
|
+
lastName: z.ZodString;
|
|
221
|
+
organizationId: z.ZodNullable<z.ZodString>;
|
|
222
|
+
organizationName: z.ZodNullable<z.ZodString>;
|
|
223
|
+
customerGroupId: z.ZodNullable<z.ZodString>;
|
|
224
|
+
customerGroupName: z.ZodNullable<z.ZodString>;
|
|
225
|
+
blocked: z.ZodBoolean;
|
|
226
|
+
deleted: z.ZodBoolean;
|
|
227
|
+
createdAt: z.ZodString;
|
|
228
|
+
lastLoginAt: z.ZodNullable<z.ZodString>;
|
|
229
|
+
}, z.core.$strip>>;
|
|
230
|
+
meta: z.ZodObject<{
|
|
231
|
+
page: z.ZodNumber;
|
|
232
|
+
pageSize: z.ZodNumber;
|
|
233
|
+
total: z.ZodNumber;
|
|
234
|
+
}, z.core.$strip>;
|
|
235
|
+
}, z.core.$strip>;
|
|
236
|
+
export type AdminCustomerListResponse = z.infer<typeof adminCustomerListResponseSchema>;
|
|
186
237
|
export declare const adminCustomerBlockInfoSchema: z.ZodObject<{
|
|
187
238
|
blockedAt: z.ZodString;
|
|
188
239
|
blockSource: z.ZodEnum<{
|
|
@@ -230,6 +281,7 @@ export declare const adminCustomerDetailSchema: z.ZodObject<{
|
|
|
230
281
|
}, z.core.$strip>>;
|
|
231
282
|
emailVerifiedAt: z.ZodNullable<z.ZodString>;
|
|
232
283
|
twoFactorEnabled: z.ZodBoolean;
|
|
284
|
+
preferredLanguage: z.ZodNullable<z.ZodString>;
|
|
233
285
|
salesChannelIds: z.ZodArray<z.ZodString>;
|
|
234
286
|
defaults: z.ZodObject<{
|
|
235
287
|
paymentMethodId: z.ZodNullable<z.ZodString>;
|