@open-mercato/core 0.8.1-develop.7296.1.2111d779db → 0.8.1-develop.7441.1.b42958b98c

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 (2353) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/AGENTS.md +4 -5
  3. package/dist/generated/entities/availability_policy/index.js +41 -0
  4. package/dist/generated/entities/availability_policy/index.js.map +7 -0
  5. package/dist/generated/entities/communication_channel/index.js +3 -1
  6. package/dist/generated/entities/communication_channel/index.js.map +2 -2
  7. package/dist/generated/entities/customer_email_conversation_share/index.js +21 -0
  8. package/dist/generated/entities/customer_email_conversation_share/index.js.map +7 -0
  9. package/dist/generated/entities/customer_group/index.js +33 -0
  10. package/dist/generated/entities/customer_group/index.js.map +7 -0
  11. package/dist/generated/entities/customer_group_membership/index.js +29 -0
  12. package/dist/generated/entities/customer_group_membership/index.js.map +7 -0
  13. package/dist/generated/entities/customer_group_terms/index.js +33 -0
  14. package/dist/generated/entities/customer_group_terms/index.js.map +7 -0
  15. package/dist/generated/entities/customer_interaction/index.js +2 -0
  16. package/dist/generated/entities/customer_interaction/index.js.map +2 -2
  17. package/dist/generated/entities/form/index.js +35 -0
  18. package/dist/generated/entities/form/index.js.map +7 -0
  19. package/dist/generated/entities/form_access_audit/index.js +21 -0
  20. package/dist/generated/entities/form_access_audit/index.js.map +7 -0
  21. package/dist/generated/entities/form_attachment/index.js +29 -0
  22. package/dist/generated/entities/form_attachment/index.js.map +7 -0
  23. package/dist/generated/entities/form_consent_record/index.js +37 -0
  24. package/dist/generated/entities/form_consent_record/index.js.map +7 -0
  25. package/dist/generated/entities/form_distribution/index.js +47 -0
  26. package/dist/generated/entities/form_distribution/index.js.map +7 -0
  27. package/dist/generated/entities/form_invitation/index.js +49 -0
  28. package/dist/generated/entities/form_invitation/index.js.map +7 -0
  29. package/dist/generated/entities/form_submission/index.js +39 -0
  30. package/dist/generated/entities/form_submission/index.js.map +7 -0
  31. package/dist/generated/entities/form_submission_actor/index.js +23 -0
  32. package/dist/generated/entities/form_submission_actor/index.js.map +7 -0
  33. package/dist/generated/entities/form_submission_revision/index.js +29 -0
  34. package/dist/generated/entities/form_submission_revision/index.js.map +7 -0
  35. package/dist/generated/entities/form_version/index.js +37 -0
  36. package/dist/generated/entities/form_version/index.js.map +7 -0
  37. package/dist/generated/entities/forms_encryption_key/index.js +15 -0
  38. package/dist/generated/entities/forms_encryption_key/index.js.map +7 -0
  39. package/dist/generated/entities.ids.generated.js +27 -2
  40. package/dist/generated/entities.ids.generated.js.map +2 -2
  41. package/dist/generated/entity-fields-registry.js +269 -0
  42. package/dist/generated/entity-fields-registry.js.map +2 -2
  43. package/dist/helpers/integration/communicationChannelsFixtures.js +16 -0
  44. package/dist/helpers/integration/communicationChannelsFixtures.js.map +2 -2
  45. package/dist/helpers/integration/customerGroupsFixtures.js +88 -0
  46. package/dist/helpers/integration/customerGroupsFixtures.js.map +7 -0
  47. package/dist/helpers/integration/formsFixtures.js +448 -0
  48. package/dist/helpers/integration/formsFixtures.js.map +7 -0
  49. package/dist/modules/api_docs/api/get/version.js +19 -7
  50. package/dist/modules/api_docs/api/get/version.js.map +2 -2
  51. package/dist/modules/api_keys/api/keys/route.js +74 -169
  52. package/dist/modules/api_keys/api/keys/route.js.map +2 -2
  53. package/dist/modules/api_keys/backend/api-keys/create/page.js +1 -1
  54. package/dist/modules/api_keys/backend/api-keys/create/page.js.map +2 -2
  55. package/dist/modules/api_keys/commands/keys.js +140 -0
  56. package/dist/modules/api_keys/commands/keys.js.map +7 -0
  57. package/dist/modules/api_keys/services/apiKeyService.js +72 -43
  58. package/dist/modules/api_keys/services/apiKeyService.js.map +2 -2
  59. package/dist/modules/attachments/api/file/[id]/route.js +9 -2
  60. package/dist/modules/attachments/api/file/[id]/route.js.map +2 -2
  61. package/dist/modules/attachments/api/image/[id]/[[...slug]]/route.js +6 -2
  62. package/dist/modules/attachments/api/image/[id]/[[...slug]]/route.js.map +2 -2
  63. package/dist/modules/attachments/api/route.js +10 -4
  64. package/dist/modules/attachments/api/route.js.map +2 -2
  65. package/dist/modules/attachments/components/AttachmentLibrary.js +16 -6
  66. package/dist/modules/attachments/components/AttachmentLibrary.js.map +2 -2
  67. package/dist/modules/attachments/lib/access.js +1 -3
  68. package/dist/modules/attachments/lib/access.js.map +2 -2
  69. package/dist/modules/attachments/lib/requestScope.js +13 -4
  70. package/dist/modules/attachments/lib/requestScope.js.map +2 -2
  71. package/dist/modules/audit_logs/api/audit-logs/actions/export/route.js +6 -1
  72. package/dist/modules/audit_logs/api/audit-logs/actions/export/route.js.map +2 -2
  73. package/dist/modules/audit_logs/api/audit-logs/actions/redo/route.js +36 -6
  74. package/dist/modules/audit_logs/api/audit-logs/actions/redo/route.js.map +3 -3
  75. package/dist/modules/audit_logs/api/audit-logs/actions/route.js +6 -1
  76. package/dist/modules/audit_logs/api/audit-logs/actions/route.js.map +2 -2
  77. package/dist/modules/audit_logs/api/audit-logs/actions/undo/route.js +34 -4
  78. package/dist/modules/audit_logs/api/audit-logs/actions/undo/route.js.map +2 -2
  79. package/dist/modules/audit_logs/data/validators.js +1 -0
  80. package/dist/modules/audit_logs/data/validators.js.map +2 -2
  81. package/dist/modules/audit_logs/lib/actorSubject.js +65 -0
  82. package/dist/modules/audit_logs/lib/actorSubject.js.map +7 -0
  83. package/dist/modules/audit_logs/lib/replayAuthorization.js +41 -0
  84. package/dist/modules/audit_logs/lib/replayAuthorization.js.map +7 -0
  85. package/dist/modules/audit_logs/services/actionLogService.js +162 -39
  86. package/dist/modules/audit_logs/services/actionLogService.js.map +3 -3
  87. package/dist/modules/auth/api/features.js +1 -1
  88. package/dist/modules/auth/api/features.js.map +2 -2
  89. package/dist/modules/auth/cli.js +29 -17
  90. package/dist/modules/auth/cli.js.map +2 -2
  91. package/dist/modules/auth/commands/acl.js +25 -36
  92. package/dist/modules/auth/commands/acl.js.map +2 -2
  93. package/dist/modules/auth/commands/interceptors.js +22 -0
  94. package/dist/modules/auth/commands/interceptors.js.map +7 -0
  95. package/dist/modules/auth/commands/roles.js +421 -147
  96. package/dist/modules/auth/commands/roles.js.map +2 -2
  97. package/dist/modules/auth/commands/users.js +543 -69
  98. package/dist/modules/auth/commands/users.js.map +2 -2
  99. package/dist/modules/auth/lib/authorizationStateLocks.js +249 -0
  100. package/dist/modules/auth/lib/authorizationStateLocks.js.map +7 -0
  101. package/dist/modules/auth/lib/commandReplay.js +144 -0
  102. package/dist/modules/auth/lib/commandReplay.js.map +7 -0
  103. package/dist/modules/auth/lib/executionPrincipal.js +32 -25
  104. package/dist/modules/auth/lib/executionPrincipal.js.map +2 -2
  105. package/dist/modules/auth/lib/grantChecks.js +7 -2
  106. package/dist/modules/auth/lib/grantChecks.js.map +2 -2
  107. package/dist/modules/auth/lib/setup-app.js +85 -49
  108. package/dist/modules/auth/lib/setup-app.js.map +2 -2
  109. package/dist/modules/auth/lib/tokenHash.js +13 -1
  110. package/dist/modules/auth/lib/tokenHash.js.map +2 -2
  111. package/dist/modules/auth/services/rbacService.js +386 -5
  112. package/dist/modules/auth/services/rbacService.js.map +3 -3
  113. package/dist/modules/availability/acl.js +16 -0
  114. package/dist/modules/availability/acl.js.map +7 -0
  115. package/dist/modules/availability/api/check/route.js +115 -0
  116. package/dist/modules/availability/api/check/route.js.map +7 -0
  117. package/dist/modules/availability/api/openapi.js +27 -0
  118. package/dist/modules/availability/api/openapi.js.map +7 -0
  119. package/dist/modules/availability/api/policies/resolve-preview/route.js +72 -0
  120. package/dist/modules/availability/api/policies/resolve-preview/route.js.map +7 -0
  121. package/dist/modules/availability/api/policies/route.js +203 -0
  122. package/dist/modules/availability/api/policies/route.js.map +7 -0
  123. package/dist/modules/availability/backend/availability/check/page.js +185 -0
  124. package/dist/modules/availability/backend/availability/check/page.js.map +7 -0
  125. package/dist/modules/availability/backend/availability/check/page.meta.js +16 -0
  126. package/dist/modules/availability/backend/availability/check/page.meta.js.map +7 -0
  127. package/dist/modules/availability/backend/availability/policies/ResolutionPreviewPanel.js +83 -0
  128. package/dist/modules/availability/backend/availability/policies/ResolutionPreviewPanel.js.map +7 -0
  129. package/dist/modules/availability/backend/availability/policies/ScopeFields.js +53 -0
  130. package/dist/modules/availability/backend/availability/policies/ScopeFields.js.map +7 -0
  131. package/dist/modules/availability/backend/availability/policies/StockManagedField.js +32 -0
  132. package/dist/modules/availability/backend/availability/policies/StockManagedField.js.map +7 -0
  133. package/dist/modules/availability/backend/availability/policies/[id]/page.js +168 -0
  134. package/dist/modules/availability/backend/availability/policies/[id]/page.js.map +7 -0
  135. package/dist/modules/availability/backend/availability/policies/[id]/page.meta.js +12 -0
  136. package/dist/modules/availability/backend/availability/policies/[id]/page.meta.js.map +7 -0
  137. package/dist/modules/availability/backend/availability/policies/create/page.js +119 -0
  138. package/dist/modules/availability/backend/availability/policies/create/page.js.map +7 -0
  139. package/dist/modules/availability/backend/availability/policies/create/page.meta.js +12 -0
  140. package/dist/modules/availability/backend/availability/policies/create/page.meta.js.map +7 -0
  141. package/dist/modules/availability/backend/availability/policies/formGroups.js +77 -0
  142. package/dist/modules/availability/backend/availability/policies/formGroups.js.map +7 -0
  143. package/dist/modules/availability/backend/availability/policies/page.js +207 -0
  144. package/dist/modules/availability/backend/availability/policies/page.js.map +7 -0
  145. package/dist/modules/availability/backend/availability/policies/page.meta.js +16 -0
  146. package/dist/modules/availability/backend/availability/policies/page.meta.js.map +7 -0
  147. package/dist/modules/availability/backend/availability/policies/policyPayload.js +28 -0
  148. package/dist/modules/availability/backend/availability/policies/policyPayload.js.map +7 -0
  149. package/dist/modules/availability/commands/policies.js +364 -0
  150. package/dist/modules/availability/commands/policies.js.map +7 -0
  151. package/dist/modules/availability/commands/scope.js +19 -0
  152. package/dist/modules/availability/commands/scope.js.map +7 -0
  153. package/dist/modules/availability/data/entities.js +94 -0
  154. package/dist/modules/availability/data/entities.js.map +7 -0
  155. package/dist/modules/availability/data/validators.js +59 -0
  156. package/dist/modules/availability/data/validators.js.map +7 -0
  157. package/dist/modules/availability/di.js +50 -0
  158. package/dist/modules/availability/di.js.map +7 -0
  159. package/dist/modules/availability/events.js +18 -0
  160. package/dist/modules/availability/events.js.map +7 -0
  161. package/dist/modules/availability/index.js +15 -0
  162. package/dist/modules/availability/index.js.map +7 -0
  163. package/dist/modules/availability/lib/catalogTarget.js +42 -0
  164. package/dist/modules/availability/lib/catalogTarget.js.map +7 -0
  165. package/dist/modules/availability/lib/organizationScope.js +10 -0
  166. package/dist/modules/availability/lib/organizationScope.js.map +7 -0
  167. package/dist/modules/availability/lib/policyResolution.js +150 -0
  168. package/dist/modules/availability/lib/policyResolution.js.map +7 -0
  169. package/dist/modules/availability/lib/tryResolve.js +11 -0
  170. package/dist/modules/availability/lib/tryResolve.js.map +7 -0
  171. package/dist/modules/availability/migrations/Migration20260922095844_availability.js +16 -0
  172. package/dist/modules/availability/migrations/Migration20260922095844_availability.js.map +7 -0
  173. package/dist/modules/availability/migrations/Migration20260930120000_availability.js +20 -0
  174. package/dist/modules/availability/migrations/Migration20260930120000_availability.js.map +7 -0
  175. package/dist/modules/availability/setup.js +12 -0
  176. package/dist/modules/availability/setup.js.map +7 -0
  177. package/dist/modules/catalog/api/categories/bulk-create/route.js +110 -0
  178. package/dist/modules/catalog/api/categories/bulk-create/route.js.map +7 -0
  179. package/dist/modules/catalog/api/categories/route.js +56 -8
  180. package/dist/modules/catalog/api/categories/route.js.map +2 -2
  181. package/dist/modules/catalog/api/products/bulk-create/route.js +110 -0
  182. package/dist/modules/catalog/api/products/bulk-create/route.js.map +7 -0
  183. package/dist/modules/catalog/api/products/route.js +55 -31
  184. package/dist/modules/catalog/api/products/route.js.map +3 -3
  185. package/dist/modules/catalog/backend/catalog/products/[id]/page.js +2 -6
  186. package/dist/modules/catalog/backend/catalog/products/[id]/page.js.map +2 -2
  187. package/dist/modules/catalog/backend/catalog/products/create/page.js +12 -4
  188. package/dist/modules/catalog/backend/catalog/products/create/page.js.map +2 -2
  189. package/dist/modules/catalog/commands/categories.js +1 -0
  190. package/dist/modules/catalog/commands/categories.js.map +2 -2
  191. package/dist/modules/catalog/commands/productDeleteChildren.js +389 -0
  192. package/dist/modules/catalog/commands/productDeleteChildren.js.map +7 -0
  193. package/dist/modules/catalog/commands/products.js +57 -19
  194. package/dist/modules/catalog/commands/products.js.map +2 -2
  195. package/dist/modules/catalog/components/PriceKindSettings.js +5 -19
  196. package/dist/modules/catalog/components/PriceKindSettings.js.map +2 -2
  197. package/dist/modules/catalog/components/products/ProductUomSection.js +26 -29
  198. package/dist/modules/catalog/components/products/ProductUomSection.js.map +2 -2
  199. package/dist/modules/catalog/components/products/productForm.js +3 -2
  200. package/dist/modules/catalog/components/products/productForm.js.map +2 -2
  201. package/dist/modules/catalog/data/validators.js +15 -0
  202. package/dist/modules/catalog/data/validators.js.map +2 -2
  203. package/dist/modules/catalog/di.js +3 -2
  204. package/dist/modules/catalog/di.js.map +2 -2
  205. package/dist/modules/catalog/events.js +9 -3
  206. package/dist/modules/catalog/events.js.map +2 -2
  207. package/dist/modules/catalog/lib/bulkCreateCategories.js +237 -0
  208. package/dist/modules/catalog/lib/bulkCreateCategories.js.map +7 -0
  209. package/dist/modules/catalog/lib/bulkCreateCheckpoint.js +82 -0
  210. package/dist/modules/catalog/lib/bulkCreateCheckpoint.js.map +7 -0
  211. package/dist/modules/catalog/lib/bulkCreateMutationGuards.js +39 -0
  212. package/dist/modules/catalog/lib/bulkCreateMutationGuards.js.map +7 -0
  213. package/dist/modules/catalog/lib/bulkCreateProducts.js +241 -0
  214. package/dist/modules/catalog/lib/bulkCreateProducts.js.map +7 -0
  215. package/dist/modules/catalog/lib/bulkDelete.js +10 -11
  216. package/dist/modules/catalog/lib/bulkDelete.js.map +2 -2
  217. package/dist/modules/catalog/lib/catalogQueue.js +14 -0
  218. package/dist/modules/catalog/lib/catalogQueue.js.map +7 -0
  219. package/dist/modules/catalog/lib/currencyOptions.js +25 -0
  220. package/dist/modules/catalog/lib/currencyOptions.js.map +7 -0
  221. package/dist/modules/catalog/lib/productSearch.js +8 -0
  222. package/dist/modules/catalog/lib/productSearch.js.map +7 -0
  223. package/dist/modules/catalog/lib/seeds.js +2 -42
  224. package/dist/modules/catalog/lib/seeds.js.map +2 -2
  225. package/dist/modules/catalog/lib/unitLabels.js +53 -0
  226. package/dist/modules/catalog/lib/unitLabels.js.map +7 -0
  227. package/dist/modules/catalog/migrations/Migration20260914120000.js +29 -0
  228. package/dist/modules/catalog/migrations/Migration20260914120000.js.map +7 -0
  229. package/dist/modules/catalog/migrations/Migration20260914120100.js +28 -0
  230. package/dist/modules/catalog/migrations/Migration20260914120100.js.map +7 -0
  231. package/dist/modules/catalog/workers/catalog-category-bulk-create.js +40 -0
  232. package/dist/modules/catalog/workers/catalog-category-bulk-create.js.map +7 -0
  233. package/dist/modules/catalog/workers/catalog-product-bulk-create.js +40 -0
  234. package/dist/modules/catalog/workers/catalog-product-bulk-create.js.map +7 -0
  235. package/dist/modules/communication_channels/acl.js +8 -0
  236. package/dist/modules/communication_channels/acl.js.map +2 -2
  237. package/dist/modules/communication_channels/api/get/me/channels/route.js +4 -0
  238. package/dist/modules/communication_channels/api/get/me/channels/route.js.map +2 -2
  239. package/dist/modules/communication_channels/api/get/oauth/[provider]/callback/route.js +22 -0
  240. package/dist/modules/communication_channels/api/get/oauth/[provider]/callback/route.js.map +2 -2
  241. package/dist/modules/communication_channels/api/post/channels/[id]/import-history/route.js +4 -4
  242. package/dist/modules/communication_channels/api/post/channels/[id]/import-history/route.js.map +2 -2
  243. package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js +2 -1
  244. package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js.map +2 -2
  245. package/dist/modules/communication_channels/api/post/channels/connect/credentials/route.js +4 -6
  246. package/dist/modules/communication_channels/api/post/channels/connect/credentials/route.js.map +2 -2
  247. package/dist/modules/communication_channels/api/post/channels/connect/tenant-credentials/route.js +4 -6
  248. package/dist/modules/communication_channels/api/post/channels/connect/tenant-credentials/route.js.map +2 -2
  249. package/dist/modules/communication_channels/api/post/test-seed/route.js +90 -20
  250. package/dist/modules/communication_channels/api/post/test-seed/route.js.map +3 -3
  251. package/dist/modules/communication_channels/api/put/channels/[id]/visibility/route.js +137 -0
  252. package/dist/modules/communication_channels/api/put/channels/[id]/visibility/route.js.map +7 -0
  253. package/dist/modules/communication_channels/backend/profile/communication-channels/page.js +175 -107
  254. package/dist/modules/communication_channels/backend/profile/communication-channels/page.js.map +2 -2
  255. package/dist/modules/communication_channels/commands/ingest-inbound-message.js +2 -1
  256. package/dist/modules/communication_channels/commands/ingest-inbound-message.js.map +2 -2
  257. package/dist/modules/communication_channels/commands/set-channel-visibility.js +88 -0
  258. package/dist/modules/communication_channels/commands/set-channel-visibility.js.map +7 -0
  259. package/dist/modules/communication_channels/data/enrichers.js +18 -9
  260. package/dist/modules/communication_channels/data/enrichers.js.map +2 -2
  261. package/dist/modules/communication_channels/data/entities.js +4 -0
  262. package/dist/modules/communication_channels/data/entities.js.map +2 -2
  263. package/dist/modules/communication_channels/di.js +9 -1
  264. package/dist/modules/communication_channels/di.js.map +2 -2
  265. package/dist/modules/communication_channels/events.js +7 -0
  266. package/dist/modules/communication_channels/events.js.map +2 -2
  267. package/dist/modules/communication_channels/index.js +1 -1
  268. package/dist/modules/communication_channels/index.js.map +1 -1
  269. package/dist/modules/communication_channels/lib/access-control.js +2 -1
  270. package/dist/modules/communication_channels/lib/access-control.js.map +2 -2
  271. package/dist/modules/communication_channels/lib/channel-thread-access.js +60 -0
  272. package/dist/modules/communication_channels/lib/channel-thread-access.js.map +7 -0
  273. package/dist/modules/communication_channels/lib/credential-refresh.js +11 -2
  274. package/dist/modules/communication_channels/lib/credential-refresh.js.map +2 -2
  275. package/dist/modules/communication_channels/lib/inbound-message-origin.js +18 -0
  276. package/dist/modules/communication_channels/lib/inbound-message-origin.js.map +7 -0
  277. package/dist/modules/communication_channels/lib/oauth-state.js +37 -0
  278. package/dist/modules/communication_channels/lib/oauth-state.js.map +2 -2
  279. package/dist/modules/communication_channels/lib/outbound-delivery-intent.js +12 -0
  280. package/dist/modules/communication_channels/lib/outbound-delivery-intent.js.map +7 -0
  281. package/dist/modules/communication_channels/lib/send-as-user.js +1 -1
  282. package/dist/modules/communication_channels/lib/send-as-user.js.map +2 -2
  283. package/dist/modules/communication_channels/migrations/Migration20260825141000_communication_channels.js +14 -0
  284. package/dist/modules/communication_channels/migrations/Migration20260825141000_communication_channels.js.map +7 -0
  285. package/dist/modules/communication_channels/setup.js +6 -2
  286. package/dist/modules/communication_channels/setup.js.map +2 -2
  287. package/dist/modules/communication_channels/subscribers/outbound-bridge.js +8 -2
  288. package/dist/modules/communication_channels/subscribers/outbound-bridge.js.map +2 -2
  289. package/dist/modules/communication_channels/workers/gmail-history-sync.js +1 -1
  290. package/dist/modules/communication_channels/workers/gmail-history-sync.js.map +2 -2
  291. package/dist/modules/communication_channels/workers/poll-channel.js +1 -1
  292. package/dist/modules/communication_channels/workers/poll-channel.js.map +2 -2
  293. package/dist/modules/communication_channels/workers/reaction-processor.js +2 -2
  294. package/dist/modules/communication_channels/workers/reaction-processor.js.map +2 -2
  295. package/dist/modules/configs/api/upgrade-actions/route.js +2 -1
  296. package/dist/modules/configs/api/upgrade-actions/route.js.map +2 -2
  297. package/dist/modules/configs/cli.js +2 -2
  298. package/dist/modules/configs/cli.js.map +2 -2
  299. package/dist/modules/configs/lib/upgrade-actions.js +28 -6
  300. package/dist/modules/configs/lib/upgrade-actions.js.map +2 -2
  301. package/dist/modules/configs/services/upgradeActionsService.js +44 -30
  302. package/dist/modules/configs/services/upgradeActionsService.js.map +2 -2
  303. package/dist/modules/currencies/api/currencies/route.js +11 -5
  304. package/dist/modules/currencies/api/currencies/route.js.map +2 -2
  305. package/dist/modules/currencies/api/exchange-rates/route.js +11 -5
  306. package/dist/modules/currencies/api/exchange-rates/route.js.map +2 -2
  307. package/dist/modules/customer_groups/acl.js +14 -0
  308. package/dist/modules/customer_groups/acl.js.map +7 -0
  309. package/dist/modules/customer_groups/api/customer-groups/[id]/terms/route.js +266 -0
  310. package/dist/modules/customer_groups/api/customer-groups/[id]/terms/route.js.map +7 -0
  311. package/dist/modules/customer_groups/api/customer-groups/crud.js +473 -0
  312. package/dist/modules/customer_groups/api/customer-groups/crud.js.map +7 -0
  313. package/dist/modules/customer_groups/api/customer-groups/explain-terms/route.js +143 -0
  314. package/dist/modules/customer_groups/api/customer-groups/explain-terms/route.js.map +7 -0
  315. package/dist/modules/customer_groups/api/customer-groups/memberships/crud.js +383 -0
  316. package/dist/modules/customer_groups/api/customer-groups/memberships/crud.js.map +7 -0
  317. package/dist/modules/customer_groups/api/customer-groups/memberships/route.js +66 -0
  318. package/dist/modules/customer_groups/api/customer-groups/memberships/route.js.map +7 -0
  319. package/dist/modules/customer_groups/api/customer-groups/reconcile/adopt/route.js +133 -0
  320. package/dist/modules/customer_groups/api/customer-groups/reconcile/adopt/route.js.map +7 -0
  321. package/dist/modules/customer_groups/api/customer-groups/reconcile/route.js +80 -0
  322. package/dist/modules/customer_groups/api/customer-groups/reconcile/route.js.map +7 -0
  323. package/dist/modules/customer_groups/api/customer-groups/reorder/route.js +127 -0
  324. package/dist/modules/customer_groups/api/customer-groups/reorder/route.js.map +7 -0
  325. package/dist/modules/customer_groups/api/customer-groups/route.js +62 -0
  326. package/dist/modules/customer_groups/api/customer-groups/route.js.map +7 -0
  327. package/dist/modules/customer_groups/api/openapi.js +27 -0
  328. package/dist/modules/customer_groups/api/openapi.js.map +7 -0
  329. package/dist/modules/customer_groups/backend/customer-groups/[id]/edit/page.js +328 -0
  330. package/dist/modules/customer_groups/backend/customer-groups/[id]/edit/page.js.map +7 -0
  331. package/dist/modules/customer_groups/backend/customer-groups/[id]/edit/page.meta.js +16 -0
  332. package/dist/modules/customer_groups/backend/customer-groups/[id]/edit/page.meta.js.map +7 -0
  333. package/dist/modules/customer_groups/backend/customer-groups/create/page.js +249 -0
  334. package/dist/modules/customer_groups/backend/customer-groups/create/page.js.map +7 -0
  335. package/dist/modules/customer_groups/backend/customer-groups/create/page.meta.js +27 -0
  336. package/dist/modules/customer_groups/backend/customer-groups/create/page.meta.js.map +7 -0
  337. package/dist/modules/customer_groups/backend/customer-groups/orphans/page.js +139 -0
  338. package/dist/modules/customer_groups/backend/customer-groups/orphans/page.js.map +7 -0
  339. package/dist/modules/customer_groups/backend/customer-groups/orphans/page.meta.js +16 -0
  340. package/dist/modules/customer_groups/backend/customer-groups/orphans/page.meta.js.map +7 -0
  341. package/dist/modules/customer_groups/backend/customer-groups/page.js +364 -0
  342. package/dist/modules/customer_groups/backend/customer-groups/page.js.map +7 -0
  343. package/dist/modules/customer_groups/backend/customer-groups/page.meta.js +15 -0
  344. package/dist/modules/customer_groups/backend/customer-groups/page.meta.js.map +7 -0
  345. package/dist/modules/customer_groups/cli.js +72 -0
  346. package/dist/modules/customer_groups/cli.js.map +7 -0
  347. package/dist/modules/customer_groups/commands/reorderGroups.js +96 -0
  348. package/dist/modules/customer_groups/commands/reorderGroups.js.map +7 -0
  349. package/dist/modules/customer_groups/components/CustomerGroupDefaultField.js +41 -0
  350. package/dist/modules/customer_groups/components/CustomerGroupDefaultField.js.map +7 -0
  351. package/dist/modules/customer_groups/components/CustomerGroupParentField.js +156 -0
  352. package/dist/modules/customer_groups/components/CustomerGroupParentField.js.map +7 -0
  353. package/dist/modules/customer_groups/components/CustomerGroupTermsPriceKindField.js +94 -0
  354. package/dist/modules/customer_groups/components/CustomerGroupTermsPriceKindField.js.map +7 -0
  355. package/dist/modules/customer_groups/components/CustomerGroupTermsSection.js +197 -0
  356. package/dist/modules/customer_groups/components/CustomerGroupTermsSection.js.map +7 -0
  357. package/dist/modules/customer_groups/components/GroupPickerField.js +116 -0
  358. package/dist/modules/customer_groups/components/GroupPickerField.js.map +7 -0
  359. package/dist/modules/customer_groups/components/OrphanBanner.js +75 -0
  360. package/dist/modules/customer_groups/components/OrphanBanner.js.map +7 -0
  361. package/dist/modules/customer_groups/components/customerGroupTree.js +57 -0
  362. package/dist/modules/customer_groups/components/customerGroupTree.js.map +7 -0
  363. package/dist/modules/customer_groups/data/entities.js +226 -0
  364. package/dist/modules/customer_groups/data/entities.js.map +7 -0
  365. package/dist/modules/customer_groups/data/validators.js +153 -0
  366. package/dist/modules/customer_groups/data/validators.js.map +7 -0
  367. package/dist/modules/customer_groups/di.js +20 -0
  368. package/dist/modules/customer_groups/di.js.map +7 -0
  369. package/dist/modules/customer_groups/events.js +22 -0
  370. package/dist/modules/customer_groups/events.js.map +7 -0
  371. package/dist/modules/customer_groups/index.js +15 -0
  372. package/dist/modules/customer_groups/index.js.map +7 -0
  373. package/dist/modules/customer_groups/lib/createConflictRecheck.js +29 -0
  374. package/dist/modules/customer_groups/lib/createConflictRecheck.js.map +7 -0
  375. package/dist/modules/customer_groups/lib/customerScope.js +81 -0
  376. package/dist/modules/customer_groups/lib/customerScope.js.map +7 -0
  377. package/dist/modules/customer_groups/lib/groupEvents.js +31 -0
  378. package/dist/modules/customer_groups/lib/groupEvents.js.map +7 -0
  379. package/dist/modules/customer_groups/lib/priceKindScope.js +16 -0
  380. package/dist/modules/customer_groups/lib/priceKindScope.js.map +7 -0
  381. package/dist/modules/customer_groups/lib/reconcile.js +161 -0
  382. package/dist/modules/customer_groups/lib/reconcile.js.map +7 -0
  383. package/dist/modules/customer_groups/migrations/Migration20260922095316_customer_groups.js +27 -0
  384. package/dist/modules/customer_groups/migrations/Migration20260922095316_customer_groups.js.map +7 -0
  385. package/dist/modules/customer_groups/migrations/Migration20260922103033_customer_groups.js +19 -0
  386. package/dist/modules/customer_groups/migrations/Migration20260922103033_customer_groups.js.map +7 -0
  387. package/dist/modules/customer_groups/migrations/Migration20260922105444_customer_groups.js +19 -0
  388. package/dist/modules/customer_groups/migrations/Migration20260922105444_customer_groups.js.map +7 -0
  389. package/dist/modules/customer_groups/migrations/Migration20260923193330_customer_groups.js +19 -0
  390. package/dist/modules/customer_groups/migrations/Migration20260923193330_customer_groups.js.map +7 -0
  391. package/dist/modules/customer_groups/migrations/Migration20260929083000_customer_groups.js +20 -0
  392. package/dist/modules/customer_groups/migrations/Migration20260929083000_customer_groups.js.map +7 -0
  393. package/dist/modules/customer_groups/services/customerGroupsService.js +190 -0
  394. package/dist/modules/customer_groups/services/customerGroupsService.js.map +7 -0
  395. package/dist/modules/customer_groups/setup.js +13 -0
  396. package/dist/modules/customer_groups/setup.js.map +7 -0
  397. package/dist/modules/customer_groups/widgets/injection/group-picker-field/widget.js +31 -0
  398. package/dist/modules/customer_groups/widgets/injection/group-picker-field/widget.js.map +7 -0
  399. package/dist/modules/customer_groups/widgets/injection/person-groups-explain-terms.js +166 -0
  400. package/dist/modules/customer_groups/widgets/injection/person-groups-explain-terms.js.map +7 -0
  401. package/dist/modules/customer_groups/widgets/injection/person-groups-tab/widget.js +17 -0
  402. package/dist/modules/customer_groups/widgets/injection/person-groups-tab/widget.js.map +7 -0
  403. package/dist/modules/customer_groups/widgets/injection/person-groups-tab.js +457 -0
  404. package/dist/modules/customer_groups/widgets/injection/person-groups-tab.js.map +7 -0
  405. package/dist/modules/customer_groups/widgets/injection-table.js +33 -0
  406. package/dist/modules/customer_groups/widgets/injection-table.js.map +7 -0
  407. package/dist/modules/customers/acl.js +13 -0
  408. package/dist/modules/customers/acl.js.map +2 -2
  409. package/dist/modules/customers/api/activities/route.js +9 -1
  410. package/dist/modules/customers/api/activities/route.js.map +2 -2
  411. package/dist/modules/customers/api/companies/[id]/people/route.js +2 -1
  412. package/dist/modules/customers/api/companies/[id]/people/route.js.map +2 -2
  413. package/dist/modules/customers/api/companies/[id]/route.js +19 -7
  414. package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
  415. package/dist/modules/customers/api/deals/[id]/companies/route.js +2 -1
  416. package/dist/modules/customers/api/deals/[id]/companies/route.js.map +2 -2
  417. package/dist/modules/customers/api/deals/[id]/people/route.js +60 -6
  418. package/dist/modules/customers/api/deals/[id]/people/route.js.map +2 -2
  419. package/dist/modules/customers/api/deals/map/route.js +7 -2
  420. package/dist/modules/customers/api/deals/map/route.js.map +2 -2
  421. package/dist/modules/customers/api/dictionaries/context.js +2 -1
  422. package/dist/modules/customers/api/dictionaries/context.js.map +2 -2
  423. package/dist/modules/customers/api/entity-roles-factory.js +3 -2
  424. package/dist/modules/customers/api/entity-roles-factory.js.map +2 -2
  425. package/dist/modules/customers/api/interactions/[id]/visibility/route.js +2 -1
  426. package/dist/modules/customers/api/interactions/[id]/visibility/route.js.map +2 -2
  427. package/dist/modules/customers/api/interactions/cancel/route.js +2 -1
  428. package/dist/modules/customers/api/interactions/cancel/route.js.map +2 -2
  429. package/dist/modules/customers/api/interactions/complete/route.js +2 -1
  430. package/dist/modules/customers/api/interactions/complete/route.js.map +2 -2
  431. package/dist/modules/customers/api/interactions/conflicts/route.js +10 -6
  432. package/dist/modules/customers/api/interactions/conflicts/route.js.map +2 -2
  433. package/dist/modules/customers/api/interactions/counts/route.js +24 -4
  434. package/dist/modules/customers/api/interactions/counts/route.js.map +2 -2
  435. package/dist/modules/customers/api/interactions/route.js +31 -8
  436. package/dist/modules/customers/api/interactions/route.js.map +2 -2
  437. package/dist/modules/customers/api/labels/assign/route.js +2 -1
  438. package/dist/modules/customers/api/labels/assign/route.js.map +2 -2
  439. package/dist/modules/customers/api/labels/route.js +3 -2
  440. package/dist/modules/customers/api/labels/route.js.map +2 -2
  441. package/dist/modules/customers/api/labels/unassign/route.js +2 -1
  442. package/dist/modules/customers/api/labels/unassign/route.js.map +2 -2
  443. package/dist/modules/customers/api/people/[id]/companies/context.js +7 -2
  444. package/dist/modules/customers/api/people/[id]/companies/context.js.map +2 -2
  445. package/dist/modules/customers/api/people/[id]/email-share/route.js +218 -0
  446. package/dist/modules/customers/api/people/[id]/email-share/route.js.map +7 -0
  447. package/dist/modules/customers/api/people/[id]/email-threads/route.js +11 -2
  448. package/dist/modules/customers/api/people/[id]/email-threads/route.js.map +2 -2
  449. package/dist/modules/customers/api/people/[id]/emails/route.js +2 -1
  450. package/dist/modules/customers/api/people/[id]/emails/route.js.map +2 -2
  451. package/dist/modules/customers/api/people/[id]/route.js +20 -19
  452. package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
  453. package/dist/modules/customers/api/people/check-phone/route.js +2 -1
  454. package/dist/modules/customers/api/people/check-phone/route.js.map +2 -2
  455. package/dist/modules/customers/api/pipeline-stages/reorder/route.js +3 -2
  456. package/dist/modules/customers/api/pipeline-stages/reorder/route.js.map +2 -2
  457. package/dist/modules/customers/api/pipeline-stages/route.js +3 -3
  458. package/dist/modules/customers/api/pipeline-stages/route.js.map +2 -2
  459. package/dist/modules/customers/api/pipelines/route.js +3 -3
  460. package/dist/modules/customers/api/pipelines/route.js.map +2 -2
  461. package/dist/modules/customers/api/settings/address-format/route.js +2 -1
  462. package/dist/modules/customers/api/settings/address-format/route.js.map +2 -2
  463. package/dist/modules/customers/api/settings/dictionary-sort-modes/route.js +2 -1
  464. package/dist/modules/customers/api/settings/dictionary-sort-modes/route.js.map +2 -2
  465. package/dist/modules/customers/api/settings/stuck-threshold/route.js +2 -1
  466. package/dist/modules/customers/api/settings/stuck-threshold/route.js.map +2 -2
  467. package/dist/modules/customers/api/tags/assign/route.js +2 -1
  468. package/dist/modules/customers/api/tags/assign/route.js.map +2 -2
  469. package/dist/modules/customers/api/tags/unassign/route.js +2 -1
  470. package/dist/modules/customers/api/tags/unassign/route.js.map +2 -2
  471. package/dist/modules/customers/backend/customers/companies/[id]/page.js +4 -2
  472. package/dist/modules/customers/backend/customers/companies/[id]/page.js.map +2 -2
  473. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.js +6 -25
  474. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.js.map +2 -2
  475. package/dist/modules/customers/backend/customers/deals/[id]/page.js +21 -18
  476. package/dist/modules/customers/backend/customers/deals/[id]/page.js.map +2 -2
  477. package/dist/modules/customers/backend/customers/deals/components/ReassignOwnerDialog.js +93 -0
  478. package/dist/modules/customers/backend/customers/deals/components/ReassignOwnerDialog.js.map +7 -0
  479. package/dist/modules/customers/backend/customers/deals/page.js +111 -1
  480. package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
  481. package/dist/modules/customers/backend/customers/people/[id]/page.js +4 -2
  482. package/dist/modules/customers/backend/customers/people/[id]/page.js.map +2 -2
  483. package/dist/modules/customers/commands/addresses.js +83 -15
  484. package/dist/modules/customers/commands/addresses.js.map +2 -2
  485. package/dist/modules/customers/commands/companies.js +10 -4
  486. package/dist/modules/customers/commands/companies.js.map +2 -2
  487. package/dist/modules/customers/commands/emailConversationShares.js +177 -0
  488. package/dist/modules/customers/commands/emailConversationShares.js.map +7 -0
  489. package/dist/modules/customers/commands/index.js +1 -0
  490. package/dist/modules/customers/commands/index.js.map +2 -2
  491. package/dist/modules/customers/commands/interactions.js +48 -23
  492. package/dist/modules/customers/commands/interactions.js.map +3 -3
  493. package/dist/modules/customers/commands/people.js +3 -2
  494. package/dist/modules/customers/commands/people.js.map +2 -2
  495. package/dist/modules/customers/commands/shared.js +4 -0
  496. package/dist/modules/customers/commands/shared.js.map +2 -2
  497. package/dist/modules/customers/components/calendar/types.js.map +1 -1
  498. package/dist/modules/customers/components/detail/CompanyPeopleSection.js +81 -354
  499. package/dist/modules/customers/components/detail/CompanyPeopleSection.js.map +2 -2
  500. package/dist/modules/customers/components/detail/CreatePersonDialog.js +12 -11
  501. package/dist/modules/customers/components/detail/CreatePersonDialog.js.map +2 -2
  502. package/dist/modules/customers/components/detail/DealForm.js +73 -5
  503. package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
  504. package/dist/modules/customers/components/detail/DealOwnerSelect.js +96 -0
  505. package/dist/modules/customers/components/detail/DealOwnerSelect.js.map +7 -0
  506. package/dist/modules/customers/components/detail/DealPeopleSection.js +206 -0
  507. package/dist/modules/customers/components/detail/DealPeopleSection.js.map +7 -0
  508. package/dist/modules/customers/components/detail/DealsSection.js +8 -14
  509. package/dist/modules/customers/components/detail/DealsSection.js.map +2 -2
  510. package/dist/modules/customers/components/detail/LinkedPeopleSection.js +342 -0
  511. package/dist/modules/customers/components/detail/LinkedPeopleSection.js.map +7 -0
  512. package/dist/modules/customers/components/detail/PersonCard.js +5 -2
  513. package/dist/modules/customers/components/detail/PersonCard.js.map +2 -2
  514. package/dist/modules/customers/components/detail/PersonEmailShareControl.js +190 -0
  515. package/dist/modules/customers/components/detail/PersonEmailShareControl.js.map +7 -0
  516. package/dist/modules/customers/components/detail/PersonEmailThreadsTab.js +17 -0
  517. package/dist/modules/customers/components/detail/PersonEmailThreadsTab.js.map +2 -2
  518. package/dist/modules/customers/components/detail/ScheduleActivityDialog.js +5 -2
  519. package/dist/modules/customers/components/detail/ScheduleActivityDialog.js.map +2 -2
  520. package/dist/modules/customers/components/detail/create/CreateDealForm.js +19 -0
  521. package/dist/modules/customers/components/detail/create/CreateDealForm.js.map +2 -2
  522. package/dist/modules/customers/components/detail/create/DealDetailsFields.js +11 -0
  523. package/dist/modules/customers/components/detail/create/DealDetailsFields.js.map +2 -2
  524. package/dist/modules/customers/components/detail/create/DealSectionCard.js +2 -2
  525. package/dist/modules/customers/components/detail/create/DealSectionCard.js.map +2 -2
  526. package/dist/modules/customers/components/detail/create/dealFormTypes.js +1 -0
  527. package/dist/modules/customers/components/detail/create/dealFormTypes.js.map +2 -2
  528. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js +1 -1
  529. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js.map +2 -2
  530. package/dist/modules/customers/components/formConfig.js +2 -0
  531. package/dist/modules/customers/components/formConfig.js.map +2 -2
  532. package/dist/modules/customers/components/linking/LinkEntityDialog.js +8 -0
  533. package/dist/modules/customers/components/linking/LinkEntityDialog.js.map +2 -2
  534. package/dist/modules/customers/components/linking/adapters/personAdapter.js +3 -0
  535. package/dist/modules/customers/components/linking/adapters/personAdapter.js.map +2 -2
  536. package/dist/modules/customers/data/enrichers.js +40 -2
  537. package/dist/modules/customers/data/enrichers.js.map +2 -2
  538. package/dist/modules/customers/data/entities.js +56 -0
  539. package/dist/modules/customers/data/entities.js.map +2 -2
  540. package/dist/modules/customers/data/validators.js +11 -0
  541. package/dist/modules/customers/data/validators.js.map +2 -2
  542. package/dist/modules/customers/events.js +6 -1
  543. package/dist/modules/customers/events.js.map +2 -2
  544. package/dist/modules/customers/lib/assignableStaff.js +14 -0
  545. package/dist/modules/customers/lib/assignableStaff.js.map +2 -2
  546. package/dist/modules/customers/lib/calendar/editorPayload.js +17 -13
  547. package/dist/modules/customers/lib/calendar/editorPayload.js.map +2 -2
  548. package/dist/modules/customers/lib/calendar/mapItem.js +1 -0
  549. package/dist/modules/customers/lib/calendar/mapItem.js.map +2 -2
  550. package/dist/modules/customers/lib/conversationShares.js +126 -0
  551. package/dist/modules/customers/lib/conversationShares.js.map +7 -0
  552. package/dist/modules/customers/lib/dealsOrganizationScope.js +5 -3
  553. package/dist/modules/customers/lib/dealsOrganizationScope.js.map +2 -2
  554. package/dist/modules/customers/lib/interactionRequestContext.js +2 -1
  555. package/dist/modules/customers/lib/interactionRequestContext.js.map +2 -2
  556. package/dist/modules/customers/lib/link-channel-message-handler.js +19 -9
  557. package/dist/modules/customers/lib/link-channel-message-handler.js.map +2 -2
  558. package/dist/modules/customers/lib/personDetailCacheTags.js +32 -0
  559. package/dist/modules/customers/lib/personDetailCacheTags.js.map +7 -0
  560. package/dist/modules/customers/lib/personEmailThreads.js +26 -5
  561. package/dist/modules/customers/lib/personEmailThreads.js.map +2 -2
  562. package/dist/modules/customers/lib/reassignDealOwner.js +25 -0
  563. package/dist/modules/customers/lib/reassignDealOwner.js.map +7 -0
  564. package/dist/modules/customers/lib/userNames.js +26 -0
  565. package/dist/modules/customers/lib/userNames.js.map +7 -0
  566. package/dist/modules/customers/lib/visibilityFilter.js +70 -2
  567. package/dist/modules/customers/lib/visibilityFilter.js.map +2 -2
  568. package/dist/modules/customers/migrations/Migration20260825120000_customers.js +18 -0
  569. package/dist/modules/customers/migrations/Migration20260825120000_customers.js.map +7 -0
  570. package/dist/modules/customers/migrations/Migration20260825140000_customers.js +27 -0
  571. package/dist/modules/customers/migrations/Migration20260825140000_customers.js.map +7 -0
  572. package/dist/modules/customers/setup.js +1 -0
  573. package/dist/modules/customers/setup.js.map +2 -2
  574. package/dist/modules/customers/subscribers/channel-visibility-changed.js +16 -0
  575. package/dist/modules/customers/subscribers/channel-visibility-changed.js.map +7 -0
  576. package/dist/modules/dashboards/api/widgets/data/batch/route.js +3 -8
  577. package/dist/modules/dashboards/api/widgets/data/batch/route.js.map +2 -2
  578. package/dist/modules/dashboards/api/widgets/data/route.js +10 -15
  579. package/dist/modules/dashboards/api/widgets/data/route.js.map +2 -2
  580. package/dist/modules/dashboards/lib/aggregations.js +1 -1
  581. package/dist/modules/dashboards/lib/aggregations.js.map +2 -2
  582. package/dist/modules/dashboards/lib/widgetScope.js +2 -7
  583. package/dist/modules/dashboards/lib/widgetScope.js.map +2 -2
  584. package/dist/modules/data_sync/api/runs/[id]/cancel.js +4 -1
  585. package/dist/modules/data_sync/api/runs/[id]/cancel.js.map +2 -2
  586. package/dist/modules/data_sync/backend/data-sync/page.js +497 -329
  587. package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
  588. package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js +248 -113
  589. package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js.map +3 -3
  590. package/dist/modules/data_sync/components/useDataSyncRunAccess.js +17 -0
  591. package/dist/modules/data_sync/components/useDataSyncRunAccess.js.map +7 -0
  592. package/dist/modules/data_sync/lib/resume-point.js +21 -0
  593. package/dist/modules/data_sync/lib/resume-point.js.map +7 -0
  594. package/dist/modules/data_sync/lib/start-run.js +52 -2
  595. package/dist/modules/data_sync/lib/start-run.js.map +2 -2
  596. package/dist/modules/data_sync/lib/sync-run-service.js +22 -33
  597. package/dist/modules/data_sync/lib/sync-run-service.js.map +3 -3
  598. package/dist/modules/devices/api/[id]/route.js +3 -2
  599. package/dist/modules/devices/api/[id]/route.js.map +2 -2
  600. package/dist/modules/devices/api/admin/devices/route.js +2 -1
  601. package/dist/modules/devices/api/admin/devices/route.js.map +2 -2
  602. package/dist/modules/devices/api/route.js +2 -1
  603. package/dist/modules/devices/api/route.js.map +2 -2
  604. package/dist/modules/dictionaries/api/[dictionaryId]/route.js.map +2 -2
  605. package/dist/modules/dictionaries/api/context.js +2 -1
  606. package/dist/modules/dictionaries/api/context.js.map +2 -2
  607. package/dist/modules/dictionaries/api/route.js +4 -0
  608. package/dist/modules/dictionaries/api/route.js.map +2 -2
  609. package/dist/modules/dictionaries/components/DictionariesManager.js +4 -3
  610. package/dist/modules/dictionaries/components/DictionariesManager.js.map +2 -2
  611. package/dist/modules/dictionaries/data/validators.js +3 -1
  612. package/dist/modules/dictionaries/data/validators.js.map +2 -2
  613. package/dist/modules/directory/api/organization-branding/route.js +10 -1
  614. package/dist/modules/directory/api/organization-branding/route.js.map +2 -2
  615. package/dist/modules/directory/api/organizations/route.js +1 -1
  616. package/dist/modules/directory/api/organizations/route.js.map +1 -1
  617. package/dist/modules/directory/backend/directory/branding/page.js +17 -4
  618. package/dist/modules/directory/backend/directory/branding/page.js.map +3 -3
  619. package/dist/modules/directory/commands/organizations.js +136 -74
  620. package/dist/modules/directory/commands/organizations.js.map +2 -2
  621. package/dist/modules/directory/lib/hierarchy.js +19 -1
  622. package/dist/modules/directory/lib/hierarchy.js.map +2 -2
  623. package/dist/modules/directory/utils/organizationScope.js +66 -12
  624. package/dist/modules/directory/utils/organizationScope.js.map +2 -2
  625. package/dist/modules/directory/utils/organizationScopeFilter.js +7 -4
  626. package/dist/modules/directory/utils/organizationScopeFilter.js.map +2 -2
  627. package/dist/modules/directory/utils/organizationScopeGuard.js +6 -2
  628. package/dist/modules/directory/utils/organizationScopeGuard.js.map +2 -2
  629. package/dist/modules/entities/api/encryption.js +68 -25
  630. package/dist/modules/entities/api/encryption.js.map +2 -2
  631. package/dist/modules/entities/api/records.js +9 -8
  632. package/dist/modules/entities/api/records.js.map +2 -2
  633. package/dist/modules/entities/cli.js +33 -22
  634. package/dist/modules/entities/cli.js.map +2 -2
  635. package/dist/modules/entities/data/entities.js +8 -0
  636. package/dist/modules/entities/data/entities.js.map +2 -2
  637. package/dist/modules/entities/lib/definition-scope.js +3 -1
  638. package/dist/modules/entities/lib/definition-scope.js.map +2 -2
  639. package/dist/modules/entities/lib/encryption-maps.js +117 -0
  640. package/dist/modules/entities/lib/encryption-maps.js.map +7 -0
  641. package/dist/modules/entities/lib/helpers.js +30 -6
  642. package/dist/modules/entities/lib/helpers.js.map +2 -2
  643. package/dist/modules/entities/migrations/Migration20260910120000.js +17 -0
  644. package/dist/modules/entities/migrations/Migration20260910120000.js.map +7 -0
  645. package/dist/modules/entities/migrations/Migration20261004120000_encryption_map_scope_uniqueness.js +130 -0
  646. package/dist/modules/entities/migrations/Migration20261004120000_encryption_map_scope_uniqueness.js.map +7 -0
  647. package/dist/modules/eudr/api/dashboard/widgets/compliance-overview/route.js +2 -1
  648. package/dist/modules/eudr/api/dashboard/widgets/compliance-overview/route.js.map +2 -2
  649. package/dist/modules/eudr/api/plots/import/route.js +2 -1
  650. package/dist/modules/eudr/api/plots/import/route.js.map +2 -2
  651. package/dist/modules/eudr/api/product-mappings/suggestions/apply/route.js +2 -1
  652. package/dist/modules/eudr/api/product-mappings/suggestions/apply/route.js.map +2 -2
  653. package/dist/modules/eudr/api/product-mappings/suggestions/route.js +2 -1
  654. package/dist/modules/eudr/api/product-mappings/suggestions/route.js.map +2 -2
  655. package/dist/modules/eudr/api/reports/annual/route.js +2 -1
  656. package/dist/modules/eudr/api/reports/annual/route.js.map +2 -2
  657. package/dist/modules/eudr/api/statements/[id]/export/route.js +2 -1
  658. package/dist/modules/eudr/api/statements/[id]/export/route.js.map +2 -2
  659. package/dist/modules/eudr/api/statements/[id]/readiness/route.js +2 -1
  660. package/dist/modules/eudr/api/statements/[id]/readiness/route.js.map +2 -2
  661. package/dist/modules/eudr/api/suppliers/compliance/route.js +2 -1
  662. package/dist/modules/eudr/api/suppliers/compliance/route.js.map +2 -2
  663. package/dist/modules/feature_toggles/commands/global.js +13 -13
  664. package/dist/modules/feature_toggles/commands/global.js.map +2 -2
  665. package/dist/modules/feature_toggles/lib/feature-flag-check.js +8 -2
  666. package/dist/modules/feature_toggles/lib/feature-flag-check.js.map +2 -2
  667. package/dist/modules/forms/acl.js +14 -0
  668. package/dist/modules/forms/acl.js.map +7 -0
  669. package/dist/modules/forms/api/[id]/analytics/route.js +113 -0
  670. package/dist/modules/forms/api/[id]/analytics/route.js.map +7 -0
  671. package/dist/modules/forms/api/[id]/distributions/route.js +176 -0
  672. package/dist/modules/forms/api/[id]/distributions/route.js.map +7 -0
  673. package/dist/modules/forms/api/[id]/route.js +225 -0
  674. package/dist/modules/forms/api/[id]/route.js.map +7 -0
  675. package/dist/modules/forms/api/[id]/run/context/route.js +115 -0
  676. package/dist/modules/forms/api/[id]/run/context/route.js.map +7 -0
  677. package/dist/modules/forms/api/[id]/run/submissions/route.js +109 -0
  678. package/dist/modules/forms/api/[id]/run/submissions/route.js.map +7 -0
  679. package/dist/modules/forms/api/[id]/submissions/route.js +83 -0
  680. package/dist/modules/forms/api/[id]/submissions/route.js.map +7 -0
  681. package/dist/modules/forms/api/[id]/theme-logo/route.js +117 -0
  682. package/dist/modules/forms/api/[id]/theme-logo/route.js.map +7 -0
  683. package/dist/modules/forms/api/[id]/versions/[versionId]/diff/route.js +125 -0
  684. package/dist/modules/forms/api/[id]/versions/[versionId]/diff/route.js.map +7 -0
  685. package/dist/modules/forms/api/[id]/versions/[versionId]/publish/route.js +99 -0
  686. package/dist/modules/forms/api/[id]/versions/[versionId]/publish/route.js.map +7 -0
  687. package/dist/modules/forms/api/[id]/versions/[versionId]/route.js +176 -0
  688. package/dist/modules/forms/api/[id]/versions/[versionId]/route.js.map +7 -0
  689. package/dist/modules/forms/api/[id]/versions/fork/route.js +92 -0
  690. package/dist/modules/forms/api/[id]/versions/fork/route.js.map +7 -0
  691. package/dist/modules/forms/api/attachment-helpers.js +111 -0
  692. package/dist/modules/forms/api/attachment-helpers.js.map +7 -0
  693. package/dist/modules/forms/api/by-key/[key]/active/route.js +140 -0
  694. package/dist/modules/forms/api/by-key/[key]/active/route.js.map +7 -0
  695. package/dist/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/route.js +84 -0
  696. package/dist/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/route.js.map +7 -0
  697. package/dist/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/send/route.js +88 -0
  698. package/dist/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/send/route.js.map +7 -0
  699. package/dist/modules/forms/api/distributions/[distributionId]/invitations/route.js +183 -0
  700. package/dist/modules/forms/api/distributions/[distributionId]/invitations/route.js.map +7 -0
  701. package/dist/modules/forms/api/distributions/[distributionId]/route.js +191 -0
  702. package/dist/modules/forms/api/distributions/[distributionId]/route.js.map +7 -0
  703. package/dist/modules/forms/api/form-submissions/[id]/attachments/route.js +91 -0
  704. package/dist/modules/forms/api/form-submissions/[id]/attachments/route.js.map +7 -0
  705. package/dist/modules/forms/api/form-submissions/[id]/resume-token/route.js +110 -0
  706. package/dist/modules/forms/api/form-submissions/[id]/resume-token/route.js.map +7 -0
  707. package/dist/modules/forms/api/form-submissions/[id]/route.js +146 -0
  708. package/dist/modules/forms/api/form-submissions/[id]/route.js.map +7 -0
  709. package/dist/modules/forms/api/form-submissions/[id]/submit/route.js +74 -0
  710. package/dist/modules/forms/api/form-submissions/[id]/submit/route.js.map +7 -0
  711. package/dist/modules/forms/api/form-submissions/by-subject/[subject_type]/[subject_id]/route.js +76 -0
  712. package/dist/modules/forms/api/form-submissions/by-subject/[subject_type]/[subject_id]/route.js.map +7 -0
  713. package/dist/modules/forms/api/form-submissions/route.js +113 -0
  714. package/dist/modules/forms/api/form-submissions/route.js.map +7 -0
  715. package/dist/modules/forms/api/helpers.js +124 -0
  716. package/dist/modules/forms/api/helpers.js.map +7 -0
  717. package/dist/modules/forms/api/public/distributions/[slug]/embed-policy/route.js +47 -0
  718. package/dist/modules/forms/api/public/distributions/[slug]/embed-policy/route.js.map +7 -0
  719. package/dist/modules/forms/api/public/distributions/[slug]/route.js +81 -0
  720. package/dist/modules/forms/api/public/distributions/[slug]/route.js.map +7 -0
  721. package/dist/modules/forms/api/public/embed-loader/route.js +116 -0
  722. package/dist/modules/forms/api/public/embed-loader/route.js.map +7 -0
  723. package/dist/modules/forms/api/public/invitations/[token]/route.js +87 -0
  724. package/dist/modules/forms/api/public/invitations/[token]/route.js.map +7 -0
  725. package/dist/modules/forms/api/public/rate-limit.js +54 -0
  726. package/dist/modules/forms/api/public/rate-limit.js.map +7 -0
  727. package/dist/modules/forms/api/public/start/route.js +142 -0
  728. package/dist/modules/forms/api/public/start/route.js.map +7 -0
  729. package/dist/modules/forms/api/public/submissions/[id]/attachments/[attachmentId]/route.js +67 -0
  730. package/dist/modules/forms/api/public/submissions/[id]/attachments/[attachmentId]/route.js.map +7 -0
  731. package/dist/modules/forms/api/public/submissions/[id]/attachments/route.js +85 -0
  732. package/dist/modules/forms/api/public/submissions/[id]/attachments/route.js.map +7 -0
  733. package/dist/modules/forms/api/public/submissions/[id]/pdf/route.js +72 -0
  734. package/dist/modules/forms/api/public/submissions/[id]/pdf/route.js.map +7 -0
  735. package/dist/modules/forms/api/public/submissions/[id]/route.js +154 -0
  736. package/dist/modules/forms/api/public/submissions/[id]/route.js.map +7 -0
  737. package/dist/modules/forms/api/public/submissions/[id]/submit/route.js +127 -0
  738. package/dist/modules/forms/api/public/submissions/[id]/submit/route.js.map +7 -0
  739. package/dist/modules/forms/api/route.js +216 -0
  740. package/dist/modules/forms/api/route.js.map +7 -0
  741. package/dist/modules/forms/api/runtime-helpers.js +149 -0
  742. package/dist/modules/forms/api/runtime-helpers.js.map +7 -0
  743. package/dist/modules/forms/api/subjects/[subjectType]/[subjectId]/consents/route.js +137 -0
  744. package/dist/modules/forms/api/subjects/[subjectType]/[subjectId]/consents/route.js.map +7 -0
  745. package/dist/modules/forms/api/subjects/[subjectType]/[subjectId]/export/route.js +101 -0
  746. package/dist/modules/forms/api/subjects/[subjectType]/[subjectId]/export/route.js.map +7 -0
  747. package/dist/modules/forms/api/submissions/[submissionId]/access-audit/route.js +76 -0
  748. package/dist/modules/forms/api/submissions/[submissionId]/access-audit/route.js.map +7 -0
  749. package/dist/modules/forms/api/submissions/[submissionId]/actors/[actorId]/route.js +56 -0
  750. package/dist/modules/forms/api/submissions/[submissionId]/actors/[actorId]/route.js.map +7 -0
  751. package/dist/modules/forms/api/submissions/[submissionId]/actors/route.js +76 -0
  752. package/dist/modules/forms/api/submissions/[submissionId]/actors/route.js.map +7 -0
  753. package/dist/modules/forms/api/submissions/[submissionId]/anonymize/route.js +107 -0
  754. package/dist/modules/forms/api/submissions/[submissionId]/anonymize/route.js.map +7 -0
  755. package/dist/modules/forms/api/submissions/[submissionId]/attachments/[attachmentId]/route.js +73 -0
  756. package/dist/modules/forms/api/submissions/[submissionId]/attachments/[attachmentId]/route.js.map +7 -0
  757. package/dist/modules/forms/api/submissions/[submissionId]/export/route.js +90 -0
  758. package/dist/modules/forms/api/submissions/[submissionId]/export/route.js.map +7 -0
  759. package/dist/modules/forms/api/submissions/[submissionId]/pdf/route.js +91 -0
  760. package/dist/modules/forms/api/submissions/[submissionId]/pdf/route.js.map +7 -0
  761. package/dist/modules/forms/api/submissions/[submissionId]/reopen/route.js +55 -0
  762. package/dist/modules/forms/api/submissions/[submissionId]/reopen/route.js.map +7 -0
  763. package/dist/modules/forms/api/submissions/[submissionId]/revisions/route.js +61 -0
  764. package/dist/modules/forms/api/submissions/[submissionId]/revisions/route.js.map +7 -0
  765. package/dist/modules/forms/api/submissions/[submissionId]/route.js +75 -0
  766. package/dist/modules/forms/api/submissions/[submissionId]/route.js.map +7 -0
  767. package/dist/modules/forms/backend/forms/[id]/FormStudio.js +2811 -0
  768. package/dist/modules/forms/backend/forms/[id]/FormStudio.js.map +7 -0
  769. package/dist/modules/forms/backend/forms/[id]/analytics/page.js +214 -0
  770. package/dist/modules/forms/backend/forms/[id]/analytics/page.js.map +7 -0
  771. package/dist/modules/forms/backend/forms/[id]/analytics/page.meta.js +19 -0
  772. package/dist/modules/forms/backend/forms/[id]/analytics/page.meta.js.map +7 -0
  773. package/dist/modules/forms/backend/forms/[id]/distributions/page.js +12 -0
  774. package/dist/modules/forms/backend/forms/[id]/distributions/page.js.map +7 -0
  775. package/dist/modules/forms/backend/forms/[id]/distributions/page.meta.js +19 -0
  776. package/dist/modules/forms/backend/forms/[id]/distributions/page.meta.js.map +7 -0
  777. package/dist/modules/forms/backend/forms/[id]/history/page.js +152 -0
  778. package/dist/modules/forms/backend/forms/[id]/history/page.js.map +7 -0
  779. package/dist/modules/forms/backend/forms/[id]/history/page.meta.js +15 -0
  780. package/dist/modules/forms/backend/forms/[id]/history/page.meta.js.map +7 -0
  781. package/dist/modules/forms/backend/forms/[id]/page.js +13 -0
  782. package/dist/modules/forms/backend/forms/[id]/page.js.map +7 -0
  783. package/dist/modules/forms/backend/forms/[id]/page.meta.js +15 -0
  784. package/dist/modules/forms/backend/forms/[id]/page.meta.js.map +7 -0
  785. package/dist/modules/forms/backend/forms/[id]/studio/YesNoRow.js +51 -0
  786. package/dist/modules/forms/backend/forms/[id]/studio/YesNoRow.js.map +7 -0
  787. package/dist/modules/forms/backend/forms/[id]/studio/autosave-guard.js +21 -0
  788. package/dist/modules/forms/backend/forms/[id]/studio/autosave-guard.js.map +7 -0
  789. package/dist/modules/forms/backend/forms/[id]/studio/canvas/DragOverlayCard.js +18 -0
  790. package/dist/modules/forms/backend/forms/[id]/studio/canvas/DragOverlayCard.js.map +7 -0
  791. package/dist/modules/forms/backend/forms/[id]/studio/canvas/DropIndicator.js +41 -0
  792. package/dist/modules/forms/backend/forms/[id]/studio/canvas/DropIndicator.js.map +7 -0
  793. package/dist/modules/forms/backend/forms/[id]/studio/canvas/FieldRow.js +277 -0
  794. package/dist/modules/forms/backend/forms/[id]/studio/canvas/FieldRow.js.map +7 -0
  795. package/dist/modules/forms/backend/forms/[id]/studio/canvas/FormCanvas.js +196 -0
  796. package/dist/modules/forms/backend/forms/[id]/studio/canvas/FormCanvas.js.map +7 -0
  797. package/dist/modules/forms/backend/forms/[id]/studio/canvas/GridSlot.js +151 -0
  798. package/dist/modules/forms/backend/forms/[id]/studio/canvas/GridSlot.js.map +7 -0
  799. package/dist/modules/forms/backend/forms/[id]/studio/canvas/SectionContainer.js +340 -0
  800. package/dist/modules/forms/backend/forms/[id]/studio/canvas/SectionContainer.js.map +7 -0
  801. package/dist/modules/forms/backend/forms/[id]/studio/canvas/grid-collision.js +24 -0
  802. package/dist/modules/forms/backend/forms/[id]/studio/canvas/grid-collision.js.map +7 -0
  803. package/dist/modules/forms/backend/forms/[id]/studio/canvas/keyboard-coordinates.js +91 -0
  804. package/dist/modules/forms/backend/forms/[id]/studio/canvas/keyboard-coordinates.js.map +7 -0
  805. package/dist/modules/forms/backend/forms/[id]/studio/canvas/overlay-size.js +11 -0
  806. package/dist/modules/forms/backend/forms/[id]/studio/canvas/overlay-size.js.map +7 -0
  807. package/dist/modules/forms/backend/forms/[id]/studio/canvas/resize-math.js +27 -0
  808. package/dist/modules/forms/backend/forms/[id]/studio/canvas/resize-math.js.map +7 -0
  809. package/dist/modules/forms/backend/forms/[id]/studio/canvas/row-layout.js +80 -0
  810. package/dist/modules/forms/backend/forms/[id]/studio/canvas/row-layout.js.map +7 -0
  811. package/dist/modules/forms/backend/forms/[id]/studio/logic/ConditionBuilder.js +210 -0
  812. package/dist/modules/forms/backend/forms/[id]/studio/logic/ConditionBuilder.js.map +7 -0
  813. package/dist/modules/forms/backend/forms/[id]/studio/logic/HiddenFieldsPanel.js +91 -0
  814. package/dist/modules/forms/backend/forms/[id]/studio/logic/HiddenFieldsPanel.js.map +7 -0
  815. package/dist/modules/forms/backend/forms/[id]/studio/logic/JumpsEditor.js +201 -0
  816. package/dist/modules/forms/backend/forms/[id]/studio/logic/JumpsEditor.js.map +7 -0
  817. package/dist/modules/forms/backend/forms/[id]/studio/logic/RecallTokenPicker.js +66 -0
  818. package/dist/modules/forms/backend/forms/[id]/studio/logic/RecallTokenPicker.js.map +7 -0
  819. package/dist/modules/forms/backend/forms/[id]/studio/logic/VariablesPanel.js +223 -0
  820. package/dist/modules/forms/backend/forms/[id]/studio/logic/VariablesPanel.js.map +7 -0
  821. package/dist/modules/forms/backend/forms/[id]/studio/logic/condition-model.js +151 -0
  822. package/dist/modules/forms/backend/forms/[id]/studio/logic/condition-model.js.map +7 -0
  823. package/dist/modules/forms/backend/forms/[id]/studio/lucide-icons.js +88 -0
  824. package/dist/modules/forms/backend/forms/[id]/studio/lucide-icons.js.map +7 -0
  825. package/dist/modules/forms/backend/forms/[id]/studio/palette/FormAppearancePanel.js +493 -0
  826. package/dist/modules/forms/backend/forms/[id]/studio/palette/FormAppearancePanel.js.map +7 -0
  827. package/dist/modules/forms/backend/forms/[id]/studio/palette/FormPalettePanel.js +44 -0
  828. package/dist/modules/forms/backend/forms/[id]/studio/palette/FormPalettePanel.js.map +7 -0
  829. package/dist/modules/forms/backend/forms/[id]/studio/palette/InputParametersTab.js +350 -0
  830. package/dist/modules/forms/backend/forms/[id]/studio/palette/InputParametersTab.js.map +7 -0
  831. package/dist/modules/forms/backend/forms/[id]/studio/palette/PaletteCard.js +40 -0
  832. package/dist/modules/forms/backend/forms/[id]/studio/palette/PaletteCard.js.map +7 -0
  833. package/dist/modules/forms/backend/forms/[id]/studio/palette/RolesEditor.js +202 -0
  834. package/dist/modules/forms/backend/forms/[id]/studio/palette/RolesEditor.js.map +7 -0
  835. package/dist/modules/forms/backend/forms/[id]/studio/palette/entries.js +66 -0
  836. package/dist/modules/forms/backend/forms/[id]/studio/palette/entries.js.map +7 -0
  837. package/dist/modules/forms/backend/forms/[id]/studio/preview/PreviewSurface.js +1200 -0
  838. package/dist/modules/forms/backend/forms/[id]/studio/preview/PreviewSurface.js.map +7 -0
  839. package/dist/modules/forms/backend/forms/[id]/studio/preview/ViewportFrame.js +34 -0
  840. package/dist/modules/forms/backend/forms/[id]/studio/preview/ViewportFrame.js.map +7 -0
  841. package/dist/modules/forms/backend/forms/[id]/studio/recall.js +76 -0
  842. package/dist/modules/forms/backend/forms/[id]/studio/recall.js.map +7 -0
  843. package/dist/modules/forms/backend/forms/[id]/studio/schema-helpers.js +1693 -0
  844. package/dist/modules/forms/backend/forms/[id]/studio/schema-helpers.js.map +7 -0
  845. package/dist/modules/forms/backend/forms/[id]/studio/style/BackgroundControl.js +127 -0
  846. package/dist/modules/forms/backend/forms/[id]/studio/style/BackgroundControl.js.map +7 -0
  847. package/dist/modules/forms/backend/forms/[id]/studio/style/ColorControl.js +181 -0
  848. package/dist/modules/forms/backend/forms/[id]/studio/style/ColorControl.js.map +7 -0
  849. package/dist/modules/forms/backend/forms/[id]/studio/style/contrast.js +75 -0
  850. package/dist/modules/forms/backend/forms/[id]/studio/style/contrast.js.map +7 -0
  851. package/dist/modules/forms/backend/forms/[id]/studio/style/presets.js +91 -0
  852. package/dist/modules/forms/backend/forms/[id]/studio/style/presets.js.map +7 -0
  853. package/dist/modules/forms/backend/forms/[id]/studio/type-label.js +11 -0
  854. package/dist/modules/forms/backend/forms/[id]/studio/type-label.js.map +7 -0
  855. package/dist/modules/forms/backend/forms/[id]/studio/types.js +1 -0
  856. package/dist/modules/forms/backend/forms/[id]/studio/types.js.map +7 -0
  857. package/dist/modules/forms/backend/forms/[id]/studio/undo-controller.js +43 -0
  858. package/dist/modules/forms/backend/forms/[id]/studio/undo-controller.js.map +7 -0
  859. package/dist/modules/forms/backend/forms/[id]/studio/validation/FileConstraintsEditor.js +74 -0
  860. package/dist/modules/forms/backend/forms/[id]/studio/validation/FileConstraintsEditor.js.map +7 -0
  861. package/dist/modules/forms/backend/forms/[id]/studio/validation/GroupConfigEditor.js +134 -0
  862. package/dist/modules/forms/backend/forms/[id]/studio/validation/GroupConfigEditor.js.map +7 -0
  863. package/dist/modules/forms/backend/forms/[id]/studio/validation/LengthRangeEditor.js +61 -0
  864. package/dist/modules/forms/backend/forms/[id]/studio/validation/LengthRangeEditor.js.map +7 -0
  865. package/dist/modules/forms/backend/forms/[id]/studio/validation/MatrixColumnsEditor.js +149 -0
  866. package/dist/modules/forms/backend/forms/[id]/studio/validation/MatrixColumnsEditor.js.map +7 -0
  867. package/dist/modules/forms/backend/forms/[id]/studio/validation/MatrixRowsEditor.js +168 -0
  868. package/dist/modules/forms/backend/forms/[id]/studio/validation/MatrixRowsEditor.js.map +7 -0
  869. package/dist/modules/forms/backend/forms/[id]/studio/validation/MessageOverridesEditor.js +64 -0
  870. package/dist/modules/forms/backend/forms/[id]/studio/validation/MessageOverridesEditor.js.map +7 -0
  871. package/dist/modules/forms/backend/forms/[id]/studio/validation/NpsAnchorsEditor.js +52 -0
  872. package/dist/modules/forms/backend/forms/[id]/studio/validation/NpsAnchorsEditor.js.map +7 -0
  873. package/dist/modules/forms/backend/forms/[id]/studio/validation/NumberRangeEditor.js +59 -0
  874. package/dist/modules/forms/backend/forms/[id]/studio/validation/NumberRangeEditor.js.map +7 -0
  875. package/dist/modules/forms/backend/forms/[id]/studio/validation/OpinionIconSelect.js +31 -0
  876. package/dist/modules/forms/backend/forms/[id]/studio/validation/OpinionIconSelect.js.map +7 -0
  877. package/dist/modules/forms/backend/forms/[id]/studio/validation/PatternEditor.js +105 -0
  878. package/dist/modules/forms/backend/forms/[id]/studio/validation/PatternEditor.js.map +7 -0
  879. package/dist/modules/forms/backend/forms/[id]/studio/validation/RankingExhaustiveSwitch.js +15 -0
  880. package/dist/modules/forms/backend/forms/[id]/studio/validation/RankingExhaustiveSwitch.js.map +7 -0
  881. package/dist/modules/forms/backend/forms/[id]/studio/validation/SignatureConfigEditor.js +75 -0
  882. package/dist/modules/forms/backend/forms/[id]/studio/validation/SignatureConfigEditor.js.map +7 -0
  883. package/dist/modules/forms/backend/forms/[id]/studio/validation/ValidationPanel.js +293 -0
  884. package/dist/modules/forms/backend/forms/[id]/studio/validation/ValidationPanel.js.map +7 -0
  885. package/dist/modules/forms/backend/forms/[id]/submissions/components/RowBadges.js +42 -0
  886. package/dist/modules/forms/backend/forms/[id]/submissions/components/RowBadges.js.map +7 -0
  887. package/dist/modules/forms/backend/forms/[id]/submissions/components/SubmissionDrawer.js +473 -0
  888. package/dist/modules/forms/backend/forms/[id]/submissions/components/SubmissionDrawer.js.map +7 -0
  889. package/dist/modules/forms/backend/forms/[id]/submissions/page.js +208 -0
  890. package/dist/modules/forms/backend/forms/[id]/submissions/page.js.map +7 -0
  891. package/dist/modules/forms/backend/forms/[id]/submissions/page.meta.js +12 -0
  892. package/dist/modules/forms/backend/forms/[id]/submissions/page.meta.js.map +7 -0
  893. package/dist/modules/forms/backend/forms/create/page.js +101 -0
  894. package/dist/modules/forms/backend/forms/create/page.js.map +7 -0
  895. package/dist/modules/forms/backend/forms/create/page.meta.js +15 -0
  896. package/dist/modules/forms/backend/forms/create/page.meta.js.map +7 -0
  897. package/dist/modules/forms/backend/forms/page.js +227 -0
  898. package/dist/modules/forms/backend/forms/page.js.map +7 -0
  899. package/dist/modules/forms/backend/forms/page.meta.js +33 -0
  900. package/dist/modules/forms/backend/forms/page.meta.js.map +7 -0
  901. package/dist/modules/forms/commands/distribution.js +417 -0
  902. package/dist/modules/forms/commands/distribution.js.map +7 -0
  903. package/dist/modules/forms/commands/form-version.js +640 -0
  904. package/dist/modules/forms/commands/form-version.js.map +7 -0
  905. package/dist/modules/forms/commands/form.js +406 -0
  906. package/dist/modules/forms/commands/form.js.map +7 -0
  907. package/dist/modules/forms/commands/index.js +11 -0
  908. package/dist/modules/forms/commands/index.js.map +7 -0
  909. package/dist/modules/forms/commands/invitation.js +329 -0
  910. package/dist/modules/forms/commands/invitation.js.map +7 -0
  911. package/dist/modules/forms/commands/shared.js +151 -0
  912. package/dist/modules/forms/commands/shared.js.map +7 -0
  913. package/dist/modules/forms/commands/submission.js +132 -0
  914. package/dist/modules/forms/commands/submission.js.map +7 -0
  915. package/dist/modules/forms/data/entities.js +654 -0
  916. package/dist/modules/forms/data/entities.js.map +7 -0
  917. package/dist/modules/forms/data/validators.js +254 -0
  918. package/dist/modules/forms/data/validators.js.map +7 -0
  919. package/dist/modules/forms/di.js +199 -0
  920. package/dist/modules/forms/di.js.map +7 -0
  921. package/dist/modules/forms/encryption.js +15 -0
  922. package/dist/modules/forms/encryption.js.map +7 -0
  923. package/dist/modules/forms/events-payloads.js +81 -0
  924. package/dist/modules/forms/events-payloads.js.map +7 -0
  925. package/dist/modules/forms/events.js +33 -0
  926. package/dist/modules/forms/events.js.map +7 -0
  927. package/dist/modules/forms/extension-points.js +36 -0
  928. package/dist/modules/forms/extension-points.js.map +7 -0
  929. package/dist/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.js +33 -0
  930. package/dist/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.js.map +7 -0
  931. package/dist/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.meta.js +11 -0
  932. package/dist/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.meta.js.map +7 -0
  933. package/dist/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.js +41 -0
  934. package/dist/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.js.map +7 -0
  935. package/dist/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.meta.js +11 -0
  936. package/dist/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.meta.js.map +7 -0
  937. package/dist/modules/forms/frontend/embed/[slug]/page.js +105 -0
  938. package/dist/modules/forms/frontend/embed/[slug]/page.js.map +7 -0
  939. package/dist/modules/forms/frontend/embed/[slug]/page.meta.js +11 -0
  940. package/dist/modules/forms/frontend/embed/[slug]/page.meta.js.map +7 -0
  941. package/dist/modules/forms/frontend/f/[slug]/page.js +12 -0
  942. package/dist/modules/forms/frontend/f/[slug]/page.js.map +7 -0
  943. package/dist/modules/forms/frontend/f/[slug]/page.meta.js +11 -0
  944. package/dist/modules/forms/frontend/f/[slug]/page.meta.js.map +7 -0
  945. package/dist/modules/forms/frontend/forms/[id]/run/page.js +62 -0
  946. package/dist/modules/forms/frontend/forms/[id]/run/page.js.map +7 -0
  947. package/dist/modules/forms/frontend/forms/[id]/run/page.meta.js +11 -0
  948. package/dist/modules/forms/frontend/forms/[id]/run/page.meta.js.map +7 -0
  949. package/dist/modules/forms/frontend/i/[token]/page.js +12 -0
  950. package/dist/modules/forms/frontend/i/[token]/page.js.map +7 -0
  951. package/dist/modules/forms/frontend/i/[token]/page.meta.js +11 -0
  952. package/dist/modules/forms/frontend/i/[token]/page.meta.js.map +7 -0
  953. package/dist/modules/forms/index.js +20 -0
  954. package/dist/modules/forms/index.js.map +7 -0
  955. package/dist/modules/forms/lib/embed-frame-policy.js +68 -0
  956. package/dist/modules/forms/lib/embed-frame-policy.js.map +7 -0
  957. package/dist/modules/forms/lib/form-definition-slicing.js +38 -0
  958. package/dist/modules/forms/lib/form-definition-slicing.js.map +7 -0
  959. package/dist/modules/forms/lib/log-redaction.js +38 -0
  960. package/dist/modules/forms/lib/log-redaction.js.map +7 -0
  961. package/dist/modules/forms/lib/navigable-url.js +24 -0
  962. package/dist/modules/forms/lib/navigable-url.js.map +7 -0
  963. package/dist/modules/forms/lib/retention.js +20 -0
  964. package/dist/modules/forms/lib/retention.js.map +7 -0
  965. package/dist/modules/forms/lib/runtime-principal.js +59 -0
  966. package/dist/modules/forms/lib/runtime-principal.js.map +7 -0
  967. package/dist/modules/forms/migrations/Migration20260508135459_forms.js +17 -0
  968. package/dist/modules/forms/migrations/Migration20260508135459_forms.js.map +7 -0
  969. package/dist/modules/forms/migrations/Migration20260508140932_forms.js +23 -0
  970. package/dist/modules/forms/migrations/Migration20260508140932_forms.js.map +7 -0
  971. package/dist/modules/forms/migrations/Migration20260508155737_forms.js +15 -0
  972. package/dist/modules/forms/migrations/Migration20260508155737_forms.js.map +7 -0
  973. package/dist/modules/forms/migrations/Migration20260520120000_forms.js +23 -0
  974. package/dist/modules/forms/migrations/Migration20260520120000_forms.js.map +7 -0
  975. package/dist/modules/forms/migrations/Migration20260521090000_forms.js +13 -0
  976. package/dist/modules/forms/migrations/Migration20260521090000_forms.js.map +7 -0
  977. package/dist/modules/forms/migrations/Migration20260521120000_forms.js +17 -0
  978. package/dist/modules/forms/migrations/Migration20260521120000_forms.js.map +7 -0
  979. package/dist/modules/forms/runner/FormRunner.js +786 -0
  980. package/dist/modules/forms/runner/FormRunner.js.map +7 -0
  981. package/dist/modules/forms/runner/MatrixField.js +150 -0
  982. package/dist/modules/forms/runner/MatrixField.js.map +7 -0
  983. package/dist/modules/forms/runner/RankingField.js +131 -0
  984. package/dist/modules/forms/runner/RankingField.js.map +7 -0
  985. package/dist/modules/forms/runner/ScaleField.js +78 -0
  986. package/dist/modules/forms/runner/ScaleField.js.map +7 -0
  987. package/dist/modules/forms/runner/SignatureField.js +132 -0
  988. package/dist/modules/forms/runner/SignatureField.js.map +7 -0
  989. package/dist/modules/forms/runner/tamper-check.js +85 -0
  990. package/dist/modules/forms/runner/tamper-check.js.map +7 -0
  991. package/dist/modules/forms/schema/address-countries.js +43 -0
  992. package/dist/modules/forms/schema/address-countries.js.map +7 -0
  993. package/dist/modules/forms/schema/field-type-patterns.js +15 -0
  994. package/dist/modules/forms/schema/field-type-patterns.js.map +7 -0
  995. package/dist/modules/forms/schema/field-type-registry-advanced.js +32 -0
  996. package/dist/modules/forms/schema/field-type-registry-advanced.js.map +7 -0
  997. package/dist/modules/forms/schema/field-type-registry.js +625 -0
  998. package/dist/modules/forms/schema/field-type-registry.js.map +7 -0
  999. package/dist/modules/forms/schema/file-field.js +64 -0
  1000. package/dist/modules/forms/schema/file-field.js.map +7 -0
  1001. package/dist/modules/forms/schema/group-field.js +143 -0
  1002. package/dist/modules/forms/schema/group-field.js.map +7 -0
  1003. package/dist/modules/forms/schema/jsonlogic-grammar.js +66 -0
  1004. package/dist/modules/forms/schema/jsonlogic-grammar.js.map +7 -0
  1005. package/dist/modules/forms/schema/jsonschema-extensions.js +739 -0
  1006. package/dist/modules/forms/schema/jsonschema-extensions.js.map +7 -0
  1007. package/dist/modules/forms/schema/layout-catalog.js +38 -0
  1008. package/dist/modules/forms/schema/layout-catalog.js.map +7 -0
  1009. package/dist/modules/forms/schema/signature-field.js +67 -0
  1010. package/dist/modules/forms/schema/signature-field.js.map +7 -0
  1011. package/dist/modules/forms/schema/style-extensions.js +77 -0
  1012. package/dist/modules/forms/schema/style-extensions.js.map +7 -0
  1013. package/dist/modules/forms/schema/style-validators.js +181 -0
  1014. package/dist/modules/forms/schema/style-validators.js.map +7 -0
  1015. package/dist/modules/forms/services/access-audit-logger.js +179 -0
  1016. package/dist/modules/forms/services/access-audit-logger.js.map +7 -0
  1017. package/dist/modules/forms/services/analytics-service.js +306 -0
  1018. package/dist/modules/forms/services/analytics-service.js.map +7 -0
  1019. package/dist/modules/forms/services/anonymize-service.js +123 -0
  1020. package/dist/modules/forms/services/anonymize-service.js.map +7 -0
  1021. package/dist/modules/forms/services/attachment-service.js +123 -0
  1022. package/dist/modules/forms/services/attachment-service.js.map +7 -0
  1023. package/dist/modules/forms/services/captcha-verifier.js +76 -0
  1024. package/dist/modules/forms/services/captcha-verifier.js.map +7 -0
  1025. package/dist/modules/forms/services/consent-record-service.js +96 -0
  1026. package/dist/modules/forms/services/consent-record-service.js.map +7 -0
  1027. package/dist/modules/forms/services/distribution-service.js +366 -0
  1028. package/dist/modules/forms/services/distribution-service.js.map +7 -0
  1029. package/dist/modules/forms/services/distribution-token.js +93 -0
  1030. package/dist/modules/forms/services/distribution-token.js.map +7 -0
  1031. package/dist/modules/forms/services/encryption-service.js +328 -0
  1032. package/dist/modules/forms/services/encryption-service.js.map +7 -0
  1033. package/dist/modules/forms/services/export-service.js +210 -0
  1034. package/dist/modules/forms/services/export-service.js.map +7 -0
  1035. package/dist/modules/forms/services/field-validation-service.js +168 -0
  1036. package/dist/modules/forms/services/field-validation-service.js.map +7 -0
  1037. package/dist/modules/forms/services/form-logic-evaluator.js +517 -0
  1038. package/dist/modules/forms/services/form-logic-evaluator.js.map +7 -0
  1039. package/dist/modules/forms/services/form-version-compiler.js +518 -0
  1040. package/dist/modules/forms/services/form-version-compiler.js.map +7 -0
  1041. package/dist/modules/forms/services/form-version-differ.js +89 -0
  1042. package/dist/modules/forms/services/form-version-differ.js.map +7 -0
  1043. package/dist/modules/forms/services/jsonlogic-evaluator.js +171 -0
  1044. package/dist/modules/forms/services/jsonlogic-evaluator.js.map +7 -0
  1045. package/dist/modules/forms/services/pdf-snapshot-service.js +526 -0
  1046. package/dist/modules/forms/services/pdf-snapshot-service.js.map +7 -0
  1047. package/dist/modules/forms/services/prefill-resolver.js +53 -0
  1048. package/dist/modules/forms/services/prefill-resolver.js.map +7 -0
  1049. package/dist/modules/forms/services/role-policy-service.js +55 -0
  1050. package/dist/modules/forms/services/role-policy-service.js.map +7 -0
  1051. package/dist/modules/forms/services/style-compiler.js +234 -0
  1052. package/dist/modules/forms/services/style-compiler.js.map +7 -0
  1053. package/dist/modules/forms/services/submission-service.js +858 -0
  1054. package/dist/modules/forms/services/submission-service.js.map +7 -0
  1055. package/dist/modules/forms/services/upload-scanner.js +9 -0
  1056. package/dist/modules/forms/services/upload-scanner.js.map +7 -0
  1057. package/dist/modules/forms/services/upload-validation.js +54 -0
  1058. package/dist/modules/forms/services/upload-validation.js.map +7 -0
  1059. package/dist/modules/forms/services/visibility-resolver.js +30 -0
  1060. package/dist/modules/forms/services/visibility-resolver.js.map +7 -0
  1061. package/dist/modules/forms/setup.js +18 -0
  1062. package/dist/modules/forms/setup.js.map +7 -0
  1063. package/dist/modules/forms/subscribers/forms-consent-projector.js +58 -0
  1064. package/dist/modules/forms/subscribers/forms-consent-projector.js.map +7 -0
  1065. package/dist/modules/forms/subscribers/forms-pdf-snapshot.js +68 -0
  1066. package/dist/modules/forms/subscribers/forms-pdf-snapshot.js.map +7 -0
  1067. package/dist/modules/forms/subscribers/forms-webhook-bridge-anonymized.js +29 -0
  1068. package/dist/modules/forms/subscribers/forms-webhook-bridge-anonymized.js.map +7 -0
  1069. package/dist/modules/forms/subscribers/forms-webhook-bridge.js +35 -0
  1070. package/dist/modules/forms/subscribers/forms-webhook-bridge.js.map +7 -0
  1071. package/dist/modules/forms/subscribers/invitation-email.js +100 -0
  1072. package/dist/modules/forms/subscribers/invitation-email.js.map +7 -0
  1073. package/dist/modules/forms/translations.js +10 -0
  1074. package/dist/modules/forms/translations.js.map +7 -0
  1075. package/dist/modules/forms/ui/admin/forms/[id]/distributions/CreateDistributionDialog.js +376 -0
  1076. package/dist/modules/forms/ui/admin/forms/[id]/distributions/CreateDistributionDialog.js.map +7 -0
  1077. package/dist/modules/forms/ui/admin/forms/[id]/distributions/DistributionsPanel.js +313 -0
  1078. package/dist/modules/forms/ui/admin/forms/[id]/distributions/DistributionsPanel.js.map +7 -0
  1079. package/dist/modules/forms/ui/admin/forms/[id]/distributions/EmbedSettingsDialog.js +263 -0
  1080. package/dist/modules/forms/ui/admin/forms/[id]/distributions/EmbedSettingsDialog.js.map +7 -0
  1081. package/dist/modules/forms/ui/admin/forms/[id]/distributions/RecipientsTable.js +373 -0
  1082. package/dist/modules/forms/ui/admin/forms/[id]/distributions/RecipientsTable.js.map +7 -0
  1083. package/dist/modules/forms/ui/public/EmbeddedForm.js +166 -0
  1084. package/dist/modules/forms/ui/public/EmbeddedForm.js.map +7 -0
  1085. package/dist/modules/forms/ui/public/FormRunner.js +359 -0
  1086. package/dist/modules/forms/ui/public/FormRunner.js.map +7 -0
  1087. package/dist/modules/forms/ui/public/FormTrigger.js +45 -0
  1088. package/dist/modules/forms/ui/public/FormTrigger.js.map +7 -0
  1089. package/dist/modules/forms/ui/public/PublicFormRunnerPage.js +14 -0
  1090. package/dist/modules/forms/ui/public/PublicFormRunnerPage.js.map +7 -0
  1091. package/dist/modules/forms/ui/public/components/CompletionScreen.js +55 -0
  1092. package/dist/modules/forms/ui/public/components/CompletionScreen.js.map +7 -0
  1093. package/dist/modules/forms/ui/public/components/LocaleSwitch.js +28 -0
  1094. package/dist/modules/forms/ui/public/components/LocaleSwitch.js.map +7 -0
  1095. package/dist/modules/forms/ui/public/components/ResumeGate.js +52 -0
  1096. package/dist/modules/forms/ui/public/components/ResumeGate.js.map +7 -0
  1097. package/dist/modules/forms/ui/public/components/ReviewStep.js +90 -0
  1098. package/dist/modules/forms/ui/public/components/ReviewStep.js.map +7 -0
  1099. package/dist/modules/forms/ui/public/components/SaveIndicator.js +65 -0
  1100. package/dist/modules/forms/ui/public/components/SaveIndicator.js.map +7 -0
  1101. package/dist/modules/forms/ui/public/components/SectionStepper.js +52 -0
  1102. package/dist/modules/forms/ui/public/components/SectionStepper.js.map +7 -0
  1103. package/dist/modules/forms/ui/public/index.js +38 -0
  1104. package/dist/modules/forms/ui/public/index.js.map +7 -0
  1105. package/dist/modules/forms/ui/public/renderers/index.js +737 -0
  1106. package/dist/modules/forms/ui/public/renderers/index.js.map +7 -0
  1107. package/dist/modules/forms/ui/public/state/logic-derivation.js +42 -0
  1108. package/dist/modules/forms/ui/public/state/logic-derivation.js.map +7 -0
  1109. package/dist/modules/forms/ui/public/state/runtime-client.js +306 -0
  1110. package/dist/modules/forms/ui/public/state/runtime-client.js.map +7 -0
  1111. package/dist/modules/forms/ui/public/state/useAutosave.js +64 -0
  1112. package/dist/modules/forms/ui/public/state/useAutosave.js.map +7 -0
  1113. package/dist/modules/forms/ui/public/state/useFormRunner.js +394 -0
  1114. package/dist/modules/forms/ui/public/state/useFormRunner.js.map +7 -0
  1115. package/dist/modules/forms/ui/public/style/LogoHeader.js +33 -0
  1116. package/dist/modules/forms/ui/public/style/LogoHeader.js.map +7 -0
  1117. package/dist/modules/forms/ui/public/style/applyStyle.js +12 -0
  1118. package/dist/modules/forms/ui/public/style/applyStyle.js.map +7 -0
  1119. package/dist/modules/forms/ui/public/types.js +18 -0
  1120. package/dist/modules/forms/ui/public/types.js.map +7 -0
  1121. package/dist/modules/forms/widgets/injection/access-audit-panel/widget.js +100 -0
  1122. package/dist/modules/forms/widgets/injection/access-audit-panel/widget.js.map +7 -0
  1123. package/dist/modules/forms/widgets/injection/anonymize-button/widget.js +148 -0
  1124. package/dist/modules/forms/widgets/injection/anonymize-button/widget.js.map +7 -0
  1125. package/dist/modules/forms/widgets/injection/audit-format.js +33 -0
  1126. package/dist/modules/forms/widgets/injection/audit-format.js.map +7 -0
  1127. package/dist/modules/forms/widgets/injection/context.js +5 -0
  1128. package/dist/modules/forms/widgets/injection/context.js.map +7 -0
  1129. package/dist/modules/forms/widgets/injection/embedded-form/widget.js +52 -0
  1130. package/dist/modules/forms/widgets/injection/embedded-form/widget.js.map +7 -0
  1131. package/dist/modules/forms/widgets/injection/pdf-download-button/widget.js +83 -0
  1132. package/dist/modules/forms/widgets/injection/pdf-download-button/widget.js.map +7 -0
  1133. package/dist/modules/forms/widgets/injection/self-audit-footer/widget.js +38 -0
  1134. package/dist/modules/forms/widgets/injection/self-audit-footer/widget.js.map +7 -0
  1135. package/dist/modules/forms/widgets/injection-table.js +32 -0
  1136. package/dist/modules/forms/widgets/injection-table.js.map +7 -0
  1137. package/dist/modules/forms/workers/pdf-snapshot.js +60 -0
  1138. package/dist/modules/forms/workers/pdf-snapshot.js.map +7 -0
  1139. package/dist/modules/forms/workers/retention-purge.js +112 -0
  1140. package/dist/modules/forms/workers/retention-purge.js.map +7 -0
  1141. package/dist/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/route.js +7 -1
  1142. package/dist/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/route.js.map +2 -2
  1143. package/dist/modules/inbox_ops/data/validators.js +2 -2
  1144. package/dist/modules/inbox_ops/data/validators.js.map +2 -2
  1145. package/dist/modules/inbox_ops/lib/llmProvider.js +5 -1
  1146. package/dist/modules/inbox_ops/lib/llmProvider.js.map +2 -2
  1147. package/dist/modules/inbox_ops/widgets/notifications/ProposalCreatedRenderer.js +2 -2
  1148. package/dist/modules/inbox_ops/widgets/notifications/ProposalCreatedRenderer.js.map +2 -2
  1149. package/dist/modules/integrations/di.js +3 -1
  1150. package/dist/modules/integrations/di.js.map +2 -2
  1151. package/dist/modules/integrations/lib/credentials-service.js +29 -36
  1152. package/dist/modules/integrations/lib/credentials-service.js.map +2 -2
  1153. package/dist/modules/messages/api/[id]/attachments/route.js +7 -3
  1154. package/dist/modules/messages/api/[id]/attachments/route.js.map +2 -2
  1155. package/dist/modules/messages/api/[id]/forward-preview/route.js +4 -3
  1156. package/dist/modules/messages/api/[id]/forward-preview/route.js.map +2 -2
  1157. package/dist/modules/messages/api/[id]/route.js +29 -3
  1158. package/dist/modules/messages/api/[id]/route.js.map +2 -2
  1159. package/dist/modules/messages/api/route.js +91 -2
  1160. package/dist/modules/messages/api/route.js.map +2 -2
  1161. package/dist/modules/messages/commands/messages.js +40 -6
  1162. package/dist/modules/messages/commands/messages.js.map +2 -2
  1163. package/dist/modules/messages/components/ComposeMessagePageClient.js +24 -1
  1164. package/dist/modules/messages/components/ComposeMessagePageClient.js.map +2 -2
  1165. package/dist/modules/messages/data/validators.js +11 -1
  1166. package/dist/modules/messages/data/validators.js.map +2 -2
  1167. package/dist/modules/messages/lib/channelThreadAccess.js +30 -0
  1168. package/dist/modules/messages/lib/channelThreadAccess.js.map +7 -0
  1169. package/dist/modules/messages/lib/composeSenderDelegation.js +87 -0
  1170. package/dist/modules/messages/lib/composeSenderDelegation.js.map +7 -0
  1171. package/dist/modules/messages/lib/composeSenderOptions.js +24 -0
  1172. package/dist/modules/messages/lib/composeSenderOptions.js.map +7 -0
  1173. package/dist/modules/messages/lib/email-sender.js +1 -11
  1174. package/dist/modules/messages/lib/email-sender.js.map +2 -2
  1175. package/dist/modules/messages/lib/forwarding.js +4 -4
  1176. package/dist/modules/messages/lib/forwarding.js.map +2 -2
  1177. package/dist/modules/messages/lib/markdownEmailBody.js +15 -0
  1178. package/dist/modules/messages/lib/markdownEmailBody.js.map +7 -0
  1179. package/dist/modules/messages/lib/messageSourceEntityTypes.js +7 -0
  1180. package/dist/modules/messages/lib/messageSourceEntityTypes.js.map +7 -0
  1181. package/dist/modules/messages/lib/routeHelpers.js +43 -0
  1182. package/dist/modules/messages/lib/routeHelpers.js.map +2 -2
  1183. package/dist/modules/messages/subscribers/message-notification.js +30 -1
  1184. package/dist/modules/messages/subscribers/message-notification.js.map +2 -2
  1185. package/dist/modules/notifications/api/[id]/action/route.js +2 -1
  1186. package/dist/modules/notifications/api/[id]/action/route.js.map +2 -2
  1187. package/dist/modules/notifications/api/openapi.js +2 -1
  1188. package/dist/modules/notifications/api/openapi.js.map +2 -2
  1189. package/dist/modules/notifications/frontend/NotificationSettingsPageClient.js +47 -28
  1190. package/dist/modules/notifications/frontend/NotificationSettingsPageClient.js.map +2 -2
  1191. package/dist/modules/notifications/lib/deliveryConfig.js +27 -2
  1192. package/dist/modules/notifications/lib/deliveryConfig.js.map +2 -2
  1193. package/dist/modules/notifications/lib/notificationMapper.js +3 -1
  1194. package/dist/modules/notifications/lib/notificationMapper.js.map +2 -2
  1195. package/dist/modules/notifications/lib/safeHref.js +4 -0
  1196. package/dist/modules/notifications/lib/safeHref.js.map +2 -2
  1197. package/dist/modules/planner/api/availability-date-specific.js +2 -1
  1198. package/dist/modules/planner/api/availability-date-specific.js.map +2 -2
  1199. package/dist/modules/planner/api/availability-weekly.js +2 -1
  1200. package/dist/modules/planner/api/availability-weekly.js.map +2 -2
  1201. package/dist/modules/progress/api/active/route.js +14 -2
  1202. package/dist/modules/progress/api/active/route.js.map +2 -2
  1203. package/dist/modules/progress/api/jobs/[id]/route.js +38 -22
  1204. package/dist/modules/progress/api/jobs/[id]/route.js.map +2 -2
  1205. package/dist/modules/progress/api/jobs/route.js +20 -6
  1206. package/dist/modules/progress/api/jobs/route.js.map +2 -2
  1207. package/dist/modules/progress/api/requestScope.js +32 -0
  1208. package/dist/modules/progress/api/requestScope.js.map +7 -0
  1209. package/dist/modules/progress/lib/organizationScope.js +10 -0
  1210. package/dist/modules/progress/lib/organizationScope.js.map +7 -0
  1211. package/dist/modules/progress/lib/progressService.js.map +2 -2
  1212. package/dist/modules/progress/lib/progressServiceImpl.js +48 -15
  1213. package/dist/modules/progress/lib/progressServiceImpl.js.map +2 -2
  1214. package/dist/modules/push_notifications/api/custom-send/route.js +4 -1
  1215. package/dist/modules/push_notifications/api/custom-send/route.js.map +2 -2
  1216. package/dist/modules/query_index/api/status.js +5 -3
  1217. package/dist/modules/query_index/api/status.js.map +2 -2
  1218. package/dist/modules/query_index/di.js +2 -1
  1219. package/dist/modules/query_index/di.js.map +2 -2
  1220. package/dist/modules/query_index/lib/engine.js +2 -1
  1221. package/dist/modules/query_index/lib/engine.js.map +2 -2
  1222. package/dist/modules/query_index/lib/request-encryption.js +16 -0
  1223. package/dist/modules/query_index/lib/request-encryption.js.map +7 -0
  1224. package/dist/modules/query_index/lib/search-tokens.js +31 -1
  1225. package/dist/modules/query_index/lib/search-tokens.js.map +2 -2
  1226. package/dist/modules/resources/api/resources/tags/assign/route.js +2 -1
  1227. package/dist/modules/resources/api/resources/tags/assign/route.js.map +2 -2
  1228. package/dist/modules/resources/api/resources/tags/unassign/route.js +2 -1
  1229. package/dist/modules/resources/api/resources/tags/unassign/route.js.map +2 -2
  1230. package/dist/modules/resources/commands/activities.js +2 -2
  1231. package/dist/modules/resources/commands/activities.js.map +2 -2
  1232. package/dist/modules/sales/api/document-history/route.js +5 -1
  1233. package/dist/modules/sales/api/document-history/route.js.map +2 -2
  1234. package/dist/modules/sales/api/document-numbers/route.js +2 -1
  1235. package/dist/modules/sales/api/document-numbers/route.js.map +2 -2
  1236. package/dist/modules/sales/api/quotes/convert/route.js +2 -1
  1237. package/dist/modules/sales/api/quotes/convert/route.js.map +2 -2
  1238. package/dist/modules/sales/api/quotes/send/route.js +2 -1
  1239. package/dist/modules/sales/api/quotes/send/route.js.map +2 -2
  1240. package/dist/modules/sales/api/settings/document-numbers/route.js +7 -1
  1241. package/dist/modules/sales/api/settings/document-numbers/route.js.map +2 -2
  1242. package/dist/modules/sales/api/settings/order-editing/route.js +7 -1
  1243. package/dist/modules/sales/api/settings/order-editing/route.js.map +2 -2
  1244. package/dist/modules/sales/commands/documents.js +354 -138
  1245. package/dist/modules/sales/commands/documents.js.map +3 -3
  1246. package/dist/modules/sales/commands/payments.js +2 -1
  1247. package/dist/modules/sales/commands/payments.js.map +2 -2
  1248. package/dist/modules/sales/commands/settings.js +25 -5
  1249. package/dist/modules/sales/commands/settings.js.map +2 -2
  1250. package/dist/modules/sales/commands/shipments.js +2 -1
  1251. package/dist/modules/sales/commands/shipments.js.map +2 -2
  1252. package/dist/modules/sales/components/DocumentNumberSettings.js +32 -21
  1253. package/dist/modules/sales/components/DocumentNumberSettings.js.map +2 -2
  1254. package/dist/modules/sales/components/documents/ItemsSection.js +49 -11
  1255. package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
  1256. package/dist/modules/sales/components/documents/LineItemDialog.js +159 -81
  1257. package/dist/modules/sales/components/documents/LineItemDialog.js.map +2 -2
  1258. package/dist/modules/sales/components/documents/lineItemUtils.js +7 -0
  1259. package/dist/modules/sales/components/documents/lineItemUtils.js.map +2 -2
  1260. package/dist/modules/sales/lib/lineSnapshots.js +19 -0
  1261. package/dist/modules/sales/lib/lineSnapshots.js.map +2 -2
  1262. package/dist/modules/sales/setup.js +4 -4
  1263. package/dist/modules/sales/setup.js.map +2 -2
  1264. package/dist/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.js +2 -2
  1265. package/dist/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.js.map +2 -2
  1266. package/dist/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.js +2 -2
  1267. package/dist/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.js.map +2 -2
  1268. package/dist/modules/staff/api/leave-requests/accept/route.js +2 -1
  1269. package/dist/modules/staff/api/leave-requests/accept/route.js.map +2 -2
  1270. package/dist/modules/staff/api/leave-requests/reject/route.js +2 -1
  1271. package/dist/modules/staff/api/leave-requests/reject/route.js.map +2 -2
  1272. package/dist/modules/staff/api/leave-requests.js +2 -1
  1273. package/dist/modules/staff/api/leave-requests.js.map +2 -2
  1274. package/dist/modules/staff/api/team-members/self/route.js +2 -1
  1275. package/dist/modules/staff/api/team-members/self/route.js.map +2 -2
  1276. package/dist/modules/staff/api/team-members/tags/assign/route.js +2 -1
  1277. package/dist/modules/staff/api/team-members/tags/assign/route.js.map +2 -2
  1278. package/dist/modules/staff/api/team-members/tags/unassign/route.js +2 -1
  1279. package/dist/modules/staff/api/team-members/tags/unassign/route.js.map +2 -2
  1280. package/dist/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.js +12 -11
  1281. package/dist/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.js.map +2 -2
  1282. package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js +2 -1
  1283. package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js.map +2 -2
  1284. package/dist/modules/staff/api/timesheets/my-projects/route.js +2 -1
  1285. package/dist/modules/staff/api/timesheets/my-projects/route.js.map +2 -2
  1286. package/dist/modules/staff/api/timesheets/my-work/route.js +2 -1
  1287. package/dist/modules/staff/api/timesheets/my-work/route.js.map +2 -2
  1288. package/dist/modules/staff/api/timesheets/projects/kpis/route.js +2 -1
  1289. package/dist/modules/staff/api/timesheets/projects/kpis/route.js.map +2 -2
  1290. package/dist/modules/staff/api/timesheets/reports/[id]/close/route.js +2 -1
  1291. package/dist/modules/staff/api/timesheets/reports/[id]/close/route.js.map +2 -2
  1292. package/dist/modules/staff/api/timesheets/reports/[id]/export/route.js +3 -2
  1293. package/dist/modules/staff/api/timesheets/reports/[id]/export/route.js.map +2 -2
  1294. package/dist/modules/staff/api/timesheets/reports/[id]/sheet/route.js +3 -2
  1295. package/dist/modules/staff/api/timesheets/reports/[id]/sheet/route.js.map +2 -2
  1296. package/dist/modules/staff/api/timesheets/reports/[id]/unlock/route.js +3 -2
  1297. package/dist/modules/staff/api/timesheets/reports/[id]/unlock/route.js.map +2 -2
  1298. package/dist/modules/staff/api/timesheets/reports/preview/route.js +2 -1
  1299. package/dist/modules/staff/api/timesheets/reports/preview/route.js.map +2 -2
  1300. package/dist/modules/staff/api/timesheets/reports/shared.js +2 -1
  1301. package/dist/modules/staff/api/timesheets/reports/shared.js.map +2 -2
  1302. package/dist/modules/staff/api/timesheets/settings/reapply-rounding/route.js +2 -1
  1303. package/dist/modules/staff/api/timesheets/settings/reapply-rounding/route.js.map +2 -2
  1304. package/dist/modules/staff/api/timesheets/tags/entry-assignments/route.js +2 -1
  1305. package/dist/modules/staff/api/timesheets/tags/entry-assignments/route.js.map +2 -2
  1306. package/dist/modules/staff/api/timesheets/tags/task-assignments/route.js +2 -1
  1307. package/dist/modules/staff/api/timesheets/tags/task-assignments/route.js.map +2 -2
  1308. package/dist/modules/staff/api/timesheets/tasks/[id]/comments/route.js +2 -1
  1309. package/dist/modules/staff/api/timesheets/tasks/[id]/comments/route.js.map +2 -2
  1310. package/dist/modules/staff/api/timesheets/tasks/[id]/status/route.js +2 -1
  1311. package/dist/modules/staff/api/timesheets/tasks/[id]/status/route.js.map +2 -2
  1312. package/dist/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.js +3 -2
  1313. package/dist/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.js.map +2 -2
  1314. package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js +2 -1
  1315. package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js.map +2 -2
  1316. package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js +2 -1
  1317. package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js.map +2 -2
  1318. package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js +2 -1
  1319. package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js.map +2 -2
  1320. package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js +2 -1
  1321. package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js.map +2 -2
  1322. package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js +2 -1
  1323. package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js.map +2 -2
  1324. package/dist/modules/staff/api/timesheets/time-entries/copy-day/route.js +3 -2
  1325. package/dist/modules/staff/api/timesheets/time-entries/copy-day/route.js.map +2 -2
  1326. package/dist/modules/staff/api/timesheets/time-entries/overlaps/route.js +2 -1
  1327. package/dist/modules/staff/api/timesheets/time-entries/overlaps/route.js.map +2 -2
  1328. package/dist/modules/staff/api/timesheets/time-entries/start-timer/route.js +3 -2
  1329. package/dist/modules/staff/api/timesheets/time-entries/start-timer/route.js.map +2 -2
  1330. package/dist/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.js +3 -2
  1331. package/dist/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.js.map +2 -2
  1332. package/dist/modules/staff/api/timesheets/time-projects/route.js +2 -1
  1333. package/dist/modules/staff/api/timesheets/time-projects/route.js.map +2 -2
  1334. package/dist/modules/staff/commands/activities.js +2 -2
  1335. package/dist/modules/staff/commands/activities.js.map +2 -2
  1336. package/dist/modules/staff/commands/timesheets-entries.js.map +2 -2
  1337. package/dist/modules/staff/commands/timesheets-reports.js +55 -14
  1338. package/dist/modules/staff/commands/timesheets-reports.js.map +2 -2
  1339. package/dist/modules/staff/lib/timesheets-reports/buildReportSheet.js +2 -1
  1340. package/dist/modules/staff/lib/timesheets-reports/buildReportSheet.js.map +2 -2
  1341. package/dist/modules/staff/lib/timesheets-reports/loadReportData.js +32 -3
  1342. package/dist/modules/staff/lib/timesheets-reports/loadReportData.js.map +2 -2
  1343. package/dist/modules/staff/lib/timesheets-reports/reportPeriod.js +16 -0
  1344. package/dist/modules/staff/lib/timesheets-reports/reportPeriod.js.map +7 -0
  1345. package/dist/modules/staff/lib/timesheets-ui/CalendarPicker.js +15 -10
  1346. package/dist/modules/staff/lib/timesheets-ui/CalendarPicker.js.map +2 -2
  1347. package/dist/modules/sync_excel/api/import/route.js +35 -12
  1348. package/dist/modules/sync_excel/api/import/route.js.map +2 -2
  1349. package/dist/modules/sync_excel/api/upload/route.js +29 -4
  1350. package/dist/modules/sync_excel/api/upload/route.js.map +2 -2
  1351. package/dist/modules/translations/api/context.js +2 -1
  1352. package/dist/modules/translations/api/context.js.map +2 -2
  1353. package/dist/modules/warranty_claims/api/ai/assess/route.js +2 -1
  1354. package/dist/modules/warranty_claims/api/ai/assess/route.js.map +2 -2
  1355. package/dist/modules/warranty_claims/api/ai/draft-reply/route.js +2 -1
  1356. package/dist/modules/warranty_claims/api/ai/draft-reply/route.js.map +2 -2
  1357. package/dist/modules/warranty_claims/api/ai/suggest/route.js +2 -1
  1358. package/dist/modules/warranty_claims/api/ai/suggest/route.js.map +2 -2
  1359. package/dist/modules/warranty_claims/api/assign/route.js +2 -1
  1360. package/dist/modules/warranty_claims/api/assign/route.js.map +2 -2
  1361. package/dist/modules/warranty_claims/api/credit-memo/route.js +2 -1
  1362. package/dist/modules/warranty_claims/api/credit-memo/route.js.map +2 -2
  1363. package/dist/modules/warranty_claims/api/entitlement/route.js +2 -1
  1364. package/dist/modules/warranty_claims/api/entitlement/route.js.map +2 -2
  1365. package/dist/modules/warranty_claims/api/events/route.js +2 -1
  1366. package/dist/modules/warranty_claims/api/events/route.js.map +2 -2
  1367. package/dist/modules/warranty_claims/api/external/claims/route.js +2 -1
  1368. package/dist/modules/warranty_claims/api/external/claims/route.js.map +2 -2
  1369. package/dist/modules/warranty_claims/api/receiving/route.js +2 -1
  1370. package/dist/modules/warranty_claims/api/receiving/route.js.map +2 -2
  1371. package/dist/modules/warranty_claims/api/replacement-order/route.js +2 -1
  1372. package/dist/modules/warranty_claims/api/replacement-order/route.js.map +2 -2
  1373. package/dist/modules/warranty_claims/api/return-label/route.js +2 -1
  1374. package/dist/modules/warranty_claims/api/return-label/route.js.map +2 -2
  1375. package/dist/modules/warranty_claims/api/risk/route.js +2 -1
  1376. package/dist/modules/warranty_claims/api/risk/route.js.map +2 -2
  1377. package/dist/modules/warranty_claims/api/sales-return/route.js +2 -1
  1378. package/dist/modules/warranty_claims/api/sales-return/route.js.map +2 -2
  1379. package/dist/modules/warranty_claims/api/settings-general/route.js +2 -1
  1380. package/dist/modules/warranty_claims/api/settings-general/route.js.map +2 -2
  1381. package/dist/modules/warranty_claims/api/stats/route.js +9 -5
  1382. package/dist/modules/warranty_claims/api/stats/route.js.map +2 -2
  1383. package/dist/modules/warranty_claims/api/submit/route.js +2 -1
  1384. package/dist/modules/warranty_claims/api/submit/route.js.map +2 -2
  1385. package/dist/modules/warranty_claims/api/transition/route.js +2 -1
  1386. package/dist/modules/warranty_claims/api/transition/route.js.map +2 -2
  1387. package/dist/modules/warranty_claims/api/vendor-recovery/route.js +2 -1
  1388. package/dist/modules/warranty_claims/api/vendor-recovery/route.js.map +2 -2
  1389. package/dist/modules/warranty_claims/api/vendor-recovery-suggestions/route.js +2 -1
  1390. package/dist/modules/warranty_claims/api/vendor-recovery-suggestions/route.js.map +2 -2
  1391. package/dist/modules/warranty_claims/widgets/notifications/WarrantyClaimNotificationRenderer.js +1 -1
  1392. package/dist/modules/warranty_claims/widgets/notifications/WarrantyClaimNotificationRenderer.js.map +2 -2
  1393. package/dist/modules/wms/api/dashboard/operational/route.js +2 -1
  1394. package/dist/modules/wms/api/dashboard/operational/route.js.map +2 -2
  1395. package/dist/modules/wms/api/inventory/cycle-count/route.js +1 -0
  1396. package/dist/modules/wms/api/inventory/cycle-count/route.js.map +2 -2
  1397. package/dist/modules/wms/api/inventory/helpers.js +2 -1
  1398. package/dist/modules/wms/api/inventory/helpers.js.map +2 -2
  1399. package/dist/modules/wms/api/inventory/import/helpers.js +2 -1
  1400. package/dist/modules/wms/api/inventory/import/helpers.js.map +2 -2
  1401. package/dist/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.js +2 -1
  1402. package/dist/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.js.map +2 -2
  1403. package/dist/modules/wms/commands/inventory-actions.js +39 -1
  1404. package/dist/modules/wms/commands/inventory-actions.js.map +2 -2
  1405. package/dist/modules/wms/components/backend/CycleCountWizardDialog.js +14 -1
  1406. package/dist/modules/wms/components/backend/CycleCountWizardDialog.js.map +2 -2
  1407. package/dist/modules/wms/di.js +5 -0
  1408. package/dist/modules/wms/di.js.map +2 -2
  1409. package/dist/modules/wms/lib/availabilityCache.js +86 -0
  1410. package/dist/modules/wms/lib/availabilityCache.js.map +7 -0
  1411. package/dist/modules/wms/lib/availabilityCalculation.js +212 -0
  1412. package/dist/modules/wms/lib/availabilityCalculation.js.map +7 -0
  1413. package/dist/modules/wms/lib/availabilityProvider.js +24 -0
  1414. package/dist/modules/wms/lib/availabilityProvider.js.map +7 -0
  1415. package/dist/modules/wms/lib/loadOperationalDashboard.js +42 -5
  1416. package/dist/modules/wms/lib/loadOperationalDashboard.js.map +2 -2
  1417. package/dist/modules/wms/lib/lowStockBalanceFilter.js +23 -10
  1418. package/dist/modules/wms/lib/lowStockBalanceFilter.js.map +2 -2
  1419. package/dist/modules/wms/lib/sqlInClause.js +9 -0
  1420. package/dist/modules/wms/lib/sqlInClause.js.map +7 -0
  1421. package/dist/modules/wms/lib/tryResolve.js +11 -0
  1422. package/dist/modules/wms/lib/tryResolve.js.map +7 -0
  1423. package/dist/modules/wms/subscribers/invalidate-availability-cache-policy.js +14 -0
  1424. package/dist/modules/wms/subscribers/invalidate-availability-cache-policy.js.map +7 -0
  1425. package/dist/modules/wms/subscribers/invalidate-availability-cache-profile.js +14 -0
  1426. package/dist/modules/wms/subscribers/invalidate-availability-cache-profile.js.map +7 -0
  1427. package/dist/modules/wms/subscribers/invalidate-availability-cache.js +16 -0
  1428. package/dist/modules/wms/subscribers/invalidate-availability-cache.js.map +7 -0
  1429. package/dist/modules/wms/widgets/notifications/WmsLowStockRenderer.js +2 -2
  1430. package/dist/modules/wms/widgets/notifications/WmsLowStockRenderer.js.map +2 -2
  1431. package/dist/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.js +4 -3
  1432. package/dist/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.js.map +2 -2
  1433. package/dist/modules/workflows/api/commands/route.js +4 -1
  1434. package/dist/modules/workflows/api/commands/route.js.map +2 -2
  1435. package/dist/modules/workflows/api/definitions/[id]/callers/route.js +4 -1
  1436. package/dist/modules/workflows/api/definitions/[id]/callers/route.js.map +2 -2
  1437. package/dist/modules/workflows/api/definitions/[id]/context-schema/route.js +4 -2
  1438. package/dist/modules/workflows/api/definitions/[id]/context-schema/route.js.map +2 -2
  1439. package/dist/modules/workflows/api/definitions/[id]/customize/route.js +4 -1
  1440. package/dist/modules/workflows/api/definitions/[id]/customize/route.js.map +2 -2
  1441. package/dist/modules/workflows/api/definitions/[id]/draft/route.js +6 -1
  1442. package/dist/modules/workflows/api/definitions/[id]/draft/route.js.map +2 -2
  1443. package/dist/modules/workflows/api/definitions/[id]/publish/route.js +6 -1
  1444. package/dist/modules/workflows/api/definitions/[id]/publish/route.js.map +2 -2
  1445. package/dist/modules/workflows/api/definitions/[id]/reset-to-code/route.js +4 -1
  1446. package/dist/modules/workflows/api/definitions/[id]/reset-to-code/route.js.map +2 -2
  1447. package/dist/modules/workflows/api/definitions/[id]/route.js +5 -3
  1448. package/dist/modules/workflows/api/definitions/[id]/route.js.map +2 -2
  1449. package/dist/modules/workflows/api/definitions/[id]/test-step/route.js +4 -2
  1450. package/dist/modules/workflows/api/definitions/[id]/test-step/route.js.map +2 -2
  1451. package/dist/modules/workflows/api/definitions/generate/route.js +4 -1
  1452. package/dist/modules/workflows/api/definitions/generate/route.js.map +2 -2
  1453. package/dist/modules/workflows/api/definitions/route.js +4 -2
  1454. package/dist/modules/workflows/api/definitions/route.js.map +2 -2
  1455. package/dist/modules/workflows/api/endpoints/route.js +4 -1
  1456. package/dist/modules/workflows/api/endpoints/route.js.map +2 -2
  1457. package/dist/modules/workflows/api/functions/route.js +4 -1
  1458. package/dist/modules/workflows/api/functions/route.js.map +2 -2
  1459. package/dist/modules/workflows/api/grantable-features/route.js +2 -1
  1460. package/dist/modules/workflows/api/grantable-features/route.js.map +2 -2
  1461. package/dist/modules/workflows/api/instances/[id]/advance/route.js +4 -1
  1462. package/dist/modules/workflows/api/instances/[id]/advance/route.js.map +2 -2
  1463. package/dist/modules/workflows/api/instances/[id]/cancel/route.js +4 -1
  1464. package/dist/modules/workflows/api/instances/[id]/cancel/route.js.map +2 -2
  1465. package/dist/modules/workflows/api/instances/[id]/context/route.js +2 -1
  1466. package/dist/modules/workflows/api/instances/[id]/context/route.js.map +2 -2
  1467. package/dist/modules/workflows/api/instances/[id]/rerun-step/route.js +4 -1
  1468. package/dist/modules/workflows/api/instances/[id]/rerun-step/route.js.map +2 -2
  1469. package/dist/modules/workflows/api/instances/[id]/retry/route.js +4 -1
  1470. package/dist/modules/workflows/api/instances/[id]/retry/route.js.map +2 -2
  1471. package/dist/modules/workflows/api/instances/[id]/signal/route.js +4 -1
  1472. package/dist/modules/workflows/api/instances/[id]/signal/route.js.map +2 -2
  1473. package/dist/modules/workflows/api/instances/[id]/step-through/route.js +4 -2
  1474. package/dist/modules/workflows/api/instances/[id]/step-through/route.js.map +2 -2
  1475. package/dist/modules/workflows/api/instances/route.js +4 -2
  1476. package/dist/modules/workflows/api/instances/route.js.map +2 -2
  1477. package/dist/modules/workflows/api/instances/validate-start/route.js +4 -1
  1478. package/dist/modules/workflows/api/instances/validate-start/route.js.map +2 -2
  1479. package/dist/modules/workflows/api/rule-usage/route.js +4 -1
  1480. package/dist/modules/workflows/api/rule-usage/route.js.map +2 -2
  1481. package/dist/modules/workflows/api/signals/route.js +4 -1
  1482. package/dist/modules/workflows/api/signals/route.js.map +2 -2
  1483. package/dist/modules/workflows/api/tasks/[id]/claim/route.js +4 -1
  1484. package/dist/modules/workflows/api/tasks/[id]/claim/route.js.map +2 -2
  1485. package/dist/modules/workflows/api/tasks/[id]/complete/route.js +4 -1
  1486. package/dist/modules/workflows/api/tasks/[id]/complete/route.js.map +2 -2
  1487. package/dist/modules/workflows/api/tasks/[id]/reassign/route.js +2 -1
  1488. package/dist/modules/workflows/api/tasks/[id]/reassign/route.js.map +2 -2
  1489. package/dist/modules/workflows/api/tasks/[id]/unclaim/route.js +4 -1
  1490. package/dist/modules/workflows/api/tasks/[id]/unclaim/route.js.map +2 -2
  1491. package/dist/modules/workflows/api/templates/route.js +4 -1
  1492. package/dist/modules/workflows/api/templates/route.js.map +2 -2
  1493. package/dist/modules/workflows/api/work-inbox/next/route.js +4 -1
  1494. package/dist/modules/workflows/api/work-inbox/next/route.js.map +2 -2
  1495. package/dist/modules/workflows/lib/activity-executor.js +87 -20
  1496. package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
  1497. package/dist/modules/workflows/lib/activity-types.js +4 -4
  1498. package/dist/modules/workflows/lib/activity-types.js.map +2 -2
  1499. package/dist/modules/workflows/lib/activity-worker-handler.js +16 -11
  1500. package/dist/modules/workflows/lib/activity-worker-handler.js.map +2 -2
  1501. package/dist/modules/workflows/lib/event-trigger-service.js +8 -1
  1502. package/dist/modules/workflows/lib/event-trigger-service.js.map +2 -2
  1503. package/dist/modules/workflows/lib/step-handler.js +4 -4
  1504. package/dist/modules/workflows/lib/step-handler.js.map +2 -2
  1505. package/dist/test-utils/transactionalEntityManagerDouble.js +37 -0
  1506. package/dist/test-utils/transactionalEntityManagerDouble.js.map +7 -0
  1507. package/generated/entities/availability_policy/index.ts +19 -0
  1508. package/generated/entities/communication_channel/index.ts +1 -0
  1509. package/generated/entities/customer_email_conversation_share/index.ts +9 -0
  1510. package/generated/entities/customer_group/index.ts +15 -0
  1511. package/generated/entities/customer_group_membership/index.ts +13 -0
  1512. package/generated/entities/customer_group_terms/index.ts +15 -0
  1513. package/generated/entities/customer_interaction/index.ts +1 -0
  1514. package/generated/entities/form/index.ts +16 -0
  1515. package/generated/entities/form_access_audit/index.ts +9 -0
  1516. package/generated/entities/form_attachment/index.ts +13 -0
  1517. package/generated/entities/form_consent_record/index.ts +17 -0
  1518. package/generated/entities/form_distribution/index.ts +22 -0
  1519. package/generated/entities/form_invitation/index.ts +23 -0
  1520. package/generated/entities/form_submission/index.ts +18 -0
  1521. package/generated/entities/form_submission_actor/index.ts +10 -0
  1522. package/generated/entities/form_submission_revision/index.ts +13 -0
  1523. package/generated/entities/form_version/index.ts +17 -0
  1524. package/generated/entities/forms_encryption_key/index.ts +6 -0
  1525. package/generated/entities.ids.generated.ts +27 -2
  1526. package/generated/entity-fields-registry.ts +269 -0
  1527. package/package.json +18 -7
  1528. package/src/helpers/integration/communicationChannelsFixtures.ts +43 -0
  1529. package/src/helpers/integration/customerGroupsFixtures.ts +171 -0
  1530. package/src/helpers/integration/formsFixtures.ts +757 -0
  1531. package/src/modules/api_docs/api/get/version.ts +28 -11
  1532. package/src/modules/api_keys/api/keys/route.ts +89 -199
  1533. package/src/modules/api_keys/backend/api-keys/create/page.tsx +2 -2
  1534. package/src/modules/api_keys/commands/keys.ts +172 -0
  1535. package/src/modules/api_keys/i18n/de.json +1 -0
  1536. package/src/modules/api_keys/i18n/en.json +1 -0
  1537. package/src/modules/api_keys/i18n/es.json +1 -0
  1538. package/src/modules/api_keys/i18n/ko.json +1 -0
  1539. package/src/modules/api_keys/i18n/pl.json +1 -0
  1540. package/src/modules/api_keys/services/apiKeyService.ts +82 -49
  1541. package/src/modules/attachments/api/file/[id]/route.ts +9 -4
  1542. package/src/modules/attachments/api/image/[id]/[[...slug]]/route.ts +6 -4
  1543. package/src/modules/attachments/api/route.ts +10 -4
  1544. package/src/modules/attachments/components/AttachmentLibrary.tsx +16 -5
  1545. package/src/modules/attachments/lib/access.ts +1 -3
  1546. package/src/modules/attachments/lib/requestScope.ts +35 -3
  1547. package/src/modules/audit_logs/api/audit-logs/actions/export/route.ts +6 -1
  1548. package/src/modules/audit_logs/api/audit-logs/actions/redo/route.ts +41 -6
  1549. package/src/modules/audit_logs/api/audit-logs/actions/route.ts +6 -1
  1550. package/src/modules/audit_logs/api/audit-logs/actions/undo/route.ts +39 -4
  1551. package/src/modules/audit_logs/data/validators.ts +1 -0
  1552. package/src/modules/audit_logs/lib/actorSubject.ts +82 -0
  1553. package/src/modules/audit_logs/lib/replayAuthorization.ts +61 -0
  1554. package/src/modules/audit_logs/services/actionLogService.ts +191 -47
  1555. package/src/modules/auth/api/features.ts +1 -1
  1556. package/src/modules/auth/cli.ts +31 -17
  1557. package/src/modules/auth/commands/acl.ts +26 -36
  1558. package/src/modules/auth/commands/interceptors.ts +23 -0
  1559. package/src/modules/auth/commands/roles.ts +475 -148
  1560. package/src/modules/auth/commands/users.ts +693 -81
  1561. package/src/modules/auth/i18n/de.json +22 -0
  1562. package/src/modules/auth/i18n/en.json +22 -0
  1563. package/src/modules/auth/i18n/es.json +22 -0
  1564. package/src/modules/auth/i18n/ko.json +22 -0
  1565. package/src/modules/auth/i18n/pl.json +22 -0
  1566. package/src/modules/auth/lib/authorizationStateLocks.ts +340 -0
  1567. package/src/modules/auth/lib/commandReplay.ts +194 -0
  1568. package/src/modules/auth/lib/executionPrincipal.ts +36 -28
  1569. package/src/modules/auth/lib/grantChecks.ts +10 -2
  1570. package/src/modules/auth/lib/setup-app.ts +97 -50
  1571. package/src/modules/auth/lib/tokenHash.ts +16 -1
  1572. package/src/modules/auth/services/rbacService.ts +578 -6
  1573. package/src/modules/availability/acl.ts +12 -0
  1574. package/src/modules/availability/api/check/route.ts +136 -0
  1575. package/src/modules/availability/api/openapi.ts +28 -0
  1576. package/src/modules/availability/api/policies/resolve-preview/route.ts +83 -0
  1577. package/src/modules/availability/api/policies/route.ts +244 -0
  1578. package/src/modules/availability/backend/availability/check/page.meta.ts +12 -0
  1579. package/src/modules/availability/backend/availability/check/page.tsx +223 -0
  1580. package/src/modules/availability/backend/availability/policies/ResolutionPreviewPanel.tsx +112 -0
  1581. package/src/modules/availability/backend/availability/policies/ScopeFields.tsx +55 -0
  1582. package/src/modules/availability/backend/availability/policies/StockManagedField.tsx +37 -0
  1583. package/src/modules/availability/backend/availability/policies/[id]/page.meta.ts +8 -0
  1584. package/src/modules/availability/backend/availability/policies/[id]/page.tsx +202 -0
  1585. package/src/modules/availability/backend/availability/policies/create/page.meta.ts +8 -0
  1586. package/src/modules/availability/backend/availability/policies/create/page.tsx +131 -0
  1587. package/src/modules/availability/backend/availability/policies/formGroups.ts +83 -0
  1588. package/src/modules/availability/backend/availability/policies/page.meta.ts +12 -0
  1589. package/src/modules/availability/backend/availability/policies/page.tsx +232 -0
  1590. package/src/modules/availability/backend/availability/policies/policyPayload.ts +29 -0
  1591. package/src/modules/availability/commands/policies.ts +430 -0
  1592. package/src/modules/availability/commands/scope.ts +26 -0
  1593. package/src/modules/availability/data/entities.ts +93 -0
  1594. package/src/modules/availability/data/validators.ts +87 -0
  1595. package/src/modules/availability/di.ts +68 -0
  1596. package/src/modules/availability/events.ts +17 -0
  1597. package/src/modules/availability/i18n/de.json +92 -0
  1598. package/src/modules/availability/i18n/en.json +92 -0
  1599. package/src/modules/availability/i18n/es.json +92 -0
  1600. package/src/modules/availability/i18n/ko.json +92 -0
  1601. package/src/modules/availability/i18n/pl.json +92 -0
  1602. package/src/modules/availability/index.ts +13 -0
  1603. package/src/modules/availability/lib/catalogTarget.ts +72 -0
  1604. package/src/modules/availability/lib/organizationScope.ts +18 -0
  1605. package/src/modules/availability/lib/policyResolution.ts +289 -0
  1606. package/src/modules/availability/lib/tryResolve.ts +8 -0
  1607. package/src/modules/availability/migrations/.snapshot-open-mercato.json +375 -0
  1608. package/src/modules/availability/migrations/Migration20260922095844_availability.ts +13 -0
  1609. package/src/modules/availability/migrations/Migration20260930120000_availability.ts +22 -0
  1610. package/src/modules/availability/setup.ts +10 -0
  1611. package/src/modules/catalog/api/categories/bulk-create/route.ts +119 -0
  1612. package/src/modules/catalog/api/categories/route.ts +70 -8
  1613. package/src/modules/catalog/api/products/bulk-create/route.ts +119 -0
  1614. package/src/modules/catalog/api/products/route.ts +55 -24
  1615. package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +8 -16
  1616. package/src/modules/catalog/backend/catalog/products/create/page.tsx +16 -10
  1617. package/src/modules/catalog/commands/categories.ts +1 -0
  1618. package/src/modules/catalog/commands/productDeleteChildren.ts +557 -0
  1619. package/src/modules/catalog/commands/products.ts +69 -24
  1620. package/src/modules/catalog/components/PriceKindSettings.tsx +6 -20
  1621. package/src/modules/catalog/components/products/ProductUomSection.tsx +26 -37
  1622. package/src/modules/catalog/components/products/productForm.ts +6 -4
  1623. package/src/modules/catalog/data/validators.ts +22 -0
  1624. package/src/modules/catalog/di.ts +2 -1
  1625. package/src/modules/catalog/events.ts +9 -3
  1626. package/src/modules/catalog/i18n/de.json +40 -0
  1627. package/src/modules/catalog/i18n/en.json +40 -0
  1628. package/src/modules/catalog/i18n/es.json +40 -0
  1629. package/src/modules/catalog/i18n/ko.json +40 -0
  1630. package/src/modules/catalog/i18n/pl.json +40 -0
  1631. package/src/modules/catalog/lib/bulkCreateCategories.ts +349 -0
  1632. package/src/modules/catalog/lib/bulkCreateCheckpoint.ts +176 -0
  1633. package/src/modules/catalog/lib/bulkCreateMutationGuards.ts +62 -0
  1634. package/src/modules/catalog/lib/bulkCreateProducts.ts +340 -0
  1635. package/src/modules/catalog/lib/bulkDelete.ts +10 -14
  1636. package/src/modules/catalog/lib/catalogQueue.ts +14 -0
  1637. package/src/modules/catalog/lib/currencyOptions.ts +28 -0
  1638. package/src/modules/catalog/lib/productSearch.ts +16 -0
  1639. package/src/modules/catalog/lib/seeds.ts +2 -43
  1640. package/src/modules/catalog/lib/unitLabels.ts +52 -0
  1641. package/src/modules/catalog/migrations/Migration20260914120000.ts +51 -0
  1642. package/src/modules/catalog/migrations/Migration20260914120100.ts +50 -0
  1643. package/src/modules/catalog/workers/catalog-category-bulk-create.ts +48 -0
  1644. package/src/modules/catalog/workers/catalog-product-bulk-create.ts +48 -0
  1645. package/src/modules/communication_channels/acl.ts +8 -0
  1646. package/src/modules/communication_channels/api/get/me/channels/route.ts +4 -0
  1647. package/src/modules/communication_channels/api/get/oauth/[provider]/callback/route.ts +23 -0
  1648. package/src/modules/communication_channels/api/post/channels/[id]/import-history/route.ts +3 -4
  1649. package/src/modules/communication_channels/api/post/channels/[id]/test-send/route.ts +9 -1
  1650. package/src/modules/communication_channels/api/post/channels/connect/credentials/route.ts +4 -6
  1651. package/src/modules/communication_channels/api/post/channels/connect/tenant-credentials/route.ts +4 -6
  1652. package/src/modules/communication_channels/api/post/test-seed/route.ts +109 -24
  1653. package/src/modules/communication_channels/api/put/channels/[id]/visibility/route.ts +165 -0
  1654. package/src/modules/communication_channels/backend/profile/communication-channels/page.tsx +247 -129
  1655. package/src/modules/communication_channels/commands/ingest-inbound-message.ts +2 -1
  1656. package/src/modules/communication_channels/commands/set-channel-visibility.ts +138 -0
  1657. package/src/modules/communication_channels/data/enrichers.ts +42 -19
  1658. package/src/modules/communication_channels/data/entities.ts +21 -0
  1659. package/src/modules/communication_channels/di.ts +9 -0
  1660. package/src/modules/communication_channels/events.ts +7 -0
  1661. package/src/modules/communication_channels/i18n/de.json +16 -3
  1662. package/src/modules/communication_channels/i18n/en.json +16 -3
  1663. package/src/modules/communication_channels/i18n/es.json +16 -3
  1664. package/src/modules/communication_channels/i18n/ko.json +16 -3
  1665. package/src/modules/communication_channels/i18n/pl.json +16 -3
  1666. package/src/modules/communication_channels/index.ts +1 -1
  1667. package/src/modules/communication_channels/lib/access-control.ts +4 -1
  1668. package/src/modules/communication_channels/lib/adapter.ts +16 -6
  1669. package/src/modules/communication_channels/lib/channel-thread-access.ts +133 -0
  1670. package/src/modules/communication_channels/lib/credential-refresh.ts +27 -5
  1671. package/src/modules/communication_channels/lib/inbound-message-origin.ts +62 -0
  1672. package/src/modules/communication_channels/lib/oauth-state.ts +96 -1
  1673. package/src/modules/communication_channels/lib/outbound-delivery-intent.ts +57 -0
  1674. package/src/modules/communication_channels/lib/send-as-user.ts +2 -2
  1675. package/src/modules/communication_channels/migrations/.snapshot-open-mercato.json +18 -1
  1676. package/src/modules/communication_channels/migrations/Migration20260825141000_communication_channels.ts +22 -0
  1677. package/src/modules/communication_channels/setup.ts +4 -0
  1678. package/src/modules/communication_channels/subscribers/outbound-bridge.ts +34 -9
  1679. package/src/modules/communication_channels/workers/gmail-history-sync.ts +1 -1
  1680. package/src/modules/communication_channels/workers/poll-channel.ts +1 -1
  1681. package/src/modules/communication_channels/workers/reaction-processor.ts +2 -2
  1682. package/src/modules/configs/api/upgrade-actions/route.ts +2 -1
  1683. package/src/modules/configs/cli.ts +2 -2
  1684. package/src/modules/configs/i18n/de.json +2 -0
  1685. package/src/modules/configs/i18n/en.json +2 -0
  1686. package/src/modules/configs/i18n/es.json +2 -0
  1687. package/src/modules/configs/i18n/ko.json +2 -0
  1688. package/src/modules/configs/i18n/pl.json +2 -0
  1689. package/src/modules/configs/lib/upgrade-actions.ts +29 -6
  1690. package/src/modules/configs/services/upgradeActionsService.ts +45 -30
  1691. package/src/modules/currencies/api/currencies/route.ts +11 -5
  1692. package/src/modules/currencies/api/exchange-rates/route.ts +11 -5
  1693. package/src/modules/customer_groups/acl.ts +10 -0
  1694. package/src/modules/customer_groups/api/customer-groups/[id]/terms/route.ts +355 -0
  1695. package/src/modules/customer_groups/api/customer-groups/crud.ts +627 -0
  1696. package/src/modules/customer_groups/api/customer-groups/explain-terms/route.ts +195 -0
  1697. package/src/modules/customer_groups/api/customer-groups/memberships/crud.ts +525 -0
  1698. package/src/modules/customer_groups/api/customer-groups/memberships/route.ts +65 -0
  1699. package/src/modules/customer_groups/api/customer-groups/reconcile/adopt/route.ts +150 -0
  1700. package/src/modules/customer_groups/api/customer-groups/reconcile/route.ts +90 -0
  1701. package/src/modules/customer_groups/api/customer-groups/reorder/route.ts +147 -0
  1702. package/src/modules/customer_groups/api/customer-groups/route.ts +65 -0
  1703. package/src/modules/customer_groups/api/openapi.ts +28 -0
  1704. package/src/modules/customer_groups/backend/customer-groups/[id]/edit/page.meta.ts +12 -0
  1705. package/src/modules/customer_groups/backend/customer-groups/[id]/edit/page.tsx +392 -0
  1706. package/src/modules/customer_groups/backend/customer-groups/create/page.meta.ts +25 -0
  1707. package/src/modules/customer_groups/backend/customer-groups/create/page.tsx +279 -0
  1708. package/src/modules/customer_groups/backend/customer-groups/orphans/page.meta.ts +12 -0
  1709. package/src/modules/customer_groups/backend/customer-groups/orphans/page.tsx +216 -0
  1710. package/src/modules/customer_groups/backend/customer-groups/page.meta.ts +11 -0
  1711. package/src/modules/customer_groups/backend/customer-groups/page.tsx +478 -0
  1712. package/src/modules/customer_groups/cli.ts +87 -0
  1713. package/src/modules/customer_groups/commands/reorderGroups.ts +163 -0
  1714. package/src/modules/customer_groups/components/CustomerGroupDefaultField.tsx +55 -0
  1715. package/src/modules/customer_groups/components/CustomerGroupParentField.tsx +194 -0
  1716. package/src/modules/customer_groups/components/CustomerGroupTermsPriceKindField.tsx +111 -0
  1717. package/src/modules/customer_groups/components/CustomerGroupTermsSection.tsx +273 -0
  1718. package/src/modules/customer_groups/components/GroupPickerField.tsx +142 -0
  1719. package/src/modules/customer_groups/components/OrphanBanner.tsx +92 -0
  1720. package/src/modules/customer_groups/components/customerGroupTree.ts +84 -0
  1721. package/src/modules/customer_groups/data/entities.ts +244 -0
  1722. package/src/modules/customer_groups/data/validators.ts +232 -0
  1723. package/src/modules/customer_groups/di.ts +25 -0
  1724. package/src/modules/customer_groups/events.ts +22 -0
  1725. package/src/modules/customer_groups/i18n/de.json +199 -0
  1726. package/src/modules/customer_groups/i18n/en.json +199 -0
  1727. package/src/modules/customer_groups/i18n/es.json +199 -0
  1728. package/src/modules/customer_groups/i18n/ko.json +199 -0
  1729. package/src/modules/customer_groups/i18n/pl.json +199 -0
  1730. package/src/modules/customer_groups/index.ts +13 -0
  1731. package/src/modules/customer_groups/lib/createConflictRecheck.ts +39 -0
  1732. package/src/modules/customer_groups/lib/customerScope.ts +145 -0
  1733. package/src/modules/customer_groups/lib/groupEvents.ts +50 -0
  1734. package/src/modules/customer_groups/lib/priceKindScope.ts +22 -0
  1735. package/src/modules/customer_groups/lib/reconcile.ts +299 -0
  1736. package/src/modules/customer_groups/migrations/.snapshot-open-mercato.json +905 -0
  1737. package/src/modules/customer_groups/migrations/Migration20260922095316_customer_groups.ts +26 -0
  1738. package/src/modules/customer_groups/migrations/Migration20260922103033_customer_groups.ts +22 -0
  1739. package/src/modules/customer_groups/migrations/Migration20260922105444_customer_groups.ts +17 -0
  1740. package/src/modules/customer_groups/migrations/Migration20260923193330_customer_groups.ts +20 -0
  1741. package/src/modules/customer_groups/migrations/Migration20260929083000_customer_groups.ts +21 -0
  1742. package/src/modules/customer_groups/services/customerGroupsService.ts +358 -0
  1743. package/src/modules/customer_groups/setup.ts +11 -0
  1744. package/src/modules/customer_groups/widgets/injection/group-picker-field/widget.ts +41 -0
  1745. package/src/modules/customer_groups/widgets/injection/person-groups-explain-terms.tsx +227 -0
  1746. package/src/modules/customer_groups/widgets/injection/person-groups-tab/widget.ts +21 -0
  1747. package/src/modules/customer_groups/widgets/injection/person-groups-tab.tsx +573 -0
  1748. package/src/modules/customer_groups/widgets/injection-table.ts +35 -0
  1749. package/src/modules/customers/acl.ts +13 -0
  1750. package/src/modules/customers/api/activities/route.ts +10 -0
  1751. package/src/modules/customers/api/companies/[id]/people/route.ts +2 -1
  1752. package/src/modules/customers/api/companies/[id]/route.ts +20 -6
  1753. package/src/modules/customers/api/deals/[id]/companies/route.ts +2 -1
  1754. package/src/modules/customers/api/deals/[id]/people/route.ts +84 -4
  1755. package/src/modules/customers/api/deals/map/route.ts +11 -10
  1756. package/src/modules/customers/api/dictionaries/context.ts +2 -1
  1757. package/src/modules/customers/api/entity-roles-factory.ts +3 -2
  1758. package/src/modules/customers/api/interactions/[id]/visibility/route.ts +2 -1
  1759. package/src/modules/customers/api/interactions/cancel/route.ts +2 -1
  1760. package/src/modules/customers/api/interactions/complete/route.ts +2 -1
  1761. package/src/modules/customers/api/interactions/conflicts/route.ts +10 -10
  1762. package/src/modules/customers/api/interactions/counts/route.ts +25 -7
  1763. package/src/modules/customers/api/interactions/route.ts +34 -10
  1764. package/src/modules/customers/api/labels/assign/route.ts +2 -1
  1765. package/src/modules/customers/api/labels/route.ts +3 -2
  1766. package/src/modules/customers/api/labels/unassign/route.ts +2 -1
  1767. package/src/modules/customers/api/people/[id]/companies/context.ts +11 -2
  1768. package/src/modules/customers/api/people/[id]/email-share/route.ts +276 -0
  1769. package/src/modules/customers/api/people/[id]/email-threads/route.ts +14 -1
  1770. package/src/modules/customers/api/people/[id]/emails/route.ts +2 -1
  1771. package/src/modules/customers/api/people/[id]/route.ts +31 -22
  1772. package/src/modules/customers/api/people/check-phone/route.ts +2 -1
  1773. package/src/modules/customers/api/pipeline-stages/reorder/route.ts +3 -2
  1774. package/src/modules/customers/api/pipeline-stages/route.ts +3 -3
  1775. package/src/modules/customers/api/pipelines/route.ts +3 -3
  1776. package/src/modules/customers/api/settings/address-format/route.ts +2 -1
  1777. package/src/modules/customers/api/settings/dictionary-sort-modes/route.ts +2 -1
  1778. package/src/modules/customers/api/settings/stuck-threshold/route.ts +2 -1
  1779. package/src/modules/customers/api/tags/assign/route.ts +2 -1
  1780. package/src/modules/customers/api/tags/unassign/route.ts +2 -1
  1781. package/src/modules/customers/backend/customers/companies/[id]/page.tsx +4 -2
  1782. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.ts +10 -35
  1783. package/src/modules/customers/backend/customers/deals/[id]/page.tsx +21 -18
  1784. package/src/modules/customers/backend/customers/deals/components/ReassignOwnerDialog.tsx +115 -0
  1785. package/src/modules/customers/backend/customers/deals/page.tsx +121 -1
  1786. package/src/modules/customers/backend/customers/people/[id]/page.tsx +4 -2
  1787. package/src/modules/customers/commands/addresses.ts +117 -15
  1788. package/src/modules/customers/commands/companies.ts +10 -4
  1789. package/src/modules/customers/commands/emailConversationShares.ts +261 -0
  1790. package/src/modules/customers/commands/index.ts +1 -0
  1791. package/src/modules/customers/commands/interactions.ts +61 -21
  1792. package/src/modules/customers/commands/people.ts +3 -2
  1793. package/src/modules/customers/commands/shared.ts +4 -0
  1794. package/src/modules/customers/components/calendar/types.ts +1 -1
  1795. package/src/modules/customers/components/detail/CompanyPeopleSection.tsx +97 -399
  1796. package/src/modules/customers/components/detail/CreatePersonDialog.tsx +39 -19
  1797. package/src/modules/customers/components/detail/DealForm.tsx +118 -5
  1798. package/src/modules/customers/components/detail/DealOwnerSelect.tsx +161 -0
  1799. package/src/modules/customers/components/detail/DealPeopleSection.tsx +256 -0
  1800. package/src/modules/customers/components/detail/DealsSection.tsx +8 -14
  1801. package/src/modules/customers/components/detail/LinkedPeopleSection.tsx +474 -0
  1802. package/src/modules/customers/components/detail/PersonCard.tsx +12 -4
  1803. package/src/modules/customers/components/detail/PersonEmailShareControl.tsx +273 -0
  1804. package/src/modules/customers/components/detail/PersonEmailThreadsTab.tsx +26 -0
  1805. package/src/modules/customers/components/detail/ScheduleActivityDialog.tsx +10 -2
  1806. package/src/modules/customers/components/detail/create/CreateDealForm.tsx +30 -0
  1807. package/src/modules/customers/components/detail/create/DealDetailsFields.tsx +12 -0
  1808. package/src/modules/customers/components/detail/create/DealSectionCard.tsx +7 -2
  1809. package/src/modules/customers/components/detail/create/dealFormTypes.ts +3 -0
  1810. package/src/modules/customers/components/detail/schedule/useScheduleFormState.ts +16 -4
  1811. package/src/modules/customers/components/formConfig.tsx +3 -0
  1812. package/src/modules/customers/components/linking/LinkEntityDialog.tsx +8 -0
  1813. package/src/modules/customers/components/linking/adapters/personAdapter.tsx +4 -0
  1814. package/src/modules/customers/data/enrichers.ts +64 -5
  1815. package/src/modules/customers/data/entities.ts +105 -1
  1816. package/src/modules/customers/data/validators.ts +22 -0
  1817. package/src/modules/customers/events.ts +5 -0
  1818. package/src/modules/customers/i18n/de.json +49 -13
  1819. package/src/modules/customers/i18n/en.json +44 -8
  1820. package/src/modules/customers/i18n/es.json +44 -8
  1821. package/src/modules/customers/i18n/ko.json +44 -8
  1822. package/src/modules/customers/i18n/pl.json +44 -8
  1823. package/src/modules/customers/lib/assignableStaff.ts +17 -0
  1824. package/src/modules/customers/lib/calendar/editorPayload.ts +20 -13
  1825. package/src/modules/customers/lib/calendar/mapItem.ts +1 -0
  1826. package/src/modules/customers/lib/conversationShares.ts +250 -0
  1827. package/src/modules/customers/lib/dealsOrganizationScope.ts +5 -3
  1828. package/src/modules/customers/lib/interactionRequestContext.ts +2 -1
  1829. package/src/modules/customers/lib/link-channel-message-handler.ts +27 -4
  1830. package/src/modules/customers/lib/personDetailCacheTags.ts +68 -0
  1831. package/src/modules/customers/lib/personEmailThreads.ts +61 -6
  1832. package/src/modules/customers/lib/reassignDealOwner.ts +51 -0
  1833. package/src/modules/customers/lib/userNames.ts +39 -0
  1834. package/src/modules/customers/lib/visibilityFilter.ts +170 -3
  1835. package/src/modules/customers/migrations/.snapshot-open-mercato.json +240 -0
  1836. package/src/modules/customers/migrations/Migration20260825120000_customers.ts +19 -0
  1837. package/src/modules/customers/migrations/Migration20260825140000_customers.ts +41 -0
  1838. package/src/modules/customers/setup.ts +1 -0
  1839. package/src/modules/customers/subscribers/channel-visibility-changed.ts +50 -0
  1840. package/src/modules/dashboards/api/widgets/data/batch/route.ts +3 -8
  1841. package/src/modules/dashboards/api/widgets/data/route.ts +12 -18
  1842. package/src/modules/dashboards/lib/aggregations.ts +1 -1
  1843. package/src/modules/dashboards/lib/widgetScope.ts +2 -7
  1844. package/src/modules/data_sync/AGENTS.md +35 -1
  1845. package/src/modules/data_sync/api/runs/[id]/cancel.ts +5 -1
  1846. package/src/modules/data_sync/backend/data-sync/page.tsx +292 -19
  1847. package/src/modules/data_sync/backend/data-sync/runs/[id]/page.tsx +205 -21
  1848. package/src/modules/data_sync/components/useDataSyncRunAccess.ts +27 -0
  1849. package/src/modules/data_sync/i18n/de.json +24 -0
  1850. package/src/modules/data_sync/i18n/en.json +24 -0
  1851. package/src/modules/data_sync/i18n/es.json +24 -0
  1852. package/src/modules/data_sync/i18n/ko.json +24 -0
  1853. package/src/modules/data_sync/i18n/pl.json +24 -0
  1854. package/src/modules/data_sync/lib/adapter.ts +37 -0
  1855. package/src/modules/data_sync/lib/resume-point.ts +63 -0
  1856. package/src/modules/data_sync/lib/start-run.ts +61 -2
  1857. package/src/modules/data_sync/lib/sync-run-service.ts +27 -34
  1858. package/src/modules/devices/api/[id]/route.ts +3 -2
  1859. package/src/modules/devices/api/admin/devices/route.ts +2 -1
  1860. package/src/modules/devices/api/route.ts +2 -1
  1861. package/src/modules/dictionaries/api/[dictionaryId]/route.ts +3 -5
  1862. package/src/modules/dictionaries/api/context.ts +2 -1
  1863. package/src/modules/dictionaries/api/route.ts +4 -0
  1864. package/src/modules/dictionaries/components/DictionariesManager.tsx +4 -3
  1865. package/src/modules/dictionaries/data/validators.ts +9 -1
  1866. package/src/modules/dictionaries/i18n/de.json +3 -3
  1867. package/src/modules/dictionaries/i18n/en.json +3 -3
  1868. package/src/modules/dictionaries/i18n/es.json +3 -3
  1869. package/src/modules/dictionaries/i18n/ko.json +3 -3
  1870. package/src/modules/dictionaries/i18n/pl.json +3 -3
  1871. package/src/modules/directory/api/organization-branding/route.ts +10 -1
  1872. package/src/modules/directory/api/organizations/route.ts +1 -1
  1873. package/src/modules/directory/backend/directory/branding/page.tsx +24 -2
  1874. package/src/modules/directory/commands/organizations.ts +173 -80
  1875. package/src/modules/directory/i18n/de.json +1 -0
  1876. package/src/modules/directory/i18n/en.json +1 -0
  1877. package/src/modules/directory/i18n/es.json +1 -0
  1878. package/src/modules/directory/i18n/ko.json +1 -0
  1879. package/src/modules/directory/i18n/pl.json +1 -0
  1880. package/src/modules/directory/lib/hierarchy.ts +22 -1
  1881. package/src/modules/directory/utils/organizationScope.ts +102 -15
  1882. package/src/modules/directory/utils/organizationScopeFilter.ts +6 -3
  1883. package/src/modules/directory/utils/organizationScopeGuard.ts +9 -5
  1884. package/src/modules/entities/api/encryption.ts +73 -27
  1885. package/src/modules/entities/api/records.ts +9 -8
  1886. package/src/modules/entities/cli.ts +46 -24
  1887. package/src/modules/entities/data/entities.ts +15 -0
  1888. package/src/modules/entities/lib/definition-scope.ts +5 -1
  1889. package/src/modules/entities/lib/encryption-maps.ts +164 -0
  1890. package/src/modules/entities/lib/helpers.ts +95 -8
  1891. package/src/modules/entities/migrations/.snapshot-open-mercato.json +21 -0
  1892. package/src/modules/entities/migrations/.snapshot-openmercato.json +12 -0
  1893. package/src/modules/entities/migrations/Migration20260910120000.ts +42 -0
  1894. package/src/modules/entities/migrations/Migration20261004120000_encryption_map_scope_uniqueness.ts +130 -0
  1895. package/src/modules/eudr/api/dashboard/widgets/compliance-overview/route.ts +2 -1
  1896. package/src/modules/eudr/api/plots/import/route.ts +2 -1
  1897. package/src/modules/eudr/api/product-mappings/suggestions/apply/route.ts +2 -1
  1898. package/src/modules/eudr/api/product-mappings/suggestions/route.ts +2 -1
  1899. package/src/modules/eudr/api/reports/annual/route.ts +2 -1
  1900. package/src/modules/eudr/api/statements/[id]/export/route.ts +2 -1
  1901. package/src/modules/eudr/api/statements/[id]/readiness/route.ts +2 -1
  1902. package/src/modules/eudr/api/suppliers/compliance/route.ts +2 -1
  1903. package/src/modules/feature_toggles/commands/global.ts +18 -15
  1904. package/src/modules/feature_toggles/lib/feature-flag-check.ts +8 -3
  1905. package/src/modules/forms/acl.ts +10 -0
  1906. package/src/modules/forms/api/[id]/analytics/route.ts +137 -0
  1907. package/src/modules/forms/api/[id]/distributions/route.ts +192 -0
  1908. package/src/modules/forms/api/[id]/route.ts +245 -0
  1909. package/src/modules/forms/api/[id]/run/context/route.ts +142 -0
  1910. package/src/modules/forms/api/[id]/run/submissions/route.ts +147 -0
  1911. package/src/modules/forms/api/[id]/submissions/route.ts +100 -0
  1912. package/src/modules/forms/api/[id]/theme-logo/route.ts +147 -0
  1913. package/src/modules/forms/api/[id]/versions/[versionId]/diff/route.ts +137 -0
  1914. package/src/modules/forms/api/[id]/versions/[versionId]/publish/route.ts +108 -0
  1915. package/src/modules/forms/api/[id]/versions/[versionId]/route.ts +200 -0
  1916. package/src/modules/forms/api/[id]/versions/fork/route.ts +98 -0
  1917. package/src/modules/forms/api/attachment-helpers.ts +160 -0
  1918. package/src/modules/forms/api/by-key/[key]/active/route.ts +165 -0
  1919. package/src/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/route.ts +92 -0
  1920. package/src/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/send/route.ts +96 -0
  1921. package/src/modules/forms/api/distributions/[distributionId]/invitations/route.ts +207 -0
  1922. package/src/modules/forms/api/distributions/[distributionId]/route.ts +213 -0
  1923. package/src/modules/forms/api/form-submissions/[id]/attachments/route.ts +114 -0
  1924. package/src/modules/forms/api/form-submissions/[id]/resume-token/route.ts +140 -0
  1925. package/src/modules/forms/api/form-submissions/[id]/route.ts +176 -0
  1926. package/src/modules/forms/api/form-submissions/[id]/submit/route.ts +91 -0
  1927. package/src/modules/forms/api/form-submissions/by-subject/[subject_type]/[subject_id]/route.ts +93 -0
  1928. package/src/modules/forms/api/form-submissions/route.ts +133 -0
  1929. package/src/modules/forms/api/helpers.ts +175 -0
  1930. package/src/modules/forms/api/public/distributions/[slug]/embed-policy/route.ts +74 -0
  1931. package/src/modules/forms/api/public/distributions/[slug]/route.ts +101 -0
  1932. package/src/modules/forms/api/public/embed-loader/route.ts +136 -0
  1933. package/src/modules/forms/api/public/invitations/[token]/route.ts +107 -0
  1934. package/src/modules/forms/api/public/rate-limit.ts +69 -0
  1935. package/src/modules/forms/api/public/start/route.ts +195 -0
  1936. package/src/modules/forms/api/public/submissions/[id]/attachments/[attachmentId]/route.ts +86 -0
  1937. package/src/modules/forms/api/public/submissions/[id]/attachments/route.ts +108 -0
  1938. package/src/modules/forms/api/public/submissions/[id]/pdf/route.ts +96 -0
  1939. package/src/modules/forms/api/public/submissions/[id]/route.ts +189 -0
  1940. package/src/modules/forms/api/public/submissions/[id]/submit/route.ts +159 -0
  1941. package/src/modules/forms/api/route.ts +240 -0
  1942. package/src/modules/forms/api/runtime-helpers.ts +208 -0
  1943. package/src/modules/forms/api/subjects/[subjectType]/[subjectId]/consents/route.ts +178 -0
  1944. package/src/modules/forms/api/subjects/[subjectType]/[subjectId]/export/route.ts +135 -0
  1945. package/src/modules/forms/api/submissions/[submissionId]/access-audit/route.ts +100 -0
  1946. package/src/modules/forms/api/submissions/[submissionId]/actors/[actorId]/route.ts +70 -0
  1947. package/src/modules/forms/api/submissions/[submissionId]/actors/route.ts +92 -0
  1948. package/src/modules/forms/api/submissions/[submissionId]/anonymize/route.ts +134 -0
  1949. package/src/modules/forms/api/submissions/[submissionId]/attachments/[attachmentId]/route.ts +90 -0
  1950. package/src/modules/forms/api/submissions/[submissionId]/export/route.ts +111 -0
  1951. package/src/modules/forms/api/submissions/[submissionId]/pdf/route.ts +118 -0
  1952. package/src/modules/forms/api/submissions/[submissionId]/reopen/route.ts +69 -0
  1953. package/src/modules/forms/api/submissions/[submissionId]/revisions/route.ts +75 -0
  1954. package/src/modules/forms/api/submissions/[submissionId]/route.ts +90 -0
  1955. package/src/modules/forms/backend/forms/[id]/FormStudio.tsx +3269 -0
  1956. package/src/modules/forms/backend/forms/[id]/analytics/page.meta.ts +15 -0
  1957. package/src/modules/forms/backend/forms/[id]/analytics/page.tsx +289 -0
  1958. package/src/modules/forms/backend/forms/[id]/distributions/page.meta.ts +15 -0
  1959. package/src/modules/forms/backend/forms/[id]/distributions/page.tsx +16 -0
  1960. package/src/modules/forms/backend/forms/[id]/history/page.meta.ts +11 -0
  1961. package/src/modules/forms/backend/forms/[id]/history/page.tsx +229 -0
  1962. package/src/modules/forms/backend/forms/[id]/page.meta.ts +11 -0
  1963. package/src/modules/forms/backend/forms/[id]/page.tsx +17 -0
  1964. package/src/modules/forms/backend/forms/[id]/studio/YesNoRow.tsx +65 -0
  1965. package/src/modules/forms/backend/forms/[id]/studio/autosave-guard.ts +25 -0
  1966. package/src/modules/forms/backend/forms/[id]/studio/canvas/DragOverlayCard.tsx +24 -0
  1967. package/src/modules/forms/backend/forms/[id]/studio/canvas/DropIndicator.tsx +36 -0
  1968. package/src/modules/forms/backend/forms/[id]/studio/canvas/FieldRow.tsx +308 -0
  1969. package/src/modules/forms/backend/forms/[id]/studio/canvas/FormCanvas.tsx +265 -0
  1970. package/src/modules/forms/backend/forms/[id]/studio/canvas/GridSlot.tsx +176 -0
  1971. package/src/modules/forms/backend/forms/[id]/studio/canvas/SectionContainer.tsx +473 -0
  1972. package/src/modules/forms/backend/forms/[id]/studio/canvas/grid-collision.ts +25 -0
  1973. package/src/modules/forms/backend/forms/[id]/studio/canvas/keyboard-coordinates.ts +128 -0
  1974. package/src/modules/forms/backend/forms/[id]/studio/canvas/overlay-size.ts +15 -0
  1975. package/src/modules/forms/backend/forms/[id]/studio/canvas/resize-math.ts +36 -0
  1976. package/src/modules/forms/backend/forms/[id]/studio/canvas/row-layout.ts +110 -0
  1977. package/src/modules/forms/backend/forms/[id]/studio/logic/ConditionBuilder.tsx +264 -0
  1978. package/src/modules/forms/backend/forms/[id]/studio/logic/HiddenFieldsPanel.tsx +121 -0
  1979. package/src/modules/forms/backend/forms/[id]/studio/logic/JumpsEditor.tsx +237 -0
  1980. package/src/modules/forms/backend/forms/[id]/studio/logic/RecallTokenPicker.tsx +87 -0
  1981. package/src/modules/forms/backend/forms/[id]/studio/logic/VariablesPanel.tsx +260 -0
  1982. package/src/modules/forms/backend/forms/[id]/studio/logic/condition-model.ts +207 -0
  1983. package/src/modules/forms/backend/forms/[id]/studio/lucide-icons.ts +87 -0
  1984. package/src/modules/forms/backend/forms/[id]/studio/palette/FormAppearancePanel.tsx +561 -0
  1985. package/src/modules/forms/backend/forms/[id]/studio/palette/FormPalettePanel.tsx +52 -0
  1986. package/src/modules/forms/backend/forms/[id]/studio/palette/InputParametersTab.tsx +378 -0
  1987. package/src/modules/forms/backend/forms/[id]/studio/palette/PaletteCard.tsx +40 -0
  1988. package/src/modules/forms/backend/forms/[id]/studio/palette/RolesEditor.tsx +225 -0
  1989. package/src/modules/forms/backend/forms/[id]/studio/palette/entries.ts +102 -0
  1990. package/src/modules/forms/backend/forms/[id]/studio/preview/PreviewSurface.tsx +1459 -0
  1991. package/src/modules/forms/backend/forms/[id]/studio/preview/ViewportFrame.tsx +49 -0
  1992. package/src/modules/forms/backend/forms/[id]/studio/recall.ts +0 -0
  1993. package/src/modules/forms/backend/forms/[id]/studio/schema-helpers.ts +2525 -0
  1994. package/src/modules/forms/backend/forms/[id]/studio/style/BackgroundControl.tsx +137 -0
  1995. package/src/modules/forms/backend/forms/[id]/studio/style/ColorControl.tsx +257 -0
  1996. package/src/modules/forms/backend/forms/[id]/studio/style/contrast.ts +114 -0
  1997. package/src/modules/forms/backend/forms/[id]/studio/style/presets.ts +104 -0
  1998. package/src/modules/forms/backend/forms/[id]/studio/type-label.ts +13 -0
  1999. package/src/modules/forms/backend/forms/[id]/studio/types.ts +31 -0
  2000. package/src/modules/forms/backend/forms/[id]/studio/undo-controller.ts +52 -0
  2001. package/src/modules/forms/backend/forms/[id]/studio/validation/FileConstraintsEditor.tsx +89 -0
  2002. package/src/modules/forms/backend/forms/[id]/studio/validation/GroupConfigEditor.tsx +167 -0
  2003. package/src/modules/forms/backend/forms/[id]/studio/validation/LengthRangeEditor.tsx +67 -0
  2004. package/src/modules/forms/backend/forms/[id]/studio/validation/MatrixColumnsEditor.tsx +166 -0
  2005. package/src/modules/forms/backend/forms/[id]/studio/validation/MatrixRowsEditor.tsx +184 -0
  2006. package/src/modules/forms/backend/forms/[id]/studio/validation/MessageOverridesEditor.tsx +83 -0
  2007. package/src/modules/forms/backend/forms/[id]/studio/validation/NpsAnchorsEditor.tsx +60 -0
  2008. package/src/modules/forms/backend/forms/[id]/studio/validation/NumberRangeEditor.tsx +65 -0
  2009. package/src/modules/forms/backend/forms/[id]/studio/validation/OpinionIconSelect.tsx +46 -0
  2010. package/src/modules/forms/backend/forms/[id]/studio/validation/PatternEditor.tsx +122 -0
  2011. package/src/modules/forms/backend/forms/[id]/studio/validation/RankingExhaustiveSwitch.tsx +28 -0
  2012. package/src/modules/forms/backend/forms/[id]/studio/validation/SignatureConfigEditor.tsx +84 -0
  2013. package/src/modules/forms/backend/forms/[id]/studio/validation/ValidationPanel.tsx +369 -0
  2014. package/src/modules/forms/backend/forms/[id]/submissions/components/RowBadges.ts +56 -0
  2015. package/src/modules/forms/backend/forms/[id]/submissions/components/SubmissionDrawer.tsx +604 -0
  2016. package/src/modules/forms/backend/forms/[id]/submissions/page.meta.ts +10 -0
  2017. package/src/modules/forms/backend/forms/[id]/submissions/page.tsx +264 -0
  2018. package/src/modules/forms/backend/forms/create/page.meta.ts +11 -0
  2019. package/src/modules/forms/backend/forms/create/page.tsx +113 -0
  2020. package/src/modules/forms/backend/forms/page.meta.ts +31 -0
  2021. package/src/modules/forms/backend/forms/page.tsx +269 -0
  2022. package/src/modules/forms/commands/distribution.ts +502 -0
  2023. package/src/modules/forms/commands/form-version.ts +806 -0
  2024. package/src/modules/forms/commands/form.ts +472 -0
  2025. package/src/modules/forms/commands/index.ts +18 -0
  2026. package/src/modules/forms/commands/invitation.ts +424 -0
  2027. package/src/modules/forms/commands/shared.ts +261 -0
  2028. package/src/modules/forms/commands/submission.ts +209 -0
  2029. package/src/modules/forms/data/entities.ts +686 -0
  2030. package/src/modules/forms/data/validators.ts +483 -0
  2031. package/src/modules/forms/di.ts +246 -0
  2032. package/src/modules/forms/encryption.ts +31 -0
  2033. package/src/modules/forms/events-payloads.ts +103 -0
  2034. package/src/modules/forms/events.ts +50 -0
  2035. package/src/modules/forms/extension-points.ts +41 -0
  2036. package/src/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.meta.ts +9 -0
  2037. package/src/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.tsx +45 -0
  2038. package/src/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.meta.ts +9 -0
  2039. package/src/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.tsx +56 -0
  2040. package/src/modules/forms/frontend/embed/[slug]/page.meta.ts +42 -0
  2041. package/src/modules/forms/frontend/embed/[slug]/page.tsx +171 -0
  2042. package/src/modules/forms/frontend/f/[slug]/page.meta.ts +9 -0
  2043. package/src/modules/forms/frontend/f/[slug]/page.tsx +10 -0
  2044. package/src/modules/forms/frontend/forms/[id]/run/page.meta.ts +17 -0
  2045. package/src/modules/forms/frontend/forms/[id]/run/page.tsx +83 -0
  2046. package/src/modules/forms/frontend/i/[token]/page.meta.ts +9 -0
  2047. package/src/modules/forms/frontend/i/[token]/page.tsx +10 -0
  2048. package/src/modules/forms/i18n/de.json +800 -0
  2049. package/src/modules/forms/i18n/en.json +800 -0
  2050. package/src/modules/forms/i18n/es.json +800 -0
  2051. package/src/modules/forms/i18n/ko.json +800 -0
  2052. package/src/modules/forms/i18n/pl.json +800 -0
  2053. package/src/modules/forms/index.ts +18 -0
  2054. package/src/modules/forms/lib/embed-frame-policy.ts +144 -0
  2055. package/src/modules/forms/lib/form-definition-slicing.ts +54 -0
  2056. package/src/modules/forms/lib/log-redaction.ts +91 -0
  2057. package/src/modules/forms/lib/navigable-url.ts +57 -0
  2058. package/src/modules/forms/lib/retention.ts +73 -0
  2059. package/src/modules/forms/lib/runtime-principal.ts +101 -0
  2060. package/src/modules/forms/migrations/.snapshot-open-mercato.json +3185 -0
  2061. package/src/modules/forms/migrations/Migration20260508135459_forms.ts +17 -0
  2062. package/src/modules/forms/migrations/Migration20260508140932_forms.ts +26 -0
  2063. package/src/modules/forms/migrations/Migration20260508155737_forms.ts +15 -0
  2064. package/src/modules/forms/migrations/Migration20260520120000_forms.ts +26 -0
  2065. package/src/modules/forms/migrations/Migration20260521090000_forms.ts +15 -0
  2066. package/src/modules/forms/migrations/Migration20260521120000_forms.ts +21 -0
  2067. package/src/modules/forms/runner/FormRunner.tsx +924 -0
  2068. package/src/modules/forms/runner/MatrixField.tsx +210 -0
  2069. package/src/modules/forms/runner/RankingField.tsx +207 -0
  2070. package/src/modules/forms/runner/ScaleField.tsx +102 -0
  2071. package/src/modules/forms/runner/SignatureField.tsx +158 -0
  2072. package/src/modules/forms/runner/tamper-check.ts +131 -0
  2073. package/src/modules/forms/schema/address-countries.ts +60 -0
  2074. package/src/modules/forms/schema/field-type-patterns.ts +21 -0
  2075. package/src/modules/forms/schema/field-type-registry-advanced.ts +58 -0
  2076. package/src/modules/forms/schema/field-type-registry.ts +819 -0
  2077. package/src/modules/forms/schema/file-field.ts +102 -0
  2078. package/src/modules/forms/schema/group-field.ts +235 -0
  2079. package/src/modules/forms/schema/jsonlogic-grammar.ts +95 -0
  2080. package/src/modules/forms/schema/jsonschema-extensions.ts +1060 -0
  2081. package/src/modules/forms/schema/layout-catalog.ts +68 -0
  2082. package/src/modules/forms/schema/signature-field.ts +120 -0
  2083. package/src/modules/forms/schema/style-extensions.ts +194 -0
  2084. package/src/modules/forms/schema/style-validators.ts +252 -0
  2085. package/src/modules/forms/services/access-audit-logger.ts +275 -0
  2086. package/src/modules/forms/services/analytics-service.ts +498 -0
  2087. package/src/modules/forms/services/anonymize-service.ts +177 -0
  2088. package/src/modules/forms/services/attachment-service.ts +223 -0
  2089. package/src/modules/forms/services/captcha-verifier.ts +156 -0
  2090. package/src/modules/forms/services/consent-record-service.ts +162 -0
  2091. package/src/modules/forms/services/distribution-service.ts +509 -0
  2092. package/src/modules/forms/services/distribution-token.ts +153 -0
  2093. package/src/modules/forms/services/encryption-service.ts +500 -0
  2094. package/src/modules/forms/services/export-service.ts +360 -0
  2095. package/src/modules/forms/services/field-validation-service.ts +300 -0
  2096. package/src/modules/forms/services/form-logic-evaluator.ts +718 -0
  2097. package/src/modules/forms/services/form-version-compiler.ts +829 -0
  2098. package/src/modules/forms/services/form-version-differ.ts +143 -0
  2099. package/src/modules/forms/services/jsonlogic-evaluator.ts +228 -0
  2100. package/src/modules/forms/services/pdf-snapshot-service.ts +782 -0
  2101. package/src/modules/forms/services/prefill-resolver.ts +125 -0
  2102. package/src/modules/forms/services/role-policy-service.ts +90 -0
  2103. package/src/modules/forms/services/style-compiler.ts +378 -0
  2104. package/src/modules/forms/services/submission-service.ts +1259 -0
  2105. package/src/modules/forms/services/upload-scanner.ts +36 -0
  2106. package/src/modules/forms/services/upload-validation.ts +94 -0
  2107. package/src/modules/forms/services/visibility-resolver.ts +63 -0
  2108. package/src/modules/forms/setup.ts +16 -0
  2109. package/src/modules/forms/subscribers/forms-consent-projector.ts +100 -0
  2110. package/src/modules/forms/subscribers/forms-pdf-snapshot.ts +112 -0
  2111. package/src/modules/forms/subscribers/forms-webhook-bridge-anonymized.ts +36 -0
  2112. package/src/modules/forms/subscribers/forms-webhook-bridge.ts +56 -0
  2113. package/src/modules/forms/subscribers/invitation-email.ts +180 -0
  2114. package/src/modules/forms/translations.ts +14 -0
  2115. package/src/modules/forms/ui/admin/forms/[id]/distributions/CreateDistributionDialog.tsx +401 -0
  2116. package/src/modules/forms/ui/admin/forms/[id]/distributions/DistributionsPanel.tsx +381 -0
  2117. package/src/modules/forms/ui/admin/forms/[id]/distributions/EmbedSettingsDialog.tsx +332 -0
  2118. package/src/modules/forms/ui/admin/forms/[id]/distributions/RecipientsTable.tsx +460 -0
  2119. package/src/modules/forms/ui/public/EmbeddedForm.tsx +248 -0
  2120. package/src/modules/forms/ui/public/FormRunner.tsx +491 -0
  2121. package/src/modules/forms/ui/public/FormTrigger.tsx +80 -0
  2122. package/src/modules/forms/ui/public/PublicFormRunnerPage.tsx +34 -0
  2123. package/src/modules/forms/ui/public/components/CompletionScreen.tsx +97 -0
  2124. package/src/modules/forms/ui/public/components/LocaleSwitch.tsx +42 -0
  2125. package/src/modules/forms/ui/public/components/ResumeGate.tsx +61 -0
  2126. package/src/modules/forms/ui/public/components/ReviewStep.tsx +153 -0
  2127. package/src/modules/forms/ui/public/components/SaveIndicator.tsx +69 -0
  2128. package/src/modules/forms/ui/public/components/SectionStepper.tsx +60 -0
  2129. package/src/modules/forms/ui/public/index.ts +48 -0
  2130. package/src/modules/forms/ui/public/renderers/index.tsx +889 -0
  2131. package/src/modules/forms/ui/public/state/logic-derivation.ts +91 -0
  2132. package/src/modules/forms/ui/public/state/runtime-client.ts +495 -0
  2133. package/src/modules/forms/ui/public/state/useAutosave.ts +97 -0
  2134. package/src/modules/forms/ui/public/state/useFormRunner.ts +547 -0
  2135. package/src/modules/forms/ui/public/style/LogoHeader.tsx +43 -0
  2136. package/src/modules/forms/ui/public/style/applyStyle.ts +26 -0
  2137. package/src/modules/forms/ui/public/types.ts +228 -0
  2138. package/src/modules/forms/widgets/injection/access-audit-panel/widget.tsx +144 -0
  2139. package/src/modules/forms/widgets/injection/anonymize-button/widget.tsx +177 -0
  2140. package/src/modules/forms/widgets/injection/audit-format.ts +60 -0
  2141. package/src/modules/forms/widgets/injection/context.ts +24 -0
  2142. package/src/modules/forms/widgets/injection/embedded-form/widget.tsx +102 -0
  2143. package/src/modules/forms/widgets/injection/pdf-download-button/widget.tsx +111 -0
  2144. package/src/modules/forms/widgets/injection/self-audit-footer/widget.tsx +56 -0
  2145. package/src/modules/forms/widgets/injection-table.ts +54 -0
  2146. package/src/modules/forms/workers/pdf-snapshot.ts +110 -0
  2147. package/src/modules/forms/workers/retention-purge.ts +169 -0
  2148. package/src/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/route.ts +7 -1
  2149. package/src/modules/inbox_ops/data/validators.ts +2 -1
  2150. package/src/modules/inbox_ops/lib/llmProvider.ts +11 -0
  2151. package/src/modules/inbox_ops/widgets/notifications/ProposalCreatedRenderer.tsx +2 -2
  2152. package/src/modules/integrations/di.ts +5 -1
  2153. package/src/modules/integrations/lib/credentials-service.ts +45 -36
  2154. package/src/modules/messages/api/[id]/attachments/route.ts +12 -3
  2155. package/src/modules/messages/api/[id]/forward-preview/route.ts +9 -3
  2156. package/src/modules/messages/api/[id]/route.ts +83 -4
  2157. package/src/modules/messages/api/route.ts +123 -2
  2158. package/src/modules/messages/commands/messages.ts +81 -7
  2159. package/src/modules/messages/components/ComposeMessagePageClient.tsx +29 -1
  2160. package/src/modules/messages/data/validators.ts +10 -0
  2161. package/src/modules/messages/i18n/de.json +8 -0
  2162. package/src/modules/messages/i18n/en.json +8 -0
  2163. package/src/modules/messages/i18n/es.json +8 -0
  2164. package/src/modules/messages/i18n/ko.json +8 -0
  2165. package/src/modules/messages/i18n/pl.json +8 -0
  2166. package/src/modules/messages/lib/channelThreadAccess.ts +101 -0
  2167. package/src/modules/messages/lib/composeSenderDelegation.ts +182 -0
  2168. package/src/modules/messages/lib/composeSenderOptions.ts +56 -0
  2169. package/src/modules/messages/lib/email-sender.ts +1 -17
  2170. package/src/modules/messages/lib/forwarding.ts +17 -2
  2171. package/src/modules/messages/lib/markdownEmailBody.ts +25 -0
  2172. package/src/modules/messages/lib/messageSourceEntityTypes.ts +12 -0
  2173. package/src/modules/messages/lib/routeHelpers.ts +92 -0
  2174. package/src/modules/messages/subscribers/message-notification.ts +47 -1
  2175. package/src/modules/notifications/api/[id]/action/route.ts +2 -1
  2176. package/src/modules/notifications/api/openapi.ts +1 -0
  2177. package/src/modules/notifications/frontend/NotificationSettingsPageClient.tsx +77 -48
  2178. package/src/modules/notifications/i18n/de.json +1 -0
  2179. package/src/modules/notifications/i18n/en.json +1 -0
  2180. package/src/modules/notifications/i18n/es.json +1 -0
  2181. package/src/modules/notifications/i18n/ko.json +1 -0
  2182. package/src/modules/notifications/i18n/pl.json +1 -0
  2183. package/src/modules/notifications/lib/deliveryConfig.ts +31 -2
  2184. package/src/modules/notifications/lib/notificationMapper.ts +2 -0
  2185. package/src/modules/notifications/lib/safeHref.ts +7 -0
  2186. package/src/modules/planner/api/availability-date-specific.ts +2 -1
  2187. package/src/modules/planner/api/availability-weekly.ts +2 -1
  2188. package/src/modules/progress/AGENTS.md +2 -0
  2189. package/src/modules/progress/api/active/route.ts +14 -2
  2190. package/src/modules/progress/api/jobs/[id]/route.ts +44 -27
  2191. package/src/modules/progress/api/jobs/route.ts +22 -8
  2192. package/src/modules/progress/api/requestScope.ts +43 -0
  2193. package/src/modules/progress/lib/organizationScope.ts +17 -0
  2194. package/src/modules/progress/lib/progressService.ts +3 -2
  2195. package/src/modules/progress/lib/progressServiceImpl.ts +63 -14
  2196. package/src/modules/push_notifications/api/custom-send/route.ts +4 -1
  2197. package/src/modules/query_index/api/status.ts +4 -9
  2198. package/src/modules/query_index/di.ts +2 -1
  2199. package/src/modules/query_index/lib/engine.ts +2 -0
  2200. package/src/modules/query_index/lib/request-encryption.ts +31 -0
  2201. package/src/modules/query_index/lib/search-tokens.ts +42 -1
  2202. package/src/modules/resources/api/resources/tags/assign/route.ts +2 -1
  2203. package/src/modules/resources/api/resources/tags/unassign/route.ts +2 -1
  2204. package/src/modules/resources/commands/activities.ts +2 -2
  2205. package/src/modules/sales/api/document-history/route.ts +5 -1
  2206. package/src/modules/sales/api/document-numbers/route.ts +2 -1
  2207. package/src/modules/sales/api/quotes/convert/route.ts +2 -1
  2208. package/src/modules/sales/api/quotes/send/route.ts +2 -1
  2209. package/src/modules/sales/api/settings/document-numbers/route.ts +7 -1
  2210. package/src/modules/sales/api/settings/order-editing/route.ts +7 -1
  2211. package/src/modules/sales/commands/documents.ts +451 -131
  2212. package/src/modules/sales/commands/payments.ts +2 -1
  2213. package/src/modules/sales/commands/settings.ts +34 -6
  2214. package/src/modules/sales/commands/shipments.ts +2 -1
  2215. package/src/modules/sales/components/DocumentNumberSettings.tsx +41 -28
  2216. package/src/modules/sales/components/documents/ItemsSection.tsx +58 -13
  2217. package/src/modules/sales/components/documents/LineItemDialog.tsx +194 -111
  2218. package/src/modules/sales/components/documents/lineItemUtils.ts +18 -0
  2219. package/src/modules/sales/i18n/de.json +2 -0
  2220. package/src/modules/sales/i18n/en.json +2 -0
  2221. package/src/modules/sales/i18n/es.json +2 -0
  2222. package/src/modules/sales/i18n/ko.json +2 -0
  2223. package/src/modules/sales/i18n/pl.json +2 -0
  2224. package/src/modules/sales/lib/lineSnapshots.ts +36 -0
  2225. package/src/modules/sales/setup.ts +4 -4
  2226. package/src/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.tsx +2 -2
  2227. package/src/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.tsx +2 -2
  2228. package/src/modules/staff/api/leave-requests/accept/route.ts +2 -1
  2229. package/src/modules/staff/api/leave-requests/reject/route.ts +2 -1
  2230. package/src/modules/staff/api/leave-requests.ts +2 -1
  2231. package/src/modules/staff/api/team-members/self/route.ts +2 -1
  2232. package/src/modules/staff/api/team-members/tags/assign/route.ts +2 -1
  2233. package/src/modules/staff/api/team-members/tags/unassign/route.ts +2 -1
  2234. package/src/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.ts +16 -16
  2235. package/src/modules/staff/api/timesheets/my-projects/[projectId]/route.ts +2 -1
  2236. package/src/modules/staff/api/timesheets/my-projects/route.ts +2 -1
  2237. package/src/modules/staff/api/timesheets/my-work/route.ts +2 -1
  2238. package/src/modules/staff/api/timesheets/projects/kpis/route.ts +2 -1
  2239. package/src/modules/staff/api/timesheets/reports/[id]/close/route.ts +2 -1
  2240. package/src/modules/staff/api/timesheets/reports/[id]/export/route.ts +3 -2
  2241. package/src/modules/staff/api/timesheets/reports/[id]/sheet/route.ts +3 -2
  2242. package/src/modules/staff/api/timesheets/reports/[id]/unlock/route.ts +3 -2
  2243. package/src/modules/staff/api/timesheets/reports/preview/route.ts +2 -1
  2244. package/src/modules/staff/api/timesheets/reports/shared.ts +2 -1
  2245. package/src/modules/staff/api/timesheets/settings/reapply-rounding/route.ts +2 -1
  2246. package/src/modules/staff/api/timesheets/tags/entry-assignments/route.ts +2 -1
  2247. package/src/modules/staff/api/timesheets/tags/task-assignments/route.ts +2 -1
  2248. package/src/modules/staff/api/timesheets/tasks/[id]/comments/route.ts +2 -1
  2249. package/src/modules/staff/api/timesheets/tasks/[id]/status/route.ts +2 -1
  2250. package/src/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.ts +3 -2
  2251. package/src/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.ts +2 -1
  2252. package/src/modules/staff/api/timesheets/time-entries/[id]/segments/route.ts +2 -1
  2253. package/src/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.ts +2 -1
  2254. package/src/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.ts +2 -1
  2255. package/src/modules/staff/api/timesheets/time-entries/bulk/route.ts +2 -1
  2256. package/src/modules/staff/api/timesheets/time-entries/copy-day/route.ts +3 -2
  2257. package/src/modules/staff/api/timesheets/time-entries/overlaps/route.ts +2 -1
  2258. package/src/modules/staff/api/timesheets/time-entries/start-timer/route.ts +3 -2
  2259. package/src/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.ts +3 -2
  2260. package/src/modules/staff/api/timesheets/time-projects/route.ts +2 -1
  2261. package/src/modules/staff/commands/activities.ts +2 -2
  2262. package/src/modules/staff/commands/timesheets-entries.ts +3 -2
  2263. package/src/modules/staff/commands/timesheets-reports.ts +88 -15
  2264. package/src/modules/staff/lib/timesheets-reports/buildReportSheet.ts +1 -0
  2265. package/src/modules/staff/lib/timesheets-reports/loadReportData.ts +69 -8
  2266. package/src/modules/staff/lib/timesheets-reports/reportPeriod.ts +18 -0
  2267. package/src/modules/staff/lib/timesheets-ui/CalendarPicker.tsx +21 -10
  2268. package/src/modules/sync_excel/api/import/route.ts +40 -12
  2269. package/src/modules/sync_excel/api/upload/route.ts +34 -4
  2270. package/src/modules/translations/api/context.ts +2 -1
  2271. package/src/modules/warranty_claims/api/ai/assess/route.ts +2 -1
  2272. package/src/modules/warranty_claims/api/ai/draft-reply/route.ts +2 -1
  2273. package/src/modules/warranty_claims/api/ai/suggest/route.ts +2 -1
  2274. package/src/modules/warranty_claims/api/assign/route.ts +2 -1
  2275. package/src/modules/warranty_claims/api/credit-memo/route.ts +2 -1
  2276. package/src/modules/warranty_claims/api/entitlement/route.ts +2 -1
  2277. package/src/modules/warranty_claims/api/events/route.ts +2 -1
  2278. package/src/modules/warranty_claims/api/external/claims/route.ts +2 -1
  2279. package/src/modules/warranty_claims/api/receiving/route.ts +2 -1
  2280. package/src/modules/warranty_claims/api/replacement-order/route.ts +2 -1
  2281. package/src/modules/warranty_claims/api/return-label/route.ts +2 -1
  2282. package/src/modules/warranty_claims/api/risk/route.ts +2 -1
  2283. package/src/modules/warranty_claims/api/sales-return/route.ts +2 -1
  2284. package/src/modules/warranty_claims/api/settings-general/route.ts +2 -1
  2285. package/src/modules/warranty_claims/api/stats/route.ts +11 -11
  2286. package/src/modules/warranty_claims/api/submit/route.ts +2 -1
  2287. package/src/modules/warranty_claims/api/transition/route.ts +2 -1
  2288. package/src/modules/warranty_claims/api/vendor-recovery/route.ts +2 -1
  2289. package/src/modules/warranty_claims/api/vendor-recovery-suggestions/route.ts +2 -1
  2290. package/src/modules/warranty_claims/widgets/notifications/WarrantyClaimNotificationRenderer.tsx +1 -1
  2291. package/src/modules/wms/api/dashboard/operational/route.ts +2 -1
  2292. package/src/modules/wms/api/inventory/cycle-count/route.ts +1 -0
  2293. package/src/modules/wms/api/inventory/helpers.ts +2 -1
  2294. package/src/modules/wms/api/inventory/import/helpers.ts +2 -1
  2295. package/src/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.ts +2 -1
  2296. package/src/modules/wms/commands/inventory-actions.ts +45 -1
  2297. package/src/modules/wms/components/backend/CycleCountWizardDialog.tsx +14 -1
  2298. package/src/modules/wms/di.ts +6 -0
  2299. package/src/modules/wms/i18n/de.json +1 -0
  2300. package/src/modules/wms/i18n/en.json +1 -0
  2301. package/src/modules/wms/i18n/es.json +1 -0
  2302. package/src/modules/wms/i18n/ko.json +1 -0
  2303. package/src/modules/wms/i18n/pl.json +1 -0
  2304. package/src/modules/wms/lib/availabilityCache.ts +137 -0
  2305. package/src/modules/wms/lib/availabilityCalculation.ts +351 -0
  2306. package/src/modules/wms/lib/availabilityProvider.ts +47 -0
  2307. package/src/modules/wms/lib/loadOperationalDashboard.ts +51 -3
  2308. package/src/modules/wms/lib/lowStockBalanceFilter.ts +23 -10
  2309. package/src/modules/wms/lib/sqlInClause.ts +21 -0
  2310. package/src/modules/wms/lib/tryResolve.ts +8 -0
  2311. package/src/modules/wms/subscribers/invalidate-availability-cache-policy.ts +18 -0
  2312. package/src/modules/wms/subscribers/invalidate-availability-cache-profile.ts +18 -0
  2313. package/src/modules/wms/subscribers/invalidate-availability-cache.ts +30 -0
  2314. package/src/modules/wms/widgets/notifications/WmsLowStockRenderer.tsx +2 -2
  2315. package/src/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.tsx +4 -3
  2316. package/src/modules/workflows/AGENTS.md +7 -5
  2317. package/src/modules/workflows/api/commands/route.ts +4 -1
  2318. package/src/modules/workflows/api/definitions/[id]/callers/route.ts +4 -1
  2319. package/src/modules/workflows/api/definitions/[id]/context-schema/route.ts +4 -2
  2320. package/src/modules/workflows/api/definitions/[id]/customize/route.ts +4 -1
  2321. package/src/modules/workflows/api/definitions/[id]/draft/route.ts +6 -1
  2322. package/src/modules/workflows/api/definitions/[id]/publish/route.ts +10 -1
  2323. package/src/modules/workflows/api/definitions/[id]/reset-to-code/route.ts +4 -1
  2324. package/src/modules/workflows/api/definitions/[id]/route.ts +5 -3
  2325. package/src/modules/workflows/api/definitions/[id]/test-step/route.ts +4 -2
  2326. package/src/modules/workflows/api/definitions/generate/route.ts +4 -1
  2327. package/src/modules/workflows/api/definitions/route.ts +4 -2
  2328. package/src/modules/workflows/api/endpoints/route.ts +4 -1
  2329. package/src/modules/workflows/api/functions/route.ts +4 -1
  2330. package/src/modules/workflows/api/grantable-features/route.ts +2 -1
  2331. package/src/modules/workflows/api/instances/[id]/advance/route.ts +4 -1
  2332. package/src/modules/workflows/api/instances/[id]/cancel/route.ts +4 -1
  2333. package/src/modules/workflows/api/instances/[id]/context/route.ts +2 -1
  2334. package/src/modules/workflows/api/instances/[id]/rerun-step/route.ts +4 -1
  2335. package/src/modules/workflows/api/instances/[id]/retry/route.ts +4 -1
  2336. package/src/modules/workflows/api/instances/[id]/signal/route.ts +4 -1
  2337. package/src/modules/workflows/api/instances/[id]/step-through/route.ts +4 -2
  2338. package/src/modules/workflows/api/instances/route.ts +4 -2
  2339. package/src/modules/workflows/api/instances/validate-start/route.ts +4 -1
  2340. package/src/modules/workflows/api/rule-usage/route.ts +4 -1
  2341. package/src/modules/workflows/api/signals/route.ts +4 -1
  2342. package/src/modules/workflows/api/tasks/[id]/claim/route.ts +4 -1
  2343. package/src/modules/workflows/api/tasks/[id]/complete/route.ts +4 -1
  2344. package/src/modules/workflows/api/tasks/[id]/reassign/route.ts +2 -1
  2345. package/src/modules/workflows/api/tasks/[id]/unclaim/route.ts +4 -1
  2346. package/src/modules/workflows/api/templates/route.ts +4 -1
  2347. package/src/modules/workflows/api/work-inbox/next/route.ts +4 -1
  2348. package/src/modules/workflows/lib/activity-executor.ts +125 -28
  2349. package/src/modules/workflows/lib/activity-types.ts +8 -4
  2350. package/src/modules/workflows/lib/activity-worker-handler.ts +16 -12
  2351. package/src/modules/workflows/lib/event-trigger-service.ts +18 -2
  2352. package/src/modules/workflows/lib/step-handler.ts +13 -8
  2353. package/src/test-utils/transactionalEntityManagerDouble.ts +51 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/messages/commands/messages.ts"],
