@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.
Files changed (385) hide show
  1. package/dist/accept-language.d.ts +31 -0
  2. package/dist/accept-language.js +64 -0
  3. package/dist/actor.d.ts +16 -0
  4. package/dist/addresses.d.ts +35 -0
  5. package/dist/addresses.js +8 -1
  6. package/dist/admin-actions.d.ts +2 -0
  7. package/dist/admin-actions.js +18 -0
  8. package/dist/admin-contributions.d.ts +99 -12
  9. package/dist/admin-contributions.js +36 -10
  10. package/dist/admin-roles.d.ts +17 -2
  11. package/dist/admin-users.d.ts +9 -0
  12. package/dist/admin.d.ts +114 -4
  13. package/dist/admin.js +98 -3
  14. package/dist/api-keys.d.ts +22 -0
  15. package/dist/api-keys.js +4 -0
  16. package/dist/assets-library.d.ts +45 -0
  17. package/dist/assets-library.js +20 -3
  18. package/dist/audit-logs.d.ts +12 -0
  19. package/dist/audit-logs.js +12 -0
  20. package/dist/auth.d.ts +9 -0
  21. package/dist/auth.js +9 -0
  22. package/dist/blog.d.ts +382 -22
  23. package/dist/blog.js +199 -17
  24. package/dist/carts.d.ts +423 -36
  25. package/dist/carts.js +150 -12
  26. package/dist/catalog.d.ts +379 -208
  27. package/dist/catalog.js +241 -163
  28. package/dist/cms-brand.d.ts +14 -14
  29. package/dist/cms.d.ts +71 -16
  30. package/dist/cms.js +15 -0
  31. package/dist/command-hooks.d.ts +301 -0
  32. package/dist/command-hooks.js +248 -0
  33. package/dist/common.d.ts +23 -6
  34. package/dist/common.js +25 -2
  35. package/dist/comparisons.d.ts +21 -14
  36. package/dist/comparisons.js +2 -1
  37. package/dist/credit-limits.d.ts +22 -0
  38. package/dist/credit-limits.js +35 -0
  39. package/dist/crm.d.ts +134 -78
  40. package/dist/crm.js +21 -5
  41. package/dist/custom-fields.d.ts +417 -49
  42. package/dist/custom-fields.js +142 -1
  43. package/dist/customer-accounts.d.ts +324 -22
  44. package/dist/customer-accounts.js +43 -0
  45. package/dist/customer-notifications.d.ts +143 -0
  46. package/dist/customer-notifications.js +41 -0
  47. package/dist/customers.d.ts +92 -73
  48. package/dist/customers.js +98 -10
  49. package/dist/dictionary.d.ts +53 -0
  50. package/dist/dictionary.js +25 -0
  51. package/dist/document-templates.d.ts +12 -12
  52. package/dist/email.d.ts +34 -0
  53. package/dist/email.js +6 -0
  54. package/dist/errors.d.ts +431 -3
  55. package/dist/errors.js +523 -3
  56. package/dist/forms-logic.d.ts +79 -0
  57. package/dist/forms-logic.fixtures.d.ts +52 -0
  58. package/dist/forms-logic.fixtures.js +610 -0
  59. package/dist/forms-logic.js +699 -0
  60. package/dist/forms.d.ts +9833 -0
  61. package/dist/forms.js +827 -0
  62. package/dist/i18n.d.ts +34 -0
  63. package/dist/i18n.js +15 -0
  64. package/dist/import-export.d.ts +180 -0
  65. package/dist/import-export.js +60 -0
  66. package/dist/index.d.ts +16 -1
  67. package/dist/index.js +30 -1
  68. package/dist/inventory.d.ts +9 -9
  69. package/dist/invoice-ledger.d.ts +13 -13
  70. package/dist/invoices.d.ts +126 -0
  71. package/dist/invoices.js +53 -0
  72. package/dist/line-bounds.d.ts +53 -0
  73. package/dist/line-bounds.js +65 -0
  74. package/dist/megamenu.d.ts +27 -27
  75. package/dist/mfa.d.ts +210 -4
  76. package/dist/mfa.js +136 -0
  77. package/dist/modules.d.ts +56 -8
  78. package/dist/modules.js +128 -3
  79. package/dist/money-decimal.d.ts +54 -0
  80. package/dist/money-decimal.js +95 -0
  81. package/dist/newsletter.d.ts +4 -4
  82. package/dist/orders.d.ts +246 -12
  83. package/dist/orders.js +140 -7
  84. package/dist/organization-hooks.d.ts +99 -0
  85. package/dist/organization-hooks.js +22 -0
  86. package/dist/organization-registry-lookup.d.ts +362 -0
  87. package/dist/organization-registry-lookup.js +196 -0
  88. package/dist/organization-roles.d.ts +341 -0
  89. package/dist/organization-roles.js +218 -0
  90. package/dist/organizations.d.ts +1074 -103
  91. package/dist/organizations.js +293 -28
  92. package/dist/page-builder-props.d.ts +56 -56
  93. package/dist/pim-connector.d.ts +7 -3
  94. package/dist/pim-connector.js +6 -2
  95. package/dist/pim-field-path.d.ts +5 -1
  96. package/dist/pim-field-path.js +37 -81
  97. package/dist/pim-locale-mapping.d.ts +131 -0
  98. package/dist/pim-locale-mapping.js +193 -0
  99. package/dist/price-books.d.ts +215 -63
  100. package/dist/price-books.js +47 -2
  101. package/dist/price-lists.d.ts +13 -10
  102. package/dist/product-feeds.d.ts +249 -100
  103. package/dist/product-feeds.js +46 -2
  104. package/dist/product-scope-model.d.ts +161 -0
  105. package/dist/product-scope-model.js +161 -0
  106. package/dist/product-scope-overrides.d.ts +0 -103
  107. package/dist/product-scope-overrides.js +0 -54
  108. package/dist/product-scoped-values.d.ts +2610 -0
  109. package/dist/product-scoped-values.js +425 -0
  110. package/dist/product-scopes.d.ts +199 -64
  111. package/dist/product-scopes.js +120 -23
  112. package/dist/product-tax-rates.d.ts +38 -0
  113. package/dist/product-tax-rates.js +45 -0
  114. package/dist/product-url-keys.d.ts +51 -45
  115. package/dist/product-url-keys.js +73 -39
  116. package/dist/product-value-resolver.d.ts +37 -60
  117. package/dist/product-value-resolver.js +36 -96
  118. package/dist/projects.d.ts +76 -28
  119. package/dist/projects.js +53 -9
  120. package/dist/promotions.d.ts +163 -11
  121. package/dist/promotions.js +23 -1
  122. package/dist/pwa.d.ts +41 -2
  123. package/dist/quick-order.d.ts +159 -9
  124. package/dist/quick-order.js +79 -4
  125. package/dist/quote-requests.d.ts +231 -17
  126. package/dist/quote-requests.js +111 -9
  127. package/dist/record-references.d.ts +15 -15
  128. package/dist/record-references.js +2 -3
  129. package/dist/record-rich-text.js +2 -1
  130. package/dist/returns.d.ts +214 -52
  131. package/dist/returns.js +143 -28
  132. package/dist/sales-channels.d.ts +34 -3
  133. package/dist/sales-channels.js +16 -1
  134. package/dist/saved-list-views.d.ts +28 -0
  135. package/dist/saved-list-views.js +14 -1
  136. package/dist/schema-extensions.d.ts +36 -0
  137. package/dist/schema-extensions.js +29 -0
  138. package/dist/scoped-write-encoding.d.ts +100 -0
  139. package/dist/scoped-write-encoding.js +135 -0
  140. package/dist/search.d.ts +18 -16
  141. package/dist/seo.d.ts +83 -30
  142. package/dist/seo.js +8 -1
  143. package/dist/settings.d.ts +173 -2
  144. package/dist/settings.js +53 -2
  145. package/dist/shopping-lists.d.ts +63 -4
  146. package/dist/shopping-lists.js +57 -3
  147. package/dist/storefront-cache-tags.d.ts +22 -0
  148. package/dist/storefront-cache-tags.js +12 -0
  149. package/dist/storefront-value-overrides.d.ts +18 -56
  150. package/dist/storefront-value-overrides.js +11 -86
  151. package/dist/tasks.d.ts +27 -27
  152. package/dist/taxes.d.ts +27 -0
  153. package/dist/taxes.js +4 -0
  154. package/dist/transactional-emails.d.ts +48 -22
  155. package/dist/webhooks.d.ts +75 -0
  156. package/dist/webhooks.js +24 -0
  157. package/package.json +5 -3
  158. package/dist/actor.d.ts.map +0 -1
  159. package/dist/actor.js.map +0 -1
  160. package/dist/addresses.d.ts.map +0 -1
  161. package/dist/addresses.js.map +0 -1
  162. package/dist/admin-actions.d.ts.map +0 -1
  163. package/dist/admin-actions.js.map +0 -1
  164. package/dist/admin-contributions.d.ts.map +0 -1
  165. package/dist/admin-contributions.js.map +0 -1
  166. package/dist/admin-feedback.d.ts.map +0 -1
  167. package/dist/admin-feedback.js.map +0 -1
  168. package/dist/admin-i18n.d.ts.map +0 -1
  169. package/dist/admin-i18n.js.map +0 -1
  170. package/dist/admin-name.d.ts.map +0 -1
  171. package/dist/admin-name.js.map +0 -1
  172. package/dist/admin-notifications.d.ts.map +0 -1
  173. package/dist/admin-notifications.js.map +0 -1
  174. package/dist/admin-preferences.d.ts.map +0 -1
  175. package/dist/admin-preferences.js.map +0 -1
  176. package/dist/admin-roles.d.ts.map +0 -1
  177. package/dist/admin-roles.js.map +0 -1
  178. package/dist/admin-search.d.ts.map +0 -1
  179. package/dist/admin-search.js.map +0 -1
  180. package/dist/admin-users.d.ts.map +0 -1
  181. package/dist/admin-users.js.map +0 -1
  182. package/dist/admin.d.ts.map +0 -1
  183. package/dist/admin.js.map +0 -1
  184. package/dist/analytics.d.ts.map +0 -1
  185. package/dist/analytics.js.map +0 -1
  186. package/dist/api-keys.d.ts.map +0 -1
  187. package/dist/api-keys.js.map +0 -1
  188. package/dist/assets-library.d.ts.map +0 -1
  189. package/dist/assets-library.js.map +0 -1
  190. package/dist/audit-logs.d.ts.map +0 -1
  191. package/dist/audit-logs.js.map +0 -1
  192. package/dist/auth.d.ts.map +0 -1
  193. package/dist/auth.js.map +0 -1
  194. package/dist/blog.d.ts.map +0 -1
  195. package/dist/blog.js.map +0 -1
  196. package/dist/capabilities.d.ts.map +0 -1
  197. package/dist/capabilities.js.map +0 -1
  198. package/dist/carts.d.ts.map +0 -1
  199. package/dist/carts.js.map +0 -1
  200. package/dist/catalog.d.ts.map +0 -1
  201. package/dist/catalog.js.map +0 -1
  202. package/dist/cms-brand.d.ts.map +0 -1
  203. package/dist/cms-brand.js.map +0 -1
  204. package/dist/cms-contact-form.d.ts.map +0 -1
  205. package/dist/cms-contact-form.js.map +0 -1
  206. package/dist/cms.d.ts.map +0 -1
  207. package/dist/cms.js.map +0 -1
  208. package/dist/common.d.ts.map +0 -1
  209. package/dist/common.js.map +0 -1
  210. package/dist/comparisons.d.ts.map +0 -1
  211. package/dist/comparisons.js.map +0 -1
  212. package/dist/credentials.d.ts.map +0 -1
  213. package/dist/credentials.js.map +0 -1
  214. package/dist/credit-limits.d.ts.map +0 -1
  215. package/dist/credit-limits.js.map +0 -1
  216. package/dist/crm-rich-text.d.ts.map +0 -1
  217. package/dist/crm-rich-text.js.map +0 -1
  218. package/dist/crm.d.ts.map +0 -1
  219. package/dist/crm.js.map +0 -1
  220. package/dist/currencies.d.ts.map +0 -1
  221. package/dist/currencies.js.map +0 -1
  222. package/dist/custom-fields.d.ts.map +0 -1
  223. package/dist/custom-fields.js.map +0 -1
  224. package/dist/customer-accounts.d.ts.map +0 -1
  225. package/dist/customer-accounts.js.map +0 -1
  226. package/dist/customers.d.ts.map +0 -1
  227. package/dist/customers.js.map +0 -1
  228. package/dist/dictionary.d.ts.map +0 -1
  229. package/dist/dictionary.js.map +0 -1
  230. package/dist/document-templates.d.ts.map +0 -1
  231. package/dist/document-templates.js.map +0 -1
  232. package/dist/document-values.d.ts.map +0 -1
  233. package/dist/document-values.js.map +0 -1
  234. package/dist/email-address.d.ts.map +0 -1
  235. package/dist/email-address.js.map +0 -1
  236. package/dist/email.d.ts.map +0 -1
  237. package/dist/email.js.map +0 -1
  238. package/dist/envelopes.d.ts.map +0 -1
  239. package/dist/envelopes.js.map +0 -1
  240. package/dist/environment-inputs.d.ts.map +0 -1
  241. package/dist/environment-inputs.js.map +0 -1
  242. package/dist/erp-connector.d.ts.map +0 -1
  243. package/dist/erp-connector.js.map +0 -1
  244. package/dist/errors.d.ts.map +0 -1
  245. package/dist/errors.js.map +0 -1
  246. package/dist/google-analytics.d.ts.map +0 -1
  247. package/dist/google-analytics.js.map +0 -1
  248. package/dist/google-tag-manager.d.ts.map +0 -1
  249. package/dist/google-tag-manager.js.map +0 -1
  250. package/dist/i18n.d.ts.map +0 -1
  251. package/dist/i18n.js.map +0 -1
  252. package/dist/import-export.d.ts.map +0 -1
  253. package/dist/import-export.js.map +0 -1
  254. package/dist/index.d.ts.map +0 -1
  255. package/dist/index.js.map +0 -1
  256. package/dist/inventory.d.ts.map +0 -1
  257. package/dist/inventory.js.map +0 -1
  258. package/dist/invoice-ledger.d.ts.map +0 -1
  259. package/dist/invoice-ledger.js.map +0 -1
  260. package/dist/invoices.d.ts.map +0 -1
  261. package/dist/invoices.js.map +0 -1
  262. package/dist/kernel.d.ts.map +0 -1
  263. package/dist/kernel.js.map +0 -1
  264. package/dist/languages.d.ts.map +0 -1
  265. package/dist/languages.js.map +0 -1
  266. package/dist/line-groups.d.ts.map +0 -1
  267. package/dist/line-groups.js.map +0 -1
  268. package/dist/linkedin-ads.d.ts.map +0 -1
  269. package/dist/linkedin-ads.js.map +0 -1
  270. package/dist/localized-name.d.ts.map +0 -1
  271. package/dist/localized-name.js.map +0 -1
  272. package/dist/megamenu.d.ts.map +0 -1
  273. package/dist/megamenu.js.map +0 -1
  274. package/dist/meta-ads.d.ts.map +0 -1
  275. package/dist/meta-ads.js.map +0 -1
  276. package/dist/mfa.d.ts.map +0 -1
  277. package/dist/mfa.js.map +0 -1
  278. package/dist/modules.d.ts.map +0 -1
  279. package/dist/modules.js.map +0 -1
  280. package/dist/money-decimal.d.ts.map +0 -1
  281. package/dist/money-decimal.js.map +0 -1
  282. package/dist/money-input.d.ts.map +0 -1
  283. package/dist/money-input.js.map +0 -1
  284. package/dist/newsletter.d.ts.map +0 -1
  285. package/dist/newsletter.js.map +0 -1
  286. package/dist/order-minimums.d.ts.map +0 -1
  287. package/dist/order-minimums.js.map +0 -1
  288. package/dist/orders.d.ts.map +0 -1
  289. package/dist/orders.js.map +0 -1
  290. package/dist/organizations.d.ts.map +0 -1
  291. package/dist/organizations.js.map +0 -1
  292. package/dist/page-builder-props.d.ts.map +0 -1
  293. package/dist/page-builder-props.js.map +0 -1
  294. package/dist/page-builder-values.d.ts.map +0 -1
  295. package/dist/page-builder-values.js.map +0 -1
  296. package/dist/pagination.d.ts.map +0 -1
  297. package/dist/pagination.js.map +0 -1
  298. package/dist/payment-methods.d.ts.map +0 -1
  299. package/dist/payment-methods.js.map +0 -1
  300. package/dist/payment-return-url.d.ts.map +0 -1
  301. package/dist/payment-return-url.js.map +0 -1
  302. package/dist/payments.d.ts.map +0 -1
  303. package/dist/payments.js.map +0 -1
  304. package/dist/pim-connector.d.ts.map +0 -1
  305. package/dist/pim-connector.js.map +0 -1
  306. package/dist/pim-field-path.d.ts.map +0 -1
  307. package/dist/pim-field-path.js.map +0 -1
  308. package/dist/platform-info.d.ts.map +0 -1
  309. package/dist/platform-info.js.map +0 -1
  310. package/dist/platform-language.d.ts.map +0 -1
  311. package/dist/platform-language.js.map +0 -1
  312. package/dist/price-book-decimal.d.ts.map +0 -1
  313. package/dist/price-book-decimal.js.map +0 -1
  314. package/dist/price-books.d.ts.map +0 -1
  315. package/dist/price-books.js.map +0 -1
  316. package/dist/price-lists.d.ts.map +0 -1
  317. package/dist/price-lists.js.map +0 -1
  318. package/dist/product-feeds.d.ts.map +0 -1
  319. package/dist/product-feeds.js.map +0 -1
  320. package/dist/product-scope-overrides.d.ts.map +0 -1
  321. package/dist/product-scope-overrides.js.map +0 -1
  322. package/dist/product-scopes.d.ts.map +0 -1
  323. package/dist/product-scopes.js.map +0 -1
  324. package/dist/product-summary-text.d.ts.map +0 -1
  325. package/dist/product-summary-text.js.map +0 -1
  326. package/dist/product-url-keys.d.ts.map +0 -1
  327. package/dist/product-url-keys.js.map +0 -1
  328. package/dist/product-value-resolver.d.ts.map +0 -1
  329. package/dist/product-value-resolver.js.map +0 -1
  330. package/dist/projects.d.ts.map +0 -1
  331. package/dist/projects.js.map +0 -1
  332. package/dist/promotions.d.ts.map +0 -1
  333. package/dist/promotions.js.map +0 -1
  334. package/dist/prompt-actions.d.ts.map +0 -1
  335. package/dist/prompt-actions.js.map +0 -1
  336. package/dist/pwa.d.ts.map +0 -1
  337. package/dist/pwa.js.map +0 -1
  338. package/dist/quick-order.d.ts.map +0 -1
  339. package/dist/quick-order.js.map +0 -1
  340. package/dist/quote-requests.d.ts.map +0 -1
  341. package/dist/quote-requests.js.map +0 -1
  342. package/dist/record-references.d.ts.map +0 -1
  343. package/dist/record-references.js.map +0 -1
  344. package/dist/record-rich-text.d.ts.map +0 -1
  345. package/dist/record-rich-text.js.map +0 -1
  346. package/dist/returns.d.ts.map +0 -1
  347. package/dist/returns.js.map +0 -1
  348. package/dist/sales-channels.d.ts.map +0 -1
  349. package/dist/sales-channels.js.map +0 -1
  350. package/dist/saved-list-views.d.ts.map +0 -1
  351. package/dist/saved-list-views.js.map +0 -1
  352. package/dist/scope-notice.d.ts.map +0 -1
  353. package/dist/scope-notice.js.map +0 -1
  354. package/dist/scoped-translations.d.ts +0 -48
  355. package/dist/scoped-translations.d.ts.map +0 -1
  356. package/dist/scoped-translations.js +0 -78
  357. package/dist/scoped-translations.js.map +0 -1
  358. package/dist/search.d.ts.map +0 -1
  359. package/dist/search.js.map +0 -1
  360. package/dist/seo.d.ts.map +0 -1
  361. package/dist/seo.js.map +0 -1
  362. package/dist/settings.d.ts.map +0 -1
  363. package/dist/settings.js.map +0 -1
  364. package/dist/shipments.d.ts.map +0 -1
  365. package/dist/shipments.js.map +0 -1
  366. package/dist/shipping-methods.d.ts.map +0 -1
  367. package/dist/shipping-methods.js.map +0 -1
  368. package/dist/shopping-lists.d.ts.map +0 -1
  369. package/dist/shopping-lists.js.map +0 -1
  370. package/dist/storefront-cache-tags.d.ts.map +0 -1
  371. package/dist/storefront-cache-tags.js.map +0 -1
  372. package/dist/storefront-language-path.d.ts.map +0 -1
  373. package/dist/storefront-language-path.js.map +0 -1
  374. package/dist/storefront-value-overrides.d.ts.map +0 -1
  375. package/dist/storefront-value-overrides.js.map +0 -1
  376. package/dist/tasks.d.ts.map +0 -1
  377. package/dist/tasks.js.map +0 -1
  378. package/dist/taxes.d.ts.map +0 -1
  379. package/dist/taxes.js.map +0 -1
  380. package/dist/text-normalization.d.ts.map +0 -1
  381. package/dist/text-normalization.js.map +0 -1
  382. package/dist/transactional-emails.d.ts.map +0 -1
  383. package/dist/transactional-emails.js.map +0 -1
  384. package/dist/webhooks.d.ts.map +0 -1
  385. package/dist/webhooks.js.map +0 -1
