@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/modules.js
CHANGED
|
@@ -19,6 +19,7 @@ import { capabilityKeyRe } from './capabilities.js';
|
|
|
19
19
|
import { transactionalEmailManifestEntrySchema } from './transactional-emails.js';
|
|
20
20
|
import { BlockCategorySchema, BlockDefinitionSchema, blockNameRe } from './cms.js';
|
|
21
21
|
import { EnvironmentInputSchema } from './environment-inputs.js';
|
|
22
|
+
import { HookableActionDeclarationSchema, hookableActionRe } from './command-hooks.js';
|
|
22
23
|
// ---------------------------------------------------------------------------
|
|
23
24
|
// Identifier / version regexes
|
|
24
25
|
// ---------------------------------------------------------------------------
|
|
@@ -308,10 +309,10 @@ export const OmittedModuleSchema = z.object({
|
|
|
308
309
|
* report's, so neither belongs here
|
|
309
310
|
* (`specs/107-override-report-and-ladder/contracts/deployment-declaration.md` §5).
|
|
310
311
|
*
|
|
311
|
-
* Every field defaults to empty, so a declaration that leaves one out means
|
|
312
|
+
* Every field defaults to empty (or is optional), so a declaration that leaves one out means
|
|
312
313
|
* "none of these" rather than "unparseable" — the reading an absent file already
|
|
313
314
|
* gets. A deployment that diverges by nothing still ships the file with all
|
|
314
|
-
*
|
|
315
|
+
* fields written out, because the mechanism is easier to find than to remember.
|
|
315
316
|
*/
|
|
316
317
|
export const DeploymentDivergenceDeclarationSchema = z.object({
|
|
317
318
|
/** The modules this deployment does not ship. D-101, unchanged in substance. */
|
|
@@ -353,8 +354,29 @@ export const DeploymentDivergenceDeclarationSchema = z.object({
|
|
|
353
354
|
* `specs/107-override-report-and-ladder/`.
|
|
354
355
|
*/
|
|
355
356
|
reasons: z.record(z.string().min(1), z.string().min(20).max(800)).default({}),
|
|
357
|
+
/**
|
|
358
|
+
* Execution order, per hookable action, for command-hook modules that no
|
|
359
|
+
* manifest dependency orders (`specs/176-command-hooks-outbox/` FR-014, OD-1).
|
|
360
|
+
*
|
|
361
|
+
* Two hook modules on one action and phase with no dependency path between
|
|
362
|
+
* them refuse composition (`UnorderedCommandHooksError`) unless the
|
|
363
|
+
* deployment names both here, first runs first. An entry that contradicts a
|
|
364
|
+
* dependency path is refused too (`CommandHookOrderContradictionError`): the
|
|
365
|
+
* dependency graph is the order, and this only breaks ties it leaves open.
|
|
366
|
+
* It is the deployment's to own because two independent instance packages
|
|
367
|
+
* must not be made to depend on each other just to be ordered.
|
|
368
|
+
*
|
|
369
|
+
* Optional rather than defaulted, unlike the three fields above: it arrived
|
|
370
|
+
* after instances had scaffolded a typed `divergence.ts`, and a defaulted
|
|
371
|
+
* field is a required member of the inferred type — an upgrade would have
|
|
372
|
+
* turned every such file into a type error for a field it does not need.
|
|
373
|
+
* Absent means `{}`.
|
|
374
|
+
*/
|
|
375
|
+
commandHookOrder: z
|
|
376
|
+
.record(z.string().regex(hookableActionRe), z.array(z.string().regex(moduleIdRe)).min(2))
|
|
377
|
+
.optional(),
|
|
356
378
|
})
|
|
357
|
-
//
|
|
379
|
+
// Four fields are the whole vocabulary, so a fifth is a typo — and a
|
|
358
380
|
// mistyped field name under a lenient object is silently stripped, which
|
|
359
381
|
// reads as "this deployment declares nothing" for a file whose author wrote
|
|
360
382
|
// a declaration. Refusing it names the key.
|
|
@@ -649,6 +671,25 @@ export const ModuleManifestSchema = z.object({
|
|
|
649
671
|
* is true of most modules and is not a finding.
|
|
650
672
|
*/
|
|
651
673
|
env: z.array(EnvironmentInputSchema).optional(),
|
|
674
|
+
/**
|
|
675
|
+
* The Command actions this module opens to command hooks, and for which
|
|
676
|
+
* phases (`specs/176-command-hooks-outbox/` FR-010,
|
|
677
|
+
* `contracts/command-hooks-api.md` §1).
|
|
678
|
+
*
|
|
679
|
+
* Each entry is derived from a typed ref the module publishes in
|
|
680
|
+
* `@endora-commerce/contracts` (`toHookableActionDeclaration(ref)`), so the
|
|
681
|
+
* manifest and every hook author name one constant. The declaration is a
|
|
682
|
+
* public contract: a composition refuses a hook on an action no composed
|
|
683
|
+
* module declares, or for a phase this list does not offer. Declare only a
|
|
684
|
+
* Command whose `run` is complete and that is not reversible.
|
|
685
|
+
*
|
|
686
|
+
* {@link defineModuleManifest} refuses one action listed twice; two modules
|
|
687
|
+
* declaring one action is the composer's refusal, because it needs both.
|
|
688
|
+
*
|
|
689
|
+
* Absent means "nothing in this module is hookable", which is true of most
|
|
690
|
+
* modules and is not a finding.
|
|
691
|
+
*/
|
|
692
|
+
hookableActions: z.array(HookableActionDeclarationSchema).optional(),
|
|
652
693
|
});
|
|
653
694
|
/**
|
|
654
695
|
* The three cross-field activation rules (feature 073,
|
|
@@ -1056,6 +1097,21 @@ function assertEnvironmentInputRules(m) {
|
|
|
1056
1097
|
`it here would be one fact with two homes and two descriptions.`);
|
|
1057
1098
|
}
|
|
1058
1099
|
}
|
|
1100
|
+
/**
|
|
1101
|
+
* `specs/176-command-hooks-outbox/` FR-010 — one action is declared once per
|
|
1102
|
+
* manifest. A second entry would offer the union of two phase lists nobody
|
|
1103
|
+
* wrote as one, so it is refused with the module and the action named.
|
|
1104
|
+
*/
|
|
1105
|
+
function assertHookableActionRules(m) {
|
|
1106
|
+
const seen = new Set();
|
|
1107
|
+
for (const declaration of m.hookableActions ?? []) {
|
|
1108
|
+
if (seen.has(declaration.action)) {
|
|
1109
|
+
throw new Error(`[contracts/modules] manifest "${m.id}" declares hookable action "${declaration.action}" ` +
|
|
1110
|
+
'twice. List each action once, with every phase it offers.');
|
|
1111
|
+
}
|
|
1112
|
+
seen.add(declaration.action);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1059
1115
|
/**
|
|
1060
1116
|
* Identity-with-validation helper for module authors. Modules export a
|
|
1061
1117
|
* single `manifest` constant via this helper so TypeScript inference is
|
|
@@ -1097,6 +1153,7 @@ export function defineModuleManifest(m) {
|
|
|
1097
1153
|
assertBlockRules(m);
|
|
1098
1154
|
assertDemoRules(m);
|
|
1099
1155
|
assertEnvironmentInputRules(m);
|
|
1156
|
+
assertHookableActionRules(m);
|
|
1100
1157
|
return ModuleManifestSchema.parse(m);
|
|
1101
1158
|
}
|
|
1102
1159
|
// ---------------------------------------------------------------------------
|
package/dist/orders.d.ts
CHANGED
|
@@ -73,6 +73,60 @@ export declare const orderPendingEffectSchema: z.ZodObject<{
|
|
|
73
73
|
lastAttemptAt: z.ZodNullable<z.ZodString>;
|
|
74
74
|
}, z.core.$strip>;
|
|
75
75
|
export type OrderPendingEffect = z.infer<typeof orderPendingEffectSchema>;
|
|
76
|
+
/**
|
|
77
|
+
* Where an external system — an ERP, a WMS, a fulfilment connector — stands
|
|
78
|
+
* with an order, as that system's integration last reported it: handed over
|
|
79
|
+
* and not answered yet, accepted, or refused.
|
|
80
|
+
*/
|
|
81
|
+
export declare const ORDER_EXTERNAL_REFERENCE_STATES: readonly ["pending", "synced", "error"];
|
|
82
|
+
export type OrderExternalReferenceState = (typeof ORDER_EXTERNAL_REFERENCE_STATES)[number];
|
|
83
|
+
/** The longest message an integration may record, in characters. */
|
|
84
|
+
export declare const ORDER_EXTERNAL_REFERENCE_MESSAGE_MAX = 1000;
|
|
85
|
+
/** The longest external reference (the other system's number), in characters. */
|
|
86
|
+
export declare const ORDER_EXTERNAL_REFERENCE_MAX = 255;
|
|
87
|
+
/**
|
|
88
|
+
* The stable key a writer records its references under — normally its own
|
|
89
|
+
* module id. Lower-case, starting with a letter, then letters, digits, `_`,
|
|
90
|
+
* `-` or `.`, at most 64 characters: it is shown to the operator as written
|
|
91
|
+
* and it is half of the row's identity, so it is a key and not a label.
|
|
92
|
+
*/
|
|
93
|
+
export declare const orderExternalReferenceSystemSchema: z.ZodString;
|
|
94
|
+
/**
|
|
95
|
+
* What a writer records through {@link OrderExternalReferencePort.set}.
|
|
96
|
+
*
|
|
97
|
+
* - `reference` — the other system's number for the order. **Omitted keeps
|
|
98
|
+
* the stored one** (a writer that only reports a new state need not repeat
|
|
99
|
+
* it); `null` clears it.
|
|
100
|
+
* - `message` — the other system's own words, normally on `error`. **Omitted
|
|
101
|
+
* means none**: the message describes the state being recorded, so a writer
|
|
102
|
+
* reporting `synced` after an `error` does not leave the refusal standing.
|
|
103
|
+
*/
|
|
104
|
+
export declare const orderExternalReferenceWriteSchema: z.ZodObject<{
|
|
105
|
+
reference: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
106
|
+
state: z.ZodEnum<{
|
|
107
|
+
error: "error";
|
|
108
|
+
pending: "pending";
|
|
109
|
+
synced: "synced";
|
|
110
|
+
}>;
|
|
111
|
+
message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
export type OrderExternalReferenceWrite = z.infer<typeof orderExternalReferenceWriteSchema>;
|
|
114
|
+
/**
|
|
115
|
+
* One external system's reference on an order, as the admin order detail
|
|
116
|
+
* carries it (`GET /api/v1/admin/orders/:id`, `externalReferences`).
|
|
117
|
+
*/
|
|
118
|
+
export declare const adminOrderExternalReferenceSchema: z.ZodObject<{
|
|
119
|
+
system: z.ZodString;
|
|
120
|
+
reference: z.ZodNullable<z.ZodString>;
|
|
121
|
+
state: z.ZodEnum<{
|
|
122
|
+
error: "error";
|
|
123
|
+
pending: "pending";
|
|
124
|
+
synced: "synced";
|
|
125
|
+
}>;
|
|
126
|
+
message: z.ZodNullable<z.ZodString>;
|
|
127
|
+
updatedAt: z.ZodString;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
export type AdminOrderExternalReference = z.infer<typeof adminOrderExternalReferenceSchema>;
|
|
76
130
|
/**
|
|
77
131
|
* Issue #904 — the VAT method an order was placed under, as `orders.vat_method`
|
|
78
132
|
* stores it (`null`: placed before 0.108.0). `per_rate`: VAT per rate on the
|
|
@@ -414,6 +468,17 @@ export declare const adminOrderDetailSchema: z.ZodObject<{
|
|
|
414
468
|
lastName: z.ZodString;
|
|
415
469
|
email: z.ZodString;
|
|
416
470
|
}, z.core.$strip>>;
|
|
471
|
+
externalReferences: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
472
|
+
system: z.ZodString;
|
|
473
|
+
reference: z.ZodNullable<z.ZodString>;
|
|
474
|
+
state: z.ZodEnum<{
|
|
475
|
+
error: "error";
|
|
476
|
+
pending: "pending";
|
|
477
|
+
synced: "synced";
|
|
478
|
+
}>;
|
|
479
|
+
message: z.ZodNullable<z.ZodString>;
|
|
480
|
+
updatedAt: z.ZodString;
|
|
481
|
+
}, z.core.$strip>>>;
|
|
417
482
|
}, z.core.$strip>;
|
|
418
483
|
export type AdminOrderDetail = z.infer<typeof adminOrderDetailSchema>;
|
|
419
484
|
/**
|
|
@@ -920,6 +985,7 @@ export declare const adminCreateOrderRequestSchema: z.ZodObject<{
|
|
|
920
985
|
type: z.ZodString;
|
|
921
986
|
id: z.ZodString;
|
|
922
987
|
}, z.core.$strict>>;
|
|
988
|
+
customFieldValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
923
989
|
}, z.core.$strip>;
|
|
924
990
|
export type AdminCreateOrderRequest = z.infer<typeof adminCreateOrderRequestSchema>;
|
|
925
991
|
/**
|
|
@@ -1557,9 +1623,23 @@ export interface OrderPlacementPort {
|
|
|
1557
1623
|
* instead of their active basket, which the placement then never touches. The
|
|
1558
1624
|
* working basket ends `completed` against the order, or is removed when the
|
|
1559
1625
|
* placement is refused.
|
|
1626
|
+
*
|
|
1627
|
+
* `options.languageTag` (issue #1308) — the buyer request's scope language:
|
|
1628
|
+
* the channel language its `Accept-Language` asks for
|
|
1629
|
+
* (`requestScopeLanguage`). The basket's lines are judged for availability,
|
|
1630
|
+
* and the order's lines named, at (the order's channel, `languageTag`
|
|
1631
|
+
* resolved against that channel's own languages) — the language the same
|
|
1632
|
+
* request's `CartWritePort.addItems` judged them in, so a line it admitted
|
|
1633
|
+
* is not refused here for being off in the channel's default language.
|
|
1634
|
+
* Absent: the language `options.language` names on the channel, else the
|
|
1635
|
+
* channel's default, as before — the answer for a caller with no storefront
|
|
1636
|
+
* request (an API-key order, an operator naming a customer's channel). The
|
|
1637
|
+
* field is additive: an implementation outside this repository may ignore it
|
|
1638
|
+
* and keep that behaviour.
|
|
1560
1639
|
*/
|
|
1561
1640
|
placeOrder(ctx: OrderCustomerContext, req: PlaceOrderRequest, options?: {
|
|
1562
1641
|
language?: string;
|
|
1642
|
+
languageTag?: string;
|
|
1563
1643
|
workingBasketId?: string;
|
|
1564
1644
|
}): Promise<PlacedOrderRecord>;
|
|
1565
1645
|
}
|
|
@@ -1734,6 +1814,67 @@ export interface OrderTransitionPort {
|
|
|
1734
1814
|
*/
|
|
1735
1815
|
isTerminal(orderId: string): Promise<boolean | null>;
|
|
1736
1816
|
}
|
|
1817
|
+
/** The container name {@link OrderExternalReferencePort} is registered under. */
|
|
1818
|
+
export declare const ORDER_EXTERNAL_REFERENCE_PORT: "orderExternalReferencePort";
|
|
1819
|
+
/**
|
|
1820
|
+
* One external system's reference on an order, as
|
|
1821
|
+
* {@link OrderExternalReferencePort} answers it (issue #1030).
|
|
1822
|
+
*/
|
|
1823
|
+
export interface OrderExternalReference {
|
|
1824
|
+
orderId: string;
|
|
1825
|
+
/** The writer's stable key, e.g. its module id ({@link orderExternalReferenceSystemSchema}). */
|
|
1826
|
+
system: string;
|
|
1827
|
+
/** The external system's number for the order, once known. */
|
|
1828
|
+
reference: string | null;
|
|
1829
|
+
state: OrderExternalReferenceState;
|
|
1830
|
+
/** The external system's own words, plain text, at most 1000 characters. */
|
|
1831
|
+
message: string | null;
|
|
1832
|
+
/** When this system's entry last changed. A write that changed nothing does not move it. */
|
|
1833
|
+
updatedAt: Date;
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Container name: `orderExternalReferencePort`. Owner: `orders`
|
|
1837
|
+
* ({@link ORDER_EXTERNAL_REFERENCE_PORT}; issue #1030).
|
|
1838
|
+
*
|
|
1839
|
+
* What an integration that hands orders to another system — an ERP, a WMS, a
|
|
1840
|
+
* fulfilment connector — records **on the order**: that system's number for
|
|
1841
|
+
* it, where the hand-over stands, and the other system's words when it
|
|
1842
|
+
* refused. One entry per order and system. The operator reads them on the
|
|
1843
|
+
* admin order page, and the admin order list's search finds an order by its
|
|
1844
|
+
* reference. Buyer-facing reads never carry them.
|
|
1845
|
+
*
|
|
1846
|
+
* **Writes are audited Commands** (`order.external_reference.set`), each
|
|
1847
|
+
* recorded with the calling actor — so call it inside a tenant context, as a
|
|
1848
|
+
* worker does under `enterSystemScope`. A write that changes nothing records
|
|
1849
|
+
* nothing and does not move `updatedAt`, because a sync loop resends.
|
|
1850
|
+
*
|
|
1851
|
+
* **Refusals are thrown**, as the admin API's are: an order the caller cannot
|
|
1852
|
+
* see is `404 ORDER_NOT_FOUND`, and a write that fails
|
|
1853
|
+
* {@link orderExternalReferenceWriteSchema} or a system key that fails
|
|
1854
|
+
* {@link orderExternalReferenceSystemSchema} is `400 VALIDATION_FAILED`.
|
|
1855
|
+
* The reads answer an unknown order with `null` / `[]`.
|
|
1856
|
+
*
|
|
1857
|
+
* An entry outlives its writer: a system whose module is uninstalled leaves
|
|
1858
|
+
* its entries in place, as history. Every read and write is confined to the
|
|
1859
|
+
* orders the caller's tenant context can see.
|
|
1860
|
+
*
|
|
1861
|
+
* **Owner off:** the seam fails closed — resolving this port throws
|
|
1862
|
+
* `ModuleDisabledError` and the call answers 503 `MODULE_DISABLED`, so nothing
|
|
1863
|
+
* half-executes. Resolve it per use with `lazyPort`, and do not wrap the call
|
|
1864
|
+
* in a bare `catch`. Whether `orders` has an off state at all is its
|
|
1865
|
+
* manifest's `activation` to say, not this line's: a module declaring
|
|
1866
|
+
* `nonDeactivatable` never enters one.
|
|
1867
|
+
*/
|
|
1868
|
+
export interface OrderExternalReferencePort {
|
|
1869
|
+
/** Upsert this system's entry for the order: one Command, one audit row per actual change. */
|
|
1870
|
+
set(orderId: string, system: string, value: OrderExternalReferenceWrite): Promise<OrderExternalReference>;
|
|
1871
|
+
/** This system's entry for the order, or `null`. */
|
|
1872
|
+
get(orderId: string, system: string): Promise<OrderExternalReference | null>;
|
|
1873
|
+
/** Every system's entry for the order, ordered by system key. */
|
|
1874
|
+
listForOrder(orderId: string): Promise<OrderExternalReference[]>;
|
|
1875
|
+
/** The orders whose reference in `system` equals `reference` exactly (normally 0 or 1). */
|
|
1876
|
+
findOrderIds(system: string, reference: string): Promise<string[]>;
|
|
1877
|
+
}
|
|
1737
1878
|
/**
|
|
1738
1879
|
* The answer to a buyer-side claim on an order's GA4 `purchase` conversion
|
|
1739
1880
|
* (issue #277).
|
package/dist/orders.js
CHANGED
|
@@ -5,6 +5,7 @@ import { customFieldCarrySkipSchema, customFieldFiltersQueryParamSchema, customF
|
|
|
5
5
|
import { vatStatusSchema } from './organizations.js';
|
|
6
6
|
import { savedListViewColumnsSchema, savedListViewFiltersSchema, savedListViewNameSchema, savedListViewSchema, savedListViewSortSchema, } from './saved-list-views.js';
|
|
7
7
|
import { twoDecimalAmount } from './money-input.js';
|
|
8
|
+
import { lineQuantitySchema, REQUEST_LINE_ITEMS_MAX } from './line-bounds.js';
|
|
8
9
|
import { vatSummaryRowSchema } from './invoices.js';
|
|
9
10
|
/**
|
|
10
11
|
* Orders module contracts — Source of truth per Principle V.
|
|
@@ -89,6 +90,69 @@ export const orderPendingEffectSchema = z.object({
|
|
|
89
90
|
attempts: z.number().int().nonnegative(),
|
|
90
91
|
lastAttemptAt: isoDateTimeSchema.nullable(),
|
|
91
92
|
});
|
|
93
|
+
// --- External references (issue #1030) ----------------------------------------
|
|
94
|
+
/**
|
|
95
|
+
* Where an external system — an ERP, a WMS, a fulfilment connector — stands
|
|
96
|
+
* with an order, as that system's integration last reported it: handed over
|
|
97
|
+
* and not answered yet, accepted, or refused.
|
|
98
|
+
*/
|
|
99
|
+
export const ORDER_EXTERNAL_REFERENCE_STATES = ['pending', 'synced', 'error'];
|
|
100
|
+
/** The longest message an integration may record, in characters. */
|
|
101
|
+
export const ORDER_EXTERNAL_REFERENCE_MESSAGE_MAX = 1000;
|
|
102
|
+
/** The longest external reference (the other system's number), in characters. */
|
|
103
|
+
export const ORDER_EXTERNAL_REFERENCE_MAX = 255;
|
|
104
|
+
/**
|
|
105
|
+
* The stable key a writer records its references under — normally its own
|
|
106
|
+
* module id. Lower-case, starting with a letter, then letters, digits, `_`,
|
|
107
|
+
* `-` or `.`, at most 64 characters: it is shown to the operator as written
|
|
108
|
+
* and it is half of the row's identity, so it is a key and not a label.
|
|
109
|
+
*/
|
|
110
|
+
export const orderExternalReferenceSystemSchema = z
|
|
111
|
+
.string()
|
|
112
|
+
.max(64)
|
|
113
|
+
.regex(/^[a-z][a-z0-9_.-]*$/, 'A system key is lower-case letters, digits, "_", "-" or "." and starts with a letter.');
|
|
114
|
+
/**
|
|
115
|
+
* Plain text: any character but a control character other than tab, line feed
|
|
116
|
+
* and carriage return. The admin renders it as text, never as markup.
|
|
117
|
+
*/
|
|
118
|
+
const CONTROL_CHARACTER = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/;
|
|
119
|
+
/**
|
|
120
|
+
* What a writer records through {@link OrderExternalReferencePort.set}.
|
|
121
|
+
*
|
|
122
|
+
* - `reference` — the other system's number for the order. **Omitted keeps
|
|
123
|
+
* the stored one** (a writer that only reports a new state need not repeat
|
|
124
|
+
* it); `null` clears it.
|
|
125
|
+
* - `message` — the other system's own words, normally on `error`. **Omitted
|
|
126
|
+
* means none**: the message describes the state being recorded, so a writer
|
|
127
|
+
* reporting `synced` after an `error` does not leave the refusal standing.
|
|
128
|
+
*/
|
|
129
|
+
export const orderExternalReferenceWriteSchema = z.object({
|
|
130
|
+
reference: z
|
|
131
|
+
.string()
|
|
132
|
+
.max(ORDER_EXTERNAL_REFERENCE_MAX)
|
|
133
|
+
.refine((value) => value.trim().length > 0, 'An external reference is not empty.')
|
|
134
|
+
.refine((value) => !CONTROL_CHARACTER.test(value), 'An external reference is plain text.')
|
|
135
|
+
.nullable()
|
|
136
|
+
.optional(),
|
|
137
|
+
state: z.enum(ORDER_EXTERNAL_REFERENCE_STATES),
|
|
138
|
+
message: z
|
|
139
|
+
.string()
|
|
140
|
+
.max(ORDER_EXTERNAL_REFERENCE_MESSAGE_MAX)
|
|
141
|
+
.refine((value) => !CONTROL_CHARACTER.test(value), 'A message is plain text.')
|
|
142
|
+
.nullable()
|
|
143
|
+
.optional(),
|
|
144
|
+
});
|
|
145
|
+
/**
|
|
146
|
+
* One external system's reference on an order, as the admin order detail
|
|
147
|
+
* carries it (`GET /api/v1/admin/orders/:id`, `externalReferences`).
|
|
148
|
+
*/
|
|
149
|
+
export const adminOrderExternalReferenceSchema = z.object({
|
|
150
|
+
system: z.string(),
|
|
151
|
+
reference: z.string().nullable(),
|
|
152
|
+
state: z.enum(ORDER_EXTERNAL_REFERENCE_STATES),
|
|
153
|
+
message: z.string().nullable(),
|
|
154
|
+
updatedAt: isoDateTimeSchema,
|
|
155
|
+
});
|
|
92
156
|
/**
|
|
93
157
|
* Issue #904 — the VAT method an order was placed under, as `orders.vat_method`
|
|
94
158
|
* stores it (`null`: placed before 0.108.0). `per_rate`: VAT per rate on the
|
|
@@ -284,6 +348,12 @@ export const adminOrderDetailSchema = orderSchema.extend({
|
|
|
284
348
|
email: z.string(),
|
|
285
349
|
})
|
|
286
350
|
.nullable(),
|
|
351
|
+
/**
|
|
352
|
+
* Issue #1030 — what each external system has reported about this order,
|
|
353
|
+
* one entry per system, ordered by system key. Empty when none has; a reply
|
|
354
|
+
* from a server older than the field parses as empty.
|
|
355
|
+
*/
|
|
356
|
+
externalReferences: z.array(adminOrderExternalReferenceSchema).default([]),
|
|
287
357
|
});
|
|
288
358
|
/**
|
|
289
359
|
* What a status-changing order route answers when the change **committed** but
|
|
@@ -631,7 +701,7 @@ export const updateOrderSavedViewRequestSchema = createOrderSavedViewRequestSche
|
|
|
631
701
|
export const adminCreateOrderItemSchema = z.object({
|
|
632
702
|
productId: uuidSchema,
|
|
633
703
|
variantId: uuidSchema.optional(),
|
|
634
|
-
quantity:
|
|
704
|
+
quantity: lineQuantitySchema,
|
|
635
705
|
});
|
|
636
706
|
/**
|
|
637
707
|
* A brand-new address typed inline on the admin create-order form, instead of
|
|
@@ -654,7 +724,7 @@ export const adminCreateOrderInlineAddressSchema = z.object({
|
|
|
654
724
|
* VALIDATION_FAILED`, `details: { code: 'too_many_items', maximum }`), deliberately not by
|
|
655
725
|
* a schema `.max()`, which would answer 400.
|
|
656
726
|
*/
|
|
657
|
-
export const ADMIN_ORDER_MAX_ITEMS =
|
|
727
|
+
export const ADMIN_ORDER_MAX_ITEMS = REQUEST_LINE_ITEMS_MAX;
|
|
658
728
|
/**
|
|
659
729
|
* Feature 159 — a line of the admin create request: the preview's item plus the
|
|
660
730
|
* `groups[].key` it belongs to (absent or `null` = ungrouped). The preview keeps
|
|
@@ -696,6 +766,11 @@ export const adminCreateOrderRequestSchema = z
|
|
|
696
766
|
* not returned. Only this admin request may carry it.
|
|
697
767
|
*/
|
|
698
768
|
origin: OriginReferenceSchema.optional(),
|
|
769
|
+
/**
|
|
770
|
+
* Feature 175 (FR-017) — the order's custom-field values, validated with
|
|
771
|
+
* the administrator's rules inside the creating Command.
|
|
772
|
+
*/
|
|
773
|
+
customFieldValues: customFieldValuesSchema.optional(),
|
|
699
774
|
})
|
|
700
775
|
.superRefine((val, ctx) => {
|
|
701
776
|
if ((val.deliveryAddressId == null) === (val.deliveryAddress == null)) {
|
|
@@ -740,7 +815,7 @@ export const apiPlaceOrderRequestSchema = z
|
|
|
740
815
|
lines: z
|
|
741
816
|
.array(z.object({
|
|
742
817
|
sku: z.string().min(1),
|
|
743
|
-
quantity:
|
|
818
|
+
quantity: lineQuantitySchema,
|
|
744
819
|
}))
|
|
745
820
|
.min(1),
|
|
746
821
|
deliveryMethodId: uuidSchema,
|
|
@@ -922,6 +997,8 @@ export const cloneOrderToQuoteResponseSchema = z.object({
|
|
|
922
997
|
export const ORDER_STATUS_ON_HOLD = 'on_hold';
|
|
923
998
|
export const ORDER_STATUS_CANCELLED = 'cancelled';
|
|
924
999
|
export const ORDER_STATUS_INITIAL = 'new';
|
|
1000
|
+
/** The container name {@link OrderExternalReferencePort} is registered under. */
|
|
1001
|
+
export const ORDER_EXTERNAL_REFERENCE_PORT = 'orderExternalReferencePort';
|
|
925
1002
|
/**
|
|
926
1003
|
* The answer to a buyer-side claim on an order's GA4 `purchase` conversion
|
|
927
1004
|
* (issue #277).
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { OrganizationRecord, OrganizationStatus, VatStatus } from './organizations.js';
|
|
2
|
+
/**
|
|
3
|
+
* `organization.create` — an operator creates an Organization. `organization`
|
|
4
|
+
* reflects the **uncommitted** row on the Command's transaction.
|
|
5
|
+
*/
|
|
6
|
+
export interface OrganizationCreateHookData {
|
|
7
|
+
readonly organization: OrganizationRecord;
|
|
8
|
+
/** The channels the create bound, sorted and deduplicated. */
|
|
9
|
+
readonly salesChannelIds: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
/** `organization.register` — a business registers on the storefront. */
|
|
12
|
+
export interface OrganizationRegisterHookData {
|
|
13
|
+
readonly organization: OrganizationRecord;
|
|
14
|
+
/** The first account, created by the child `customer_account.create`. */
|
|
15
|
+
readonly customerAccountId: string;
|
|
16
|
+
/** The request's resolved channel; `null` when the system default was bound. */
|
|
17
|
+
readonly salesChannelId: string | null;
|
|
18
|
+
/** The registry lookup's outcome code, when the registration carried a matched lookup. */
|
|
19
|
+
readonly registryLookupOutcome: string | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `organization.admin_patch` and `organization.set_custom_field_values` — an
|
|
23
|
+
* existing Organization changed. `organization` is the after-state.
|
|
24
|
+
*/
|
|
25
|
+
export interface OrganizationUpdateHookData {
|
|
26
|
+
readonly organization: OrganizationRecord;
|
|
27
|
+
/** Sorted names of the columns whose value changed. */
|
|
28
|
+
readonly changedFields: readonly string[];
|
|
29
|
+
/** Sorted keys of the custom fields whose value changed. */
|
|
30
|
+
readonly changedCustomFields: readonly string[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* `organization.convert_to_company` (issue #1057) — an operator turned a
|
|
34
|
+
* personal Organization into a company. **Ids, codes and field names only**
|
|
35
|
+
* (`specs/conventions/audit-state.md` list 1): never the tax ID, the name or the
|
|
36
|
+
* address the conversion wrote.
|
|
37
|
+
*/
|
|
38
|
+
export interface OrganizationConvertToCompanyHookData {
|
|
39
|
+
readonly organizationId: string;
|
|
40
|
+
/** The status the conversion kept. */
|
|
41
|
+
readonly status: OrganizationStatus;
|
|
42
|
+
/** The company's VAT classification, as converted. */
|
|
43
|
+
readonly vatStatus: VatStatus;
|
|
44
|
+
/** Sorted names of the columns whose value changed. */
|
|
45
|
+
readonly changedFields: readonly string[];
|
|
46
|
+
/** `true` when the Organization had never been approved and the conversion stamped it. */
|
|
47
|
+
readonly approvalStamped: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* `organization.tax_id.change` (issue #1057) — an operator corrected a
|
|
51
|
+
* company's tax ID in place. **Never the old or the new tax ID**; a correction
|
|
52
|
+
* to the same value (after normalisation) is handed `changedFields: []` and
|
|
53
|
+
* `vatValidationReset: false`, and nothing was written.
|
|
54
|
+
*/
|
|
55
|
+
export interface OrganizationTaxIdChangeHookData {
|
|
56
|
+
readonly organizationId: string;
|
|
57
|
+
/** `['taxId']`, or `[]` for the same value. */
|
|
58
|
+
readonly changedFields: readonly string[];
|
|
59
|
+
/** `true` when the VAT validation summary was reset to never-validated. */
|
|
60
|
+
readonly vatValidationReset: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** `afterCommit` data: ids and codes only (audit-state list 1). Delivered in P3. */
|
|
63
|
+
export type OrganizationCreateOutbox = {
|
|
64
|
+
readonly organizationId: string;
|
|
65
|
+
readonly status: string;
|
|
66
|
+
};
|
|
67
|
+
export type OrganizationRegisterOutbox = {
|
|
68
|
+
readonly organizationId: string;
|
|
69
|
+
readonly customerAccountId: string;
|
|
70
|
+
readonly status: string;
|
|
71
|
+
};
|
|
72
|
+
export type OrganizationUpdateOutbox = {
|
|
73
|
+
readonly organizationId: string;
|
|
74
|
+
readonly changedFields: readonly string[];
|
|
75
|
+
readonly changedCustomFields: readonly string[];
|
|
76
|
+
};
|
|
77
|
+
export type OrganizationConvertToCompanyOutbox = {
|
|
78
|
+
readonly organizationId: string;
|
|
79
|
+
readonly status: string;
|
|
80
|
+
readonly changedFields: readonly string[];
|
|
81
|
+
};
|
|
82
|
+
export type OrganizationTaxIdChangeOutbox = {
|
|
83
|
+
readonly organizationId: string;
|
|
84
|
+
readonly changedFields: readonly string[];
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* The refs a hook author registers against (`ctx.commandHooks([{ on: ORG.create, … }])`)
|
|
88
|
+
* and the `organizations` manifest lists. All six offer both phases; the
|
|
89
|
+
* `afterCommit` delivery is the transactional outbox (P3).
|
|
90
|
+
*/
|
|
91
|
+
export declare const ORGANIZATION_HOOKABLE_ACTIONS: {
|
|
92
|
+
readonly create: import("./command-hooks.js").HookableActionRef<OrganizationCreateHookData, OrganizationCreateOutbox>;
|
|
93
|
+
readonly register: import("./command-hooks.js").HookableActionRef<OrganizationRegisterHookData, OrganizationRegisterOutbox>;
|
|
94
|
+
readonly adminPatch: import("./command-hooks.js").HookableActionRef<OrganizationUpdateHookData, OrganizationUpdateOutbox>;
|
|
95
|
+
readonly setCustomFieldValues: import("./command-hooks.js").HookableActionRef<OrganizationUpdateHookData, OrganizationUpdateOutbox>;
|
|
96
|
+
readonly convertToCompany: import("./command-hooks.js").HookableActionRef<OrganizationConvertToCompanyHookData, OrganizationConvertToCompanyOutbox>;
|
|
97
|
+
readonly changeTaxId: import("./command-hooks.js").HookableActionRef<OrganizationTaxIdChangeHookData, OrganizationTaxIdChangeOutbox>;
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=organization-hooks.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// `organizations`' hookable actions — `specs/176-command-hooks-outbox/` FR-024,
|
|
2
|
+
// `contracts/organization-hookable-actions.md`.
|
|
3
|
+
//
|
|
4
|
+
// The six Organization writes an instance may take part in through a command
|
|
5
|
+
// hook (`organization.convert_to_company` and `organization.tax_id.change`
|
|
6
|
+
// since issue #1057). The action strings, the phases and the data types are a public
|
|
7
|
+
// contract: changing one is a changeset on `@endora-commerce/contracts`.
|
|
8
|
+
import { hookableAction } from './command-hooks.js';
|
|
9
|
+
/**
|
|
10
|
+
* The refs a hook author registers against (`ctx.commandHooks([{ on: ORG.create, … }])`)
|
|
11
|
+
* and the `organizations` manifest lists. All six offer both phases; the
|
|
12
|
+
* `afterCommit` delivery is the transactional outbox (P3).
|
|
13
|
+
*/
|
|
14
|
+
export const ORGANIZATION_HOOKABLE_ACTIONS = {
|
|
15
|
+
create: hookableAction('organization.create', 'organization', ['beforeCommit', 'afterCommit']),
|
|
16
|
+
register: hookableAction('organization.register', 'organization', ['beforeCommit', 'afterCommit']),
|
|
17
|
+
adminPatch: hookableAction('organization.admin_patch', 'organization', ['beforeCommit', 'afterCommit']),
|
|
18
|
+
setCustomFieldValues: hookableAction('organization.set_custom_field_values', 'organization', ['beforeCommit', 'afterCommit']),
|
|
19
|
+
convertToCompany: hookableAction('organization.convert_to_company', 'organization', ['beforeCommit', 'afterCommit']),
|
|
20
|
+
changeTaxId: hookableAction('organization.tax_id.change', 'organization', ['beforeCommit', 'afterCommit']),
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=organization-hooks.js.map
|
|
@@ -47,8 +47,8 @@ export declare const registryLookupRequestSchema: z.ZodObject<{
|
|
|
47
47
|
export type RegistryLookupRequest = z.infer<typeof registryLookupRequestSchema>;
|
|
48
48
|
export declare const REGISTRY_LOOKUP_STATUSES: readonly ["found", "not_found", "unavailable", "invalid_tax_id", "unsupported_country"];
|
|
49
49
|
export declare const registryLookupStatusSchema: z.ZodEnum<{
|
|
50
|
-
unavailable: "unavailable";
|
|
51
50
|
not_found: "not_found";
|
|
51
|
+
unavailable: "unavailable";
|
|
52
52
|
found: "found";
|
|
53
53
|
invalid_tax_id: "invalid_tax_id";
|
|
54
54
|
unsupported_country: "unsupported_country";
|
|
@@ -99,8 +99,8 @@ export type RegistryLookupCompany = z.infer<typeof registryLookupCompanySchema>;
|
|
|
99
99
|
export declare const registryLookupResponseSchema: z.ZodObject<{
|
|
100
100
|
data: z.ZodObject<{
|
|
101
101
|
status: z.ZodEnum<{
|
|
102
|
-
unavailable: "unavailable";
|
|
103
102
|
not_found: "not_found";
|
|
103
|
+
unavailable: "unavailable";
|
|
104
104
|
found: "found";
|
|
105
105
|
invalid_tax_id: "invalid_tax_id";
|
|
106
106
|
unsupported_country: "unsupported_country";
|
|
@@ -161,8 +161,8 @@ export declare const registryAttemptSchema: z.ZodObject<{
|
|
|
161
161
|
}>;
|
|
162
162
|
outcome: z.ZodEnum<{
|
|
163
163
|
skipped: "skipped";
|
|
164
|
-
unavailable: "unavailable";
|
|
165
164
|
not_found: "not_found";
|
|
165
|
+
unavailable: "unavailable";
|
|
166
166
|
found: "found";
|
|
167
167
|
}>;
|
|
168
168
|
errorKind: z.ZodNullable<z.ZodString>;
|
|
@@ -207,8 +207,8 @@ export declare const registryDetailsSchema: z.ZodObject<{
|
|
|
207
207
|
}>;
|
|
208
208
|
outcome: z.ZodEnum<{
|
|
209
209
|
skipped: "skipped";
|
|
210
|
-
unavailable: "unavailable";
|
|
211
210
|
not_found: "not_found";
|
|
211
|
+
unavailable: "unavailable";
|
|
212
212
|
found: "found";
|
|
213
213
|
}>;
|
|
214
214
|
errorKind: z.ZodNullable<z.ZodString>;
|
|
@@ -328,8 +328,8 @@ export declare const organizationTaxIdValidationRecordSchema: z.ZodObject<{
|
|
|
328
328
|
}>;
|
|
329
329
|
outcome: z.ZodEnum<{
|
|
330
330
|
skipped: "skipped";
|
|
331
|
-
unavailable: "unavailable";
|
|
332
331
|
not_found: "not_found";
|
|
332
|
+
unavailable: "unavailable";
|
|
333
333
|
found: "found";
|
|
334
334
|
}>;
|
|
335
335
|
errorKind: z.ZodNullable<z.ZodString>;
|
|
@@ -204,6 +204,7 @@ export declare const adminDirectMemberToRoleRequestSchema: z.ZodObject<{
|
|
|
204
204
|
lastName: z.ZodString;
|
|
205
205
|
password: z.ZodString;
|
|
206
206
|
roleId: z.ZodOptional<z.ZodString>;
|
|
207
|
+
customFieldValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
207
208
|
}, z.core.$strict>;
|
|
208
209
|
export type AdminDirectMemberToRoleRequest = z.infer<typeof adminDirectMemberToRoleRequestSchema>;
|
|
209
210
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { isoDateTimeSchema, uuidSchema } from './common.js';
|
|
3
3
|
import { ERROR_CODES } from './errors.js';
|
|
4
|
+
import { customFieldValuesSchema } from './custom-fields.js';
|
|
4
5
|
/**
|
|
5
6
|
* Organization roles and organization permissions — the buyer's side of
|
|
6
7
|
* "who may do what" (`specs/170-organization-roles/`).
|
|
@@ -143,6 +144,12 @@ export const adminDirectMemberToRoleRequestSchema = z
|
|
|
143
144
|
lastName: z.string().min(1).max(120),
|
|
144
145
|
password: z.string().min(12).max(256),
|
|
145
146
|
roleId: uuidSchema.optional(),
|
|
147
|
+
/**
|
|
148
|
+
* Feature 175 (FR-018) — the new account's custom-field values (entity
|
|
149
|
+
* type `customer`), validated with the administrator's rules before the
|
|
150
|
+
* account is created.
|
|
151
|
+
*/
|
|
152
|
+
customFieldValues: customFieldValuesSchema.optional(),
|
|
146
153
|
})
|
|
147
154
|
.strict();
|
|
148
155
|
/**
|