4
- "sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { z } from 'zod'\nimport { registerCommand, type CommandHandler } from '@open-mercato/shared/lib/commands'\nimport { withAtomicFlush } from '@open-mercato/shared/lib/commands/flush'\nimport { extractUndoPayload, type UndoPayload } from '@open-mercato/shared/lib/commands/undo'\nimport { findOneWithDecryption, findWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { Message, MessageObject, MessageRecipient, type MessageActionData } from '../data/entities'\nimport { emitMessagesEvent } from '../events'\nimport {\n composeMessageSchema,\n forwardMessageSchema,\n replyMessageSchema,\n updateDraftSchema,\n} from '../data/validators'\nimport { linkAttachmentsToMessage, linkLibraryAttachmentsToMessage, copyAttachmentsForForwardMessages } from '../lib/attachments'\nimport { MESSAGE_ATTACHMENT_ENTITY_ID, MESSAGE_ENTITY_ID } from '../lib/constants'\nimport { getMessageTypeOrDefault } from '../lib/message-types-registry'\nimport { validateMessageObjectsForType } from '../lib/object-validation'\nimport { buildForwardBodyFromLegacyInput, buildForwardPreviewFromThreadSlice, buildForwardThreadSlice } from '../lib/forwarding'\nimport {\n assertOrganizationAccess,\n loadMessageAggregateSnapshot,\n restoreMessageAggregateSnapshot,\n type MessageAggregateSnapshot,\n type MessageScopeInput,\n} from './shared'\n\ntype MessageSentEventPayload = {\n messageId: string\n senderUserId: string\n recipientUserIds: string[]\n sendViaEmail: boolean\n /**\n * The message arrived from an external channel (#6093). Its `senderUserId`\n * is the channel's system user and its real correspondent lives in\n * `externalName` / `externalEmail`; subscribers that show a sender read it\n * from there.\n */\n inboundFromChannel?: boolean\n externalEmail?: string | null\n forwardedFrom?: string\n replyTo?: string\n tenantId: string\n organizationId?: string | null\n}\n\ntype ContainerWithResolve = {\n resolve: (name: string) => unknown\n}\n\nasync function emitMessageSentEvent(_container: ContainerWithResolve, payload: MessageSentEventPayload) {\n await emitMessagesEvent('messages.message.sent', payload, { persistent: true })\n}\n\nasync function emitMessageDeletedEvent(_container: ContainerWithResolve, payload: {\n messageId: string\n actorUserId: string\n target: 'sender' | 'recipient'\n tenantId: string\n organizationId: string | null\n}) {\n await emitMessagesEvent(\n 'messages.message.deleted',\n { ...payload, recipientUserId: payload.actorUserId },\n { persistent: true },\n )\n}\n\nasync function emitMessageGloballyDeletedEvent(_container: ContainerWithResolve, payload: {\n messageId: string\n actorUserId: string\n recipientUserIds: string[]\n tenantId: string\n organizationId: string | null\n}) {\n const audience = Array.from(new Set([payload.actorUserId, ...payload.recipientUserIds]))\n await emitMessagesEvent(\n 'messages.message.deleted',\n {\n messageId: payload.messageId,\n actorUserId: payload.actorUserId,\n target: 'global',\n recipientUserIds: audience,\n tenantId: payload.tenantId,\n organizationId: payload.organizationId,\n },\n { persistent: true },\n )\n}\n\nasync function emitMessageIndexUpsert(\n container: ContainerWithResolve,\n payload: {\n messageId: string\n tenantId: string\n organizationId: string | null\n },\n) {\n let bus: { emitEvent: (name: string, body: unknown, options?: unknown) => Promise<void> } | null = null\n try {\n bus = container.resolve('eventBus') as { emitEvent: (name: string, body: unknown, options?: unknown) => Promise<void> }\n } catch {\n bus = null\n }\n\n if (!bus) return\n\n await bus.emitEvent(\n 'query_index.upsert_one',\n {\n entityType: MESSAGE_ENTITY_ID,\n recordId: payload.messageId,\n tenantId: payload.tenantId,\n organizationId: payload.organizationId,\n crudAction: 'updated',\n coverageBaseDelta: 1,\n },\n {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId,\n },\n ).catch(() => undefined)\n}\n\nconst scopeSchema = z.object({\n tenantId: z.string().uuid(),\n organizationId: z.string().uuid().nullable(),\n userId: z.string().uuid(),\n})\n\nconst composeCommandSchema = composeMessageSchema.safeExtend({\n tenantId: scopeSchema.shape.tenantId,\n organizationId: scopeSchema.shape.organizationId,\n userId: scopeSchema.shape.userId,\n // Optional dedup key (inbound email ingest sets it; other callers leave it\n // undefined). When set, a re-issued compose returns the first message instead\n // of creating a duplicate.\n idempotencyKey: z.string().min(1).max(255).optional(),\n})\n\nconst updateDraftCommandSchema = updateDraftSchema.safeExtend({\n messageId: z.string().uuid(),\n tenantId: scopeSchema.shape.tenantId,\n organizationId: scopeSchema.shape.organizationId,\n userId: scopeSchema.shape.userId,\n})\n\nconst replyCommandSchema = replyMessageSchema.safeExtend({\n messageId: z.string().uuid(),\n tenantId: scopeSchema.shape.tenantId,\n organizationId: scopeSchema.shape.organizationId,\n userId: scopeSchema.shape.userId,\n})\n\nconst forwardCommandSchema = forwardMessageSchema.safeExtend({\n messageId: z.string().uuid(),\n tenantId: scopeSchema.shape.tenantId,\n organizationId: scopeSchema.shape.organizationId,\n userId: scopeSchema.shape.userId,\n})\n\nconst deleteForActorCommandSchema = z.object({\n messageId: z.string().uuid(),\n tenantId: scopeSchema.shape.tenantId,\n organizationId: scopeSchema.shape.organizationId,\n userId: scopeSchema.shape.userId,\n})\n\ntype ComposeCommandInput = z.infer<typeof composeCommandSchema>\ntype UpdateDraftCommandInput = z.infer<typeof updateDraftCommandSchema>\ntype ReplyCommandInput = z.infer<typeof replyCommandSchema>\ntype ForwardCommandInput = z.infer<typeof forwardCommandSchema>\ntype DeleteForActorCommandInput = z.infer<typeof deleteForActorCommandSchema>\n\ntype MessageDeleteUndoState = {\n messageId: string\n messageDeletedAt: string | null\n recipientId: string | null\n recipientStatus: 'unread' | 'read' | 'archived' | 'deleted' | null\n recipientDeletedAt: string | null\n}\n\nfunction toIso(value: Date | null | undefined): string | null {\n return value ? value.toISOString() : null\n}\n\nfunction toDate(value: string | null | undefined): Date | null {\n if (!value) return null\n return new Date(value)\n}\n\nfunction buildReplySubject(subject: string): string {\n if (/^re:\\s*/i.test(subject)) return subject\n return `Re: ${subject}`\n}\n\nasync function requireMessageById(\n em: EntityManager,\n scope: MessageScopeInput,\n messageId: string,\n) {\n const message = await findOneWithDecryption(\n em,\n Message,\n {\n id: messageId,\n tenantId: scope.tenantId,\n deletedAt: null,\n },\n undefined,\n {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n },\n )\n if (!message) throw new Error('Message not found')\n assertOrganizationAccess(scope, message)\n return message\n}\n\nfunction isUniqueViolation(err: unknown): boolean {\n if (!err || typeof err !== 'object') return false\n const code = (err as { code?: string }).code\n if (code === '23505') return true\n const message = (err as { message?: string }).message\n return typeof message === 'string' && /duplicate key value|unique constraint/i.test(message)\n}\n\ntype ComposeMessageResult = {\n id: string\n threadId: string | null\n externalEmail: string | null\n isDraft: boolean\n recipientUserIds: string[]\n /**\n * True when this was an idempotent replay \u2014 an existing message was returned\n * and nothing was written. Signals `buildLog` to skip the audit/undo entry.\n */\n deduplicated?: boolean\n}\n\nasync function buildComposeResultFromExisting(\n em: EntityManager,\n message: Message,\n): Promise<ComposeMessageResult> {\n const recipients = await findWithDecryption(\n em,\n MessageRecipient,\n { messageId: message.id, deletedAt: null },\n undefined,\n { tenantId: message.tenantId, organizationId: message.organizationId ?? null },\n )\n return {\n id: message.id,\n threadId: message.threadId ?? null,\n externalEmail: message.externalEmail ?? null,\n isDraft: message.isDraft,\n recipientUserIds: recipients.map((recipient) => recipient.recipientUserId),\n deduplicated: true,\n }\n}\n\nconst composeMessageCommand: CommandHandler<unknown, { id: string; threadId: string | null; externalEmail: string | null; isDraft: boolean; recipientUserIds: string[]; deduplicated?: boolean }> = {\n id: 'messages.messages.compose',\n async execute(rawInput, ctx) {\n const input = composeCommandSchema.parse(rawInput)\n if (input.objects?.length) {\n const objectValidationError = validateMessageObjectsForType(input.type, input.objects)\n if (objectValidationError) throw new Error(objectValidationError)\n }\n\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const scope = { tenantId: input.tenantId, organizationId: input.organizationId }\n\n // Idempotency fast-path: a retried inbound-email ingest re-issues compose\n // for the same source message (the first attempt committed the message but a\n // downstream transient failure rolled the ingest back). Return that message\n // so the retry cannot create a duplicate.\n if (input.idempotencyKey) {\n const existing = await findOneWithDecryption(\n em,\n Message,\n { tenantId: input.tenantId, idempotencyKey: input.idempotencyKey },\n undefined,\n scope,\n )\n if (existing) return buildComposeResultFromExisting(em, existing)\n }\n\n let messageId = ''\n let responseThreadId: string | null = null\n let responseExternalEmail: string | null = null\n\n const composeTx = em.transactional(async (trx) => {\n const threadId = input.parentMessageId\n ? (\n await findOneWithDecryption(\n trx,\n Message,\n {\n id: input.parentMessageId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n deletedAt: null,\n },\n undefined,\n scope,\n )\n )?.threadId ?? input.parentMessageId\n : undefined\n\n const isPublicVisibility = input.visibility === 'public'\n // #6093: a channel-ingested message was RECEIVED, not sent. Ingest passes\n // `sendViaEmail: false` on purpose; forcing it for public visibility would\n // mail the assignee a copy and echo the message to its external sender\n // (#6089) the moment the recipients waiver lets it compose. #6090 removes\n // the forcing for every caller; until then it is skipped here for the\n // ingest path only.\n const sendViaEmail = isPublicVisibility && !input.inboundFromChannel ? true : input.sendViaEmail\n const message = trx.create(Message, {\n type: input.type,\n visibility: input.visibility ?? null,\n sourceEntityType: input.sourceEntityType,\n sourceEntityId: input.sourceEntityId,\n externalEmail: input.externalEmail,\n externalName: input.externalName,\n threadId: threadId ?? undefined,\n parentMessageId: input.parentMessageId,\n senderUserId: input.userId,\n subject: input.subject,\n body: input.body,\n bodyFormat: input.bodyFormat,\n priority: input.priority,\n status: input.isDraft ? 'draft' : 'sent',\n isDraft: input.isDraft ?? false,\n // #6095: channel ingest passes the provider's timestamp so an imported\n // mailbox sorts by when the mail was received, not when it was imported.\n sentAt: input.isDraft ? null : input.sentAt ?? new Date(),\n actionData: input.actionData as MessageActionData | undefined,\n sendViaEmail,\n idempotencyKey: input.idempotencyKey ?? null,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n\n await trx.persist(message).flush()\n if (!threadId && !input.isDraft && !message.threadId) {\n message.threadId = message.id\n await trx.flush()\n }\n\n for (const recipient of input.recipients) {\n trx.persist(trx.create(MessageRecipient, {\n messageId: message.id,\n recipientUserId: recipient.userId,\n recipientType: recipient.type,\n status: 'unread',\n }))\n }\n\n if (input.objects) {\n for (const obj of input.objects) {\n trx.persist(trx.create(MessageObject, {\n messageId: message.id,\n entityModule: obj.entityModule,\n entityType: obj.entityType,\n entityId: obj.entityId,\n actionRequired: obj.actionRequired,\n actionType: obj.actionType,\n actionLabel: obj.actionLabel,\n }))\n }\n }\n\n await trx.flush()\n\n if (input.attachmentIds?.length) {\n await linkAttachmentsToMessage(\n trx,\n message.id,\n input.attachmentIds,\n input.organizationId,\n input.tenantId,\n )\n }\n\n if (input.attachmentRecordId) {\n await linkLibraryAttachmentsToMessage(\n trx,\n message.id,\n input.attachmentRecordId,\n input.organizationId,\n input.tenantId,\n )\n }\n\n messageId = message.id\n responseThreadId = message.threadId ?? null\n responseExternalEmail = message.externalEmail ?? null\n })\n try {\n await composeTx\n } catch (err) {\n // Lost a concurrent race on the same idempotency key \u2014 return the message\n // the winning compose created. A propagated 23505 would otherwise be\n // classified permanent and dead-letter the inbound mail.\n if (input.idempotencyKey && isUniqueViolation(err)) {\n const existing = await findOneWithDecryption(\n em.fork(),\n Message,\n { tenantId: input.tenantId, idempotencyKey: input.idempotencyKey },\n undefined,\n scope,\n )\n if (existing) return buildComposeResultFromExisting(em.fork(), existing)\n }\n throw err\n }\n\n if (!input.isDraft) {\n await emitMessageSentEvent(ctx.container, {\n messageId,\n senderUserId: input.userId,\n recipientUserIds: input.recipients.map((recipient) => recipient.userId),\n sendViaEmail:\n input.visibility === 'public' && !input.inboundFromChannel ? true : input.sendViaEmail,\n inboundFromChannel: input.inboundFromChannel === true,\n externalEmail: responseExternalEmail,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n }\n\n await emitMessageIndexUpsert(ctx.container, {\n messageId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n\n return {\n id: messageId,\n threadId: responseThreadId,\n externalEmail: responseExternalEmail,\n isDraft: input.isDraft,\n recipientUserIds: input.recipients.map((recipient) => recipient.userId),\n }\n },\n async captureAfter(_input, result, ctx) {\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n return loadMessageAggregateSnapshot(em, result.id)\n },\n buildLog: async ({ input, result, snapshots }) => {\n // Idempotent replay: execute returned a pre-existing message without writing\n // anything. Skip the audit entry entirely \u2014 logging it as a fresh \"Compose\n // message\" would both misrepresent the dedup and expose an undo that\n // soft-deletes a legitimately-received inbound message.\n if (result.deduplicated) return { skipLog: true }\n const parsed = composeCommandSchema.parse(input)\n return {\n actionLabel: parsed.isDraft ? 'Create draft message' : 'Compose message',\n resourceKind: 'messages.message',\n resourceId: result.id,\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n payload: {\n undo: {\n after: (snapshots.after as MessageAggregateSnapshot | undefined) ?? null,\n } satisfies UndoPayload<MessageAggregateSnapshot>,\n },\n snapshotAfter: snapshots.after ?? null,\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const undo = extractUndoPayload<UndoPayload<MessageAggregateSnapshot>>(logEntry)\n const after = undo?.after\n if (!after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await em.findOne(Message, { id: after.message.id })\n if (!message) return\n message.deletedAt = new Date()\n await em.flush()\n if (!after.message.isDraft) {\n await emitMessageGloballyDeletedEvent(ctx.container, {\n messageId: after.message.id,\n actorUserId: after.message.senderUserId,\n recipientUserIds: after.recipients.map((recipient) => recipient.recipientUserId),\n tenantId: after.message.tenantId,\n organizationId: after.message.organizationId,\n })\n }\n },\n}\n\nconst updateDraftCommand: CommandHandler<unknown, { ok: true; id: string }> = {\n id: 'messages.messages.update_draft',\n async prepare(rawInput, ctx) {\n const input = updateDraftCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const snapshot = await loadMessageAggregateSnapshot(em, input.messageId, {\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n return snapshot ? { before: snapshot } : {}\n },\n async execute(rawInput, ctx) {\n const input = updateDraftCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await requireMessageById(em, input, input.messageId)\n\n if (message.senderUserId !== input.userId) throw new Error('Access denied')\n if (!message.isDraft) throw new Error('Only draft messages can be edited')\n\n const isSending = input.isDraft === false\n const preloadedRecipients = isSending && !input.recipients\n ? await findWithDecryption(\n em,\n MessageRecipient,\n { messageId: message.id, deletedAt: null },\n undefined,\n {\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n },\n )\n : null\n\n const nextMessageType = input.type ?? message.type\n if (input.objects) {\n const objectValidationError = validateMessageObjectsForType(nextMessageType, input.objects)\n if (objectValidationError) throw new Error(objectValidationError)\n } else if (input.type !== undefined) {\n const existingObjects = await em.find(MessageObject, { messageId: message.id })\n if (existingObjects.length > 0) {\n const objectValidationError = validateMessageObjectsForType(\n nextMessageType,\n existingObjects.map((item) => ({\n entityModule: item.entityModule,\n entityType: item.entityType,\n entityId: item.entityId,\n })),\n )\n if (objectValidationError) throw new Error(objectValidationError)\n }\n }\n\n // Validate the send transition BEFORE the atomic-flush block so a rejected\n // send never mutates or flushes anything (everything checked here is known\n // from the parsed input + the loaded message).\n if (isSending) {\n const finalVisibility = input.visibility ?? message.visibility\n const finalSubject = input.subject ?? message.subject\n const finalBody = input.body ?? message.body\n const finalRecipientCount = input.recipients\n ? input.recipients.length\n : (preloadedRecipients?.length ?? 0)\n if (finalVisibility !== 'public' && finalRecipientCount === 0) {\n throw new Error('at least one recipient is required')\n }\n if (!finalSubject?.trim()) throw new Error('subject is required')\n if (!finalBody?.trim()) throw new Error('body is required')\n }\n\n // Phase 1 mutates the managed `message` scalars; the per-phase flush issues\n // those changes before phase 2's interleaved reads run (e.g.\n // `linkAttachmentsToMessage` issues an `em.find`). Under MikroORM v7 a read\n // between a scalar mutation and the terminal flush on the same EntityManager\n // silently drops the pending changeset, so keeping the scalar edits in their\n // own phase guarantees subject/body/etc. are persisted (SPEC-018 Problem 1).\n await withAtomicFlush(em, [() => {\n if (input.type !== undefined) message.type = input.type\n if (input.visibility !== undefined) message.visibility = input.visibility\n if (input.sourceEntityType !== undefined) message.sourceEntityType = input.sourceEntityType\n if (input.sourceEntityId !== undefined) message.sourceEntityId = input.sourceEntityId\n if (input.externalEmail !== undefined) message.externalEmail = input.externalEmail\n if (input.externalName !== undefined) message.externalName = input.externalName\n if (input.subject !== undefined) message.subject = input.subject\n if (input.body !== undefined) message.body = input.body\n if (input.bodyFormat !== undefined) message.bodyFormat = input.bodyFormat\n if (input.priority !== undefined) message.priority = input.priority\n if (input.actionData !== undefined) message.actionData = input.actionData\n if (input.sendViaEmail !== undefined) message.sendViaEmail = input.sendViaEmail\n }, async () => {\n if (input.recipients) {\n await em.nativeDelete(MessageRecipient, { messageId: message.id })\n for (const recipient of input.recipients) {\n em.persist(em.create(MessageRecipient, {\n messageId: message.id,\n recipientUserId: recipient.userId,\n recipientType: recipient.type,\n status: 'unread',\n }))\n }\n }\n\n if (input.objects) {\n await em.nativeDelete(MessageObject, { messageId: message.id })\n for (const object of input.objects) {\n em.persist(em.create(MessageObject, {\n messageId: message.id,\n entityModule: object.entityModule,\n entityType: object.entityType,\n entityId: object.entityId,\n actionRequired: object.actionRequired,\n actionType: object.actionType,\n actionLabel: object.actionLabel,\n }))\n }\n }\n\n if (input.attachmentIds) {\n const { Attachment } = await import('@open-mercato/core/modules/attachments/data/entities')\n if (input.attachmentIds.length === 0) {\n await em.nativeDelete(Attachment, {\n entityId: MESSAGE_ATTACHMENT_ENTITY_ID,\n recordId: message.id,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n } else {\n await em.nativeDelete(Attachment, {\n entityId: MESSAGE_ATTACHMENT_ENTITY_ID,\n recordId: message.id,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n id: { $nin: input.attachmentIds },\n })\n }\n await linkAttachmentsToMessage(\n em,\n message.id,\n input.attachmentIds,\n input.organizationId,\n input.tenantId,\n )\n }\n\n if (isSending) {\n // Send transition was validated before the block; just apply the\n // status mutations here (persisted by this phase's boundary flush).\n message.isDraft = false\n message.status = 'sent'\n message.sentAt = new Date()\n if (!message.threadId) message.threadId = message.id\n }\n }], { transaction: true })\n\n await emitMessageIndexUpsert(ctx.container, {\n messageId: message.id,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n\n if (isSending) {\n const recipientUserIds = input.recipients\n ? input.recipients.map((r) => r.userId)\n : (preloadedRecipients ?? []).map((r) => r.recipientUserId)\n const resolvedVisibility = input.visibility ?? message.visibility\n const resolvedSendViaEmail = input.sendViaEmail ?? message.sendViaEmail\n await emitMessageSentEvent(ctx.container, {\n messageId: message.id,\n senderUserId: input.userId,\n recipientUserIds,\n sendViaEmail: resolvedVisibility === 'public' ? true : resolvedSendViaEmail,\n externalEmail: message.externalEmail ?? null,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n }\n\n return { ok: true, id: message.id }\n },\n async captureAfter(rawInput, _result, ctx) {\n const input = updateDraftCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n return loadMessageAggregateSnapshot(em, input.messageId, {\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n },\n buildLog: async ({ input, snapshots }) => {\n const parsed = updateDraftCommandSchema.parse(input)\n return {\n actionLabel: parsed.isDraft === false ? 'Send draft message' : 'Update draft message',\n resourceKind: 'messages.message',\n resourceId: parsed.messageId,\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n payload: {\n undo: {\n before: (snapshots.before as MessageAggregateSnapshot | undefined) ?? null,\n after: (snapshots.after as MessageAggregateSnapshot | undefined) ?? null,\n } satisfies UndoPayload<MessageAggregateSnapshot>,\n },\n snapshotBefore: snapshots.before ?? null,\n snapshotAfter: snapshots.after ?? null,\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const undo = extractUndoPayload<UndoPayload<MessageAggregateSnapshot>>(logEntry)\n const before = undo?.before\n if (!before) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n await restoreMessageAggregateSnapshot(em, before)\n },\n}\n\nconst replyMessageCommand: CommandHandler<unknown, { id: string; externalEmail: string | null; recipientUserIds: string[] }> = {\n id: 'messages.messages.reply',\n async execute(rawInput, ctx) {\n const input = replyCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const original = await requireMessageById(em, input, input.messageId)\n const ownRecipient = await em.findOne(MessageRecipient, {\n messageId: original.id,\n recipientUserId: input.userId,\n deletedAt: null,\n })\n if (original.senderUserId !== input.userId && !ownRecipient) throw new Error('Access denied')\n\n const messageType = getMessageTypeOrDefault(original.type)\n if (messageType.allowReply === false) throw new Error('Reply is not allowed for this message type')\n\n const recipientIds = new Set(\n (input.recipients ?? [])\n .map((recipient) => recipient.userId)\n .filter((recipientUserId) => recipientUserId !== input.userId),\n )\n\n if (recipientIds.size === 0) {\n const originalRecipients = await em.find(MessageRecipient, { messageId: original.id, deletedAt: null })\n if (input.replyAll) {\n if (original.senderUserId !== input.userId) recipientIds.add(original.senderUserId)\n for (const recipient of originalRecipients) {\n if (recipient.recipientUserId !== input.userId) recipientIds.add(recipient.recipientUserId)\n }\n } else if (original.senderUserId !== input.userId) {\n recipientIds.add(original.senderUserId)\n } else {\n for (const recipient of originalRecipients) {\n if (recipient.recipientUserId !== input.userId) {\n recipientIds.add(recipient.recipientUserId)\n break\n }\n }\n }\n\n if (recipientIds.size === 0 && original.senderUserId === input.userId) {\n recipientIds.add(input.userId)\n }\n }\n if (recipientIds.size === 0) throw new Error('No recipients available for reply')\n\n let messageId = ''\n let responseExternalEmail: string | null = null\n await em.transactional(async (trx) => {\n const message = trx.create(Message, {\n type: original.type,\n visibility: original.visibility ?? null,\n sourceEntityType: original.sourceEntityType,\n sourceEntityId: original.sourceEntityId,\n externalEmail: original.externalEmail,\n externalName: original.externalName,\n threadId: original.threadId ?? original.id,\n parentMessageId: original.id,\n senderUserId: input.userId,\n subject: buildReplySubject(original.subject),\n body: input.body,\n bodyFormat: input.bodyFormat,\n priority: original.priority,\n status: 'sent',\n isDraft: false,\n sentAt: new Date(),\n sendViaEmail: input.sendViaEmail,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n await trx.persist(message).flush()\n for (const recipientUserId of recipientIds) {\n trx.persist(trx.create(MessageRecipient, {\n messageId: message.id,\n recipientUserId,\n recipientType: 'to',\n status: 'unread',\n }))\n }\n await trx.flush()\n if (input.attachmentIds?.length) {\n await linkAttachmentsToMessage(\n trx,\n message.id,\n input.attachmentIds,\n input.organizationId,\n input.tenantId,\n )\n }\n if (input.attachmentRecordId) {\n await linkLibraryAttachmentsToMessage(\n trx,\n message.id,\n input.attachmentRecordId,\n input.organizationId,\n input.tenantId,\n )\n }\n messageId = message.id\n responseExternalEmail = message.externalEmail ?? null\n })\n\n await emitMessageSentEvent(ctx.container, {\n messageId,\n senderUserId: input.userId,\n recipientUserIds: Array.from(recipientIds),\n sendViaEmail: input.sendViaEmail,\n externalEmail: responseExternalEmail,\n replyTo: original.id,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n await emitMessageIndexUpsert(ctx.container, {\n messageId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n\n return {\n id: messageId,\n externalEmail: responseExternalEmail,\n recipientUserIds: Array.from(recipientIds),\n }\n },\n async captureAfter(_input, result, ctx) {\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n return loadMessageAggregateSnapshot(em, result.id)\n },\n buildLog: async ({ input, result, snapshots }) => {\n const parsed = replyCommandSchema.parse(input)\n return {\n actionLabel: 'Reply to message',\n resourceKind: 'messages.message',\n resourceId: result.id,\n parentResourceKind: 'messages.message',\n parentResourceId: parsed.messageId,\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n payload: {\n undo: {\n after: (snapshots.after as MessageAggregateSnapshot | undefined) ?? null,\n } satisfies UndoPayload<MessageAggregateSnapshot>,\n },\n snapshotAfter: snapshots.after ?? null,\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const undo = extractUndoPayload<UndoPayload<MessageAggregateSnapshot>>(logEntry)\n const after = undo?.after\n if (!after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await em.findOne(Message, { id: after.message.id })\n if (!message) return\n message.deletedAt = new Date()\n await em.flush()\n await emitMessageGloballyDeletedEvent(ctx.container, {\n messageId: after.message.id,\n actorUserId: after.message.senderUserId,\n recipientUserIds: after.recipients.map((recipient) => recipient.recipientUserId),\n tenantId: after.message.tenantId,\n organizationId: after.message.organizationId,\n })\n },\n}\n\nconst forwardMessageCommand: CommandHandler<unknown, { id: string; externalEmail: string | null; recipientUserIds: string[] }> = {\n id: 'messages.messages.forward',\n async execute(rawInput, ctx) {\n const input = forwardCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const original = await requireMessageById(em, input, input.messageId)\n const isRecipient = await em.findOne(MessageRecipient, {\n messageId: input.messageId,\n recipientUserId: input.userId,\n deletedAt: null,\n })\n if (original.senderUserId !== input.userId && !isRecipient) throw new Error('Access denied')\n\n const messageType = getMessageTypeOrDefault(original.type)\n if (messageType.allowForward === false) throw new Error('Forward is not allowed for this message type')\n\n const originalObjects = await em.find(MessageObject, { messageId: input.messageId })\n const forwardThreadSlice = await buildForwardThreadSlice(em, {\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n userId: input.userId,\n }, original)\n const generatedPreview = await buildForwardPreviewFromThreadSlice(em, {\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n userId: input.userId,\n }, original, forwardThreadSlice)\n const forwardedBody = typeof input.body === 'string'\n ? input.body\n : buildForwardBodyFromLegacyInput(generatedPreview.body, input.additionalBody)\n let newMessageId = ''\n let responseExternalEmail: string | null = null\n await em.transactional(async (trx) => {\n const newMessage = trx.create(Message, {\n type: original.type,\n visibility: original.visibility ?? null,\n sourceEntityType: original.sourceEntityType,\n sourceEntityId: original.sourceEntityId,\n externalEmail: original.externalEmail,\n externalName: original.externalName,\n threadId: original.threadId ?? original.id,\n parentMessageId: original.id,\n senderUserId: input.userId,\n subject: `Fwd: ${original.subject}`,\n body: forwardedBody,\n bodyFormat: original.bodyFormat,\n priority: original.priority,\n status: 'sent',\n isDraft: false,\n sentAt: new Date(),\n sendViaEmail: input.sendViaEmail,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n await trx.persist(newMessage).flush()\n for (const recipient of input.recipients) {\n trx.persist(trx.create(MessageRecipient, {\n messageId: newMessage.id,\n recipientUserId: recipient.userId,\n recipientType: recipient.type,\n status: 'unread',\n }))\n }\n for (const obj of originalObjects) {\n trx.persist(trx.create(MessageObject, {\n messageId: newMessage.id,\n entityModule: obj.entityModule,\n entityType: obj.entityType,\n entityId: obj.entityId,\n actionRequired: obj.actionRequired,\n actionType: obj.actionType,\n actionLabel: obj.actionLabel,\n entitySnapshot: obj.entitySnapshot,\n }))\n }\n await trx.flush()\n if (input.includeAttachments !== false) {\n await copyAttachmentsForForwardMessages(\n trx,\n forwardThreadSlice.map((item) => item.id),\n newMessage.id,\n input.tenantId,\n )\n }\n newMessageId = newMessage.id\n responseExternalEmail = newMessage.externalEmail ?? null\n })\n\n await emitMessageSentEvent(ctx.container, {\n messageId: newMessageId,\n senderUserId: input.userId,\n recipientUserIds: input.recipients.map((item) => item.userId),\n sendViaEmail: input.sendViaEmail,\n externalEmail: responseExternalEmail,\n forwardedFrom: original.id,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n await emitMessageIndexUpsert(ctx.container, {\n messageId: newMessageId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n\n return {\n id: newMessageId,\n externalEmail: responseExternalEmail,\n recipientUserIds: input.recipients.map((item) => item.userId),\n }\n },\n async captureAfter(_input, result, ctx) {\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n return loadMessageAggregateSnapshot(em, result.id)\n },\n buildLog: async ({ input, result, snapshots }) => {\n const parsed = forwardCommandSchema.parse(input)\n return {\n actionLabel: 'Forward message',\n resourceKind: 'messages.message',\n resourceId: result.id,\n parentResourceKind: 'messages.message',\n parentResourceId: parsed.messageId,\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n payload: {\n undo: {\n after: (snapshots.after as MessageAggregateSnapshot | undefined) ?? null,\n } satisfies UndoPayload<MessageAggregateSnapshot>,\n },\n snapshotAfter: snapshots.after ?? null,\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const undo = extractUndoPayload<UndoPayload<MessageAggregateSnapshot>>(logEntry)\n const after = undo?.after\n if (!after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await em.findOne(Message, { id: after.message.id })\n if (!message) return\n message.deletedAt = new Date()\n await em.flush()\n await emitMessageGloballyDeletedEvent(ctx.container, {\n messageId: after.message.id,\n actorUserId: after.message.senderUserId,\n recipientUserIds: after.recipients.map((recipient) => recipient.recipientUserId),\n tenantId: after.message.tenantId,\n organizationId: after.message.organizationId,\n })\n },\n}\n\nconst deleteForActorCommand: CommandHandler<unknown, { ok: true }> = {\n id: 'messages.messages.delete_for_actor',\n async prepare(rawInput, ctx) {\n const input = deleteForActorCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await requireMessageById(em, input, input.messageId)\n const recipient = await em.findOne(MessageRecipient, {\n messageId: input.messageId,\n recipientUserId: input.userId,\n deletedAt: null,\n })\n return {\n before: {\n messageId: message.id,\n messageDeletedAt: toIso(message.deletedAt),\n recipientId: recipient?.id ?? null,\n recipientStatus: recipient?.status ?? null,\n recipientDeletedAt: toIso(recipient?.deletedAt),\n } satisfies MessageDeleteUndoState,\n }\n },\n async execute(rawInput, ctx) {\n const input = deleteForActorCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await requireMessageById(em, input, input.messageId)\n const recipient = await em.findOne(MessageRecipient, {\n messageId: input.messageId,\n recipientUserId: input.userId,\n deletedAt: null,\n })\n if (recipient) {\n recipient.status = 'deleted'\n recipient.deletedAt = new Date()\n await em.flush()\n await emitMessageDeletedEvent(ctx.container, {\n messageId: input.messageId,\n actorUserId: input.userId,\n target: 'recipient',\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n return { ok: true }\n }\n if (message.senderUserId === input.userId) {\n const recipientRows = await em.find(MessageRecipient, { messageId: input.messageId })\n message.deletedAt = new Date()\n await em.flush()\n const recipientUserIds = recipientRows\n .map((row) => row.recipientUserId)\n .filter((value): value is string => typeof value === 'string' && value.length > 0)\n await emitMessageGloballyDeletedEvent(ctx.container, {\n messageId: input.messageId,\n actorUserId: input.userId,\n recipientUserIds,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n return { ok: true }\n }\n throw new Error('Access denied')\n },\n async captureAfter(rawInput, _result, ctx) {\n const input = deleteForActorCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await em.findOne(Message, { id: input.messageId, tenantId: input.tenantId })\n const recipient = await em.findOne(MessageRecipient, {\n messageId: input.messageId,\n recipientUserId: input.userId,\n })\n return {\n messageId: input.messageId,\n messageDeletedAt: toIso(message?.deletedAt),\n recipientId: recipient?.id ?? null,\n recipientStatus: recipient?.status ?? null,\n recipientDeletedAt: toIso(recipient?.deletedAt),\n } satisfies MessageDeleteUndoState\n },\n buildLog: async ({ input, snapshots }) => {\n const parsed = deleteForActorCommandSchema.parse(input)\n return {\n actionLabel: 'Delete message for actor',\n resourceKind: 'messages.message',\n resourceId: parsed.messageId,\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n payload: {\n undo: {\n before: (snapshots.before as MessageDeleteUndoState | undefined) ?? null,\n after: (snapshots.after as MessageDeleteUndoState | undefined) ?? null,\n } satisfies UndoPayload<MessageDeleteUndoState>,\n },\n snapshotBefore: snapshots.before ?? null,\n snapshotAfter: snapshots.after ?? null,\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const undo = extractUndoPayload<UndoPayload<MessageDeleteUndoState>>(logEntry)\n const before = undo?.before\n if (!before) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await em.findOne(Message, { id: before.messageId })\n if (message) {\n message.deletedAt = toDate(before.messageDeletedAt)\n }\n if (before.recipientId) {\n const recipient = await em.findOne(MessageRecipient, { id: before.recipientId })\n if (recipient) {\n recipient.status = (before.recipientStatus ?? 'unread') as MessageRecipient['status']\n recipient.deletedAt = toDate(before.recipientDeletedAt)\n }\n }\n await em.flush()\n },\n}\n\nregisterCommand(composeMessageCommand)\nregisterCommand(updateDraftCommand)\nregisterCommand(replyMessageCommand)\nregisterCommand(forwardMessageCommand)\nregisterCommand(deleteForActorCommand)\n"],
5
- "mappings": "AACA,SAAS,SAAS;AAClB,SAAS,uBAA4C;AACrD,SAAS,uBAAuB;AAChC,SAAS,0BAA4C;AACrD,SAAS,uBAAuB,0BAA0B;AAC1D,SAAS,SAAS,eAAe,wBAAgD;AACjF,SAAS,yBAAyB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B,iCAAiC,yCAAyC;AAC7G,SAAS,8BAA8B,yBAAyB;AAChE,SAAS,+BAA+B;AACxC,SAAS,qCAAqC;AAC9C,SAAS,iCAAiC,oCAAoC,+BAA+B;AAC7G;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAA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
4
+ "sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { z } from 'zod'\nimport { registerCommand, type CommandHandler, type CommandRuntimeContext } from '@open-mercato/shared/lib/commands'\nimport { withAtomicFlush } from '@open-mercato/shared/lib/commands/flush'\nimport { extractUndoPayload, type UndoPayload } from '@open-mercato/shared/lib/commands/undo'\nimport { findOneWithDecryption, findWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { Message, MessageObject, MessageRecipient, type MessageActionData } from '../data/entities'\nimport { emitMessagesEvent } from '../events'\nimport {\n composeMessageSchema,\n forwardMessageSchema,\n replyMessageSchema,\n updateDraftSchema,\n} from '../data/validators'\nimport { linkAttachmentsToMessage, linkLibraryAttachmentsToMessage, copyAttachmentsForForwardMessages } from '../lib/attachments'\nimport {\n EXTERNAL_CONVERSATION_SOURCE_ENTITY_TYPE,\n resolveActorFeatures,\n resolveMessageChannelThreadAccess,\n} from '../lib/channelThreadAccess'\nimport { MESSAGE_ATTACHMENT_ENTITY_ID, MESSAGE_ENTITY_ID } from '../lib/constants'\nimport { canUseChannelThreadFallback } from '../lib/routeHelpers'\nimport { getMessageTypeOrDefault } from '../lib/message-types-registry'\nimport { validateMessageObjectsForType } from '../lib/object-validation'\nimport { buildForwardBodyFromLegacyInput, buildForwardPreviewFromThreadSlice, buildForwardThreadSlice } from '../lib/forwarding'\nimport {\n assertOrganizationAccess,\n loadMessageAggregateSnapshot,\n restoreMessageAggregateSnapshot,\n type MessageAggregateSnapshot,\n type MessageScopeInput,\n} from './shared'\n\ntype MessageSentEventPayload = {\n messageId: string\n senderUserId: string\n recipientUserIds: string[]\n sendViaEmail: boolean\n /**\n * The message arrived from an external channel (#6093). Its `senderUserId`\n * is the channel's system user and its real correspondent lives in\n * `externalName` / `externalEmail`; subscribers that show a sender read it\n * from there.\n */\n inboundFromChannel?: boolean\n externalEmail?: string | null\n forwardedFrom?: string\n replyTo?: string\n tenantId: string\n organizationId?: string | null\n}\n\ntype ContainerWithResolve = {\n resolve: (name: string) => unknown\n}\n\nasync function emitMessageSentEvent(_container: ContainerWithResolve, payload: MessageSentEventPayload) {\n await emitMessagesEvent('messages.message.sent', payload, { persistent: true })\n}\n\nasync function emitMessageDeletedEvent(_container: ContainerWithResolve, payload: {\n messageId: string\n actorUserId: string\n target: 'sender' | 'recipient'\n tenantId: string\n organizationId: string | null\n}) {\n await emitMessagesEvent(\n 'messages.message.deleted',\n { ...payload, recipientUserId: payload.actorUserId },\n { persistent: true },\n )\n}\n\nasync function emitMessageGloballyDeletedEvent(_container: ContainerWithResolve, payload: {\n messageId: string\n actorUserId: string\n recipientUserIds: string[]\n tenantId: string\n organizationId: string | null\n}) {\n const audience = Array.from(new Set([payload.actorUserId, ...payload.recipientUserIds]))\n await emitMessagesEvent(\n 'messages.message.deleted',\n {\n messageId: payload.messageId,\n actorUserId: payload.actorUserId,\n target: 'global',\n recipientUserIds: audience,\n tenantId: payload.tenantId,\n organizationId: payload.organizationId,\n },\n { persistent: true },\n )\n}\n\nasync function emitMessageIndexUpsert(\n container: ContainerWithResolve,\n payload: {\n messageId: string\n tenantId: string\n organizationId: string | null\n },\n) {\n let bus: { emitEvent: (name: string, body: unknown, options?: unknown) => Promise<void> } | null = null\n try {\n bus = container.resolve('eventBus') as { emitEvent: (name: string, body: unknown, options?: unknown) => Promise<void> }\n } catch {\n bus = null\n }\n\n if (!bus) return\n\n await bus.emitEvent(\n 'query_index.upsert_one',\n {\n entityType: MESSAGE_ENTITY_ID,\n recordId: payload.messageId,\n tenantId: payload.tenantId,\n organizationId: payload.organizationId,\n crudAction: 'updated',\n coverageBaseDelta: 1,\n },\n {\n tenantId: payload.tenantId,\n organizationId: payload.organizationId,\n },\n ).catch(() => undefined)\n}\n\nconst scopeSchema = z.object({\n tenantId: z.string().uuid(),\n organizationId: z.string().uuid().nullable(),\n userId: z.string().uuid(),\n})\n\nconst composeCommandSchema = composeMessageSchema.safeExtend({\n tenantId: scopeSchema.shape.tenantId,\n organizationId: scopeSchema.shape.organizationId,\n userId: scopeSchema.shape.userId,\n // Optional dedup key (inbound email ingest sets it; other callers leave it\n // undefined). When set, a re-issued compose returns the first message instead\n // of creating a duplicate.\n idempotencyKey: z.string().min(1).max(255).optional(),\n})\n\nconst updateDraftCommandSchema = updateDraftSchema.safeExtend({\n messageId: z.string().uuid(),\n tenantId: scopeSchema.shape.tenantId,\n organizationId: scopeSchema.shape.organizationId,\n userId: scopeSchema.shape.userId,\n})\n\nconst replyCommandSchema = replyMessageSchema.safeExtend({\n messageId: z.string().uuid(),\n tenantId: scopeSchema.shape.tenantId,\n organizationId: scopeSchema.shape.organizationId,\n userId: scopeSchema.shape.userId,\n})\n\nconst forwardCommandSchema = forwardMessageSchema.safeExtend({\n messageId: z.string().uuid(),\n tenantId: scopeSchema.shape.tenantId,\n organizationId: scopeSchema.shape.organizationId,\n userId: scopeSchema.shape.userId,\n})\n\nconst deleteForActorCommandSchema = z.object({\n messageId: z.string().uuid(),\n tenantId: scopeSchema.shape.tenantId,\n organizationId: scopeSchema.shape.organizationId,\n userId: scopeSchema.shape.userId,\n})\n\ntype ComposeCommandInput = z.infer<typeof composeCommandSchema>\ntype UpdateDraftCommandInput = z.infer<typeof updateDraftCommandSchema>\ntype ReplyCommandInput = z.infer<typeof replyCommandSchema>\ntype ForwardCommandInput = z.infer<typeof forwardCommandSchema>\ntype DeleteForActorCommandInput = z.infer<typeof deleteForActorCommandSchema>\n\ntype MessageDeleteUndoState = {\n messageId: string\n messageDeletedAt: string | null\n recipientId: string | null\n recipientStatus: 'unread' | 'read' | 'archived' | 'deleted' | null\n recipientDeletedAt: string | null\n}\n\nfunction toIso(value: Date | null | undefined): string | null {\n return value ? value.toISOString() : null\n}\n\nfunction toDate(value: string | null | undefined): Date | null {\n if (!value) return null\n return new Date(value)\n}\n\nfunction buildReplySubject(subject: string): string {\n if (/^re:\\s*/i.test(subject)) return subject\n return `Re: ${subject}`\n}\n\nasync function requireMessageById(\n em: EntityManager,\n scope: MessageScopeInput,\n messageId: string,\n) {\n const message = await findOneWithDecryption(\n em,\n Message,\n {\n id: messageId,\n tenantId: scope.tenantId,\n deletedAt: null,\n },\n undefined,\n {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n },\n )\n if (!message) throw new Error('Message not found')\n assertOrganizationAccess(scope, message)\n return message\n}\n\nfunction isUniqueViolation(err: unknown): boolean {\n if (!err || typeof err !== 'object') return false\n const code = (err as { code?: string }).code\n if (code === '23505') return true\n const message = (err as { message?: string }).message\n return typeof message === 'string' && /duplicate key value|unique constraint/i.test(message)\n}\n\ntype ComposeMessageResult = {\n id: string\n threadId: string | null\n externalEmail: string | null\n isDraft: boolean\n recipientUserIds: string[]\n /**\n * True when this was an idempotent replay \u2014 an existing message was returned\n * and nothing was written. Signals `buildLog` to skip the audit/undo entry.\n */\n deduplicated?: boolean\n}\n\nasync function buildComposeResultFromExisting(\n em: EntityManager,\n message: Message,\n): Promise<ComposeMessageResult> {\n const recipients = await findWithDecryption(\n em,\n MessageRecipient,\n { messageId: message.id, deletedAt: null },\n undefined,\n { tenantId: message.tenantId, organizationId: message.organizationId ?? null },\n )\n return {\n id: message.id,\n threadId: message.threadId ?? null,\n externalEmail: message.externalEmail ?? null,\n isDraft: message.isDraft,\n recipientUserIds: recipients.map((recipient) => recipient.recipientUserId),\n deduplicated: true,\n }\n}\n\nconst composeMessageCommand: CommandHandler<unknown, { id: string; threadId: string | null; externalEmail: string | null; isDraft: boolean; recipientUserIds: string[]; deduplicated?: boolean }> = {\n id: 'messages.messages.compose',\n async execute(rawInput, ctx) {\n const input = composeCommandSchema.parse(rawInput)\n if (input.objects?.length) {\n const objectValidationError = validateMessageObjectsForType(input.type, input.objects)\n if (objectValidationError) throw new Error(objectValidationError)\n }\n\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const scope = { tenantId: input.tenantId, organizationId: input.organizationId }\n\n // Idempotency fast-path: a retried inbound-email ingest re-issues compose\n // for the same source message (the first attempt committed the message but a\n // downstream transient failure rolled the ingest back). Return that message\n // so the retry cannot create a duplicate.\n if (input.idempotencyKey) {\n const existing = await findOneWithDecryption(\n em,\n Message,\n { tenantId: input.tenantId, idempotencyKey: input.idempotencyKey },\n undefined,\n scope,\n )\n if (existing) return buildComposeResultFromExisting(em, existing)\n }\n\n let messageId = ''\n let responseThreadId: string | null = null\n let responseExternalEmail: string | null = null\n\n const composeTx = em.transactional(async (trx) => {\n const threadId = input.parentMessageId\n ? (\n await findOneWithDecryption(\n trx,\n Message,\n {\n id: input.parentMessageId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n deletedAt: null,\n },\n undefined,\n scope,\n )\n )?.threadId ?? input.parentMessageId\n : undefined\n\n const isPublicVisibility = input.visibility === 'public'\n // #6093: a channel-ingested message was RECEIVED, not sent. Ingest passes\n // `sendViaEmail: false` on purpose; forcing it for public visibility would\n // mail the assignee a copy and echo the message to its external sender\n // (#6089) the moment the recipients waiver lets it compose. #6090 removes\n // the forcing for every caller; until then it is skipped here for the\n // ingest path only.\n const sendViaEmail = isPublicVisibility && !input.inboundFromChannel ? true : input.sendViaEmail\n const message = trx.create(Message, {\n type: input.type,\n visibility: input.visibility ?? null,\n sourceEntityType: input.sourceEntityType,\n sourceEntityId: input.sourceEntityId,\n externalEmail: input.externalEmail,\n externalName: input.externalName,\n threadId: threadId ?? undefined,\n parentMessageId: input.parentMessageId,\n senderUserId: input.userId,\n subject: input.subject,\n body: input.body,\n bodyFormat: input.bodyFormat,\n priority: input.priority,\n status: input.isDraft ? 'draft' : 'sent',\n isDraft: input.isDraft ?? false,\n // #6095: channel ingest passes the provider's timestamp so an imported\n // mailbox sorts by when the mail was received, not when it was imported.\n sentAt: input.isDraft ? null : input.sentAt ?? new Date(),\n actionData: input.actionData as MessageActionData | undefined,\n sendViaEmail,\n idempotencyKey: input.idempotencyKey ?? null,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n\n await trx.persist(message).flush()\n if (!threadId && !input.isDraft && !message.threadId) {\n message.threadId = message.id\n await trx.flush()\n }\n\n for (const recipient of input.recipients) {\n trx.persist(trx.create(MessageRecipient, {\n messageId: message.id,\n recipientUserId: recipient.userId,\n recipientType: recipient.type,\n status: 'unread',\n }))\n }\n\n if (input.objects) {\n for (const obj of input.objects) {\n trx.persist(trx.create(MessageObject, {\n messageId: message.id,\n entityModule: obj.entityModule,\n entityType: obj.entityType,\n entityId: obj.entityId,\n actionRequired: obj.actionRequired,\n actionType: obj.actionType,\n actionLabel: obj.actionLabel,\n }))\n }\n }\n\n await trx.flush()\n\n if (input.attachmentIds?.length) {\n await linkAttachmentsToMessage(\n trx,\n message.id,\n input.attachmentIds,\n input.organizationId,\n input.tenantId,\n )\n }\n\n if (input.attachmentRecordId) {\n await linkLibraryAttachmentsToMessage(\n trx,\n message.id,\n input.attachmentRecordId,\n input.organizationId,\n input.tenantId,\n )\n }\n\n messageId = message.id\n responseThreadId = message.threadId ?? null\n responseExternalEmail = message.externalEmail ?? null\n })\n try {\n await composeTx\n } catch (err) {\n // Lost a concurrent race on the same idempotency key \u2014 return the message\n // the winning compose created. A propagated 23505 would otherwise be\n // classified permanent and dead-letter the inbound mail.\n if (input.idempotencyKey && isUniqueViolation(err)) {\n const existing = await findOneWithDecryption(\n em.fork(),\n Message,\n { tenantId: input.tenantId, idempotencyKey: input.idempotencyKey },\n undefined,\n scope,\n )\n if (existing) return buildComposeResultFromExisting(em.fork(), existing)\n }\n throw err\n }\n\n if (!input.isDraft) {\n await emitMessageSentEvent(ctx.container, {\n messageId,\n senderUserId: input.userId,\n recipientUserIds: input.recipients.map((recipient) => recipient.userId),\n sendViaEmail:\n input.visibility === 'public' && !input.inboundFromChannel ? true : input.sendViaEmail,\n inboundFromChannel: input.inboundFromChannel === true,\n externalEmail: responseExternalEmail,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n }\n\n await emitMessageIndexUpsert(ctx.container, {\n messageId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n\n return {\n id: messageId,\n threadId: responseThreadId,\n externalEmail: responseExternalEmail,\n isDraft: input.isDraft,\n recipientUserIds: input.recipients.map((recipient) => recipient.userId),\n }\n },\n async captureAfter(_input, result, ctx) {\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n return loadMessageAggregateSnapshot(em, result.id)\n },\n buildLog: async ({ input, result, snapshots }) => {\n // Idempotent replay: execute returned a pre-existing message without writing\n // anything. Skip the audit entry entirely \u2014 logging it as a fresh \"Compose\n // message\" would both misrepresent the dedup and expose an undo that\n // soft-deletes a legitimately-received inbound message.\n if (result.deduplicated) return { skipLog: true }\n const parsed = composeCommandSchema.parse(input)\n return {\n actionLabel: parsed.isDraft ? 'Create draft message' : 'Compose message',\n resourceKind: 'messages.message',\n resourceId: result.id,\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n payload: {\n undo: {\n after: (snapshots.after as MessageAggregateSnapshot | undefined) ?? null,\n } satisfies UndoPayload<MessageAggregateSnapshot>,\n },\n snapshotAfter: snapshots.after ?? null,\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const undo = extractUndoPayload<UndoPayload<MessageAggregateSnapshot>>(logEntry)\n const after = undo?.after\n if (!after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await em.findOne(Message, { id: after.message.id })\n if (!message) return\n message.deletedAt = new Date()\n await em.flush()\n if (!after.message.isDraft) {\n await emitMessageGloballyDeletedEvent(ctx.container, {\n messageId: after.message.id,\n actorUserId: after.message.senderUserId,\n recipientUserIds: after.recipients.map((recipient) => recipient.recipientUserId),\n tenantId: after.message.tenantId,\n organizationId: after.message.organizationId,\n })\n }\n },\n}\n\nconst updateDraftCommand: CommandHandler<unknown, { ok: true; id: string }> = {\n id: 'messages.messages.update_draft',\n async prepare(rawInput, ctx) {\n const input = updateDraftCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const snapshot = await loadMessageAggregateSnapshot(em, input.messageId, {\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n return snapshot ? { before: snapshot } : {}\n },\n async execute(rawInput, ctx) {\n const input = updateDraftCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await requireMessageById(em, input, input.messageId)\n\n if (message.senderUserId !== input.userId) throw new Error('Access denied')\n if (!message.isDraft) throw new Error('Only draft messages can be edited')\n\n const isSending = input.isDraft === false\n const preloadedRecipients = isSending && !input.recipients\n ? await findWithDecryption(\n em,\n MessageRecipient,\n { messageId: message.id, deletedAt: null },\n undefined,\n {\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n },\n )\n : null\n\n const nextMessageType = input.type ?? message.type\n if (input.objects) {\n const objectValidationError = validateMessageObjectsForType(nextMessageType, input.objects)\n if (objectValidationError) throw new Error(objectValidationError)\n } else if (input.type !== undefined) {\n const existingObjects = await em.find(MessageObject, { messageId: message.id })\n if (existingObjects.length > 0) {\n const objectValidationError = validateMessageObjectsForType(\n nextMessageType,\n existingObjects.map((item) => ({\n entityModule: item.entityModule,\n entityType: item.entityType,\n entityId: item.entityId,\n })),\n )\n if (objectValidationError) throw new Error(objectValidationError)\n }\n }\n\n // Validate the send transition BEFORE the atomic-flush block so a rejected\n // send never mutates or flushes anything (everything checked here is known\n // from the parsed input + the loaded message).\n if (isSending) {\n const finalVisibility = input.visibility ?? message.visibility\n const finalSubject = input.subject ?? message.subject\n const finalBody = input.body ?? message.body\n const finalRecipientCount = input.recipients\n ? input.recipients.length\n : (preloadedRecipients?.length ?? 0)\n if (finalVisibility !== 'public' && finalRecipientCount === 0) {\n throw new Error('at least one recipient is required')\n }\n if (!finalSubject?.trim()) throw new Error('subject is required')\n if (!finalBody?.trim()) throw new Error('body is required')\n }\n\n // Phase 1 mutates the managed `message` scalars; the per-phase flush issues\n // those changes before phase 2's interleaved reads run (e.g.\n // `linkAttachmentsToMessage` issues an `em.find`). Under MikroORM v7 a read\n // between a scalar mutation and the terminal flush on the same EntityManager\n // silently drops the pending changeset, so keeping the scalar edits in their\n // own phase guarantees subject/body/etc. are persisted (SPEC-018 Problem 1).\n await withAtomicFlush(em, [() => {\n if (input.type !== undefined) message.type = input.type\n if (input.visibility !== undefined) message.visibility = input.visibility\n if (input.sourceEntityType !== undefined) message.sourceEntityType = input.sourceEntityType\n if (input.sourceEntityId !== undefined) message.sourceEntityId = input.sourceEntityId\n if (input.externalEmail !== undefined) message.externalEmail = input.externalEmail\n if (input.externalName !== undefined) message.externalName = input.externalName\n if (input.subject !== undefined) message.subject = input.subject\n if (input.body !== undefined) message.body = input.body\n if (input.bodyFormat !== undefined) message.bodyFormat = input.bodyFormat\n if (input.priority !== undefined) message.priority = input.priority\n if (input.actionData !== undefined) message.actionData = input.actionData\n if (input.sendViaEmail !== undefined) message.sendViaEmail = input.sendViaEmail\n }, async () => {\n if (input.recipients) {\n await em.nativeDelete(MessageRecipient, { messageId: message.id })\n for (const recipient of input.recipients) {\n em.persist(em.create(MessageRecipient, {\n messageId: message.id,\n recipientUserId: recipient.userId,\n recipientType: recipient.type,\n status: 'unread',\n }))\n }\n }\n\n if (input.objects) {\n await em.nativeDelete(MessageObject, { messageId: message.id })\n for (const object of input.objects) {\n em.persist(em.create(MessageObject, {\n messageId: message.id,\n entityModule: object.entityModule,\n entityType: object.entityType,\n entityId: object.entityId,\n actionRequired: object.actionRequired,\n actionType: object.actionType,\n actionLabel: object.actionLabel,\n }))\n }\n }\n\n if (input.attachmentIds) {\n const { Attachment } = await import('@open-mercato/core/modules/attachments/data/entities')\n if (input.attachmentIds.length === 0) {\n await em.nativeDelete(Attachment, {\n entityId: MESSAGE_ATTACHMENT_ENTITY_ID,\n recordId: message.id,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n } else {\n await em.nativeDelete(Attachment, {\n entityId: MESSAGE_ATTACHMENT_ENTITY_ID,\n recordId: message.id,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n id: { $nin: input.attachmentIds },\n })\n }\n await linkAttachmentsToMessage(\n em,\n message.id,\n input.attachmentIds,\n input.organizationId,\n input.tenantId,\n )\n }\n\n if (isSending) {\n // Send transition was validated before the block; just apply the\n // status mutations here (persisted by this phase's boundary flush).\n message.isDraft = false\n message.status = 'sent'\n message.sentAt = new Date()\n if (!message.threadId) message.threadId = message.id\n }\n }], { transaction: true })\n\n await emitMessageIndexUpsert(ctx.container, {\n messageId: message.id,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n\n if (isSending) {\n const recipientUserIds = input.recipients\n ? input.recipients.map((r) => r.userId)\n : (preloadedRecipients ?? []).map((r) => r.recipientUserId)\n const resolvedVisibility = input.visibility ?? message.visibility\n const resolvedSendViaEmail = input.sendViaEmail ?? message.sendViaEmail\n await emitMessageSentEvent(ctx.container, {\n messageId: message.id,\n senderUserId: input.userId,\n recipientUserIds,\n sendViaEmail: resolvedVisibility === 'public' ? true : resolvedSendViaEmail,\n externalEmail: message.externalEmail ?? null,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n }\n\n return { ok: true, id: message.id }\n },\n async captureAfter(rawInput, _result, ctx) {\n const input = updateDraftCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n return loadMessageAggregateSnapshot(em, input.messageId, {\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n },\n buildLog: async ({ input, snapshots }) => {\n const parsed = updateDraftCommandSchema.parse(input)\n return {\n actionLabel: parsed.isDraft === false ? 'Send draft message' : 'Update draft message',\n resourceKind: 'messages.message',\n resourceId: parsed.messageId,\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n payload: {\n undo: {\n before: (snapshots.before as MessageAggregateSnapshot | undefined) ?? null,\n after: (snapshots.after as MessageAggregateSnapshot | undefined) ?? null,\n } satisfies UndoPayload<MessageAggregateSnapshot>,\n },\n snapshotBefore: snapshots.before ?? null,\n snapshotAfter: snapshots.after ?? null,\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const undo = extractUndoPayload<UndoPayload<MessageAggregateSnapshot>>(logEntry)\n const before = undo?.before\n if (!before) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n await restoreMessageAggregateSnapshot(em, before)\n },\n}\n\n/**\n * The channel-thread fallback for a non-participant acting on `original`\n * (#5535): the channels hub decides whether the caller may work the thread.\n * An internal thread resolves to `null` and denies, leaving the participant\n * rule in force. Only an explicitly public message qualifies \u2014 channel access\n * never opens another operator's internal note, matching the detail read.\n *\n * The same `messages.view` gate as the read routes applies, because the hub\n * grants every shared channel regardless of features: without it, a caller\n * holding only `messages.compose` could forward a conversation it may not read\n * to itself and read it as the recipient.\n */\nasync function canActOnChannelThreadMessage(\n ctx: CommandRuntimeContext,\n input: { tenantId: string; organizationId?: string | null; userId: string },\n original: Message,\n): Promise<boolean> {\n if (original.visibility !== 'public') return false\n const scope = { tenantId: input.tenantId, organizationId: input.organizationId ?? null, userId: input.userId }\n if (!(await canUseChannelThreadFallback(ctx, scope))) return false\n const channelThread = await resolveMessageChannelThreadAccess(\n ctx.container,\n { tenantId: input.tenantId, organizationId: input.organizationId ?? null },\n { messageThreadId: original.threadId ?? original.id },\n { userId: input.userId, features: resolveActorFeatures(ctx.auth) },\n )\n return channelThread?.canAccess === true\n}\n\nasync function isOnChannelThread(\n ctx: CommandRuntimeContext,\n input: { tenantId: string; organizationId?: string | null; userId: string },\n original: Message,\n): Promise<boolean> {\n if (original.sourceEntityType === EXTERNAL_CONVERSATION_SOURCE_ENTITY_TYPE) return true\n const channelThread = await resolveMessageChannelThreadAccess(\n ctx.container,\n { tenantId: input.tenantId, organizationId: input.organizationId ?? null },\n { messageThreadId: original.threadId ?? original.id },\n { userId: input.userId, features: resolveActorFeatures(ctx.auth) },\n )\n return channelThread !== null\n}\n\nconst replyMessageCommand: CommandHandler<unknown, { id: string; externalEmail: string | null; recipientUserIds: string[] }> = {\n id: 'messages.messages.reply',\n async execute(rawInput, ctx) {\n const input = replyCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const original = await requireMessageById(em, input, input.messageId)\n const ownRecipient = await em.findOne(MessageRecipient, {\n messageId: original.id,\n recipientUserId: input.userId,\n deletedAt: null,\n })\n if (original.senderUserId !== input.userId && !ownRecipient) {\n // A message that arrived over a communication channel has no platform\n // participant to match: its sender is the channel system user and an\n // unassigned conversation produces no recipient rows, so the\n // sender-or-recipient test denies every operator \u2014 a tenant admin\n // included (#5535). For a thread the channels hub owns, that hub's own\n // access rule is the applicable one; an internal thread resolves to\n // `null` here and keeps the participant rule unchanged.\n if (!(await canActOnChannelThreadMessage(ctx, input, original))) throw new Error('Access denied')\n }\n\n const messageType = getMessageTypeOrDefault(original.type)\n if (messageType.allowReply === false) throw new Error('Reply is not allowed for this message type')\n\n const recipientIds = new Set(\n (input.recipients ?? [])\n .map((recipient) => recipient.userId)\n .filter((recipientUserId) => recipientUserId !== input.userId),\n )\n\n if (recipientIds.size === 0) {\n const originalRecipients = await em.find(MessageRecipient, { messageId: original.id, deletedAt: null })\n if (input.replyAll) {\n if (original.senderUserId !== input.userId) recipientIds.add(original.senderUserId)\n for (const recipient of originalRecipients) {\n if (recipient.recipientUserId !== input.userId) recipientIds.add(recipient.recipientUserId)\n }\n } else if (original.senderUserId !== input.userId) {\n recipientIds.add(original.senderUserId)\n } else {\n for (const recipient of originalRecipients) {\n if (recipient.recipientUserId !== input.userId) {\n recipientIds.add(recipient.recipientUserId)\n break\n }\n }\n }\n\n if (recipientIds.size === 0 && original.senderUserId === input.userId) {\n recipientIds.add(input.userId)\n }\n }\n if (recipientIds.size === 0) throw new Error('No recipients available for reply')\n\n let messageId = ''\n let responseExternalEmail: string | null = null\n await em.transactional(async (trx) => {\n const message = trx.create(Message, {\n type: original.type,\n visibility: original.visibility ?? null,\n sourceEntityType: original.sourceEntityType,\n sourceEntityId: original.sourceEntityId,\n externalEmail: original.externalEmail,\n externalName: original.externalName,\n threadId: original.threadId ?? original.id,\n parentMessageId: original.id,\n senderUserId: input.userId,\n subject: buildReplySubject(original.subject),\n body: input.body,\n bodyFormat: input.bodyFormat,\n priority: original.priority,\n status: 'sent',\n isDraft: false,\n sentAt: new Date(),\n sendViaEmail: input.sendViaEmail,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n await trx.persist(message).flush()\n for (const recipientUserId of recipientIds) {\n trx.persist(trx.create(MessageRecipient, {\n messageId: message.id,\n recipientUserId,\n recipientType: 'to',\n status: 'unread',\n }))\n }\n await trx.flush()\n if (input.attachmentIds?.length) {\n await linkAttachmentsToMessage(\n trx,\n message.id,\n input.attachmentIds,\n input.organizationId,\n input.tenantId,\n )\n }\n if (input.attachmentRecordId) {\n await linkLibraryAttachmentsToMessage(\n trx,\n message.id,\n input.attachmentRecordId,\n input.organizationId,\n input.tenantId,\n )\n }\n messageId = message.id\n responseExternalEmail = message.externalEmail ?? null\n })\n\n await emitMessageSentEvent(ctx.container, {\n messageId,\n senderUserId: input.userId,\n recipientUserIds: Array.from(recipientIds),\n sendViaEmail: input.sendViaEmail,\n externalEmail: responseExternalEmail,\n replyTo: original.id,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n await emitMessageIndexUpsert(ctx.container, {\n messageId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n\n return {\n id: messageId,\n externalEmail: responseExternalEmail,\n recipientUserIds: Array.from(recipientIds),\n }\n },\n async captureAfter(_input, result, ctx) {\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n return loadMessageAggregateSnapshot(em, result.id)\n },\n buildLog: async ({ input, result, snapshots }) => {\n const parsed = replyCommandSchema.parse(input)\n return {\n actionLabel: 'Reply to message',\n resourceKind: 'messages.message',\n resourceId: result.id,\n parentResourceKind: 'messages.message',\n parentResourceId: parsed.messageId,\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n payload: {\n undo: {\n after: (snapshots.after as MessageAggregateSnapshot | undefined) ?? null,\n } satisfies UndoPayload<MessageAggregateSnapshot>,\n },\n snapshotAfter: snapshots.after ?? null,\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const undo = extractUndoPayload<UndoPayload<MessageAggregateSnapshot>>(logEntry)\n const after = undo?.after\n if (!after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await em.findOne(Message, { id: after.message.id })\n if (!message) return\n message.deletedAt = new Date()\n await em.flush()\n await emitMessageGloballyDeletedEvent(ctx.container, {\n messageId: after.message.id,\n actorUserId: after.message.senderUserId,\n recipientUserIds: after.recipients.map((recipient) => recipient.recipientUserId),\n tenantId: after.message.tenantId,\n organizationId: after.message.organizationId,\n })\n },\n}\n\nconst forwardMessageCommand: CommandHandler<unknown, { id: string; externalEmail: string | null; recipientUserIds: string[] }> = {\n id: 'messages.messages.forward',\n async execute(rawInput, ctx) {\n const input = forwardCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const original = await requireMessageById(em, input, input.messageId)\n const isRecipient = await em.findOne(MessageRecipient, {\n messageId: input.messageId,\n recipientUserId: input.userId,\n deletedAt: null,\n })\n // Same fallback as the reply command (#6355): an operator who may answer an\n // inbound channel message may also forward it internally.\n const viaChannelThread = original.senderUserId !== input.userId && !isRecipient\n if (viaChannelThread && !(await canActOnChannelThreadMessage(ctx, input, original))) {\n throw new Error('Access denied')\n }\n\n const messageType = getMessageTypeOrDefault(original.type)\n if (messageType.allowForward === false) throw new Error('Forward is not allowed for this message type')\n\n const originalObjects = await em.find(MessageObject, { messageId: input.messageId })\n const forwardThreadSlice = await buildForwardThreadSlice(em, {\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n userId: input.userId,\n }, original, { includePublicThreadMessages: viaChannelThread })\n const generatedPreview = await buildForwardPreviewFromThreadSlice(em, {\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n userId: input.userId,\n }, original, forwardThreadSlice)\n const forwardedBody = typeof input.body === 'string'\n ? input.body\n : buildForwardBodyFromLegacyInput(generatedPreview.body, input.additionalBody)\n // A forward of a channel conversation is addressed to colleagues, never to\n // the correspondent. The channels bridge already refuses `forwardedFrom`, but\n // the messages email path would still mail `externalEmail` on\n // `sendViaEmail` \u2014 so the customer's address is not carried onto it.\n // It is also filed as internal: replies copy their parent's visibility and\n // carry no `forwardedFrom`, so a public forward made every reply under it\n // deliverable to the correspondent (#6431, #6428). The bridge routes on the\n // thread, not the source, and some public messages on a channel thread\n // carry no source type (an AI or parented compose), so the thread decides.\n const keepsExternalCorrespondent = !(await isOnChannelThread(ctx, input, original))\n let newMessageId = ''\n let responseExternalEmail: string | null = null\n await em.transactional(async (trx) => {\n const newMessage = trx.create(Message, {\n type: original.type,\n visibility: keepsExternalCorrespondent ? original.visibility ?? null : 'internal',\n sourceEntityType: original.sourceEntityType,\n sourceEntityId: original.sourceEntityId,\n externalEmail: keepsExternalCorrespondent ? original.externalEmail : null,\n externalName: keepsExternalCorrespondent ? original.externalName : null,\n threadId: original.threadId ?? original.id,\n parentMessageId: original.id,\n senderUserId: input.userId,\n subject: `Fwd: ${original.subject}`,\n body: forwardedBody,\n bodyFormat: original.bodyFormat,\n priority: original.priority,\n status: 'sent',\n isDraft: false,\n sentAt: new Date(),\n sendViaEmail: input.sendViaEmail,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n await trx.persist(newMessage).flush()\n for (const recipient of input.recipients) {\n trx.persist(trx.create(MessageRecipient, {\n messageId: newMessage.id,\n recipientUserId: recipient.userId,\n recipientType: recipient.type,\n status: 'unread',\n }))\n }\n for (const obj of originalObjects) {\n trx.persist(trx.create(MessageObject, {\n messageId: newMessage.id,\n entityModule: obj.entityModule,\n entityType: obj.entityType,\n entityId: obj.entityId,\n actionRequired: obj.actionRequired,\n actionType: obj.actionType,\n actionLabel: obj.actionLabel,\n entitySnapshot: obj.entitySnapshot,\n }))\n }\n await trx.flush()\n if (input.includeAttachments !== false) {\n await copyAttachmentsForForwardMessages(\n trx,\n forwardThreadSlice.map((item) => item.id),\n newMessage.id,\n input.tenantId,\n )\n }\n newMessageId = newMessage.id\n responseExternalEmail = newMessage.externalEmail ?? null\n })\n\n await emitMessageSentEvent(ctx.container, {\n messageId: newMessageId,\n senderUserId: input.userId,\n recipientUserIds: input.recipients.map((item) => item.userId),\n sendViaEmail: input.sendViaEmail,\n externalEmail: responseExternalEmail,\n forwardedFrom: original.id,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n await emitMessageIndexUpsert(ctx.container, {\n messageId: newMessageId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n\n return {\n id: newMessageId,\n externalEmail: responseExternalEmail,\n recipientUserIds: input.recipients.map((item) => item.userId),\n }\n },\n async captureAfter(_input, result, ctx) {\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n return loadMessageAggregateSnapshot(em, result.id)\n },\n buildLog: async ({ input, result, snapshots }) => {\n const parsed = forwardCommandSchema.parse(input)\n return {\n actionLabel: 'Forward message',\n resourceKind: 'messages.message',\n resourceId: result.id,\n parentResourceKind: 'messages.message',\n parentResourceId: parsed.messageId,\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n payload: {\n undo: {\n after: (snapshots.after as MessageAggregateSnapshot | undefined) ?? null,\n } satisfies UndoPayload<MessageAggregateSnapshot>,\n },\n snapshotAfter: snapshots.after ?? null,\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const undo = extractUndoPayload<UndoPayload<MessageAggregateSnapshot>>(logEntry)\n const after = undo?.after\n if (!after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await em.findOne(Message, { id: after.message.id })\n if (!message) return\n message.deletedAt = new Date()\n await em.flush()\n await emitMessageGloballyDeletedEvent(ctx.container, {\n messageId: after.message.id,\n actorUserId: after.message.senderUserId,\n recipientUserIds: after.recipients.map((recipient) => recipient.recipientUserId),\n tenantId: after.message.tenantId,\n organizationId: after.message.organizationId,\n })\n },\n}\n\nconst deleteForActorCommand: CommandHandler<unknown, { ok: true }> = {\n id: 'messages.messages.delete_for_actor',\n async prepare(rawInput, ctx) {\n const input = deleteForActorCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await requireMessageById(em, input, input.messageId)\n const recipient = await em.findOne(MessageRecipient, {\n messageId: input.messageId,\n recipientUserId: input.userId,\n deletedAt: null,\n })\n return {\n before: {\n messageId: message.id,\n messageDeletedAt: toIso(message.deletedAt),\n recipientId: recipient?.id ?? null,\n recipientStatus: recipient?.status ?? null,\n recipientDeletedAt: toIso(recipient?.deletedAt),\n } satisfies MessageDeleteUndoState,\n }\n },\n async execute(rawInput, ctx) {\n const input = deleteForActorCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await requireMessageById(em, input, input.messageId)\n const recipient = await em.findOne(MessageRecipient, {\n messageId: input.messageId,\n recipientUserId: input.userId,\n deletedAt: null,\n })\n if (recipient) {\n recipient.status = 'deleted'\n recipient.deletedAt = new Date()\n await em.flush()\n await emitMessageDeletedEvent(ctx.container, {\n messageId: input.messageId,\n actorUserId: input.userId,\n target: 'recipient',\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n return { ok: true }\n }\n if (message.senderUserId === input.userId) {\n const recipientRows = await em.find(MessageRecipient, { messageId: input.messageId })\n message.deletedAt = new Date()\n await em.flush()\n const recipientUserIds = recipientRows\n .map((row) => row.recipientUserId)\n .filter((value): value is string => typeof value === 'string' && value.length > 0)\n await emitMessageGloballyDeletedEvent(ctx.container, {\n messageId: input.messageId,\n actorUserId: input.userId,\n recipientUserIds,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n })\n return { ok: true }\n }\n throw new Error('Access denied')\n },\n async captureAfter(rawInput, _result, ctx) {\n const input = deleteForActorCommandSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await em.findOne(Message, { id: input.messageId, tenantId: input.tenantId })\n const recipient = await em.findOne(MessageRecipient, {\n messageId: input.messageId,\n recipientUserId: input.userId,\n })\n return {\n messageId: input.messageId,\n messageDeletedAt: toIso(message?.deletedAt),\n recipientId: recipient?.id ?? null,\n recipientStatus: recipient?.status ?? null,\n recipientDeletedAt: toIso(recipient?.deletedAt),\n } satisfies MessageDeleteUndoState\n },\n buildLog: async ({ input, snapshots }) => {\n const parsed = deleteForActorCommandSchema.parse(input)\n return {\n actionLabel: 'Delete message for actor',\n resourceKind: 'messages.message',\n resourceId: parsed.messageId,\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n payload: {\n undo: {\n before: (snapshots.before as MessageDeleteUndoState | undefined) ?? null,\n after: (snapshots.after as MessageDeleteUndoState | undefined) ?? null,\n } satisfies UndoPayload<MessageDeleteUndoState>,\n },\n snapshotBefore: snapshots.before ?? null,\n snapshotAfter: snapshots.after ?? null,\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const undo = extractUndoPayload<UndoPayload<MessageDeleteUndoState>>(logEntry)\n const before = undo?.before\n if (!before) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const message = await em.findOne(Message, { id: before.messageId })\n if (message) {\n message.deletedAt = toDate(before.messageDeletedAt)\n }\n if (before.recipientId) {\n const recipient = await em.findOne(MessageRecipient, { id: before.recipientId })\n if (recipient) {\n recipient.status = (before.recipientStatus ?? 'unread') as MessageRecipient['status']\n recipient.deletedAt = toDate(before.recipientDeletedAt)\n }\n }\n await em.flush()\n },\n}\n\nregisterCommand(composeMessageCommand)\nregisterCommand(updateDraftCommand)\nregisterCommand(replyMessageCommand)\nregisterCommand(forwardMessageCommand)\nregisterCommand(deleteForActorCommand)\n"],
5
+ "mappings": "AACA,SAAS,SAAS;AAClB,SAAS,uBAAwE;AACjF,SAAS,uBAAuB;AAChC,SAAS,0BAA4C;AACrD,SAAS,uBAAuB,0BAA0B;AAC1D,SAAS,SAAS,eAAe,wBAAgD;AACjF,SAAS,yBAAyB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B,iCAAiC,yCAAyC;AAC7G;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B,yBAAyB;AAChE,SAAS,mCAAmC;AAC5C,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gBAAgB,qBAAqB;",
6
6
  "names": []
