@endora-commerce/mod-organizations 0.100.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 (288) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -0
  3. package/dist/admin/components/OrganizationSalesRepsTab.d.ts +27 -0
  4. package/dist/admin/components/OrganizationSalesRepsTab.d.ts.map +1 -0
  5. package/dist/admin/components/OrganizationSalesRepsTab.js +170 -0
  6. package/dist/admin/components/OrganizationSalesRepsTab.js.map +1 -0
  7. package/dist/admin/index.d.ts +30 -0
  8. package/dist/admin/index.d.ts.map +1 -0
  9. package/dist/admin/index.js +59 -0
  10. package/dist/admin/index.js.map +1 -0
  11. package/dist/admin/pages/OrganizationDetail.d.ts +9 -0
  12. package/dist/admin/pages/OrganizationDetail.d.ts.map +1 -0
  13. package/dist/admin/pages/OrganizationDetail.js +247 -0
  14. package/dist/admin/pages/OrganizationDetail.js.map +1 -0
  15. package/dist/admin/pages/OrganizationsList.d.ts +9 -0
  16. package/dist/admin/pages/OrganizationsList.d.ts.map +1 -0
  17. package/dist/admin/pages/OrganizationsList.js +73 -0
  18. package/dist/admin/pages/OrganizationsList.js.map +1 -0
  19. package/dist/admin/panels/ApplicablePriceListsPanel.d.ts +12 -0
  20. package/dist/admin/panels/ApplicablePriceListsPanel.d.ts.map +1 -0
  21. package/dist/admin/panels/ApplicablePriceListsPanel.js +49 -0
  22. package/dist/admin/panels/ApplicablePriceListsPanel.js.map +1 -0
  23. package/dist/admin/panels/FulfilmentStrategyPanel.d.ts +16 -0
  24. package/dist/admin/panels/FulfilmentStrategyPanel.d.ts.map +1 -0
  25. package/dist/admin/panels/FulfilmentStrategyPanel.js +29 -0
  26. package/dist/admin/panels/FulfilmentStrategyPanel.js.map +1 -0
  27. package/dist/admin/panels/HierarchyPanel.d.ts +15 -0
  28. package/dist/admin/panels/HierarchyPanel.d.ts.map +1 -0
  29. package/dist/admin/panels/HierarchyPanel.js +65 -0
  30. package/dist/admin/panels/HierarchyPanel.js.map +1 -0
  31. package/dist/admin/panels/ModerationActionsPanel.d.ts +28 -0
  32. package/dist/admin/panels/ModerationActionsPanel.d.ts.map +1 -0
  33. package/dist/admin/panels/ModerationActionsPanel.js +111 -0
  34. package/dist/admin/panels/ModerationActionsPanel.js.map +1 -0
  35. package/dist/admin/panels/RestrictionsPanel.d.ts +24 -0
  36. package/dist/admin/panels/RestrictionsPanel.d.ts.map +1 -0
  37. package/dist/admin/panels/RestrictionsPanel.js +121 -0
  38. package/dist/admin/panels/RestrictionsPanel.js.map +1 -0
  39. package/dist/admin/panels/VatValidationPanel.d.ts +28 -0
  40. package/dist/admin/panels/VatValidationPanel.d.ts.map +1 -0
  41. package/dist/admin/panels/VatValidationPanel.js +79 -0
  42. package/dist/admin/panels/VatValidationPanel.js.map +1 -0
  43. package/dist/backend/commands/move.command.d.ts +11 -0
  44. package/dist/backend/commands/move.command.d.ts.map +1 -0
  45. package/dist/backend/commands/move.command.js +11 -0
  46. package/dist/backend/commands/move.command.js.map +1 -0
  47. package/dist/backend/commands/set-cart-approval-policy.command.d.ts +31 -0
  48. package/dist/backend/commands/set-cart-approval-policy.command.d.ts.map +1 -0
  49. package/dist/backend/commands/set-cart-approval-policy.command.js +56 -0
  50. package/dist/backend/commands/set-cart-approval-policy.command.js.map +1 -0
  51. package/dist/backend/commands/set-credit-mode.command.d.ts +16 -0
  52. package/dist/backend/commands/set-credit-mode.command.d.ts.map +1 -0
  53. package/dist/backend/commands/set-credit-mode.command.js +25 -0
  54. package/dist/backend/commands/set-credit-mode.command.js.map +1 -0
  55. package/dist/backend/commands/set-parent.command.d.ts +26 -0
  56. package/dist/backend/commands/set-parent.command.d.ts.map +1 -0
  57. package/dist/backend/commands/set-parent.command.js +51 -0
  58. package/dist/backend/commands/set-parent.command.js.map +1 -0
  59. package/dist/backend/demo/reset.d.ts +20 -0
  60. package/dist/backend/demo/reset.d.ts.map +1 -0
  61. package/dist/backend/demo/reset.js +11 -0
  62. package/dist/backend/demo/reset.js.map +1 -0
  63. package/dist/backend/demo/rows.d.ts +44 -0
  64. package/dist/backend/demo/rows.d.ts.map +1 -0
  65. package/dist/backend/demo/rows.js +44 -0
  66. package/dist/backend/demo/rows.js.map +1 -0
  67. package/dist/backend/demo/seed.d.ts +20 -0
  68. package/dist/backend/demo/seed.d.ts.map +1 -0
  69. package/dist/backend/demo/seed.js +28 -0
  70. package/dist/backend/demo/seed.js.map +1 -0
  71. package/dist/backend/email-templates/invitation.d.ts +23 -0
  72. package/dist/backend/email-templates/invitation.d.ts.map +1 -0
  73. package/dist/backend/email-templates/invitation.js +35 -0
  74. package/dist/backend/email-templates/invitation.js.map +1 -0
  75. package/dist/backend/email-templates/transactional-defaults.d.ts +54 -0
  76. package/dist/backend/email-templates/transactional-defaults.d.ts.map +1 -0
  77. package/dist/backend/email-templates/transactional-defaults.js +242 -0
  78. package/dist/backend/email-templates/transactional-defaults.js.map +1 -0
  79. package/dist/backend/email-templates/verification.d.ts +14 -0
  80. package/dist/backend/email-templates/verification.d.ts.map +1 -0
  81. package/dist/backend/email-templates/verification.js +34 -0
  82. package/dist/backend/email-templates/verification.js.map +1 -0
  83. package/dist/backend/entities/email-verification-token.entity.d.ts +17 -0
  84. package/dist/backend/entities/email-verification-token.entity.d.ts.map +1 -0
  85. package/dist/backend/entities/email-verification-token.entity.js +60 -0
  86. package/dist/backend/entities/email-verification-token.entity.js.map +1 -0
  87. package/dist/backend/entities/organization-delivery-method-link.entity.d.ts +14 -0
  88. package/dist/backend/entities/organization-delivery-method-link.entity.d.ts.map +1 -0
  89. package/dist/backend/entities/organization-delivery-method-link.entity.js +41 -0
  90. package/dist/backend/entities/organization-delivery-method-link.entity.js.map +1 -0
  91. package/dist/backend/entities/organization-invitation.entity.d.ts +21 -0
  92. package/dist/backend/entities/organization-invitation.entity.d.ts.map +1 -0
  93. package/dist/backend/entities/organization-invitation.entity.js +85 -0
  94. package/dist/backend/entities/organization-invitation.entity.js.map +1 -0
  95. package/dist/backend/entities/organization-payment-method-link.entity.d.ts +14 -0
  96. package/dist/backend/entities/organization-payment-method-link.entity.d.ts.map +1 -0
  97. package/dist/backend/entities/organization-payment-method-link.entity.js +41 -0
  98. package/dist/backend/entities/organization-payment-method-link.entity.js.map +1 -0
  99. package/dist/backend/entities/organization-sales-rep-assignment.entity.d.ts +17 -0
  100. package/dist/backend/entities/organization-sales-rep-assignment.entity.d.ts.map +1 -0
  101. package/dist/backend/entities/organization-sales-rep-assignment.entity.js +56 -0
  102. package/dist/backend/entities/organization-sales-rep-assignment.entity.js.map +1 -0
  103. package/dist/backend/entities/organization-tax-id-validation.entity.d.ts +29 -0
  104. package/dist/backend/entities/organization-tax-id-validation.entity.d.ts.map +1 -0
  105. package/dist/backend/entities/organization-tax-id-validation.entity.js +78 -0
  106. package/dist/backend/entities/organization-tax-id-validation.entity.js.map +1 -0
  107. package/dist/backend/entities/organization-warehouse-link.entity.d.ts +15 -0
  108. package/dist/backend/entities/organization-warehouse-link.entity.d.ts.map +1 -0
  109. package/dist/backend/entities/organization-warehouse-link.entity.js +42 -0
  110. package/dist/backend/entities/organization-warehouse-link.entity.js.map +1 -0
  111. package/dist/backend/entities/organization.entity.d.ts +125 -0
  112. package/dist/backend/entities/organization.entity.d.ts.map +1 -0
  113. package/dist/backend/entities/organization.entity.js +282 -0
  114. package/dist/backend/entities/organization.entity.js.map +1 -0
  115. package/dist/backend/index.d.ts +250 -0
  116. package/dist/backend/index.d.ts.map +1 -0
  117. package/dist/backend/index.js +506 -0
  118. package/dist/backend/index.js.map +1 -0
  119. package/dist/backend/integrations/ministerstwo-finansow-client.d.ts +22 -0
  120. package/dist/backend/integrations/ministerstwo-finansow-client.d.ts.map +1 -0
  121. package/dist/backend/integrations/ministerstwo-finansow-client.js +172 -0
  122. package/dist/backend/integrations/ministerstwo-finansow-client.js.map +1 -0
  123. package/dist/backend/integrations/vies-client.d.ts +18 -0
  124. package/dist/backend/integrations/vies-client.d.ts.map +1 -0
  125. package/dist/backend/integrations/vies-client.js +133 -0
  126. package/dist/backend/integrations/vies-client.js.map +1 -0
  127. package/dist/backend/plugin.d.ts +126 -0
  128. package/dist/backend/plugin.d.ts.map +1 -0
  129. package/dist/backend/plugin.js +139 -0
  130. package/dist/backend/plugin.js.map +1 -0
  131. package/dist/backend/routes.admin.d.ts +66 -0
  132. package/dist/backend/routes.admin.d.ts.map +1 -0
  133. package/dist/backend/routes.admin.js +711 -0
  134. package/dist/backend/routes.admin.js.map +1 -0
  135. package/dist/backend/routes.customer.d.ts +33 -0
  136. package/dist/backend/routes.customer.d.ts.map +1 -0
  137. package/dist/backend/routes.customer.js +139 -0
  138. package/dist/backend/routes.customer.js.map +1 -0
  139. package/dist/backend/routes.members.d.ts +31 -0
  140. package/dist/backend/routes.members.d.ts.map +1 -0
  141. package/dist/backend/routes.members.js +109 -0
  142. package/dist/backend/routes.members.js.map +1 -0
  143. package/dist/backend/routes.public.d.ts +49 -0
  144. package/dist/backend/routes.public.d.ts.map +1 -0
  145. package/dist/backend/routes.public.js +220 -0
  146. package/dist/backend/routes.public.js.map +1 -0
  147. package/dist/backend/routes.sales-reps.d.ts +46 -0
  148. package/dist/backend/routes.sales-reps.d.ts.map +1 -0
  149. package/dist/backend/routes.sales-reps.js +114 -0
  150. package/dist/backend/routes.sales-reps.js.map +1 -0
  151. package/dist/backend/routes.storefront.d.ts +25 -0
  152. package/dist/backend/routes.storefront.d.ts.map +1 -0
  153. package/dist/backend/routes.storefront.js +65 -0
  154. package/dist/backend/routes.storefront.js.map +1 -0
  155. package/dist/backend/schemas/organization.d.ts +59 -0
  156. package/dist/backend/schemas/organization.d.ts.map +1 -0
  157. package/dist/backend/schemas/organization.js +55 -0
  158. package/dist/backend/schemas/organization.js.map +1 -0
  159. package/dist/backend/schemas/settings.d.ts +30 -0
  160. package/dist/backend/schemas/settings.d.ts.map +1 -0
  161. package/dist/backend/schemas/settings.js +35 -0
  162. package/dist/backend/schemas/settings.js.map +1 -0
  163. package/dist/backend/services/email-verification-service.d.ts +45 -0
  164. package/dist/backend/services/email-verification-service.d.ts.map +1 -0
  165. package/dist/backend/services/email-verification-service.js +95 -0
  166. package/dist/backend/services/email-verification-service.js.map +1 -0
  167. package/dist/backend/services/invitation-service.d.ts +85 -0
  168. package/dist/backend/services/invitation-service.d.ts.map +1 -0
  169. package/dist/backend/services/invitation-service.js +266 -0
  170. package/dist/backend/services/invitation-service.js.map +1 -0
  171. package/dist/backend/services/normalize-name.d.ts +14 -0
  172. package/dist/backend/services/normalize-name.d.ts.map +1 -0
  173. package/dist/backend/services/normalize-name.js +14 -0
  174. package/dist/backend/services/normalize-name.js.map +1 -0
  175. package/dist/backend/services/org-registration-notifier.d.ts +36 -0
  176. package/dist/backend/services/org-registration-notifier.d.ts.map +1 -0
  177. package/dist/backend/services/org-registration-notifier.js +109 -0
  178. package/dist/backend/services/org-registration-notifier.js.map +1 -0
  179. package/dist/backend/services/org-template-email.d.ts +18 -0
  180. package/dist/backend/services/org-template-email.d.ts.map +1 -0
  181. package/dist/backend/services/org-template-email.js +16 -0
  182. package/dist/backend/services/org-template-email.js.map +1 -0
  183. package/dist/backend/services/organization-context-service.d.ts +52 -0
  184. package/dist/backend/services/organization-context-service.d.ts.map +1 -0
  185. package/dist/backend/services/organization-context-service.js +70 -0
  186. package/dist/backend/services/organization-context-service.js.map +1 -0
  187. package/dist/backend/services/organization-country-reference.d.ts +11 -0
  188. package/dist/backend/services/organization-country-reference.d.ts.map +1 -0
  189. package/dist/backend/services/organization-country-reference.js +24 -0
  190. package/dist/backend/services/organization-country-reference.js.map +1 -0
  191. package/dist/backend/services/organization-details-port.d.ts +33 -0
  192. package/dist/backend/services/organization-details-port.d.ts.map +1 -0
  193. package/dist/backend/services/organization-details-port.js +95 -0
  194. package/dist/backend/services/organization-details-port.js.map +1 -0
  195. package/dist/backend/services/organization-effective-pricelists-service.d.ts +50 -0
  196. package/dist/backend/services/organization-effective-pricelists-service.d.ts.map +1 -0
  197. package/dist/backend/services/organization-effective-pricelists-service.js +68 -0
  198. package/dist/backend/services/organization-effective-pricelists-service.js.map +1 -0
  199. package/dist/backend/services/organization-inheritance-service.d.ts +73 -0
  200. package/dist/backend/services/organization-inheritance-service.d.ts.map +1 -0
  201. package/dist/backend/services/organization-inheritance-service.js +63 -0
  202. package/dist/backend/services/organization-inheritance-service.js.map +1 -0
  203. package/dist/backend/services/organization-moderation-service.d.ts +124 -0
  204. package/dist/backend/services/organization-moderation-service.d.ts.map +1 -0
  205. package/dist/backend/services/organization-moderation-service.js +337 -0
  206. package/dist/backend/services/organization-moderation-service.js.map +1 -0
  207. package/dist/backend/services/organization-restriction-service.d.ts +70 -0
  208. package/dist/backend/services/organization-restriction-service.d.ts.map +1 -0
  209. package/dist/backend/services/organization-restriction-service.js +210 -0
  210. package/dist/backend/services/organization-restriction-service.js.map +1 -0
  211. package/dist/backend/services/organization-tax-id-validation-service.d.ts +59 -0
  212. package/dist/backend/services/organization-tax-id-validation-service.d.ts.map +1 -0
  213. package/dist/backend/services/organization-tax-id-validation-service.js +115 -0
  214. package/dist/backend/services/organization-tax-id-validation-service.js.map +1 -0
  215. package/dist/backend/services/organization-tree-service.d.ts +102 -0
  216. package/dist/backend/services/organization-tree-service.d.ts.map +1 -0
  217. package/dist/backend/services/organization-tree-service.js +184 -0
  218. package/dist/backend/services/organization-tree-service.js.map +1 -0
  219. package/dist/backend/services/personal-organization-service.d.ts +130 -0
  220. package/dist/backend/services/personal-organization-service.d.ts.map +1 -0
  221. package/dist/backend/services/personal-organization-service.js +207 -0
  222. package/dist/backend/services/personal-organization-service.js.map +1 -0
  223. package/dist/backend/services/registration-service.d.ts +80 -0
  224. package/dist/backend/services/registration-service.d.ts.map +1 -0
  225. package/dist/backend/services/registration-service.js +126 -0
  226. package/dist/backend/services/registration-service.js.map +1 -0
  227. package/dist/backend/services/sales-rep-assignment-service.d.ts +89 -0
  228. package/dist/backend/services/sales-rep-assignment-service.d.ts.map +1 -0
  229. package/dist/backend/services/sales-rep-assignment-service.js +176 -0
  230. package/dist/backend/services/sales-rep-assignment-service.js.map +1 -0
  231. package/dist/backend/services/vat-validator-port.d.ts +20 -0
  232. package/dist/backend/services/vat-validator-port.d.ts.map +1 -0
  233. package/dist/backend/services/vat-validator-port.js +2 -0
  234. package/dist/backend/services/vat-validator-port.js.map +1 -0
  235. package/dist/manifest.d.ts +176 -0
  236. package/dist/manifest.d.ts.map +1 -0
  237. package/dist/manifest.js +503 -0
  238. package/dist/manifest.js.map +1 -0
  239. package/dist/migrations/20260424T205317_organizations_init.d.ts +13 -0
  240. package/dist/migrations/20260424T205317_organizations_init.d.ts.map +1 -0
  241. package/dist/migrations/20260424T205317_organizations_init.js +100 -0
  242. package/dist/migrations/20260424T205317_organizations_init.js.map +1 -0
  243. package/dist/migrations/20260425T051700_organizations_invitations_init.d.ts +13 -0
  244. package/dist/migrations/20260425T051700_organizations_invitations_init.d.ts.map +1 -0
  245. package/dist/migrations/20260425T051700_organizations_invitations_init.js +39 -0
  246. package/dist/migrations/20260425T051700_organizations_invitations_init.js.map +1 -0
  247. package/dist/migrations/20260611T140349_organizations_consolidation.d.ts +35 -0
  248. package/dist/migrations/20260611T140349_organizations_consolidation.d.ts.map +1 -0
  249. package/dist/migrations/20260611T140349_organizations_consolidation.js +180 -0
  250. package/dist/migrations/20260611T140349_organizations_consolidation.js.map +1 -0
  251. package/dist/migrations/20260611T140358_organizations_org_order_confirmation_emails.d.ts +10 -0
  252. package/dist/migrations/20260611T140358_organizations_org_order_confirmation_emails.d.ts.map +1 -0
  253. package/dist/migrations/20260611T140358_organizations_org_order_confirmation_emails.js +14 -0
  254. package/dist/migrations/20260611T140358_organizations_org_order_confirmation_emails.js.map +1 -0
  255. package/dist/migrations/20260611T140402_organizations_org_fulfilment_strategy.d.ts +14 -0
  256. package/dist/migrations/20260611T140402_organizations_org_fulfilment_strategy.d.ts.map +1 -0
  257. package/dist/migrations/20260611T140402_organizations_org_fulfilment_strategy.js +20 -0
  258. package/dist/migrations/20260611T140402_organizations_org_fulfilment_strategy.js.map +1 -0
  259. package/dist/migrations/20260717T151403_organizations_personal_organizations.d.ts +24 -0
  260. package/dist/migrations/20260717T151403_organizations_personal_organizations.d.ts.map +1 -0
  261. package/dist/migrations/20260717T151403_organizations_personal_organizations.js +63 -0
  262. package/dist/migrations/20260717T151403_organizations_personal_organizations.js.map +1 -0
  263. package/dist/migrations/20260718T200340_organizations_organization_custom_field_values.d.ts +12 -0
  264. package/dist/migrations/20260718T200340_organizations_organization_custom_field_values.d.ts.map +1 -0
  265. package/dist/migrations/20260718T200340_organizations_organization_custom_field_values.js +16 -0
  266. package/dist/migrations/20260718T200340_organizations_organization_custom_field_values.js.map +1 -0
  267. package/dist/migrations/20260720T044254_organizations_org_hierarchy.d.ts +23 -0
  268. package/dist/migrations/20260720T044254_organizations_org_hierarchy.d.ts.map +1 -0
  269. package/dist/migrations/20260720T044254_organizations_org_hierarchy.js +37 -0
  270. package/dist/migrations/20260720T044254_organizations_org_hierarchy.js.map +1 -0
  271. package/dist/migrations/20260912T094646_organizations_sales_channel_organizations.d.ts +27 -0
  272. package/dist/migrations/20260912T094646_organizations_sales_channel_organizations.d.ts.map +1 -0
  273. package/dist/migrations/20260912T094646_organizations_sales_channel_organizations.js +44 -0
  274. package/dist/migrations/20260912T094646_organizations_sales_channel_organizations.js.map +1 -0
  275. package/dist/migrations/index.d.ts +35 -0
  276. package/dist/migrations/index.d.ts.map +1 -0
  277. package/dist/migrations/index.js +45 -0
  278. package/dist/migrations/index.js.map +1 -0
  279. package/dist/ports/index.d.ts +53 -0
  280. package/dist/ports/index.d.ts.map +1 -0
  281. package/dist/ports/index.js +2 -0
  282. package/dist/ports/index.js.map +1 -0
  283. package/docs/organization-hierarchy.md +117 -0
  284. package/docs/organizations.md +312 -0
  285. package/i18n/en.json +17 -0
  286. package/i18n/pl.json +17 -0
  287. package/package.json +107 -0
  288. package/tailwind.css +14 -0
