@endora-commerce/contracts 0.109.0 → 0.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accept-language.d.ts +31 -0
- package/dist/accept-language.js +64 -0
- package/dist/actor.d.ts +16 -0
- package/dist/addresses.d.ts +35 -0
- package/dist/addresses.js +8 -1
- package/dist/admin-actions.d.ts +2 -0
- package/dist/admin-actions.js +18 -0
- package/dist/admin-contributions.d.ts +99 -12
- package/dist/admin-contributions.js +36 -10
- package/dist/admin-roles.d.ts +17 -2
- package/dist/admin-users.d.ts +9 -0
- package/dist/admin.d.ts +114 -4
- package/dist/admin.js +98 -3
- package/dist/api-keys.d.ts +22 -0
- package/dist/api-keys.js +4 -0
- package/dist/assets-library.d.ts +45 -0
- package/dist/assets-library.js +20 -3
- package/dist/audit-logs.d.ts +12 -0
- package/dist/audit-logs.js +12 -0
- package/dist/auth.d.ts +9 -0
- package/dist/auth.js +9 -0
- package/dist/blog.d.ts +382 -22
- package/dist/blog.js +199 -17
- package/dist/carts.d.ts +423 -36
- package/dist/carts.js +150 -12
- package/dist/catalog.d.ts +379 -208
- package/dist/catalog.js +241 -163
- package/dist/cms-brand.d.ts +14 -14
- package/dist/cms.d.ts +71 -16
- package/dist/cms.js +15 -0
- package/dist/command-hooks.d.ts +301 -0
- package/dist/command-hooks.js +248 -0
- package/dist/common.d.ts +23 -6
- package/dist/common.js +25 -2
- package/dist/comparisons.d.ts +21 -14
- package/dist/comparisons.js +2 -1
- package/dist/credit-limits.d.ts +22 -0
- package/dist/credit-limits.js +35 -0
- package/dist/crm.d.ts +134 -78
- package/dist/crm.js +21 -5
- package/dist/custom-fields.d.ts +417 -49
- package/dist/custom-fields.js +142 -1
- package/dist/customer-accounts.d.ts +324 -22
- package/dist/customer-accounts.js +43 -0
- package/dist/customer-notifications.d.ts +143 -0
- package/dist/customer-notifications.js +41 -0
- package/dist/customers.d.ts +92 -73
- package/dist/customers.js +98 -10
- package/dist/dictionary.d.ts +53 -0
- package/dist/dictionary.js +25 -0
- package/dist/document-templates.d.ts +12 -12
- package/dist/email.d.ts +34 -0
- package/dist/email.js +6 -0
- package/dist/errors.d.ts +431 -3
- package/dist/errors.js +523 -3
- package/dist/forms-logic.d.ts +79 -0
- package/dist/forms-logic.fixtures.d.ts +52 -0
- package/dist/forms-logic.fixtures.js +610 -0
- package/dist/forms-logic.js +699 -0
- package/dist/forms.d.ts +9833 -0
- package/dist/forms.js +827 -0
- package/dist/i18n.d.ts +34 -0
- package/dist/i18n.js +15 -0
- package/dist/import-export.d.ts +180 -0
- package/dist/import-export.js +60 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.js +30 -1
- package/dist/inventory.d.ts +9 -9
- package/dist/invoice-ledger.d.ts +13 -13
- package/dist/invoices.d.ts +126 -0
- package/dist/invoices.js +53 -0
- package/dist/line-bounds.d.ts +53 -0
- package/dist/line-bounds.js +65 -0
- package/dist/megamenu.d.ts +27 -27
- package/dist/mfa.d.ts +210 -4
- package/dist/mfa.js +136 -0
- package/dist/modules.d.ts +56 -8
- package/dist/modules.js +128 -3
- package/dist/money-decimal.d.ts +54 -0
- package/dist/money-decimal.js +95 -0
- package/dist/newsletter.d.ts +4 -4
- package/dist/orders.d.ts +246 -12
- package/dist/orders.js +140 -7
- package/dist/organization-hooks.d.ts +99 -0
- package/dist/organization-hooks.js +22 -0
- package/dist/organization-registry-lookup.d.ts +362 -0
- package/dist/organization-registry-lookup.js +196 -0
- package/dist/organization-roles.d.ts +341 -0
- package/dist/organization-roles.js +218 -0
- package/dist/organizations.d.ts +1074 -103
- package/dist/organizations.js +293 -28
- package/dist/page-builder-props.d.ts +56 -56
- package/dist/pim-connector.d.ts +7 -3
- package/dist/pim-connector.js +6 -2
- package/dist/pim-field-path.d.ts +5 -1
- package/dist/pim-field-path.js +37 -81
- package/dist/pim-locale-mapping.d.ts +131 -0
- package/dist/pim-locale-mapping.js +193 -0
- package/dist/price-books.d.ts +215 -63
- package/dist/price-books.js +47 -2
- package/dist/price-lists.d.ts +13 -10
- package/dist/product-feeds.d.ts +249 -100
- package/dist/product-feeds.js +46 -2
- package/dist/product-scope-model.d.ts +161 -0
- package/dist/product-scope-model.js +161 -0
- package/dist/product-scope-overrides.d.ts +0 -103
- package/dist/product-scope-overrides.js +0 -54
- package/dist/product-scoped-values.d.ts +2610 -0
- package/dist/product-scoped-values.js +425 -0
- package/dist/product-scopes.d.ts +199 -64
- package/dist/product-scopes.js +120 -23
- package/dist/product-tax-rates.d.ts +38 -0
- package/dist/product-tax-rates.js +45 -0
- package/dist/product-url-keys.d.ts +51 -45
- package/dist/product-url-keys.js +73 -39
- package/dist/product-value-resolver.d.ts +37 -60
- package/dist/product-value-resolver.js +36 -96
- package/dist/projects.d.ts +76 -28
- package/dist/projects.js +53 -9
- package/dist/promotions.d.ts +163 -11
- package/dist/promotions.js +23 -1
- package/dist/pwa.d.ts +41 -2
- package/dist/quick-order.d.ts +159 -9
- package/dist/quick-order.js +79 -4
- package/dist/quote-requests.d.ts +231 -17
- package/dist/quote-requests.js +111 -9
- package/dist/record-references.d.ts +15 -15
- package/dist/record-references.js +2 -3
- package/dist/record-rich-text.js +2 -1
- package/dist/returns.d.ts +214 -52
- package/dist/returns.js +143 -28
- package/dist/sales-channels.d.ts +34 -3
- package/dist/sales-channels.js +16 -1
- package/dist/saved-list-views.d.ts +28 -0
- package/dist/saved-list-views.js +14 -1
- package/dist/schema-extensions.d.ts +36 -0
- package/dist/schema-extensions.js +29 -0
- package/dist/scoped-write-encoding.d.ts +100 -0
- package/dist/scoped-write-encoding.js +135 -0
- package/dist/search.d.ts +18 -16
- package/dist/seo.d.ts +83 -30
- package/dist/seo.js +8 -1
- package/dist/settings.d.ts +173 -2
- package/dist/settings.js +53 -2
- package/dist/shopping-lists.d.ts +63 -4
- package/dist/shopping-lists.js +57 -3
- package/dist/storefront-cache-tags.d.ts +22 -0
- package/dist/storefront-cache-tags.js +12 -0
- package/dist/storefront-value-overrides.d.ts +18 -56
- package/dist/storefront-value-overrides.js +11 -86
- package/dist/tasks.d.ts +27 -27
- package/dist/taxes.d.ts +27 -0
- package/dist/taxes.js +4 -0
- package/dist/transactional-emails.d.ts +48 -22
- package/dist/webhooks.d.ts +75 -0
- package/dist/webhooks.js +24 -0
- package/package.json +5 -3
- package/dist/actor.d.ts.map +0 -1
- package/dist/actor.js.map +0 -1
- package/dist/addresses.d.ts.map +0 -1
- package/dist/addresses.js.map +0 -1
- package/dist/admin-actions.d.ts.map +0 -1
- package/dist/admin-actions.js.map +0 -1
- package/dist/admin-contributions.d.ts.map +0 -1
- package/dist/admin-contributions.js.map +0 -1
- package/dist/admin-feedback.d.ts.map +0 -1
- package/dist/admin-feedback.js.map +0 -1
- package/dist/admin-i18n.d.ts.map +0 -1
- package/dist/admin-i18n.js.map +0 -1
- package/dist/admin-name.d.ts.map +0 -1
- package/dist/admin-name.js.map +0 -1
- package/dist/admin-notifications.d.ts.map +0 -1
- package/dist/admin-notifications.js.map +0 -1
- package/dist/admin-preferences.d.ts.map +0 -1
- package/dist/admin-preferences.js.map +0 -1
- package/dist/admin-roles.d.ts.map +0 -1
- package/dist/admin-roles.js.map +0 -1
- package/dist/admin-search.d.ts.map +0 -1
- package/dist/admin-search.js.map +0 -1
- package/dist/admin-users.d.ts.map +0 -1
- package/dist/admin-users.js.map +0 -1
- package/dist/admin.d.ts.map +0 -1
- package/dist/admin.js.map +0 -1
- package/dist/analytics.d.ts.map +0 -1
- package/dist/analytics.js.map +0 -1
- package/dist/api-keys.d.ts.map +0 -1
- package/dist/api-keys.js.map +0 -1
- package/dist/assets-library.d.ts.map +0 -1
- package/dist/assets-library.js.map +0 -1
- package/dist/audit-logs.d.ts.map +0 -1
- package/dist/audit-logs.js.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/blog.d.ts.map +0 -1
- package/dist/blog.js.map +0 -1
- package/dist/capabilities.d.ts.map +0 -1
- package/dist/capabilities.js.map +0 -1
- package/dist/carts.d.ts.map +0 -1
- package/dist/carts.js.map +0 -1
- package/dist/catalog.d.ts.map +0 -1
- package/dist/catalog.js.map +0 -1
- package/dist/cms-brand.d.ts.map +0 -1
- package/dist/cms-brand.js.map +0 -1
- package/dist/cms-contact-form.d.ts.map +0 -1
- package/dist/cms-contact-form.js.map +0 -1
- package/dist/cms.d.ts.map +0 -1
- package/dist/cms.js.map +0 -1
- package/dist/common.d.ts.map +0 -1
- package/dist/common.js.map +0 -1
- package/dist/comparisons.d.ts.map +0 -1
- package/dist/comparisons.js.map +0 -1
- package/dist/credentials.d.ts.map +0 -1
- package/dist/credentials.js.map +0 -1
- package/dist/credit-limits.d.ts.map +0 -1
- package/dist/credit-limits.js.map +0 -1
- package/dist/crm-rich-text.d.ts.map +0 -1
- package/dist/crm-rich-text.js.map +0 -1
- package/dist/crm.d.ts.map +0 -1
- package/dist/crm.js.map +0 -1
- package/dist/currencies.d.ts.map +0 -1
- package/dist/currencies.js.map +0 -1
- package/dist/custom-fields.d.ts.map +0 -1
- package/dist/custom-fields.js.map +0 -1
- package/dist/customer-accounts.d.ts.map +0 -1
- package/dist/customer-accounts.js.map +0 -1
- package/dist/customers.d.ts.map +0 -1
- package/dist/customers.js.map +0 -1
- package/dist/dictionary.d.ts.map +0 -1
- package/dist/dictionary.js.map +0 -1
- package/dist/document-templates.d.ts.map +0 -1
- package/dist/document-templates.js.map +0 -1
- package/dist/document-values.d.ts.map +0 -1
- package/dist/document-values.js.map +0 -1
- package/dist/email-address.d.ts.map +0 -1
- package/dist/email-address.js.map +0 -1
- package/dist/email.d.ts.map +0 -1
- package/dist/email.js.map +0 -1
- package/dist/envelopes.d.ts.map +0 -1
- package/dist/envelopes.js.map +0 -1
- package/dist/environment-inputs.d.ts.map +0 -1
- package/dist/environment-inputs.js.map +0 -1
- package/dist/erp-connector.d.ts.map +0 -1
- package/dist/erp-connector.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/google-analytics.d.ts.map +0 -1
- package/dist/google-analytics.js.map +0 -1
- package/dist/google-tag-manager.d.ts.map +0 -1
- package/dist/google-tag-manager.js.map +0 -1
- package/dist/i18n.d.ts.map +0 -1
- package/dist/i18n.js.map +0 -1
- package/dist/import-export.d.ts.map +0 -1
- package/dist/import-export.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inventory.d.ts.map +0 -1
- package/dist/inventory.js.map +0 -1
- package/dist/invoice-ledger.d.ts.map +0 -1
- package/dist/invoice-ledger.js.map +0 -1
- package/dist/invoices.d.ts.map +0 -1
- package/dist/invoices.js.map +0 -1
- package/dist/kernel.d.ts.map +0 -1
- package/dist/kernel.js.map +0 -1
- package/dist/languages.d.ts.map +0 -1
- package/dist/languages.js.map +0 -1
- package/dist/line-groups.d.ts.map +0 -1
- package/dist/line-groups.js.map +0 -1
- package/dist/linkedin-ads.d.ts.map +0 -1
- package/dist/linkedin-ads.js.map +0 -1
- package/dist/localized-name.d.ts.map +0 -1
- package/dist/localized-name.js.map +0 -1
- package/dist/megamenu.d.ts.map +0 -1
- package/dist/megamenu.js.map +0 -1
- package/dist/meta-ads.d.ts.map +0 -1
- package/dist/meta-ads.js.map +0 -1
- package/dist/mfa.d.ts.map +0 -1
- package/dist/mfa.js.map +0 -1
- package/dist/modules.d.ts.map +0 -1
- package/dist/modules.js.map +0 -1
- package/dist/money-decimal.d.ts.map +0 -1
- package/dist/money-decimal.js.map +0 -1
- package/dist/money-input.d.ts.map +0 -1
- package/dist/money-input.js.map +0 -1
- package/dist/newsletter.d.ts.map +0 -1
- package/dist/newsletter.js.map +0 -1
- package/dist/order-minimums.d.ts.map +0 -1
- package/dist/order-minimums.js.map +0 -1
- package/dist/orders.d.ts.map +0 -1
- package/dist/orders.js.map +0 -1
- package/dist/organizations.d.ts.map +0 -1
- package/dist/organizations.js.map +0 -1
- package/dist/page-builder-props.d.ts.map +0 -1
- package/dist/page-builder-props.js.map +0 -1
- package/dist/page-builder-values.d.ts.map +0 -1
- package/dist/page-builder-values.js.map +0 -1
- package/dist/pagination.d.ts.map +0 -1
- package/dist/pagination.js.map +0 -1
- package/dist/payment-methods.d.ts.map +0 -1
- package/dist/payment-methods.js.map +0 -1
- package/dist/payment-return-url.d.ts.map +0 -1
- package/dist/payment-return-url.js.map +0 -1
- package/dist/payments.d.ts.map +0 -1
- package/dist/payments.js.map +0 -1
- package/dist/pim-connector.d.ts.map +0 -1
- package/dist/pim-connector.js.map +0 -1
- package/dist/pim-field-path.d.ts.map +0 -1
- package/dist/pim-field-path.js.map +0 -1
- package/dist/platform-info.d.ts.map +0 -1
- package/dist/platform-info.js.map +0 -1
- package/dist/platform-language.d.ts.map +0 -1
- package/dist/platform-language.js.map +0 -1
- package/dist/price-book-decimal.d.ts.map +0 -1
- package/dist/price-book-decimal.js.map +0 -1
- package/dist/price-books.d.ts.map +0 -1
- package/dist/price-books.js.map +0 -1
- package/dist/price-lists.d.ts.map +0 -1
- package/dist/price-lists.js.map +0 -1
- package/dist/product-feeds.d.ts.map +0 -1
- package/dist/product-feeds.js.map +0 -1
- package/dist/product-scope-overrides.d.ts.map +0 -1
- package/dist/product-scope-overrides.js.map +0 -1
- package/dist/product-scopes.d.ts.map +0 -1
- package/dist/product-scopes.js.map +0 -1
- package/dist/product-summary-text.d.ts.map +0 -1
- package/dist/product-summary-text.js.map +0 -1
- package/dist/product-url-keys.d.ts.map +0 -1
- package/dist/product-url-keys.js.map +0 -1
- package/dist/product-value-resolver.d.ts.map +0 -1
- package/dist/product-value-resolver.js.map +0 -1
- package/dist/projects.d.ts.map +0 -1
- package/dist/projects.js.map +0 -1
- package/dist/promotions.d.ts.map +0 -1
- package/dist/promotions.js.map +0 -1
- package/dist/prompt-actions.d.ts.map +0 -1
- package/dist/prompt-actions.js.map +0 -1
- package/dist/pwa.d.ts.map +0 -1
- package/dist/pwa.js.map +0 -1
- package/dist/quick-order.d.ts.map +0 -1
- package/dist/quick-order.js.map +0 -1
- package/dist/quote-requests.d.ts.map +0 -1
- package/dist/quote-requests.js.map +0 -1
- package/dist/record-references.d.ts.map +0 -1
- package/dist/record-references.js.map +0 -1
- package/dist/record-rich-text.d.ts.map +0 -1
- package/dist/record-rich-text.js.map +0 -1
- package/dist/returns.d.ts.map +0 -1
- package/dist/returns.js.map +0 -1
- package/dist/sales-channels.d.ts.map +0 -1
- package/dist/sales-channels.js.map +0 -1
- package/dist/saved-list-views.d.ts.map +0 -1
- package/dist/saved-list-views.js.map +0 -1
- package/dist/scope-notice.d.ts.map +0 -1
- package/dist/scope-notice.js.map +0 -1
- package/dist/scoped-translations.d.ts +0 -48
- package/dist/scoped-translations.d.ts.map +0 -1
- package/dist/scoped-translations.js +0 -78
- package/dist/scoped-translations.js.map +0 -1
- package/dist/search.d.ts.map +0 -1
- package/dist/search.js.map +0 -1
- package/dist/seo.d.ts.map +0 -1
- package/dist/seo.js.map +0 -1
- package/dist/settings.d.ts.map +0 -1
- package/dist/settings.js.map +0 -1
- package/dist/shipments.d.ts.map +0 -1
- package/dist/shipments.js.map +0 -1
- package/dist/shipping-methods.d.ts.map +0 -1
- package/dist/shipping-methods.js.map +0 -1
- package/dist/shopping-lists.d.ts.map +0 -1
- package/dist/shopping-lists.js.map +0 -1
- package/dist/storefront-cache-tags.d.ts.map +0 -1
- package/dist/storefront-cache-tags.js.map +0 -1
- package/dist/storefront-language-path.d.ts.map +0 -1
- package/dist/storefront-language-path.js.map +0 -1
- package/dist/storefront-value-overrides.d.ts.map +0 -1
- package/dist/storefront-value-overrides.js.map +0 -1
- package/dist/tasks.d.ts.map +0 -1
- package/dist/tasks.js.map +0 -1
- package/dist/taxes.d.ts.map +0 -1
- package/dist/taxes.js.map +0 -1
- package/dist/text-normalization.d.ts.map +0 -1
- package/dist/text-normalization.js.map +0 -1
- package/dist/transactional-emails.d.ts.map +0 -1
- package/dist/transactional-emails.js.map +0 -1
- package/dist/webhooks.d.ts.map +0 -1
- package/dist/webhooks.js.map +0 -1
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
// Command hooks — `specs/176-command-hooks-outbox/` P2 (US2),
|
|
2
|
+
// `contracts/command-hooks-api.md` §1.
|
|
3
|
+
//
|
|
4
|
+
// The platform-free half of the command-hook API: the typed reference an owner
|
|
5
|
+
// publishes for each Command action it opens to hooks, the manifest
|
|
6
|
+
// declaration derived from it, and the error codes the platform answers a
|
|
7
|
+
// misuse with. The platform half — `ctx.commandHooks`, the bus dispatch, the
|
|
8
|
+
// hook context — is `@endora-commerce/platform/commands` and `./kernel`.
|
|
9
|
+
//
|
|
10
|
+
// One constant serves both readers (FR-010): the owner lists the ref in its
|
|
11
|
+
// manifest through `toHookableActionDeclaration`, and a hook author imports the
|
|
12
|
+
// same ref so the hook's `data` is typed by the owner's declaration.
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
export const COMMAND_HOOK_PHASES = ['beforeCommit', 'afterCommit'];
|
|
15
|
+
/**
|
|
16
|
+
* The longest string an outbox value may be. Long enough for a UUID, an ISO
|
|
17
|
+
* timestamp, a dictionary code and a dotted field name
|
|
18
|
+
* (`extensions.<moduleId>.changedFields`); short of anything a sentence needs.
|
|
19
|
+
*/
|
|
20
|
+
export const OUTBOX_STRING_MAX_LENGTH = 128;
|
|
21
|
+
/**
|
|
22
|
+
* Printable ASCII without a space and without `@`: what an id, a code, a date
|
|
23
|
+
* and a field name are made of. `@` is refused because an e-mail address is the
|
|
24
|
+
* one personal datum that otherwise has a code's shape.
|
|
25
|
+
*/
|
|
26
|
+
const OUTBOX_STRING_RE = /^[\x21-\x3f\x41-\x7e]*$/;
|
|
27
|
+
function scalarIssue(value) {
|
|
28
|
+
if (value === null || typeof value === 'boolean')
|
|
29
|
+
return null;
|
|
30
|
+
if (typeof value === 'number')
|
|
31
|
+
return Number.isFinite(value) ? null : 'not-finite';
|
|
32
|
+
if (typeof value === 'string') {
|
|
33
|
+
if (value.length > OUTBOX_STRING_MAX_LENGTH)
|
|
34
|
+
return 'too-long';
|
|
35
|
+
return OUTBOX_STRING_RE.test(value) ? null : 'not-code-shaped';
|
|
36
|
+
}
|
|
37
|
+
if (typeof value === 'object')
|
|
38
|
+
return 'nested';
|
|
39
|
+
return 'not-a-scalar';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The keys of `data` that an outbox row may not store (FR-031): a nested
|
|
43
|
+
* object, a string longer than {@link OUTBOX_STRING_MAX_LENGTH} or with
|
|
44
|
+
* whitespace or an `@` in it, a non-finite number, anything that is not a scalar. An
|
|
45
|
+
* array is allowed when every member is. Sorted by key, and the value is never
|
|
46
|
+
* repeated: the answer is what an error message may print.
|
|
47
|
+
*
|
|
48
|
+
* A **structural** guard — it cannot tell a one-word name from a code, and the
|
|
49
|
+
* owner's `outboxData` remains the place list 1 is decided. What it refuses is
|
|
50
|
+
* the shape free text, an address or a snapshot has, so the common mistake
|
|
51
|
+
* fails the Command (and the owner's `expectHookableCommand`) instead of
|
|
52
|
+
* landing in a platform-global table.
|
|
53
|
+
*/
|
|
54
|
+
export function outboxDataViolations(data) {
|
|
55
|
+
const violations = [];
|
|
56
|
+
for (const key of Object.keys(data).sort()) {
|
|
57
|
+
const value = data[key];
|
|
58
|
+
const issue = Array.isArray(value)
|
|
59
|
+
? (value.map(scalarIssue).find((found) => found !== null) ?? null)
|
|
60
|
+
: scalarIssue(value);
|
|
61
|
+
if (issue !== null)
|
|
62
|
+
violations.push({ key, issue });
|
|
63
|
+
}
|
|
64
|
+
return violations;
|
|
65
|
+
}
|
|
66
|
+
/** A Command action: dot-separated lower-case segments, at least two. */
|
|
67
|
+
export const hookableActionRe = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/;
|
|
68
|
+
const objectTypeRe = /^[a-z][a-z0-9_]*$/;
|
|
69
|
+
/**
|
|
70
|
+
* Declare a hookable action. The owner calls this once per action, in
|
|
71
|
+
* `@endora-commerce/contracts`, and exports the result.
|
|
72
|
+
*
|
|
73
|
+
* Refuses a malformed action or object type, and an empty or repeated phase
|
|
74
|
+
* list, at module load — a ref is a public contract and is never built at run
|
|
75
|
+
* time from data.
|
|
76
|
+
*/
|
|
77
|
+
export function hookableAction(action, objectType, phases) {
|
|
78
|
+
const parsed = HookableActionDeclarationSchema.parse({ action, objectType, phases: [...phases] });
|
|
79
|
+
return Object.freeze({
|
|
80
|
+
action: parsed.action,
|
|
81
|
+
objectType: parsed.objectType,
|
|
82
|
+
phases: Object.freeze([...parsed.phases]),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/** The manifest entry for one hookable action, derived from its ref. */
|
|
86
|
+
export const HookableActionDeclarationSchema = z
|
|
87
|
+
.object({
|
|
88
|
+
action: z.string().regex(hookableActionRe),
|
|
89
|
+
objectType: z.string().regex(objectTypeRe),
|
|
90
|
+
phases: z.array(z.enum(COMMAND_HOOK_PHASES)).min(1),
|
|
91
|
+
})
|
|
92
|
+
.strict()
|
|
93
|
+
.superRefine((value, ctx) => {
|
|
94
|
+
if (new Set(value.phases).size !== value.phases.length) {
|
|
95
|
+
ctx.addIssue({
|
|
96
|
+
code: 'custom',
|
|
97
|
+
path: ['phases'],
|
|
98
|
+
message: `hookable action "${value.action}" lists a phase twice`,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
/** What an owner writes in its manifest's `hookableActions`. */
|
|
103
|
+
export function toHookableActionDeclaration(ref) {
|
|
104
|
+
return { action: ref.action, objectType: ref.objectType, phases: [...ref.phases] };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The codes the platform answers a command-hook misuse with. Owned by the
|
|
108
|
+
* platform vocabulary (`_i18n`, translated pl + en under `errors.<CODE>`).
|
|
109
|
+
*
|
|
110
|
+
* - `COMMAND_EXTENSION_UNCLAIMED` (422) — a Command's `extensions` carries a
|
|
111
|
+
* key no present hook module on that action claims; refused before any
|
|
112
|
+
* write, `details: [{ path: 'extensions.<key>', issue }]` (FR-019).
|
|
113
|
+
* - `COMMAND_HOOK_CYCLE` (500) — a hookable action reappears in its own
|
|
114
|
+
* ancestor chain, or hook-induced nesting passed its bound (FR-022).
|
|
115
|
+
* - `COMMAND_HOOK_DATA_MISSING` (500) — a Command declared hookable did not
|
|
116
|
+
* supply its hook data (FR-023).
|
|
117
|
+
*/
|
|
118
|
+
export const COMMAND_HOOK_ERROR_CODES = {
|
|
119
|
+
EXTENSION_UNCLAIMED: 'COMMAND_EXTENSION_UNCLAIMED',
|
|
120
|
+
CYCLE: 'COMMAND_HOOK_CYCLE',
|
|
121
|
+
DATA_MISSING: 'COMMAND_HOOK_DATA_MISSING',
|
|
122
|
+
};
|
|
123
|
+
/** How deep hook-induced Command nesting may go: the ninth Command in one chain is refused. */
|
|
124
|
+
export const COMMAND_HOOK_MAX_DEPTH = 8;
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
// The read-only execution plan (`GET /api/v1/admin/command-hooks`, FR-026/FR-040)
|
|
127
|
+
// ---------------------------------------------------------------------------
|
|
128
|
+
/**
|
|
129
|
+
* One registered hook. A `beforeCommit` hook carries its position in its
|
|
130
|
+
* action's execution order; an `afterCommit` handler carries `null`, because
|
|
131
|
+
* each one is an outbox row of its own and the outbox promises no order across
|
|
132
|
+
* rows (`contracts/outbox-and-admin-api.md`, amendment 3). Handlers are listed
|
|
133
|
+
* by module id, then registration order — for a stable screen, not a sequence.
|
|
134
|
+
*/
|
|
135
|
+
export const CommandHookPlanItemSchema = z.object({
|
|
136
|
+
action: z.string(),
|
|
137
|
+
phase: z.enum(COMMAND_HOOK_PHASES),
|
|
138
|
+
/** 1-based position within the action's `beforeCommit` hooks; `null` for an `afterCommit` handler. */
|
|
139
|
+
position: z.number().int().positive().nullable(),
|
|
140
|
+
module: z.string(),
|
|
141
|
+
id: z.string(),
|
|
142
|
+
/** Whether the hook's module is present on the effective state right now. */
|
|
143
|
+
moduleEnabled: z.boolean(),
|
|
144
|
+
});
|
|
145
|
+
/** One action some module declares hookable, whether or not anything hooks it. */
|
|
146
|
+
export const CommandHookPlanActionSchema = z.object({
|
|
147
|
+
action: z.string(),
|
|
148
|
+
objectType: z.string(),
|
|
149
|
+
owner: z.string(),
|
|
150
|
+
phases: z.array(z.enum(COMMAND_HOOK_PHASES)),
|
|
151
|
+
});
|
|
152
|
+
export const CommandHookPlanResponseSchema = z.object({
|
|
153
|
+
actions: z.array(CommandHookPlanActionSchema),
|
|
154
|
+
items: z.array(CommandHookPlanItemSchema),
|
|
155
|
+
});
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
// The command outbox operator API (`specs/176-command-hooks-outbox/` P4, FR-040)
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
/** Where an outbox row is in its delivery (`data-model.md` §4). */
|
|
160
|
+
export const COMMAND_OUTBOX_STATUSES = ['pending', 'in_flight', 'delivered', 'dead'];
|
|
161
|
+
export const CommandOutboxStatusSchema = z.enum(COMMAND_OUTBOX_STATUSES);
|
|
162
|
+
/**
|
|
163
|
+
* The statuses an operator lists. A delivered row needs nobody's attention and
|
|
164
|
+
* is purged after seven days, so the list does not offer it.
|
|
165
|
+
*/
|
|
166
|
+
export const COMMAND_OUTBOX_LISTED_STATUSES = ['dead', 'pending', 'in_flight'];
|
|
167
|
+
/** The largest page `GET /api/v1/admin/command-outbox` serves. */
|
|
168
|
+
export const COMMAND_OUTBOX_PAGE_MAX = 100;
|
|
169
|
+
/**
|
|
170
|
+
* `GET /api/v1/admin/command-outbox` — filtered by status (dead rows by
|
|
171
|
+
* default: they are the ones an operator acts on), keyset-paginated by the
|
|
172
|
+
* row's `sequence`, newest first. `cursor` is the previous page's
|
|
173
|
+
* `nextCursor`, opaque to the client.
|
|
174
|
+
*/
|
|
175
|
+
export const CommandOutboxListQuerySchema = z.object({
|
|
176
|
+
status: z.enum(COMMAND_OUTBOX_LISTED_STATUSES).default('dead'),
|
|
177
|
+
limit: z.coerce.number().int().min(1).max(COMMAND_OUTBOX_PAGE_MAX).default(50),
|
|
178
|
+
cursor: z
|
|
179
|
+
.string()
|
|
180
|
+
.regex(/^[1-9][0-9]{0,18}$/)
|
|
181
|
+
.optional(),
|
|
182
|
+
});
|
|
183
|
+
/**
|
|
184
|
+
* One outbox row as an operator sees it: names, ids, codes, counts and dates
|
|
185
|
+
* only. The row's `data` is **never** served, and neither is anything a
|
|
186
|
+
* failure said — only its code and the error's class are stored — so this list
|
|
187
|
+
* shows nothing the audit log would not (FR-040).
|
|
188
|
+
*
|
|
189
|
+
* `lastErrorCode` is the raw stored string; the screen translates it when the
|
|
190
|
+
* hook module or the platform has a sentence for it, and shows it as it is
|
|
191
|
+
* otherwise.
|
|
192
|
+
*/
|
|
193
|
+
export const CommandOutboxListItemSchema = z.object({
|
|
194
|
+
id: z.string().uuid(),
|
|
195
|
+
action: z.string(),
|
|
196
|
+
objectType: z.string(),
|
|
197
|
+
objectId: z.string(),
|
|
198
|
+
organizationId: z.string().uuid().nullable(),
|
|
199
|
+
hookModule: z.string(),
|
|
200
|
+
hookId: z.string(),
|
|
201
|
+
status: CommandOutboxStatusSchema,
|
|
202
|
+
attempts: z.number().int().nonnegative(),
|
|
203
|
+
lastErrorCode: z.string().nullable(),
|
|
204
|
+
lastErrorClass: z.string().nullable(),
|
|
205
|
+
createdAt: z.string(),
|
|
206
|
+
availableAt: z.string(),
|
|
207
|
+
deadAt: z.string().nullable(),
|
|
208
|
+
});
|
|
209
|
+
/** One page; `nextCursor` is `null` on the last. */
|
|
210
|
+
export const CommandOutboxListResponseSchema = z.object({
|
|
211
|
+
items: z.array(CommandOutboxListItemSchema),
|
|
212
|
+
nextCursor: z.string().nullable(),
|
|
213
|
+
});
|
|
214
|
+
/**
|
|
215
|
+
* `POST /api/v1/admin/command-outbox/:id/retry` — the path parameter. Any
|
|
216
|
+
* string, on purpose: a value that is not a uuid names no row, so the route
|
|
217
|
+
* answers it with the same `404` as an unknown id (issue #781, owner ruling of
|
|
218
|
+
* 2026-11-05), where a uuid params schema would answer `400` (issue #1269).
|
|
219
|
+
*/
|
|
220
|
+
export const CommandOutboxRetryParamsSchema = z.object({ id: z.string() });
|
|
221
|
+
/** `POST /api/v1/admin/command-outbox/:id/retry` — the row, now pending. */
|
|
222
|
+
export const CommandOutboxRetryResponseSchema = z.object({ item: CommandOutboxListItemSchema });
|
|
223
|
+
/**
|
|
224
|
+
* The failure codes the platform's own drain stores in `last_error_code`
|
|
225
|
+
* (`contracts/outbox-and-admin-api.md`, amendment 4). Lower-kebab, because
|
|
226
|
+
* they are delivery outcomes and not HTTP error codes; translated by the
|
|
227
|
+
* platform vocabulary under {@link commandOutboxFailureKey}.
|
|
228
|
+
*/
|
|
229
|
+
export const COMMAND_OUTBOX_FAILURE_CODES = {
|
|
230
|
+
HOOK_UNREGISTERED: 'hook-unregistered',
|
|
231
|
+
PERMANENT_FAILURE: 'permanent-failure',
|
|
232
|
+
HANDLER_FAILED: 'handler-failed',
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* The bundle key a stored failure code may be translated under, besides
|
|
236
|
+
* `errors.<CODE>`: `commandOutbox.failure.<code>`, the code verbatim.
|
|
237
|
+
*
|
|
238
|
+
* Two families because a stored code has two shapes. An `HttpError`'s code is
|
|
239
|
+
* SCREAMING_SNAKE and already has its `errors.<CODE>` sentence wherever it is
|
|
240
|
+
* declared; a `PermanentOutboxFailure` code may be any code-shaped string
|
|
241
|
+
* (`acme-erp-rejected`), which `errors.*` cannot hold — that family is read by
|
|
242
|
+
* the error envelope and refuses any other key grammar
|
|
243
|
+
* (`check-error-translations`, `malformed-key`).
|
|
244
|
+
*/
|
|
245
|
+
export function commandOutboxFailureKey(code) {
|
|
246
|
+
return `commandOutbox.failure.${code}`;
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=command-hooks.js.map
|
package/dist/common.d.ts
CHANGED
|
@@ -7,6 +7,29 @@ export declare const isoDateTimeSchema: z.ZodString;
|
|
|
7
7
|
export type IsoDateTime = z.infer<typeof isoDateTimeSchema>;
|
|
8
8
|
export declare const uuidSchema: z.ZodString;
|
|
9
9
|
export type Uuid = z.infer<typeof uuidSchema>;
|
|
10
|
+
/**
|
|
11
|
+
* The one spelling of a `uuid`'s shape as a regular-expression source,
|
|
12
|
+
* unanchored and matching either case without a flag, for a pattern that has
|
|
13
|
+
* to find a uuid *inside* a longer value — an asset address, a `kind:id` token
|
|
14
|
+
* (issue #781). A value that is a uuid on its own is checked with
|
|
15
|
+
* {@link isUuidShape}, not with this.
|
|
16
|
+
*/
|
|
17
|
+
export declare const UUID_SHAPE_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
|
|
18
|
+
/**
|
|
19
|
+
* A value with the shape of a PostgreSQL `uuid`: 8-4-4-4-12 hexadecimal digits,
|
|
20
|
+
* either case. Shape only — deliberately looser than `uuidSchema`, which checks
|
|
21
|
+
* RFC 9562's version and variant bits that PostgreSQL does not, and that
|
|
22
|
+
* hand-written seed ids do not always honour.
|
|
23
|
+
*
|
|
24
|
+
* A route keyed by a `uuid` column checks its path parameter against this
|
|
25
|
+
* before the database sees it (issue #753): PostgreSQL answers any other value
|
|
26
|
+
* with `invalid input syntax for type uuid`, a 500. A value of another shape
|
|
27
|
+
* names no record, so the route answers its own not-found, as it does for a
|
|
28
|
+
* well-formed id that names nothing.
|
|
29
|
+
*/
|
|
30
|
+
export declare const uuidShapeSchema: z.ZodString;
|
|
31
|
+
/** Whether `value` has the shape of a PostgreSQL `uuid` — see `uuidShapeSchema`. */
|
|
32
|
+
export declare function isUuidShape(value: string): boolean;
|
|
10
33
|
/** Whether `YYYY-MM-DD` names a day the calendar has: `2026-02-31` and `2026-13-01` do not. */
|
|
11
34
|
export declare function isCalendarDate(value: string): boolean;
|
|
12
35
|
/** A calendar date as `YYYY-MM-DD`, refusing a day the calendar does not have. */
|
|
@@ -70,12 +93,6 @@ export declare const paymentStatusSchema: z.ZodEnum<{
|
|
|
70
93
|
refunded: "refunded";
|
|
71
94
|
}>;
|
|
72
95
|
export type PaymentStatus = z.infer<typeof paymentStatusSchema>;
|
|
73
|
-
/** Roles within a Customer Organization (FR-042). */
|
|
74
|
-
export declare const organizationRoleSchema: z.ZodEnum<{
|
|
75
|
-
organization_admin: "organization_admin";
|
|
76
|
-
regular_user: "regular_user";
|
|
77
|
-
}>;
|
|
78
|
-
export type OrganizationRole = z.infer<typeof organizationRoleSchema>;
|
|
79
96
|
/** Supported Sales Channel visibility modes (R-18 + FR-106). */
|
|
80
97
|
export declare const productVisibilitySchema: z.ZodEnum<{
|
|
81
98
|
public: "public";
|
package/dist/common.js
CHANGED
|
@@ -8,6 +8,31 @@ export const isoDateTimeSchema = z
|
|
|
8
8
|
.datetime({ offset: true })
|
|
9
9
|
.describe('ISO-8601 datetime with offset, e.g. 2026-04-23T10:15:30.000Z');
|
|
10
10
|
export const uuidSchema = z.string().uuid();
|
|
11
|
+
/**
|
|
12
|
+
* The one spelling of a `uuid`'s shape as a regular-expression source,
|
|
13
|
+
* unanchored and matching either case without a flag, for a pattern that has
|
|
14
|
+
* to find a uuid *inside* a longer value — an asset address, a `kind:id` token
|
|
15
|
+
* (issue #781). A value that is a uuid on its own is checked with
|
|
16
|
+
* {@link isUuidShape}, not with this.
|
|
17
|
+
*/
|
|
18
|
+
export const UUID_SHAPE_PATTERN = '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
|
|
19
|
+
/**
|
|
20
|
+
* A value with the shape of a PostgreSQL `uuid`: 8-4-4-4-12 hexadecimal digits,
|
|
21
|
+
* either case. Shape only — deliberately looser than `uuidSchema`, which checks
|
|
22
|
+
* RFC 9562's version and variant bits that PostgreSQL does not, and that
|
|
23
|
+
* hand-written seed ids do not always honour.
|
|
24
|
+
*
|
|
25
|
+
* A route keyed by a `uuid` column checks its path parameter against this
|
|
26
|
+
* before the database sees it (issue #753): PostgreSQL answers any other value
|
|
27
|
+
* with `invalid input syntax for type uuid`, a 500. A value of another shape
|
|
28
|
+
* names no record, so the route answers its own not-found, as it does for a
|
|
29
|
+
* well-formed id that names nothing.
|
|
30
|
+
*/
|
|
31
|
+
export const uuidShapeSchema = z.string().regex(new RegExp(`^${UUID_SHAPE_PATTERN}$`), 'Not a UUID');
|
|
32
|
+
/** Whether `value` has the shape of a PostgreSQL `uuid` — see `uuidShapeSchema`. */
|
|
33
|
+
export function isUuidShape(value) {
|
|
34
|
+
return uuidShapeSchema.safeParse(value).success;
|
|
35
|
+
}
|
|
11
36
|
/** Whether `YYYY-MM-DD` names a day the calendar has: `2026-02-31` and `2026-13-01` do not. */
|
|
12
37
|
export function isCalendarDate(value) {
|
|
13
38
|
const [year = 0, month = 0, day = 0] = value.split('-').map(Number);
|
|
@@ -84,8 +109,6 @@ export const orderStatusSchema = z.enum([
|
|
|
84
109
|
]);
|
|
85
110
|
/** Payment lifecycle statuses (FR-014). `failed` added by feature 034 (payment-method adapter framework). */
|
|
86
111
|
export const paymentStatusSchema = z.enum(['awaiting_payment', 'paid', 'failed', 'deferred', 'refunded']);
|
|
87
|
-
/** Roles within a Customer Organization (FR-042). */
|
|
88
|
-
export const organizationRoleSchema = z.enum(['organization_admin', 'regular_user']);
|
|
89
112
|
/** Supported Sales Channel visibility modes (R-18 + FR-106). */
|
|
90
113
|
export const productVisibilitySchema = z.enum(['public', 'logged_in_only', 'organization_restricted']);
|
|
91
114
|
/**
|
package/dist/comparisons.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export type ComparisonRowClass = z.infer<typeof comparisonRowClassSchema>;
|
|
|
23
23
|
export declare const comparisonProductSummarySchema: z.ZodObject<{
|
|
24
24
|
id: z.ZodString;
|
|
25
25
|
sku: z.ZodString;
|
|
26
|
-
name: z.
|
|
26
|
+
name: z.ZodString;
|
|
27
27
|
slug: z.ZodString;
|
|
28
28
|
type: z.ZodEnum<{
|
|
29
29
|
simple: "simple";
|
|
@@ -52,8 +52,9 @@ export declare const comparisonAttributeRowSchema: z.ZodObject<{
|
|
|
52
52
|
date: "date";
|
|
53
53
|
enum: "enum";
|
|
54
54
|
select: "select";
|
|
55
|
-
price: "price";
|
|
56
55
|
multiselect: "multiselect";
|
|
56
|
+
page_builder: "page_builder";
|
|
57
|
+
price: "price";
|
|
57
58
|
}>;
|
|
58
59
|
values: z.ZodArray<z.ZodNullable<z.ZodString>>;
|
|
59
60
|
rowClass: z.ZodEnum<{
|
|
@@ -89,7 +90,7 @@ export declare const comparisonOwnerViewSchema: z.ZodObject<{
|
|
|
89
90
|
products: z.ZodArray<z.ZodObject<{
|
|
90
91
|
id: z.ZodString;
|
|
91
92
|
sku: z.ZodString;
|
|
92
|
-
name: z.
|
|
93
|
+
name: z.ZodString;
|
|
93
94
|
slug: z.ZodString;
|
|
94
95
|
type: z.ZodEnum<{
|
|
95
96
|
simple: "simple";
|
|
@@ -117,8 +118,9 @@ export declare const comparisonOwnerViewSchema: z.ZodObject<{
|
|
|
117
118
|
date: "date";
|
|
118
119
|
enum: "enum";
|
|
119
120
|
select: "select";
|
|
120
|
-
price: "price";
|
|
121
121
|
multiselect: "multiselect";
|
|
122
|
+
page_builder: "page_builder";
|
|
123
|
+
price: "price";
|
|
122
124
|
}>;
|
|
123
125
|
values: z.ZodArray<z.ZodNullable<z.ZodString>>;
|
|
124
126
|
rowClass: z.ZodEnum<{
|
|
@@ -156,7 +158,7 @@ export declare const comparisonDocumentDataSchema: z.ZodObject<{
|
|
|
156
158
|
products: z.ZodArray<z.ZodObject<{
|
|
157
159
|
id: z.ZodString;
|
|
158
160
|
sku: z.ZodString;
|
|
159
|
-
name: z.
|
|
161
|
+
name: z.ZodString;
|
|
160
162
|
slug: z.ZodString;
|
|
161
163
|
type: z.ZodEnum<{
|
|
162
164
|
simple: "simple";
|
|
@@ -184,8 +186,9 @@ export declare const comparisonDocumentDataSchema: z.ZodObject<{
|
|
|
184
186
|
date: "date";
|
|
185
187
|
enum: "enum";
|
|
186
188
|
select: "select";
|
|
187
|
-
price: "price";
|
|
188
189
|
multiselect: "multiselect";
|
|
190
|
+
page_builder: "page_builder";
|
|
191
|
+
price: "price";
|
|
189
192
|
}>;
|
|
190
193
|
values: z.ZodArray<z.ZodNullable<z.ZodString>>;
|
|
191
194
|
rowClass: z.ZodEnum<{
|
|
@@ -222,7 +225,7 @@ export declare const comparisonOwnerResponseSchema: z.ZodObject<{
|
|
|
222
225
|
products: z.ZodArray<z.ZodObject<{
|
|
223
226
|
id: z.ZodString;
|
|
224
227
|
sku: z.ZodString;
|
|
225
|
-
name: z.
|
|
228
|
+
name: z.ZodString;
|
|
226
229
|
slug: z.ZodString;
|
|
227
230
|
type: z.ZodEnum<{
|
|
228
231
|
simple: "simple";
|
|
@@ -250,8 +253,9 @@ export declare const comparisonOwnerResponseSchema: z.ZodObject<{
|
|
|
250
253
|
date: "date";
|
|
251
254
|
enum: "enum";
|
|
252
255
|
select: "select";
|
|
253
|
-
price: "price";
|
|
254
256
|
multiselect: "multiselect";
|
|
257
|
+
page_builder: "page_builder";
|
|
258
|
+
price: "price";
|
|
255
259
|
}>;
|
|
256
260
|
values: z.ZodArray<z.ZodNullable<z.ZodString>>;
|
|
257
261
|
rowClass: z.ZodEnum<{
|
|
@@ -299,7 +303,7 @@ export declare const comparisonSharedViewSchema: z.ZodObject<{
|
|
|
299
303
|
products: z.ZodArray<z.ZodObject<{
|
|
300
304
|
id: z.ZodString;
|
|
301
305
|
sku: z.ZodString;
|
|
302
|
-
name: z.
|
|
306
|
+
name: z.ZodString;
|
|
303
307
|
slug: z.ZodString;
|
|
304
308
|
type: z.ZodEnum<{
|
|
305
309
|
simple: "simple";
|
|
@@ -327,8 +331,9 @@ export declare const comparisonSharedViewSchema: z.ZodObject<{
|
|
|
327
331
|
date: "date";
|
|
328
332
|
enum: "enum";
|
|
329
333
|
select: "select";
|
|
330
|
-
price: "price";
|
|
331
334
|
multiselect: "multiselect";
|
|
335
|
+
page_builder: "page_builder";
|
|
336
|
+
price: "price";
|
|
332
337
|
}>;
|
|
333
338
|
values: z.ZodArray<z.ZodNullable<z.ZodString>>;
|
|
334
339
|
rowClass: z.ZodEnum<{
|
|
@@ -357,7 +362,7 @@ export declare const comparisonSharedResponseSchema: z.ZodObject<{
|
|
|
357
362
|
products: z.ZodArray<z.ZodObject<{
|
|
358
363
|
id: z.ZodString;
|
|
359
364
|
sku: z.ZodString;
|
|
360
|
-
name: z.
|
|
365
|
+
name: z.ZodString;
|
|
361
366
|
slug: z.ZodString;
|
|
362
367
|
type: z.ZodEnum<{
|
|
363
368
|
simple: "simple";
|
|
@@ -385,8 +390,9 @@ export declare const comparisonSharedResponseSchema: z.ZodObject<{
|
|
|
385
390
|
date: "date";
|
|
386
391
|
enum: "enum";
|
|
387
392
|
select: "select";
|
|
388
|
-
price: "price";
|
|
389
393
|
multiselect: "multiselect";
|
|
394
|
+
page_builder: "page_builder";
|
|
395
|
+
price: "price";
|
|
390
396
|
}>;
|
|
391
397
|
values: z.ZodArray<z.ZodNullable<z.ZodString>>;
|
|
392
398
|
rowClass: z.ZodEnum<{
|
|
@@ -523,7 +529,7 @@ export declare const comparisonAdminDetailSchema: z.ZodObject<{
|
|
|
523
529
|
products: z.ZodArray<z.ZodObject<{
|
|
524
530
|
id: z.ZodString;
|
|
525
531
|
sku: z.ZodString;
|
|
526
|
-
name: z.
|
|
532
|
+
name: z.ZodString;
|
|
527
533
|
slug: z.ZodString;
|
|
528
534
|
type: z.ZodEnum<{
|
|
529
535
|
simple: "simple";
|
|
@@ -551,8 +557,9 @@ export declare const comparisonAdminDetailSchema: z.ZodObject<{
|
|
|
551
557
|
date: "date";
|
|
552
558
|
enum: "enum";
|
|
553
559
|
select: "select";
|
|
554
|
-
price: "price";
|
|
555
560
|
multiselect: "multiselect";
|
|
561
|
+
page_builder: "page_builder";
|
|
562
|
+
price: "price";
|
|
556
563
|
}>;
|
|
557
564
|
values: z.ZodArray<z.ZodNullable<z.ZodString>>;
|
|
558
565
|
rowClass: z.ZodEnum<{
|
package/dist/comparisons.js
CHANGED
|
@@ -33,7 +33,8 @@ export const comparisonRowClassSchema = z.enum(['common', 'different']);
|
|
|
33
33
|
export const comparisonProductSummarySchema = z.object({
|
|
34
34
|
id: uuidSchema,
|
|
35
35
|
sku: z.string(),
|
|
36
|
-
name
|
|
36
|
+
/** Feature 174 (`contracts/readers.md` §2) — the name effective at the comparison's (channel, language). */
|
|
37
|
+
name: z.string(),
|
|
37
38
|
slug: z.string(),
|
|
38
39
|
type: z.enum(['simple', 'configurable', 'grouped', 'bundle', 'virtual']),
|
|
39
40
|
/**
|
package/dist/credit-limits.d.ts
CHANGED
|
@@ -16,17 +16,39 @@ export declare const creditLimitReservationReleaseReasonSchema: z.ZodEnum<{
|
|
|
16
16
|
export type CreditLimitReservationReleaseReason = z.infer<typeof creditLimitReservationReleaseReasonSchema>;
|
|
17
17
|
export declare const creditLimitViewSchema: z.ZodObject<{
|
|
18
18
|
organizationId: z.ZodString;
|
|
19
|
+
organizationName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
19
20
|
grantedAmount: z.ZodNumber;
|
|
20
21
|
availableAmount: z.ZodNumber;
|
|
21
22
|
currency: z.ZodString;
|
|
23
|
+
activeReservationCount: z.ZodNumber;
|
|
22
24
|
activeReservations: z.ZodArray<z.ZodObject<{
|
|
23
25
|
orderId: z.ZodString;
|
|
26
|
+
orderBusinessId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
24
27
|
amount: z.ZodNumber;
|
|
25
28
|
createdAt: z.ZodString;
|
|
26
29
|
}, z.core.$strip>>;
|
|
27
30
|
grantedAt: z.ZodString;
|
|
28
31
|
}, z.core.$strip>;
|
|
29
32
|
export type CreditLimitView = z.infer<typeof creditLimitViewSchema>;
|
|
33
|
+
/** `GET /api/v1/admin/credit-limits` — every granted credit limit (issue #599). */
|
|
34
|
+
export declare const creditLimitListResponseSchema: z.ZodObject<{
|
|
35
|
+
data: z.ZodArray<z.ZodObject<{
|
|
36
|
+
organizationId: z.ZodString;
|
|
37
|
+
organizationName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
38
|
+
grantedAmount: z.ZodNumber;
|
|
39
|
+
availableAmount: z.ZodNumber;
|
|
40
|
+
currency: z.ZodString;
|
|
41
|
+
activeReservationCount: z.ZodNumber;
|
|
42
|
+
activeReservations: z.ZodArray<z.ZodObject<{
|
|
43
|
+
orderId: z.ZodString;
|
|
44
|
+
orderBusinessId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
45
|
+
amount: z.ZodNumber;
|
|
46
|
+
createdAt: z.ZodString;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
grantedAt: z.ZodString;
|
|
49
|
+
}, z.core.$strip>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
export type CreditLimitListResponse = z.infer<typeof creditLimitListResponseSchema>;
|
|
30
52
|
export declare const grantCreditLimitRequestSchema: z.ZodObject<{
|
|
31
53
|
grantedAmount: z.ZodNumber;
|
|
32
54
|
currency: z.ZodString;
|
package/dist/credit-limits.js
CHANGED
|
@@ -13,16 +13,51 @@ export const creditLimitReservationReleaseReasonSchema = z.enum([
|
|
|
13
13
|
]);
|
|
14
14
|
export const creditLimitViewSchema = z.object({
|
|
15
15
|
organizationId: uuidSchema,
|
|
16
|
+
/**
|
|
17
|
+
* The organization's name, for the admin roster and detail; `null` when the
|
|
18
|
+
* organization cannot be read, and always `null` on the customer's own
|
|
19
|
+
* `GET /api/v1/me/credit-limit`. Answered since the admin roster shipped and
|
|
20
|
+
* declared here only by issue #599; optional for a client that predates it.
|
|
21
|
+
*/
|
|
22
|
+
organizationName: z.string().nullable().optional(),
|
|
16
23
|
grantedAmount: z.number().finite().nonnegative(),
|
|
17
24
|
availableAmount: z.number().finite(),
|
|
18
25
|
currency: z.string().length(3),
|
|
26
|
+
/**
|
|
27
|
+
* How many reservations the limit holds — **every** one of them, whoever
|
|
28
|
+
* placed the order (issue #748). The limit is shared, so `availableAmount`
|
|
29
|
+
* and this count are the Organization's figures; `activeReservations` is the
|
|
30
|
+
* list the caller may read, which for the customer's `GET
|
|
31
|
+
* /api/v1/me/credit-limit` is narrower when their organization role lacks
|
|
32
|
+
* `orders.view_organization`. Never derive the count from the list's length.
|
|
33
|
+
*/
|
|
34
|
+
activeReservationCount: z.number().int().nonnegative(),
|
|
35
|
+
/**
|
|
36
|
+
* The active reservations the caller may read. The admin views list every
|
|
37
|
+
* one; the customer view lists the reservations of the orders the buyer may
|
|
38
|
+
* read under `orders`' read scope (`specs/170-organization-roles/` FR-049).
|
|
39
|
+
*/
|
|
19
40
|
activeReservations: z.array(z.object({
|
|
20
41
|
orderId: uuidSchema,
|
|
42
|
+
/**
|
|
43
|
+
* The order's customer-facing number (`businessId`, the one the buyer's
|
|
44
|
+
* order list shows), so neither the storefront (issue #661) nor the admin
|
|
45
|
+
* credit-limit screen (issue #1178) shows the database id. Answered by
|
|
46
|
+
* the customer's `GET /api/v1/me/credit-limit` and by the admin list,
|
|
47
|
+
* detail and adjustment replies; omitted from a fresh grant's reply,
|
|
48
|
+
* which holds no reservation. `null` when `orders` returned no such
|
|
49
|
+
* order; optional for a server that predates it.
|
|
50
|
+
*/
|
|
51
|
+
orderBusinessId: z.string().nullable().optional(),
|
|
21
52
|
amount: z.number().finite(),
|
|
22
53
|
createdAt: isoDateTimeSchema,
|
|
23
54
|
})),
|
|
24
55
|
grantedAt: isoDateTimeSchema,
|
|
25
56
|
});
|
|
57
|
+
/** `GET /api/v1/admin/credit-limits` — every granted credit limit (issue #599). */
|
|
58
|
+
export const creditLimitListResponseSchema = z.object({
|
|
59
|
+
data: z.array(creditLimitViewSchema),
|
|
60
|
+
});
|
|
26
61
|
export const grantCreditLimitRequestSchema = z.object({
|
|
27
62
|
grantedAmount: twoDecimalAmount(z.number().finite().positive()),
|
|
28
63
|
currency: z.string().length(3),
|