@endora-commerce/contracts 0.109.0 → 0.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accept-language.d.ts +31 -0
- package/dist/accept-language.js +64 -0
- package/dist/actor.d.ts +16 -0
- package/dist/addresses.d.ts +35 -0
- package/dist/addresses.js +8 -1
- package/dist/admin-actions.d.ts +2 -0
- package/dist/admin-actions.js +18 -0
- package/dist/admin-contributions.d.ts +99 -12
- package/dist/admin-contributions.js +36 -10
- package/dist/admin-roles.d.ts +17 -2
- package/dist/admin-users.d.ts +9 -0
- package/dist/admin.d.ts +114 -4
- package/dist/admin.js +98 -3
- package/dist/api-keys.d.ts +22 -0
- package/dist/api-keys.js +4 -0
- package/dist/assets-library.d.ts +45 -0
- package/dist/assets-library.js +20 -3
- package/dist/audit-logs.d.ts +12 -0
- package/dist/audit-logs.js +12 -0
- package/dist/auth.d.ts +9 -0
- package/dist/auth.js +9 -0
- package/dist/blog.d.ts +382 -22
- package/dist/blog.js +199 -17
- package/dist/carts.d.ts +423 -36
- package/dist/carts.js +150 -12
- package/dist/catalog.d.ts +379 -208
- package/dist/catalog.js +241 -163
- package/dist/cms-brand.d.ts +14 -14
- package/dist/cms.d.ts +71 -16
- package/dist/cms.js +15 -0
- package/dist/command-hooks.d.ts +301 -0
- package/dist/command-hooks.js +248 -0
- package/dist/common.d.ts +23 -6
- package/dist/common.js +25 -2
- package/dist/comparisons.d.ts +21 -14
- package/dist/comparisons.js +2 -1
- package/dist/credit-limits.d.ts +22 -0
- package/dist/credit-limits.js +35 -0
- package/dist/crm.d.ts +134 -78
- package/dist/crm.js +21 -5
- package/dist/custom-fields.d.ts +417 -49
- package/dist/custom-fields.js +142 -1
- package/dist/customer-accounts.d.ts +324 -22
- package/dist/customer-accounts.js +43 -0
- package/dist/customer-notifications.d.ts +143 -0
- package/dist/customer-notifications.js +41 -0
- package/dist/customers.d.ts +92 -73
- package/dist/customers.js +98 -10
- package/dist/dictionary.d.ts +53 -0
- package/dist/dictionary.js +25 -0
- package/dist/document-templates.d.ts +12 -12
- package/dist/email.d.ts +34 -0
- package/dist/email.js +6 -0
- package/dist/errors.d.ts +431 -3
- package/dist/errors.js +523 -3
- package/dist/forms-logic.d.ts +79 -0
- package/dist/forms-logic.fixtures.d.ts +52 -0
- package/dist/forms-logic.fixtures.js +610 -0
- package/dist/forms-logic.js +699 -0
- package/dist/forms.d.ts +9833 -0
- package/dist/forms.js +827 -0
- package/dist/i18n.d.ts +34 -0
- package/dist/i18n.js +15 -0
- package/dist/import-export.d.ts +180 -0
- package/dist/import-export.js +60 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.js +30 -1
- package/dist/inventory.d.ts +9 -9
- package/dist/invoice-ledger.d.ts +13 -13
- package/dist/invoices.d.ts +126 -0
- package/dist/invoices.js +53 -0
- package/dist/line-bounds.d.ts +53 -0
- package/dist/line-bounds.js +65 -0
- package/dist/megamenu.d.ts +27 -27
- package/dist/mfa.d.ts +210 -4
- package/dist/mfa.js +136 -0
- package/dist/modules.d.ts +56 -8
- package/dist/modules.js +128 -3
- package/dist/money-decimal.d.ts +54 -0
- package/dist/money-decimal.js +95 -0
- package/dist/newsletter.d.ts +4 -4
- package/dist/orders.d.ts +246 -12
- package/dist/orders.js +140 -7
- package/dist/organization-hooks.d.ts +99 -0
- package/dist/organization-hooks.js +22 -0
- package/dist/organization-registry-lookup.d.ts +362 -0
- package/dist/organization-registry-lookup.js +196 -0
- package/dist/organization-roles.d.ts +341 -0
- package/dist/organization-roles.js +218 -0
- package/dist/organizations.d.ts +1074 -103
- package/dist/organizations.js +293 -28
- package/dist/page-builder-props.d.ts +56 -56
- package/dist/pim-connector.d.ts +7 -3
- package/dist/pim-connector.js +6 -2
- package/dist/pim-field-path.d.ts +5 -1
- package/dist/pim-field-path.js +37 -81
- package/dist/pim-locale-mapping.d.ts +131 -0
- package/dist/pim-locale-mapping.js +193 -0
- package/dist/price-books.d.ts +215 -63
- package/dist/price-books.js +47 -2
- package/dist/price-lists.d.ts +13 -10
- package/dist/product-feeds.d.ts +249 -100
- package/dist/product-feeds.js +46 -2
- package/dist/product-scope-model.d.ts +161 -0
- package/dist/product-scope-model.js +161 -0
- package/dist/product-scope-overrides.d.ts +0 -103
- package/dist/product-scope-overrides.js +0 -54
- package/dist/product-scoped-values.d.ts +2610 -0
- package/dist/product-scoped-values.js +425 -0
- package/dist/product-scopes.d.ts +199 -64
- package/dist/product-scopes.js +120 -23
- package/dist/product-tax-rates.d.ts +38 -0
- package/dist/product-tax-rates.js +45 -0
- package/dist/product-url-keys.d.ts +51 -45
- package/dist/product-url-keys.js +73 -39
- package/dist/product-value-resolver.d.ts +37 -60
- package/dist/product-value-resolver.js +36 -96
- package/dist/projects.d.ts +76 -28
- package/dist/projects.js +53 -9
- package/dist/promotions.d.ts +163 -11
- package/dist/promotions.js +23 -1
- package/dist/pwa.d.ts +41 -2
- package/dist/quick-order.d.ts +159 -9
- package/dist/quick-order.js +79 -4
- package/dist/quote-requests.d.ts +231 -17
- package/dist/quote-requests.js +111 -9
- package/dist/record-references.d.ts +15 -15
- package/dist/record-references.js +2 -3
- package/dist/record-rich-text.js +2 -1
- package/dist/returns.d.ts +214 -52
- package/dist/returns.js +143 -28
- package/dist/sales-channels.d.ts +34 -3
- package/dist/sales-channels.js +16 -1
- package/dist/saved-list-views.d.ts +28 -0
- package/dist/saved-list-views.js +14 -1
- package/dist/schema-extensions.d.ts +36 -0
- package/dist/schema-extensions.js +29 -0
- package/dist/scoped-write-encoding.d.ts +100 -0
- package/dist/scoped-write-encoding.js +135 -0
- package/dist/search.d.ts +18 -16
- package/dist/seo.d.ts +83 -30
- package/dist/seo.js +8 -1
- package/dist/settings.d.ts +173 -2
- package/dist/settings.js +53 -2
- package/dist/shopping-lists.d.ts +63 -4
- package/dist/shopping-lists.js +57 -3
- package/dist/storefront-cache-tags.d.ts +22 -0
- package/dist/storefront-cache-tags.js +12 -0
- package/dist/storefront-value-overrides.d.ts +18 -56
- package/dist/storefront-value-overrides.js +11 -86
- package/dist/tasks.d.ts +27 -27
- package/dist/taxes.d.ts +27 -0
- package/dist/taxes.js +4 -0
- package/dist/transactional-emails.d.ts +48 -22
- package/dist/webhooks.d.ts +75 -0
- package/dist/webhooks.js +24 -0
- package/package.json +5 -3
- package/dist/actor.d.ts.map +0 -1
- package/dist/actor.js.map +0 -1
- package/dist/addresses.d.ts.map +0 -1
- package/dist/addresses.js.map +0 -1
- package/dist/admin-actions.d.ts.map +0 -1
- package/dist/admin-actions.js.map +0 -1
- package/dist/admin-contributions.d.ts.map +0 -1
- package/dist/admin-contributions.js.map +0 -1
- package/dist/admin-feedback.d.ts.map +0 -1
- package/dist/admin-feedback.js.map +0 -1
- package/dist/admin-i18n.d.ts.map +0 -1
- package/dist/admin-i18n.js.map +0 -1
- package/dist/admin-name.d.ts.map +0 -1
- package/dist/admin-name.js.map +0 -1
- package/dist/admin-notifications.d.ts.map +0 -1
- package/dist/admin-notifications.js.map +0 -1
- package/dist/admin-preferences.d.ts.map +0 -1
- package/dist/admin-preferences.js.map +0 -1
- package/dist/admin-roles.d.ts.map +0 -1
- package/dist/admin-roles.js.map +0 -1
- package/dist/admin-search.d.ts.map +0 -1
- package/dist/admin-search.js.map +0 -1
- package/dist/admin-users.d.ts.map +0 -1
- package/dist/admin-users.js.map +0 -1
- package/dist/admin.d.ts.map +0 -1
- package/dist/admin.js.map +0 -1
- package/dist/analytics.d.ts.map +0 -1
- package/dist/analytics.js.map +0 -1
- package/dist/api-keys.d.ts.map +0 -1
- package/dist/api-keys.js.map +0 -1
- package/dist/assets-library.d.ts.map +0 -1
- package/dist/assets-library.js.map +0 -1
- package/dist/audit-logs.d.ts.map +0 -1
- package/dist/audit-logs.js.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/blog.d.ts.map +0 -1
- package/dist/blog.js.map +0 -1
- package/dist/capabilities.d.ts.map +0 -1
- package/dist/capabilities.js.map +0 -1
- package/dist/carts.d.ts.map +0 -1
- package/dist/carts.js.map +0 -1
- package/dist/catalog.d.ts.map +0 -1
- package/dist/catalog.js.map +0 -1
- package/dist/cms-brand.d.ts.map +0 -1
- package/dist/cms-brand.js.map +0 -1
- package/dist/cms-contact-form.d.ts.map +0 -1
- package/dist/cms-contact-form.js.map +0 -1
- package/dist/cms.d.ts.map +0 -1
- package/dist/cms.js.map +0 -1
- package/dist/common.d.ts.map +0 -1
- package/dist/common.js.map +0 -1
- package/dist/comparisons.d.ts.map +0 -1
- package/dist/comparisons.js.map +0 -1
- package/dist/credentials.d.ts.map +0 -1
- package/dist/credentials.js.map +0 -1
- package/dist/credit-limits.d.ts.map +0 -1
- package/dist/credit-limits.js.map +0 -1
- package/dist/crm-rich-text.d.ts.map +0 -1
- package/dist/crm-rich-text.js.map +0 -1
- package/dist/crm.d.ts.map +0 -1
- package/dist/crm.js.map +0 -1
- package/dist/currencies.d.ts.map +0 -1
- package/dist/currencies.js.map +0 -1
- package/dist/custom-fields.d.ts.map +0 -1
- package/dist/custom-fields.js.map +0 -1
- package/dist/customer-accounts.d.ts.map +0 -1
- package/dist/customer-accounts.js.map +0 -1
- package/dist/customers.d.ts.map +0 -1
- package/dist/customers.js.map +0 -1
- package/dist/dictionary.d.ts.map +0 -1
- package/dist/dictionary.js.map +0 -1
- package/dist/document-templates.d.ts.map +0 -1
- package/dist/document-templates.js.map +0 -1
- package/dist/document-values.d.ts.map +0 -1
- package/dist/document-values.js.map +0 -1
- package/dist/email-address.d.ts.map +0 -1
- package/dist/email-address.js.map +0 -1
- package/dist/email.d.ts.map +0 -1
- package/dist/email.js.map +0 -1
- package/dist/envelopes.d.ts.map +0 -1
- package/dist/envelopes.js.map +0 -1
- package/dist/environment-inputs.d.ts.map +0 -1
- package/dist/environment-inputs.js.map +0 -1
- package/dist/erp-connector.d.ts.map +0 -1
- package/dist/erp-connector.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/google-analytics.d.ts.map +0 -1
- package/dist/google-analytics.js.map +0 -1
- package/dist/google-tag-manager.d.ts.map +0 -1
- package/dist/google-tag-manager.js.map +0 -1
- package/dist/i18n.d.ts.map +0 -1
- package/dist/i18n.js.map +0 -1
- package/dist/import-export.d.ts.map +0 -1
- package/dist/import-export.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inventory.d.ts.map +0 -1
- package/dist/inventory.js.map +0 -1
- package/dist/invoice-ledger.d.ts.map +0 -1
- package/dist/invoice-ledger.js.map +0 -1
- package/dist/invoices.d.ts.map +0 -1
- package/dist/invoices.js.map +0 -1
- package/dist/kernel.d.ts.map +0 -1
- package/dist/kernel.js.map +0 -1
- package/dist/languages.d.ts.map +0 -1
- package/dist/languages.js.map +0 -1
- package/dist/line-groups.d.ts.map +0 -1
- package/dist/line-groups.js.map +0 -1
- package/dist/linkedin-ads.d.ts.map +0 -1
- package/dist/linkedin-ads.js.map +0 -1
- package/dist/localized-name.d.ts.map +0 -1
- package/dist/localized-name.js.map +0 -1
- package/dist/megamenu.d.ts.map +0 -1
- package/dist/megamenu.js.map +0 -1
- package/dist/meta-ads.d.ts.map +0 -1
- package/dist/meta-ads.js.map +0 -1
- package/dist/mfa.d.ts.map +0 -1
- package/dist/mfa.js.map +0 -1
- package/dist/modules.d.ts.map +0 -1
- package/dist/modules.js.map +0 -1
- package/dist/money-decimal.d.ts.map +0 -1
- package/dist/money-decimal.js.map +0 -1
- package/dist/money-input.d.ts.map +0 -1
- package/dist/money-input.js.map +0 -1
- package/dist/newsletter.d.ts.map +0 -1
- package/dist/newsletter.js.map +0 -1
- package/dist/order-minimums.d.ts.map +0 -1
- package/dist/order-minimums.js.map +0 -1
- package/dist/orders.d.ts.map +0 -1
- package/dist/orders.js.map +0 -1
- package/dist/organizations.d.ts.map +0 -1
- package/dist/organizations.js.map +0 -1
- package/dist/page-builder-props.d.ts.map +0 -1
- package/dist/page-builder-props.js.map +0 -1
- package/dist/page-builder-values.d.ts.map +0 -1
- package/dist/page-builder-values.js.map +0 -1
- package/dist/pagination.d.ts.map +0 -1
- package/dist/pagination.js.map +0 -1
- package/dist/payment-methods.d.ts.map +0 -1
- package/dist/payment-methods.js.map +0 -1
- package/dist/payment-return-url.d.ts.map +0 -1
- package/dist/payment-return-url.js.map +0 -1
- package/dist/payments.d.ts.map +0 -1
- package/dist/payments.js.map +0 -1
- package/dist/pim-connector.d.ts.map +0 -1
- package/dist/pim-connector.js.map +0 -1
- package/dist/pim-field-path.d.ts.map +0 -1
- package/dist/pim-field-path.js.map +0 -1
- package/dist/platform-info.d.ts.map +0 -1
- package/dist/platform-info.js.map +0 -1
- package/dist/platform-language.d.ts.map +0 -1
- package/dist/platform-language.js.map +0 -1
- package/dist/price-book-decimal.d.ts.map +0 -1
- package/dist/price-book-decimal.js.map +0 -1
- package/dist/price-books.d.ts.map +0 -1
- package/dist/price-books.js.map +0 -1
- package/dist/price-lists.d.ts.map +0 -1
- package/dist/price-lists.js.map +0 -1
- package/dist/product-feeds.d.ts.map +0 -1
- package/dist/product-feeds.js.map +0 -1
- package/dist/product-scope-overrides.d.ts.map +0 -1
- package/dist/product-scope-overrides.js.map +0 -1
- package/dist/product-scopes.d.ts.map +0 -1
- package/dist/product-scopes.js.map +0 -1
- package/dist/product-summary-text.d.ts.map +0 -1
- package/dist/product-summary-text.js.map +0 -1
- package/dist/product-url-keys.d.ts.map +0 -1
- package/dist/product-url-keys.js.map +0 -1
- package/dist/product-value-resolver.d.ts.map +0 -1
- package/dist/product-value-resolver.js.map +0 -1
- package/dist/projects.d.ts.map +0 -1
- package/dist/projects.js.map +0 -1
- package/dist/promotions.d.ts.map +0 -1
- package/dist/promotions.js.map +0 -1
- package/dist/prompt-actions.d.ts.map +0 -1
- package/dist/prompt-actions.js.map +0 -1
- package/dist/pwa.d.ts.map +0 -1
- package/dist/pwa.js.map +0 -1
- package/dist/quick-order.d.ts.map +0 -1
- package/dist/quick-order.js.map +0 -1
- package/dist/quote-requests.d.ts.map +0 -1
- package/dist/quote-requests.js.map +0 -1
- package/dist/record-references.d.ts.map +0 -1
- package/dist/record-references.js.map +0 -1
- package/dist/record-rich-text.d.ts.map +0 -1
- package/dist/record-rich-text.js.map +0 -1
- package/dist/returns.d.ts.map +0 -1
- package/dist/returns.js.map +0 -1
- package/dist/sales-channels.d.ts.map +0 -1
- package/dist/sales-channels.js.map +0 -1
- package/dist/saved-list-views.d.ts.map +0 -1
- package/dist/saved-list-views.js.map +0 -1
- package/dist/scope-notice.d.ts.map +0 -1
- package/dist/scope-notice.js.map +0 -1
- package/dist/scoped-translations.d.ts +0 -48
- package/dist/scoped-translations.d.ts.map +0 -1
- package/dist/scoped-translations.js +0 -78
- package/dist/scoped-translations.js.map +0 -1
- package/dist/search.d.ts.map +0 -1
- package/dist/search.js.map +0 -1
- package/dist/seo.d.ts.map +0 -1
- package/dist/seo.js.map +0 -1
- package/dist/settings.d.ts.map +0 -1
- package/dist/settings.js.map +0 -1
- package/dist/shipments.d.ts.map +0 -1
- package/dist/shipments.js.map +0 -1
- package/dist/shipping-methods.d.ts.map +0 -1
- package/dist/shipping-methods.js.map +0 -1
- package/dist/shopping-lists.d.ts.map +0 -1
- package/dist/shopping-lists.js.map +0 -1
- package/dist/storefront-cache-tags.d.ts.map +0 -1
- package/dist/storefront-cache-tags.js.map +0 -1
- package/dist/storefront-language-path.d.ts.map +0 -1
- package/dist/storefront-language-path.js.map +0 -1
- package/dist/storefront-value-overrides.d.ts.map +0 -1
- package/dist/storefront-value-overrides.js.map +0 -1
- package/dist/tasks.d.ts.map +0 -1
- package/dist/tasks.js.map +0 -1
- package/dist/taxes.d.ts.map +0 -1
- package/dist/taxes.js.map +0 -1
- package/dist/text-normalization.d.ts.map +0 -1
- package/dist/text-normalization.js.map +0 -1
- package/dist/transactional-emails.d.ts.map +0 -1
- package/dist/transactional-emails.js.map +0 -1
- package/dist/webhooks.d.ts.map +0 -1
- package/dist/webhooks.js.map +0 -1
package/dist/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.
|
|
@@ -421,6 +443,33 @@ export const ExclusiveCapabilitySchema = z.object({
|
|
|
421
443
|
/** The code raised when a second member is activated. Owned by this module. */
|
|
422
444
|
errorCode: z.string().regex(errorCodeRe),
|
|
423
445
|
});
|
|
446
|
+
/**
|
|
447
|
+
* The shape of an **organization permission** code (`specs/170-organization-roles/`,
|
|
448
|
+
* FR-020, research R-2): `<module>.<action>`, lower snake case, exactly one dot.
|
|
449
|
+
*
|
|
450
|
+
* The operator vocabulary is `<area>:<action>` (`permissions` below). Two
|
|
451
|
+
* shapes make a mix-up visible in review, and the permission inventory's
|
|
452
|
+
* `cross-vocabulary` finding makes it fail the build.
|
|
453
|
+
*/
|
|
454
|
+
export const ORGANIZATION_PERMISSION_CODE = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_]*$/;
|
|
455
|
+
/**
|
|
456
|
+
* One organization permission a module declares — a buyer action its routes
|
|
457
|
+
* or services gate (`contracts/organization-permissions-manifest.md` §1).
|
|
458
|
+
*
|
|
459
|
+
* `label` and `description` are the English fallbacks; the translations live
|
|
460
|
+
* in the declaring module's own bundle under
|
|
461
|
+
* `organizationPermissions.<code>.label` and `.description`. `memberDefault`
|
|
462
|
+
* says whether an Organization's *Member* role holds the code from the moment
|
|
463
|
+
* it is first offered (FR-021, research R-17).
|
|
464
|
+
*/
|
|
465
|
+
export const moduleOrganizationPermissionDeclarationSchema = z
|
|
466
|
+
.object({
|
|
467
|
+
code: z.string().regex(ORGANIZATION_PERMISSION_CODE),
|
|
468
|
+
label: z.string().min(1).max(160),
|
|
469
|
+
description: z.string().min(1).max(500),
|
|
470
|
+
memberDefault: z.boolean(),
|
|
471
|
+
})
|
|
472
|
+
.strict();
|
|
424
473
|
export const ModuleManifestSchema = z.object({
|
|
425
474
|
id: z.string().regex(moduleIdRe),
|
|
426
475
|
name: z.string().min(1).max(120),
|
|
@@ -495,6 +544,17 @@ export const ModuleManifestSchema = z.object({
|
|
|
495
544
|
* when the module is enabled (feature 026).
|
|
496
545
|
*/
|
|
497
546
|
permissions: z.array(modulePermissionDeclarationSchema).optional(),
|
|
547
|
+
/**
|
|
548
|
+
* The **organization** permissions this module declares — the buyer actions
|
|
549
|
+
* its routes and services gate (`specs/170-organization-roles/`, FR-020). A
|
|
550
|
+
* different vocabulary from `permissions` above, which is the operator's;
|
|
551
|
+
* the two never meet. Each code sits in this module's own namespace
|
|
552
|
+
* (`<id>.<action>`), which {@link defineModuleManifest} enforces.
|
|
553
|
+
*
|
|
554
|
+
* Absent means "this module gates no buyer action", which is true of most
|
|
555
|
+
* modules and is not a finding.
|
|
556
|
+
*/
|
|
557
|
+
organizationPermissions: z.array(moduleOrganizationPermissionDeclarationSchema).optional(),
|
|
498
558
|
/**
|
|
499
559
|
* Per-module transactional email declarations (feature 047). Each entry is
|
|
500
560
|
* reconciled into `transactional_emails` at boot; default subject/content are
|
|
@@ -611,6 +671,25 @@ export const ModuleManifestSchema = z.object({
|
|
|
611
671
|
* is true of most modules and is not a finding.
|
|
612
672
|
*/
|
|
613
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(),
|
|
614
693
|
});
|
|
615
694
|
/**
|
|
616
695
|
* The three cross-field activation rules (feature 073,
|
|
@@ -790,6 +869,35 @@ function assertNonBindingRules(m) {
|
|
|
790
869
|
* condition it on, and adding one would be a self-certified exemption issued by
|
|
791
870
|
* the measured party.
|
|
792
871
|
*/
|
|
872
|
+
/**
|
|
873
|
+
* The organization-permission rules `defineModuleManifest` can decide from one
|
|
874
|
+
* manifest (`contracts/organization-permissions-manifest.md` §1; research R-2):
|
|
875
|
+
* the code's shape, its namespace, and no code twice. Whether a code is also an
|
|
876
|
+
* operator code, enforced somewhere and labelled in every language needs the
|
|
877
|
+
* whole tree, and is the permission inventory's.
|
|
878
|
+
*/
|
|
879
|
+
function assertOrganizationPermissionRules(m) {
|
|
880
|
+
const seen = new Set();
|
|
881
|
+
for (const declaration of m.organizationPermissions ?? []) {
|
|
882
|
+
const code = declaration.code;
|
|
883
|
+
if (!ORGANIZATION_PERMISSION_CODE.test(code)) {
|
|
884
|
+
throw new Error(`[contracts/modules] manifest "${m.id}" declares organization permission ` +
|
|
885
|
+
`"${code}", which is not \`<module>.<action>\` in lower snake case ` +
|
|
886
|
+
`(${String(ORGANIZATION_PERMISSION_CODE)}) — the operator vocabulary is ` +
|
|
887
|
+
'`<area>:<action>`, and the two never meet.');
|
|
888
|
+
}
|
|
889
|
+
if (code.slice(0, code.indexOf('.')) !== m.id) {
|
|
890
|
+
throw new Error(`[contracts/modules] manifest "${m.id}" declares organization permission ` +
|
|
891
|
+
`"${code}", which is outside its own namespace ("${m.id}.<action>") — a ` +
|
|
892
|
+
'code is declared by the module whose buyer action it gates.');
|
|
893
|
+
}
|
|
894
|
+
if (seen.has(code)) {
|
|
895
|
+
throw new Error(`[contracts/modules] manifest "${m.id}" declares organization permission ` +
|
|
896
|
+
`"${code}" twice — one code has one label, one description and one default.`);
|
|
897
|
+
}
|
|
898
|
+
seen.add(code);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
793
901
|
function assertErrorCodeRules(m) {
|
|
794
902
|
const seenCodes = new Set();
|
|
795
903
|
for (const declaration of m.errorCodes ?? []) {
|
|
@@ -989,6 +1097,21 @@ function assertEnvironmentInputRules(m) {
|
|
|
989
1097
|
`it here would be one fact with two homes and two descriptions.`);
|
|
990
1098
|
}
|
|
991
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
|
+
}
|
|
992
1115
|
/**
|
|
993
1116
|
* Identity-with-validation helper for module authors. Modules export a
|
|
994
1117
|
* single `manifest` constant via this helper so TypeScript inference is
|
|
@@ -1026,9 +1149,11 @@ export function defineModuleManifest(m) {
|
|
|
1026
1149
|
assertNonBindingRules(m);
|
|
1027
1150
|
assertCapabilityRules(m);
|
|
1028
1151
|
assertErrorCodeRules(m);
|
|
1152
|
+
assertOrganizationPermissionRules(m);
|
|
1029
1153
|
assertBlockRules(m);
|
|
1030
1154
|
assertDemoRules(m);
|
|
1031
1155
|
assertEnvironmentInputRules(m);
|
|
1156
|
+
assertHookableActionRules(m);
|
|
1032
1157
|
return ModuleManifestSchema.parse(m);
|
|
1033
1158
|
}
|
|
1034
1159
|
// ---------------------------------------------------------------------------
|
package/dist/money-decimal.d.ts
CHANGED
|
@@ -159,4 +159,58 @@ export declare function netForGrossAtRate(gross: string | number, rate: string |
|
|
|
159
159
|
vat: string;
|
|
160
160
|
exact: boolean;
|
|
161
161
|
};
|
|
162
|
+
/** An order-level charge that follows the goods' VAT rates (issue #904). */
|
|
163
|
+
export type OrderChargeKind = 'delivery' | 'payment_surcharge';
|
|
164
|
+
/** One part of an order-level charge at one VAT rate: {@link chargesByRate}'s answer, two-place amounts. */
|
|
165
|
+
export interface ChargeByRate {
|
|
166
|
+
kind: OrderChargeKind;
|
|
167
|
+
/** The rate as a fraction, keyed as {@link vatByRate}'s rows key it (`0.23`, `0`). */
|
|
168
|
+
rate: string;
|
|
169
|
+
/** The part of the charge's gross allocated to this rate. */
|
|
170
|
+
gross: string;
|
|
171
|
+
/** The part's net, by the row-target rule. */
|
|
172
|
+
net: string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* **Allocates order-level charges — delivery and the payment surcharge — over
|
|
176
|
+
* the goods' VAT rates** (issue #904; owner ruling of 2026-11-07: a charge
|
|
177
|
+
* takes the rate of the goods it accompanies). A charge's price is a **gross**,
|
|
178
|
+
* what the buyer pays (owner ruling E-904-T3 of 2026-11-08); this decides each
|
|
179
|
+
* part's gross and net, and the VAT is then {@link vatByRate} over the goods and
|
|
180
|
+
* the parts together — no second VAT computation exists.
|
|
181
|
+
*
|
|
182
|
+
* The rules, in order:
|
|
183
|
+
* 1. **Weights.** `W_r` is the sum of the goods nets at rate `r` (each net read
|
|
184
|
+
* at two places). The order-level discount is not taken off.
|
|
185
|
+
* 2. **Split each charge's gross `G`, in cents.** Each part is
|
|
186
|
+
* `floor(G × W_r / ΣW)`; the cents left over go one at a time to the largest
|
|
187
|
+
* remainders, a tie to the higher rate. The parts add up to `G` exactly; a
|
|
188
|
+
* part of 0.00 is dropped, and so is a charge of 0.00.
|
|
189
|
+
* 3. **If `ΣW = 0`** (every goods line priced at 0.00), the whole charge goes
|
|
190
|
+
* to the highest rate among the goods lines.
|
|
191
|
+
* 4. **The part's net, by the row target.** `T_r` is the goods' row gross at
|
|
192
|
+
* `r` plus the parts already placed at `r` plus this part; the part's net is
|
|
193
|
+
* `netForGrossAtRate(T_r).net` less the row's net so far. So a rate's row
|
|
194
|
+
* gross is the goods' row gross plus the charges' gross wherever the one VAT
|
|
195
|
+
* method can produce that gross at all; where it cannot, the row is a grosz
|
|
196
|
+
* off and so is the total (owner ruling E-904-6 of 2026-11-08), and a
|
|
197
|
+
* part's own gross is informational, as a line's is.
|
|
198
|
+
* A part's net may be 0.00; a part is dropped only when its gross is 0.00,
|
|
199
|
+
* never by its net.
|
|
200
|
+
*
|
|
201
|
+
* Charges are taken in input order, and their parts are answered in that order,
|
|
202
|
+
* each charge's parts by ascending rate. A negative charge, or a non-zero charge
|
|
203
|
+
* with no goods line to follow, is refused.
|
|
204
|
+
*/
|
|
205
|
+
export declare function chargesByRate(input: {
|
|
206
|
+
goods: ReadonlyArray<{
|
|
207
|
+
net: string | number;
|
|
208
|
+
rate: string | number;
|
|
209
|
+
}>;
|
|
210
|
+
charges: ReadonlyArray<{
|
|
211
|
+
kind: OrderChargeKind;
|
|
212
|
+
gross: string | number;
|
|
213
|
+
}>;
|
|
214
|
+
unit: 'fraction' | 'percent';
|
|
215
|
+
}): ChargeByRate[];
|
|
162
216
|
//# sourceMappingURL=money-decimal.d.ts.map
|
package/dist/money-decimal.js
CHANGED
|
@@ -362,4 +362,99 @@ export function netForGrossAtRate(gross, rate, unit) {
|
|
|
362
362
|
}
|
|
363
363
|
return { net: nearest, vat: moneyDifference(target, nearest), exact: false };
|
|
364
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* **Allocates order-level charges — delivery and the payment surcharge — over
|
|
367
|
+
* the goods' VAT rates** (issue #904; owner ruling of 2026-11-07: a charge
|
|
368
|
+
* takes the rate of the goods it accompanies). A charge's price is a **gross**,
|
|
369
|
+
* what the buyer pays (owner ruling E-904-T3 of 2026-11-08); this decides each
|
|
370
|
+
* part's gross and net, and the VAT is then {@link vatByRate} over the goods and
|
|
371
|
+
* the parts together — no second VAT computation exists.
|
|
372
|
+
*
|
|
373
|
+
* The rules, in order:
|
|
374
|
+
* 1. **Weights.** `W_r` is the sum of the goods nets at rate `r` (each net read
|
|
375
|
+
* at two places). The order-level discount is not taken off.
|
|
376
|
+
* 2. **Split each charge's gross `G`, in cents.** Each part is
|
|
377
|
+
* `floor(G × W_r / ΣW)`; the cents left over go one at a time to the largest
|
|
378
|
+
* remainders, a tie to the higher rate. The parts add up to `G` exactly; a
|
|
379
|
+
* part of 0.00 is dropped, and so is a charge of 0.00.
|
|
380
|
+
* 3. **If `ΣW = 0`** (every goods line priced at 0.00), the whole charge goes
|
|
381
|
+
* to the highest rate among the goods lines.
|
|
382
|
+
* 4. **The part's net, by the row target.** `T_r` is the goods' row gross at
|
|
383
|
+
* `r` plus the parts already placed at `r` plus this part; the part's net is
|
|
384
|
+
* `netForGrossAtRate(T_r).net` less the row's net so far. So a rate's row
|
|
385
|
+
* gross is the goods' row gross plus the charges' gross wherever the one VAT
|
|
386
|
+
* method can produce that gross at all; where it cannot, the row is a grosz
|
|
387
|
+
* off and so is the total (owner ruling E-904-6 of 2026-11-08), and a
|
|
388
|
+
* part's own gross is informational, as a line's is.
|
|
389
|
+
* A part's net may be 0.00; a part is dropped only when its gross is 0.00,
|
|
390
|
+
* never by its net.
|
|
391
|
+
*
|
|
392
|
+
* Charges are taken in input order, and their parts are answered in that order,
|
|
393
|
+
* each charge's parts by ascending rate. A negative charge, or a non-zero charge
|
|
394
|
+
* with no goods line to follow, is refused.
|
|
395
|
+
*/
|
|
396
|
+
export function chargesByRate(input) {
|
|
397
|
+
const centsOf = (value) => round(exact(value), 2).digits;
|
|
398
|
+
const fromCents = (digits) => render({ digits, scale: 2 });
|
|
399
|
+
// Rule 1: the goods nets per rate, in cents, and each rate's goods row.
|
|
400
|
+
const weights = new Map();
|
|
401
|
+
for (const line of input.goods) {
|
|
402
|
+
const rate = rateKey(rateFraction(line.rate, input.unit));
|
|
403
|
+
const key = render(rate);
|
|
404
|
+
const net = centsOf(line.net);
|
|
405
|
+
if (net < 0n)
|
|
406
|
+
throw new Error(`Not a non-negative goods net: "${String(line.net)}"`);
|
|
407
|
+
const entry = weights.get(key) ?? { rate, weight: 0n };
|
|
408
|
+
entry.weight += net;
|
|
409
|
+
weights.set(key, entry);
|
|
410
|
+
}
|
|
411
|
+
// Higher rate first: the order the tie-break reads.
|
|
412
|
+
const rates = [...weights.entries()].sort((a, b) => compareDecimals(b[0], a[0]));
|
|
413
|
+
const total = rates.reduce((acc, [, e]) => acc + e.weight, 0n);
|
|
414
|
+
const goodsRows = new Map(vatByRate(input.goods, input.unit).rows.map((r) => [r.rate, r]));
|
|
415
|
+
const row = new Map(rates.map(([key]) => [key, { net: centsOf(goodsRows.get(key).net), gross: centsOf(goodsRows.get(key).gross) }]));
|
|
416
|
+
const answer = [];
|
|
417
|
+
for (const charge of input.charges) {
|
|
418
|
+
const gross = centsOf(charge.gross);
|
|
419
|
+
if (gross < 0n)
|
|
420
|
+
throw new Error(`Not a non-negative charge: "${String(charge.gross)}"`);
|
|
421
|
+
if (gross === 0n)
|
|
422
|
+
continue;
|
|
423
|
+
if (rates.length === 0)
|
|
424
|
+
throw new Error(`No goods line for the ${charge.kind} charge to follow`);
|
|
425
|
+
// Rule 2 (and rule 3 when no goods line carries a value).
|
|
426
|
+
let parts;
|
|
427
|
+
if (total === 0n) {
|
|
428
|
+
parts = [{ key: rates[0][0], cents: gross }];
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
const shares = rates.map(([key, e], index) => ({
|
|
432
|
+
key,
|
|
433
|
+
index,
|
|
434
|
+
cents: (gross * e.weight) / total,
|
|
435
|
+
remainder: (gross * e.weight) % total,
|
|
436
|
+
}));
|
|
437
|
+
let left = gross - shares.reduce((acc, s) => acc + s.cents, 0n);
|
|
438
|
+
const byRemainder = [...shares].sort((a, b) => a.remainder === b.remainder ? a.index - b.index : a.remainder > b.remainder ? -1 : 1);
|
|
439
|
+
for (const share of byRemainder) {
|
|
440
|
+
if (left === 0n)
|
|
441
|
+
break;
|
|
442
|
+
share.cents += 1n;
|
|
443
|
+
left -= 1n;
|
|
444
|
+
}
|
|
445
|
+
parts = shares;
|
|
446
|
+
}
|
|
447
|
+
// Rule 4, by ascending rate in the answer.
|
|
448
|
+
for (const part of [...parts].reverse()) {
|
|
449
|
+
if (part.cents === 0n)
|
|
450
|
+
continue;
|
|
451
|
+
const current = row.get(part.key);
|
|
452
|
+
const target = current.gross + part.cents;
|
|
453
|
+
const rowNet = centsOf(netForGrossAtRate(fromCents(target), part.key, 'fraction').net);
|
|
454
|
+
answer.push({ kind: charge.kind, rate: part.key, gross: fromCents(part.cents), net: fromCents(rowNet - current.net) });
|
|
455
|
+
row.set(part.key, { net: rowNet, gross: target });
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return answer;
|
|
459
|
+
}
|
|
365
460
|
//# sourceMappingURL=money-decimal.js.map
|
package/dist/newsletter.d.ts
CHANGED
|
@@ -33,9 +33,9 @@ export declare const campaignTargetTypeSchema: z.ZodEnum<{
|
|
|
33
33
|
export type CampaignTargetType = z.infer<typeof campaignTargetTypeSchema>;
|
|
34
34
|
export declare const campaignStatusSchema: z.ZodEnum<{
|
|
35
35
|
cancelled: "cancelled";
|
|
36
|
+
scheduled: "scheduled";
|
|
36
37
|
draft: "draft";
|
|
37
38
|
sent: "sent";
|
|
38
|
-
scheduled: "scheduled";
|
|
39
39
|
sending: "sending";
|
|
40
40
|
}>;
|
|
41
41
|
export type CampaignStatus = z.infer<typeof campaignStatusSchema>;
|
|
@@ -58,8 +58,8 @@ export declare const reentryPolicySchema: z.ZodEnum<{
|
|
|
58
58
|
export type ReentryPolicy = z.infer<typeof reentryPolicySchema>;
|
|
59
59
|
export declare const sendRecordStatusSchema: z.ZodEnum<{
|
|
60
60
|
failed: "failed";
|
|
61
|
-
sent: "sent";
|
|
62
61
|
queued: "queued";
|
|
62
|
+
sent: "sent";
|
|
63
63
|
bounced: "bounced";
|
|
64
64
|
complained: "complained";
|
|
65
65
|
}>;
|
|
@@ -211,9 +211,9 @@ export declare const campaignSummarySchema: z.ZodObject<{
|
|
|
211
211
|
subject: z.ZodString;
|
|
212
212
|
status: z.ZodEnum<{
|
|
213
213
|
cancelled: "cancelled";
|
|
214
|
+
scheduled: "scheduled";
|
|
214
215
|
draft: "draft";
|
|
215
216
|
sent: "sent";
|
|
216
|
-
scheduled: "scheduled";
|
|
217
217
|
sending: "sending";
|
|
218
218
|
}>;
|
|
219
219
|
targetType: z.ZodEnum<{
|
|
@@ -246,9 +246,9 @@ export declare const campaignDetailSchema: z.ZodObject<{
|
|
|
246
246
|
subject: z.ZodString;
|
|
247
247
|
status: z.ZodEnum<{
|
|
248
248
|
cancelled: "cancelled";
|
|
249
|
+
scheduled: "scheduled";
|
|
249
250
|
draft: "draft";
|
|
250
251
|
sent: "sent";
|
|
251
|
-
scheduled: "scheduled";
|
|
252
252
|
sending: "sending";
|
|
253
253
|
}>;
|
|
254
254
|
targetType: z.ZodEnum<{
|