7
7
  }
@@ -1,11 +1,33 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
3
4
  import { useRouter } from "next/navigation";
4
5
  import { extensionPoints } from "@open-mercato/core/modules/messages/extension-points";
5
6
  import { MessageComposer } from "@open-mercato/ui/backend/messages";
7
+ import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
8
+ import { toComposeSenderOptions } from "@open-mercato/core/modules/messages/lib/composeSenderOptions";
6
9
  import { InjectionSpot } from "@open-mercato/ui/backend/injection/InjectionSpot";
7
10
  function ComposeMessagePageClient() {
8
11
  const router = useRouter();
12
+ const [senderOptions, setSenderOptions] = React.useState([]);
13
+ React.useEffect(() => {
14
+ let cancelled = false;
15
+ void (async () => {
16
+ try {
17
+ const response = await apiCall(
18
+ "/api/communication_channels/me/channels",
19
+ { method: "GET", headers: { "x-om-forbidden-redirect": "0", "x-om-unauthorized-redirect": "0" } }
20
+ );
21
+ if (cancelled || !response.ok) return;
22
+ setSenderOptions(toComposeSenderOptions(response.result?.items));
23
+ } catch {
24
+ if (!cancelled) setSenderOptions([]);
25
+ }
26
+ })();
27
+ return () => {
28
+ cancelled = true;
29
+ };
30
+ }, []);
9
31
  return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
10
32
  /* @__PURE__ */ jsx(
11
33
  InjectionSpot,
@@ -20,10 +42,11 @@ function ComposeMessagePageClient() {
20
42
  {
21
43
  inline: true,
22
44
  variant: "compose",
45
+ senderOptions,
23
46
  onCancel: () => {
24
47
  router.push("/backend/messages");
25
48
  },
26
- onSuccess: (result) => {
49
+ onSuccess: () => {
27
50
  router.push("/backend/messages");
28
51
  }
29
52
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/messages/components/ComposeMessagePageClient.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport { useRouter } from 'next/navigation'\nimport { extensionPoints } from '@open-mercato/core/modules/messages/extension-points'\nimport { MessageComposer } from '@open-mercato/ui/backend/messages'\n// UMES extension surface \u2014 compose page injection spot (SPEC-045d \u00A79.3a).\n// Channel provider packages inject \"composer capabilities\" widgets here\n// (character limit warnings, channel format selector, attachment scoping, etc.).\nimport { InjectionSpot } from '@open-mercato/ui/backend/injection/InjectionSpot'\n\nexport function ComposeMessagePageClient() {\n const router = useRouter()\n\n return (\n <div className=\"space-y-4\">\n {/*\n Standalone widget mount above the composer \u2014 NOT CrudForm field\n resolution. This page is not a CrudForm, so the `crud-form:*:fields`\n field-event pipeline (onFieldChange, value transformers, etc.) does\n not apply here. Provider packages render composer-capability widgets\n (character-limit warnings, channel format selectors, attachment\n scoping) into this spot purely as additional UI siblings.\n */}\n <InjectionSpot\n spotId={extensionPoints.hosts.composeFields.spotId}\n context={{ form: 'compose' }}\n data={{}}\n />\n <MessageComposer\n inline\n variant=\"compose\"\n onCancel={() => {\n router.push('/backend/messages')\n }}\n onSuccess={(result) => {\n router.push('/backend/messages')\n }}\n />\n </div>\n )\n}\n"],
5
- "mappings": ";AAcI,SASE,KATF;AAZJ,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAIhC,SAAS,qBAAqB;AAEvB,SAAS,2BAA2B;AACzC,QAAM,SAAS,UAAU;AAEzB,SACE,qBAAC,SAAI,WAAU,aASb;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ,gBAAgB,MAAM,cAAc;AAAA,QAC5C,SAAS,EAAE,MAAM,UAAU;AAAA,QAC3B,MAAM,CAAC;AAAA;AAAA,IACT;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,QAAM;AAAA,QACN,SAAQ;AAAA,QACR,UAAU,MAAM;AACd,iBAAO,KAAK,mBAAmB;AAAA,QACjC;AAAA,QACA,WAAW,CAAC,WAAW;AACrB,iBAAO,KAAK,mBAAmB;AAAA,QACjC;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;",
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport { extensionPoints } from '@open-mercato/core/modules/messages/extension-points'\nimport { MessageComposer } from '@open-mercato/ui/backend/messages'\nimport type { MessageSenderOption } from '@open-mercato/ui/backend/messages'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { toComposeSenderOptions } from '@open-mercato/core/modules/messages/lib/composeSenderOptions'\n// UMES extension surface \u2014 compose page injection spot (SPEC-045d \u00A79.3a).\n// Channel provider packages inject \"composer capabilities\" widgets here\n// (character limit warnings, channel format selector, attachment scoping, etc.).\nimport { InjectionSpot } from '@open-mercato/ui/backend/injection/InjectionSpot'\n\nexport function ComposeMessagePageClient() {\n const router = useRouter()\n const [senderOptions, setSenderOptions] = React.useState<MessageSenderOption[]>([])\n\n // `communication_channels` is optional, so its endpoint may be absent or\n // forbidden here. Either way the list stays empty and the composer renders\n // exactly as before: no selector, platform sender only.\n React.useEffect(() => {\n let cancelled = false\n void (async () => {\n try {\n const response = await apiCall<{ items?: unknown[] }>(\n '/api/communication_channels/me/channels',\n { method: 'GET', headers: { 'x-om-forbidden-redirect': '0', 'x-om-unauthorized-redirect': '0' } },\n )\n if (cancelled || !response.ok) return\n setSenderOptions(toComposeSenderOptions(response.result?.items))\n } catch {\n if (!cancelled) setSenderOptions([])\n }\n })()\n return () => {\n cancelled = true\n }\n }, [])\n\n return (\n <div className=\"space-y-4\">\n {/*\n Standalone widget mount above the composer \u2014 NOT CrudForm field\n resolution. This page is not a CrudForm, so the `crud-form:*:fields`\n field-event pipeline (onFieldChange, value transformers, etc.) does\n not apply here. Provider packages render composer-capability widgets\n (character-limit warnings, channel format selectors, attachment\n scoping) into this spot purely as additional UI siblings.\n */}\n <InjectionSpot\n spotId={extensionPoints.hosts.composeFields.spotId}\n context={{ form: 'compose' }}\n data={{}}\n />\n <MessageComposer\n inline\n variant=\"compose\"\n senderOptions={senderOptions}\n onCancel={() => {\n router.push('/backend/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+116,14 @@ const composeMessageBaseSchema = z.object({
116
116
  attachmentRecordId: z.string().min(1).max(255).optional(),
117
117
  actionData: messageActionDataSchema.optional(),
118
118
  sendViaEmail: z.boolean().optional().default(false),
119
+ /**
120
+ * Employee-owned communication channel to send this message through instead
121
+ * of the platform sender (#6258). The channel is never trusted from the body:
122
+ * the route hands it to the `communication_channels` send-as-user facade,
123
+ * which resolves it inside the caller's scope and refuses a channel the
124
+ * caller does not own. Absent means the platform sender.
125
+ */
126
+ senderChannelId: z.string().uuid().optional(),
119
127
  parentMessageId: z.string().uuid().optional(),
120
128
  isDraft: z.boolean().optional().default(false),
121
129
  /**
@@ -200,7 +208,9 @@ const updateDraftSchema = z.object({
200
208
  attachmentIds: z.array(z.string().uuid()).optional(),
201
209
  actionData: messageActionDataSchema.optional(),
202
210
  sendViaEmail: z.boolean().optional(),
203
- isDraft: z.literal(false).optional()
211
+ isDraft: z.literal(false).optional(),
212
+ /** Accepted only so the route can refuse it explicitly; zod would otherwise strip it and the send would fall back to the platform sender unnoticed. */
213
+ senderChannelId: z.string().uuid().optional()
204
214
  }).superRefine((value, ctx) => {
205
215
  if (value.recipients) {
206
216
  const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/messages/data/validators.ts"],
4
- "sourcesContent": ["import { z } from 'zod'\nimport { parseBooleanFlag } from '@open-mercato/shared/lib/boolean'\nimport { sanitizeRichTextHref } from '@open-mercato/shared/lib/html/sanitizeRichText'\nimport { channelTypeRequiresExternalEmail } from '../lib/channel-sender-identity'\n\nfunction collectDuplicateRecipientIds(\n recipients: Array<{ userId: string }>,\n): string[] {\n const seen = new Set<string>()\n const duplicates = new Set<string>()\n for (const recipient of recipients) {\n if (seen.has(recipient.userId)) {\n duplicates.add(recipient.userId)\n continue\n }\n seen.add(recipient.userId)\n }\n return Array.from(duplicates)\n}\n\nfunction validateDefaultWithObjectsPayload(\n value: {\n type?: string\n objects?: Array<{ actionRequired?: boolean; actionType?: string; actionLabel?: string }>\n },\n ctx: z.RefinementCtx,\n): void {\n if (value.type !== 'messages.defaultWithObjects') return\n\n if (!Array.isArray(value.objects) || value.objects.length === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['objects'],\n message: 'at least one object is required for messages.defaultWithObjects',\n })\n return\n }\n\n value.objects.forEach((object, index) => {\n if (object.actionRequired === true) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['objects', index, 'actionRequired'],\n message: 'actionRequired must be false for messages.defaultWithObjects',\n })\n }\n if (typeof object.actionType === 'string' && object.actionType.trim().length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['objects', index, 'actionType'],\n message: 'actionType is not allowed for messages.defaultWithObjects',\n })\n }\n if (typeof object.actionLabel === 'string' && object.actionLabel.trim().length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['objects', index, 'actionLabel'],\n message: 'actionLabel is not allowed for messages.defaultWithObjects',\n })\n }\n })\n}\n\nexport const messageRecipientSchema = z.object({\n userId: z.string().uuid(),\n type: z.enum(['to', 'cc', 'bcc']).optional().default('to'),\n})\n\nexport const messageObjectSchema = z.object({\n entityModule: z.string().min(1),\n entityType: z.string().min(1),\n entityId: z.string().uuid(),\n actionRequired: z.boolean().optional().default(false),\n actionType: z.string().optional(),\n actionLabel: z.string().optional(),\n})\n\nexport const messageActionSchema = z.object({\n id: z.string().min(1),\n label: z.string().min(1),\n labelKey: z.string().optional(),\n variant: z.enum(['default', 'secondary', 'destructive', 'outline', 'ghost']).optional(),\n icon: z.string().optional(),\n commandId: z.string().optional(),\n href: z\n .string()\n .optional()\n .refine(\n (value) => value == null || sanitizeRichTextHref(value) != null,\n { message: '[internal] message action href must be http(s), mailto, tel, or a relative path' },\n ),\n isTerminal: z.boolean().optional(),\n confirmRequired: z.boolean().optional(),\n confirmMessage: z.string().optional(),\n})\n\nexport const messageActionDataSchema = z.object({\n actions: z.array(messageActionSchema),\n primaryActionId: z.string().optional(),\n expiresAt: z.string().datetime().optional(),\n})\n\nconst composeMessageBaseSchema = z.object({\n type: z.string().optional().default('default'),\n visibility: z.enum(['public', 'internal']).nullable().optional(),\n sourceEntityType: z.string().min(1).optional(),\n sourceEntityId: z.string().uuid().optional(),\n externalEmail: z.string().email().optional(),\n externalName: z.string().min(1).max(255).optional(),\n /**\n * Channel type the message originates from, when the caller knows it (#4975).\n * Non-email channels (Discord, Slack, SMS\u2026) have senders with no address, so\n * `externalEmail` is not required for them. Resolved server-side \u2014 the HTTP\n * route strips any client-sent value and derives it from the referenced\n * conversation or parent message, so a caller cannot waive the requirement by\n * asserting its own channel type.\n */\n sourceChannelType: z.string().min(1).max(64).optional(),\n /**\n * Set by channel ingest for a message that arrived FROM an external channel\n * (#6093). On such a message `recipients` are not external addressees \u2014 a\n * public message has none \u2014 but the internal users the hub routes it to\n * (the conversation's assignee), so the \"no recipients on a public message\"\n * rule does not apply. Server-only like `sourceChannelType`: the HTTP route\n * strips any client-sent value, so a caller cannot waive the rule by\n * asserting its message came in from a channel.\n */\n inboundFromChannel: z.boolean().optional(),\n recipients: z.array(messageRecipientSchema).max(100).optional().default([]),\n subject: z.string().max(500).optional().default(''),\n body: z.string().max(50000).optional().default(''),\n bodyFormat: z.enum(['text', 'markdown']).optional().default('text'),\n priority: z.enum(['low', 'normal', 'high', 'urgent']).optional().default('normal'),\n objects: z.array(messageObjectSchema).optional(),\n attachmentIds: z.array(z.string().uuid()).optional(),\n attachmentRecordId: z.string().min(1).max(255).optional(),\n actionData: messageActionDataSchema.optional(),\n sendViaEmail: z.boolean().optional().default(false),\n parentMessageId: z.string().uuid().optional(),\n isDraft: z.boolean().optional().default(false),\n /**\n * When the message was actually sent, if the caller knows better than \"now\"\n * (#6095). Channel ingest sets it to the provider's timestamp so an imported\n * mailbox keeps its real chronology instead of collapsing onto the import\n * minute. Server-only: the HTTP route strips any client-sent value, so a\n * browser caller cannot backdate a message. Ignored for drafts.\n */\n sentAt: z.coerce.date().optional(),\n})\n\ntype ComposeMessageRefinementValue = Omit<\n z.infer<typeof composeMessageBaseSchema>,\n 'sourceChannelType' | 'sentAt'\n> & { sourceChannelType?: string; sentAt?: Date }\n\nfunction refineComposeMessage(value: ComposeMessageRefinementValue, ctx: z.RefinementCtx): void {\n const isDraft = value.isDraft ?? false\n const visibility = value.visibility ?? 'internal'\n const recipientCount = value.recipients.length\n const hasExternalEmail = Boolean(value.externalEmail?.trim())\n const hasSubject = value.subject.trim().length > 0\n const hasBody = value.body.trim().length > 0\n\n if (!isDraft) {\n if (visibility === 'public') {\n // #4975: an external correspondent is only guaranteed to have an address\n // on an email-typed channel. `channelTypeRequiresExternalEmail` fails\n // closed, so an unknown or absent channel type keeps the original rule.\n if (!hasExternalEmail && channelTypeRequiresExternalEmail(value.sourceChannelType)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['externalEmail'],\n message: 'externalEmail is required when visibility is public',\n })\n }\n // #6093: a channel-ingested message is addressed to the assignee of its\n // conversation; that recipient is internal routing, not a second\n // external addressee, so only a user-composed public message is bound\n // by this rule.\n if (recipientCount > 0 && !value.inboundFromChannel) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['recipients'],\n message: 'recipients must be empty when visibility is public',\n })\n }\n } else if (recipientCount === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['recipients'],\n message: 'at least one recipient is required when visibility is internal',\n })\n }\n\n if (!hasSubject) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['subject'],\n message: 'subject is required',\n })\n }\n if (!hasBody) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['body'],\n message: 'body is required',\n })\n }\n }\n\n const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients)\n if (duplicateRecipientIds.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['recipients'],\n message: 'recipient user ids must be unique',\n })\n }\n\n validateDefaultWithObjectsPayload(value, ctx)\n}\n\n/**\n * Full compose contract, including the server-resolved `sourceChannelType`,\n * the ingest-only `inboundFromChannel`, and the server-supplied `sentAt`. Used\n * by the `messages.messages.compose` command and by the HTTP route AFTER it\n * has resolved the channel type itself.\n */\nexport const composeMessageSchema = composeMessageBaseSchema.superRefine(refineComposeMessage)\n\n/**\n * Client-facing compose contract \u2014 the same rules minus the server-only fields:\n * `sourceChannelType` is never accepted from a request body (#4975), neither is\n * `inboundFromChannel` (#6093) nor `sentAt` (#6095). Published in OpenAPI so the\n * documented request shape matches what `POST /api/messages` actually reads:\n * the route discards any client-sent value for these, resolves the real\n * channel type from the referenced conversation or parent message, and only\n * then validates against {@link composeMessageSchema}.\n */\nexport const composeMessageRequestSchema = composeMessageBaseSchema\n .omit({ sourceChannelType: true, inboundFromChannel: true, sentAt: true })\n .superRefine(refineComposeMessage)\n\nexport const updateDraftSchema = z.object({\n type: z.string().optional(),\n visibility: z.enum(['public', 'internal']).nullable().optional(),\n sourceEntityType: z.string().min(1).optional(),\n sourceEntityId: z.string().uuid().optional(),\n externalEmail: z.string().email().optional(),\n externalName: z.string().min(1).max(255).optional(),\n recipients: z.array(messageRecipientSchema).optional(),\n subject: z.string().max(500).optional(),\n body: z.string().max(50000).optional(),\n bodyFormat: z.enum(['text', 'markdown']).optional(),\n priority: z.enum(['low', 'normal', 'high', 'urgent']).optional(),\n objects: z.array(messageObjectSchema).optional(),\n attachmentIds: z.array(z.string().uuid()).optional(),\n actionData: messageActionDataSchema.optional(),\n sendViaEmail: z.boolean().optional(),\n isDraft: z.literal(false).optional(),\n}).superRefine((value, ctx) => {\n if (value.recipients) {\n const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients)\n if (duplicateRecipientIds.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['recipients'],\n message: 'recipient user ids must be unique',\n })\n }\n }\n\n validateDefaultWithObjectsPayload(value, ctx)\n})\n\nexport const listMessagesSchema = z.object({\n folder: z.enum(['inbox', 'sent', 'drafts', 'archived', 'all']).optional().default('inbox'),\n status: z.enum(['unread', 'read', 'archived']).optional(),\n type: z.string().optional(),\n visibility: z.enum(['public', 'internal']).optional(),\n sourceEntityType: z.string().optional(),\n sourceEntityId: z.string().uuid().optional(),\n externalEmail: z.string().email().optional(),\n hasObjects: z.string().transform(parseBooleanFlag).optional(),\n hasAttachments: z.string().transform(parseBooleanFlag).optional(),\n hasActions: z.string().transform(parseBooleanFlag).optional(),\n senderId: z.string().uuid().optional(),\n search: z.string().max(200).optional(),\n since: z.string().datetime().optional(),\n page: z.coerce.number().int().min(1).optional().default(1),\n pageSize: z.coerce.number().int().min(1).max(100).optional().default(20),\n})\n\nexport const forwardMessageSchema = z.object({\n recipients: z.array(messageRecipientSchema).min(1).max(100),\n body: z.string().max(50000).optional(),\n additionalBody: z.string().max(10000).optional(),\n includeAttachments: z.boolean().optional().default(true),\n sendViaEmail: z.boolean().optional().default(false),\n}).superRefine((value, ctx) => {\n const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients)\n if (duplicateRecipientIds.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['recipients'],\n message: 'recipient user ids must be unique',\n })\n }\n})\n\nexport const replyMessageSchema = z.object({\n body: z.string().min(1).max(50000),\n bodyFormat: z.enum(['text', 'markdown']).optional().default('text'),\n recipients: z.array(messageRecipientSchema).max(100).optional(),\n attachmentIds: z.array(z.string().uuid()).optional(),\n attachmentRecordId: z.string().min(1).max(255).optional(),\n replyAll: z.boolean().optional().default(false),\n sendViaEmail: z.boolean().optional().default(false),\n}).superRefine((value, ctx) => {\n if (!value.recipients) return\n const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients)\n if (duplicateRecipientIds.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['recipients'],\n message: 'recipient user ids must be unique',\n })\n }\n})\n\nexport const executeActionSchema = z.object({\n messageId: z.string().uuid(),\n actionId: z.string().min(1),\n payload: z.record(z.string(), z.unknown()).optional(),\n})\n\nexport const confirmMessageSchema = z.object({\n messageId: z.string().uuid(),\n tenantId: z.string().uuid().optional(),\n organizationId: z.string().uuid().nullable().optional(),\n confirmed: z.boolean().optional().default(true),\n})\n\nexport const messageObjectTypesQuerySchema = z.object({\n messageType: z.string().min(1),\n})\n\nexport const attachmentIdsPayloadSchema = z.object({\n attachmentIds: z.array(z.string().uuid()).min(1).max(100),\n})\n\nexport const unlinkAttachmentPayloadSchema = z.object({\n attachmentId: z.string().uuid().optional(),\n attachmentIds: z.array(z.string().uuid()).min(1).max(100).optional(),\n}).refine(\n (value) => Boolean(value.attachmentId || value.attachmentIds?.length),\n { message: 'attachmentId or attachmentIds is required' }\n)\n\nexport type ComposeMessageInput = z.infer<typeof composeMessageSchema>\nexport type UpdateDraftInput = z.infer<typeof updateDraftSchema>\nexport type ListMessagesInput = z.infer<typeof listMessagesSchema>\nexport type ForwardMessageInput = z.infer<typeof forwardMessageSchema>\nexport type ReplyMessageInput = z.infer<typeof replyMessageSchema>\nexport type ExecuteActionInput = z.infer<typeof executeActionSchema>\nexport type ConfirmMessageInput = z.infer<typeof confirmMessageSchema>\nexport type MessageObjectTypesQueryInput = z.infer<typeof messageObjectTypesQuerySchema>\nexport type AttachmentIdsPayload = z.infer<typeof attachmentIdsPayloadSchema>\nexport type UnlinkAttachmentPayload = z.infer<typeof unlinkAttachmentPayloadSchema>\n"],
5
- "mappings": "AAAA,SAAS,SAAS;AAClB,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,wCAAwC;AAEjD,SAAS,6BACP,YACU;AACV,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,aAAa,oBAAI,IAAY;AACnC,aAAW,aAAa,YAAY;AAClC,QAAI,KAAK,IAAI,UAAU,MAAM,GAAG;AAC9B,iBAAW,IAAI,UAAU,MAAM;AAC/B;AAAA,IACF;AACA,SAAK,IAAI,UAAU,MAAM;AAAA,EAC3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EACjD,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAC1D,CAAC;AAEM,MAAM,gCAAgC,EAAE,OAAO;AAAA,EACpD,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA,EACzC,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS;AACrE,CAAC,EAAE;AAAA,EACD,CAAC,UAAU,QAAQ,MAAM,gBAAgB,MAAM,eAAe,MAAM;AAAA,EACpE,EAAE,SAAS,4CAA4C;AACzD;",
4
+ "sourcesContent": ["import { z } from 'zod'\nimport { parseBooleanFlag } from '@open-mercato/shared/lib/boolean'\nimport { sanitizeRichTextHref } from '@open-mercato/shared/lib/html/sanitizeRichText'\nimport { channelTypeRequiresExternalEmail } from '../lib/channel-sender-identity'\n\nfunction collectDuplicateRecipientIds(\n recipients: Array<{ userId: string }>,\n): string[] {\n const seen = new Set<string>()\n const duplicates = new Set<string>()\n for (const recipient of recipients) {\n if (seen.has(recipient.userId)) {\n duplicates.add(recipient.userId)\n continue\n }\n seen.add(recipient.userId)\n }\n return Array.from(duplicates)\n}\n\nfunction validateDefaultWithObjectsPayload(\n value: {\n type?: string\n objects?: Array<{ actionRequired?: boolean; actionType?: string; actionLabel?: string }>\n },\n ctx: z.RefinementCtx,\n): void {\n if (value.type !== 'messages.defaultWithObjects') return\n\n if (!Array.isArray(value.objects) || value.objects.length === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['objects'],\n message: 'at least one object is required for messages.defaultWithObjects',\n })\n return\n }\n\n value.objects.forEach((object, index) => {\n if (object.actionRequired === true) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['objects', index, 'actionRequired'],\n message: 'actionRequired must be false for messages.defaultWithObjects',\n })\n }\n if (typeof object.actionType === 'string' && object.actionType.trim().length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['objects', index, 'actionType'],\n message: 'actionType is not allowed for messages.defaultWithObjects',\n })\n }\n if (typeof object.actionLabel === 'string' && object.actionLabel.trim().length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['objects', index, 'actionLabel'],\n message: 'actionLabel is not allowed for messages.defaultWithObjects',\n })\n }\n })\n}\n\nexport const messageRecipientSchema = z.object({\n userId: z.string().uuid(),\n type: z.enum(['to', 'cc', 'bcc']).optional().default('to'),\n})\n\nexport const messageObjectSchema = z.object({\n entityModule: z.string().min(1),\n entityType: z.string().min(1),\n entityId: z.string().uuid(),\n actionRequired: z.boolean().optional().default(false),\n actionType: z.string().optional(),\n actionLabel: z.string().optional(),\n})\n\nexport const messageActionSchema = z.object({\n id: z.string().min(1),\n label: z.string().min(1),\n labelKey: z.string().optional(),\n variant: z.enum(['default', 'secondary', 'destructive', 'outline', 'ghost']).optional(),\n icon: z.string().optional(),\n commandId: z.string().optional(),\n href: z\n .string()\n .optional()\n .refine(\n (value) => value == null || sanitizeRichTextHref(value) != null,\n { message: '[internal] message action href must be http(s), mailto, tel, or a relative path' },\n ),\n isTerminal: z.boolean().optional(),\n confirmRequired: z.boolean().optional(),\n confirmMessage: z.string().optional(),\n})\n\nexport const messageActionDataSchema = z.object({\n actions: z.array(messageActionSchema),\n primaryActionId: z.string().optional(),\n expiresAt: z.string().datetime().optional(),\n})\n\nconst composeMessageBaseSchema = z.object({\n type: z.string().optional().default('default'),\n visibility: z.enum(['public', 'internal']).nullable().optional(),\n sourceEntityType: z.string().min(1).optional(),\n sourceEntityId: z.string().uuid().optional(),\n externalEmail: z.string().email().optional(),\n externalName: z.string().min(1).max(255).optional(),\n /**\n * Channel type the message originates from, when the caller knows it (#4975).\n * Non-email channels (Discord, Slack, SMS\u2026) have senders with no address, so\n * `externalEmail` is not required for them. Resolved server-side \u2014 the HTTP\n * route strips any client-sent value and derives it from the referenced\n * conversation or parent message, so a caller cannot waive the requirement by\n * asserting its own channel type.\n */\n sourceChannelType: z.string().min(1).max(64).optional(),\n /**\n * Set by channel ingest for a message that arrived FROM an external channel\n * (#6093). On such a message `recipients` are not external addressees \u2014 a\n * public message has none \u2014 but the internal users the hub routes it to\n * (the conversation's assignee), so the \"no recipients on a public message\"\n * rule does not apply. Server-only like `sourceChannelType`: the HTTP route\n * strips any client-sent value, so a caller cannot waive the rule by\n * asserting its message came in from a channel.\n */\n inboundFromChannel: z.boolean().optional(),\n recipients: z.array(messageRecipientSchema).max(100).optional().default([]),\n subject: z.string().max(500).optional().default(''),\n body: z.string().max(50000).optional().default(''),\n bodyFormat: z.enum(['text', 'markdown']).optional().default('text'),\n priority: z.enum(['low', 'normal', 'high', 'urgent']).optional().default('normal'),\n objects: z.array(messageObjectSchema).optional(),\n attachmentIds: z.array(z.string().uuid()).optional(),\n attachmentRecordId: z.string().min(1).max(255).optional(),\n actionData: messageActionDataSchema.optional(),\n sendViaEmail: z.boolean().optional().default(false),\n /**\n * Employee-owned communication channel to send this message through instead\n * of the platform sender (#6258). The channel is never trusted from the body:\n * the route hands it to the `communication_channels` send-as-user facade,\n * which resolves it inside the caller's scope and refuses a channel the\n * caller does not own. Absent means the platform sender.\n */\n senderChannelId: z.string().uuid().optional(),\n parentMessageId: z.string().uuid().optional(),\n isDraft: z.boolean().optional().default(false),\n /**\n * When the message was actually sent, if the caller knows better than \"now\"\n * (#6095). Channel ingest sets it to the provider's timestamp so an imported\n * mailbox keeps its real chronology instead of collapsing onto the import\n * minute. Server-only: the HTTP route strips any client-sent value, so a\n * browser caller cannot backdate a message. Ignored for drafts.\n */\n sentAt: z.coerce.date().optional(),\n})\n\ntype ComposeMessageRefinementValue = Omit<\n z.infer<typeof composeMessageBaseSchema>,\n 'sourceChannelType' | 'sentAt'\n> & { sourceChannelType?: string; sentAt?: Date }\n\nfunction refineComposeMessage(value: ComposeMessageRefinementValue, ctx: z.RefinementCtx): void {\n const isDraft = value.isDraft ?? false\n const visibility = value.visibility ?? 'internal'\n const recipientCount = value.recipients.length\n const hasExternalEmail = Boolean(value.externalEmail?.trim())\n const hasSubject = value.subject.trim().length > 0\n const hasBody = value.body.trim().length > 0\n\n if (!isDraft) {\n if (visibility === 'public') {\n // #4975: an external correspondent is only guaranteed to have an address\n // on an email-typed channel. `channelTypeRequiresExternalEmail` fails\n // closed, so an unknown or absent channel type keeps the original rule.\n if (!hasExternalEmail && channelTypeRequiresExternalEmail(value.sourceChannelType)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['externalEmail'],\n message: 'externalEmail is required when visibility is public',\n })\n }\n // #6093: a channel-ingested message is addressed to the assignee of its\n // conversation; that recipient is internal routing, not a second\n // external addressee, so only a user-composed public message is bound\n // by this rule.\n if (recipientCount > 0 && !value.inboundFromChannel) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['recipients'],\n message: 'recipients must be empty when visibility is public',\n })\n }\n } else if (recipientCount === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['recipients'],\n message: 'at least one recipient is required when visibility is internal',\n })\n }\n\n if (!hasSubject) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['subject'],\n message: 'subject is required',\n })\n }\n if (!hasBody) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['body'],\n message: 'body is required',\n })\n }\n }\n\n const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients)\n if (duplicateRecipientIds.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['recipients'],\n message: 'recipient user ids must be unique',\n })\n }\n\n validateDefaultWithObjectsPayload(value, ctx)\n}\n\n/**\n * Full compose contract, including the server-resolved `sourceChannelType`,\n * the ingest-only `inboundFromChannel`, and the server-supplied `sentAt`. Used\n * by the `messages.messages.compose` command and by the HTTP route AFTER it\n * has resolved the channel type itself.\n */\nexport const composeMessageSchema = composeMessageBaseSchema.superRefine(refineComposeMessage)\n\n/**\n * Client-facing compose contract \u2014 the same rules minus the server-only fields:\n * `sourceChannelType` is never accepted from a request body (#4975), neither is\n * `inboundFromChannel` (#6093) nor `sentAt` (#6095). Published in OpenAPI so the\n * documented request shape matches what `POST /api/messages` actually reads:\n * the route discards any client-sent value for these, resolves the real\n * channel type from the referenced conversation or parent message, and only\n * then validates against {@link composeMessageSchema}.\n */\nexport const composeMessageRequestSchema = composeMessageBaseSchema\n .omit({ sourceChannelType: true, inboundFromChannel: true, sentAt: true })\n .superRefine(refineComposeMessage)\n\nexport const updateDraftSchema = z.object({\n type: z.string().optional(),\n visibility: z.enum(['public', 'internal']).nullable().optional(),\n sourceEntityType: z.string().min(1).optional(),\n sourceEntityId: z.string().uuid().optional(),\n externalEmail: z.string().email().optional(),\n externalName: z.string().min(1).max(255).optional(),\n recipients: z.array(messageRecipientSchema).optional(),\n subject: z.string().max(500).optional(),\n body: z.string().max(50000).optional(),\n bodyFormat: z.enum(['text', 'markdown']).optional(),\n priority: z.enum(['low', 'normal', 'high', 'urgent']).optional(),\n objects: z.array(messageObjectSchema).optional(),\n attachmentIds: z.array(z.string().uuid()).optional(),\n actionData: messageActionDataSchema.optional(),\n sendViaEmail: z.boolean().optional(),\n isDraft: z.literal(false).optional(),\n /** Accepted only so the route can refuse it explicitly; zod would otherwise strip it and the send would fall back to the platform sender unnoticed. */\n senderChannelId: z.string().uuid().optional(),\n}).superRefine((value, ctx) => {\n if (value.recipients) {\n const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients)\n if (duplicateRecipientIds.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['recipients'],\n message: 'recipient user ids must be unique',\n })\n }\n }\n\n validateDefaultWithObjectsPayload(value, ctx)\n})\n\nexport const listMessagesSchema = z.object({\n folder: z.enum(['inbox', 'sent', 'drafts', 'archived', 'all']).optional().default('inbox'),\n status: z.enum(['unread', 'read', 'archived']).optional(),\n type: z.string().optional(),\n visibility: z.enum(['public', 'internal']).optional(),\n sourceEntityType: z.string().optional(),\n sourceEntityId: z.string().uuid().optional(),\n externalEmail: z.string().email().optional(),\n hasObjects: z.string().transform(parseBooleanFlag).optional(),\n hasAttachments: z.string().transform(parseBooleanFlag).optional(),\n hasActions: z.string().transform(parseBooleanFlag).optional(),\n senderId: z.string().uuid().optional(),\n search: z.string().max(200).optional(),\n since: z.string().datetime().optional(),\n page: z.coerce.number().int().min(1).optional().default(1),\n pageSize: z.coerce.number().int().min(1).max(100).optional().default(20),\n})\n\nexport const forwardMessageSchema = z.object({\n recipients: z.array(messageRecipientSchema).min(1).max(100),\n body: z.string().max(50000).optional(),\n additionalBody: z.string().max(10000).optional(),\n includeAttachments: z.boolean().optional().default(true),\n sendViaEmail: z.boolean().optional().default(false),\n}).superRefine((value, ctx) => {\n const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients)\n if (duplicateRecipientIds.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['recipients'],\n message: 'recipient user ids must be unique',\n })\n }\n})\n\nexport const replyMessageSchema = z.object({\n body: z.string().min(1).max(50000),\n bodyFormat: z.enum(['text', 'markdown']).optional().default('text'),\n recipients: z.array(messageRecipientSchema).max(100).optional(),\n attachmentIds: z.array(z.string().uuid()).optional(),\n attachmentRecordId: z.string().min(1).max(255).optional(),\n replyAll: z.boolean().optional().default(false),\n sendViaEmail: z.boolean().optional().default(false),\n}).superRefine((value, ctx) => {\n if (!value.recipients) return\n const duplicateRecipientIds = collectDuplicateRecipientIds(value.recipients)\n if (duplicateRecipientIds.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['recipients'],\n message: 'recipient user ids must be unique',\n })\n }\n})\n\nexport const executeActionSchema = z.object({\n messageId: z.string().uuid(),\n actionId: z.string().min(1),\n payload: z.record(z.string(), z.unknown()).optional(),\n})\n\nexport const confirmMessageSchema = z.object({\n messageId: z.string().uuid(),\n tenantId: z.string().uuid().optional(),\n organizationId: z.string().uuid().nullable().optional(),\n confirmed: z.boolean().optional().default(true),\n})\n\nexport const messageObjectTypesQuerySchema = z.object({\n messageType: z.string().min(1),\n})\n\nexport const attachmentIdsPayloadSchema = z.object({\n attachmentIds: z.array(z.string().uuid()).min(1).max(100),\n})\n\nexport const unlinkAttachmentPayloadSchema = z.object({\n attachmentId: z.string().uuid().optional(),\n attachmentIds: z.array(z.string().uuid()).min(1).max(100).optional(),\n}).refine(\n (value) => Boolean(value.attachmentId || value.attachmentIds?.length),\n { message: 'attachmentId or attachmentIds is required' }\n)\n\nexport type ComposeMessageInput = z.infer<typeof composeMessageSchema>\nexport type UpdateDraftInput = z.infer<typeof updateDraftSchema>\nexport type ListMessagesInput = z.infer<typeof listMessagesSchema>\nexport type ForwardMessageInput = z.infer<typeof forwardMessageSchema>\nexport type ReplyMessageInput = z.infer<typeof replyMessageSchema>\nexport type ExecuteActionInput = z.infer<typeof executeActionSchema>\nexport type ConfirmMessageInput = z.infer<typeof confirmMessageSchema>\nexport type MessageObjectTypesQueryInput = z.infer<typeof messageObjectTypesQuerySchema>\nexport type AttachmentIdsPayload = z.infer<typeof attachmentIdsPayloadSchema>\nexport type UnlinkAttachmentPayload = z.infer<typeof unlinkAttachmentPayloadSchema>\n"],
5
+ "mappings": "AAAA,SAAS,SAAS;AAClB,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,wCAAwC;AAEjD,SAAS,6BACP,YACU;AACV,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,aAAa,oBAAI,IAAY;AACnC,aAAW,aAAa,YAAY;AAClC,QAAI,KAAK,IAAI,UAAU,MAAM,GAAG;AAC9B,iBAAW,IAAI,UAAU,MAAM;AAC/B;AAAA,IACF;AACA,SAAK,IAAI,UAAU,MAAM;AAAA,EAC3B;AACA,SAAO,MAAM,KAAK,UAAU;AAC9B;AAEA,SAAS,kCACP,OAIA,KACM;AACN,MAAI,MAAM,SAAS,8BAA+B;AAElD,MAAI,CAAC,MAAM,QAAQ,MAAM,OAAO,KAAK,MAAM,QAAQ,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AAA,EACjD,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAC1D,CAAC;AAEM,MAAM,gCAAgC,EAAE,OAAO;AAAA,EACpD,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA,EACzC,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS;AACrE,CAAC,EAAE;AAAA,EACD,CAAC,UAAU,QAAQ,MAAM,gBAAgB,MAAM,eAAe,MAAM;AAAA,EACpE,EAAE,SAAS,4CAA4C;AACzD;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,30 @@
1
+ import { EXTERNAL_CONVERSATION_SOURCE_ENTITY_TYPE } from "./composeSourceChannelType.js";
2
+ const CHANNEL_THREAD_FALLBACK_FEATURE = "messages.view";
3
+ function tryResolveChannelThreadAccessService(container) {
4
+ try {
5
+ const service = container.resolve(
6
+ "communicationChannelsResolveChannelThreadAccess"
7
+ );
8
+ return typeof service === "function" ? service : void 0;
9
+ } catch {
10
+ return void 0;
11
+ }
12
+ }
13
+ function resolveActorFeatures(auth) {
14
+ const features = auth?.features;
15
+ if (!Array.isArray(features)) return [];
16
+ return features.filter((value) => typeof value === "string");
17
+ }
18
+ async function resolveMessageChannelThreadAccess(container, scope, reference, actor) {
19
+ if (!reference.messageThreadId && !reference.externalConversationId) return null;
20
+ const resolveChannelThreadAccess = tryResolveChannelThreadAccessService(container);
21
+ if (!resolveChannelThreadAccess) return null;
22
+ return resolveChannelThreadAccess(container, scope, reference, actor);
23
+ }
24
+ export {
25
+ CHANNEL_THREAD_FALLBACK_FEATURE,
26
+ EXTERNAL_CONVERSATION_SOURCE_ENTITY_TYPE,
27
+ resolveActorFeatures,
28
+ resolveMessageChannelThreadAccess
29
+ };
30
+ //# sourceMappingURL=channelThreadAccess.js.map