@@ -0,0 +1,56 @@
1
+ import { ERROR_CODES } from '@endora-commerce/contracts';
2
+ import { HttpError } from '@endora-commerce/platform/http';
3
+ import { Organization } from '../entities/organization.entity.js';
4
+ import { toOrganizationRecord } from '../services/organization-details-port.js';
5
+ /**
6
+ * `organization.set_cart_approval_policy` (issue #175, Principle XIII).
7
+ *
8
+ * Flips `organizations.requires_cart_approval` — the per-organisation "an Org
9
+ * Admin must approve a cart before checkout" policy of feature 027 US4.
10
+ *
11
+ * The write used to live in `carts` (`CartApprovalService.setPolicy*`), which
12
+ * held this module's entity to do it. Moving it here is what D-78 step 1 asks
13
+ * for, and it settles the question the direct write had been ducking: the flip
14
+ * has never carried an audit row on the `organizations` side, and under
15
+ * Constitution XIII it must. Hence a Command rather than a plain service
16
+ * method — the actor is derived from the caller's ambient context by the bus,
17
+ * never passed in, so the same Command serves the platform-admin route and the
18
+ * Org-Admin self-service one and records which of them it was.
19
+ *
20
+ * Idempotent: a write of the value the row already carries mutates nothing and
21
+ * records nothing (`skipAudit`), because an audit row saying a change happened
22
+ * when none did is worse than no row. That is also the behaviour `carts` had,
23
+ * and its cascade keys off `changed`.
24
+ *
25
+ * The lookup is `{ id }` with no `deletedAt` filter, deliberately: it is the
26
+ * predicate the two `setPolicy*` methods used, and narrowing it here would be a
27
+ * behaviour change riding along with a relocation.
28
+ */
29
+ export function makeSetCartApprovalPolicyCommand(input) {
30
+ return {
31
+ action: 'organization.set_cart_approval_policy',
32
+ objectType: 'organization',
33
+ objectId: input.organizationId,
34
+ run: async ({ em }) => {
35
+ const org = await em.findOne(Organization, { id: input.organizationId });
36
+ if (!org) {
37
+ throw new HttpError(404, ERROR_CODES.NOT_FOUND, 'organization_not_found');
38
+ }
39
+ if (org.requiresCartApproval === input.requiresCartApproval) {
40
+ return {
41
+ result: { organization: toOrganizationRecord(org), changed: false },
42
+ skipAudit: true,
43
+ };
44
+ }
45
+ const before = { requiresCartApproval: org.requiresCartApproval };
46
+ org.requiresCartApproval = input.requiresCartApproval;
47
+ await em.flush();
48
+ return {
49
+ result: { organization: toOrganizationRecord(org), changed: true },
50
+ before,
51
+ after: { requiresCartApproval: input.requiresCartApproval },
52
+ };
53
+ },
54
+ };
55
+ }
56
+ //# sourceMappingURL=set-cart-approval-policy.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-cart-approval-policy.command.js","sourceRoot":"","sources":["../../../src/backend/commands/set-cart-approval-policy.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAsC,MAAM,4BAA4B,CAAC;AAE7F,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,gCAAgC,CAAC,KAGhD;IACC,OAAO;QACL,MAAM,EAAE,uCAAuC;QAC/C,UAAU,EAAE,cAAc;QAC1B,QAAQ,EAAE,KAAK,CAAC,cAAc;QAC9B,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;YACpB,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC;YACzE,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,IAAI,SAAS,CAAC,GAAG,EAAE,WAAW,CAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC;YAC5E,CAAC;YACD,IAAI,GAAG,CAAC,oBAAoB,KAAK,KAAK,CAAC,oBAAoB,EAAE,CAAC;gBAC5D,OAAO;oBACL,MAAM,EAAE,EAAE,YAAY,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE;oBACnE,SAAS,EAAE,IAAI;iBAChB,CAAC;YACJ,CAAC;YACD,MAAM,MAAM,GAAG,EAAE,oBAAoB,EAAE,GAAG,CAAC,oBAAoB,EAAE,CAAC;YAClE,GAAG,CAAC,oBAAoB,GAAG,KAAK,CAAC,oBAAoB,CAAC;YACtD,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO;gBACL,MAAM,EAAE,EAAE,YAAY,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;gBAClE,MAAM;gBACN,KAAK,EAAE,EAAE,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,EAAE;aAC5D,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Command } from '@endora-commerce/platform/commands';
2
+ import { Organization } from '../entities/organization.entity.js';
3
+ /**
4
+ * `organization.set_credit_mode` (feature 056 US3, Principle XIII).
5
+ *
6
+ * Platform-admin-only change of a per-organization credit-inheritance mode
7
+ * override (`shared_pool` | `independent_default` | `null` ⇒ Settings global
8
+ * default). This is a money-behavior switch, so the route rejects any scoped /
9
+ * roll-up actor (403) before running the Command; the Command owns the audit.
10
+ */
11
+ export type CreditInheritanceModeValue = 'shared_pool' | 'independent_default' | null;
12
+ export declare function makeSetCreditModeCommand(input: {
13
+ organizationId: string;
14
+ mode: CreditInheritanceModeValue;
15
+ }): Command<Organization>;
16
+ //# sourceMappingURL=set-credit-mode.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-credit-mode.command.d.ts","sourceRoot":"","sources":["../../../src/backend/commands/set-credit-mode.command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE;;;;;;;GAOG;AACH,MAAM,MAAM,0BAA0B,GAAG,aAAa,GAAG,qBAAqB,GAAG,IAAI,CAAC;AAEtF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,0BAA0B,CAAC;CAClC,GAAG,OAAO,CAAC,YAAY,CAAC,CAoBxB"}
@@ -0,0 +1,25 @@
1
+ import { ERROR_CODES } from '@endora-commerce/contracts';
2
+ import { HttpError } from '@endora-commerce/platform/http';
3
+ import { Organization } from '../entities/organization.entity.js';
4
+ export function makeSetCreditModeCommand(input) {
5
+ return {
6
+ action: 'organization.set_credit_mode',
7
+ objectType: 'organization',
8
+ objectId: input.organizationId,
9
+ run: async ({ em }) => {
10
+ const org = await em.findOne(Organization, { id: input.organizationId, deletedAt: null });
11
+ if (!org) {
12
+ throw new HttpError(404, ERROR_CODES.NOT_FOUND, 'Organization not found.');
13
+ }
14
+ const before = { creditInheritanceMode: org.creditInheritanceMode ?? null };
15
+ org.creditInheritanceMode = input.mode;
16
+ await em.flush();
17
+ return {
18
+ result: org,
19
+ before,
20
+ after: { creditInheritanceMode: input.mode },
21
+ };
22
+ },
23
+ };
24
+ }
25
+ //# sourceMappingURL=set-credit-mode.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-credit-mode.command.js","sourceRoot":"","sources":["../../../src/backend/commands/set-credit-mode.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAYlE,MAAM,UAAU,wBAAwB,CAAC,KAGxC;IACC,OAAO;QACL,MAAM,EAAE,8BAA8B;QACtC,UAAU,EAAE,cAAc;QAC1B,QAAQ,EAAE,KAAK,CAAC,cAAc;QAC9B,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;YACpB,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1F,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,IAAI,SAAS,CAAC,GAAG,EAAE,WAAW,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;YAC7E,CAAC;YACD,MAAM,MAAM,GAAG,EAAE,qBAAqB,EAAE,GAAG,CAAC,qBAAqB,IAAI,IAAI,EAAE,CAAC;YAC5E,GAAG,CAAC,qBAAqB,GAAG,KAAK,CAAC,IAAI,CAAC;YACvC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO;gBACL,MAAM,EAAE,GAAG;gBACX,MAAM;gBACN,KAAK,EAAE,EAAE,qBAAqB,EAAE,KAAK,CAAC,IAAI,EAAE;aAC7C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { Command } from '@endora-commerce/platform/commands';
2
+ import { Organization } from '../entities/organization.entity.js';
3
+ import type { OrganizationTreeService } from '../services/organization-tree-service.js';
4
+ /**
5
+ * Tree re-parent Commands (feature 056 US1, Principle XIII).
6
+ *
7
+ * `organization.set_parent` (first-assign / detach) and `organization.move`
8
+ * (re-parent an existing child) share the same mechanism — cycle + depth
9
+ * checks, then a single-UPDATE subtree path rewrite via the tree service. Both
10
+ * are **reversible**: the audit `stateBefore` captures the node's prior
11
+ * `parent_id` + the moved subtree's prior `path` values, so a mis-move can be
12
+ * undone.
13
+ */
14
+ export interface ReparentCommandDeps {
15
+ tree: OrganizationTreeService;
16
+ }
17
+ export interface ReparentCommandInput {
18
+ organizationId: string;
19
+ /** `null` ⇒ detach `:id` to a root. */
20
+ parentId: string | null;
21
+ }
22
+ /** Shared factory for the two re-parent actions. */
23
+ export declare function makeReparentCommand(action: 'organization.set_parent' | 'organization.move', deps: ReparentCommandDeps, input: ReparentCommandInput): Command<Organization>;
24
+ /** `organization.set_parent` — assign a first parent or detach to a root. */
25
+ export declare function makeSetParentCommand(deps: ReparentCommandDeps, input: ReparentCommandInput): Command<Organization>;
26
+ //# sourceMappingURL=set-parent.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-parent.command.d.ts","sourceRoot":"","sources":["../../../src/backend/commands/set-parent.command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAExF;;;;;;;;;GASG;AAEH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,uBAAuB,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,oDAAoD;AACpD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,yBAAyB,GAAG,mBAAmB,EACvD,IAAI,EAAE,mBAAmB,EACzB,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,YAAY,CAAC,CA6CvB;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,mBAAmB,EACzB,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAEvB"}
@@ -0,0 +1,51 @@
1
+ import { ERROR_CODES } from '@endora-commerce/contracts';
2
+ import { HttpError } from '@endora-commerce/platform/http';
3
+ import { Organization } from '../entities/organization.entity.js';
4
+ /** Shared factory for the two re-parent actions. */
5
+ export function makeReparentCommand(action, deps, input) {
6
+ return {
7
+ action,
8
+ objectType: 'organization',
9
+ objectId: input.organizationId,
10
+ run: async ({ em }) => {
11
+ const node = await em.findOne(Organization, {
12
+ id: input.organizationId,
13
+ deletedAt: null,
14
+ });
15
+ if (!node) {
16
+ // 404 is indistinguishable from out-of-scope (Principle XI).
17
+ throw new HttpError(404, ERROR_CODES.NOT_FOUND, 'Organization not found.');
18
+ }
19
+ let newParent = null;
20
+ if (input.parentId !== null) {
21
+ newParent = await em.findOne(Organization, { id: input.parentId, deletedAt: null });
22
+ if (!newParent) {
23
+ throw new HttpError(404, ERROR_CODES.NOT_FOUND, 'Parent organization not found.');
24
+ }
25
+ }
26
+ const beforeParentId = node.parentId ?? null;
27
+ const beforePath = node.path;
28
+ deps.tree.assertNoCycle(node, newParent);
29
+ await deps.tree.assertMaxDepth(em, node, newParent);
30
+ const { affected } = await deps.tree.applyReparentPaths(em, node, newParent);
31
+ await em.flush();
32
+ return {
33
+ result: node,
34
+ before: {
35
+ parentId: beforeParentId,
36
+ path: beforePath,
37
+ subtreePaths: affected,
38
+ },
39
+ after: {
40
+ parentId: node.parentId ?? null,
41
+ path: node.path,
42
+ },
43
+ };
44
+ },
45
+ };
46
+ }
47
+ /** `organization.set_parent` — assign a first parent or detach to a root. */
48
+ export function makeSetParentCommand(deps, input) {
49
+ return makeReparentCommand('organization.set_parent', deps, input);
50
+ }
51
+ //# sourceMappingURL=set-parent.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-parent.command.js","sourceRoot":"","sources":["../../../src/backend/commands/set-parent.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAwBlE,oDAAoD;AACpD,MAAM,UAAU,mBAAmB,CACjC,MAAuD,EACvD,IAAyB,EACzB,KAA2B;IAE3B,OAAO;QACL,MAAM;QACN,UAAU,EAAE,cAAc;QAC1B,QAAQ,EAAE,KAAK,CAAC,cAAc;QAC9B,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;YACpB,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE;gBAC1C,EAAE,EAAE,KAAK,CAAC,cAAc;gBACxB,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;YACH,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,6DAA6D;gBAC7D,MAAM,IAAI,SAAS,CAAC,GAAG,EAAE,WAAW,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;YAC7E,CAAC;YAED,IAAI,SAAS,GAAwB,IAAI,CAAC;YAC1C,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;gBAC5B,SAAS,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBACpF,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,MAAM,IAAI,SAAS,CAAC,GAAG,EAAE,WAAW,CAAC,SAAS,EAAE,gCAAgC,CAAC,CAAC;gBACpF,CAAC;YACH,CAAC;YAED,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;YAC7C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC;YAE7B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YACzC,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;YACpD,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;YAC7E,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;YAEjB,OAAO;gBACL,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE;oBACN,QAAQ,EAAE,cAAc;oBACxB,IAAI,EAAE,UAAU;oBAChB,YAAY,EAAE,QAAQ;iBACvB;gBACD,KAAK,EAAE;oBACL,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI;oBAC/B,IAAI,EAAE,IAAI,CAAC,IAAI;iBAChB;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,oBAAoB,CAClC,IAAyB,EACzB,KAA2B;IAE3B,OAAO,mBAAmB,CAAC,yBAAyB,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACrE,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Withdraw `organizations`' demo data (feature 113, T222 — contract §2.5).
3
+ *
4
+ * By the fixed tax id `seed` assigns, never by a predicate over the table. This
5
+ * is the withdrawal that replaces `organizations`' line in the host's
6
+ * `truncate … cascade`, and the replacement is a repair rather than a
7
+ * relocation: an organisation is the tenant every buyer, address, cart, quote
8
+ * request and order hangs off (Principle XI), so that one word took a
9
+ * developer's entire test tenancy with it through the cascade, silently, on
10
+ * every `seed:dev`.
11
+ *
12
+ * The buyer who belongs to this organisation and the credit limit granted to it
13
+ * are withdrawn first, by the composition: `reset` runs the composition's
14
+ * withdrawal before any module's (§5.5), which is also what leaves no row
15
+ * referencing the organisation deleted below.
16
+ */
17
+ import type { DemoResetResult, ModuleDemoContext } from '@endora-commerce/contracts';
18
+ import type { ModuleContext } from '@endora-commerce/platform/kernel';
19
+ export declare function resetDemo(context: ModuleDemoContext<ModuleContext>): Promise<DemoResetResult>;
20
+ //# sourceMappingURL=reset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../../../src/backend/demo/reset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAStE,wBAAsB,SAAS,CAC7B,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,GACxC,OAAO,CAAC,eAAe,CAAC,CAO1B"}
@@ -0,0 +1,11 @@
1
+ import { Organization } from '../entities/organization.entity.js';
2
+ import { DEMO_ORGANIZATION } from './rows.js';
3
+ export async function resetDemo(context) {
4
+ // command-coverage-ignore: the withdrawal half of the demo data above. Same
5
+ // entry point, same `mustBeNonProduction()` guard, same absence of an
6
+ // operator to attribute the write to (contract §2.7).
7
+ const em = context.ctx.cradle().emFactory();
8
+ const removed = await em.nativeDelete(Organization, { taxId: DEMO_ORGANIZATION.taxId });
9
+ return { removed: [{ entity: 'Organization', count: removed }] };
10
+ }
11
+ //# sourceMappingURL=reset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../src/backend/demo/reset.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAM9C,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,OAAyC;IAEzC,4EAA4E;IAC5E,sEAAsE;IACtE,sDAAsD;IACtD,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAA2B,CAAC,SAAS,EAAE,CAAC;IACrE,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,iBAAiB,CAAC,KAAK,EAAE,CAAC,CAAC;IACxF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AACnE,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The organisation this module's demo data creates (feature 113, T222).
3
+ *
4
+ * One place holding the data, imported by both bodies: `seed.ts` creates this
5
+ * row and `reset.ts` withdraws exactly it, by the `taxId` it is keyed on
6
+ * (contract §2.5) — the column the installation declares unique, and the one the
7
+ * instance composition already resolves the demo organisation by.
8
+ *
9
+ * The values are the host seed's verbatim, moved rather than rewritten. The
10
+ * frozen copy the parity comparison read them against is deleted with that
11
+ * comparison (T226); what holds them now is
12
+ * `test/integration/demo/demo-shop.test.ts`' recorded delta.
13
+ *
14
+ * ## What is not here
15
+ *
16
+ * The demo **buyer** and the demo **credit limit**. Both are another module's
17
+ * row against this one's and are therefore composition steps (§5.1):
18
+ * `customer_accounts.organization_id` is `NOT NULL`, so the buyer cannot even be
19
+ * created before it has an organisation, and a grant is `credit_limits`' row
20
+ * whose whole content is a reference to this one.
21
+ *
22
+ * ## §2.6 and the address
23
+ *
24
+ * `Organization.name` is a `varchar(255)` and `registeredAddress` a JSONB
25
+ * snapshot of four scalars, so the per-language shape §2.6 asks for has nowhere
26
+ * to go and putting it there would be a migration this feature does not take
27
+ * (contract §8). None of these values is prose in any case: a company name, a
28
+ * street, a city and a NIP are operator content that reads the same in both
29
+ * shipped languages.
30
+ */
31
+ /** The demo organisation, in `Organization`'s own field names. */
32
+ export declare const DEMO_ORGANIZATION: {
33
+ readonly name: "Acme B2B (demo)";
34
+ readonly taxId: "PL5210000099";
35
+ readonly status: "active";
36
+ readonly vatStatus: "vat_payer";
37
+ readonly registeredAddress: {
38
+ readonly street: "ul. Demo 1";
39
+ readonly city: "Warszawa";
40
+ readonly postalCode: "00-001";
41
+ readonly country: "PL";
42
+ };
43
+ };
44
+ //# sourceMappingURL=rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../../src/backend/demo/rows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,kEAAkE;AAClE,eAAO,MAAM,iBAAiB;;;;;;;;;;;CAWpB,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The organisation this module's demo data creates (feature 113, T222).
3
+ *
4
+ * One place holding the data, imported by both bodies: `seed.ts` creates this
5
+ * row and `reset.ts` withdraws exactly it, by the `taxId` it is keyed on
6
+ * (contract §2.5) — the column the installation declares unique, and the one the
7
+ * instance composition already resolves the demo organisation by.
8
+ *
9
+ * The values are the host seed's verbatim, moved rather than rewritten. The
10
+ * frozen copy the parity comparison read them against is deleted with that
11
+ * comparison (T226); what holds them now is
12
+ * `test/integration/demo/demo-shop.test.ts`' recorded delta.
13
+ *
14
+ * ## What is not here
15
+ *
16
+ * The demo **buyer** and the demo **credit limit**. Both are another module's
17
+ * row against this one's and are therefore composition steps (§5.1):
18
+ * `customer_accounts.organization_id` is `NOT NULL`, so the buyer cannot even be
19
+ * created before it has an organisation, and a grant is `credit_limits`' row
20
+ * whose whole content is a reference to this one.
21
+ *
22
+ * ## §2.6 and the address
23
+ *
24
+ * `Organization.name` is a `varchar(255)` and `registeredAddress` a JSONB
25
+ * snapshot of four scalars, so the per-language shape §2.6 asks for has nowhere
26
+ * to go and putting it there would be a migration this feature does not take
27
+ * (contract §8). None of these values is prose in any case: a company name, a
28
+ * street, a city and a NIP are operator content that reads the same in both
29
+ * shipped languages.
30
+ */
31
+ /** The demo organisation, in `Organization`'s own field names. */
32
+ export const DEMO_ORGANIZATION = {
33
+ name: 'Acme B2B (demo)',
34
+ taxId: 'PL5210000099',
35
+ status: 'active',
36
+ vatStatus: 'vat_payer',
37
+ registeredAddress: {
38
+ street: 'ul. Demo 1',
39
+ city: 'Warszawa',
40
+ postalCode: '00-001',
41
+ country: 'PL',
42
+ },
43
+ };
44
+ //# sourceMappingURL=rows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.js","sourceRoot":"","sources":["../../../src/backend/demo/rows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,kEAAkE;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE,cAAc;IACrB,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,iBAAiB,EAAE;QACjB,MAAM,EAAE,YAAY;QACpB,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE,IAAI;KACd;CACO,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * `organizations`' demo data (feature 113, T222 — contract §2).
3
+ *
4
+ * The buying organisation the demo shop trades with, in the module that owns the
5
+ * table. It writes `organizations` and nothing else (§2.1), reads no other
6
+ * module's table and resolves no port (§2.2), so declaring it added no entry to
7
+ * this module's manifest `dependencies` (§2.3).
8
+ *
9
+ * **The buyer who belongs to it and the credit limit granted to it are not
10
+ * here.** Each is another module's row against this one's, so each is a
11
+ * composition step (§5.1) in `backend/src/seeds/demo-composition.ts`, which runs
12
+ * after every module's `seed` and finds this organisation waiting.
13
+ *
14
+ * Idempotent by an existence probe on the natural key (§2.4): a second run
15
+ * creates nothing and reports the same count.
16
+ */
17
+ import type { DemoSeedResult, ModuleDemoContext } from '@endora-commerce/contracts';
18
+ import type { ModuleContext } from '@endora-commerce/platform/kernel';
19
+ export declare function seedDemo(context: ModuleDemoContext<ModuleContext>): Promise<DemoSeedResult>;
20
+ //# sourceMappingURL=seed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../../src/backend/demo/seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAUtE,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,GACxC,OAAO,CAAC,cAAc,CAAC,CA0BzB"}
@@ -0,0 +1,28 @@
1
+ import { Organization } from '../entities/organization.entity.js';
2
+ import { DEMO_ORGANIZATION } from './rows.js';
3
+ export async function seedDemo(context) {
4
+ // command-coverage-ignore: demo data, reached only by `endora demo seed`,
5
+ // whose entry point calls `mustBeNonProduction()` as its first statement and
6
+ // outside every `try` (contract §2.7, §3.3). The guard is the enforcement:
7
+ // this write has no operator, no tenant and no audit reader, and the command
8
+ // refuses to run against a production database at all.
9
+ const em = context.ctx.cradle().emFactory();
10
+ const existing = await em.findOne(Organization, { taxId: DEMO_ORGANIZATION.taxId });
11
+ // Present already: left exactly as it is. An operator may have renamed it or
12
+ // moved it through moderation, and overwriting that here would be this body
13
+ // deciding its own literal outranks their change.
14
+ if (!existing) {
15
+ em.create(Organization, {
16
+ name: DEMO_ORGANIZATION.name,
17
+ taxId: DEMO_ORGANIZATION.taxId,
18
+ status: DEMO_ORGANIZATION.status,
19
+ vatStatus: DEMO_ORGANIZATION.vatStatus,
20
+ registeredAddress: { ...DEMO_ORGANIZATION.registeredAddress },
21
+ });
22
+ await em.flush();
23
+ }
24
+ // What the demo *holds* after the run, not what this call inserted: seeding
25
+ // twice must report the same counts (`DemoEntityCount`).
26
+ return { created: [{ entity: 'Organization', count: 1 }] };
27
+ }
28
+ //# sourceMappingURL=seed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.js","sourceRoot":"","sources":["../../../src/backend/demo/seed.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAO9C,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,OAAyC;IAEzC,0EAA0E;IAC1E,6EAA6E;IAC7E,2EAA2E;IAC3E,6EAA6E;IAC7E,uDAAuD;IACvD,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAA2B,CAAC,SAAS,EAAE,CAAC;IAErE,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,iBAAiB,CAAC,KAAK,EAAE,CAAC,CAAC;IACpF,6EAA6E;IAC7E,4EAA4E;IAC5E,kDAAkD;IAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE;YACtB,IAAI,EAAE,iBAAiB,CAAC,IAAI;YAC5B,KAAK,EAAE,iBAAiB,CAAC,KAAK;YAC9B,MAAM,EAAE,iBAAiB,CAAC,MAAM;YAChC,SAAS,EAAE,iBAAiB,CAAC,SAAS;YACtC,iBAAiB,EAAE,EAAE,GAAG,iBAAiB,CAAC,iBAAiB,EAAE;SAC9D,CAAC,CAAC;QACH,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;IAED,4EAA4E;IAC5E,yDAAyD;IACzD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { EmailMailerSendInput } from '@endora-commerce/contracts';
2
+ /**
3
+ * Invitation email template (T178 / FR-043).
4
+ *
5
+ * Pure builder — takes the raw token (returned by InvitationService.invite)
6
+ * plus the surrounding context, returns the EmailMailerSendInput an Org Admin
7
+ * can dispatch via any Mailer. Kept template-y on purpose: production can
8
+ * swap in an HTML renderer by widening Mailer; today the plain-text body
9
+ * is enough for the SMTP transport and the in-memory test mailer alike.
10
+ */
11
+ export interface BuildInvitationEmailInput {
12
+ invitationId: string;
13
+ rawToken: string;
14
+ inviteeEmail: string;
15
+ inviterName: string;
16
+ organizationName: string;
17
+ role: 'organization_admin' | 'regular_user';
18
+ expiresAt: Date;
19
+ /** Storefront base URL used to build the redemption link. */
20
+ acceptBaseUrl: string;
21
+ }
22
+ export declare function buildInvitationEmail(input: BuildInvitationEmailInput): EmailMailerSendInput;
23
+ //# sourceMappingURL=invitation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invitation.d.ts","sourceRoot":"","sources":["../../../src/backend/email-templates/invitation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEvE;;;;;;;;GAQG;AAEH,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,oBAAoB,GAAG,cAAc,CAAC;IAC5C,SAAS,EAAE,IAAI,CAAC;IAChB,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,oBAAoB,CAgC3F"}
@@ -0,0 +1,35 @@
1
+ export function buildInvitationEmail(input) {
2
+ const acceptUrl = `${trimSlash(input.acceptBaseUrl)}/invitations/${input.rawToken}/accept`;
3
+ const roleLabel = input.role === 'organization_admin' ? 'Organization Admin' : 'Member';
4
+ const expiresOn = input.expiresAt.toISOString().slice(0, 10);
5
+ const text = [
6
+ `Hi,`,
7
+ ``,
8
+ `${input.inviterName} invited you to join "${input.organizationName}" on the B2B platform`,
9
+ `as ${roleLabel}.`,
10
+ ``,
11
+ `Accept the invitation here (link expires ${expiresOn}):`,
12
+ acceptUrl,
13
+ ``,
14
+ `If you did not expect this email, you can safely ignore it — the link will`,
15
+ `expire on its own and no account will be created.`,
16
+ ].join('\n');
17
+ return {
18
+ messageId: `invitation:${input.invitationId}`,
19
+ to: input.inviteeEmail,
20
+ subject: `You're invited to join ${input.organizationName}`,
21
+ text,
22
+ meta: {
23
+ kind: 'organization_invitation',
24
+ invitationId: input.invitationId,
25
+ organizationName: input.organizationName,
26
+ role: input.role,
27
+ expiresAt: input.expiresAt.toISOString(),
28
+ acceptUrl,
29
+ },
30
+ };
31
+ }
32
+ function trimSlash(s) {
33
+ return s.endsWith('/') ? s.slice(0, -1) : s;
34
+ }
35
+ //# sourceMappingURL=invitation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invitation.js","sourceRoot":"","sources":["../../../src/backend/email-templates/invitation.ts"],"names":[],"mappings":"AAwBA,MAAM,UAAU,oBAAoB,CAAC,KAAgC;IACnE,MAAM,SAAS,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,aAAa,CAAC,gBAAgB,KAAK,CAAC,QAAQ,SAAS,CAAC;IAC3F,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,KAAK,oBAAoB,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC;IACxF,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAE7D,MAAM,IAAI,GAAG;QACX,KAAK;QACL,EAAE;QACF,GAAG,KAAK,CAAC,WAAW,yBAAyB,KAAK,CAAC,gBAAgB,uBAAuB;QAC1F,MAAM,SAAS,GAAG;QAClB,EAAE;QACF,4CAA4C,SAAS,IAAI;QACzD,SAAS;QACT,EAAE;QACF,4EAA4E;QAC5E,mDAAmD;KACpD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,OAAO;QACL,SAAS,EAAE,cAAc,KAAK,CAAC,YAAY,EAAE;QAC7C,EAAE,EAAE,KAAK,CAAC,YAAY;QACtB,OAAO,EAAE,0BAA0B,KAAK,CAAC,gBAAgB,EAAE;QAC3D,IAAI;QACJ,IAAI,EAAE;YACJ,IAAI,EAAE,yBAAyB;YAC/B,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;YACxC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE;YACxC,SAAS;SACV;KACF,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,CAAS;IAC1B,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,54 @@
1
+ export declare const EMAIL_VERIFICATION_DEFAULT: {
2
+ defaultSubject: Record<string, string>;
3
+ defaultContent: Record<string, unknown>;
4
+ languages: string[];
5
+ nonDeactivatable: {
6
+ readonly reason: string;
7
+ };
8
+ };
9
+ export declare const ORGANIZATION_INVITATION_DEFAULT: {
10
+ defaultSubject: Record<string, string>;
11
+ defaultContent: Record<string, unknown>;
12
+ languages: string[];
13
+ nonDeactivatable: {
14
+ readonly reason: string;
15
+ };
16
+ };
17
+ export declare const NEW_ORG_REGISTRATION_DEFAULT: {
18
+ defaultSubject: Record<string, string>;
19
+ defaultContent: Record<string, unknown>;
20
+ languages: string[];
21
+ };
22
+ /**
23
+ * The two messages a moderated organisation's administrator receives
24
+ * (`specs/093-backend-delivered-prose/` § Out of scope — the seam-B carve-out).
25
+ *
26
+ * They were finished Polish sentences composed inside
27
+ * `OrganizationModerationService` and handed straight to the transport: no
28
+ * code, no template, no language. A buyer on an English sales channel received
29
+ * Polish unconditionally, and unlike an operator a buyer has no admin panel to
30
+ * go and check the facts in.
31
+ *
32
+ * English is the primary copy and `en-US` is first in {@link LANGS}, which is
33
+ * what `TransactionalEmailService` passes as the content resolver's
34
+ * `fallbackLanguage` — so a language with no content, and a language that could
35
+ * not be resolved at all, both read English (owner ruling, 2026-09-01). The
36
+ * Polish here is the copy these two e-mails already shipped, moved rather than
37
+ * retranslated.
38
+ *
39
+ * Neither is `nonDeactivatable`. The criterion the two above it meet is
40
+ * "required to create or regain access to an account"; a status notice is not
41
+ * that — the organisation's administrator can sign in and read the same status
42
+ * on their own screen — so switching it off stays an ordinary business choice.
43
+ */
44
+ export declare const ORGANIZATION_APPROVED_DEFAULT: {
45
+ defaultSubject: Record<string, string>;
46
+ defaultContent: Record<string, unknown>;
47
+ languages: string[];
48
+ };
49
+ export declare const ORGANIZATION_REJECTED_DEFAULT: {
50
+ defaultSubject: Record<string, string>;
51
+ defaultContent: Record<string, unknown>;
52
+ languages: string[];
53
+ };
54
+ //# sourceMappingURL=transactional-defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactional-defaults.d.ts","sourceRoot":"","sources":["../../../src/backend/email-templates/transactional-defaults.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,0BAA0B;oBAIhC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;oBAmCtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;CAG7B,CAAC;AAEF,eAAO,MAAM,+BAA+B;oBAIrC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;oBAmCtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;CAG7B,CAAC;AAEF,eAAO,MAAM,4BAA4B;oBAIlC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;oBA+BtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;CAE7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,6BAA6B;oBAInC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;oBA2BtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;CAE7B,CAAC;AAEF,eAAO,MAAM,6BAA6B;oBAInC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;oBA+BtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;CAE7B,CAAC"}