@@ -17,6 +17,14 @@
17
17
  * Nothing here imports from `backend/src/` (FR-034).
18
18
  */
19
19
  import { z } from 'zod';
20
+ export declare const CUSTOMER_ACCOUNT_ANONYMIZED_EVENT = "customer_account.anonymized.v1";
21
+ export declare const CustomerAccountAnonymizedEventV1Schema: z.ZodObject<{
22
+ eventId: z.ZodString;
23
+ occurredAt: z.ZodString;
24
+ customerAccountId: z.ZodString;
25
+ organizationId: z.ZodString;
26
+ }, z.core.$strict>;
27
+ export type CustomerAccountAnonymizedEventV1 = z.infer<typeof CustomerAccountAnonymizedEventV1Schema>;
20
28
  export declare const customerGroupSchema: z.ZodObject<{
21
29
  id: z.ZodString;
22
30
  code: z.ZodString;
@@ -26,6 +34,18 @@ export declare const customerGroupSchema: z.ZodObject<{
26
34
  updatedAt: z.ZodString;
27
35
  }, z.core.$strip>;
28
36
  export type CustomerGroup = z.infer<typeof customerGroupSchema>;
37
+ /** `GET /api/v1/admin/customer-groups` — every group (issue #599). */
38
+ export declare const customerGroupListResponseSchema: z.ZodObject<{
39
+ data: z.ZodArray<z.ZodObject<{
40
+ id: z.ZodString;
41
+ code: z.ZodString;
42
+ name: z.ZodString;
43
+ description: z.ZodNullable<z.ZodString>;
44
+ createdAt: z.ZodString;
45
+ updatedAt: z.ZodString;
46
+ }, z.core.$strip>>;
47
+ }, z.core.$strip>;
48
+ export type CustomerGroupListResponse = z.infer<typeof customerGroupListResponseSchema>;
29
49
  export declare const upsertCustomerGroupRequestSchema: z.ZodObject<{
30
50
  code: z.ZodString;
31
51
  name: z.ZodString;
@@ -60,8 +80,20 @@ export interface CustomerGroupReadPort {
60
80
  /** Every group, ordered by code. */
61
81
  listAll(): Promise<CustomerGroupRecord[]>;
62
82
  }
63
- export type CustomerAccountRole = 'organization_admin' | 'regular_user';
64
83
  export type CustomerAccountBlockSource = 'staff' | 'org_owner';
84
+ /**
85
+ * The codes a redacted `customer_account` audit row keeps (issue #844).
86
+ *
87
+ * Owner: `customer_accounts`; **codes only**. When an anonymised subject's
88
+ * audit history is erased, the platform's rule keeps ids, timestamps, booleans
89
+ * and a few global code keys, and erases every other value. These are the keys
90
+ * this module's audit snapshots record a *code* under that the rule would not
91
+ * otherwise keep — `blockSource` (`staff` / `org_owner`) and `via` (how a
92
+ * password was changed: `reset_token` / `self_service`). A value under one of
93
+ * them is still erased unless it has a code's shape. Adding a key here keeps it
94
+ * in every erased history, so add a key only when its values are codes.
95
+ */
96
+ export declare const CUSTOMER_ACCOUNT_AUDIT_KEEP_KEYS: readonly string[];
65
97
  /**
66
98
  * A customer account as it crosses a module boundary — a plain shape, never
67
99
  * the ORM entity (FR-011).
@@ -82,7 +114,12 @@ export interface CustomerAccountRecord {
82
114
  email: string;
83
115
  firstName: string;
84
116
  lastName: string;
85
- role: CustomerAccountRole;
117
+ /**
118
+ * The organization role the account holds — a role of {@link organizationId}
119
+ * (`specs/170-organization-roles/` data-model §2; a composite foreign key in
120
+ * the database). Never `null`: every account holds exactly one.
121
+ */
122
+ organizationRoleId: string;
86
123
  emailVerifiedAt: Date | null;
87
124
  /** Whether a confirmed TOTP enrolment exists. The secret itself never travels. */
88
125
  twoFactorEnabled: boolean;
@@ -100,6 +137,25 @@ export interface CustomerAccountRecord {
100
137
  blockedByCustomerAccountId: string | null;
101
138
  deletionRequestedByAdminUserId: string | null;
102
139
  anonymizedAt: Date | null;
140
+ /**
141
+ * Issue #652 (D-292) — the language the account's owner reads: one BCP-47
142
+ * content-language tag, spelled as the sales channel that captured it spells
143
+ * it (`pl-PL`, `en-US`). Captured at account creation and, while still
144
+ * `null`, at sign-in, from the request's channel and its `Accept-Language`;
145
+ * overwritten only by the owner's own choice on the storefront account page.
146
+ *
147
+ * A message composed outside a request resolves it against the channel it
148
+ * is rendered for — `scopeLanguageOf(renderChannel, preferredLanguage)`:
149
+ * the exact language, else one of the same base language, else that
150
+ * channel's default — so a value the channel no longer offers falls back
151
+ * rather than failing. Inside a request the `Accept-Language` header still
152
+ * decides the response language (D-131).
153
+ *
154
+ * `null` means unknown: the account predates the field and has not signed in
155
+ * since, or was created by an operator. Personal data (D-288 list 2): never
156
+ * written into an audit state, cleared by the anonymisation sweep.
157
+ */
158
+ preferredLanguage: string | null;
103
159
  }
104
160
  /**
105
161
  * Which accounts a lookup should consider. Soft-deleted accounts still resolve
@@ -138,15 +194,20 @@ export interface CustomerAccountReadPort {
138
194
  * forgotten.
139
195
  */
140
196
  findInOrganization(id: string, organizationId: string, options?: CustomerAccountLookupOptions): Promise<CustomerAccountRecord | null>;
141
- /** Members of an organisation, ordered by role then creation date. */
197
+ /** Members of an organisation: its *Administrator* holders first, then by creation date. */
142
198
  listByOrganization(organizationId: string, options?: CustomerAccountLookupOptions): Promise<CustomerAccountRecord[]>;
143
199
  /**
144
- * How many accounts in the organisation hold the role, optionally ignoring
145
- * one id and optionally counting only unblocked accounts. This is the shape
146
- * the "an organisation may not lose its last admin" rule is spelled with, in
147
- * three modules, three slightly different ways.
200
+ * How many accounts of the organisation hold its *Administrator* role — the
201
+ * predicate the "an organisation keeps at least one administrator" rule is
202
+ * spelled with since `specs/170-organization-roles/`
203
+ * (`contracts/commands-audit-events.md` §3): optionally ignoring one id, and
204
+ * optionally counting only active or only unblocked accounts.
205
+ *
206
+ * A count, not a guard: it takes no lock. The member Commands that must not
207
+ * race (`customer_account.change_role`, `customer_account.remove_member`)
208
+ * lock the holders themselves before counting.
148
209
  */
149
- countByOrganizationRole(organizationId: string, role: CustomerAccountRole, options?: {
210
+ countAdministrators(organizationId: string, options?: {
150
211
  excludeCustomerAccountId?: string;
151
212
  activeOnly?: boolean;
152
213
  notBlocked?: boolean;
@@ -196,13 +257,31 @@ export interface CustomerAccountCreateInput {
196
257
  password: string;
197
258
  firstName: string;
198
259
  lastName: string;
199
- role: CustomerAccountRole;
260
+ /**
261
+ * The organization role the account will hold, a role of
262
+ * {@link organizationId}. Required: no production path relies on the
263
+ * database's default (research R-28).
264
+ */
265
+ organizationRoleId: string;
200
266
  /**
201
267
  * Whether the address is already confirmed. Accepting an invitation implies
202
268
  * it — the invitation was delivered to that address; self-registration and
203
269
  * the admin direct-create do not.
204
270
  */
205
271
  emailVerified?: boolean;
272
+ /**
273
+ * Feature 175 — the account's custom-field values, ALREADY VALIDATED by the
274
+ * caller through custom_fields' value port (the caller owns the surface and
275
+ * must validate before its first write). Stored as given; `{}` when absent.
276
+ */
277
+ customFieldValues?: Record<string, unknown>;
278
+ /**
279
+ * Issue #652 (D-292) — the language captured from the creating request:
280
+ * `requestScopeLanguage(requestChannel, Accept-Language)`, so a
281
+ * tag the channel spells. Absent or `null` stores `null` — the admin
282
+ * direct-create, which has no buyer request to read it from.
283
+ */
284
+ preferredLanguage?: string | null;
206
285
  }
207
286
  /** Absent fields are left unchanged. */
208
287
  export interface CustomerAccountProfilePatch {
@@ -215,6 +294,37 @@ export interface CustomerAccountProfilePatch {
215
294
  firstName?: string;
216
295
  lastName?: string;
217
296
  }
297
+ /** Where a preferred-language write comes from (issue #652, D-292). */
298
+ export type CustomerPreferredLanguageSource = 'self_service' | 'sign_in';
299
+ /**
300
+ * Container name: `customerAccountPreferencePort`. Owner: `customer_accounts`.
301
+ *
302
+ * Issue #652 (D-292) — the account's preferred language, the customer twin of
303
+ * `AdminUserPreferencePort`. Two methods, because there are two writers:
304
+ *
305
+ * - `setPreferredLanguage` — the owner's explicit choice on the storefront
306
+ * account page (`customers`' `PATCH /api/v1/me/customer/preferred-language`),
307
+ * the only write that overwrites a stored value. The caller has already
308
+ * checked the tag against the request channel's languages and passes it in
309
+ * that channel's spelling; this port stores it as given. Throws HTTP 404
310
+ * `NOT_FOUND` for an id no live account has.
311
+ * - `captureIfUnset` — a sign-in's capture (federated sign-in through `mfa`):
312
+ * writes only while the account has no value, and does nothing at all —
313
+ * no write, no audit entry — when it already has one or the id is unknown.
314
+ *
315
+ * Both run `customer_account.set_preferred_language` on the Command Bus. Its
316
+ * audit entry names the field and the source and never the tag (D-288 list 2):
317
+ * `{ changedFields: ['preferredLanguage'], source }`.
318
+ *
319
+ * **Owner off:** the seam fails closed — resolving this port throws
320
+ * `ModuleDisabledError` and the call answers 503 `MODULE_DISABLED`. Whether
321
+ * `customer_accounts` has an off state at all is its manifest's `activation` to
322
+ * say, not this line's: a module declaring `nonDeactivatable` never enters one.
323
+ */
324
+ export interface CustomerAccountPreferencePort {
325
+ setPreferredLanguage(customerAccountId: string, preferredLanguage: string): Promise<CustomerAccountRecord>;
326
+ captureIfUnset(customerAccountId: string, preferredLanguage: string): Promise<void>;
327
+ }
218
328
  /**
219
329
  * Container name: `customerAccountMemberWritePort`. Owner: `customer_accounts`.
220
330
  *
@@ -238,7 +348,7 @@ export interface CustomerAccountProfilePatch {
238
348
  * organisation panel" rather than "this account's e-mail changed" — and both
239
349
  * are kept, which is what the role endpoint has always recorded.
240
350
  *
241
- * `changeRole` is **not** here: {@link CustomerRolePort} already owns it, with
351
+ * A role change is **not** here: {@link CustomerAccountRoleCommandPort} owns it, with
242
352
  * the "an organisation keeps at least one admin" guard.
243
353
  * {@link CustomerAccountMemberWritePort.promoteToOrganizationAdmin} is a
244
354
  * different question — the break-glass path an operator reaches *because* an
@@ -275,8 +385,12 @@ export interface CustomerAccountMemberWritePort {
275
385
  * Feature 051 — binds an org-less account to the organisation just
276
386
  * provisioned for it. Throws HTTP 404 `NOT_FOUND` when no account has that
277
387
  * id.
388
+ *
389
+ * `organizationRoleId` is a role **of `organizationId`**, written in the same
390
+ * statement: the composite foreign key refuses the previous Organization's
391
+ * role (`specs/170-organization-roles/` data-model §2, research R-34).
278
392
  */
279
- attachToOrganization(customerAccountId: string, organizationId: string): Promise<CustomerAccountRecord>;
393
+ attachToOrganization(customerAccountId: string, organizationId: string, organizationRoleId: string): Promise<CustomerAccountRecord>;
280
394
  }
281
395
  /** What a caller sets the session cookie from after a successful first factor. */
282
396
  export interface CustomerLoginResult {
@@ -306,6 +420,14 @@ export interface CustomerLoginInput extends CustomerAuthenticationOrigin {
306
420
  ip?: string;
307
421
  userAgent?: string;
308
422
  salesChannelId?: string | null;
423
+ /**
424
+ * Issue #652 (D-292) — the sign-in request's language, already resolved
425
+ * against its channel (`scopeLanguageOf`). Stored on the account only while
426
+ * the account has none, and only once the password, the block and the
427
+ * channel access have been accepted; a refused sign-in stores nothing.
428
+ * Absent or `null` stores nothing.
429
+ */
430
+ language?: string | null;
309
431
  }
310
432
  /** Where a customer's attempt came from, as far as the caller knows. */
311
433
  export interface CustomerAuthenticationOrigin {
@@ -546,9 +668,140 @@ export interface CustomerRollupScopePort {
546
668
  */
547
669
  export interface CustomerRolePort {
548
670
  listMembers(organizationId: string): Promise<CustomerAccountRecord[]>;
549
- changeRole(organizationId: string, targetCustomerAccountId: string, newRole: CustomerAccountRole): Promise<CustomerAccountRecord>;
550
671
  removeMember(organizationId: string, targetCustomerAccountId: string): Promise<void>;
551
672
  }
673
+ /**
674
+ * Announced on commit whenever an account's organization role changes —
675
+ * `customer_account.change_role` (also as a child of `organization_role.delete`)
676
+ * and `customer_account.promote_organization_admin` (data-model §7). `carts`
677
+ * resets the approval state of a member who gained
678
+ * `carts.order_without_approval` from it (FR-034).
679
+ */
680
+ export declare const CUSTOMER_ACCOUNT_ORGANIZATION_ROLE_CHANGED_EVENT: "customer_account.organization_role_changed.v1";
681
+ export interface CustomerAccountOrganizationRoleChangedEventV1 {
682
+ readonly eventId: string;
683
+ readonly occurredAt: string;
684
+ readonly organizationId: string;
685
+ readonly customerAccountId: string;
686
+ readonly fromRoleId: string;
687
+ readonly toRoleId: string;
688
+ }
689
+ /** `customer_account.change_role`'s input: the member and the role of its own Organization it moves to. */
690
+ export interface CustomerAccountRoleChangeInput {
691
+ readonly organizationId: string;
692
+ readonly customerAccountId: string;
693
+ readonly roleId: string;
694
+ /**
695
+ * Also move a **removed** (soft-deleted) member. Only the reassignment of a
696
+ * deleted role's holders asks for it: the foreign key counts removed accounts
697
+ * as holders, so they must move too. Every other caller leaves it unset, and a
698
+ * removed member answers `404` as an unknown one does.
699
+ */
700
+ readonly includeRemoved?: boolean;
701
+ }
702
+ /** What `customer_account.change_role` answers. `fromRoleId === toRoleId` when nothing changed. */
703
+ export interface CustomerAccountRoleChangeResult {
704
+ readonly organizationId: string;
705
+ readonly customerAccountId: string;
706
+ readonly fromRoleId: string;
707
+ readonly toRoleId: string;
708
+ }
709
+ /**
710
+ * A Command as the platform's Command Bus runs it, named structurally because
711
+ * this package depends on no platform code and may name no `EntityManager`.
712
+ * The platform's `Command<TResult>` is assignable to it and it to that, so a
713
+ * caller hands it to `commandBus.run` or, as a child, to `ctx.run` unchanged.
714
+ * Its `run` belongs to the bus; a caller never invokes it.
715
+ */
716
+ export interface CustomerAccountRoleChangeCommand {
717
+ readonly action: string;
718
+ readonly objectType: string;
719
+ readonly objectId: string;
720
+ run(ctx: never): Promise<{
721
+ readonly result: CustomerAccountRoleChangeResult;
722
+ }>;
723
+ }
724
+ /**
725
+ * Container name: `customerAccountRoleCommandPort`. Owner: `customer_accounts`.
726
+ *
727
+ * The role assignment as a **Command factory** (`specs/170-organization-roles/`
728
+ * `contracts/commands-audit-events.md` §2; research R-22): `organizations`
729
+ * deletes a held role by running one `changeRole` Command per holder as a
730
+ * **child** of `organization_role.delete`, through `ctx.run` — on the parent's
731
+ * transaction, each with its own audit entry, all committing or none. No
732
+ * `EntityManager` crosses: the child runs on the one the bus hands it.
733
+ *
734
+ * `changeRole` refuses `404 NOT_FOUND` for an account that is not a live member
735
+ * of the Organization or a role the Organization does not have, and `409
736
+ * CANNOT_DEMOTE_LAST_ADMIN` when it would leave the Organization without an
737
+ * active administrator — counted under a `for update` lock on the holders
738
+ * (research R-29).
739
+ *
740
+ * `holdersOf` lists every account holding the role — blocked and soft-deleted
741
+ * ones included, because the foreign key does not distinguish them.
742
+ *
743
+ * **Owner off:** the seam fails closed — resolving this port throws
744
+ * `ModuleDisabledError` and the call answers 503 `MODULE_DISABLED`. Whether
745
+ * `customer_accounts` has an off state at all is its manifest's `activation` to
746
+ * say, not this line's: a module declaring `nonDeactivatable` never enters one.
747
+ */
748
+ export interface CustomerAccountRoleCommandPort {
749
+ changeRole(input: CustomerAccountRoleChangeInput): CustomerAccountRoleChangeCommand;
750
+ holdersOf(organizationId: string, roleId: string): Promise<string[]>;
751
+ }
752
+ /**
753
+ * `customer_account.create` as the platform's Command Bus runs it, named
754
+ * structurally for the reason {@link CustomerAccountRoleChangeCommand} is: the
755
+ * platform's `Command<CustomerAccountRecord>` is assignable to it and it to
756
+ * that, so a caller hands it to `commandBus.run` or, as a child, to `ctx.run`
757
+ * unchanged. Its `run` belongs to the bus.
758
+ */
759
+ export interface CustomerAccountCreateCommand {
760
+ readonly action: string;
761
+ readonly objectType: string;
762
+ readonly objectId: string;
763
+ run(ctx: never): Promise<{
764
+ readonly result: CustomerAccountRecord;
765
+ }>;
766
+ }
767
+ /**
768
+ * What {@link CustomerAccountMemberCommandPort.prepareCreate} takes: an account's
769
+ * creation input without the two ids a caller may only know inside its own
770
+ * transaction — a registration learns its Organization's *Administrator* role
771
+ * id from the row the Organization's insert wrote.
772
+ */
773
+ export type CustomerAccountCreatePreparation = Omit<CustomerAccountCreateInput, 'organizationId' | 'organizationRoleId'>;
774
+ /** A prepared account creation: the password is hashed, the Command not yet built. */
775
+ export interface PreparedCustomerAccountCreate {
776
+ /** The `customer_account.create` Command for that Organization and role. */
777
+ command(target: {
778
+ organizationId: string;
779
+ organizationRoleId: string;
780
+ }): CustomerAccountCreateCommand;
781
+ }
782
+ /**
783
+ * Container name: `customerAccountMemberCommandPort`. Owner: `customer_accounts`.
784
+ *
785
+ * The account creation as a **Command factory** (`specs/176-command-hooks-outbox/`
786
+ * FR-002, FR-005, `contracts/registration-command.md`): `organizations` creates
787
+ * a registration's first account as a **child** of `organization.register`
788
+ * through `ctx.run`, so the Organization and its administrator commit together
789
+ * or not at all, each with its own audit entry. No `EntityManager` crosses.
790
+ *
791
+ * `prepareCreate` hashes the password **now**, outside any transaction — the
792
+ * hash's cost is deliberate and must never run while a transaction holds the
793
+ * caller's rows — and the Command it later builds only writes. The Command
794
+ * refuses `409 EMAIL_ALREADY_REGISTERED` from its pre-check and from the unique
795
+ * index, inside its run.
796
+ *
797
+ * {@link CustomerAccountMemberWritePort.create} runs this same Command,
798
+ * top-level, so the creation has one implementation (FR-004).
799
+ *
800
+ * **Owner off:** the seam fails closed, as {@link CustomerAccountRoleCommandPort} does.
801
+ */
802
+ export interface CustomerAccountMemberCommandPort {
803
+ prepareCreate(input: CustomerAccountCreatePreparation): Promise<PreparedCustomerAccountCreate>;
804
+ }
552
805
  /**
553
806
  * A standalone (org-less) self-registration, as `customers` asks for one.
554
807
  *
@@ -570,6 +823,8 @@ export interface CustomerAccountStandaloneCreateInput {
570
823
  password: string;
571
824
  firstName: string;
572
825
  lastName: string;
826
+ /** Issue #652 — as {@link CustomerAccountCreateInput.preferredLanguage}. */
827
+ preferredLanguage?: string | null;
573
828
  }
574
829
  /**
575
830
  * The request the write was made from, stamped onto its audit row.
@@ -584,6 +839,21 @@ export interface CustomerAccountWriteRequestMeta {
584
839
  userAgent?: string | null;
585
840
  requestId?: string | null;
586
841
  }
842
+ /**
843
+ * Who moves an account between Organizations, and the role it holds there
844
+ * (`specs/170-organization-roles/` research R-34).
845
+ *
846
+ * `organizationRoleId` is a role of the **destination** Organization and is
847
+ * written in the same statement as the Organization: the composite foreign key
848
+ * refuses the previous Organization's role. The caller resolves it — the
849
+ * destination's *Administrator* for a personal Organization (from the
850
+ * provisioning answer), else the destination's predefined role of the kind the
851
+ * account held (owner ruling PR-11).
852
+ */
853
+ export interface CustomerAccountOrganizationMoveInput {
854
+ actorAdminUserId: string;
855
+ organizationRoleId: string;
856
+ }
587
857
  /** Which lifecycle bucket the admin customer list is asking for. */
588
858
  export type CustomerAccountLifecycleStatus = 'active' | 'blocked' | 'deleted';
589
859
  /**
@@ -669,7 +939,7 @@ export interface CustomerAccountAdminSearchPort {
669
939
  * staff member may act on this customer, and whether blocking them would
670
940
  * strand an organisation without an administrator, are `customers`' questions
671
941
  * and stay there — the counting half of the second one is
672
- * {@link CustomerAccountReadPort.countByOrganizationRole}, which already
942
+ * {@link CustomerAccountReadPort.countAdministrators}, which already
673
943
  * exists. What moves is the write and the one audit row that describes it, so
674
944
  * that a row on this table is never written by a module that does not own it
675
945
  * and never written without being recorded. Unlike
@@ -737,9 +1007,7 @@ export interface CustomerAccountLifecycleWritePort {
737
1007
  * refuses at the column. What an operator detaching a member actually wants
738
1008
  * is {@link detachToPersonalOrganization} below.
739
1009
  */
740
- setOrganization(customerAccountId: string, organizationId: string, input: {
741
- actorAdminUserId: string;
742
- }): Promise<CustomerAccountRecord>;
1010
+ setOrganization(customerAccountId: string, organizationId: string, input: CustomerAccountOrganizationMoveInput): Promise<CustomerAccountRecord>;
743
1011
  /**
744
1012
  * D-178 — the operator's "this person no longer belongs to that company",
745
1013
  * expressed as the move it has to be rather than as the detach it used to be.
@@ -753,9 +1021,7 @@ export interface CustomerAccountLifecycleWritePort {
753
1021
  * the verb an operator's history already reads, now describing what really
754
1022
  * happened.
755
1023
  */
756
- detachToPersonalOrganization(customerAccountId: string, personalOrganizationId: string, input: {
757
- actorAdminUserId: string;
758
- }): Promise<CustomerAccountRecord>;
1024
+ detachToPersonalOrganization(customerAccountId: string, personalOrganizationId: string, input: CustomerAccountOrganizationMoveInput): Promise<CustomerAccountRecord>;
759
1025
  /** `null` clears the direct group; the organisation's own group still applies. */
760
1026
  setCustomerGroup(customerAccountId: string, customerGroupId: string | null, input: {
761
1027
  actorAdminUserId: string;
@@ -778,13 +1044,49 @@ export interface CustomerAccountLifecycleWritePort {
778
1044
  setCustomFieldValues(customerAccountId: string, merge: (current: Record<string, unknown>) => Promise<Record<string, unknown>>): Promise<CustomerAccountRecord>;
779
1045
  /**
780
1046
  * Soft-deleted accounts whose retention window elapsed before `cutoff` and
781
- * that have not been anonymised yet — the sweep's work list.
1047
+ * that have not been anonymised yet — the sweep's work list. It also lists,
1048
+ * whatever the cutoff, an anonymised account that an earlier scrub left a
1049
+ * block reason (before issue #843) or custom field values (before #802) on,
1050
+ * until {@link anonymize} has finished it.
782
1051
  */
783
1052
  listDueForAnonymization(cutoff: Date): Promise<CustomerAccountRecord[]>;
1053
+ /**
1054
+ * Whether {@link listDueForAnonymization} at `cutoff` would list anything —
1055
+ * **yes or no, and nothing else** (issue #857).
1056
+ *
1057
+ * The sweep's scheduled tick asks this with no tenant context, before it
1058
+ * enters the system scope, so that a tick with no account due writes no
1059
+ * `tenant.escape_hatch` audit row. It is the work list's own predicate, so
1060
+ * `false` means the sweep would anonymise nobody. No id, row or count of any
1061
+ * account leaves it.
1062
+ */
1063
+ hasDueForAnonymization(cutoff: Date): Promise<boolean>;
784
1064
  /**
785
1065
  * Irreversibly scrubs the account's personal data. Returns the account
786
- * unchanged when it was already anonymised, and throws HTTP 404
787
- * `CUSTOMER_NOT_FOUND` for an id nothing matches.
1066
+ * unchanged when it was already fully anonymised, and throws HTTP 404
1067
+ * `CUSTOMER_NOT_FOUND` for an id nothing matches. The row is locked before
1068
+ * `anonymizedAt` is read (issue #857), so two concurrent calls for one
1069
+ * account scrub, audit and announce it once.
1070
+ *
1071
+ * It is the anonymisation cascade's **last** write (issue #800): the
1072
+ * `anonymizedAt` it stamps is what takes the account off
1073
+ * {@link listDueForAnonymization}, so it is the commit marker for the
1074
+ * organisation and address scrubs that run before it.
1075
+ *
1076
+ * The scrub clears the e-mail, both names, the credentials, **every**
1077
+ * custom field value and the operator's block reason (issue #843; the block
1078
+ * itself stays), and commits in one transaction with its
1079
+ * `customer_account.anonymized` audit row, which records none of the erased
1080
+ * data (issue #802). `customer_account.anonymized.v1` is announced after
1081
+ * that commit, only on the transition.
1082
+ *
1083
+ * An account an earlier scrub left a block reason or custom field values on
1084
+ * is finished once: those are cleared, `anonymizedAt` is kept, and one more
1085
+ * `customer_account.anonymized` row is written, with no second announcement.
1086
+ * The rows tell the two apart by `stateBefore.anonymizedAt`: `null` on the
1087
+ * first scrub, the original ISO timestamp on a finish. On both,
1088
+ * `stateBefore` is `{ anonymizedAt, customFieldKeys, hadBlockReason }` and
1089
+ * `stateAfter.anonymizedAt` is the time of the first scrub.
788
1090
  */
789
1091
  anonymize(customerAccountId: string): Promise<CustomerAccountRecord>;
790
1092
  }
@@ -18,6 +18,23 @@
18
18
  */
19
19
  import { z } from 'zod';
20
20
  import { isoDateTimeSchema, uuidSchema } from './common.js';
21
+ // --- the anonymisation event ---------------------------------------------------
22
+ //
23
+ // `specs/170-forms-module/` research R-17, contracts/events-and-webhook.md §3.
24
+ // `CustomerAccountLifecycleWritePort.anonymize` announces the irreversible step
25
+ // once, after its write and its audit row, so a module holding data attributed
26
+ // to the account can erase it within the same sweep step. Ids only: the account
27
+ // has just been scrubbed, and the event says which one, never what it held. Not
28
+ // offered to outbound webhooks.
29
+ export const CUSTOMER_ACCOUNT_ANONYMIZED_EVENT = 'customer_account.anonymized.v1';
30
+ export const CustomerAccountAnonymizedEventV1Schema = z
31
+ .object({
32
+ eventId: z.string().min(1),
33
+ occurredAt: isoDateTimeSchema,
34
+ customerAccountId: z.string().uuid(),
35
+ organizationId: z.string().uuid(),
36
+ })
37
+ .strict();
21
38
  // --- customer groups ---------------------------------------------------------
22
39
  //
23
40
  // Feature 076, D-79 — the segmentation bucket a customer belongs to. It used to
@@ -33,11 +50,37 @@ export const customerGroupSchema = z.object({
33
50
  createdAt: isoDateTimeSchema,
34
51
  updatedAt: isoDateTimeSchema,
35
52
  });
53
+ /** `GET /api/v1/admin/customer-groups` — every group (issue #599). */
54
+ export const customerGroupListResponseSchema = z.object({
55
+ data: z.array(customerGroupSchema),
56
+ });
36
57
  export const upsertCustomerGroupRequestSchema = z.object({
37
58
  code: z.string().min(1).max(64),
38
59
  name: z.string().min(1).max(160),
39
60
  description: z.string().max(1000).nullable().optional(),
40
61
  });
62
+ /**
63
+ * The codes a redacted `customer_account` audit row keeps (issue #844).
64
+ *
65
+ * Owner: `customer_accounts`; **codes only**. When an anonymised subject's
66
+ * audit history is erased, the platform's rule keeps ids, timestamps, booleans
67
+ * and a few global code keys, and erases every other value. These are the keys
68
+ * this module's audit snapshots record a *code* under that the rule would not
69
+ * otherwise keep — `blockSource` (`staff` / `org_owner`) and `via` (how a
70
+ * password was changed: `reset_token` / `self_service`). A value under one of
71
+ * them is still erased unless it has a code's shape. Adding a key here keeps it
72
+ * in every erased history, so add a key only when its values are codes.
73
+ */
74
+ export const CUSTOMER_ACCOUNT_AUDIT_KEEP_KEYS = ['blockSource', 'via'];
75
+ // --- organization role assignment (`specs/170-organization-roles/`) -----------
76
+ /**
77
+ * Announced on commit whenever an account's organization role changes —
78
+ * `customer_account.change_role` (also as a child of `organization_role.delete`)
79
+ * and `customer_account.promote_organization_admin` (data-model §7). `carts`
80
+ * resets the approval state of a member who gained
81
+ * `carts.order_without_approval` from it (FR-034).
82
+ */
83
+ export const CUSTOMER_ACCOUNT_ORGANIZATION_ROLE_CHANGED_EVENT = 'customer_account.organization_role_changed.v1';
41
84
  // --- effective customer group ------------------------------------------------
42
85
  /**
43
86
  * D-287 P0 — the one customer-group rule every pricing path applies, and the