@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.
Files changed (347) hide show
  1. package/dist/accept-language.d.ts +31 -0
  2. package/dist/accept-language.js +64 -0
  3. package/dist/admin-actions.d.ts +2 -0
  4. package/dist/admin-actions.js +18 -0
  5. package/dist/admin-contributions.d.ts +37 -5
  6. package/dist/admin-contributions.js +9 -2
  7. package/dist/admin-roles.d.ts +9 -0
  8. package/dist/admin.d.ts +37 -0
  9. package/dist/admin.js +19 -0
  10. package/dist/api-keys.d.ts +22 -0
  11. package/dist/api-keys.js +4 -0
  12. package/dist/assets-library.d.ts +19 -0
  13. package/dist/assets-library.js +14 -0
  14. package/dist/auth.d.ts +9 -0
  15. package/dist/auth.js +9 -0
  16. package/dist/carts.d.ts +30 -1
  17. package/dist/carts.js +20 -5
  18. package/dist/catalog.d.ts +61 -22
  19. package/dist/catalog.js +32 -6
  20. package/dist/cms.d.ts +33 -3
  21. package/dist/cms.js +15 -0
  22. package/dist/command-hooks.d.ts +301 -0
  23. package/dist/command-hooks.js +248 -0
  24. package/dist/comparisons.d.ts +14 -14
  25. package/dist/credit-limits.d.ts +21 -0
  26. package/dist/credit-limits.js +21 -0
  27. package/dist/crm.d.ts +81 -55
  28. package/dist/crm.js +15 -5
  29. package/dist/custom-fields.d.ts +403 -49
  30. package/dist/custom-fields.js +127 -0
  31. package/dist/customer-accounts.d.ts +138 -0
  32. package/dist/customer-accounts.js +4 -0
  33. package/dist/customer-notifications.d.ts +143 -0
  34. package/dist/customer-notifications.js +41 -0
  35. package/dist/customers.d.ts +52 -0
  36. package/dist/customers.js +53 -0
  37. package/dist/dictionary.d.ts +53 -0
  38. package/dist/dictionary.js +25 -0
  39. package/dist/document-templates.d.ts +4 -4
  40. package/dist/email.d.ts +34 -0
  41. package/dist/email.js +6 -0
  42. package/dist/errors.d.ts +312 -2
  43. package/dist/errors.js +377 -2
  44. package/dist/forms.d.ts +88 -88
  45. package/dist/i18n.d.ts +34 -0
  46. package/dist/i18n.js +15 -0
  47. package/dist/index.d.ts +7 -1
  48. package/dist/index.js +12 -1
  49. package/dist/invoice-ledger.d.ts +6 -6
  50. package/dist/invoices.d.ts +126 -0
  51. package/dist/invoices.js +49 -0
  52. package/dist/line-bounds.d.ts +53 -0
  53. package/dist/line-bounds.js +65 -0
  54. package/dist/megamenu.d.ts +27 -27
  55. package/dist/mfa.d.ts +86 -0
  56. package/dist/mfa.js +90 -0
  57. package/dist/modules.d.ts +21 -5
  58. package/dist/modules.js +60 -3
  59. package/dist/orders.d.ts +141 -0
  60. package/dist/orders.js +80 -3
  61. package/dist/organization-hooks.d.ts +99 -0
  62. package/dist/organization-hooks.js +22 -0
  63. package/dist/organization-registry-lookup.d.ts +5 -5
  64. package/dist/organization-roles.d.ts +1 -0
  65. package/dist/organization-roles.js +7 -0
  66. package/dist/organizations.d.ts +954 -17
  67. package/dist/organizations.js +229 -8
  68. package/dist/price-books.d.ts +173 -25
  69. package/dist/price-books.js +41 -0
  70. package/dist/price-lists.d.ts +5 -2
  71. package/dist/product-feeds.d.ts +157 -8
  72. package/dist/product-feeds.js +41 -2
  73. package/dist/product-scopes.d.ts +17 -0
  74. package/dist/product-scopes.js +31 -5
  75. package/dist/projects.d.ts +61 -28
  76. package/dist/projects.js +47 -9
  77. package/dist/promotions.d.ts +157 -5
  78. package/dist/promotions.js +23 -1
  79. package/dist/pwa.d.ts +39 -0
  80. package/dist/quick-order.d.ts +9 -3
  81. package/dist/quick-order.js +4 -3
  82. package/dist/quote-requests.d.ts +168 -5
  83. package/dist/quote-requests.js +69 -8
  84. package/dist/record-references.d.ts +15 -15
  85. package/dist/returns.d.ts +6 -0
  86. package/dist/returns.js +4 -2
  87. package/dist/sales-channels.d.ts +34 -3
  88. package/dist/sales-channels.js +16 -1
  89. package/dist/schema-extensions.d.ts +36 -0
  90. package/dist/schema-extensions.js +29 -0
  91. package/dist/seo.d.ts +2 -2
  92. package/dist/settings.d.ts +44 -2
  93. package/dist/settings.js +17 -2
  94. package/dist/shopping-lists.d.ts +39 -1
  95. package/dist/shopping-lists.js +37 -3
  96. package/dist/storefront-cache-tags.d.ts +10 -0
  97. package/dist/tasks.d.ts +21 -21
  98. package/dist/taxes.d.ts +27 -0
  99. package/dist/taxes.js +4 -0
  100. package/dist/transactional-emails.d.ts +39 -13
  101. package/dist/webhooks.d.ts +75 -0
  102. package/dist/webhooks.js +24 -0
  103. package/package.json +4 -2
  104. package/dist/actor.d.ts.map +0 -1
  105. package/dist/actor.js.map +0 -1
  106. package/dist/addresses.d.ts.map +0 -1
  107. package/dist/addresses.js.map +0 -1
  108. package/dist/admin-actions.d.ts.map +0 -1
  109. package/dist/admin-actions.js.map +0 -1
  110. package/dist/admin-contributions.d.ts.map +0 -1
  111. package/dist/admin-contributions.js.map +0 -1
  112. package/dist/admin-feedback.d.ts.map +0 -1
  113. package/dist/admin-feedback.js.map +0 -1
  114. package/dist/admin-i18n.d.ts.map +0 -1
  115. package/dist/admin-i18n.js.map +0 -1
  116. package/dist/admin-name.d.ts.map +0 -1
  117. package/dist/admin-name.js.map +0 -1
  118. package/dist/admin-notifications.d.ts.map +0 -1
  119. package/dist/admin-notifications.js.map +0 -1
  120. package/dist/admin-preferences.d.ts.map +0 -1
  121. package/dist/admin-preferences.js.map +0 -1
  122. package/dist/admin-roles.d.ts.map +0 -1
  123. package/dist/admin-roles.js.map +0 -1
  124. package/dist/admin-search.d.ts.map +0 -1
  125. package/dist/admin-search.js.map +0 -1
  126. package/dist/admin-users.d.ts.map +0 -1
  127. package/dist/admin-users.js.map +0 -1
  128. package/dist/admin.d.ts.map +0 -1
  129. package/dist/admin.js.map +0 -1
  130. package/dist/analytics.d.ts.map +0 -1
  131. package/dist/analytics.js.map +0 -1
  132. package/dist/api-keys.d.ts.map +0 -1
  133. package/dist/api-keys.js.map +0 -1
  134. package/dist/assets-library.d.ts.map +0 -1
  135. package/dist/assets-library.js.map +0 -1
  136. package/dist/audit-logs.d.ts.map +0 -1
  137. package/dist/audit-logs.js.map +0 -1
  138. package/dist/auth.d.ts.map +0 -1
  139. package/dist/auth.js.map +0 -1
  140. package/dist/blog.d.ts.map +0 -1
  141. package/dist/blog.js.map +0 -1
  142. package/dist/capabilities.d.ts.map +0 -1
  143. package/dist/capabilities.js.map +0 -1
  144. package/dist/carts.d.ts.map +0 -1
  145. package/dist/carts.js.map +0 -1
  146. package/dist/catalog.d.ts.map +0 -1
  147. package/dist/catalog.js.map +0 -1
  148. package/dist/cms-brand.d.ts.map +0 -1
  149. package/dist/cms-brand.js.map +0 -1
  150. package/dist/cms-contact-form.d.ts.map +0 -1
  151. package/dist/cms-contact-form.js.map +0 -1
  152. package/dist/cms.d.ts.map +0 -1
  153. package/dist/cms.js.map +0 -1
  154. package/dist/common.d.ts.map +0 -1
  155. package/dist/common.js.map +0 -1
  156. package/dist/comparisons.d.ts.map +0 -1
  157. package/dist/comparisons.js.map +0 -1
  158. package/dist/credentials.d.ts.map +0 -1
  159. package/dist/credentials.js.map +0 -1
  160. package/dist/credit-limits.d.ts.map +0 -1
  161. package/dist/credit-limits.js.map +0 -1
  162. package/dist/crm-rich-text.d.ts.map +0 -1
  163. package/dist/crm-rich-text.js.map +0 -1
  164. package/dist/crm.d.ts.map +0 -1
  165. package/dist/crm.js.map +0 -1
  166. package/dist/currencies.d.ts.map +0 -1
  167. package/dist/currencies.js.map +0 -1
  168. package/dist/custom-fields.d.ts.map +0 -1
  169. package/dist/custom-fields.js.map +0 -1
  170. package/dist/customer-accounts.d.ts.map +0 -1
  171. package/dist/customer-accounts.js.map +0 -1
  172. package/dist/customers.d.ts.map +0 -1
  173. package/dist/customers.js.map +0 -1
  174. package/dist/dictionary.d.ts.map +0 -1
  175. package/dist/dictionary.js.map +0 -1
  176. package/dist/document-templates.d.ts.map +0 -1
  177. package/dist/document-templates.js.map +0 -1
  178. package/dist/document-values.d.ts.map +0 -1
  179. package/dist/document-values.js.map +0 -1
  180. package/dist/email-address.d.ts.map +0 -1
  181. package/dist/email-address.js.map +0 -1
  182. package/dist/email.d.ts.map +0 -1
  183. package/dist/email.js.map +0 -1
  184. package/dist/envelopes.d.ts.map +0 -1
  185. package/dist/envelopes.js.map +0 -1
  186. package/dist/environment-inputs.d.ts.map +0 -1
  187. package/dist/environment-inputs.js.map +0 -1
  188. package/dist/erp-connector.d.ts.map +0 -1
  189. package/dist/erp-connector.js.map +0 -1
  190. package/dist/errors.d.ts.map +0 -1
  191. package/dist/errors.js.map +0 -1
  192. package/dist/forms-logic.d.ts.map +0 -1
  193. package/dist/forms-logic.fixtures.d.ts.map +0 -1
  194. package/dist/forms-logic.fixtures.js.map +0 -1
  195. package/dist/forms-logic.js.map +0 -1
  196. package/dist/forms.d.ts.map +0 -1
  197. package/dist/forms.js.map +0 -1
  198. package/dist/google-analytics.d.ts.map +0 -1
  199. package/dist/google-analytics.js.map +0 -1
  200. package/dist/google-tag-manager.d.ts.map +0 -1
  201. package/dist/google-tag-manager.js.map +0 -1
  202. package/dist/i18n.d.ts.map +0 -1
  203. package/dist/i18n.js.map +0 -1
  204. package/dist/import-export.d.ts.map +0 -1
  205. package/dist/import-export.js.map +0 -1
  206. package/dist/index.d.ts.map +0 -1
  207. package/dist/index.js.map +0 -1
  208. package/dist/inventory.d.ts.map +0 -1
  209. package/dist/inventory.js.map +0 -1
  210. package/dist/invoice-ledger.d.ts.map +0 -1
  211. package/dist/invoice-ledger.js.map +0 -1
  212. package/dist/invoices.d.ts.map +0 -1
  213. package/dist/invoices.js.map +0 -1
  214. package/dist/kernel.d.ts.map +0 -1
  215. package/dist/kernel.js.map +0 -1
  216. package/dist/languages.d.ts.map +0 -1
  217. package/dist/languages.js.map +0 -1
  218. package/dist/line-groups.d.ts.map +0 -1
  219. package/dist/line-groups.js.map +0 -1
  220. package/dist/linkedin-ads.d.ts.map +0 -1
  221. package/dist/linkedin-ads.js.map +0 -1
  222. package/dist/localized-name.d.ts.map +0 -1
  223. package/dist/localized-name.js.map +0 -1
  224. package/dist/megamenu.d.ts.map +0 -1
  225. package/dist/megamenu.js.map +0 -1
  226. package/dist/meta-ads.d.ts.map +0 -1
  227. package/dist/meta-ads.js.map +0 -1
  228. package/dist/mfa.d.ts.map +0 -1
  229. package/dist/mfa.js.map +0 -1
  230. package/dist/modules.d.ts.map +0 -1
  231. package/dist/modules.js.map +0 -1
  232. package/dist/money-decimal.d.ts.map +0 -1
  233. package/dist/money-decimal.js.map +0 -1
  234. package/dist/money-input.d.ts.map +0 -1
  235. package/dist/money-input.js.map +0 -1
  236. package/dist/newsletter.d.ts.map +0 -1
  237. package/dist/newsletter.js.map +0 -1
  238. package/dist/order-minimums.d.ts.map +0 -1
  239. package/dist/order-minimums.js.map +0 -1
  240. package/dist/orders.d.ts.map +0 -1
  241. package/dist/orders.js.map +0 -1
  242. package/dist/organization-registry-lookup.d.ts.map +0 -1
  243. package/dist/organization-registry-lookup.js.map +0 -1
  244. package/dist/organization-roles.d.ts.map +0 -1
  245. package/dist/organization-roles.js.map +0 -1
  246. package/dist/organizations.d.ts.map +0 -1
  247. package/dist/organizations.js.map +0 -1
  248. package/dist/page-builder-props.d.ts.map +0 -1
  249. package/dist/page-builder-props.js.map +0 -1
  250. package/dist/page-builder-values.d.ts.map +0 -1
  251. package/dist/page-builder-values.js.map +0 -1
  252. package/dist/pagination.d.ts.map +0 -1
  253. package/dist/pagination.js.map +0 -1
  254. package/dist/payment-methods.d.ts.map +0 -1
  255. package/dist/payment-methods.js.map +0 -1
  256. package/dist/payment-return-url.d.ts.map +0 -1
  257. package/dist/payment-return-url.js.map +0 -1
  258. package/dist/payments.d.ts.map +0 -1
  259. package/dist/payments.js.map +0 -1
  260. package/dist/pim-connector.d.ts.map +0 -1
  261. package/dist/pim-connector.js.map +0 -1
  262. package/dist/pim-field-path.d.ts.map +0 -1
  263. package/dist/pim-field-path.js.map +0 -1
  264. package/dist/pim-locale-mapping.d.ts.map +0 -1
  265. package/dist/pim-locale-mapping.js.map +0 -1
  266. package/dist/platform-info.d.ts.map +0 -1
  267. package/dist/platform-info.js.map +0 -1
  268. package/dist/platform-language.d.ts.map +0 -1
  269. package/dist/platform-language.js.map +0 -1
  270. package/dist/price-book-decimal.d.ts.map +0 -1
  271. package/dist/price-book-decimal.js.map +0 -1
  272. package/dist/price-books.d.ts.map +0 -1
  273. package/dist/price-books.js.map +0 -1
  274. package/dist/price-lists.d.ts.map +0 -1
  275. package/dist/price-lists.js.map +0 -1
  276. package/dist/product-feeds.d.ts.map +0 -1
  277. package/dist/product-feeds.js.map +0 -1
  278. package/dist/product-scope-model.d.ts.map +0 -1
  279. package/dist/product-scope-model.js.map +0 -1
  280. package/dist/product-scope-overrides.d.ts.map +0 -1
  281. package/dist/product-scope-overrides.js.map +0 -1
  282. package/dist/product-scoped-values.d.ts.map +0 -1
  283. package/dist/product-scoped-values.js.map +0 -1
  284. package/dist/product-scopes.d.ts.map +0 -1
  285. package/dist/product-scopes.js.map +0 -1
  286. package/dist/product-summary-text.d.ts.map +0 -1
  287. package/dist/product-summary-text.js.map +0 -1
  288. package/dist/product-tax-rates.d.ts.map +0 -1
  289. package/dist/product-tax-rates.js.map +0 -1
  290. package/dist/product-url-keys.d.ts.map +0 -1
  291. package/dist/product-url-keys.js.map +0 -1
  292. package/dist/product-value-resolver.d.ts.map +0 -1
  293. package/dist/product-value-resolver.js.map +0 -1
  294. package/dist/projects.d.ts.map +0 -1
  295. package/dist/projects.js.map +0 -1
  296. package/dist/promotions.d.ts.map +0 -1
  297. package/dist/promotions.js.map +0 -1
  298. package/dist/prompt-actions.d.ts.map +0 -1
  299. package/dist/prompt-actions.js.map +0 -1
  300. package/dist/pwa.d.ts.map +0 -1
  301. package/dist/pwa.js.map +0 -1
  302. package/dist/quick-order.d.ts.map +0 -1
  303. package/dist/quick-order.js.map +0 -1
  304. package/dist/quote-requests.d.ts.map +0 -1
  305. package/dist/quote-requests.js.map +0 -1
  306. package/dist/record-references.d.ts.map +0 -1
  307. package/dist/record-references.js.map +0 -1
  308. package/dist/record-rich-text.d.ts.map +0 -1
  309. package/dist/record-rich-text.js.map +0 -1
  310. package/dist/returns.d.ts.map +0 -1
  311. package/dist/returns.js.map +0 -1
  312. package/dist/sales-channels.d.ts.map +0 -1
  313. package/dist/sales-channels.js.map +0 -1
  314. package/dist/saved-list-views.d.ts.map +0 -1
  315. package/dist/saved-list-views.js.map +0 -1
  316. package/dist/scope-notice.d.ts.map +0 -1
  317. package/dist/scope-notice.js.map +0 -1
  318. package/dist/scoped-write-encoding.d.ts.map +0 -1
  319. package/dist/scoped-write-encoding.js.map +0 -1
  320. package/dist/search.d.ts.map +0 -1
  321. package/dist/search.js.map +0 -1
  322. package/dist/seo.d.ts.map +0 -1
  323. package/dist/seo.js.map +0 -1
  324. package/dist/settings.d.ts.map +0 -1
  325. package/dist/settings.js.map +0 -1
  326. package/dist/shipments.d.ts.map +0 -1
  327. package/dist/shipments.js.map +0 -1
  328. package/dist/shipping-methods.d.ts.map +0 -1
  329. package/dist/shipping-methods.js.map +0 -1
  330. package/dist/shopping-lists.d.ts.map +0 -1
  331. package/dist/shopping-lists.js.map +0 -1
  332. package/dist/storefront-cache-tags.d.ts.map +0 -1
  333. package/dist/storefront-cache-tags.js.map +0 -1
  334. package/dist/storefront-language-path.d.ts.map +0 -1
  335. package/dist/storefront-language-path.js.map +0 -1
  336. package/dist/storefront-value-overrides.d.ts.map +0 -1
  337. package/dist/storefront-value-overrides.js.map +0 -1
  338. package/dist/tasks.d.ts.map +0 -1
  339. package/dist/tasks.js.map +0 -1
  340. package/dist/taxes.d.ts.map +0 -1
  341. package/dist/taxes.js.map +0 -1
  342. package/dist/text-normalization.d.ts.map +0 -1
  343. package/dist/text-normalization.js.map +0 -1
  344. package/dist/transactional-emails.d.ts.map +0 -1
  345. package/dist/transactional-emails.js.map +0 -1
  346. package/dist/webhooks.d.ts.map +0 -1
  347. 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
- * three written out, because the mechanism is easier to find than to remember.
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
- // Three fields are the whole vocabulary, so a fourth is a typo — and a
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: z.number().int().positive(),
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 = 200;
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: z.number().int().min(1),
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
  /**