@open-mercato/core 0.8.1-develop.7297.1.67605e74f9 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2343) 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 +186 -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 +122 -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 +33 -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 +124 -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 +124 -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 +3 -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/products.js +5 -2
  192. package/dist/modules/catalog/commands/products.js.map +2 -2
  193. package/dist/modules/catalog/components/PriceKindSettings.js +5 -19
  194. package/dist/modules/catalog/components/PriceKindSettings.js.map +2 -2
  195. package/dist/modules/catalog/components/prices/PriceScopeSelectors.js +2 -2
  196. package/dist/modules/catalog/components/prices/PriceScopeSelectors.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/test-seed/route.js +90 -20
  246. package/dist/modules/communication_channels/api/post/test-seed/route.js.map +3 -3
  247. package/dist/modules/communication_channels/api/put/channels/[id]/visibility/route.js +137 -0
  248. package/dist/modules/communication_channels/api/put/channels/[id]/visibility/route.js.map +7 -0
  249. package/dist/modules/communication_channels/backend/profile/communication-channels/page.js +175 -107
  250. package/dist/modules/communication_channels/backend/profile/communication-channels/page.js.map +2 -2
  251. package/dist/modules/communication_channels/commands/ingest-inbound-message.js +2 -1
  252. package/dist/modules/communication_channels/commands/ingest-inbound-message.js.map +2 -2
  253. package/dist/modules/communication_channels/commands/set-channel-visibility.js +88 -0
  254. package/dist/modules/communication_channels/commands/set-channel-visibility.js.map +7 -0
  255. package/dist/modules/communication_channels/data/enrichers.js +18 -9
  256. package/dist/modules/communication_channels/data/enrichers.js.map +2 -2
  257. package/dist/modules/communication_channels/data/entities.js +4 -0
  258. package/dist/modules/communication_channels/data/entities.js.map +2 -2
  259. package/dist/modules/communication_channels/di.js +9 -1
  260. package/dist/modules/communication_channels/di.js.map +2 -2
  261. package/dist/modules/communication_channels/events.js +7 -0
  262. package/dist/modules/communication_channels/events.js.map +2 -2
  263. package/dist/modules/communication_channels/index.js +1 -1
  264. package/dist/modules/communication_channels/index.js.map +1 -1
  265. package/dist/modules/communication_channels/lib/access-control.js +2 -1
  266. package/dist/modules/communication_channels/lib/access-control.js.map +2 -2
  267. package/dist/modules/communication_channels/lib/channel-thread-access.js +60 -0
  268. package/dist/modules/communication_channels/lib/channel-thread-access.js.map +7 -0
  269. package/dist/modules/communication_channels/lib/credential-refresh.js +11 -2
  270. package/dist/modules/communication_channels/lib/credential-refresh.js.map +2 -2
  271. package/dist/modules/communication_channels/lib/inbound-message-origin.js +18 -0
  272. package/dist/modules/communication_channels/lib/inbound-message-origin.js.map +7 -0
  273. package/dist/modules/communication_channels/lib/oauth-state.js +37 -0
  274. package/dist/modules/communication_channels/lib/oauth-state.js.map +2 -2
  275. package/dist/modules/communication_channels/lib/outbound-delivery-intent.js +12 -0
  276. package/dist/modules/communication_channels/lib/outbound-delivery-intent.js.map +7 -0
  277. package/dist/modules/communication_channels/lib/send-as-user.js +1 -1
  278. package/dist/modules/communication_channels/lib/send-as-user.js.map +2 -2
  279. package/dist/modules/communication_channels/migrations/Migration20260825141000_communication_channels.js +14 -0
  280. package/dist/modules/communication_channels/migrations/Migration20260825141000_communication_channels.js.map +7 -0
  281. package/dist/modules/communication_channels/setup.js +6 -2
  282. package/dist/modules/communication_channels/setup.js.map +2 -2
  283. package/dist/modules/communication_channels/subscribers/outbound-bridge.js +8 -2
  284. package/dist/modules/communication_channels/subscribers/outbound-bridge.js.map +2 -2
  285. package/dist/modules/communication_channels/workers/gmail-history-sync.js +1 -1
  286. package/dist/modules/communication_channels/workers/gmail-history-sync.js.map +2 -2
  287. package/dist/modules/communication_channels/workers/poll-channel.js +1 -1
  288. package/dist/modules/communication_channels/workers/poll-channel.js.map +2 -2
  289. package/dist/modules/communication_channels/workers/reaction-processor.js +2 -2
  290. package/dist/modules/communication_channels/workers/reaction-processor.js.map +2 -2
  291. package/dist/modules/configs/api/upgrade-actions/route.js +2 -1
  292. package/dist/modules/configs/api/upgrade-actions/route.js.map +2 -2
  293. package/dist/modules/configs/cli.js +2 -2
  294. package/dist/modules/configs/cli.js.map +2 -2
  295. package/dist/modules/configs/lib/upgrade-actions.js +28 -6
  296. package/dist/modules/configs/lib/upgrade-actions.js.map +2 -2
  297. package/dist/modules/configs/services/upgradeActionsService.js +44 -30
  298. package/dist/modules/configs/services/upgradeActionsService.js.map +2 -2
  299. package/dist/modules/currencies/api/currencies/route.js +11 -5
  300. package/dist/modules/currencies/api/currencies/route.js.map +2 -2
  301. package/dist/modules/currencies/api/exchange-rates/route.js +11 -5
  302. package/dist/modules/currencies/api/exchange-rates/route.js.map +2 -2
  303. package/dist/modules/customer_accounts/api/admin/users/[id]/sessions/[sessionId].js +78 -0
  304. package/dist/modules/customer_accounts/api/admin/users/[id]/sessions/[sessionId].js.map +7 -0
  305. package/dist/modules/customer_groups/acl.js +14 -0
  306. package/dist/modules/customer_groups/acl.js.map +7 -0
  307. package/dist/modules/customer_groups/api/customer-groups/[id]/terms/route.js +266 -0
  308. package/dist/modules/customer_groups/api/customer-groups/[id]/terms/route.js.map +7 -0
  309. package/dist/modules/customer_groups/api/customer-groups/crud.js +473 -0
  310. package/dist/modules/customer_groups/api/customer-groups/crud.js.map +7 -0
  311. package/dist/modules/customer_groups/api/customer-groups/explain-terms/route.js +143 -0
  312. package/dist/modules/customer_groups/api/customer-groups/explain-terms/route.js.map +7 -0
  313. package/dist/modules/customer_groups/api/customer-groups/memberships/crud.js +383 -0
  314. package/dist/modules/customer_groups/api/customer-groups/memberships/crud.js.map +7 -0
  315. package/dist/modules/customer_groups/api/customer-groups/memberships/route.js +66 -0
  316. package/dist/modules/customer_groups/api/customer-groups/memberships/route.js.map +7 -0
  317. package/dist/modules/customer_groups/api/customer-groups/price-kinds/route.js +90 -0
  318. package/dist/modules/customer_groups/api/customer-groups/price-kinds/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 +368 -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 +199 -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 +50 -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 +2 -1
  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 -2
  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 +6 -1
  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 +24 -5
  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 +3 -11
  499. package/dist/modules/customers/components/detail/CompanyPeopleSection.js.map +2 -2
  500. package/dist/modules/customers/components/detail/DealForm.js +66 -2
  501. package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
  502. package/dist/modules/customers/components/detail/DealOwnerSelect.js +96 -0
  503. package/dist/modules/customers/components/detail/DealOwnerSelect.js.map +7 -0
  504. package/dist/modules/customers/components/detail/DealsSection.js +8 -14
  505. package/dist/modules/customers/components/detail/DealsSection.js.map +2 -2
  506. package/dist/modules/customers/components/detail/PersonEmailShareControl.js +190 -0
  507. package/dist/modules/customers/components/detail/PersonEmailShareControl.js.map +7 -0
  508. package/dist/modules/customers/components/detail/PersonEmailThreadsTab.js +17 -0
  509. package/dist/modules/customers/components/detail/PersonEmailThreadsTab.js.map +2 -2
  510. package/dist/modules/customers/components/detail/ScheduleActivityDialog.js +5 -2
  511. package/dist/modules/customers/components/detail/ScheduleActivityDialog.js.map +2 -2
  512. package/dist/modules/customers/components/detail/create/CreateDealForm.js +19 -0
  513. package/dist/modules/customers/components/detail/create/CreateDealForm.js.map +2 -2
  514. package/dist/modules/customers/components/detail/create/DealDetailsFields.js +11 -0
  515. package/dist/modules/customers/components/detail/create/DealDetailsFields.js.map +2 -2
  516. package/dist/modules/customers/components/detail/create/DealSectionCard.js +2 -2
  517. package/dist/modules/customers/components/detail/create/DealSectionCard.js.map +2 -2
  518. package/dist/modules/customers/components/detail/create/dealFormTypes.js +1 -0
  519. package/dist/modules/customers/components/detail/create/dealFormTypes.js.map +2 -2
  520. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js +1 -1
  521. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js.map +2 -2
  522. package/dist/modules/customers/components/formConfig.js +2 -0
  523. package/dist/modules/customers/components/formConfig.js.map +2 -2
  524. package/dist/modules/customers/components/linking/LinkEntityDialog.js +8 -0
  525. package/dist/modules/customers/components/linking/LinkEntityDialog.js.map +2 -2
  526. package/dist/modules/customers/data/enrichers.js +40 -2
  527. package/dist/modules/customers/data/enrichers.js.map +2 -2
  528. package/dist/modules/customers/data/entities.js +56 -0
  529. package/dist/modules/customers/data/entities.js.map +2 -2
  530. package/dist/modules/customers/data/validators.js +11 -0
  531. package/dist/modules/customers/data/validators.js.map +2 -2
  532. package/dist/modules/customers/events.js +6 -1
  533. package/dist/modules/customers/events.js.map +2 -2
  534. package/dist/modules/customers/lib/assignableStaff.js +14 -0
  535. package/dist/modules/customers/lib/assignableStaff.js.map +2 -2
  536. package/dist/modules/customers/lib/calendar/editorPayload.js +17 -13
  537. package/dist/modules/customers/lib/calendar/editorPayload.js.map +2 -2
  538. package/dist/modules/customers/lib/calendar/mapItem.js +1 -0
  539. package/dist/modules/customers/lib/calendar/mapItem.js.map +2 -2
  540. package/dist/modules/customers/lib/conversationShares.js +126 -0
  541. package/dist/modules/customers/lib/conversationShares.js.map +7 -0
  542. package/dist/modules/customers/lib/dealsOrganizationScope.js +5 -3
  543. package/dist/modules/customers/lib/dealsOrganizationScope.js.map +2 -2
  544. package/dist/modules/customers/lib/interactionRequestContext.js +2 -1
  545. package/dist/modules/customers/lib/interactionRequestContext.js.map +2 -2
  546. package/dist/modules/customers/lib/link-channel-message-handler.js +19 -9
  547. package/dist/modules/customers/lib/link-channel-message-handler.js.map +2 -2
  548. package/dist/modules/customers/lib/personDetailCacheTags.js +32 -0
  549. package/dist/modules/customers/lib/personDetailCacheTags.js.map +7 -0
  550. package/dist/modules/customers/lib/personEmailThreads.js +26 -5
  551. package/dist/modules/customers/lib/personEmailThreads.js.map +2 -2
  552. package/dist/modules/customers/lib/reassignDealOwner.js +25 -0
  553. package/dist/modules/customers/lib/reassignDealOwner.js.map +7 -0
  554. package/dist/modules/customers/lib/userNames.js +26 -0
  555. package/dist/modules/customers/lib/userNames.js.map +7 -0
  556. package/dist/modules/customers/lib/visibilityFilter.js +70 -2
  557. package/dist/modules/customers/lib/visibilityFilter.js.map +2 -2
  558. package/dist/modules/customers/migrations/Migration20260825120000_customers.js +18 -0
  559. package/dist/modules/customers/migrations/Migration20260825120000_customers.js.map +7 -0
  560. package/dist/modules/customers/migrations/Migration20260825140000_customers.js +27 -0
  561. package/dist/modules/customers/migrations/Migration20260825140000_customers.js.map +7 -0
  562. package/dist/modules/customers/setup.js +1 -0
  563. package/dist/modules/customers/setup.js.map +2 -2
  564. package/dist/modules/customers/subscribers/channel-visibility-changed.js +16 -0
  565. package/dist/modules/customers/subscribers/channel-visibility-changed.js.map +7 -0
  566. package/dist/modules/dashboards/api/widgets/data/batch/route.js +3 -8
  567. package/dist/modules/dashboards/api/widgets/data/batch/route.js.map +2 -2
  568. package/dist/modules/dashboards/api/widgets/data/route.js +10 -15
  569. package/dist/modules/dashboards/api/widgets/data/route.js.map +2 -2
  570. package/dist/modules/dashboards/lib/aggregations.js +1 -1
  571. package/dist/modules/dashboards/lib/aggregations.js.map +2 -2
  572. package/dist/modules/dashboards/lib/widgetScope.js +2 -7
  573. package/dist/modules/dashboards/lib/widgetScope.js.map +2 -2
  574. package/dist/modules/data_sync/api/runs/[id]/cancel.js +4 -1
  575. package/dist/modules/data_sync/api/runs/[id]/cancel.js.map +2 -2
  576. package/dist/modules/data_sync/backend/data-sync/page.js +497 -329
  577. package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
  578. package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js +248 -113
  579. package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js.map +3 -3
  580. package/dist/modules/data_sync/components/useDataSyncRunAccess.js +17 -0
  581. package/dist/modules/data_sync/components/useDataSyncRunAccess.js.map +7 -0
  582. package/dist/modules/data_sync/lib/resume-point.js +21 -0
  583. package/dist/modules/data_sync/lib/resume-point.js.map +7 -0
  584. package/dist/modules/data_sync/lib/start-run.js +52 -2
  585. package/dist/modules/data_sync/lib/start-run.js.map +2 -2
  586. package/dist/modules/data_sync/lib/sync-run-service.js +22 -33
  587. package/dist/modules/data_sync/lib/sync-run-service.js.map +3 -3
  588. package/dist/modules/devices/api/[id]/route.js +3 -2
  589. package/dist/modules/devices/api/[id]/route.js.map +2 -2
  590. package/dist/modules/devices/api/admin/devices/route.js +2 -1
  591. package/dist/modules/devices/api/admin/devices/route.js.map +2 -2
  592. package/dist/modules/devices/api/route.js +2 -1
  593. package/dist/modules/devices/api/route.js.map +2 -2
  594. package/dist/modules/dictionaries/api/[dictionaryId]/route.js.map +2 -2
  595. package/dist/modules/dictionaries/api/context.js +2 -1
  596. package/dist/modules/dictionaries/api/context.js.map +2 -2
  597. package/dist/modules/dictionaries/api/route.js +4 -0
  598. package/dist/modules/dictionaries/api/route.js.map +2 -2
  599. package/dist/modules/dictionaries/components/DictionariesManager.js +101 -89
  600. package/dist/modules/dictionaries/components/DictionariesManager.js.map +2 -2
  601. package/dist/modules/dictionaries/data/validators.js +3 -1
  602. package/dist/modules/dictionaries/data/validators.js.map +2 -2
  603. package/dist/modules/directory/api/organization-branding/route.js +10 -1
  604. package/dist/modules/directory/api/organization-branding/route.js.map +2 -2
  605. package/dist/modules/directory/api/organizations/route.js +1 -1
  606. package/dist/modules/directory/api/organizations/route.js.map +1 -1
  607. package/dist/modules/directory/backend/directory/branding/page.js +17 -4
  608. package/dist/modules/directory/backend/directory/branding/page.js.map +3 -3
  609. package/dist/modules/directory/commands/organizations.js +136 -74
  610. package/dist/modules/directory/commands/organizations.js.map +2 -2
  611. package/dist/modules/directory/lib/hierarchy.js +19 -1
  612. package/dist/modules/directory/lib/hierarchy.js.map +2 -2
  613. package/dist/modules/directory/utils/organizationScope.js +66 -12
  614. package/dist/modules/directory/utils/organizationScope.js.map +2 -2
  615. package/dist/modules/directory/utils/organizationScopeFilter.js +7 -4
  616. package/dist/modules/directory/utils/organizationScopeFilter.js.map +2 -2
  617. package/dist/modules/directory/utils/organizationScopeGuard.js +6 -2
  618. package/dist/modules/directory/utils/organizationScopeGuard.js.map +2 -2
  619. package/dist/modules/entities/api/encryption.js +68 -25
  620. package/dist/modules/entities/api/encryption.js.map +2 -2
  621. package/dist/modules/entities/api/records.js +9 -8
  622. package/dist/modules/entities/api/records.js.map +2 -2
  623. package/dist/modules/entities/cli.js +33 -22
  624. package/dist/modules/entities/cli.js.map +2 -2
  625. package/dist/modules/entities/data/entities.js +8 -0
  626. package/dist/modules/entities/data/entities.js.map +2 -2
  627. package/dist/modules/entities/lib/definition-scope.js +3 -1
  628. package/dist/modules/entities/lib/definition-scope.js.map +2 -2
  629. package/dist/modules/entities/lib/encryption-maps.js +117 -0
  630. package/dist/modules/entities/lib/encryption-maps.js.map +7 -0
  631. package/dist/modules/entities/lib/helpers.js +30 -6
  632. package/dist/modules/entities/lib/helpers.js.map +2 -2
  633. package/dist/modules/entities/migrations/Migration20260910120000.js +17 -0
  634. package/dist/modules/entities/migrations/Migration20260910120000.js.map +7 -0
  635. package/dist/modules/entities/migrations/Migration20261004120000_encryption_map_scope_uniqueness.js +130 -0
  636. package/dist/modules/entities/migrations/Migration20261004120000_encryption_map_scope_uniqueness.js.map +7 -0
  637. package/dist/modules/eudr/api/dashboard/widgets/compliance-overview/route.js +2 -1
  638. package/dist/modules/eudr/api/dashboard/widgets/compliance-overview/route.js.map +2 -2
  639. package/dist/modules/eudr/api/plots/import/route.js +2 -1
  640. package/dist/modules/eudr/api/plots/import/route.js.map +2 -2
  641. package/dist/modules/eudr/api/product-mappings/suggestions/apply/route.js +2 -1
  642. package/dist/modules/eudr/api/product-mappings/suggestions/apply/route.js.map +2 -2
  643. package/dist/modules/eudr/api/product-mappings/suggestions/route.js +2 -1
  644. package/dist/modules/eudr/api/product-mappings/suggestions/route.js.map +2 -2
  645. package/dist/modules/eudr/api/reports/annual/route.js +2 -1
  646. package/dist/modules/eudr/api/reports/annual/route.js.map +2 -2
  647. package/dist/modules/eudr/api/statements/[id]/export/route.js +2 -1
  648. package/dist/modules/eudr/api/statements/[id]/export/route.js.map +2 -2
  649. package/dist/modules/eudr/api/statements/[id]/readiness/route.js +2 -1
  650. package/dist/modules/eudr/api/statements/[id]/readiness/route.js.map +2 -2
  651. package/dist/modules/eudr/api/suppliers/compliance/route.js +2 -1
  652. package/dist/modules/eudr/api/suppliers/compliance/route.js.map +2 -2
  653. package/dist/modules/feature_toggles/commands/global.js +13 -13
  654. package/dist/modules/feature_toggles/commands/global.js.map +2 -2
  655. package/dist/modules/feature_toggles/lib/feature-flag-check.js +8 -2
  656. package/dist/modules/feature_toggles/lib/feature-flag-check.js.map +2 -2
  657. package/dist/modules/forms/acl.js +14 -0
  658. package/dist/modules/forms/acl.js.map +7 -0
  659. package/dist/modules/forms/api/[id]/analytics/route.js +113 -0
  660. package/dist/modules/forms/api/[id]/analytics/route.js.map +7 -0
  661. package/dist/modules/forms/api/[id]/distributions/route.js +176 -0
  662. package/dist/modules/forms/api/[id]/distributions/route.js.map +7 -0
  663. package/dist/modules/forms/api/[id]/route.js +225 -0
  664. package/dist/modules/forms/api/[id]/route.js.map +7 -0
  665. package/dist/modules/forms/api/[id]/run/context/route.js +115 -0
  666. package/dist/modules/forms/api/[id]/run/context/route.js.map +7 -0
  667. package/dist/modules/forms/api/[id]/run/submissions/route.js +109 -0
  668. package/dist/modules/forms/api/[id]/run/submissions/route.js.map +7 -0
  669. package/dist/modules/forms/api/[id]/submissions/route.js +83 -0
  670. package/dist/modules/forms/api/[id]/submissions/route.js.map +7 -0
  671. package/dist/modules/forms/api/[id]/theme-logo/route.js +117 -0
  672. package/dist/modules/forms/api/[id]/theme-logo/route.js.map +7 -0
  673. package/dist/modules/forms/api/[id]/versions/[versionId]/diff/route.js +125 -0
  674. package/dist/modules/forms/api/[id]/versions/[versionId]/diff/route.js.map +7 -0
  675. package/dist/modules/forms/api/[id]/versions/[versionId]/publish/route.js +99 -0
  676. package/dist/modules/forms/api/[id]/versions/[versionId]/publish/route.js.map +7 -0
  677. package/dist/modules/forms/api/[id]/versions/[versionId]/route.js +176 -0
  678. package/dist/modules/forms/api/[id]/versions/[versionId]/route.js.map +7 -0
  679. package/dist/modules/forms/api/[id]/versions/fork/route.js +92 -0
  680. package/dist/modules/forms/api/[id]/versions/fork/route.js.map +7 -0
  681. package/dist/modules/forms/api/attachment-helpers.js +111 -0
  682. package/dist/modules/forms/api/attachment-helpers.js.map +7 -0
  683. package/dist/modules/forms/api/by-key/[key]/active/route.js +140 -0
  684. package/dist/modules/forms/api/by-key/[key]/active/route.js.map +7 -0
  685. package/dist/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/route.js +84 -0
  686. package/dist/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/route.js.map +7 -0
  687. package/dist/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/send/route.js +88 -0
  688. package/dist/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/send/route.js.map +7 -0
  689. package/dist/modules/forms/api/distributions/[distributionId]/invitations/route.js +183 -0
  690. package/dist/modules/forms/api/distributions/[distributionId]/invitations/route.js.map +7 -0
  691. package/dist/modules/forms/api/distributions/[distributionId]/route.js +191 -0
  692. package/dist/modules/forms/api/distributions/[distributionId]/route.js.map +7 -0
  693. package/dist/modules/forms/api/form-submissions/[id]/attachments/route.js +91 -0
  694. package/dist/modules/forms/api/form-submissions/[id]/attachments/route.js.map +7 -0
  695. package/dist/modules/forms/api/form-submissions/[id]/resume-token/route.js +110 -0
  696. package/dist/modules/forms/api/form-submissions/[id]/resume-token/route.js.map +7 -0
  697. package/dist/modules/forms/api/form-submissions/[id]/route.js +146 -0
  698. package/dist/modules/forms/api/form-submissions/[id]/route.js.map +7 -0
  699. package/dist/modules/forms/api/form-submissions/[id]/submit/route.js +74 -0
  700. package/dist/modules/forms/api/form-submissions/[id]/submit/route.js.map +7 -0
  701. package/dist/modules/forms/api/form-submissions/by-subject/[subject_type]/[subject_id]/route.js +76 -0
  702. package/dist/modules/forms/api/form-submissions/by-subject/[subject_type]/[subject_id]/route.js.map +7 -0
  703. package/dist/modules/forms/api/form-submissions/route.js +113 -0
  704. package/dist/modules/forms/api/form-submissions/route.js.map +7 -0
  705. package/dist/modules/forms/api/helpers.js +124 -0
  706. package/dist/modules/forms/api/helpers.js.map +7 -0
  707. package/dist/modules/forms/api/public/distributions/[slug]/embed-policy/route.js +47 -0
  708. package/dist/modules/forms/api/public/distributions/[slug]/embed-policy/route.js.map +7 -0
  709. package/dist/modules/forms/api/public/distributions/[slug]/route.js +81 -0
  710. package/dist/modules/forms/api/public/distributions/[slug]/route.js.map +7 -0
  711. package/dist/modules/forms/api/public/embed-loader/route.js +116 -0
  712. package/dist/modules/forms/api/public/embed-loader/route.js.map +7 -0
  713. package/dist/modules/forms/api/public/invitations/[token]/route.js +87 -0
  714. package/dist/modules/forms/api/public/invitations/[token]/route.js.map +7 -0
  715. package/dist/modules/forms/api/public/rate-limit.js +54 -0
  716. package/dist/modules/forms/api/public/rate-limit.js.map +7 -0
  717. package/dist/modules/forms/api/public/start/route.js +142 -0
  718. package/dist/modules/forms/api/public/start/route.js.map +7 -0
  719. package/dist/modules/forms/api/public/submissions/[id]/attachments/[attachmentId]/route.js +67 -0
  720. package/dist/modules/forms/api/public/submissions/[id]/attachments/[attachmentId]/route.js.map +7 -0
  721. package/dist/modules/forms/api/public/submissions/[id]/attachments/route.js +85 -0
  722. package/dist/modules/forms/api/public/submissions/[id]/attachments/route.js.map +7 -0
  723. package/dist/modules/forms/api/public/submissions/[id]/pdf/route.js +72 -0
  724. package/dist/modules/forms/api/public/submissions/[id]/pdf/route.js.map +7 -0
  725. package/dist/modules/forms/api/public/submissions/[id]/route.js +154 -0
  726. package/dist/modules/forms/api/public/submissions/[id]/route.js.map +7 -0
  727. package/dist/modules/forms/api/public/submissions/[id]/submit/route.js +127 -0
  728. package/dist/modules/forms/api/public/submissions/[id]/submit/route.js.map +7 -0
  729. package/dist/modules/forms/api/route.js +216 -0
  730. package/dist/modules/forms/api/route.js.map +7 -0
  731. package/dist/modules/forms/api/runtime-helpers.js +149 -0
  732. package/dist/modules/forms/api/runtime-helpers.js.map +7 -0
  733. package/dist/modules/forms/api/subjects/[subjectType]/[subjectId]/consents/route.js +137 -0
  734. package/dist/modules/forms/api/subjects/[subjectType]/[subjectId]/consents/route.js.map +7 -0
  735. package/dist/modules/forms/api/subjects/[subjectType]/[subjectId]/export/route.js +101 -0
  736. package/dist/modules/forms/api/subjects/[subjectType]/[subjectId]/export/route.js.map +7 -0
  737. package/dist/modules/forms/api/submissions/[submissionId]/access-audit/route.js +76 -0
  738. package/dist/modules/forms/api/submissions/[submissionId]/access-audit/route.js.map +7 -0
  739. package/dist/modules/forms/api/submissions/[submissionId]/actors/[actorId]/route.js +56 -0
  740. package/dist/modules/forms/api/submissions/[submissionId]/actors/[actorId]/route.js.map +7 -0
  741. package/dist/modules/forms/api/submissions/[submissionId]/actors/route.js +76 -0
  742. package/dist/modules/forms/api/submissions/[submissionId]/actors/route.js.map +7 -0
  743. package/dist/modules/forms/api/submissions/[submissionId]/anonymize/route.js +107 -0
  744. package/dist/modules/forms/api/submissions/[submissionId]/anonymize/route.js.map +7 -0
  745. package/dist/modules/forms/api/submissions/[submissionId]/attachments/[attachmentId]/route.js +73 -0
  746. package/dist/modules/forms/api/submissions/[submissionId]/attachments/[attachmentId]/route.js.map +7 -0
  747. package/dist/modules/forms/api/submissions/[submissionId]/export/route.js +90 -0
  748. package/dist/modules/forms/api/submissions/[submissionId]/export/route.js.map +7 -0
  749. package/dist/modules/forms/api/submissions/[submissionId]/pdf/route.js +91 -0
  750. package/dist/modules/forms/api/submissions/[submissionId]/pdf/route.js.map +7 -0
  751. package/dist/modules/forms/api/submissions/[submissionId]/reopen/route.js +55 -0
  752. package/dist/modules/forms/api/submissions/[submissionId]/reopen/route.js.map +7 -0
  753. package/dist/modules/forms/api/submissions/[submissionId]/revisions/route.js +61 -0
  754. package/dist/modules/forms/api/submissions/[submissionId]/revisions/route.js.map +7 -0
  755. package/dist/modules/forms/api/submissions/[submissionId]/route.js +75 -0
  756. package/dist/modules/forms/api/submissions/[submissionId]/route.js.map +7 -0
  757. package/dist/modules/forms/backend/forms/[id]/FormStudio.js +2811 -0
  758. package/dist/modules/forms/backend/forms/[id]/FormStudio.js.map +7 -0
  759. package/dist/modules/forms/backend/forms/[id]/analytics/page.js +214 -0
  760. package/dist/modules/forms/backend/forms/[id]/analytics/page.js.map +7 -0
  761. package/dist/modules/forms/backend/forms/[id]/analytics/page.meta.js +19 -0
  762. package/dist/modules/forms/backend/forms/[id]/analytics/page.meta.js.map +7 -0
  763. package/dist/modules/forms/backend/forms/[id]/distributions/page.js +12 -0
  764. package/dist/modules/forms/backend/forms/[id]/distributions/page.js.map +7 -0
  765. package/dist/modules/forms/backend/forms/[id]/distributions/page.meta.js +19 -0
  766. package/dist/modules/forms/backend/forms/[id]/distributions/page.meta.js.map +7 -0
  767. package/dist/modules/forms/backend/forms/[id]/history/page.js +152 -0
  768. package/dist/modules/forms/backend/forms/[id]/history/page.js.map +7 -0
  769. package/dist/modules/forms/backend/forms/[id]/history/page.meta.js +15 -0
  770. package/dist/modules/forms/backend/forms/[id]/history/page.meta.js.map +7 -0
  771. package/dist/modules/forms/backend/forms/[id]/page.js +13 -0
  772. package/dist/modules/forms/backend/forms/[id]/page.js.map +7 -0
  773. package/dist/modules/forms/backend/forms/[id]/page.meta.js +15 -0
  774. package/dist/modules/forms/backend/forms/[id]/page.meta.js.map +7 -0
  775. package/dist/modules/forms/backend/forms/[id]/studio/YesNoRow.js +51 -0
  776. package/dist/modules/forms/backend/forms/[id]/studio/YesNoRow.js.map +7 -0
  777. package/dist/modules/forms/backend/forms/[id]/studio/autosave-guard.js +21 -0
  778. package/dist/modules/forms/backend/forms/[id]/studio/autosave-guard.js.map +7 -0
  779. package/dist/modules/forms/backend/forms/[id]/studio/canvas/DragOverlayCard.js +18 -0
  780. package/dist/modules/forms/backend/forms/[id]/studio/canvas/DragOverlayCard.js.map +7 -0
  781. package/dist/modules/forms/backend/forms/[id]/studio/canvas/DropIndicator.js +41 -0
  782. package/dist/modules/forms/backend/forms/[id]/studio/canvas/DropIndicator.js.map +7 -0
  783. package/dist/modules/forms/backend/forms/[id]/studio/canvas/FieldRow.js +277 -0
  784. package/dist/modules/forms/backend/forms/[id]/studio/canvas/FieldRow.js.map +7 -0
  785. package/dist/modules/forms/backend/forms/[id]/studio/canvas/FormCanvas.js +196 -0
  786. package/dist/modules/forms/backend/forms/[id]/studio/canvas/FormCanvas.js.map +7 -0
  787. package/dist/modules/forms/backend/forms/[id]/studio/canvas/GridSlot.js +151 -0
  788. package/dist/modules/forms/backend/forms/[id]/studio/canvas/GridSlot.js.map +7 -0
  789. package/dist/modules/forms/backend/forms/[id]/studio/canvas/SectionContainer.js +340 -0
  790. package/dist/modules/forms/backend/forms/[id]/studio/canvas/SectionContainer.js.map +7 -0
  791. package/dist/modules/forms/backend/forms/[id]/studio/canvas/grid-collision.js +24 -0
  792. package/dist/modules/forms/backend/forms/[id]/studio/canvas/grid-collision.js.map +7 -0
  793. package/dist/modules/forms/backend/forms/[id]/studio/canvas/keyboard-coordinates.js +91 -0
  794. package/dist/modules/forms/backend/forms/[id]/studio/canvas/keyboard-coordinates.js.map +7 -0
  795. package/dist/modules/forms/backend/forms/[id]/studio/canvas/overlay-size.js +11 -0
  796. package/dist/modules/forms/backend/forms/[id]/studio/canvas/overlay-size.js.map +7 -0
  797. package/dist/modules/forms/backend/forms/[id]/studio/canvas/resize-math.js +27 -0
  798. package/dist/modules/forms/backend/forms/[id]/studio/canvas/resize-math.js.map +7 -0
  799. package/dist/modules/forms/backend/forms/[id]/studio/canvas/row-layout.js +80 -0
  800. package/dist/modules/forms/backend/forms/[id]/studio/canvas/row-layout.js.map +7 -0
  801. package/dist/modules/forms/backend/forms/[id]/studio/logic/ConditionBuilder.js +210 -0
  802. package/dist/modules/forms/backend/forms/[id]/studio/logic/ConditionBuilder.js.map +7 -0
  803. package/dist/modules/forms/backend/forms/[id]/studio/logic/HiddenFieldsPanel.js +91 -0
  804. package/dist/modules/forms/backend/forms/[id]/studio/logic/HiddenFieldsPanel.js.map +7 -0
  805. package/dist/modules/forms/backend/forms/[id]/studio/logic/JumpsEditor.js +201 -0
  806. package/dist/modules/forms/backend/forms/[id]/studio/logic/JumpsEditor.js.map +7 -0
  807. package/dist/modules/forms/backend/forms/[id]/studio/logic/RecallTokenPicker.js +66 -0
  808. package/dist/modules/forms/backend/forms/[id]/studio/logic/RecallTokenPicker.js.map +7 -0
  809. package/dist/modules/forms/backend/forms/[id]/studio/logic/VariablesPanel.js +223 -0
  810. package/dist/modules/forms/backend/forms/[id]/studio/logic/VariablesPanel.js.map +7 -0
  811. package/dist/modules/forms/backend/forms/[id]/studio/logic/condition-model.js +151 -0
  812. package/dist/modules/forms/backend/forms/[id]/studio/logic/condition-model.js.map +7 -0
  813. package/dist/modules/forms/backend/forms/[id]/studio/lucide-icons.js +88 -0
  814. package/dist/modules/forms/backend/forms/[id]/studio/lucide-icons.js.map +7 -0
  815. package/dist/modules/forms/backend/forms/[id]/studio/palette/FormAppearancePanel.js +493 -0
  816. package/dist/modules/forms/backend/forms/[id]/studio/palette/FormAppearancePanel.js.map +7 -0
  817. package/dist/modules/forms/backend/forms/[id]/studio/palette/FormPalettePanel.js +44 -0
  818. package/dist/modules/forms/backend/forms/[id]/studio/palette/FormPalettePanel.js.map +7 -0
  819. package/dist/modules/forms/backend/forms/[id]/studio/palette/InputParametersTab.js +350 -0
  820. package/dist/modules/forms/backend/forms/[id]/studio/palette/InputParametersTab.js.map +7 -0
  821. package/dist/modules/forms/backend/forms/[id]/studio/palette/PaletteCard.js +40 -0
  822. package/dist/modules/forms/backend/forms/[id]/studio/palette/PaletteCard.js.map +7 -0
  823. package/dist/modules/forms/backend/forms/[id]/studio/palette/RolesEditor.js +202 -0
  824. package/dist/modules/forms/backend/forms/[id]/studio/palette/RolesEditor.js.map +7 -0
  825. package/dist/modules/forms/backend/forms/[id]/studio/palette/entries.js +66 -0
  826. package/dist/modules/forms/backend/forms/[id]/studio/palette/entries.js.map +7 -0
  827. package/dist/modules/forms/backend/forms/[id]/studio/preview/PreviewSurface.js +1200 -0
  828. package/dist/modules/forms/backend/forms/[id]/studio/preview/PreviewSurface.js.map +7 -0
  829. package/dist/modules/forms/backend/forms/[id]/studio/preview/ViewportFrame.js +34 -0
  830. package/dist/modules/forms/backend/forms/[id]/studio/preview/ViewportFrame.js.map +7 -0
  831. package/dist/modules/forms/backend/forms/[id]/studio/recall.js +76 -0
  832. package/dist/modules/forms/backend/forms/[id]/studio/recall.js.map +7 -0
  833. package/dist/modules/forms/backend/forms/[id]/studio/schema-helpers.js +1693 -0
  834. package/dist/modules/forms/backend/forms/[id]/studio/schema-helpers.js.map +7 -0
  835. package/dist/modules/forms/backend/forms/[id]/studio/style/BackgroundControl.js +127 -0
  836. package/dist/modules/forms/backend/forms/[id]/studio/style/BackgroundControl.js.map +7 -0
  837. package/dist/modules/forms/backend/forms/[id]/studio/style/ColorControl.js +181 -0
  838. package/dist/modules/forms/backend/forms/[id]/studio/style/ColorControl.js.map +7 -0
  839. package/dist/modules/forms/backend/forms/[id]/studio/style/contrast.js +75 -0
  840. package/dist/modules/forms/backend/forms/[id]/studio/style/contrast.js.map +7 -0
  841. package/dist/modules/forms/backend/forms/[id]/studio/style/presets.js +91 -0
  842. package/dist/modules/forms/backend/forms/[id]/studio/style/presets.js.map +7 -0
  843. package/dist/modules/forms/backend/forms/[id]/studio/type-label.js +11 -0
  844. package/dist/modules/forms/backend/forms/[id]/studio/type-label.js.map +7 -0
  845. package/dist/modules/forms/backend/forms/[id]/studio/types.js +1 -0
  846. package/dist/modules/forms/backend/forms/[id]/studio/types.js.map +7 -0
  847. package/dist/modules/forms/backend/forms/[id]/studio/undo-controller.js +43 -0
  848. package/dist/modules/forms/backend/forms/[id]/studio/undo-controller.js.map +7 -0
  849. package/dist/modules/forms/backend/forms/[id]/studio/validation/FileConstraintsEditor.js +74 -0
  850. package/dist/modules/forms/backend/forms/[id]/studio/validation/FileConstraintsEditor.js.map +7 -0
  851. package/dist/modules/forms/backend/forms/[id]/studio/validation/GroupConfigEditor.js +134 -0
  852. package/dist/modules/forms/backend/forms/[id]/studio/validation/GroupConfigEditor.js.map +7 -0
  853. package/dist/modules/forms/backend/forms/[id]/studio/validation/LengthRangeEditor.js +61 -0
  854. package/dist/modules/forms/backend/forms/[id]/studio/validation/LengthRangeEditor.js.map +7 -0
  855. package/dist/modules/forms/backend/forms/[id]/studio/validation/MatrixColumnsEditor.js +149 -0
  856. package/dist/modules/forms/backend/forms/[id]/studio/validation/MatrixColumnsEditor.js.map +7 -0
  857. package/dist/modules/forms/backend/forms/[id]/studio/validation/MatrixRowsEditor.js +168 -0
  858. package/dist/modules/forms/backend/forms/[id]/studio/validation/MatrixRowsEditor.js.map +7 -0
  859. package/dist/modules/forms/backend/forms/[id]/studio/validation/MessageOverridesEditor.js +64 -0
  860. package/dist/modules/forms/backend/forms/[id]/studio/validation/MessageOverridesEditor.js.map +7 -0
  861. package/dist/modules/forms/backend/forms/[id]/studio/validation/NpsAnchorsEditor.js +52 -0
  862. package/dist/modules/forms/backend/forms/[id]/studio/validation/NpsAnchorsEditor.js.map +7 -0
  863. package/dist/modules/forms/backend/forms/[id]/studio/validation/NumberRangeEditor.js +59 -0
  864. package/dist/modules/forms/backend/forms/[id]/studio/validation/NumberRangeEditor.js.map +7 -0
  865. package/dist/modules/forms/backend/forms/[id]/studio/validation/OpinionIconSelect.js +31 -0
  866. package/dist/modules/forms/backend/forms/[id]/studio/validation/OpinionIconSelect.js.map +7 -0
  867. package/dist/modules/forms/backend/forms/[id]/studio/validation/PatternEditor.js +105 -0
  868. package/dist/modules/forms/backend/forms/[id]/studio/validation/PatternEditor.js.map +7 -0
  869. package/dist/modules/forms/backend/forms/[id]/studio/validation/RankingExhaustiveSwitch.js +15 -0
  870. package/dist/modules/forms/backend/forms/[id]/studio/validation/RankingExhaustiveSwitch.js.map +7 -0
  871. package/dist/modules/forms/backend/forms/[id]/studio/validation/SignatureConfigEditor.js +75 -0
  872. package/dist/modules/forms/backend/forms/[id]/studio/validation/SignatureConfigEditor.js.map +7 -0
  873. package/dist/modules/forms/backend/forms/[id]/studio/validation/ValidationPanel.js +293 -0
  874. package/dist/modules/forms/backend/forms/[id]/studio/validation/ValidationPanel.js.map +7 -0
  875. package/dist/modules/forms/backend/forms/[id]/submissions/components/RowBadges.js +42 -0
  876. package/dist/modules/forms/backend/forms/[id]/submissions/components/RowBadges.js.map +7 -0
  877. package/dist/modules/forms/backend/forms/[id]/submissions/components/SubmissionDrawer.js +473 -0
  878. package/dist/modules/forms/backend/forms/[id]/submissions/components/SubmissionDrawer.js.map +7 -0
  879. package/dist/modules/forms/backend/forms/[id]/submissions/components/formSummary.js +9 -0
  880. package/dist/modules/forms/backend/forms/[id]/submissions/components/formSummary.js.map +7 -0
  881. package/dist/modules/forms/backend/forms/[id]/submissions/page.js +205 -0
  882. package/dist/modules/forms/backend/forms/[id]/submissions/page.js.map +7 -0
  883. package/dist/modules/forms/backend/forms/[id]/submissions/page.meta.js +12 -0
  884. package/dist/modules/forms/backend/forms/[id]/submissions/page.meta.js.map +7 -0
  885. package/dist/modules/forms/backend/forms/create/page.js +101 -0
  886. package/dist/modules/forms/backend/forms/create/page.js.map +7 -0
  887. package/dist/modules/forms/backend/forms/create/page.meta.js +15 -0
  888. package/dist/modules/forms/backend/forms/create/page.meta.js.map +7 -0
  889. package/dist/modules/forms/backend/forms/page.js +227 -0
  890. package/dist/modules/forms/backend/forms/page.js.map +7 -0
  891. package/dist/modules/forms/backend/forms/page.meta.js +33 -0
  892. package/dist/modules/forms/backend/forms/page.meta.js.map +7 -0
  893. package/dist/modules/forms/commands/distribution.js +421 -0
  894. package/dist/modules/forms/commands/distribution.js.map +7 -0
  895. package/dist/modules/forms/commands/form-version.js +645 -0
  896. package/dist/modules/forms/commands/form-version.js.map +7 -0
  897. package/dist/modules/forms/commands/form.js +411 -0
  898. package/dist/modules/forms/commands/form.js.map +7 -0
  899. package/dist/modules/forms/commands/index.js +11 -0
  900. package/dist/modules/forms/commands/index.js.map +7 -0
  901. package/dist/modules/forms/commands/invitation.js +333 -0
  902. package/dist/modules/forms/commands/invitation.js.map +7 -0
  903. package/dist/modules/forms/commands/shared.js +151 -0
  904. package/dist/modules/forms/commands/shared.js.map +7 -0
  905. package/dist/modules/forms/commands/submission.js +139 -0
  906. package/dist/modules/forms/commands/submission.js.map +7 -0
  907. package/dist/modules/forms/data/entities.js +654 -0
  908. package/dist/modules/forms/data/entities.js.map +7 -0
  909. package/dist/modules/forms/data/validators.js +254 -0
  910. package/dist/modules/forms/data/validators.js.map +7 -0
  911. package/dist/modules/forms/di.js +199 -0
  912. package/dist/modules/forms/di.js.map +7 -0
  913. package/dist/modules/forms/encryption.js +15 -0
  914. package/dist/modules/forms/encryption.js.map +7 -0
  915. package/dist/modules/forms/events-payloads.js +81 -0
  916. package/dist/modules/forms/events-payloads.js.map +7 -0
  917. package/dist/modules/forms/events.js +33 -0
  918. package/dist/modules/forms/events.js.map +7 -0
  919. package/dist/modules/forms/extension-points.js +36 -0
  920. package/dist/modules/forms/extension-points.js.map +7 -0
  921. package/dist/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.js +33 -0
  922. package/dist/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.js.map +7 -0
  923. package/dist/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.meta.js +11 -0
  924. package/dist/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.meta.js.map +7 -0
  925. package/dist/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.js +41 -0
  926. package/dist/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.js.map +7 -0
  927. package/dist/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.meta.js +11 -0
  928. package/dist/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.meta.js.map +7 -0
  929. package/dist/modules/forms/frontend/embed/[slug]/page.js +105 -0
  930. package/dist/modules/forms/frontend/embed/[slug]/page.js.map +7 -0
  931. package/dist/modules/forms/frontend/embed/[slug]/page.meta.js +11 -0
  932. package/dist/modules/forms/frontend/embed/[slug]/page.meta.js.map +7 -0
  933. package/dist/modules/forms/frontend/f/[slug]/page.js +12 -0
  934. package/dist/modules/forms/frontend/f/[slug]/page.js.map +7 -0
  935. package/dist/modules/forms/frontend/f/[slug]/page.meta.js +11 -0
  936. package/dist/modules/forms/frontend/f/[slug]/page.meta.js.map +7 -0
  937. package/dist/modules/forms/frontend/forms/[id]/run/page.js +62 -0
  938. package/dist/modules/forms/frontend/forms/[id]/run/page.js.map +7 -0
  939. package/dist/modules/forms/frontend/forms/[id]/run/page.meta.js +11 -0
  940. package/dist/modules/forms/frontend/forms/[id]/run/page.meta.js.map +7 -0
  941. package/dist/modules/forms/frontend/i/[token]/page.js +12 -0
  942. package/dist/modules/forms/frontend/i/[token]/page.js.map +7 -0
  943. package/dist/modules/forms/frontend/i/[token]/page.meta.js +11 -0
  944. package/dist/modules/forms/frontend/i/[token]/page.meta.js.map +7 -0
  945. package/dist/modules/forms/index.js +20 -0
  946. package/dist/modules/forms/index.js.map +7 -0
  947. package/dist/modules/forms/lib/embed-frame-policy.js +68 -0
  948. package/dist/modules/forms/lib/embed-frame-policy.js.map +7 -0
  949. package/dist/modules/forms/lib/form-definition-slicing.js +38 -0
  950. package/dist/modules/forms/lib/form-definition-slicing.js.map +7 -0
  951. package/dist/modules/forms/lib/log-redaction.js +38 -0
  952. package/dist/modules/forms/lib/log-redaction.js.map +7 -0
  953. package/dist/modules/forms/lib/navigable-url.js +24 -0
  954. package/dist/modules/forms/lib/navigable-url.js.map +7 -0
  955. package/dist/modules/forms/lib/retention.js +20 -0
  956. package/dist/modules/forms/lib/retention.js.map +7 -0
  957. package/dist/modules/forms/lib/runtime-principal.js +59 -0
  958. package/dist/modules/forms/lib/runtime-principal.js.map +7 -0
  959. package/dist/modules/forms/migrations/Migration20260508135459_forms.js +17 -0
  960. package/dist/modules/forms/migrations/Migration20260508135459_forms.js.map +7 -0
  961. package/dist/modules/forms/migrations/Migration20260508140932_forms.js +23 -0
  962. package/dist/modules/forms/migrations/Migration20260508140932_forms.js.map +7 -0
  963. package/dist/modules/forms/migrations/Migration20260508155737_forms.js +15 -0
  964. package/dist/modules/forms/migrations/Migration20260508155737_forms.js.map +7 -0
  965. package/dist/modules/forms/migrations/Migration20260520120000_forms.js +23 -0
  966. package/dist/modules/forms/migrations/Migration20260520120000_forms.js.map +7 -0
  967. package/dist/modules/forms/migrations/Migration20260521090000_forms.js +13 -0
  968. package/dist/modules/forms/migrations/Migration20260521090000_forms.js.map +7 -0
  969. package/dist/modules/forms/migrations/Migration20260521120000_forms.js +17 -0
  970. package/dist/modules/forms/migrations/Migration20260521120000_forms.js.map +7 -0
  971. package/dist/modules/forms/runner/FormRunner.js +786 -0
  972. package/dist/modules/forms/runner/FormRunner.js.map +7 -0
  973. package/dist/modules/forms/runner/MatrixField.js +150 -0
  974. package/dist/modules/forms/runner/MatrixField.js.map +7 -0
  975. package/dist/modules/forms/runner/RankingField.js +131 -0
  976. package/dist/modules/forms/runner/RankingField.js.map +7 -0
  977. package/dist/modules/forms/runner/ScaleField.js +78 -0
  978. package/dist/modules/forms/runner/ScaleField.js.map +7 -0
  979. package/dist/modules/forms/runner/SignatureField.js +132 -0
  980. package/dist/modules/forms/runner/SignatureField.js.map +7 -0
  981. package/dist/modules/forms/runner/tamper-check.js +85 -0
  982. package/dist/modules/forms/runner/tamper-check.js.map +7 -0
  983. package/dist/modules/forms/schema/address-countries.js +43 -0
  984. package/dist/modules/forms/schema/address-countries.js.map +7 -0
  985. package/dist/modules/forms/schema/field-type-patterns.js +15 -0
  986. package/dist/modules/forms/schema/field-type-patterns.js.map +7 -0
  987. package/dist/modules/forms/schema/field-type-registry-advanced.js +32 -0
  988. package/dist/modules/forms/schema/field-type-registry-advanced.js.map +7 -0
  989. package/dist/modules/forms/schema/field-type-registry.js +625 -0
  990. package/dist/modules/forms/schema/field-type-registry.js.map +7 -0
  991. package/dist/modules/forms/schema/file-field.js +64 -0
  992. package/dist/modules/forms/schema/file-field.js.map +7 -0
  993. package/dist/modules/forms/schema/group-field.js +143 -0
  994. package/dist/modules/forms/schema/group-field.js.map +7 -0
  995. package/dist/modules/forms/schema/jsonlogic-grammar.js +66 -0
  996. package/dist/modules/forms/schema/jsonlogic-grammar.js.map +7 -0
  997. package/dist/modules/forms/schema/jsonschema-extensions.js +739 -0
  998. package/dist/modules/forms/schema/jsonschema-extensions.js.map +7 -0
  999. package/dist/modules/forms/schema/layout-catalog.js +38 -0
  1000. package/dist/modules/forms/schema/layout-catalog.js.map +7 -0
  1001. package/dist/modules/forms/schema/signature-field.js +67 -0
  1002. package/dist/modules/forms/schema/signature-field.js.map +7 -0
  1003. package/dist/modules/forms/schema/style-extensions.js +77 -0
  1004. package/dist/modules/forms/schema/style-extensions.js.map +7 -0
  1005. package/dist/modules/forms/schema/style-validators.js +181 -0
  1006. package/dist/modules/forms/schema/style-validators.js.map +7 -0
  1007. package/dist/modules/forms/services/access-audit-logger.js +179 -0
  1008. package/dist/modules/forms/services/access-audit-logger.js.map +7 -0
  1009. package/dist/modules/forms/services/analytics-service.js +306 -0
  1010. package/dist/modules/forms/services/analytics-service.js.map +7 -0
  1011. package/dist/modules/forms/services/anonymize-service.js +123 -0
  1012. package/dist/modules/forms/services/anonymize-service.js.map +7 -0
  1013. package/dist/modules/forms/services/attachment-service.js +123 -0
  1014. package/dist/modules/forms/services/attachment-service.js.map +7 -0
  1015. package/dist/modules/forms/services/captcha-verifier.js +76 -0
  1016. package/dist/modules/forms/services/captcha-verifier.js.map +7 -0
  1017. package/dist/modules/forms/services/consent-record-service.js +96 -0
  1018. package/dist/modules/forms/services/consent-record-service.js.map +7 -0
  1019. package/dist/modules/forms/services/distribution-service.js +366 -0
  1020. package/dist/modules/forms/services/distribution-service.js.map +7 -0
  1021. package/dist/modules/forms/services/distribution-token.js +93 -0
  1022. package/dist/modules/forms/services/distribution-token.js.map +7 -0
  1023. package/dist/modules/forms/services/encryption-service.js +328 -0
  1024. package/dist/modules/forms/services/encryption-service.js.map +7 -0
  1025. package/dist/modules/forms/services/export-service.js +210 -0
  1026. package/dist/modules/forms/services/export-service.js.map +7 -0
  1027. package/dist/modules/forms/services/field-validation-service.js +168 -0
  1028. package/dist/modules/forms/services/field-validation-service.js.map +7 -0
  1029. package/dist/modules/forms/services/form-logic-evaluator.js +517 -0
  1030. package/dist/modules/forms/services/form-logic-evaluator.js.map +7 -0
  1031. package/dist/modules/forms/services/form-version-compiler.js +518 -0
  1032. package/dist/modules/forms/services/form-version-compiler.js.map +7 -0
  1033. package/dist/modules/forms/services/form-version-differ.js +89 -0
  1034. package/dist/modules/forms/services/form-version-differ.js.map +7 -0
  1035. package/dist/modules/forms/services/jsonlogic-evaluator.js +171 -0
  1036. package/dist/modules/forms/services/jsonlogic-evaluator.js.map +7 -0
  1037. package/dist/modules/forms/services/pdf-snapshot-service.js +526 -0
  1038. package/dist/modules/forms/services/pdf-snapshot-service.js.map +7 -0
  1039. package/dist/modules/forms/services/prefill-resolver.js +53 -0
  1040. package/dist/modules/forms/services/prefill-resolver.js.map +7 -0
  1041. package/dist/modules/forms/services/role-policy-service.js +55 -0
  1042. package/dist/modules/forms/services/role-policy-service.js.map +7 -0
  1043. package/dist/modules/forms/services/style-compiler.js +234 -0
  1044. package/dist/modules/forms/services/style-compiler.js.map +7 -0
  1045. package/dist/modules/forms/services/submission-service.js +858 -0
  1046. package/dist/modules/forms/services/submission-service.js.map +7 -0
  1047. package/dist/modules/forms/services/upload-scanner.js +9 -0
  1048. package/dist/modules/forms/services/upload-scanner.js.map +7 -0
  1049. package/dist/modules/forms/services/upload-validation.js +54 -0
  1050. package/dist/modules/forms/services/upload-validation.js.map +7 -0
  1051. package/dist/modules/forms/services/visibility-resolver.js +30 -0
  1052. package/dist/modules/forms/services/visibility-resolver.js.map +7 -0
  1053. package/dist/modules/forms/setup.js +18 -0
  1054. package/dist/modules/forms/setup.js.map +7 -0
  1055. package/dist/modules/forms/subscribers/forms-consent-projector.js +58 -0
  1056. package/dist/modules/forms/subscribers/forms-consent-projector.js.map +7 -0
  1057. package/dist/modules/forms/subscribers/forms-pdf-snapshot.js +68 -0
  1058. package/dist/modules/forms/subscribers/forms-pdf-snapshot.js.map +7 -0
  1059. package/dist/modules/forms/subscribers/forms-webhook-bridge-anonymized.js +29 -0
  1060. package/dist/modules/forms/subscribers/forms-webhook-bridge-anonymized.js.map +7 -0
  1061. package/dist/modules/forms/subscribers/forms-webhook-bridge.js +35 -0
  1062. package/dist/modules/forms/subscribers/forms-webhook-bridge.js.map +7 -0
  1063. package/dist/modules/forms/subscribers/invitation-email.js +100 -0
  1064. package/dist/modules/forms/subscribers/invitation-email.js.map +7 -0
  1065. package/dist/modules/forms/translations.js +10 -0
  1066. package/dist/modules/forms/translations.js.map +7 -0
  1067. package/dist/modules/forms/ui/admin/forms/[id]/distributions/CreateDistributionDialog.js +376 -0
  1068. package/dist/modules/forms/ui/admin/forms/[id]/distributions/CreateDistributionDialog.js.map +7 -0
  1069. package/dist/modules/forms/ui/admin/forms/[id]/distributions/DistributionsPanel.js +313 -0
  1070. package/dist/modules/forms/ui/admin/forms/[id]/distributions/DistributionsPanel.js.map +7 -0
  1071. package/dist/modules/forms/ui/admin/forms/[id]/distributions/EmbedSettingsDialog.js +263 -0
  1072. package/dist/modules/forms/ui/admin/forms/[id]/distributions/EmbedSettingsDialog.js.map +7 -0
  1073. package/dist/modules/forms/ui/admin/forms/[id]/distributions/RecipientsTable.js +373 -0
  1074. package/dist/modules/forms/ui/admin/forms/[id]/distributions/RecipientsTable.js.map +7 -0
  1075. package/dist/modules/forms/ui/public/EmbeddedForm.js +166 -0
  1076. package/dist/modules/forms/ui/public/EmbeddedForm.js.map +7 -0
  1077. package/dist/modules/forms/ui/public/FormRunner.js +359 -0
  1078. package/dist/modules/forms/ui/public/FormRunner.js.map +7 -0
  1079. package/dist/modules/forms/ui/public/FormTrigger.js +45 -0
  1080. package/dist/modules/forms/ui/public/FormTrigger.js.map +7 -0
  1081. package/dist/modules/forms/ui/public/PublicFormRunnerPage.js +14 -0
  1082. package/dist/modules/forms/ui/public/PublicFormRunnerPage.js.map +7 -0
  1083. package/dist/modules/forms/ui/public/components/CompletionScreen.js +55 -0
  1084. package/dist/modules/forms/ui/public/components/CompletionScreen.js.map +7 -0
  1085. package/dist/modules/forms/ui/public/components/LocaleSwitch.js +28 -0
  1086. package/dist/modules/forms/ui/public/components/LocaleSwitch.js.map +7 -0
  1087. package/dist/modules/forms/ui/public/components/ResumeGate.js +52 -0
  1088. package/dist/modules/forms/ui/public/components/ResumeGate.js.map +7 -0
  1089. package/dist/modules/forms/ui/public/components/ReviewStep.js +90 -0
  1090. package/dist/modules/forms/ui/public/components/ReviewStep.js.map +7 -0
  1091. package/dist/modules/forms/ui/public/components/SaveIndicator.js +65 -0
  1092. package/dist/modules/forms/ui/public/components/SaveIndicator.js.map +7 -0
  1093. package/dist/modules/forms/ui/public/components/SectionStepper.js +52 -0
  1094. package/dist/modules/forms/ui/public/components/SectionStepper.js.map +7 -0
  1095. package/dist/modules/forms/ui/public/index.js +38 -0
  1096. package/dist/modules/forms/ui/public/index.js.map +7 -0
  1097. package/dist/modules/forms/ui/public/renderers/index.js +737 -0
  1098. package/dist/modules/forms/ui/public/renderers/index.js.map +7 -0
  1099. package/dist/modules/forms/ui/public/state/logic-derivation.js +42 -0
  1100. package/dist/modules/forms/ui/public/state/logic-derivation.js.map +7 -0
  1101. package/dist/modules/forms/ui/public/state/runtime-client.js +306 -0
  1102. package/dist/modules/forms/ui/public/state/runtime-client.js.map +7 -0
  1103. package/dist/modules/forms/ui/public/state/useAutosave.js +64 -0
  1104. package/dist/modules/forms/ui/public/state/useAutosave.js.map +7 -0
  1105. package/dist/modules/forms/ui/public/state/useFormRunner.js +394 -0
  1106. package/dist/modules/forms/ui/public/state/useFormRunner.js.map +7 -0
  1107. package/dist/modules/forms/ui/public/style/LogoHeader.js +33 -0
  1108. package/dist/modules/forms/ui/public/style/LogoHeader.js.map +7 -0
  1109. package/dist/modules/forms/ui/public/style/applyStyle.js +12 -0
  1110. package/dist/modules/forms/ui/public/style/applyStyle.js.map +7 -0
  1111. package/dist/modules/forms/ui/public/types.js +18 -0
  1112. package/dist/modules/forms/ui/public/types.js.map +7 -0
  1113. package/dist/modules/forms/widgets/injection/access-audit-panel/widget.js +100 -0
  1114. package/dist/modules/forms/widgets/injection/access-audit-panel/widget.js.map +7 -0
  1115. package/dist/modules/forms/widgets/injection/anonymize-button/widget.js +148 -0
  1116. package/dist/modules/forms/widgets/injection/anonymize-button/widget.js.map +7 -0
  1117. package/dist/modules/forms/widgets/injection/audit-format.js +33 -0
  1118. package/dist/modules/forms/widgets/injection/audit-format.js.map +7 -0
  1119. package/dist/modules/forms/widgets/injection/context.js +5 -0
  1120. package/dist/modules/forms/widgets/injection/context.js.map +7 -0
  1121. package/dist/modules/forms/widgets/injection/embedded-form/widget.js +52 -0
  1122. package/dist/modules/forms/widgets/injection/embedded-form/widget.js.map +7 -0
  1123. package/dist/modules/forms/widgets/injection/pdf-download-button/widget.js +83 -0
  1124. package/dist/modules/forms/widgets/injection/pdf-download-button/widget.js.map +7 -0
  1125. package/dist/modules/forms/widgets/injection/self-audit-footer/widget.js +38 -0
  1126. package/dist/modules/forms/widgets/injection/self-audit-footer/widget.js.map +7 -0
  1127. package/dist/modules/forms/widgets/injection-table.js +32 -0
  1128. package/dist/modules/forms/widgets/injection-table.js.map +7 -0
  1129. package/dist/modules/forms/workers/pdf-snapshot.js +60 -0
  1130. package/dist/modules/forms/workers/pdf-snapshot.js.map +7 -0
  1131. package/dist/modules/forms/workers/retention-purge.js +112 -0
  1132. package/dist/modules/forms/workers/retention-purge.js.map +7 -0
  1133. package/dist/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/route.js +7 -1
  1134. package/dist/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/route.js.map +2 -2
  1135. package/dist/modules/inbox_ops/data/validators.js +2 -2
  1136. package/dist/modules/inbox_ops/data/validators.js.map +2 -2
  1137. package/dist/modules/inbox_ops/lib/llmProvider.js +5 -1
  1138. package/dist/modules/inbox_ops/lib/llmProvider.js.map +2 -2
  1139. package/dist/modules/inbox_ops/widgets/notifications/ProposalCreatedRenderer.js +2 -2
  1140. package/dist/modules/inbox_ops/widgets/notifications/ProposalCreatedRenderer.js.map +2 -2
  1141. package/dist/modules/integrations/di.js +3 -1
  1142. package/dist/modules/integrations/di.js.map +2 -2
  1143. package/dist/modules/integrations/lib/credentials-service.js +29 -36
  1144. package/dist/modules/integrations/lib/credentials-service.js.map +2 -2
  1145. package/dist/modules/messages/api/[id]/attachments/route.js +7 -3
  1146. package/dist/modules/messages/api/[id]/attachments/route.js.map +2 -2
  1147. package/dist/modules/messages/api/[id]/forward-preview/route.js +4 -3
  1148. package/dist/modules/messages/api/[id]/forward-preview/route.js.map +2 -2
  1149. package/dist/modules/messages/api/[id]/route.js +29 -3
  1150. package/dist/modules/messages/api/[id]/route.js.map +2 -2
  1151. package/dist/modules/messages/api/route.js +91 -2
  1152. package/dist/modules/messages/api/route.js.map +2 -2
  1153. package/dist/modules/messages/commands/messages.js +40 -6
  1154. package/dist/modules/messages/commands/messages.js.map +2 -2
  1155. package/dist/modules/messages/components/ComposeMessagePageClient.js +24 -1
  1156. package/dist/modules/messages/components/ComposeMessagePageClient.js.map +2 -2
  1157. package/dist/modules/messages/data/validators.js +11 -1
  1158. package/dist/modules/messages/data/validators.js.map +2 -2
  1159. package/dist/modules/messages/lib/channelThreadAccess.js +30 -0
  1160. package/dist/modules/messages/lib/channelThreadAccess.js.map +7 -0
  1161. package/dist/modules/messages/lib/composeSenderDelegation.js +87 -0
  1162. package/dist/modules/messages/lib/composeSenderDelegation.js.map +7 -0
  1163. package/dist/modules/messages/lib/composeSenderOptions.js +24 -0
  1164. package/dist/modules/messages/lib/composeSenderOptions.js.map +7 -0
  1165. package/dist/modules/messages/lib/email-sender.js +1 -11
  1166. package/dist/modules/messages/lib/email-sender.js.map +2 -2
  1167. package/dist/modules/messages/lib/forwarding.js +4 -4
  1168. package/dist/modules/messages/lib/forwarding.js.map +2 -2
  1169. package/dist/modules/messages/lib/markdownEmailBody.js +15 -0
  1170. package/dist/modules/messages/lib/markdownEmailBody.js.map +7 -0
  1171. package/dist/modules/messages/lib/messageSourceEntityTypes.js +7 -0
  1172. package/dist/modules/messages/lib/messageSourceEntityTypes.js.map +7 -0
  1173. package/dist/modules/messages/lib/routeHelpers.js +43 -0
  1174. package/dist/modules/messages/lib/routeHelpers.js.map +2 -2
  1175. package/dist/modules/messages/subscribers/message-notification.js +30 -1
  1176. package/dist/modules/messages/subscribers/message-notification.js.map +2 -2
  1177. package/dist/modules/notifications/api/[id]/action/route.js +2 -1
  1178. package/dist/modules/notifications/api/[id]/action/route.js.map +2 -2
  1179. package/dist/modules/notifications/api/openapi.js +2 -1
  1180. package/dist/modules/notifications/api/openapi.js.map +2 -2
  1181. package/dist/modules/notifications/frontend/NotificationSettingsPageClient.js +47 -28
  1182. package/dist/modules/notifications/frontend/NotificationSettingsPageClient.js.map +2 -2
  1183. package/dist/modules/notifications/lib/deliveryConfig.js +27 -2
  1184. package/dist/modules/notifications/lib/deliveryConfig.js.map +2 -2
  1185. package/dist/modules/notifications/lib/notificationMapper.js +3 -1
  1186. package/dist/modules/notifications/lib/notificationMapper.js.map +2 -2
  1187. package/dist/modules/notifications/lib/safeHref.js +4 -0
  1188. package/dist/modules/notifications/lib/safeHref.js.map +2 -2
  1189. package/dist/modules/planner/api/availability-date-specific.js +2 -1
  1190. package/dist/modules/planner/api/availability-date-specific.js.map +2 -2
  1191. package/dist/modules/planner/api/availability-weekly.js +2 -1
  1192. package/dist/modules/planner/api/availability-weekly.js.map +2 -2
  1193. package/dist/modules/progress/api/active/route.js +14 -2
  1194. package/dist/modules/progress/api/active/route.js.map +2 -2
  1195. package/dist/modules/progress/api/jobs/[id]/route.js +38 -22
  1196. package/dist/modules/progress/api/jobs/[id]/route.js.map +2 -2
  1197. package/dist/modules/progress/api/jobs/route.js +20 -6
  1198. package/dist/modules/progress/api/jobs/route.js.map +2 -2
  1199. package/dist/modules/progress/api/requestScope.js +32 -0
  1200. package/dist/modules/progress/api/requestScope.js.map +7 -0
  1201. package/dist/modules/progress/lib/organizationScope.js +10 -0
  1202. package/dist/modules/progress/lib/organizationScope.js.map +7 -0
  1203. package/dist/modules/progress/lib/progressService.js.map +2 -2
  1204. package/dist/modules/progress/lib/progressServiceImpl.js +48 -15
  1205. package/dist/modules/progress/lib/progressServiceImpl.js.map +2 -2
  1206. package/dist/modules/push_notifications/api/custom-send/route.js +4 -1
  1207. package/dist/modules/push_notifications/api/custom-send/route.js.map +2 -2
  1208. package/dist/modules/query_index/api/status.js +5 -3
  1209. package/dist/modules/query_index/api/status.js.map +2 -2
  1210. package/dist/modules/query_index/di.js +2 -1
  1211. package/dist/modules/query_index/di.js.map +2 -2
  1212. package/dist/modules/query_index/lib/engine.js +2 -1
  1213. package/dist/modules/query_index/lib/engine.js.map +2 -2
  1214. package/dist/modules/query_index/lib/request-encryption.js +16 -0
  1215. package/dist/modules/query_index/lib/request-encryption.js.map +7 -0
  1216. package/dist/modules/query_index/lib/search-tokens.js +31 -1
  1217. package/dist/modules/query_index/lib/search-tokens.js.map +2 -2
  1218. package/dist/modules/resources/api/resources/tags/assign/route.js +2 -1
  1219. package/dist/modules/resources/api/resources/tags/assign/route.js.map +2 -2
  1220. package/dist/modules/resources/api/resources/tags/unassign/route.js +2 -1
  1221. package/dist/modules/resources/api/resources/tags/unassign/route.js.map +2 -2
  1222. package/dist/modules/resources/commands/activities.js +2 -2
  1223. package/dist/modules/resources/commands/activities.js.map +2 -2
  1224. package/dist/modules/sales/api/document-history/route.js +5 -1
  1225. package/dist/modules/sales/api/document-history/route.js.map +2 -2
  1226. package/dist/modules/sales/api/document-numbers/route.js +2 -1
  1227. package/dist/modules/sales/api/document-numbers/route.js.map +2 -2
  1228. package/dist/modules/sales/api/quotes/convert/route.js +2 -1
  1229. package/dist/modules/sales/api/quotes/convert/route.js.map +2 -2
  1230. package/dist/modules/sales/api/quotes/send/route.js +2 -1
  1231. package/dist/modules/sales/api/quotes/send/route.js.map +2 -2
  1232. package/dist/modules/sales/api/settings/document-numbers/route.js +7 -1
  1233. package/dist/modules/sales/api/settings/document-numbers/route.js.map +2 -2
  1234. package/dist/modules/sales/api/settings/order-editing/route.js +7 -1
  1235. package/dist/modules/sales/api/settings/order-editing/route.js.map +2 -2
  1236. package/dist/modules/sales/commands/documents.js +354 -138
  1237. package/dist/modules/sales/commands/documents.js.map +3 -3
  1238. package/dist/modules/sales/commands/payments.js +2 -1
  1239. package/dist/modules/sales/commands/payments.js.map +2 -2
  1240. package/dist/modules/sales/commands/settings.js +25 -5
  1241. package/dist/modules/sales/commands/settings.js.map +2 -2
  1242. package/dist/modules/sales/commands/shipments.js +2 -1
  1243. package/dist/modules/sales/commands/shipments.js.map +2 -2
  1244. package/dist/modules/sales/components/DocumentNumberSettings.js +32 -21
  1245. package/dist/modules/sales/components/DocumentNumberSettings.js.map +2 -2
  1246. package/dist/modules/sales/components/documents/ItemsSection.js +49 -11
  1247. package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
  1248. package/dist/modules/sales/lib/lineSnapshots.js +19 -0
  1249. package/dist/modules/sales/lib/lineSnapshots.js.map +2 -2
  1250. package/dist/modules/sales/setup.js +4 -4
  1251. package/dist/modules/sales/setup.js.map +2 -2
  1252. package/dist/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.js +2 -2
  1253. package/dist/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.js.map +2 -2
  1254. package/dist/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.js +2 -2
  1255. package/dist/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.js.map +2 -2
  1256. package/dist/modules/staff/api/leave-requests/accept/route.js +2 -1
  1257. package/dist/modules/staff/api/leave-requests/accept/route.js.map +2 -2
  1258. package/dist/modules/staff/api/leave-requests/reject/route.js +2 -1
  1259. package/dist/modules/staff/api/leave-requests/reject/route.js.map +2 -2
  1260. package/dist/modules/staff/api/leave-requests.js +2 -1
  1261. package/dist/modules/staff/api/leave-requests.js.map +2 -2
  1262. package/dist/modules/staff/api/team-members/self/route.js +2 -1
  1263. package/dist/modules/staff/api/team-members/self/route.js.map +2 -2
  1264. package/dist/modules/staff/api/team-members/tags/assign/route.js +2 -1
  1265. package/dist/modules/staff/api/team-members/tags/assign/route.js.map +2 -2
  1266. package/dist/modules/staff/api/team-members/tags/unassign/route.js +2 -1
  1267. package/dist/modules/staff/api/team-members/tags/unassign/route.js.map +2 -2
  1268. package/dist/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.js +12 -11
  1269. package/dist/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.js.map +2 -2
  1270. package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js +2 -1
  1271. package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js.map +2 -2
  1272. package/dist/modules/staff/api/timesheets/my-projects/route.js +2 -1
  1273. package/dist/modules/staff/api/timesheets/my-projects/route.js.map +2 -2
  1274. package/dist/modules/staff/api/timesheets/my-work/route.js +2 -1
  1275. package/dist/modules/staff/api/timesheets/my-work/route.js.map +2 -2
  1276. package/dist/modules/staff/api/timesheets/projects/kpis/route.js +2 -1
  1277. package/dist/modules/staff/api/timesheets/projects/kpis/route.js.map +2 -2
  1278. package/dist/modules/staff/api/timesheets/reports/[id]/close/route.js +2 -1
  1279. package/dist/modules/staff/api/timesheets/reports/[id]/close/route.js.map +2 -2
  1280. package/dist/modules/staff/api/timesheets/reports/[id]/export/route.js +3 -2
  1281. package/dist/modules/staff/api/timesheets/reports/[id]/export/route.js.map +2 -2
  1282. package/dist/modules/staff/api/timesheets/reports/[id]/sheet/route.js +3 -2
  1283. package/dist/modules/staff/api/timesheets/reports/[id]/sheet/route.js.map +2 -2
  1284. package/dist/modules/staff/api/timesheets/reports/[id]/unlock/route.js +3 -2
  1285. package/dist/modules/staff/api/timesheets/reports/[id]/unlock/route.js.map +2 -2
  1286. package/dist/modules/staff/api/timesheets/reports/preview/route.js +2 -1
  1287. package/dist/modules/staff/api/timesheets/reports/preview/route.js.map +2 -2
  1288. package/dist/modules/staff/api/timesheets/reports/shared.js +2 -1
  1289. package/dist/modules/staff/api/timesheets/reports/shared.js.map +2 -2
  1290. package/dist/modules/staff/api/timesheets/settings/reapply-rounding/route.js +2 -1
  1291. package/dist/modules/staff/api/timesheets/settings/reapply-rounding/route.js.map +2 -2
  1292. package/dist/modules/staff/api/timesheets/tags/entry-assignments/route.js +2 -1
  1293. package/dist/modules/staff/api/timesheets/tags/entry-assignments/route.js.map +2 -2
  1294. package/dist/modules/staff/api/timesheets/tags/task-assignments/route.js +2 -1
  1295. package/dist/modules/staff/api/timesheets/tags/task-assignments/route.js.map +2 -2
  1296. package/dist/modules/staff/api/timesheets/tasks/[id]/comments/route.js +2 -1
  1297. package/dist/modules/staff/api/timesheets/tasks/[id]/comments/route.js.map +2 -2
  1298. package/dist/modules/staff/api/timesheets/tasks/[id]/status/route.js +2 -1
  1299. package/dist/modules/staff/api/timesheets/tasks/[id]/status/route.js.map +2 -2
  1300. package/dist/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.js +3 -2
  1301. package/dist/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.js.map +2 -2
  1302. package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js +2 -1
  1303. package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js.map +2 -2
  1304. package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js +2 -1
  1305. package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js.map +2 -2
  1306. package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js +2 -1
  1307. package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js.map +2 -2
  1308. package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js +2 -1
  1309. package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js.map +2 -2
  1310. package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js +2 -1
  1311. package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js.map +2 -2
  1312. package/dist/modules/staff/api/timesheets/time-entries/copy-day/route.js +3 -2
  1313. package/dist/modules/staff/api/timesheets/time-entries/copy-day/route.js.map +2 -2
  1314. package/dist/modules/staff/api/timesheets/time-entries/overlaps/route.js +2 -1
  1315. package/dist/modules/staff/api/timesheets/time-entries/overlaps/route.js.map +2 -2
  1316. package/dist/modules/staff/api/timesheets/time-entries/start-timer/route.js +3 -2
  1317. package/dist/modules/staff/api/timesheets/time-entries/start-timer/route.js.map +2 -2
  1318. package/dist/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.js +3 -2
  1319. package/dist/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.js.map +2 -2
  1320. package/dist/modules/staff/api/timesheets/time-projects/route.js +2 -1
  1321. package/dist/modules/staff/api/timesheets/time-projects/route.js.map +2 -2
  1322. package/dist/modules/staff/commands/activities.js +2 -2
  1323. package/dist/modules/staff/commands/activities.js.map +2 -2
  1324. package/dist/modules/staff/commands/timesheets-entries.js.map +2 -2
  1325. package/dist/modules/staff/commands/timesheets-reports.js +55 -14
  1326. package/dist/modules/staff/commands/timesheets-reports.js.map +2 -2
  1327. package/dist/modules/staff/lib/timesheets-reports/buildReportSheet.js +2 -1
  1328. package/dist/modules/staff/lib/timesheets-reports/buildReportSheet.js.map +2 -2
  1329. package/dist/modules/staff/lib/timesheets-reports/loadReportData.js +32 -3
  1330. package/dist/modules/staff/lib/timesheets-reports/loadReportData.js.map +2 -2
  1331. package/dist/modules/staff/lib/timesheets-reports/reportPeriod.js +16 -0
  1332. package/dist/modules/staff/lib/timesheets-reports/reportPeriod.js.map +7 -0
  1333. package/dist/modules/staff/lib/timesheets-ui/CalendarPicker.js +15 -10
  1334. package/dist/modules/staff/lib/timesheets-ui/CalendarPicker.js.map +2 -2
  1335. package/dist/modules/sync_excel/api/import/route.js +35 -12
  1336. package/dist/modules/sync_excel/api/import/route.js.map +2 -2
  1337. package/dist/modules/sync_excel/api/upload/route.js +29 -4
  1338. package/dist/modules/sync_excel/api/upload/route.js.map +2 -2
  1339. package/dist/modules/translations/api/context.js +2 -1
  1340. package/dist/modules/translations/api/context.js.map +2 -2
  1341. package/dist/modules/warranty_claims/api/ai/assess/route.js +2 -1
  1342. package/dist/modules/warranty_claims/api/ai/assess/route.js.map +2 -2
  1343. package/dist/modules/warranty_claims/api/ai/draft-reply/route.js +2 -1
  1344. package/dist/modules/warranty_claims/api/ai/draft-reply/route.js.map +2 -2
  1345. package/dist/modules/warranty_claims/api/ai/suggest/route.js +2 -1
  1346. package/dist/modules/warranty_claims/api/ai/suggest/route.js.map +2 -2
  1347. package/dist/modules/warranty_claims/api/assign/route.js +2 -1
  1348. package/dist/modules/warranty_claims/api/assign/route.js.map +2 -2
  1349. package/dist/modules/warranty_claims/api/credit-memo/route.js +2 -1
  1350. package/dist/modules/warranty_claims/api/credit-memo/route.js.map +2 -2
  1351. package/dist/modules/warranty_claims/api/entitlement/route.js +2 -1
  1352. package/dist/modules/warranty_claims/api/entitlement/route.js.map +2 -2
  1353. package/dist/modules/warranty_claims/api/events/route.js +2 -1
  1354. package/dist/modules/warranty_claims/api/events/route.js.map +2 -2
  1355. package/dist/modules/warranty_claims/api/external/claims/route.js +2 -1
  1356. package/dist/modules/warranty_claims/api/external/claims/route.js.map +2 -2
  1357. package/dist/modules/warranty_claims/api/receiving/route.js +2 -1
  1358. package/dist/modules/warranty_claims/api/receiving/route.js.map +2 -2
  1359. package/dist/modules/warranty_claims/api/replacement-order/route.js +2 -1
  1360. package/dist/modules/warranty_claims/api/replacement-order/route.js.map +2 -2
  1361. package/dist/modules/warranty_claims/api/return-label/route.js +2 -1
  1362. package/dist/modules/warranty_claims/api/return-label/route.js.map +2 -2
  1363. package/dist/modules/warranty_claims/api/risk/route.js +2 -1
  1364. package/dist/modules/warranty_claims/api/risk/route.js.map +2 -2
  1365. package/dist/modules/warranty_claims/api/sales-return/route.js +2 -1
  1366. package/dist/modules/warranty_claims/api/sales-return/route.js.map +2 -2
  1367. package/dist/modules/warranty_claims/api/settings-general/route.js +2 -1
  1368. package/dist/modules/warranty_claims/api/settings-general/route.js.map +2 -2
  1369. package/dist/modules/warranty_claims/api/stats/route.js +9 -5
  1370. package/dist/modules/warranty_claims/api/stats/route.js.map +2 -2
  1371. package/dist/modules/warranty_claims/api/submit/route.js +2 -1
  1372. package/dist/modules/warranty_claims/api/submit/route.js.map +2 -2
  1373. package/dist/modules/warranty_claims/api/transition/route.js +2 -1
  1374. package/dist/modules/warranty_claims/api/transition/route.js.map +2 -2
  1375. package/dist/modules/warranty_claims/api/vendor-recovery/route.js +2 -1
  1376. package/dist/modules/warranty_claims/api/vendor-recovery/route.js.map +2 -2
  1377. package/dist/modules/warranty_claims/api/vendor-recovery-suggestions/route.js +2 -1
  1378. package/dist/modules/warranty_claims/api/vendor-recovery-suggestions/route.js.map +2 -2
  1379. package/dist/modules/warranty_claims/widgets/notifications/WarrantyClaimNotificationRenderer.js +1 -1
  1380. package/dist/modules/warranty_claims/widgets/notifications/WarrantyClaimNotificationRenderer.js.map +2 -2
  1381. package/dist/modules/wms/api/dashboard/operational/route.js +2 -1
  1382. package/dist/modules/wms/api/dashboard/operational/route.js.map +2 -2
  1383. package/dist/modules/wms/api/inventory/cycle-count/route.js +1 -0
  1384. package/dist/modules/wms/api/inventory/cycle-count/route.js.map +2 -2
  1385. package/dist/modules/wms/api/inventory/helpers.js +2 -1
  1386. package/dist/modules/wms/api/inventory/helpers.js.map +2 -2
  1387. package/dist/modules/wms/api/inventory/import/helpers.js +2 -1
  1388. package/dist/modules/wms/api/inventory/import/helpers.js.map +2 -2
  1389. package/dist/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.js +2 -1
  1390. package/dist/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.js.map +2 -2
  1391. package/dist/modules/wms/commands/inventory-actions.js +39 -1
  1392. package/dist/modules/wms/commands/inventory-actions.js.map +2 -2
  1393. package/dist/modules/wms/components/backend/CycleCountWizardDialog.js +14 -1
  1394. package/dist/modules/wms/components/backend/CycleCountWizardDialog.js.map +2 -2
  1395. package/dist/modules/wms/di.js +5 -0
  1396. package/dist/modules/wms/di.js.map +2 -2
  1397. package/dist/modules/wms/lib/availabilityCache.js +86 -0
  1398. package/dist/modules/wms/lib/availabilityCache.js.map +7 -0
  1399. package/dist/modules/wms/lib/availabilityCalculation.js +212 -0
  1400. package/dist/modules/wms/lib/availabilityCalculation.js.map +7 -0
  1401. package/dist/modules/wms/lib/availabilityProvider.js +24 -0
  1402. package/dist/modules/wms/lib/availabilityProvider.js.map +7 -0
  1403. package/dist/modules/wms/lib/loadOperationalDashboard.js +42 -5
  1404. package/dist/modules/wms/lib/loadOperationalDashboard.js.map +2 -2
  1405. package/dist/modules/wms/lib/lowStockBalanceFilter.js +23 -10
  1406. package/dist/modules/wms/lib/lowStockBalanceFilter.js.map +2 -2
  1407. package/dist/modules/wms/lib/sqlInClause.js +9 -0
  1408. package/dist/modules/wms/lib/sqlInClause.js.map +7 -0
  1409. package/dist/modules/wms/lib/tryResolve.js +11 -0
  1410. package/dist/modules/wms/lib/tryResolve.js.map +7 -0
  1411. package/dist/modules/wms/subscribers/invalidate-availability-cache-policy.js +14 -0
  1412. package/dist/modules/wms/subscribers/invalidate-availability-cache-policy.js.map +7 -0
  1413. package/dist/modules/wms/subscribers/invalidate-availability-cache-profile.js +14 -0
  1414. package/dist/modules/wms/subscribers/invalidate-availability-cache-profile.js.map +7 -0
  1415. package/dist/modules/wms/subscribers/invalidate-availability-cache.js +16 -0
  1416. package/dist/modules/wms/subscribers/invalidate-availability-cache.js.map +7 -0
  1417. package/dist/modules/wms/widgets/notifications/WmsLowStockRenderer.js +2 -2
  1418. package/dist/modules/wms/widgets/notifications/WmsLowStockRenderer.js.map +2 -2
  1419. package/dist/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.js +4 -3
  1420. package/dist/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.js.map +2 -2
  1421. package/dist/modules/workflows/api/commands/route.js +4 -1
  1422. package/dist/modules/workflows/api/commands/route.js.map +2 -2
  1423. package/dist/modules/workflows/api/definitions/[id]/callers/route.js +4 -1
  1424. package/dist/modules/workflows/api/definitions/[id]/callers/route.js.map +2 -2
  1425. package/dist/modules/workflows/api/definitions/[id]/context-schema/route.js +4 -2
  1426. package/dist/modules/workflows/api/definitions/[id]/context-schema/route.js.map +2 -2
  1427. package/dist/modules/workflows/api/definitions/[id]/customize/route.js +4 -1
  1428. package/dist/modules/workflows/api/definitions/[id]/customize/route.js.map +2 -2
  1429. package/dist/modules/workflows/api/definitions/[id]/draft/route.js +6 -1
  1430. package/dist/modules/workflows/api/definitions/[id]/draft/route.js.map +2 -2
  1431. package/dist/modules/workflows/api/definitions/[id]/publish/route.js +6 -1
  1432. package/dist/modules/workflows/api/definitions/[id]/publish/route.js.map +2 -2
  1433. package/dist/modules/workflows/api/definitions/[id]/reset-to-code/route.js +4 -1
  1434. package/dist/modules/workflows/api/definitions/[id]/reset-to-code/route.js.map +2 -2
  1435. package/dist/modules/workflows/api/definitions/[id]/route.js +5 -3
  1436. package/dist/modules/workflows/api/definitions/[id]/route.js.map +2 -2
  1437. package/dist/modules/workflows/api/definitions/[id]/test-step/route.js +4 -2
  1438. package/dist/modules/workflows/api/definitions/[id]/test-step/route.js.map +2 -2
  1439. package/dist/modules/workflows/api/definitions/generate/route.js +4 -1
  1440. package/dist/modules/workflows/api/definitions/generate/route.js.map +2 -2
  1441. package/dist/modules/workflows/api/definitions/route.js +4 -2
  1442. package/dist/modules/workflows/api/definitions/route.js.map +2 -2
  1443. package/dist/modules/workflows/api/endpoints/route.js +4 -1
  1444. package/dist/modules/workflows/api/endpoints/route.js.map +2 -2
  1445. package/dist/modules/workflows/api/functions/route.js +4 -1
  1446. package/dist/modules/workflows/api/functions/route.js.map +2 -2
  1447. package/dist/modules/workflows/api/grantable-features/route.js +2 -1
  1448. package/dist/modules/workflows/api/grantable-features/route.js.map +2 -2
  1449. package/dist/modules/workflows/api/instances/[id]/advance/route.js +4 -1
  1450. package/dist/modules/workflows/api/instances/[id]/advance/route.js.map +2 -2
  1451. package/dist/modules/workflows/api/instances/[id]/cancel/route.js +4 -1
  1452. package/dist/modules/workflows/api/instances/[id]/cancel/route.js.map +2 -2
  1453. package/dist/modules/workflows/api/instances/[id]/context/route.js +2 -1
  1454. package/dist/modules/workflows/api/instances/[id]/context/route.js.map +2 -2
  1455. package/dist/modules/workflows/api/instances/[id]/rerun-step/route.js +4 -1
  1456. package/dist/modules/workflows/api/instances/[id]/rerun-step/route.js.map +2 -2
  1457. package/dist/modules/workflows/api/instances/[id]/retry/route.js +4 -1
  1458. package/dist/modules/workflows/api/instances/[id]/retry/route.js.map +2 -2
  1459. package/dist/modules/workflows/api/instances/[id]/signal/route.js +4 -1
  1460. package/dist/modules/workflows/api/instances/[id]/signal/route.js.map +2 -2
  1461. package/dist/modules/workflows/api/instances/[id]/step-through/route.js +4 -2
  1462. package/dist/modules/workflows/api/instances/[id]/step-through/route.js.map +2 -2
  1463. package/dist/modules/workflows/api/instances/route.js +4 -2
  1464. package/dist/modules/workflows/api/instances/route.js.map +2 -2
  1465. package/dist/modules/workflows/api/instances/validate-start/route.js +4 -1
  1466. package/dist/modules/workflows/api/instances/validate-start/route.js.map +2 -2
  1467. package/dist/modules/workflows/api/rule-usage/route.js +4 -1
  1468. package/dist/modules/workflows/api/rule-usage/route.js.map +2 -2
  1469. package/dist/modules/workflows/api/signals/route.js +4 -1
  1470. package/dist/modules/workflows/api/signals/route.js.map +2 -2
  1471. package/dist/modules/workflows/api/tasks/[id]/claim/route.js +4 -1
  1472. package/dist/modules/workflows/api/tasks/[id]/claim/route.js.map +2 -2
  1473. package/dist/modules/workflows/api/tasks/[id]/complete/route.js +4 -1
  1474. package/dist/modules/workflows/api/tasks/[id]/complete/route.js.map +2 -2
  1475. package/dist/modules/workflows/api/tasks/[id]/reassign/route.js +2 -1
  1476. package/dist/modules/workflows/api/tasks/[id]/reassign/route.js.map +2 -2
  1477. package/dist/modules/workflows/api/tasks/[id]/unclaim/route.js +4 -1
  1478. package/dist/modules/workflows/api/tasks/[id]/unclaim/route.js.map +2 -2
  1479. package/dist/modules/workflows/api/templates/route.js +4 -1
  1480. package/dist/modules/workflows/api/templates/route.js.map +2 -2
  1481. package/dist/modules/workflows/api/work-inbox/next/route.js +4 -1
  1482. package/dist/modules/workflows/api/work-inbox/next/route.js.map +2 -2
  1483. package/dist/modules/workflows/lib/event-trigger-service.js +8 -1
  1484. package/dist/modules/workflows/lib/event-trigger-service.js.map +2 -2
  1485. package/dist/modules/workflows/lib/step-handler.js +4 -4
  1486. package/dist/modules/workflows/lib/step-handler.js.map +2 -2
  1487. package/dist/test-utils/transactionalEntityManagerDouble.js +37 -0
  1488. package/dist/test-utils/transactionalEntityManagerDouble.js.map +7 -0
  1489. package/generated/entities/availability_policy/index.ts +19 -0
  1490. package/generated/entities/communication_channel/index.ts +1 -0
  1491. package/generated/entities/customer_email_conversation_share/index.ts +9 -0
  1492. package/generated/entities/customer_group/index.ts +15 -0
  1493. package/generated/entities/customer_group_membership/index.ts +13 -0
  1494. package/generated/entities/customer_group_terms/index.ts +15 -0
  1495. package/generated/entities/customer_interaction/index.ts +1 -0
  1496. package/generated/entities/form/index.ts +16 -0
  1497. package/generated/entities/form_access_audit/index.ts +9 -0
  1498. package/generated/entities/form_attachment/index.ts +13 -0
  1499. package/generated/entities/form_consent_record/index.ts +17 -0
  1500. package/generated/entities/form_distribution/index.ts +22 -0
  1501. package/generated/entities/form_invitation/index.ts +23 -0
  1502. package/generated/entities/form_submission/index.ts +18 -0
  1503. package/generated/entities/form_submission_actor/index.ts +10 -0
  1504. package/generated/entities/form_submission_revision/index.ts +13 -0
  1505. package/generated/entities/form_version/index.ts +17 -0
  1506. package/generated/entities/forms_encryption_key/index.ts +6 -0
  1507. package/generated/entities.ids.generated.ts +27 -2
  1508. package/generated/entity-fields-registry.ts +269 -0
  1509. package/package.json +19 -9
  1510. package/src/helpers/integration/communicationChannelsFixtures.ts +43 -0
  1511. package/src/helpers/integration/customerGroupsFixtures.ts +171 -0
  1512. package/src/helpers/integration/formsFixtures.ts +757 -0
  1513. package/src/modules/api_docs/api/get/version.ts +28 -11
  1514. package/src/modules/api_keys/api/keys/route.ts +89 -199
  1515. package/src/modules/api_keys/backend/api-keys/create/page.tsx +2 -2
  1516. package/src/modules/api_keys/commands/keys.ts +172 -0
  1517. package/src/modules/api_keys/i18n/de.json +1 -0
  1518. package/src/modules/api_keys/i18n/en.json +1 -0
  1519. package/src/modules/api_keys/i18n/es.json +1 -0
  1520. package/src/modules/api_keys/i18n/ko.json +1 -0
  1521. package/src/modules/api_keys/i18n/pl.json +1 -0
  1522. package/src/modules/api_keys/services/apiKeyService.ts +82 -49
  1523. package/src/modules/attachments/api/file/[id]/route.ts +9 -4
  1524. package/src/modules/attachments/api/image/[id]/[[...slug]]/route.ts +6 -4
  1525. package/src/modules/attachments/api/route.ts +10 -4
  1526. package/src/modules/attachments/components/AttachmentLibrary.tsx +16 -5
  1527. package/src/modules/attachments/lib/access.ts +1 -3
  1528. package/src/modules/attachments/lib/requestScope.ts +35 -3
  1529. package/src/modules/audit_logs/api/audit-logs/actions/export/route.ts +6 -1
  1530. package/src/modules/audit_logs/api/audit-logs/actions/redo/route.ts +41 -6
  1531. package/src/modules/audit_logs/api/audit-logs/actions/route.ts +6 -1
  1532. package/src/modules/audit_logs/api/audit-logs/actions/undo/route.ts +39 -4
  1533. package/src/modules/audit_logs/data/validators.ts +1 -0
  1534. package/src/modules/audit_logs/lib/actorSubject.ts +82 -0
  1535. package/src/modules/audit_logs/lib/replayAuthorization.ts +61 -0
  1536. package/src/modules/audit_logs/services/actionLogService.ts +191 -47
  1537. package/src/modules/auth/api/features.ts +1 -1
  1538. package/src/modules/auth/cli.ts +31 -17
  1539. package/src/modules/auth/commands/acl.ts +26 -36
  1540. package/src/modules/auth/commands/interceptors.ts +23 -0
  1541. package/src/modules/auth/commands/roles.ts +475 -148
  1542. package/src/modules/auth/commands/users.ts +693 -81
  1543. package/src/modules/auth/i18n/de.json +22 -0
  1544. package/src/modules/auth/i18n/en.json +22 -0
  1545. package/src/modules/auth/i18n/es.json +22 -0
  1546. package/src/modules/auth/i18n/ko.json +22 -0
  1547. package/src/modules/auth/i18n/pl.json +22 -0
  1548. package/src/modules/auth/lib/authorizationStateLocks.ts +340 -0
  1549. package/src/modules/auth/lib/commandReplay.ts +194 -0
  1550. package/src/modules/auth/lib/executionPrincipal.ts +36 -28
  1551. package/src/modules/auth/lib/grantChecks.ts +10 -2
  1552. package/src/modules/auth/lib/setup-app.ts +97 -50
  1553. package/src/modules/auth/lib/tokenHash.ts +16 -1
  1554. package/src/modules/auth/services/rbacService.ts +578 -6
  1555. package/src/modules/availability/acl.ts +12 -0
  1556. package/src/modules/availability/api/check/route.ts +136 -0
  1557. package/src/modules/availability/api/openapi.ts +28 -0
  1558. package/src/modules/availability/api/policies/resolve-preview/route.ts +83 -0
  1559. package/src/modules/availability/api/policies/route.ts +243 -0
  1560. package/src/modules/availability/backend/availability/check/page.meta.ts +12 -0
  1561. package/src/modules/availability/backend/availability/check/page.tsx +226 -0
  1562. package/src/modules/availability/backend/availability/policies/ResolutionPreviewPanel.tsx +112 -0
  1563. package/src/modules/availability/backend/availability/policies/ScopeFields.tsx +55 -0
  1564. package/src/modules/availability/backend/availability/policies/StockManagedField.tsx +37 -0
  1565. package/src/modules/availability/backend/availability/policies/[id]/page.meta.ts +8 -0
  1566. package/src/modules/availability/backend/availability/policies/[id]/page.tsx +202 -0
  1567. package/src/modules/availability/backend/availability/policies/create/page.meta.ts +8 -0
  1568. package/src/modules/availability/backend/availability/policies/create/page.tsx +134 -0
  1569. package/src/modules/availability/backend/availability/policies/formGroups.ts +83 -0
  1570. package/src/modules/availability/backend/availability/policies/page.meta.ts +12 -0
  1571. package/src/modules/availability/backend/availability/policies/page.tsx +232 -0
  1572. package/src/modules/availability/backend/availability/policies/policyPayload.ts +29 -0
  1573. package/src/modules/availability/commands/policies.ts +430 -0
  1574. package/src/modules/availability/commands/scope.ts +26 -0
  1575. package/src/modules/availability/data/entities.ts +93 -0
  1576. package/src/modules/availability/data/validators.ts +87 -0
  1577. package/src/modules/availability/di.ts +68 -0
  1578. package/src/modules/availability/events.ts +17 -0
  1579. package/src/modules/availability/i18n/de.json +93 -0
  1580. package/src/modules/availability/i18n/en.json +93 -0
  1581. package/src/modules/availability/i18n/es.json +93 -0
  1582. package/src/modules/availability/i18n/ko.json +93 -0
  1583. package/src/modules/availability/i18n/pl.json +93 -0
  1584. package/src/modules/availability/index.ts +13 -0
  1585. package/src/modules/availability/lib/catalogTarget.ts +72 -0
  1586. package/src/modules/availability/lib/organizationScope.ts +55 -0
  1587. package/src/modules/availability/lib/policyResolution.ts +289 -0
  1588. package/src/modules/availability/lib/tryResolve.ts +8 -0
  1589. package/src/modules/availability/migrations/.snapshot-open-mercato.json +375 -0
  1590. package/src/modules/availability/migrations/Migration20260922095844_availability.ts +13 -0
  1591. package/src/modules/availability/migrations/Migration20260930120000_availability.ts +22 -0
  1592. package/src/modules/availability/setup.ts +10 -0
  1593. package/src/modules/catalog/api/categories/bulk-create/route.ts +133 -0
  1594. package/src/modules/catalog/api/categories/route.ts +70 -8
  1595. package/src/modules/catalog/api/products/bulk-create/route.ts +133 -0
  1596. package/src/modules/catalog/api/products/route.ts +55 -24
  1597. package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +9 -16
  1598. package/src/modules/catalog/backend/catalog/products/create/page.tsx +16 -10
  1599. package/src/modules/catalog/commands/categories.ts +1 -0
  1600. package/src/modules/catalog/commands/products.ts +11 -7
  1601. package/src/modules/catalog/components/PriceKindSettings.tsx +6 -20
  1602. package/src/modules/catalog/components/prices/PriceScopeSelectors.tsx +2 -2
  1603. package/src/modules/catalog/components/products/ProductUomSection.tsx +26 -37
  1604. package/src/modules/catalog/components/products/productForm.ts +6 -4
  1605. package/src/modules/catalog/data/validators.ts +22 -0
  1606. package/src/modules/catalog/di.ts +2 -1
  1607. package/src/modules/catalog/events.ts +9 -3
  1608. package/src/modules/catalog/i18n/de.json +40 -0
  1609. package/src/modules/catalog/i18n/en.json +40 -0
  1610. package/src/modules/catalog/i18n/es.json +40 -0
  1611. package/src/modules/catalog/i18n/ko.json +40 -0
  1612. package/src/modules/catalog/i18n/pl.json +40 -0
  1613. package/src/modules/catalog/lib/bulkCreateCategories.ts +349 -0
  1614. package/src/modules/catalog/lib/bulkCreateCheckpoint.ts +176 -0
  1615. package/src/modules/catalog/lib/bulkCreateMutationGuards.ts +62 -0
  1616. package/src/modules/catalog/lib/bulkCreateProducts.ts +340 -0
  1617. package/src/modules/catalog/lib/bulkDelete.ts +10 -14
  1618. package/src/modules/catalog/lib/catalogQueue.ts +14 -0
  1619. package/src/modules/catalog/lib/currencyOptions.ts +28 -0
  1620. package/src/modules/catalog/lib/productSearch.ts +16 -0
  1621. package/src/modules/catalog/lib/seeds.ts +2 -43
  1622. package/src/modules/catalog/lib/unitLabels.ts +52 -0
  1623. package/src/modules/catalog/migrations/Migration20260914120000.ts +51 -0
  1624. package/src/modules/catalog/migrations/Migration20260914120100.ts +50 -0
  1625. package/src/modules/catalog/workers/catalog-category-bulk-create.ts +48 -0
  1626. package/src/modules/catalog/workers/catalog-product-bulk-create.ts +48 -0
  1627. package/src/modules/communication_channels/acl.ts +8 -0
  1628. package/src/modules/communication_channels/api/get/me/channels/route.ts +4 -0
  1629. package/src/modules/communication_channels/api/get/oauth/[provider]/callback/route.ts +23 -0
  1630. package/src/modules/communication_channels/api/post/channels/[id]/import-history/route.ts +3 -4
  1631. package/src/modules/communication_channels/api/post/channels/[id]/test-send/route.ts +9 -1
  1632. package/src/modules/communication_channels/api/post/test-seed/route.ts +109 -24
  1633. package/src/modules/communication_channels/api/put/channels/[id]/visibility/route.ts +165 -0
  1634. package/src/modules/communication_channels/backend/profile/communication-channels/page.tsx +247 -129
  1635. package/src/modules/communication_channels/commands/ingest-inbound-message.ts +2 -1
  1636. package/src/modules/communication_channels/commands/set-channel-visibility.ts +138 -0
  1637. package/src/modules/communication_channels/data/enrichers.ts +42 -19
  1638. package/src/modules/communication_channels/data/entities.ts +21 -0
  1639. package/src/modules/communication_channels/di.ts +9 -0
  1640. package/src/modules/communication_channels/events.ts +7 -0
  1641. package/src/modules/communication_channels/i18n/de.json +13 -3
  1642. package/src/modules/communication_channels/i18n/en.json +13 -3
  1643. package/src/modules/communication_channels/i18n/es.json +13 -3
  1644. package/src/modules/communication_channels/i18n/ko.json +13 -3
  1645. package/src/modules/communication_channels/i18n/pl.json +13 -3
  1646. package/src/modules/communication_channels/index.ts +1 -1
  1647. package/src/modules/communication_channels/lib/access-control.ts +4 -1
  1648. package/src/modules/communication_channels/lib/adapter.ts +16 -6
  1649. package/src/modules/communication_channels/lib/channel-thread-access.ts +133 -0
  1650. package/src/modules/communication_channels/lib/credential-refresh.ts +27 -5
  1651. package/src/modules/communication_channels/lib/inbound-message-origin.ts +62 -0
  1652. package/src/modules/communication_channels/lib/oauth-state.ts +96 -1
  1653. package/src/modules/communication_channels/lib/outbound-delivery-intent.ts +57 -0
  1654. package/src/modules/communication_channels/lib/send-as-user.ts +2 -2
  1655. package/src/modules/communication_channels/migrations/.snapshot-open-mercato.json +18 -1
  1656. package/src/modules/communication_channels/migrations/Migration20260825141000_communication_channels.ts +22 -0
  1657. package/src/modules/communication_channels/setup.ts +4 -0
  1658. package/src/modules/communication_channels/subscribers/outbound-bridge.ts +34 -9
  1659. package/src/modules/communication_channels/workers/gmail-history-sync.ts +1 -1
  1660. package/src/modules/communication_channels/workers/poll-channel.ts +1 -1
  1661. package/src/modules/communication_channels/workers/reaction-processor.ts +2 -2
  1662. package/src/modules/configs/api/upgrade-actions/route.ts +2 -1
  1663. package/src/modules/configs/cli.ts +2 -2
  1664. package/src/modules/configs/i18n/de.json +2 -0
  1665. package/src/modules/configs/i18n/en.json +2 -0
  1666. package/src/modules/configs/i18n/es.json +2 -0
  1667. package/src/modules/configs/i18n/ko.json +2 -0
  1668. package/src/modules/configs/i18n/pl.json +2 -0
  1669. package/src/modules/configs/lib/upgrade-actions.ts +29 -6
  1670. package/src/modules/configs/services/upgradeActionsService.ts +45 -30
  1671. package/src/modules/currencies/api/currencies/route.ts +11 -5
  1672. package/src/modules/currencies/api/exchange-rates/route.ts +11 -5
  1673. package/src/modules/customer_accounts/AGENTS.md +1 -0
  1674. package/src/modules/customer_accounts/api/admin/users/[id]/sessions/[sessionId].ts +89 -0
  1675. package/src/modules/customer_groups/acl.ts +10 -0
  1676. package/src/modules/customer_groups/api/customer-groups/[id]/terms/route.ts +355 -0
  1677. package/src/modules/customer_groups/api/customer-groups/crud.ts +627 -0
  1678. package/src/modules/customer_groups/api/customer-groups/explain-terms/route.ts +195 -0
  1679. package/src/modules/customer_groups/api/customer-groups/memberships/crud.ts +525 -0
  1680. package/src/modules/customer_groups/api/customer-groups/memberships/route.ts +65 -0
  1681. package/src/modules/customer_groups/api/customer-groups/price-kinds/route.ts +99 -0
  1682. package/src/modules/customer_groups/api/customer-groups/reconcile/adopt/route.ts +150 -0
  1683. package/src/modules/customer_groups/api/customer-groups/reconcile/route.ts +90 -0
  1684. package/src/modules/customer_groups/api/customer-groups/reorder/route.ts +147 -0
  1685. package/src/modules/customer_groups/api/customer-groups/route.ts +65 -0
  1686. package/src/modules/customer_groups/api/openapi.ts +28 -0
  1687. package/src/modules/customer_groups/backend/customer-groups/[id]/edit/page.meta.ts +12 -0
  1688. package/src/modules/customer_groups/backend/customer-groups/[id]/edit/page.tsx +392 -0
  1689. package/src/modules/customer_groups/backend/customer-groups/create/page.meta.ts +25 -0
  1690. package/src/modules/customer_groups/backend/customer-groups/create/page.tsx +279 -0
  1691. package/src/modules/customer_groups/backend/customer-groups/orphans/page.meta.ts +12 -0
  1692. package/src/modules/customer_groups/backend/customer-groups/orphans/page.tsx +216 -0
  1693. package/src/modules/customer_groups/backend/customer-groups/page.meta.ts +11 -0
  1694. package/src/modules/customer_groups/backend/customer-groups/page.tsx +484 -0
  1695. package/src/modules/customer_groups/cli.ts +87 -0
  1696. package/src/modules/customer_groups/commands/reorderGroups.ts +163 -0
  1697. package/src/modules/customer_groups/components/CustomerGroupDefaultField.tsx +55 -0
  1698. package/src/modules/customer_groups/components/CustomerGroupParentField.tsx +194 -0
  1699. package/src/modules/customer_groups/components/CustomerGroupTermsPriceKindField.tsx +112 -0
  1700. package/src/modules/customer_groups/components/CustomerGroupTermsSection.tsx +277 -0
  1701. package/src/modules/customer_groups/components/GroupPickerField.tsx +142 -0
  1702. package/src/modules/customer_groups/components/OrphanBanner.tsx +92 -0
  1703. package/src/modules/customer_groups/components/customerGroupTree.ts +84 -0
  1704. package/src/modules/customer_groups/data/entities.ts +244 -0
  1705. package/src/modules/customer_groups/data/validators.ts +232 -0
  1706. package/src/modules/customer_groups/di.ts +25 -0
  1707. package/src/modules/customer_groups/events.ts +22 -0
  1708. package/src/modules/customer_groups/i18n/de.json +199 -0
  1709. package/src/modules/customer_groups/i18n/en.json +199 -0
  1710. package/src/modules/customer_groups/i18n/es.json +199 -0
  1711. package/src/modules/customer_groups/i18n/ko.json +199 -0
  1712. package/src/modules/customer_groups/i18n/pl.json +199 -0
  1713. package/src/modules/customer_groups/index.ts +13 -0
  1714. package/src/modules/customer_groups/lib/createConflictRecheck.ts +39 -0
  1715. package/src/modules/customer_groups/lib/customerScope.ts +145 -0
  1716. package/src/modules/customer_groups/lib/groupEvents.ts +50 -0
  1717. package/src/modules/customer_groups/lib/priceKindScope.ts +65 -0
  1718. package/src/modules/customer_groups/lib/reconcile.ts +299 -0
  1719. package/src/modules/customer_groups/migrations/.snapshot-open-mercato.json +905 -0
  1720. package/src/modules/customer_groups/migrations/Migration20260922095316_customer_groups.ts +26 -0
  1721. package/src/modules/customer_groups/migrations/Migration20260922103033_customer_groups.ts +22 -0
  1722. package/src/modules/customer_groups/migrations/Migration20260922105444_customer_groups.ts +17 -0
  1723. package/src/modules/customer_groups/migrations/Migration20260923193330_customer_groups.ts +20 -0
  1724. package/src/modules/customer_groups/migrations/Migration20260929083000_customer_groups.ts +21 -0
  1725. package/src/modules/customer_groups/services/customerGroupsService.ts +358 -0
  1726. package/src/modules/customer_groups/setup.ts +11 -0
  1727. package/src/modules/customer_groups/widgets/injection/group-picker-field/widget.ts +41 -0
  1728. package/src/modules/customer_groups/widgets/injection/person-groups-explain-terms.tsx +227 -0
  1729. package/src/modules/customer_groups/widgets/injection/person-groups-tab/widget.ts +21 -0
  1730. package/src/modules/customer_groups/widgets/injection/person-groups-tab.tsx +573 -0
  1731. package/src/modules/customer_groups/widgets/injection-table.ts +35 -0
  1732. package/src/modules/customers/acl.ts +13 -0
  1733. package/src/modules/customers/api/activities/route.ts +10 -0
  1734. package/src/modules/customers/api/companies/[id]/people/route.ts +2 -1
  1735. package/src/modules/customers/api/companies/[id]/route.ts +20 -6
  1736. package/src/modules/customers/api/deals/[id]/companies/route.ts +2 -1
  1737. package/src/modules/customers/api/deals/[id]/people/route.ts +2 -1
  1738. package/src/modules/customers/api/deals/map/route.ts +11 -10
  1739. package/src/modules/customers/api/dictionaries/context.ts +2 -1
  1740. package/src/modules/customers/api/entity-roles-factory.ts +3 -2
  1741. package/src/modules/customers/api/interactions/[id]/visibility/route.ts +2 -1
  1742. package/src/modules/customers/api/interactions/cancel/route.ts +2 -1
  1743. package/src/modules/customers/api/interactions/complete/route.ts +2 -1
  1744. package/src/modules/customers/api/interactions/conflicts/route.ts +10 -10
  1745. package/src/modules/customers/api/interactions/counts/route.ts +25 -7
  1746. package/src/modules/customers/api/interactions/route.ts +34 -10
  1747. package/src/modules/customers/api/labels/assign/route.ts +2 -1
  1748. package/src/modules/customers/api/labels/route.ts +3 -2
  1749. package/src/modules/customers/api/labels/unassign/route.ts +2 -1
  1750. package/src/modules/customers/api/people/[id]/companies/context.ts +11 -2
  1751. package/src/modules/customers/api/people/[id]/email-share/route.ts +276 -0
  1752. package/src/modules/customers/api/people/[id]/email-threads/route.ts +14 -1
  1753. package/src/modules/customers/api/people/[id]/emails/route.ts +2 -1
  1754. package/src/modules/customers/api/people/[id]/route.ts +31 -22
  1755. package/src/modules/customers/api/people/check-phone/route.ts +2 -1
  1756. package/src/modules/customers/api/pipeline-stages/reorder/route.ts +3 -2
  1757. package/src/modules/customers/api/pipeline-stages/route.ts +3 -3
  1758. package/src/modules/customers/api/pipelines/route.ts +3 -3
  1759. package/src/modules/customers/api/settings/address-format/route.ts +2 -1
  1760. package/src/modules/customers/api/settings/dictionary-sort-modes/route.ts +2 -1
  1761. package/src/modules/customers/api/settings/stuck-threshold/route.ts +2 -1
  1762. package/src/modules/customers/api/tags/assign/route.ts +2 -1
  1763. package/src/modules/customers/api/tags/unassign/route.ts +2 -1
  1764. package/src/modules/customers/backend/customers/companies/[id]/page.tsx +4 -2
  1765. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.ts +10 -6
  1766. package/src/modules/customers/backend/customers/deals/[id]/page.tsx +6 -1
  1767. package/src/modules/customers/backend/customers/deals/components/ReassignOwnerDialog.tsx +115 -0
  1768. package/src/modules/customers/backend/customers/deals/page.tsx +121 -1
  1769. package/src/modules/customers/backend/customers/people/[id]/page.tsx +4 -2
  1770. package/src/modules/customers/commands/addresses.ts +117 -15
  1771. package/src/modules/customers/commands/companies.ts +26 -5
  1772. package/src/modules/customers/commands/emailConversationShares.ts +261 -0
  1773. package/src/modules/customers/commands/index.ts +1 -0
  1774. package/src/modules/customers/commands/interactions.ts +61 -21
  1775. package/src/modules/customers/commands/people.ts +3 -2
  1776. package/src/modules/customers/commands/shared.ts +4 -0
  1777. package/src/modules/customers/components/calendar/types.ts +1 -1
  1778. package/src/modules/customers/components/detail/CompanyPeopleSection.tsx +3 -11
  1779. package/src/modules/customers/components/detail/DealForm.tsx +111 -2
  1780. package/src/modules/customers/components/detail/DealOwnerSelect.tsx +161 -0
  1781. package/src/modules/customers/components/detail/DealsSection.tsx +8 -14
  1782. package/src/modules/customers/components/detail/PersonEmailShareControl.tsx +273 -0
  1783. package/src/modules/customers/components/detail/PersonEmailThreadsTab.tsx +26 -0
  1784. package/src/modules/customers/components/detail/ScheduleActivityDialog.tsx +10 -2
  1785. package/src/modules/customers/components/detail/create/CreateDealForm.tsx +30 -0
  1786. package/src/modules/customers/components/detail/create/DealDetailsFields.tsx +12 -0
  1787. package/src/modules/customers/components/detail/create/DealSectionCard.tsx +7 -2
  1788. package/src/modules/customers/components/detail/create/dealFormTypes.ts +3 -0
  1789. package/src/modules/customers/components/detail/schedule/useScheduleFormState.ts +16 -4
  1790. package/src/modules/customers/components/formConfig.tsx +3 -0
  1791. package/src/modules/customers/components/linking/LinkEntityDialog.tsx +8 -0
  1792. package/src/modules/customers/data/enrichers.ts +64 -5
  1793. package/src/modules/customers/data/entities.ts +105 -1
  1794. package/src/modules/customers/data/validators.ts +22 -0
  1795. package/src/modules/customers/events.ts +5 -0
  1796. package/src/modules/customers/i18n/de.json +28 -5
  1797. package/src/modules/customers/i18n/en.json +23 -0
  1798. package/src/modules/customers/i18n/es.json +23 -0
  1799. package/src/modules/customers/i18n/ko.json +23 -0
  1800. package/src/modules/customers/i18n/pl.json +23 -0
  1801. package/src/modules/customers/lib/assignableStaff.ts +17 -0
  1802. package/src/modules/customers/lib/calendar/editorPayload.ts +20 -13
  1803. package/src/modules/customers/lib/calendar/mapItem.ts +1 -0
  1804. package/src/modules/customers/lib/conversationShares.ts +250 -0
  1805. package/src/modules/customers/lib/dealsOrganizationScope.ts +5 -3
  1806. package/src/modules/customers/lib/interactionRequestContext.ts +2 -1
  1807. package/src/modules/customers/lib/link-channel-message-handler.ts +27 -4
  1808. package/src/modules/customers/lib/personDetailCacheTags.ts +68 -0
  1809. package/src/modules/customers/lib/personEmailThreads.ts +61 -6
  1810. package/src/modules/customers/lib/reassignDealOwner.ts +51 -0
  1811. package/src/modules/customers/lib/userNames.ts +39 -0
  1812. package/src/modules/customers/lib/visibilityFilter.ts +170 -3
  1813. package/src/modules/customers/migrations/.snapshot-open-mercato.json +240 -0
  1814. package/src/modules/customers/migrations/Migration20260825120000_customers.ts +19 -0
  1815. package/src/modules/customers/migrations/Migration20260825140000_customers.ts +41 -0
  1816. package/src/modules/customers/setup.ts +1 -0
  1817. package/src/modules/customers/subscribers/channel-visibility-changed.ts +50 -0
  1818. package/src/modules/dashboards/api/widgets/data/batch/route.ts +3 -8
  1819. package/src/modules/dashboards/api/widgets/data/route.ts +12 -18
  1820. package/src/modules/dashboards/lib/aggregations.ts +1 -1
  1821. package/src/modules/dashboards/lib/widgetScope.ts +2 -7
  1822. package/src/modules/data_sync/AGENTS.md +35 -1
  1823. package/src/modules/data_sync/api/runs/[id]/cancel.ts +5 -1
  1824. package/src/modules/data_sync/backend/data-sync/page.tsx +292 -19
  1825. package/src/modules/data_sync/backend/data-sync/runs/[id]/page.tsx +205 -21
  1826. package/src/modules/data_sync/components/useDataSyncRunAccess.ts +27 -0
  1827. package/src/modules/data_sync/i18n/de.json +24 -0
  1828. package/src/modules/data_sync/i18n/en.json +24 -0
  1829. package/src/modules/data_sync/i18n/es.json +24 -0
  1830. package/src/modules/data_sync/i18n/ko.json +24 -0
  1831. package/src/modules/data_sync/i18n/pl.json +24 -0
  1832. package/src/modules/data_sync/lib/adapter.ts +37 -0
  1833. package/src/modules/data_sync/lib/resume-point.ts +63 -0
  1834. package/src/modules/data_sync/lib/start-run.ts +61 -2
  1835. package/src/modules/data_sync/lib/sync-run-service.ts +27 -34
  1836. package/src/modules/devices/api/[id]/route.ts +3 -2
  1837. package/src/modules/devices/api/admin/devices/route.ts +2 -1
  1838. package/src/modules/devices/api/route.ts +2 -1
  1839. package/src/modules/dictionaries/api/[dictionaryId]/route.ts +3 -5
  1840. package/src/modules/dictionaries/api/context.ts +2 -1
  1841. package/src/modules/dictionaries/api/route.ts +4 -0
  1842. package/src/modules/dictionaries/components/DictionariesManager.tsx +12 -4
  1843. package/src/modules/dictionaries/data/validators.ts +9 -1
  1844. package/src/modules/dictionaries/i18n/de.json +3 -3
  1845. package/src/modules/dictionaries/i18n/en.json +3 -3
  1846. package/src/modules/dictionaries/i18n/es.json +3 -3
  1847. package/src/modules/dictionaries/i18n/ko.json +3 -3
  1848. package/src/modules/dictionaries/i18n/pl.json +3 -3
  1849. package/src/modules/directory/api/organization-branding/route.ts +10 -1
  1850. package/src/modules/directory/api/organizations/route.ts +1 -1
  1851. package/src/modules/directory/backend/directory/branding/page.tsx +24 -2
  1852. package/src/modules/directory/commands/organizations.ts +173 -80
  1853. package/src/modules/directory/i18n/de.json +1 -0
  1854. package/src/modules/directory/i18n/en.json +1 -0
  1855. package/src/modules/directory/i18n/es.json +1 -0
  1856. package/src/modules/directory/i18n/ko.json +1 -0
  1857. package/src/modules/directory/i18n/pl.json +1 -0
  1858. package/src/modules/directory/lib/hierarchy.ts +22 -1
  1859. package/src/modules/directory/utils/organizationScope.ts +102 -15
  1860. package/src/modules/directory/utils/organizationScopeFilter.ts +6 -3
  1861. package/src/modules/directory/utils/organizationScopeGuard.ts +9 -5
  1862. package/src/modules/entities/api/encryption.ts +73 -27
  1863. package/src/modules/entities/api/records.ts +9 -8
  1864. package/src/modules/entities/cli.ts +46 -24
  1865. package/src/modules/entities/data/entities.ts +15 -0
  1866. package/src/modules/entities/lib/definition-scope.ts +5 -1
  1867. package/src/modules/entities/lib/encryption-maps.ts +164 -0
  1868. package/src/modules/entities/lib/helpers.ts +95 -8
  1869. package/src/modules/entities/migrations/.snapshot-open-mercato.json +21 -0
  1870. package/src/modules/entities/migrations/.snapshot-openmercato.json +12 -0
  1871. package/src/modules/entities/migrations/Migration20260910120000.ts +42 -0
  1872. package/src/modules/entities/migrations/Migration20261004120000_encryption_map_scope_uniqueness.ts +130 -0
  1873. package/src/modules/eudr/api/dashboard/widgets/compliance-overview/route.ts +2 -1
  1874. package/src/modules/eudr/api/plots/import/route.ts +2 -1
  1875. package/src/modules/eudr/api/product-mappings/suggestions/apply/route.ts +2 -1
  1876. package/src/modules/eudr/api/product-mappings/suggestions/route.ts +2 -1
  1877. package/src/modules/eudr/api/reports/annual/route.ts +2 -1
  1878. package/src/modules/eudr/api/statements/[id]/export/route.ts +2 -1
  1879. package/src/modules/eudr/api/statements/[id]/readiness/route.ts +2 -1
  1880. package/src/modules/eudr/api/suppliers/compliance/route.ts +2 -1
  1881. package/src/modules/eudr/i18n/de.json +1 -0
  1882. package/src/modules/eudr/i18n/en.json +1 -0
  1883. package/src/modules/eudr/i18n/es.json +1 -0
  1884. package/src/modules/eudr/i18n/ko.json +1 -0
  1885. package/src/modules/eudr/i18n/pl.json +1 -0
  1886. package/src/modules/feature_toggles/commands/global.ts +18 -15
  1887. package/src/modules/feature_toggles/lib/feature-flag-check.ts +8 -3
  1888. package/src/modules/forms/acl.ts +10 -0
  1889. package/src/modules/forms/api/[id]/analytics/route.ts +137 -0
  1890. package/src/modules/forms/api/[id]/distributions/route.ts +192 -0
  1891. package/src/modules/forms/api/[id]/route.ts +245 -0
  1892. package/src/modules/forms/api/[id]/run/context/route.ts +142 -0
  1893. package/src/modules/forms/api/[id]/run/submissions/route.ts +147 -0
  1894. package/src/modules/forms/api/[id]/submissions/route.ts +100 -0
  1895. package/src/modules/forms/api/[id]/theme-logo/route.ts +147 -0
  1896. package/src/modules/forms/api/[id]/versions/[versionId]/diff/route.ts +137 -0
  1897. package/src/modules/forms/api/[id]/versions/[versionId]/publish/route.ts +108 -0
  1898. package/src/modules/forms/api/[id]/versions/[versionId]/route.ts +200 -0
  1899. package/src/modules/forms/api/[id]/versions/fork/route.ts +98 -0
  1900. package/src/modules/forms/api/attachment-helpers.ts +160 -0
  1901. package/src/modules/forms/api/by-key/[key]/active/route.ts +165 -0
  1902. package/src/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/route.ts +92 -0
  1903. package/src/modules/forms/api/distributions/[distributionId]/invitations/[invitationId]/send/route.ts +96 -0
  1904. package/src/modules/forms/api/distributions/[distributionId]/invitations/route.ts +207 -0
  1905. package/src/modules/forms/api/distributions/[distributionId]/route.ts +213 -0
  1906. package/src/modules/forms/api/form-submissions/[id]/attachments/route.ts +114 -0
  1907. package/src/modules/forms/api/form-submissions/[id]/resume-token/route.ts +140 -0
  1908. package/src/modules/forms/api/form-submissions/[id]/route.ts +176 -0
  1909. package/src/modules/forms/api/form-submissions/[id]/submit/route.ts +91 -0
  1910. package/src/modules/forms/api/form-submissions/by-subject/[subject_type]/[subject_id]/route.ts +93 -0
  1911. package/src/modules/forms/api/form-submissions/route.ts +133 -0
  1912. package/src/modules/forms/api/helpers.ts +175 -0
  1913. package/src/modules/forms/api/public/distributions/[slug]/embed-policy/route.ts +74 -0
  1914. package/src/modules/forms/api/public/distributions/[slug]/route.ts +101 -0
  1915. package/src/modules/forms/api/public/embed-loader/route.ts +136 -0
  1916. package/src/modules/forms/api/public/invitations/[token]/route.ts +107 -0
  1917. package/src/modules/forms/api/public/rate-limit.ts +69 -0
  1918. package/src/modules/forms/api/public/start/route.ts +195 -0
  1919. package/src/modules/forms/api/public/submissions/[id]/attachments/[attachmentId]/route.ts +86 -0
  1920. package/src/modules/forms/api/public/submissions/[id]/attachments/route.ts +108 -0
  1921. package/src/modules/forms/api/public/submissions/[id]/pdf/route.ts +96 -0
  1922. package/src/modules/forms/api/public/submissions/[id]/route.ts +189 -0
  1923. package/src/modules/forms/api/public/submissions/[id]/submit/route.ts +159 -0
  1924. package/src/modules/forms/api/route.ts +240 -0
  1925. package/src/modules/forms/api/runtime-helpers.ts +208 -0
  1926. package/src/modules/forms/api/subjects/[subjectType]/[subjectId]/consents/route.ts +178 -0
  1927. package/src/modules/forms/api/subjects/[subjectType]/[subjectId]/export/route.ts +135 -0
  1928. package/src/modules/forms/api/submissions/[submissionId]/access-audit/route.ts +100 -0
  1929. package/src/modules/forms/api/submissions/[submissionId]/actors/[actorId]/route.ts +70 -0
  1930. package/src/modules/forms/api/submissions/[submissionId]/actors/route.ts +92 -0
  1931. package/src/modules/forms/api/submissions/[submissionId]/anonymize/route.ts +134 -0
  1932. package/src/modules/forms/api/submissions/[submissionId]/attachments/[attachmentId]/route.ts +90 -0
  1933. package/src/modules/forms/api/submissions/[submissionId]/export/route.ts +111 -0
  1934. package/src/modules/forms/api/submissions/[submissionId]/pdf/route.ts +118 -0
  1935. package/src/modules/forms/api/submissions/[submissionId]/reopen/route.ts +69 -0
  1936. package/src/modules/forms/api/submissions/[submissionId]/revisions/route.ts +75 -0
  1937. package/src/modules/forms/api/submissions/[submissionId]/route.ts +90 -0
  1938. package/src/modules/forms/backend/forms/[id]/FormStudio.tsx +3269 -0
  1939. package/src/modules/forms/backend/forms/[id]/analytics/page.meta.ts +15 -0
  1940. package/src/modules/forms/backend/forms/[id]/analytics/page.tsx +289 -0
  1941. package/src/modules/forms/backend/forms/[id]/distributions/page.meta.ts +15 -0
  1942. package/src/modules/forms/backend/forms/[id]/distributions/page.tsx +16 -0
  1943. package/src/modules/forms/backend/forms/[id]/history/page.meta.ts +11 -0
  1944. package/src/modules/forms/backend/forms/[id]/history/page.tsx +229 -0
  1945. package/src/modules/forms/backend/forms/[id]/page.meta.ts +11 -0
  1946. package/src/modules/forms/backend/forms/[id]/page.tsx +17 -0
  1947. package/src/modules/forms/backend/forms/[id]/studio/YesNoRow.tsx +65 -0
  1948. package/src/modules/forms/backend/forms/[id]/studio/autosave-guard.ts +25 -0
  1949. package/src/modules/forms/backend/forms/[id]/studio/canvas/DragOverlayCard.tsx +24 -0
  1950. package/src/modules/forms/backend/forms/[id]/studio/canvas/DropIndicator.tsx +36 -0
  1951. package/src/modules/forms/backend/forms/[id]/studio/canvas/FieldRow.tsx +308 -0
  1952. package/src/modules/forms/backend/forms/[id]/studio/canvas/FormCanvas.tsx +265 -0
  1953. package/src/modules/forms/backend/forms/[id]/studio/canvas/GridSlot.tsx +176 -0
  1954. package/src/modules/forms/backend/forms/[id]/studio/canvas/SectionContainer.tsx +473 -0
  1955. package/src/modules/forms/backend/forms/[id]/studio/canvas/grid-collision.ts +25 -0
  1956. package/src/modules/forms/backend/forms/[id]/studio/canvas/keyboard-coordinates.ts +128 -0
  1957. package/src/modules/forms/backend/forms/[id]/studio/canvas/overlay-size.ts +15 -0
  1958. package/src/modules/forms/backend/forms/[id]/studio/canvas/resize-math.ts +36 -0
  1959. package/src/modules/forms/backend/forms/[id]/studio/canvas/row-layout.ts +110 -0
  1960. package/src/modules/forms/backend/forms/[id]/studio/logic/ConditionBuilder.tsx +264 -0
  1961. package/src/modules/forms/backend/forms/[id]/studio/logic/HiddenFieldsPanel.tsx +121 -0
  1962. package/src/modules/forms/backend/forms/[id]/studio/logic/JumpsEditor.tsx +237 -0
  1963. package/src/modules/forms/backend/forms/[id]/studio/logic/RecallTokenPicker.tsx +87 -0
  1964. package/src/modules/forms/backend/forms/[id]/studio/logic/VariablesPanel.tsx +260 -0
  1965. package/src/modules/forms/backend/forms/[id]/studio/logic/condition-model.ts +207 -0
  1966. package/src/modules/forms/backend/forms/[id]/studio/lucide-icons.ts +87 -0
  1967. package/src/modules/forms/backend/forms/[id]/studio/palette/FormAppearancePanel.tsx +561 -0
  1968. package/src/modules/forms/backend/forms/[id]/studio/palette/FormPalettePanel.tsx +52 -0
  1969. package/src/modules/forms/backend/forms/[id]/studio/palette/InputParametersTab.tsx +378 -0
  1970. package/src/modules/forms/backend/forms/[id]/studio/palette/PaletteCard.tsx +40 -0
  1971. package/src/modules/forms/backend/forms/[id]/studio/palette/RolesEditor.tsx +225 -0
  1972. package/src/modules/forms/backend/forms/[id]/studio/palette/entries.ts +102 -0
  1973. package/src/modules/forms/backend/forms/[id]/studio/preview/PreviewSurface.tsx +1459 -0
  1974. package/src/modules/forms/backend/forms/[id]/studio/preview/ViewportFrame.tsx +49 -0
  1975. package/src/modules/forms/backend/forms/[id]/studio/recall.ts +0 -0
  1976. package/src/modules/forms/backend/forms/[id]/studio/schema-helpers.ts +2525 -0
  1977. package/src/modules/forms/backend/forms/[id]/studio/style/BackgroundControl.tsx +137 -0
  1978. package/src/modules/forms/backend/forms/[id]/studio/style/ColorControl.tsx +257 -0
  1979. package/src/modules/forms/backend/forms/[id]/studio/style/contrast.ts +114 -0
  1980. package/src/modules/forms/backend/forms/[id]/studio/style/presets.ts +104 -0
  1981. package/src/modules/forms/backend/forms/[id]/studio/type-label.ts +13 -0
  1982. package/src/modules/forms/backend/forms/[id]/studio/types.ts +31 -0
  1983. package/src/modules/forms/backend/forms/[id]/studio/undo-controller.ts +52 -0
  1984. package/src/modules/forms/backend/forms/[id]/studio/validation/FileConstraintsEditor.tsx +89 -0
  1985. package/src/modules/forms/backend/forms/[id]/studio/validation/GroupConfigEditor.tsx +167 -0
  1986. package/src/modules/forms/backend/forms/[id]/studio/validation/LengthRangeEditor.tsx +67 -0
  1987. package/src/modules/forms/backend/forms/[id]/studio/validation/MatrixColumnsEditor.tsx +166 -0
  1988. package/src/modules/forms/backend/forms/[id]/studio/validation/MatrixRowsEditor.tsx +184 -0
  1989. package/src/modules/forms/backend/forms/[id]/studio/validation/MessageOverridesEditor.tsx +83 -0
  1990. package/src/modules/forms/backend/forms/[id]/studio/validation/NpsAnchorsEditor.tsx +60 -0
  1991. package/src/modules/forms/backend/forms/[id]/studio/validation/NumberRangeEditor.tsx +65 -0
  1992. package/src/modules/forms/backend/forms/[id]/studio/validation/OpinionIconSelect.tsx +46 -0
  1993. package/src/modules/forms/backend/forms/[id]/studio/validation/PatternEditor.tsx +122 -0
  1994. package/src/modules/forms/backend/forms/[id]/studio/validation/RankingExhaustiveSwitch.tsx +28 -0
  1995. package/src/modules/forms/backend/forms/[id]/studio/validation/SignatureConfigEditor.tsx +84 -0
  1996. package/src/modules/forms/backend/forms/[id]/studio/validation/ValidationPanel.tsx +369 -0
  1997. package/src/modules/forms/backend/forms/[id]/submissions/components/RowBadges.ts +56 -0
  1998. package/src/modules/forms/backend/forms/[id]/submissions/components/SubmissionDrawer.tsx +605 -0
  1999. package/src/modules/forms/backend/forms/[id]/submissions/components/formSummary.ts +19 -0
  2000. package/src/modules/forms/backend/forms/[id]/submissions/page.meta.ts +10 -0
  2001. package/src/modules/forms/backend/forms/[id]/submissions/page.tsx +252 -0
  2002. package/src/modules/forms/backend/forms/create/page.meta.ts +11 -0
  2003. package/src/modules/forms/backend/forms/create/page.tsx +113 -0
  2004. package/src/modules/forms/backend/forms/page.meta.ts +31 -0
  2005. package/src/modules/forms/backend/forms/page.tsx +269 -0
  2006. package/src/modules/forms/commands/distribution.ts +506 -0
  2007. package/src/modules/forms/commands/form-version.ts +811 -0
  2008. package/src/modules/forms/commands/form.ts +477 -0
  2009. package/src/modules/forms/commands/index.ts +18 -0
  2010. package/src/modules/forms/commands/invitation.ts +428 -0
  2011. package/src/modules/forms/commands/shared.ts +261 -0
  2012. package/src/modules/forms/commands/submission.ts +216 -0
  2013. package/src/modules/forms/data/entities.ts +686 -0
  2014. package/src/modules/forms/data/validators.ts +483 -0
  2015. package/src/modules/forms/di.ts +246 -0
  2016. package/src/modules/forms/encryption.ts +31 -0
  2017. package/src/modules/forms/events-payloads.ts +103 -0
  2018. package/src/modules/forms/events.ts +50 -0
  2019. package/src/modules/forms/extension-points.ts +41 -0
  2020. package/src/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.meta.ts +9 -0
  2021. package/src/modules/forms/frontend/[orgSlug]/portal/forms/[key]/page.tsx +45 -0
  2022. package/src/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.meta.ts +9 -0
  2023. package/src/modules/forms/frontend/[orgSlug]/portal/submissions/[id]/continue/page.tsx +56 -0
  2024. package/src/modules/forms/frontend/embed/[slug]/page.meta.ts +42 -0
  2025. package/src/modules/forms/frontend/embed/[slug]/page.tsx +171 -0
  2026. package/src/modules/forms/frontend/f/[slug]/page.meta.ts +9 -0
  2027. package/src/modules/forms/frontend/f/[slug]/page.tsx +10 -0
  2028. package/src/modules/forms/frontend/forms/[id]/run/page.meta.ts +17 -0
  2029. package/src/modules/forms/frontend/forms/[id]/run/page.tsx +83 -0
  2030. package/src/modules/forms/frontend/i/[token]/page.meta.ts +9 -0
  2031. package/src/modules/forms/frontend/i/[token]/page.tsx +10 -0
  2032. package/src/modules/forms/i18n/de.json +821 -0
  2033. package/src/modules/forms/i18n/en.json +821 -0
  2034. package/src/modules/forms/i18n/es.json +821 -0
  2035. package/src/modules/forms/i18n/ko.json +821 -0
  2036. package/src/modules/forms/i18n/pl.json +821 -0
  2037. package/src/modules/forms/index.ts +18 -0
  2038. package/src/modules/forms/lib/embed-frame-policy.ts +144 -0
  2039. package/src/modules/forms/lib/form-definition-slicing.ts +54 -0
  2040. package/src/modules/forms/lib/log-redaction.ts +91 -0
  2041. package/src/modules/forms/lib/navigable-url.ts +57 -0
  2042. package/src/modules/forms/lib/retention.ts +73 -0
  2043. package/src/modules/forms/lib/runtime-principal.ts +101 -0
  2044. package/src/modules/forms/migrations/.snapshot-open-mercato.json +3185 -0
  2045. package/src/modules/forms/migrations/Migration20260508135459_forms.ts +17 -0
  2046. package/src/modules/forms/migrations/Migration20260508140932_forms.ts +26 -0
  2047. package/src/modules/forms/migrations/Migration20260508155737_forms.ts +15 -0
  2048. package/src/modules/forms/migrations/Migration20260520120000_forms.ts +26 -0
  2049. package/src/modules/forms/migrations/Migration20260521090000_forms.ts +15 -0
  2050. package/src/modules/forms/migrations/Migration20260521120000_forms.ts +21 -0
  2051. package/src/modules/forms/runner/FormRunner.tsx +924 -0
  2052. package/src/modules/forms/runner/MatrixField.tsx +210 -0
  2053. package/src/modules/forms/runner/RankingField.tsx +207 -0
  2054. package/src/modules/forms/runner/ScaleField.tsx +102 -0
  2055. package/src/modules/forms/runner/SignatureField.tsx +158 -0
  2056. package/src/modules/forms/runner/tamper-check.ts +131 -0
  2057. package/src/modules/forms/schema/address-countries.ts +60 -0
  2058. package/src/modules/forms/schema/field-type-patterns.ts +21 -0
  2059. package/src/modules/forms/schema/field-type-registry-advanced.ts +58 -0
  2060. package/src/modules/forms/schema/field-type-registry.ts +819 -0
  2061. package/src/modules/forms/schema/file-field.ts +102 -0
  2062. package/src/modules/forms/schema/group-field.ts +235 -0
  2063. package/src/modules/forms/schema/jsonlogic-grammar.ts +95 -0
  2064. package/src/modules/forms/schema/jsonschema-extensions.ts +1060 -0
  2065. package/src/modules/forms/schema/layout-catalog.ts +68 -0
  2066. package/src/modules/forms/schema/signature-field.ts +120 -0
  2067. package/src/modules/forms/schema/style-extensions.ts +194 -0
  2068. package/src/modules/forms/schema/style-validators.ts +252 -0
  2069. package/src/modules/forms/services/access-audit-logger.ts +275 -0
  2070. package/src/modules/forms/services/analytics-service.ts +498 -0
  2071. package/src/modules/forms/services/anonymize-service.ts +177 -0
  2072. package/src/modules/forms/services/attachment-service.ts +223 -0
  2073. package/src/modules/forms/services/captcha-verifier.ts +156 -0
  2074. package/src/modules/forms/services/consent-record-service.ts +162 -0
  2075. package/src/modules/forms/services/distribution-service.ts +509 -0
  2076. package/src/modules/forms/services/distribution-token.ts +153 -0
  2077. package/src/modules/forms/services/encryption-service.ts +500 -0
  2078. package/src/modules/forms/services/export-service.ts +360 -0
  2079. package/src/modules/forms/services/field-validation-service.ts +300 -0
  2080. package/src/modules/forms/services/form-logic-evaluator.ts +718 -0
  2081. package/src/modules/forms/services/form-version-compiler.ts +829 -0
  2082. package/src/modules/forms/services/form-version-differ.ts +143 -0
  2083. package/src/modules/forms/services/jsonlogic-evaluator.ts +228 -0
  2084. package/src/modules/forms/services/pdf-snapshot-service.ts +782 -0
  2085. package/src/modules/forms/services/prefill-resolver.ts +125 -0
  2086. package/src/modules/forms/services/role-policy-service.ts +90 -0
  2087. package/src/modules/forms/services/style-compiler.ts +378 -0
  2088. package/src/modules/forms/services/submission-service.ts +1259 -0
  2089. package/src/modules/forms/services/upload-scanner.ts +36 -0
  2090. package/src/modules/forms/services/upload-validation.ts +94 -0
  2091. package/src/modules/forms/services/visibility-resolver.ts +63 -0
  2092. package/src/modules/forms/setup.ts +16 -0
  2093. package/src/modules/forms/subscribers/forms-consent-projector.ts +100 -0
  2094. package/src/modules/forms/subscribers/forms-pdf-snapshot.ts +112 -0
  2095. package/src/modules/forms/subscribers/forms-webhook-bridge-anonymized.ts +36 -0
  2096. package/src/modules/forms/subscribers/forms-webhook-bridge.ts +56 -0
  2097. package/src/modules/forms/subscribers/invitation-email.ts +180 -0
  2098. package/src/modules/forms/translations.ts +14 -0
  2099. package/src/modules/forms/ui/admin/forms/[id]/distributions/CreateDistributionDialog.tsx +401 -0
  2100. package/src/modules/forms/ui/admin/forms/[id]/distributions/DistributionsPanel.tsx +381 -0
  2101. package/src/modules/forms/ui/admin/forms/[id]/distributions/EmbedSettingsDialog.tsx +332 -0
  2102. package/src/modules/forms/ui/admin/forms/[id]/distributions/RecipientsTable.tsx +460 -0
  2103. package/src/modules/forms/ui/public/EmbeddedForm.tsx +248 -0
  2104. package/src/modules/forms/ui/public/FormRunner.tsx +491 -0
  2105. package/src/modules/forms/ui/public/FormTrigger.tsx +80 -0
  2106. package/src/modules/forms/ui/public/PublicFormRunnerPage.tsx +34 -0
  2107. package/src/modules/forms/ui/public/components/CompletionScreen.tsx +97 -0
  2108. package/src/modules/forms/ui/public/components/LocaleSwitch.tsx +42 -0
  2109. package/src/modules/forms/ui/public/components/ResumeGate.tsx +61 -0
  2110. package/src/modules/forms/ui/public/components/ReviewStep.tsx +153 -0
  2111. package/src/modules/forms/ui/public/components/SaveIndicator.tsx +69 -0
  2112. package/src/modules/forms/ui/public/components/SectionStepper.tsx +60 -0
  2113. package/src/modules/forms/ui/public/index.ts +48 -0
  2114. package/src/modules/forms/ui/public/renderers/index.tsx +889 -0
  2115. package/src/modules/forms/ui/public/state/logic-derivation.ts +91 -0
  2116. package/src/modules/forms/ui/public/state/runtime-client.ts +495 -0
  2117. package/src/modules/forms/ui/public/state/useAutosave.ts +97 -0
  2118. package/src/modules/forms/ui/public/state/useFormRunner.ts +547 -0
  2119. package/src/modules/forms/ui/public/style/LogoHeader.tsx +43 -0
  2120. package/src/modules/forms/ui/public/style/applyStyle.ts +26 -0
  2121. package/src/modules/forms/ui/public/types.ts +228 -0
  2122. package/src/modules/forms/widgets/injection/access-audit-panel/widget.tsx +144 -0
  2123. package/src/modules/forms/widgets/injection/anonymize-button/widget.tsx +177 -0
  2124. package/src/modules/forms/widgets/injection/audit-format.ts +60 -0
  2125. package/src/modules/forms/widgets/injection/context.ts +24 -0
  2126. package/src/modules/forms/widgets/injection/embedded-form/widget.tsx +102 -0
  2127. package/src/modules/forms/widgets/injection/pdf-download-button/widget.tsx +111 -0
  2128. package/src/modules/forms/widgets/injection/self-audit-footer/widget.tsx +56 -0
  2129. package/src/modules/forms/widgets/injection-table.ts +54 -0
  2130. package/src/modules/forms/workers/pdf-snapshot.ts +110 -0
  2131. package/src/modules/forms/workers/retention-purge.ts +169 -0
  2132. package/src/modules/inbox_ops/api/proposals/[id]/actions/[actionId]/route.ts +7 -1
  2133. package/src/modules/inbox_ops/data/validators.ts +2 -1
  2134. package/src/modules/inbox_ops/lib/llmProvider.ts +11 -0
  2135. package/src/modules/inbox_ops/widgets/notifications/ProposalCreatedRenderer.tsx +2 -2
  2136. package/src/modules/integrations/di.ts +5 -1
  2137. package/src/modules/integrations/lib/credentials-service.ts +45 -36
  2138. package/src/modules/messages/api/[id]/attachments/route.ts +12 -3
  2139. package/src/modules/messages/api/[id]/forward-preview/route.ts +9 -3
  2140. package/src/modules/messages/api/[id]/route.ts +83 -4
  2141. package/src/modules/messages/api/route.ts +123 -2
  2142. package/src/modules/messages/commands/messages.ts +81 -7
  2143. package/src/modules/messages/components/ComposeMessagePageClient.tsx +29 -1
  2144. package/src/modules/messages/data/validators.ts +10 -0
  2145. package/src/modules/messages/i18n/de.json +8 -0
  2146. package/src/modules/messages/i18n/en.json +8 -0
  2147. package/src/modules/messages/i18n/es.json +8 -0
  2148. package/src/modules/messages/i18n/ko.json +8 -0
  2149. package/src/modules/messages/i18n/pl.json +8 -0
  2150. package/src/modules/messages/lib/channelThreadAccess.ts +101 -0
  2151. package/src/modules/messages/lib/composeSenderDelegation.ts +182 -0
  2152. package/src/modules/messages/lib/composeSenderOptions.ts +56 -0
  2153. package/src/modules/messages/lib/email-sender.ts +1 -17
  2154. package/src/modules/messages/lib/forwarding.ts +17 -2
  2155. package/src/modules/messages/lib/markdownEmailBody.ts +25 -0
  2156. package/src/modules/messages/lib/messageSourceEntityTypes.ts +12 -0
  2157. package/src/modules/messages/lib/routeHelpers.ts +92 -0
  2158. package/src/modules/messages/subscribers/message-notification.ts +47 -1
  2159. package/src/modules/notifications/AGENTS.md +1 -1
  2160. package/src/modules/notifications/api/[id]/action/route.ts +2 -1
  2161. package/src/modules/notifications/api/openapi.ts +1 -0
  2162. package/src/modules/notifications/frontend/NotificationSettingsPageClient.tsx +77 -48
  2163. package/src/modules/notifications/i18n/de.json +1 -0
  2164. package/src/modules/notifications/i18n/en.json +1 -0
  2165. package/src/modules/notifications/i18n/es.json +1 -0
  2166. package/src/modules/notifications/i18n/ko.json +1 -0
  2167. package/src/modules/notifications/i18n/pl.json +1 -0
  2168. package/src/modules/notifications/lib/deliveryConfig.ts +31 -2
  2169. package/src/modules/notifications/lib/notificationMapper.ts +2 -0
  2170. package/src/modules/notifications/lib/safeHref.ts +7 -0
  2171. package/src/modules/planner/api/availability-date-specific.ts +2 -1
  2172. package/src/modules/planner/api/availability-weekly.ts +2 -1
  2173. package/src/modules/progress/AGENTS.md +2 -0
  2174. package/src/modules/progress/api/active/route.ts +14 -2
  2175. package/src/modules/progress/api/jobs/[id]/route.ts +44 -27
  2176. package/src/modules/progress/api/jobs/route.ts +22 -8
  2177. package/src/modules/progress/api/requestScope.ts +43 -0
  2178. package/src/modules/progress/lib/organizationScope.ts +17 -0
  2179. package/src/modules/progress/lib/progressService.ts +3 -2
  2180. package/src/modules/progress/lib/progressServiceImpl.ts +63 -14
  2181. package/src/modules/push_notifications/api/custom-send/route.ts +4 -1
  2182. package/src/modules/push_notifications/i18n/de.json +1 -0
  2183. package/src/modules/push_notifications/i18n/en.json +1 -0
  2184. package/src/modules/push_notifications/i18n/es.json +1 -0
  2185. package/src/modules/push_notifications/i18n/ko.json +1 -0
  2186. package/src/modules/push_notifications/i18n/pl.json +1 -0
  2187. package/src/modules/query_index/api/status.ts +4 -9
  2188. package/src/modules/query_index/di.ts +2 -1
  2189. package/src/modules/query_index/lib/engine.ts +2 -0
  2190. package/src/modules/query_index/lib/request-encryption.ts +31 -0
  2191. package/src/modules/query_index/lib/search-tokens.ts +42 -1
  2192. package/src/modules/resources/api/resources/tags/assign/route.ts +2 -1
  2193. package/src/modules/resources/api/resources/tags/unassign/route.ts +2 -1
  2194. package/src/modules/resources/commands/activities.ts +2 -2
  2195. package/src/modules/sales/api/document-history/route.ts +5 -1
  2196. package/src/modules/sales/api/document-numbers/route.ts +2 -1
  2197. package/src/modules/sales/api/quotes/convert/route.ts +2 -1
  2198. package/src/modules/sales/api/quotes/send/route.ts +2 -1
  2199. package/src/modules/sales/api/settings/document-numbers/route.ts +7 -1
  2200. package/src/modules/sales/api/settings/order-editing/route.ts +7 -1
  2201. package/src/modules/sales/commands/documents.ts +451 -131
  2202. package/src/modules/sales/commands/payments.ts +2 -1
  2203. package/src/modules/sales/commands/settings.ts +34 -6
  2204. package/src/modules/sales/commands/shipments.ts +2 -1
  2205. package/src/modules/sales/components/DocumentNumberSettings.tsx +41 -28
  2206. package/src/modules/sales/components/documents/ItemsSection.tsx +58 -13
  2207. package/src/modules/sales/i18n/de.json +2 -0
  2208. package/src/modules/sales/i18n/en.json +2 -0
  2209. package/src/modules/sales/i18n/es.json +2 -0
  2210. package/src/modules/sales/i18n/ko.json +2 -0
  2211. package/src/modules/sales/i18n/pl.json +2 -0
  2212. package/src/modules/sales/lib/lineSnapshots.ts +36 -0
  2213. package/src/modules/sales/setup.ts +4 -4
  2214. package/src/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.tsx +2 -2
  2215. package/src/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.tsx +2 -2
  2216. package/src/modules/staff/api/leave-requests/accept/route.ts +2 -1
  2217. package/src/modules/staff/api/leave-requests/reject/route.ts +2 -1
  2218. package/src/modules/staff/api/leave-requests.ts +2 -1
  2219. package/src/modules/staff/api/team-members/self/route.ts +2 -1
  2220. package/src/modules/staff/api/team-members/tags/assign/route.ts +2 -1
  2221. package/src/modules/staff/api/team-members/tags/unassign/route.ts +2 -1
  2222. package/src/modules/staff/api/timesheets/_shared/withTimesheetInterceptors.ts +16 -16
  2223. package/src/modules/staff/api/timesheets/my-projects/[projectId]/route.ts +2 -1
  2224. package/src/modules/staff/api/timesheets/my-projects/route.ts +2 -1
  2225. package/src/modules/staff/api/timesheets/my-work/route.ts +2 -1
  2226. package/src/modules/staff/api/timesheets/projects/kpis/route.ts +2 -1
  2227. package/src/modules/staff/api/timesheets/reports/[id]/close/route.ts +2 -1
  2228. package/src/modules/staff/api/timesheets/reports/[id]/export/route.ts +3 -2
  2229. package/src/modules/staff/api/timesheets/reports/[id]/sheet/route.ts +3 -2
  2230. package/src/modules/staff/api/timesheets/reports/[id]/unlock/route.ts +3 -2
  2231. package/src/modules/staff/api/timesheets/reports/preview/route.ts +2 -1
  2232. package/src/modules/staff/api/timesheets/reports/shared.ts +2 -1
  2233. package/src/modules/staff/api/timesheets/settings/reapply-rounding/route.ts +2 -1
  2234. package/src/modules/staff/api/timesheets/tags/entry-assignments/route.ts +2 -1
  2235. package/src/modules/staff/api/timesheets/tags/task-assignments/route.ts +2 -1
  2236. package/src/modules/staff/api/timesheets/tasks/[id]/comments/route.ts +2 -1
  2237. package/src/modules/staff/api/timesheets/tasks/[id]/status/route.ts +2 -1
  2238. package/src/modules/staff/api/timesheets/time-entries/[id]/duplicate/route.ts +3 -2
  2239. package/src/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.ts +2 -1
  2240. package/src/modules/staff/api/timesheets/time-entries/[id]/segments/route.ts +2 -1
  2241. package/src/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.ts +2 -1
  2242. package/src/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.ts +2 -1
  2243. package/src/modules/staff/api/timesheets/time-entries/bulk/route.ts +2 -1
  2244. package/src/modules/staff/api/timesheets/time-entries/copy-day/route.ts +3 -2
  2245. package/src/modules/staff/api/timesheets/time-entries/overlaps/route.ts +2 -1
  2246. package/src/modules/staff/api/timesheets/time-entries/start-timer/route.ts +3 -2
  2247. package/src/modules/staff/api/timesheets/time-projects/[id]/change-currency/route.ts +3 -2
  2248. package/src/modules/staff/api/timesheets/time-projects/route.ts +2 -1
  2249. package/src/modules/staff/commands/activities.ts +2 -2
  2250. package/src/modules/staff/commands/timesheets-entries.ts +3 -2
  2251. package/src/modules/staff/commands/timesheets-reports.ts +88 -15
  2252. package/src/modules/staff/lib/timesheets-reports/buildReportSheet.ts +1 -0
  2253. package/src/modules/staff/lib/timesheets-reports/loadReportData.ts +69 -8
  2254. package/src/modules/staff/lib/timesheets-reports/reportPeriod.ts +18 -0
  2255. package/src/modules/staff/lib/timesheets-ui/CalendarPicker.tsx +21 -10
  2256. package/src/modules/sync_excel/api/import/route.ts +40 -12
  2257. package/src/modules/sync_excel/api/upload/route.ts +34 -4
  2258. package/src/modules/translations/api/context.ts +2 -1
  2259. package/src/modules/warranty_claims/api/ai/assess/route.ts +2 -1
  2260. package/src/modules/warranty_claims/api/ai/draft-reply/route.ts +2 -1
  2261. package/src/modules/warranty_claims/api/ai/suggest/route.ts +2 -1
  2262. package/src/modules/warranty_claims/api/assign/route.ts +2 -1
  2263. package/src/modules/warranty_claims/api/credit-memo/route.ts +2 -1
  2264. package/src/modules/warranty_claims/api/entitlement/route.ts +2 -1
  2265. package/src/modules/warranty_claims/api/events/route.ts +2 -1
  2266. package/src/modules/warranty_claims/api/external/claims/route.ts +2 -1
  2267. package/src/modules/warranty_claims/api/receiving/route.ts +2 -1
  2268. package/src/modules/warranty_claims/api/replacement-order/route.ts +2 -1
  2269. package/src/modules/warranty_claims/api/return-label/route.ts +2 -1
  2270. package/src/modules/warranty_claims/api/risk/route.ts +2 -1
  2271. package/src/modules/warranty_claims/api/sales-return/route.ts +2 -1
  2272. package/src/modules/warranty_claims/api/settings-general/route.ts +2 -1
  2273. package/src/modules/warranty_claims/api/stats/route.ts +11 -11
  2274. package/src/modules/warranty_claims/api/submit/route.ts +2 -1
  2275. package/src/modules/warranty_claims/api/transition/route.ts +2 -1
  2276. package/src/modules/warranty_claims/api/vendor-recovery/route.ts +2 -1
  2277. package/src/modules/warranty_claims/api/vendor-recovery-suggestions/route.ts +2 -1
  2278. package/src/modules/warranty_claims/i18n/de.json +1 -0
  2279. package/src/modules/warranty_claims/i18n/en.json +1 -0
  2280. package/src/modules/warranty_claims/i18n/es.json +1 -0
  2281. package/src/modules/warranty_claims/i18n/ko.json +1 -0
  2282. package/src/modules/warranty_claims/i18n/pl.json +1 -0
  2283. package/src/modules/warranty_claims/widgets/notifications/WarrantyClaimNotificationRenderer.tsx +1 -1
  2284. package/src/modules/wms/api/dashboard/operational/route.ts +2 -1
  2285. package/src/modules/wms/api/inventory/cycle-count/route.ts +1 -0
  2286. package/src/modules/wms/api/inventory/helpers.ts +2 -1
  2287. package/src/modules/wms/api/inventory/import/helpers.ts +2 -1
  2288. package/src/modules/wms/api/sales-orders/[salesOrderId]/warehouse-assignment/route.ts +2 -1
  2289. package/src/modules/wms/commands/inventory-actions.ts +45 -1
  2290. package/src/modules/wms/components/backend/CycleCountWizardDialog.tsx +14 -1
  2291. package/src/modules/wms/di.ts +6 -0
  2292. package/src/modules/wms/i18n/de.json +2 -0
  2293. package/src/modules/wms/i18n/en.json +2 -0
  2294. package/src/modules/wms/i18n/es.json +2 -0
  2295. package/src/modules/wms/i18n/ko.json +2 -0
  2296. package/src/modules/wms/i18n/pl.json +2 -0
  2297. package/src/modules/wms/lib/availabilityCache.ts +137 -0
  2298. package/src/modules/wms/lib/availabilityCalculation.ts +351 -0
  2299. package/src/modules/wms/lib/availabilityProvider.ts +47 -0
  2300. package/src/modules/wms/lib/loadOperationalDashboard.ts +51 -3
  2301. package/src/modules/wms/lib/lowStockBalanceFilter.ts +23 -10
  2302. package/src/modules/wms/lib/sqlInClause.ts +21 -0
  2303. package/src/modules/wms/lib/tryResolve.ts +8 -0
  2304. package/src/modules/wms/subscribers/invalidate-availability-cache-policy.ts +18 -0
  2305. package/src/modules/wms/subscribers/invalidate-availability-cache-profile.ts +18 -0
  2306. package/src/modules/wms/subscribers/invalidate-availability-cache.ts +30 -0
  2307. package/src/modules/wms/widgets/notifications/WmsLowStockRenderer.tsx +2 -2
  2308. package/src/modules/wms/widgets/notifications/WmsReservationShortfallRenderer.tsx +4 -3
  2309. package/src/modules/workflows/AGENTS.md +3 -1
  2310. package/src/modules/workflows/api/commands/route.ts +4 -1
  2311. package/src/modules/workflows/api/definitions/[id]/callers/route.ts +4 -1
  2312. package/src/modules/workflows/api/definitions/[id]/context-schema/route.ts +4 -2
  2313. package/src/modules/workflows/api/definitions/[id]/customize/route.ts +4 -1
  2314. package/src/modules/workflows/api/definitions/[id]/draft/route.ts +6 -1
  2315. package/src/modules/workflows/api/definitions/[id]/publish/route.ts +10 -1
  2316. package/src/modules/workflows/api/definitions/[id]/reset-to-code/route.ts +4 -1
  2317. package/src/modules/workflows/api/definitions/[id]/route.ts +5 -3
  2318. package/src/modules/workflows/api/definitions/[id]/test-step/route.ts +4 -2
  2319. package/src/modules/workflows/api/definitions/generate/route.ts +4 -1
  2320. package/src/modules/workflows/api/definitions/route.ts +4 -2
  2321. package/src/modules/workflows/api/endpoints/route.ts +4 -1
  2322. package/src/modules/workflows/api/functions/route.ts +4 -1
  2323. package/src/modules/workflows/api/grantable-features/route.ts +2 -1
  2324. package/src/modules/workflows/api/instances/[id]/advance/route.ts +4 -1
  2325. package/src/modules/workflows/api/instances/[id]/cancel/route.ts +4 -1
  2326. package/src/modules/workflows/api/instances/[id]/context/route.ts +2 -1
  2327. package/src/modules/workflows/api/instances/[id]/rerun-step/route.ts +4 -1
  2328. package/src/modules/workflows/api/instances/[id]/retry/route.ts +4 -1
  2329. package/src/modules/workflows/api/instances/[id]/signal/route.ts +4 -1
  2330. package/src/modules/workflows/api/instances/[id]/step-through/route.ts +4 -2
  2331. package/src/modules/workflows/api/instances/route.ts +4 -2
  2332. package/src/modules/workflows/api/instances/validate-start/route.ts +4 -1
  2333. package/src/modules/workflows/api/rule-usage/route.ts +4 -1
  2334. package/src/modules/workflows/api/signals/route.ts +4 -1
  2335. package/src/modules/workflows/api/tasks/[id]/claim/route.ts +4 -1
  2336. package/src/modules/workflows/api/tasks/[id]/complete/route.ts +4 -1
  2337. package/src/modules/workflows/api/tasks/[id]/reassign/route.ts +2 -1
  2338. package/src/modules/workflows/api/tasks/[id]/unclaim/route.ts +4 -1
  2339. package/src/modules/workflows/api/templates/route.ts +4 -1
  2340. package/src/modules/workflows/api/work-inbox/next/route.ts +4 -1
  2341. package/src/modules/workflows/lib/event-trigger-service.ts +18 -2
  2342. package/src/modules/workflows/lib/step-handler.ts +13 -8
  2343. package/src/test-utils/transactionalEntityManagerDouble.ts +51 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/customers/components/detail/DealsSection.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Link2, Pencil, Plus } from 'lucide-react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { createCrud, updateCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { LinkEntityDialog } from '../linking/LinkEntityDialog'\nimport { createDealLinkAdapter } from '../linking/adapters/dealAdapter'\nimport { LoadingMessage, TabEmptyState } from '@open-mercato/ui/backend/detail'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT, useLocale } from '@open-mercato/shared/lib/i18n/context'\nimport { hasMoreFromPage } from '@open-mercato/shared/lib/pagination/load-more'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { E } from '#generated/entities.ids.generated'\nimport type { DealCustomFieldEntry, DealSummary, SectionAction, TabEmptyStateConfig, Translator } from './types'\nimport { createTranslatorWithFallback } from '@open-mercato/shared/lib/i18n/translate'\nimport { formatDate } from './utils'\nimport { DealDialog } from './DealDialog'\nimport type { DealFormBaseValues, DealFormSubmitPayload } from './DealForm'\nimport { generateTempId } from '@open-mercato/core/modules/customers/lib/detailHelpers'\nimport { useCurrencyDictionary } from './hooks/useCurrencyDictionary'\nimport { useCustomerDictionary } from './hooks/useCustomerDictionary'\nimport { CustomFieldValuesList } from './CustomFieldValuesList'\nimport { useCustomFieldDisplay } from './hooks/useCustomFieldDisplay'\nimport { normalizeCustomFieldKey } from './customFieldUtils'\n\nconst DEALS_PAGE_SIZE = 10\n\ntype DealsScope =\n | { kind: 'person'; entityId: string }\n | { kind: 'company'; entityId: string }\n\ntype GuardedMutationRunner = <T,>(\n operation: () => Promise<T>,\n mutationPayload?: Record<string, unknown>,\n) => Promise<T>\n\ntype PendingAction =\n | { kind: 'create' }\n | { kind: 'update'; id: string }\n | { kind: 'remove'; id: string }\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction sanitizeCustomValues(input: unknown): Record<string, unknown> | null {\n if (!isPlainObject(input)) return null\n const result: Record<string, unknown> = {}\n Object.entries(input).forEach(([key, value]) => {\n const trimmedKey = key.trim()\n if (!trimmedKey.length) return\n result[trimmedKey] = value\n })\n return Object.keys(result).length ? result : null\n}\n\nfunction sanitizeCustomFieldEntries(\n entries: unknown,\n values: Record<string, unknown> | null,\n): DealCustomFieldEntry[] {\n const map = new Map<string, DealCustomFieldEntry>()\n if (Array.isArray(entries)) {\n entries.forEach((entry) => {\n if (!entry || typeof entry !== 'object') return\n const record = entry as Record<string, unknown>\n const keyRaw =\n typeof record.key === 'string'\n ? record.key\n : typeof record.id === 'string'\n ? record.id\n : null\n if (!keyRaw) return\n const key = keyRaw.trim()\n if (!key.length) return\n const normalizedKey = normalizeCustomFieldKey(key)\n if (!normalizedKey) return\n const label =\n typeof record.label === 'string' && record.label.trim().length\n ? record.label.trim()\n : null\n const kind =\n typeof record.kind === 'string' && record.kind.trim().length\n ? record.kind.trim()\n : null\n const multi =\n typeof record.multi === 'boolean' ? record.multi : Array.isArray(record.value) ? true : undefined\n map.set(normalizedKey, {\n key,\n label,\n value: record.value,\n kind,\n multi,\n })\n })\n }\n\n if (values) {\n Object.entries(values).forEach(([rawKey, value]) => {\n const key = rawKey.trim()\n if (!key.length) return\n const normalizedKey = normalizeCustomFieldKey(key)\n if (!normalizedKey) return\n const existing = map.get(normalizedKey)\n if (existing) {\n existing.value = value\n if (existing.multi === undefined) existing.multi = Array.isArray(value)\n } else {\n map.set(normalizedKey, {\n key,\n label: null,\n value,\n kind: null,\n multi: Array.isArray(value) ? true : undefined,\n })\n }\n })\n }\n\n return Array.from(map.values())\n}\n\ntype NormalizedDeal = Omit<\n DealSummary,\n 'valueAmount' | 'probability' | 'expectedCloseAt' | 'customValues' | 'customFields' | 'personIds' | 'companyIds'\n> & {\n valueAmount: number | null\n probability: number | null\n expectedCloseAt: string | null\n personIds: string[]\n companyIds: string[]\n customValues: Record<string, unknown> | null\n customFields: DealCustomFieldEntry[]\n}\n\nfunction toNumber(value: unknown): number | null {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed.length) return null\n const parsed = Number(trimmed)\n return Number.isNaN(parsed) ? null : parsed\n }\n return null\n}\n\nfunction toIso(value: unknown): string | null {\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed.length) return null\n const parsed = new Date(trimmed)\n return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString()\n }\n if (value instanceof Date) {\n return Number.isNaN(value.getTime()) ? null : value.toISOString()\n }\n return null\n}\n\nfunction mergeIds(...sources: Array<unknown>): string[] {\n const set = new Set<string>()\n sources.forEach((source) => {\n if (Array.isArray(source)) {\n source.forEach((value) => {\n if (typeof value !== 'string') return\n const trimmed = value.trim()\n if (!trimmed.length) return\n set.add(trimmed)\n })\n }\n })\n return Array.from(set)\n}\n\nfunction normalizeDeal(deal: Partial<DealSummary> & { id: string; title?: string }): NormalizedDeal {\n const title = typeof deal.title === 'string' && deal.title.trim().length ? deal.title.trim() : ''\n const normalizeIdList = (list: unknown): string[] => {\n if (!Array.isArray(list)) return []\n const seen = new Set<string>()\n const result: string[] = []\n list.forEach((candidate) => {\n if (typeof candidate !== 'string') return\n const trimmed = candidate.trim()\n if (!trimmed.length || seen.has(trimmed)) return\n seen.add(trimmed)\n result.push(trimmed)\n })\n return result\n }\n\n const normalizeAssignees = (entries: unknown, fallbackIds: string[]): { id: string; label: string }[] => {\n if (!Array.isArray(entries)) {\n return fallbackIds.map((id) => ({ id, label: '' }))\n }\n const seen = new Set<string>()\n const resolved: { id: string; label: string }[] = []\n entries.forEach((entry) => {\n if (!entry || typeof entry !== 'object') return\n const data = entry as Record<string, unknown>\n const id = typeof data.id === 'string' ? data.id.trim() : ''\n if (!id || seen.has(id)) return\n const label = typeof data.label === 'string' ? data.label : ''\n seen.add(id)\n resolved.push({ id, label })\n })\n if (!resolved.length && fallbackIds.length) {\n return fallbackIds.map((id) => ({ id, label: '' }))\n }\n return resolved\n }\n\n const personIds = normalizeIdList(deal.personIds ?? null)\n const companyIds = normalizeIdList(deal.companyIds ?? null)\n const people = normalizeAssignees(deal.people ?? null, personIds)\n const companies = normalizeAssignees(deal.companies ?? null, companyIds)\n\n const customValues = sanitizeCustomValues(deal.customValues ?? null)\n const customFields = sanitizeCustomFieldEntries(deal.customFields ?? null, customValues)\n\n return {\n id: deal.id,\n title,\n status: typeof deal.status === 'string' ? deal.status : deal.status ?? null,\n pipelineStage:\n typeof deal.pipelineStage === 'string' ? deal.pipelineStage : deal.pipelineStage ?? null,\n pipelineId:\n typeof deal.pipelineId === 'string' && deal.pipelineId.trim().length\n ? deal.pipelineId.trim()\n : deal.pipelineId ?? null,\n pipelineStageId:\n typeof deal.pipelineStageId === 'string' && deal.pipelineStageId.trim().length\n ? deal.pipelineStageId.trim()\n : deal.pipelineStageId ?? null,\n valueAmount: toNumber(deal.valueAmount ?? null),\n valueCurrency:\n typeof deal.valueCurrency === 'string' && deal.valueCurrency.trim().length\n ? deal.valueCurrency.trim().toUpperCase()\n : null,\n probability: toNumber(deal.probability ?? null),\n expectedCloseAt: toIso(deal.expectedCloseAt ?? null),\n description:\n typeof deal.description === 'string' && deal.description.trim().length\n ? deal.description\n : deal.description ?? null,\n ownerUserId:\n typeof deal.ownerUserId === 'string' && deal.ownerUserId.trim().length\n ? deal.ownerUserId\n : deal.ownerUserId ?? null,\n source:\n typeof deal.source === 'string' && deal.source.trim().length ? deal.source : deal.source ?? null,\n closureOutcome:\n typeof deal.closureOutcome === 'string' && deal.closureOutcome.trim().length\n ? deal.closureOutcome\n : deal.closureOutcome ?? null,\n lossReasonId:\n typeof deal.lossReasonId === 'string' && deal.lossReasonId.trim().length\n ? deal.lossReasonId\n : deal.lossReasonId ?? null,\n lossNotes:\n typeof deal.lossNotes === 'string' && deal.lossNotes.trim().length\n ? deal.lossNotes\n : deal.lossNotes ?? null,\n createdAt: toIso(deal.createdAt ?? null),\n updatedAt: toIso(deal.updatedAt ?? null),\n personIds,\n companyIds,\n people,\n companies,\n customValues,\n customFields,\n }\n}\n\nfunction formatValueLabel(\n amount: number | null,\n currency: string | null,\n emptyLabel: string,\n locale?: string,\n): string {\n if (typeof amount === 'number') {\n const formatter = new Intl.NumberFormat(locale, {\n style: currency ? 'currency' : 'decimal',\n currency: currency ?? undefined,\n maximumFractionDigits: 2,\n })\n try {\n return formatter.format(amount)\n } catch {\n return currency ? `${amount} ${currency}` : `${amount}`\n }\n }\n return emptyLabel\n}\n\nexport type DealsSectionProps = {\n scope: DealsScope | null\n addActionLabel: string\n emptyLabel: string\n emptyState: TabEmptyStateConfig\n onCountDelta?: (delta: number) => void\n onActionChange?: (action: SectionAction | null) => void\n onLoadingChange?: (isLoading: boolean) => void\n onDataRefresh?: () => Promise<void> | void\n translator?: Translator\n runGuardedMutation?: GuardedMutationRunner\n}\n\nexport function DealsSection({\n scope,\n addActionLabel,\n emptyLabel,\n emptyState,\n onCountDelta,\n onActionChange,\n onLoadingChange,\n onDataRefresh,\n translator,\n runGuardedMutation,\n}: DealsSectionProps) {\n const tHook = useT()\n const locale = useLocale()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const fallbackTranslator = React.useMemo<Translator>(() => createTranslatorWithFallback(tHook), [tHook])\n const t: Translator = React.useMemo(() => translator ?? fallbackTranslator, [translator, fallbackTranslator])\n useCurrencyDictionary()\n const scopeVersion = useOrganizationScopeVersion()\n const statusDictionaryQuery = useCustomerDictionary('deal-statuses', scopeVersion)\n const statusDictionaryMap = statusDictionaryQuery.data?.map ?? null\n const customFieldResources = useCustomFieldDisplay(E.customers.customer_deal)\n\n const [deals, setDeals] = React.useState<NormalizedDeal[]>([])\n const [isLoading, setIsLoading] = React.useState<boolean>(() => Boolean(scope))\n const [loadError, setLoadError] = React.useState<string | null>(null)\n const [pendingAction, setPendingAction] = React.useState<PendingAction | null>(null)\n const [hasMore, setHasMore] = React.useState(false)\n const pageRef = React.useRef(0)\n const hasMoreRef = React.useRef(true)\n const [dialogOpen, setDialogOpen] = React.useState(false)\n const [initialValues, setInitialValues] = React.useState<\n Partial<DealFormBaseValues & Record<string, unknown>> | undefined\n >(undefined)\n const pendingCounterRef = React.useRef(0)\n\n const pushLoading = React.useCallback(() => {\n pendingCounterRef.current += 1\n if (pendingCounterRef.current === 1) onLoadingChange?.(true)\n }, [onLoadingChange])\n\n const popLoading = React.useCallback(() => {\n pendingCounterRef.current = Math.max(0, pendingCounterRef.current - 1)\n if (pendingCounterRef.current === 0) onLoadingChange?.(false)\n }, [onLoadingChange])\n\n const translate = React.useCallback(\n (key: string, fallback: string, params?: Record<string, string | number>) => {\n const value = t(key, fallback, params)\n return value === key && fallback ? fallback : value\n },\n [t],\n )\n const runWriteMutation = React.useCallback(\n async <T,>(operation: () => Promise<T>, mutationPayload?: Record<string, unknown>): Promise<T> => {\n if (!runGuardedMutation) {\n return operation()\n }\n return runGuardedMutation(operation, mutationPayload)\n },\n [runGuardedMutation],\n )\n const refreshParentData = React.useCallback(async () => {\n await Promise.resolve(onDataRefresh?.())\n }, [onDataRefresh])\n\n const loadDeals = React.useCallback(async ({ append }: { append: boolean }) => {\n if (!scope) {\n setDeals([])\n setLoadError(null)\n setHasMore(false)\n setIsLoading(false)\n pendingCounterRef.current = 0\n onLoadingChange?.(false)\n pageRef.current = 0\n hasMoreRef.current = false\n return\n }\n if (append && !hasMoreRef.current) return\n const nextPage = append ? pageRef.current + 1 : 1\n if (!append) {\n pageRef.current = 0\n hasMoreRef.current = true\n setHasMore(true)\n setDeals([])\n }\n pushLoading()\n setIsLoading(true)\n try {\n const params = new URLSearchParams({\n page: String(nextPage),\n pageSize: String(DEALS_PAGE_SIZE),\n sortField: 'updatedAt',\n sortDir: 'desc',\n })\n if (scope.kind === 'person') params.set('personEntityId', scope.entityId)\n if (scope.kind === 'company') params.set('companyEntityId', scope.entityId)\n const payload = await readApiResultOrThrow<Record<string, unknown>>(\n `/api/customers/deals?${params.toString()}`,\n undefined,\n { errorMessage: translate('customers.people.detail.deals.loadError', 'Failed to load deals.') },\n )\n const rawItems = Array.isArray(payload?.items) ? payload.items : []\n const mapped: NormalizedDeal[] = rawItems.map((item: unknown) => {\n const record = (item && typeof item === 'object') ? (item as Record<string, unknown>) : {}\n const id =\n typeof record.id === 'string' && record.id.trim().length ? record.id : generateTempId()\n const title =\n typeof record.title === 'string' && record.title.trim().length ? record.title.trim() : ''\n const status =\n typeof record.status === 'string' && record.status.trim().length\n ? record.status.trim()\n : null\n const pipelineStage =\n typeof record.pipelineStage === 'string' && record.pipelineStage.trim().length\n ? record.pipelineStage.trim()\n : typeof record.pipeline_stage === 'string' && record.pipeline_stage.trim().length\n ? record.pipeline_stage.trim()\n : null\n const pipelineId =\n typeof record.pipelineId === 'string' && record.pipelineId.trim().length\n ? record.pipelineId.trim()\n : typeof record.pipeline_id === 'string' && record.pipeline_id.trim().length\n ? record.pipeline_id.trim()\n : null\n const pipelineStageId =\n typeof record.pipelineStageId === 'string' && record.pipelineStageId.trim().length\n ? record.pipelineStageId.trim()\n : typeof record.pipeline_stage_id === 'string' && record.pipeline_stage_id.trim().length\n ? record.pipeline_stage_id.trim()\n : null\n const valueAmount = toNumber(record.valueAmount ?? record.value_amount)\n const valueCurrencyRaw = record.valueCurrency ?? record.value_currency ?? null\n const valueCurrency =\n typeof valueCurrencyRaw === 'string' && valueCurrencyRaw.trim().length\n ? valueCurrencyRaw.trim().toUpperCase()\n : null\n const probability = toNumber(record.probability)\n const expectedCloseAt =\n typeof record.expectedCloseAt === 'string' && record.expectedCloseAt.trim().length\n ? record.expectedCloseAt\n : typeof record.expected_close_at === 'string' && record.expected_close_at.trim().length\n ? record.expected_close_at\n : null\n const description =\n typeof record.description === 'string' && record.description.trim().length\n ? record.description\n : null\n const ownerUserId =\n typeof record.ownerUserId === 'string' && record.ownerUserId.trim().length\n ? record.ownerUserId\n : typeof record.owner_user_id === 'string' && record.owner_user_id.trim().length\n ? record.owner_user_id\n : null\n const source =\n typeof record.source === 'string' && record.source.trim().length\n ? record.source\n : null\n const closureOutcome =\n typeof record.closureOutcome === 'string' && record.closureOutcome.trim().length\n ? record.closureOutcome\n : typeof record.closure_outcome === 'string' && record.closure_outcome.trim().length\n ? record.closure_outcome\n : null\n const lossReasonId =\n typeof record.lossReasonId === 'string' && record.lossReasonId.trim().length\n ? record.lossReasonId\n : typeof record.loss_reason_id === 'string' && record.loss_reason_id.trim().length\n ? record.loss_reason_id\n : null\n const lossNotes =\n typeof record.lossNotes === 'string' && record.lossNotes.trim().length\n ? record.lossNotes\n : typeof record.loss_notes === 'string' && record.loss_notes.trim().length\n ? record.loss_notes\n : null\n const createdAt =\n typeof record.createdAt === 'string' && record.createdAt.trim().length\n ? record.createdAt\n : typeof record.created_at === 'string' && record.created_at.trim().length\n ? record.created_at\n : null\n const updatedAt =\n typeof record.updatedAt === 'string' && record.updatedAt.trim().length\n ? record.updatedAt\n : typeof record.updated_at === 'string' && record.updated_at.trim().length\n ? record.updated_at\n : null\n const personIds = Array.isArray(record.personIds)\n ? record.personIds\n : Array.isArray(record.person_ids)\n ? record.person_ids\n : []\n const people = Array.isArray(record.people) ? record.people : []\n const companyIds = Array.isArray(record.companyIds)\n ? record.companyIds\n : Array.isArray(record.company_ids)\n ? record.company_ids\n : []\n const companies = Array.isArray(record.companies) ? record.companies : []\n const customValues = sanitizeCustomValues(\n record.customValues ?? record.custom_values ?? null,\n )\n const customFieldEntries = sanitizeCustomFieldEntries(\n record.customFields ?? record.custom_fields ?? null,\n customValues,\n )\n return normalizeDeal({\n id,\n title,\n status,\n pipelineStage,\n pipelineId,\n pipelineStageId,\n valueAmount,\n valueCurrency,\n probability,\n expectedCloseAt,\n description,\n ownerUserId,\n source,\n closureOutcome,\n lossReasonId,\n lossNotes,\n createdAt,\n updatedAt,\n personIds: personIds as string[] | undefined,\n people: people as { id: string; label: string }[] | undefined,\n companyIds: companyIds as string[] | undefined,\n companies: companies as { id: string; label: string }[] | undefined,\n customValues,\n customFields: customFieldEntries,\n })\n })\n setDeals((prev) => {\n if (!append) return mapped\n const mappedById = new Map(mapped.map((deal) => [deal.id, deal]))\n const prevIds = new Set(prev.map((deal) => deal.id))\n const updatedPrev = prev.map((deal) => mappedById.get(deal.id) ?? deal)\n const appended = mapped.filter((deal) => !prevIds.has(deal.id))\n return [...updatedPrev, ...appended]\n })\n pageRef.current = nextPage\n // Short-page termination, unconditionally \u2014 see `hasMoreFromPage`.\n // Preferring `totalPages` here hid deals that do exist. Measured on\n // `rawItems`, which is what the server served, rather than on the\n // deduped rows appended above.\n const nextHasMore = hasMoreFromPage(rawItems.length, DEALS_PAGE_SIZE)\n hasMoreRef.current = nextHasMore\n setHasMore(nextHasMore)\n setLoadError(null)\n } catch (err) {\n const message =\n err instanceof Error\n ? err.message\n : translate('customers.people.detail.deals.loadError', 'Failed to load deals.')\n setLoadError(message)\n if (!append) {\n setHasMore(false)\n hasMoreRef.current = false\n }\n } finally {\n setIsLoading(false)\n popLoading()\n }\n }, [popLoading, pushLoading, scope, translate])\n\n React.useEffect(() => {\n loadDeals({ append: false }).catch(() => {})\n }, [loadDeals, scope])\n\n const openCreateDialog = React.useCallback(() => {\n if (!scope) return\n setInitialValues({\n personIds: scope.kind === 'person' ? [scope.entityId] : [],\n companyIds: scope.kind === 'company' ? [scope.entityId] : [],\n })\n setDialogOpen(true)\n }, [scope])\n\n const [linkDialogOpen, setLinkDialogOpen] = React.useState(false)\n const openLinkDialog = React.useCallback(() => {\n if (!scope) return\n setLinkDialogOpen(true)\n }, [scope])\n\n const existingDealIds = React.useMemo(() => deals.map((deal) => deal.id), [deals])\n\n const dealLinkAdapter = React.useMemo(\n () =>\n createDealLinkAdapter({\n dialogTitle: t('customers.linking.deal.dialogTitle', 'Link deal'),\n dialogSubtitle: t(\n 'customers.linking.deal.dialogSubtitle',\n 'Link an existing deal to this record',\n ),\n sectionLabel: t('customers.linking.deal.sectionLabel', 'MATCHING DEALS'),\n searchPlaceholder: t('customers.linking.deal.searchPlaceholder', 'Search all deals\u2026'),\n searchEmptyHint: t('customers.linking.deal.searchEmpty', 'No matching deals found.'),\n selectedEmptyHint: t('customers.linking.deal.selectedEmpty', 'No deals selected.'),\n confirmButtonLabel: t('customers.linking.deal.confirmButton', 'Link deal'),\n orphanWarningTitle: t('customers.linking.deal.orphanWarningTitle', 'Deal without company'),\n orphanWarningMessage: t(\n 'customers.linking.deal.orphanWarning',\n 'This deal has no other linked entities. If you unlink it later, it will become unreachable.',\n ),\n contextEntityId: scope?.entityId,\n }),\n [scope?.entityId, t],\n )\n\n const handleLinkConfirm = React.useCallback(\n async ({\n addedIds,\n removedIds,\n }: {\n addedIds: string[]\n removedIds: string[]\n }) => {\n if (!scope) return\n if (!addedIds.length && !removedIds.length) return\n pushLoading()\n try {\n for (const dealId of addedIds) {\n const payload = await readApiResultOrThrow<Record<string, unknown>>(\n `/api/customers/deals/${encodeURIComponent(dealId)}`,\n )\n const currentPersonIds = Array.isArray(payload.personIds)\n ? (payload.personIds as string[]).filter((id) => typeof id === 'string')\n : []\n const currentCompanyIds = Array.isArray(payload.companyIds)\n ? (payload.companyIds as string[]).filter((id) => typeof id === 'string')\n : []\n const nextPersonIds =\n scope.kind === 'person' && !currentPersonIds.includes(scope.entityId)\n ? [...currentPersonIds, scope.entityId]\n : currentPersonIds\n const nextCompanyIds =\n scope.kind === 'company' && !currentCompanyIds.includes(scope.entityId)\n ? [...currentCompanyIds, scope.entityId]\n : currentCompanyIds\n await runWriteMutation(\n () =>\n // optimistic-lock-exempt: deal association list (link)\n updateCrud(\n 'customers/deals',\n { id: dealId, personIds: nextPersonIds, companyIds: nextCompanyIds },\n {\n errorMessage: t(\n 'customers.people.detail.deals.linkError',\n 'Failed to link deal.',\n ),\n },\n ),\n { dealId, scopeKind: scope.kind, scopeEntityId: scope.entityId, operation: 'linkDeal' },\n )\n }\n for (const dealId of removedIds) {\n const payload = await readApiResultOrThrow<Record<string, unknown>>(\n `/api/customers/deals/${encodeURIComponent(dealId)}`,\n )\n const currentPersonIds = Array.isArray(payload.personIds)\n ? (payload.personIds as string[]).filter((id) => typeof id === 'string')\n : []\n const currentCompanyIds = Array.isArray(payload.companyIds)\n ? (payload.companyIds as string[]).filter((id) => typeof id === 'string')\n : []\n const nextPersonIds =\n scope.kind === 'person'\n ? currentPersonIds.filter((id) => id !== scope.entityId)\n : currentPersonIds\n const nextCompanyIds =\n scope.kind === 'company'\n ? currentCompanyIds.filter((id) => id !== scope.entityId)\n : currentCompanyIds\n await runWriteMutation(\n () =>\n // optimistic-lock-exempt: deal association list (unlink)\n updateCrud(\n 'customers/deals',\n { id: dealId, personIds: nextPersonIds, companyIds: nextCompanyIds },\n {\n errorMessage: t(\n 'customers.people.detail.deals.unlinkError',\n 'Failed to unlink deal.',\n ),\n },\n ),\n { dealId, scopeKind: scope.kind, scopeEntityId: scope.entityId, operation: 'unlinkDeal' },\n )\n }\n await loadDeals({ append: false })\n await refreshParentData()\n if (addedIds.length + removedIds.length > 0) {\n onCountDelta?.(addedIds.length - removedIds.length)\n }\n flash(\n addedIds.length > 0\n ? t('customers.people.detail.deals.linkSuccess', 'Deal linked.')\n : t('customers.people.detail.deals.unlinkSuccess', 'Deal unlinked.'),\n 'success',\n )\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : t('customers.people.detail.deals.linkError', 'Failed to link deal.')\n flash(message, 'error')\n } finally {\n popLoading()\n }\n },\n [loadDeals, onCountDelta, popLoading, pushLoading, refreshParentData, runWriteMutation, scope, t],\n )\n\n const closeDialog = React.useCallback(() => {\n setDialogOpen(false)\n setInitialValues(undefined)\n }, [])\n\n const handleDialogOpenChange = React.useCallback(\n (next: boolean) => {\n if (!next) closeDialog()\n else setDialogOpen(true)\n },\n [closeDialog],\n )\n\n const handleCreate = React.useCallback(\n async ({ base, custom }: DealFormSubmitPayload) => {\n if (!scope) {\n throw new Error(translate('customers.people.detail.deals.error', 'Failed to save deal.'))\n }\n setPendingAction({ kind: 'create' })\n pushLoading()\n try {\n const personIds = mergeIds(base.personIds)\n const companyIds = mergeIds(base.companyIds)\n\n const payload: Record<string, unknown> = {\n title: base.title,\n status: base.status ?? undefined,\n pipelineStage: base.pipelineStage ?? undefined,\n pipelineId: base.pipelineId ?? undefined,\n pipelineStageId: base.pipelineStageId ?? undefined,\n valueAmount: typeof base.valueAmount === 'number' ? base.valueAmount : undefined,\n valueCurrency: base.valueCurrency ?? undefined,\n probability: typeof base.probability === 'number' ? base.probability : undefined,\n expectedCloseAt: base.expectedCloseAt ?? undefined,\n description: base.description ?? undefined,\n personIds,\n companyIds,\n }\n if (Object.keys(custom).length) payload.customFields = custom\n const { result } = await runWriteMutation(\n () =>\n // optimistic-lock-exempt: deal create-only, no prior version\n createCrud<{ id?: string }>('customers/deals', payload, {\n errorMessage: translate('customers.people.detail.deals.error', 'Failed to save deal.'),\n }),\n {\n ...payload,\n operation: 'createDeal',\n },\n )\n const dealId =\n typeof result?.id === 'string' && result.id.trim().length ? result.id : generateTempId()\n const belongsToScope =\n (scope.kind !== 'person' || personIds.includes(scope.entityId)) &&\n (scope.kind !== 'company' || companyIds.includes(scope.entityId))\n if (belongsToScope) {\n const customValuesForState = sanitizeCustomValues(\n Object.keys(custom).length ? custom : null,\n )\n const timestamp = new Date().toISOString()\n const normalized = normalizeDeal({\n id: dealId,\n title: base.title,\n status: base.status ?? null,\n pipelineStage: base.pipelineStage ?? null,\n pipelineId: base.pipelineId ?? null,\n pipelineStageId: base.pipelineStageId ?? null,\n valueAmount: base.valueAmount ?? null,\n valueCurrency: base.valueCurrency ?? null,\n probability: base.probability ?? null,\n expectedCloseAt: base.expectedCloseAt ?? null,\n description: base.description ?? null,\n personIds,\n companyIds,\n customValues: customValuesForState,\n createdAt: timestamp,\n updatedAt: timestamp,\n })\n setDeals((prev) => [normalized, ...prev])\n onCountDelta?.(1)\n }\n await refreshParentData()\n flash(translate('customers.people.detail.deals.success', 'Deal created.'), 'success')\n } finally {\n setPendingAction(null)\n popLoading()\n }\n },\n [onCountDelta, popLoading, pushLoading, refreshParentData, runWriteMutation, scope, translate],\n )\n\n const handleUnlink = React.useCallback(\n async (deal: NormalizedDeal) => {\n if (!scope) return\n\n const nextPersonIds =\n scope.kind === 'person'\n ? deal.personIds.filter((id) => id !== scope.entityId)\n : deal.personIds\n const nextCompanyIds =\n scope.kind === 'company'\n ? deal.companyIds.filter((id) => id !== scope.entityId)\n : deal.companyIds\n\n const confirmed = await confirm({\n title:\n scope.kind === 'person'\n ? translate('customers.people.detail.deals.unlinkConfirmPerson', 'Unlink this deal from this person?')\n : translate('customers.people.detail.deals.unlinkConfirmCompany', 'Unlink this deal from this company?'),\n description: translate(\n 'customers.people.detail.deals.unlinkDescription',\n 'The deal will remain available from its own detail page.',\n ),\n confirmText: translate('customers.people.card.unlink', 'Unlink'),\n cancelText: translate('customers.people.detail.deals.cancel', 'Cancel'),\n })\n if (!confirmed) return\n\n setPendingAction({ kind: 'remove', id: deal.id })\n pushLoading()\n try {\n const payload: Record<string, unknown> = {\n id: deal.id,\n personIds: nextPersonIds,\n companyIds: nextCompanyIds,\n }\n await runWriteMutation(\n () =>\n // optimistic-lock-exempt: deal association list (unlink)\n updateCrud('customers/deals', payload, {\n errorMessage: translate('customers.people.detail.deals.unlinkError', 'Failed to unlink deal.'),\n }),\n {\n ...payload,\n operation: 'unlinkDeal',\n },\n )\n setDeals((prev) => prev.filter((item) => item.id !== deal.id))\n onCountDelta?.(-1)\n await refreshParentData()\n flash(translate('customers.people.detail.deals.unlinkSuccess', 'Deal unlinked.'), 'success')\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : translate('customers.people.detail.deals.unlinkError', 'Failed to unlink deal.')\n flash(message, 'error')\n } finally {\n setPendingAction(null)\n popLoading()\n }\n },\n [confirm, onCountDelta, popLoading, pushLoading, refreshParentData, runWriteMutation, scope, translate],\n )\n\n const handleDialogSubmit = React.useCallback(\n async (payload: DealFormSubmitPayload) => {\n try {\n await handleCreate(payload)\n closeDialog()\n } catch (err) {\n const message =\n err instanceof Error\n ? err.message\n : translate('customers.people.detail.deals.error', 'Failed to save deal.')\n flash(message, 'error')\n }\n },\n [closeDialog, handleCreate, translate],\n )\n\n React.useEffect(() => {\n if (!onActionChange) return\n const disabled = !scope || isLoading || pendingAction !== null\n const action: SectionAction = {\n label: addActionLabel,\n onClick: () => {\n if (!disabled) openCreateDialog()\n },\n disabled,\n }\n onActionChange(action)\n return () => {\n onActionChange(null)\n }\n }, [addActionLabel, isLoading, onActionChange, openCreateDialog, pendingAction, scope])\n\n const isFormPending = pendingAction?.kind === 'create'\n\n const sortedDeals = React.useMemo(() => {\n return [...deals].sort((a, b) => {\n const timeA = a.updatedAt ?? a.createdAt ?? ''\n const timeB = b.updatedAt ?? b.createdAt ?? ''\n return timeB.localeCompare(timeA)\n })\n }, [deals])\n\n return (\n <div className=\"mt-4 space-y-4\">\n {loadError ? (\n <div className=\"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive\">\n {loadError}\n </div>\n ) : null}\n <div className=\"flex flex-wrap items-center justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={openLinkDialog}\n disabled={!scope || pendingAction !== null}\n >\n <Link2 className=\"mr-1.5 size-3.5\" />\n {t('customers.people.detail.deals.linkExisting', 'Link existing deal')}\n </Button>\n <Button\n type=\"button\"\n variant=\"default\"\n size=\"sm\"\n onClick={openCreateDialog}\n disabled={!scope || pendingAction !== null}\n >\n <Plus className=\"mr-1.5 size-3.5\" />\n {addActionLabel}\n </Button>\n </div>\n {isLoading && sortedDeals.length === 0 ? (\n <LoadingMessage\n label={t('customers.people.detail.deals.loading', 'Loading deals\u2026')}\n className=\"border-0 bg-transparent p-0 py-8 justify-center\"\n />\n ) : (\n <>\n {!isLoading && sortedDeals.length === 0 ? (\n <TabEmptyState\n title={emptyState.title}\n action={{\n label: emptyState.actionLabel,\n onClick: openCreateDialog,\n disabled: !scope || pendingAction !== null,\n }}\n />\n ) : null}\n <div className=\"space-y-4\">\n {sortedDeals.map((deal) => {\n const valueLabel = formatValueLabel(deal.valueAmount, deal.valueCurrency ?? null, emptyLabel, locale)\n const expectedLabel = deal.expectedCloseAt ? formatDate(deal.expectedCloseAt, locale) ?? emptyLabel : emptyLabel\n const probabilityLabel =\n typeof deal.probability === 'number' ? `${deal.probability}%` : emptyLabel\n const isUnlinkPending = pendingAction?.kind === 'remove' && pendingAction.id === deal.id\n const statusLabel =\n deal.status && statusDictionaryMap\n ? statusDictionaryMap[deal.status]?.label ?? deal.status\n : deal.status ?? emptyLabel\n return (\n <article key={deal.id} className=\"group rounded-lg border bg-card p-4 shadow-xs transition hover:border-border/70\">\n <header className=\"flex flex-wrap items-center justify-between gap-2\">\n <div>\n <Link\n href={`/backend/customers/deals/${encodeURIComponent(deal.id)}`}\n className=\"text-base font-semibold text-foreground transition hover:text-primary hover:underline\"\n >\n {deal.title || emptyLabel}\n </Link>\n {deal.description ? (\n <p className=\"mt-1 line-clamp-3 text-sm text-muted-foreground whitespace-pre-wrap\">{deal.description}</p>\n ) : null}\n </div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs font-medium uppercase text-muted-foreground\">\n {statusLabel}\n </span>\n <div className=\"flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100\">\n <IconButton asChild variant=\"ghost\" size=\"sm\" className=\"h-8 w-8\">\n <Link\n href={`/backend/customers/deals/${encodeURIComponent(deal.id)}`}\n aria-label={t('customers.people.detail.deals.edit', 'Open deal details')}\n >\n <Pencil className=\"size-4\" />\n </Link>\n </IconButton>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"h-8 rounded-lg px-3 text-xs\"\n onClick={(event) => {\n event.preventDefault()\n void handleUnlink(deal)\n }}\n disabled={pendingAction !== null}\n >\n {isUnlinkPending\n ? t('customers.people.detail.deals.unlinking', 'Unlinking\u2026')\n : t('customers.people.card.unlink', 'Unlink')}\n </Button>\n </div>\n </div>\n </header>\n <dl className=\"mt-3 grid gap-2 text-xs text-muted-foreground sm:grid-cols-2\">\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.pipelineStage', 'Pipeline stage')}\n </dt>\n <dd>{deal.pipelineStage ?? emptyLabel}</dd>\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.probability', 'Probability')}\n </dt>\n <dd>{probabilityLabel}</dd>\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.valueAmount', 'Value')}\n </dt>\n <dd>{valueLabel}</dd>\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.expectedCloseAt', 'Expected close')}\n </dt>\n <dd>{expectedLabel}</dd>\n </div>\n </dl>\n <CustomFieldValuesList\n entries={deal.customFields?.map((entry) => ({\n key: entry.key,\n value: entry.value,\n label: entry.label ?? undefined,\n }))}\n values={deal.customValues ?? undefined}\n resources={customFieldResources}\n emptyLabel={emptyLabel}\n itemKeyPrefix={`deal-${deal.id}-field`}\n className=\"mt-3\"\n />\n </article>\n )\n })}\n {isLoading && deals.length > 0 ? (\n <div className=\"flex justify-center\">\n <LoadingMessage\n label={t('customers.people.detail.deals.loading', 'Loading deals\u2026')}\n className=\"border-0 bg-transparent p-0 justify-center [&_span[role='status']]:h-5 [&_span[role='status']]:w-5\"\n />\n </div>\n ) : null}\n {!isLoading && hasMore ? (\n <div className=\"flex justify-center\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => {\n loadDeals({ append: true }).catch(() => {})\n }}\n disabled={pendingAction !== null || isLoading}\n >\n {t('customers.people.detail.deals.loadMore', 'Load more deals')}\n </Button>\n </div>\n ) : null}\n </div>\n </>\n )}\n\n <DealDialog\n open={dialogOpen}\n mode=\"create\"\n onOpenChange={handleDialogOpenChange}\n initialValues={initialValues}\n onSubmit={async (payload) => {\n await handleDialogSubmit(payload)\n }}\n isSubmitting={Boolean(isFormPending)}\n />\n <LinkEntityDialog\n open={linkDialogOpen}\n onOpenChange={setLinkDialogOpen}\n adapter={dealLinkAdapter}\n initialSelectedIds={existingDealIds}\n onConfirm={handleLinkConfirm}\n />\n {ConfirmDialogElement}\n </div>\n )\n}\n\nexport default DealsSection\n"],
5
- "mappings": ";AA85BQ,SAgCA,UAhCA,KAKA,YALA;AA55BR,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,OAAO,QAAQ,YAAY;AACpC,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,4BAA4B;AACrC,SAAS,YAAY,kBAAkB;AACvC,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AACtC,SAAS,gBAAgB,qBAAqB;AAC9C,SAAS,mCAAmC;AAC5C,SAAS,MAAM,iBAAiB;AAChC,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,SAAS;AAElB,SAAS,oCAAoC;AAC7C,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAE3B,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AACtC,SAAS,+BAA+B;AAExC,MAAM,kBAAkB;AAgBxB,SAAS,cAAc,OAAkD;AACvE,SAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AACrE;AAEA,SAAS,qBAAqB,OAAgD;AAC5E,MAAI,CAAC,cAAc,KAAK,EAAG,QAAO;AAClC,QAAM,SAAkC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AM,SAAS,IAC3B,oBAAC,SAAI,WAAU,uBACb;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,EAAE,yCAAyC,qBAAgB;AAAA,YAClE,WAAU;AAAA;AAAA,QACZ,GACF,IACE;AAAA,QACH,CAAC,aAAa,UACb,oBAAC,SAAI,WAAU,uBACb;AAAA,UAAC;AAAA;AAAA,YACC,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,SAAS,MAAM;AACb,wBAAU,EAAE,QAAQ,KAAK,CAAC,EAAE,MAAM,MAAM;AAAA,cAAC,CAAC;AAAA,YAC5C;AAAA,YACA,UAAU,kBAAkB,QAAQ;AAAA,YAEnC,YAAE,0CAA0C,iBAAiB;AAAA;AAAA,QAChE,GACF,IACE;AAAA,SACN;AAAA,OACF;AAAA,IAGF;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,MAAK;AAAA,QACL,cAAc;AAAA,QACd;AAAA,QACA,UAAU,OAAO,YAAY;AAC3B,gBAAM,mBAAmB,OAAO;AAAA,QAClC;AAAA,QACA,cAAc,QAAQ,aAAa;AAAA;AAAA,IACrC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,cAAc;AAAA,QACd,SAAS;AAAA,QACT,oBAAoB;AAAA,QACpB,WAAW;AAAA;AAAA,IACb;AAAA,IACC;AAAA,KACH;AAEJ;AAEA,IAAO,uBAAQ;",
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Link2, Pencil, Plus } from 'lucide-react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { createCrud, updateCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { LinkEntityDialog } from '../linking/LinkEntityDialog'\nimport { createDealLinkAdapter } from '../linking/adapters/dealAdapter'\nimport { LoadingMessage, TabEmptyState } from '@open-mercato/ui/backend/detail'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT, useLocale } from '@open-mercato/shared/lib/i18n/context'\nimport { hasMoreFromPage } from '@open-mercato/shared/lib/pagination/load-more'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { E } from '#generated/entities.ids.generated'\nimport type { DealCustomFieldEntry, DealSummary, SectionAction, TabEmptyStateConfig, Translator } from './types'\nimport { createTranslatorWithFallback } from '@open-mercato/shared/lib/i18n/translate'\nimport { formatDate } from './utils'\nimport { DealDialog } from './DealDialog'\nimport type { DealFormBaseValues, DealFormSubmitPayload } from './DealForm'\nimport { generateTempId } from '@open-mercato/core/modules/customers/lib/detailHelpers'\nimport { useCurrencyDictionary } from './hooks/useCurrencyDictionary'\nimport { useCustomerDictionary } from './hooks/useCustomerDictionary'\nimport { CustomFieldValuesList } from './CustomFieldValuesList'\nimport { useCustomFieldDisplay } from './hooks/useCustomFieldDisplay'\nimport { normalizeCustomFieldKey } from './customFieldUtils'\n\nconst DEALS_PAGE_SIZE = 10\n\ntype DealsScope =\n | { kind: 'person'; entityId: string }\n | { kind: 'company'; entityId: string }\n\ntype GuardedMutationRunner = <T,>(\n operation: () => Promise<T>,\n mutationPayload?: Record<string, unknown>,\n) => Promise<T>\n\ntype PendingAction =\n | { kind: 'create' }\n | { kind: 'update'; id: string }\n | { kind: 'remove'; id: string }\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction sanitizeCustomValues(input: unknown): Record<string, unknown> | null {\n if (!isPlainObject(input)) return null\n const result: Record<string, unknown> = {}\n Object.entries(input).forEach(([key, value]) => {\n const trimmedKey = key.trim()\n if (!trimmedKey.length) return\n result[trimmedKey] = value\n })\n return Object.keys(result).length ? result : null\n}\n\nfunction sanitizeCustomFieldEntries(\n entries: unknown,\n values: Record<string, unknown> | null,\n): DealCustomFieldEntry[] {\n const map = new Map<string, DealCustomFieldEntry>()\n if (Array.isArray(entries)) {\n entries.forEach((entry) => {\n if (!entry || typeof entry !== 'object') return\n const record = entry as Record<string, unknown>\n const keyRaw =\n typeof record.key === 'string'\n ? record.key\n : typeof record.id === 'string'\n ? record.id\n : null\n if (!keyRaw) return\n const key = keyRaw.trim()\n if (!key.length) return\n const normalizedKey = normalizeCustomFieldKey(key)\n if (!normalizedKey) return\n const label =\n typeof record.label === 'string' && record.label.trim().length\n ? record.label.trim()\n : null\n const kind =\n typeof record.kind === 'string' && record.kind.trim().length\n ? record.kind.trim()\n : null\n const multi =\n typeof record.multi === 'boolean' ? record.multi : Array.isArray(record.value) ? true : undefined\n map.set(normalizedKey, {\n key,\n label,\n value: record.value,\n kind,\n multi,\n })\n })\n }\n\n if (values) {\n Object.entries(values).forEach(([rawKey, value]) => {\n const key = rawKey.trim()\n if (!key.length) return\n const normalizedKey = normalizeCustomFieldKey(key)\n if (!normalizedKey) return\n const existing = map.get(normalizedKey)\n if (existing) {\n existing.value = value\n if (existing.multi === undefined) existing.multi = Array.isArray(value)\n } else {\n map.set(normalizedKey, {\n key,\n label: null,\n value,\n kind: null,\n multi: Array.isArray(value) ? true : undefined,\n })\n }\n })\n }\n\n return Array.from(map.values())\n}\n\ntype NormalizedDeal = Omit<\n DealSummary,\n 'valueAmount' | 'probability' | 'expectedCloseAt' | 'customValues' | 'customFields' | 'personIds' | 'companyIds'\n> & {\n valueAmount: number | null\n probability: number | null\n expectedCloseAt: string | null\n personIds: string[]\n companyIds: string[]\n customValues: Record<string, unknown> | null\n customFields: DealCustomFieldEntry[]\n}\n\nfunction toNumber(value: unknown): number | null {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed.length) return null\n const parsed = Number(trimmed)\n return Number.isNaN(parsed) ? null : parsed\n }\n return null\n}\n\nfunction toIso(value: unknown): string | null {\n if (typeof value === 'string') {\n const trimmed = value.trim()\n if (!trimmed.length) return null\n const parsed = new Date(trimmed)\n return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString()\n }\n if (value instanceof Date) {\n return Number.isNaN(value.getTime()) ? null : value.toISOString()\n }\n return null\n}\n\nfunction mergeIds(...sources: Array<unknown>): string[] {\n const set = new Set<string>()\n sources.forEach((source) => {\n if (Array.isArray(source)) {\n source.forEach((value) => {\n if (typeof value !== 'string') return\n const trimmed = value.trim()\n if (!trimmed.length) return\n set.add(trimmed)\n })\n }\n })\n return Array.from(set)\n}\n\nfunction normalizeDeal(deal: Partial<DealSummary> & { id: string; title?: string }): NormalizedDeal {\n const title = typeof deal.title === 'string' && deal.title.trim().length ? deal.title.trim() : ''\n const normalizeIdList = (list: unknown): string[] => {\n if (!Array.isArray(list)) return []\n const seen = new Set<string>()\n const result: string[] = []\n list.forEach((candidate) => {\n if (typeof candidate !== 'string') return\n const trimmed = candidate.trim()\n if (!trimmed.length || seen.has(trimmed)) return\n seen.add(trimmed)\n result.push(trimmed)\n })\n return result\n }\n\n const normalizeAssignees = (entries: unknown, fallbackIds: string[]): { id: string; label: string }[] => {\n if (!Array.isArray(entries)) {\n return fallbackIds.map((id) => ({ id, label: '' }))\n }\n const seen = new Set<string>()\n const resolved: { id: string; label: string }[] = []\n entries.forEach((entry) => {\n if (!entry || typeof entry !== 'object') return\n const data = entry as Record<string, unknown>\n const id = typeof data.id === 'string' ? data.id.trim() : ''\n if (!id || seen.has(id)) return\n const label = typeof data.label === 'string' ? data.label : ''\n seen.add(id)\n resolved.push({ id, label })\n })\n if (!resolved.length && fallbackIds.length) {\n return fallbackIds.map((id) => ({ id, label: '' }))\n }\n return resolved\n }\n\n const personIds = normalizeIdList(deal.personIds ?? null)\n const companyIds = normalizeIdList(deal.companyIds ?? null)\n const people = normalizeAssignees(deal.people ?? null, personIds)\n const companies = normalizeAssignees(deal.companies ?? null, companyIds)\n\n const customValues = sanitizeCustomValues(deal.customValues ?? null)\n const customFields = sanitizeCustomFieldEntries(deal.customFields ?? null, customValues)\n\n return {\n id: deal.id,\n title,\n status: typeof deal.status === 'string' ? deal.status : deal.status ?? null,\n pipelineStage:\n typeof deal.pipelineStage === 'string' ? deal.pipelineStage : deal.pipelineStage ?? null,\n pipelineId:\n typeof deal.pipelineId === 'string' && deal.pipelineId.trim().length\n ? deal.pipelineId.trim()\n : deal.pipelineId ?? null,\n pipelineStageId:\n typeof deal.pipelineStageId === 'string' && deal.pipelineStageId.trim().length\n ? deal.pipelineStageId.trim()\n : deal.pipelineStageId ?? null,\n valueAmount: toNumber(deal.valueAmount ?? null),\n valueCurrency:\n typeof deal.valueCurrency === 'string' && deal.valueCurrency.trim().length\n ? deal.valueCurrency.trim().toUpperCase()\n : null,\n probability: toNumber(deal.probability ?? null),\n expectedCloseAt: toIso(deal.expectedCloseAt ?? null),\n description:\n typeof deal.description === 'string' && deal.description.trim().length\n ? deal.description\n : deal.description ?? null,\n ownerUserId:\n typeof deal.ownerUserId === 'string' && deal.ownerUserId.trim().length\n ? deal.ownerUserId\n : deal.ownerUserId ?? null,\n source:\n typeof deal.source === 'string' && deal.source.trim().length ? deal.source : deal.source ?? null,\n closureOutcome:\n typeof deal.closureOutcome === 'string' && deal.closureOutcome.trim().length\n ? deal.closureOutcome\n : deal.closureOutcome ?? null,\n lossReasonId:\n typeof deal.lossReasonId === 'string' && deal.lossReasonId.trim().length\n ? deal.lossReasonId\n : deal.lossReasonId ?? null,\n lossNotes:\n typeof deal.lossNotes === 'string' && deal.lossNotes.trim().length\n ? deal.lossNotes\n : deal.lossNotes ?? null,\n createdAt: toIso(deal.createdAt ?? null),\n updatedAt: toIso(deal.updatedAt ?? null),\n personIds,\n companyIds,\n people,\n companies,\n customValues,\n customFields,\n }\n}\n\nfunction formatValueLabel(\n amount: number | null,\n currency: string | null,\n emptyLabel: string,\n locale?: string,\n): string {\n if (typeof amount === 'number') {\n const formatter = new Intl.NumberFormat(locale, {\n style: currency ? 'currency' : 'decimal',\n currency: currency ?? undefined,\n maximumFractionDigits: 2,\n })\n try {\n return formatter.format(amount)\n } catch {\n return currency ? `${amount} ${currency}` : `${amount}`\n }\n }\n return emptyLabel\n}\n\nexport type DealsSectionProps = {\n scope: DealsScope | null\n addActionLabel: string\n emptyLabel: string\n emptyState: TabEmptyStateConfig\n onCountDelta?: (delta: number) => void\n onActionChange?: (action: SectionAction | null) => void\n onLoadingChange?: (isLoading: boolean) => void\n onDataRefresh?: () => Promise<void> | void\n translator?: Translator\n runGuardedMutation?: GuardedMutationRunner\n}\n\nexport function DealsSection({\n scope,\n addActionLabel,\n emptyLabel,\n emptyState,\n onCountDelta,\n onActionChange,\n onLoadingChange,\n onDataRefresh,\n translator,\n runGuardedMutation,\n}: DealsSectionProps) {\n const tHook = useT()\n const locale = useLocale()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const fallbackTranslator = React.useMemo<Translator>(() => createTranslatorWithFallback(tHook), [tHook])\n const t: Translator = React.useMemo(() => translator ?? fallbackTranslator, [translator, fallbackTranslator])\n useCurrencyDictionary()\n const scopeVersion = useOrganizationScopeVersion()\n const statusDictionaryQuery = useCustomerDictionary('deal-statuses', scopeVersion)\n const statusDictionaryMap = statusDictionaryQuery.data?.map ?? null\n const customFieldResources = useCustomFieldDisplay(E.customers.customer_deal)\n\n const [deals, setDeals] = React.useState<NormalizedDeal[]>([])\n const [isLoading, setIsLoading] = React.useState<boolean>(() => Boolean(scope))\n const [loadError, setLoadError] = React.useState<string | null>(null)\n const [pendingAction, setPendingAction] = React.useState<PendingAction | null>(null)\n const [hasMore, setHasMore] = React.useState(false)\n const pageRef = React.useRef(0)\n const hasMoreRef = React.useRef(true)\n const [dialogOpen, setDialogOpen] = React.useState(false)\n const [initialValues, setInitialValues] = React.useState<\n Partial<DealFormBaseValues & Record<string, unknown>> | undefined\n >(undefined)\n const pendingCounterRef = React.useRef(0)\n\n const pushLoading = React.useCallback(() => {\n pendingCounterRef.current += 1\n if (pendingCounterRef.current === 1) onLoadingChange?.(true)\n }, [onLoadingChange])\n\n const popLoading = React.useCallback(() => {\n pendingCounterRef.current = Math.max(0, pendingCounterRef.current - 1)\n if (pendingCounterRef.current === 0) onLoadingChange?.(false)\n }, [onLoadingChange])\n\n const translate = React.useCallback(\n (key: string, fallback: string, params?: Record<string, string | number>) => {\n const value = t(key, fallback, params)\n return value === key && fallback ? fallback : value\n },\n [t],\n )\n const runWriteMutation = React.useCallback(\n async <T,>(operation: () => Promise<T>, mutationPayload?: Record<string, unknown>): Promise<T> => {\n if (!runGuardedMutation) {\n return operation()\n }\n return runGuardedMutation(operation, mutationPayload)\n },\n [runGuardedMutation],\n )\n const refreshParentData = React.useCallback(async () => {\n await Promise.resolve(onDataRefresh?.())\n }, [onDataRefresh])\n\n const loadDeals = React.useCallback(async ({ append }: { append: boolean }) => {\n if (!scope) {\n setDeals([])\n setLoadError(null)\n setHasMore(false)\n setIsLoading(false)\n pendingCounterRef.current = 0\n onLoadingChange?.(false)\n pageRef.current = 0\n hasMoreRef.current = false\n return\n }\n if (append && !hasMoreRef.current) return\n const nextPage = append ? pageRef.current + 1 : 1\n if (!append) {\n pageRef.current = 0\n hasMoreRef.current = true\n setHasMore(true)\n setDeals([])\n }\n pushLoading()\n setIsLoading(true)\n try {\n const params = new URLSearchParams({\n page: String(nextPage),\n pageSize: String(DEALS_PAGE_SIZE),\n sortField: 'updatedAt',\n sortDir: 'desc',\n })\n if (scope.kind === 'person') params.set('personEntityId', scope.entityId)\n if (scope.kind === 'company') params.set('companyEntityId', scope.entityId)\n const payload = await readApiResultOrThrow<Record<string, unknown>>(\n `/api/customers/deals?${params.toString()}`,\n undefined,\n { errorMessage: translate('customers.people.detail.deals.loadError', 'Failed to load deals.') },\n )\n const rawItems = Array.isArray(payload?.items) ? payload.items : []\n const mapped: NormalizedDeal[] = rawItems.map((item: unknown) => {\n const record = (item && typeof item === 'object') ? (item as Record<string, unknown>) : {}\n const id =\n typeof record.id === 'string' && record.id.trim().length ? record.id : generateTempId()\n const title =\n typeof record.title === 'string' && record.title.trim().length ? record.title.trim() : ''\n const status =\n typeof record.status === 'string' && record.status.trim().length\n ? record.status.trim()\n : null\n const pipelineStage =\n typeof record.pipelineStage === 'string' && record.pipelineStage.trim().length\n ? record.pipelineStage.trim()\n : typeof record.pipeline_stage === 'string' && record.pipeline_stage.trim().length\n ? record.pipeline_stage.trim()\n : null\n const pipelineId =\n typeof record.pipelineId === 'string' && record.pipelineId.trim().length\n ? record.pipelineId.trim()\n : typeof record.pipeline_id === 'string' && record.pipeline_id.trim().length\n ? record.pipeline_id.trim()\n : null\n const pipelineStageId =\n typeof record.pipelineStageId === 'string' && record.pipelineStageId.trim().length\n ? record.pipelineStageId.trim()\n : typeof record.pipeline_stage_id === 'string' && record.pipeline_stage_id.trim().length\n ? record.pipeline_stage_id.trim()\n : null\n const valueAmount = toNumber(record.valueAmount ?? record.value_amount)\n const valueCurrencyRaw = record.valueCurrency ?? record.value_currency ?? null\n const valueCurrency =\n typeof valueCurrencyRaw === 'string' && valueCurrencyRaw.trim().length\n ? valueCurrencyRaw.trim().toUpperCase()\n : null\n const probability = toNumber(record.probability)\n const expectedCloseAt =\n typeof record.expectedCloseAt === 'string' && record.expectedCloseAt.trim().length\n ? record.expectedCloseAt\n : typeof record.expected_close_at === 'string' && record.expected_close_at.trim().length\n ? record.expected_close_at\n : null\n const description =\n typeof record.description === 'string' && record.description.trim().length\n ? record.description\n : null\n const ownerUserId =\n typeof record.ownerUserId === 'string' && record.ownerUserId.trim().length\n ? record.ownerUserId\n : typeof record.owner_user_id === 'string' && record.owner_user_id.trim().length\n ? record.owner_user_id\n : null\n const source =\n typeof record.source === 'string' && record.source.trim().length\n ? record.source\n : null\n const closureOutcome =\n typeof record.closureOutcome === 'string' && record.closureOutcome.trim().length\n ? record.closureOutcome\n : typeof record.closure_outcome === 'string' && record.closure_outcome.trim().length\n ? record.closure_outcome\n : null\n const lossReasonId =\n typeof record.lossReasonId === 'string' && record.lossReasonId.trim().length\n ? record.lossReasonId\n : typeof record.loss_reason_id === 'string' && record.loss_reason_id.trim().length\n ? record.loss_reason_id\n : null\n const lossNotes =\n typeof record.lossNotes === 'string' && record.lossNotes.trim().length\n ? record.lossNotes\n : typeof record.loss_notes === 'string' && record.loss_notes.trim().length\n ? record.loss_notes\n : null\n const createdAt =\n typeof record.createdAt === 'string' && record.createdAt.trim().length\n ? record.createdAt\n : typeof record.created_at === 'string' && record.created_at.trim().length\n ? record.created_at\n : null\n const updatedAt =\n typeof record.updatedAt === 'string' && record.updatedAt.trim().length\n ? record.updatedAt\n : typeof record.updated_at === 'string' && record.updated_at.trim().length\n ? record.updated_at\n : null\n const personIds = Array.isArray(record.personIds)\n ? record.personIds\n : Array.isArray(record.person_ids)\n ? record.person_ids\n : []\n const people = Array.isArray(record.people) ? record.people : []\n const companyIds = Array.isArray(record.companyIds)\n ? record.companyIds\n : Array.isArray(record.company_ids)\n ? record.company_ids\n : []\n const companies = Array.isArray(record.companies) ? record.companies : []\n const customValues = sanitizeCustomValues(\n record.customValues ?? record.custom_values ?? null,\n )\n const customFieldEntries = sanitizeCustomFieldEntries(\n record.customFields ?? record.custom_fields ?? null,\n customValues,\n )\n return normalizeDeal({\n id,\n title,\n status,\n pipelineStage,\n pipelineId,\n pipelineStageId,\n valueAmount,\n valueCurrency,\n probability,\n expectedCloseAt,\n description,\n ownerUserId,\n source,\n closureOutcome,\n lossReasonId,\n lossNotes,\n createdAt,\n updatedAt,\n personIds: personIds as string[] | undefined,\n people: people as { id: string; label: string }[] | undefined,\n companyIds: companyIds as string[] | undefined,\n companies: companies as { id: string; label: string }[] | undefined,\n customValues,\n customFields: customFieldEntries,\n })\n })\n setDeals((prev) => {\n if (!append) return mapped\n const mappedById = new Map(mapped.map((deal) => [deal.id, deal]))\n const prevIds = new Set(prev.map((deal) => deal.id))\n const updatedPrev = prev.map((deal) => mappedById.get(deal.id) ?? deal)\n const appended = mapped.filter((deal) => !prevIds.has(deal.id))\n return [...updatedPrev, ...appended]\n })\n pageRef.current = nextPage\n // Short-page termination, unconditionally \u2014 see `hasMoreFromPage`.\n // Preferring `totalPages` here hid deals that do exist. Measured on\n // `rawItems`, which is what the server served, rather than on the\n // deduped rows appended above.\n const nextHasMore = hasMoreFromPage(rawItems.length, DEALS_PAGE_SIZE)\n hasMoreRef.current = nextHasMore\n setHasMore(nextHasMore)\n setLoadError(null)\n } catch (err) {\n const message =\n err instanceof Error\n ? err.message\n : translate('customers.people.detail.deals.loadError', 'Failed to load deals.')\n setLoadError(message)\n if (!append) {\n setHasMore(false)\n hasMoreRef.current = false\n }\n } finally {\n setIsLoading(false)\n popLoading()\n }\n }, [popLoading, pushLoading, scope, translate])\n\n React.useEffect(() => {\n loadDeals({ append: false }).catch(() => {})\n }, [loadDeals, scope])\n\n const openCreateDialog = React.useCallback(() => {\n if (!scope) return\n setInitialValues({\n personIds: scope.kind === 'person' ? [scope.entityId] : [],\n companyIds: scope.kind === 'company' ? [scope.entityId] : [],\n })\n setDialogOpen(true)\n }, [scope])\n\n const [linkDialogOpen, setLinkDialogOpen] = React.useState(false)\n const openLinkDialog = React.useCallback(() => {\n if (!scope) return\n setLinkDialogOpen(true)\n }, [scope])\n\n const existingDealIds = React.useMemo(() => deals.map((deal) => deal.id), [deals])\n\n const dealLinkAdapter = React.useMemo(\n () =>\n createDealLinkAdapter({\n dialogTitle: t('customers.linking.deal.dialogTitle', 'Link deal'),\n dialogSubtitle: t(\n 'customers.linking.deal.dialogSubtitle',\n 'Link an existing deal to this record',\n ),\n sectionLabel: t('customers.linking.deal.sectionLabel', 'MATCHING DEALS'),\n searchPlaceholder: t('customers.linking.deal.searchPlaceholder', 'Search all deals\u2026'),\n searchEmptyHint: t('customers.linking.deal.searchEmpty', 'No matching deals found.'),\n selectedEmptyHint: t('customers.linking.deal.selectedEmpty', 'No deals selected.'),\n confirmButtonLabel: t('customers.linking.deal.confirmButton', 'Link deal'),\n orphanWarningTitle: t('customers.linking.deal.orphanWarningTitle', 'Deal without company'),\n orphanWarningMessage: t(\n 'customers.linking.deal.orphanWarning',\n 'This deal has no other linked entities. If you unlink it later, it will become unreachable.',\n ),\n contextEntityId: scope?.entityId,\n }),\n [scope?.entityId, t],\n )\n\n const handleLinkConfirm = React.useCallback(\n async ({\n addedIds,\n removedIds,\n }: {\n addedIds: string[]\n removedIds: string[]\n }) => {\n if (!scope) return\n if (!addedIds.length && !removedIds.length) return\n pushLoading()\n try {\n for (const dealId of addedIds) {\n const payload = await readApiResultOrThrow<Record<string, unknown>>(\n `/api/customers/deals/${encodeURIComponent(dealId)}`,\n )\n const currentPersonIds = Array.isArray(payload.personIds)\n ? (payload.personIds as string[]).filter((id) => typeof id === 'string')\n : []\n const currentCompanyIds = Array.isArray(payload.companyIds)\n ? (payload.companyIds as string[]).filter((id) => typeof id === 'string')\n : []\n const nextPersonIds =\n scope.kind === 'person' && !currentPersonIds.includes(scope.entityId)\n ? [...currentPersonIds, scope.entityId]\n : currentPersonIds\n const nextCompanyIds =\n scope.kind === 'company' && !currentCompanyIds.includes(scope.entityId)\n ? [...currentCompanyIds, scope.entityId]\n : currentCompanyIds\n await runWriteMutation(\n () =>\n // optimistic-lock-exempt: deal association list (link)\n updateCrud(\n 'customers/deals',\n { id: dealId, personIds: nextPersonIds, companyIds: nextCompanyIds },\n {\n errorMessage: t(\n 'customers.people.detail.deals.linkError',\n 'Failed to link deal.',\n ),\n },\n ),\n { dealId, scopeKind: scope.kind, scopeEntityId: scope.entityId, operation: 'linkDeal' },\n )\n }\n for (const dealId of removedIds) {\n const payload = await readApiResultOrThrow<Record<string, unknown>>(\n `/api/customers/deals/${encodeURIComponent(dealId)}`,\n )\n const currentPersonIds = Array.isArray(payload.personIds)\n ? (payload.personIds as string[]).filter((id) => typeof id === 'string')\n : []\n const currentCompanyIds = Array.isArray(payload.companyIds)\n ? (payload.companyIds as string[]).filter((id) => typeof id === 'string')\n : []\n const nextPersonIds =\n scope.kind === 'person'\n ? currentPersonIds.filter((id) => id !== scope.entityId)\n : currentPersonIds\n const nextCompanyIds =\n scope.kind === 'company'\n ? currentCompanyIds.filter((id) => id !== scope.entityId)\n : currentCompanyIds\n await runWriteMutation(\n () =>\n // optimistic-lock-exempt: deal association list (unlink)\n updateCrud(\n 'customers/deals',\n { id: dealId, personIds: nextPersonIds, companyIds: nextCompanyIds },\n {\n errorMessage: t(\n 'customers.people.detail.deals.unlinkError',\n 'Failed to unlink deal.',\n ),\n },\n ),\n { dealId, scopeKind: scope.kind, scopeEntityId: scope.entityId, operation: 'unlinkDeal' },\n )\n }\n await loadDeals({ append: false })\n await refreshParentData()\n if (addedIds.length + removedIds.length > 0) {\n onCountDelta?.(addedIds.length - removedIds.length)\n }\n flash(\n addedIds.length > 0\n ? t('customers.people.detail.deals.linkSuccess', 'Deal linked.')\n : t('customers.people.detail.deals.unlinkSuccess', 'Deal unlinked.'),\n 'success',\n )\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : t('customers.people.detail.deals.linkError', 'Failed to link deal.')\n flash(message, 'error')\n } finally {\n popLoading()\n }\n },\n [loadDeals, onCountDelta, popLoading, pushLoading, refreshParentData, runWriteMutation, scope, t],\n )\n\n const closeDialog = React.useCallback(() => {\n setDialogOpen(false)\n setInitialValues(undefined)\n }, [])\n\n const handleDialogOpenChange = React.useCallback(\n (next: boolean) => {\n if (!next) closeDialog()\n else setDialogOpen(true)\n },\n [closeDialog],\n )\n\n const handleCreate = React.useCallback(\n async ({ base, custom }: DealFormSubmitPayload) => {\n if (!scope) {\n throw new Error(translate('customers.people.detail.deals.error', 'Failed to save deal.'))\n }\n setPendingAction({ kind: 'create' })\n pushLoading()\n try {\n const personIds = mergeIds(base.personIds)\n const companyIds = mergeIds(base.companyIds)\n\n const payload: Record<string, unknown> = {\n title: base.title,\n status: base.status ?? undefined,\n pipelineStage: base.pipelineStage ?? undefined,\n pipelineId: base.pipelineId ?? undefined,\n pipelineStageId: base.pipelineStageId ?? undefined,\n valueAmount: typeof base.valueAmount === 'number' ? base.valueAmount : undefined,\n valueCurrency: base.valueCurrency ?? undefined,\n probability: typeof base.probability === 'number' ? base.probability : undefined,\n expectedCloseAt: base.expectedCloseAt ?? undefined,\n description: base.description ?? undefined,\n // This payload is an explicit allow-list, so an omitted field never reaches the API.\n // `base.ownerUserId` is `null` when the picker is empty and a uuid otherwise; both are\n // valid on `dealCreateSchema` (validators.ts:183) and `createDealCommand` maps null to\n // null. Leaving it out created every deal from this flow unowned, silently.\n ownerUserId: base.ownerUserId ?? null,\n personIds,\n companyIds,\n }\n if (Object.keys(custom).length) payload.customFields = custom\n const { result } = await runWriteMutation(\n () =>\n // optimistic-lock-exempt: deal create-only, no prior version\n createCrud<{ id?: string }>('customers/deals', payload, {\n errorMessage: translate('customers.people.detail.deals.error', 'Failed to save deal.'),\n }),\n {\n ...payload,\n operation: 'createDeal',\n },\n )\n const dealId =\n typeof result?.id === 'string' && result.id.trim().length ? result.id : generateTempId()\n const belongsToScope =\n (scope.kind !== 'person' || personIds.includes(scope.entityId)) &&\n (scope.kind !== 'company' || companyIds.includes(scope.entityId))\n if (belongsToScope) {\n const customValuesForState = sanitizeCustomValues(\n Object.keys(custom).length ? custom : null,\n )\n const timestamp = new Date().toISOString()\n const normalized = normalizeDeal({\n id: dealId,\n title: base.title,\n status: base.status ?? null,\n pipelineStage: base.pipelineStage ?? null,\n pipelineId: base.pipelineId ?? null,\n pipelineStageId: base.pipelineStageId ?? null,\n valueAmount: base.valueAmount ?? null,\n valueCurrency: base.valueCurrency ?? null,\n probability: base.probability ?? null,\n expectedCloseAt: base.expectedCloseAt ?? null,\n description: base.description ?? null,\n personIds,\n companyIds,\n customValues: customValuesForState,\n createdAt: timestamp,\n updatedAt: timestamp,\n })\n setDeals((prev) => [normalized, ...prev])\n onCountDelta?.(1)\n }\n await refreshParentData()\n flash(translate('customers.people.detail.deals.success', 'Deal created.'), 'success')\n } finally {\n setPendingAction(null)\n popLoading()\n }\n },\n [onCountDelta, popLoading, pushLoading, refreshParentData, runWriteMutation, scope, translate],\n )\n\n const handleUnlink = React.useCallback(\n async (deal: NormalizedDeal) => {\n if (!scope) return\n\n const nextPersonIds =\n scope.kind === 'person'\n ? deal.personIds.filter((id) => id !== scope.entityId)\n : deal.personIds\n const nextCompanyIds =\n scope.kind === 'company'\n ? deal.companyIds.filter((id) => id !== scope.entityId)\n : deal.companyIds\n\n const confirmed = await confirm({\n title:\n scope.kind === 'person'\n ? translate('customers.people.detail.deals.unlinkConfirmPerson', 'Unlink this deal from this person?')\n : translate('customers.people.detail.deals.unlinkConfirmCompany', 'Unlink this deal from this company?'),\n description: translate(\n 'customers.people.detail.deals.unlinkDescription',\n 'The deal will remain available from its own detail page.',\n ),\n confirmText: translate('customers.people.card.unlink', 'Unlink'),\n cancelText: translate('customers.people.detail.deals.cancel', 'Cancel'),\n })\n if (!confirmed) return\n\n setPendingAction({ kind: 'remove', id: deal.id })\n pushLoading()\n try {\n const payload: Record<string, unknown> = {\n id: deal.id,\n personIds: nextPersonIds,\n companyIds: nextCompanyIds,\n }\n await runWriteMutation(\n () =>\n // optimistic-lock-exempt: deal association list (unlink)\n updateCrud('customers/deals', payload, {\n errorMessage: translate('customers.people.detail.deals.unlinkError', 'Failed to unlink deal.'),\n }),\n {\n ...payload,\n operation: 'unlinkDeal',\n },\n )\n setDeals((prev) => prev.filter((item) => item.id !== deal.id))\n onCountDelta?.(-1)\n await refreshParentData()\n flash(translate('customers.people.detail.deals.unlinkSuccess', 'Deal unlinked.'), 'success')\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : translate('customers.people.detail.deals.unlinkError', 'Failed to unlink deal.')\n flash(message, 'error')\n } finally {\n setPendingAction(null)\n popLoading()\n }\n },\n [confirm, onCountDelta, popLoading, pushLoading, refreshParentData, runWriteMutation, scope, translate],\n )\n\n const handleDialogSubmit = React.useCallback(\n async (payload: DealFormSubmitPayload) => {\n try {\n await handleCreate(payload)\n closeDialog()\n } catch (err) {\n const message =\n err instanceof Error\n ? err.message\n : translate('customers.people.detail.deals.error', 'Failed to save deal.')\n flash(message, 'error')\n }\n },\n [closeDialog, handleCreate, translate],\n )\n\n React.useEffect(() => {\n onActionChange?.(null)\n return () => onActionChange?.(null)\n }, [onActionChange])\n\n const isFormPending = pendingAction?.kind === 'create'\n\n const sortedDeals = React.useMemo(() => {\n return [...deals].sort((a, b) => {\n const timeA = a.updatedAt ?? a.createdAt ?? ''\n const timeB = b.updatedAt ?? b.createdAt ?? ''\n return timeB.localeCompare(timeA)\n })\n }, [deals])\n\n return (\n <div className=\"mt-4 space-y-4\">\n {loadError ? (\n <div className=\"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive\">\n {loadError}\n </div>\n ) : null}\n <div className=\"flex flex-wrap items-center justify-end gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={openLinkDialog}\n disabled={!scope || pendingAction !== null}\n >\n <Link2 className=\"mr-1.5 size-3.5\" />\n {t('customers.people.detail.deals.linkExisting', 'Link existing deal')}\n </Button>\n <Button\n type=\"button\"\n variant=\"default\"\n size=\"sm\"\n onClick={openCreateDialog}\n disabled={!scope || pendingAction !== null}\n >\n <Plus className=\"mr-1.5 size-3.5\" />\n {addActionLabel}\n </Button>\n </div>\n {isLoading && sortedDeals.length === 0 ? (\n <LoadingMessage\n label={t('customers.people.detail.deals.loading', 'Loading deals\u2026')}\n className=\"border-0 bg-transparent p-0 py-8 justify-center\"\n />\n ) : (\n <>\n {!isLoading && sortedDeals.length === 0 ? (\n <TabEmptyState\n title={emptyState.title}\n action={{\n label: emptyState.actionLabel,\n onClick: openCreateDialog,\n disabled: !scope || pendingAction !== null,\n }}\n />\n ) : null}\n <div className=\"space-y-4\">\n {sortedDeals.map((deal) => {\n const valueLabel = formatValueLabel(deal.valueAmount, deal.valueCurrency ?? null, emptyLabel, locale)\n const expectedLabel = deal.expectedCloseAt ? formatDate(deal.expectedCloseAt, locale) ?? emptyLabel : emptyLabel\n const probabilityLabel =\n typeof deal.probability === 'number' ? `${deal.probability}%` : emptyLabel\n const isUnlinkPending = pendingAction?.kind === 'remove' && pendingAction.id === deal.id\n const statusLabel =\n deal.status && statusDictionaryMap\n ? statusDictionaryMap[deal.status]?.label ?? deal.status\n : deal.status ?? emptyLabel\n return (\n <article key={deal.id} className=\"group rounded-lg border bg-card p-4 shadow-xs transition hover:border-border/70\">\n <header className=\"flex flex-wrap items-center justify-between gap-2\">\n <div>\n <Link\n href={`/backend/customers/deals/${encodeURIComponent(deal.id)}`}\n className=\"text-base font-semibold text-foreground transition hover:text-primary hover:underline\"\n >\n {deal.title || emptyLabel}\n </Link>\n {deal.description ? (\n <p className=\"mt-1 line-clamp-3 text-sm text-muted-foreground whitespace-pre-wrap\">{deal.description}</p>\n ) : null}\n </div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs font-medium uppercase text-muted-foreground\">\n {statusLabel}\n </span>\n <div className=\"flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100\">\n <IconButton asChild variant=\"ghost\" size=\"sm\" className=\"h-8 w-8\">\n <Link\n href={`/backend/customers/deals/${encodeURIComponent(deal.id)}`}\n aria-label={t('customers.people.detail.deals.edit', 'Open deal details')}\n >\n <Pencil className=\"size-4\" />\n </Link>\n </IconButton>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"h-8 rounded-lg px-3 text-xs\"\n onClick={(event) => {\n event.preventDefault()\n void handleUnlink(deal)\n }}\n disabled={pendingAction !== null}\n >\n {isUnlinkPending\n ? t('customers.people.detail.deals.unlinking', 'Unlinking\u2026')\n : t('customers.people.card.unlink', 'Unlink')}\n </Button>\n </div>\n </div>\n </header>\n <dl className=\"mt-3 grid gap-2 text-xs text-muted-foreground sm:grid-cols-2\">\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.pipelineStage', 'Pipeline stage')}\n </dt>\n <dd>{deal.pipelineStage ?? emptyLabel}</dd>\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.probability', 'Probability')}\n </dt>\n <dd>{probabilityLabel}</dd>\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.valueAmount', 'Value')}\n </dt>\n <dd>{valueLabel}</dd>\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <dt className=\"font-medium\">\n {t('customers.people.detail.deals.fields.expectedCloseAt', 'Expected close')}\n </dt>\n <dd>{expectedLabel}</dd>\n </div>\n </dl>\n <CustomFieldValuesList\n entries={deal.customFields?.map((entry) => ({\n key: entry.key,\n value: entry.value,\n label: entry.label ?? undefined,\n }))}\n values={deal.customValues ?? undefined}\n resources={customFieldResources}\n emptyLabel={emptyLabel}\n itemKeyPrefix={`deal-${deal.id}-field`}\n className=\"mt-3\"\n />\n </article>\n )\n })}\n {isLoading && deals.length > 0 ? (\n <div className=\"flex justify-center\">\n <LoadingMessage\n label={t('customers.people.detail.deals.loading', 'Loading deals\u2026')}\n className=\"border-0 bg-transparent p-0 justify-center [&_span[role='status']]:h-5 [&_span[role='status']]:w-5\"\n />\n </div>\n ) : null}\n {!isLoading && hasMore ? (\n <div className=\"flex justify-center\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => {\n loadDeals({ append: true }).catch(() => {})\n }}\n disabled={pendingAction !== null || isLoading}\n >\n {t('customers.people.detail.deals.loadMore', 'Load more deals')}\n </Button>\n </div>\n ) : null}\n </div>\n </>\n )}\n\n <DealDialog\n open={dialogOpen}\n mode=\"create\"\n onOpenChange={handleDialogOpenChange}\n initialValues={initialValues}\n onSubmit={async (payload) => {\n await handleDialogSubmit(payload)\n }}\n isSubmitting={Boolean(isFormPending)}\n />\n <LinkEntityDialog\n open={linkDialogOpen}\n onOpenChange={setLinkDialogOpen}\n adapter={dealLinkAdapter}\n initialSelectedIds={existingDealIds}\n onConfirm={handleLinkConfirm}\n />\n {ConfirmDialogElement}\n </div>\n )\n}\n\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AC3B,gBAAM,mBAAmB,OAAO;AAAA,QAClC;AAAA,QACA,cAAc,QAAQ,aAAa;AAAA;AAAA,IACrC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,cAAc;AAAA,QACd,SAAS;AAAA,QACT,oBAAoB;AAAA,QACpB,WAAW;AAAA;AAAA,IACb;AAAA,IACC;AAAA,KACH;AAEJ;AAEA,IAAO,uBAAQ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,190 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Users } from "lucide-react";
5
+ import { Badge } from "@open-mercato/ui/primitives/badge";
6
+ import { Switch } from "@open-mercato/ui/primitives/switch";
7
+ import { apiCall, withScopedApiRequestHeaders } from "@open-mercato/ui/backend/utils/apiCall";
8
+ import { useConfirmDialog } from "@open-mercato/ui/backend/confirm-dialog";
9
+ import { useGuardedMutation } from "@open-mercato/ui/backend/injection/useGuardedMutation";
10
+ import { surfaceRecordConflict } from "@open-mercato/ui/backend/conflicts";
11
+ import { buildOptimisticLockHeader } from "@open-mercato/ui/backend/utils/optimisticLock";
12
+ import { flash } from "@open-mercato/ui/backend/FlashMessages";
13
+ import { useT } from "@open-mercato/shared/lib/i18n/context";
14
+ const CONTEXT_ID = "customers-person-email-share";
15
+ const EMPTY_STATE = {
16
+ sharedByMe: false,
17
+ canShare: false,
18
+ updatedAt: null,
19
+ sharedBy: []
20
+ };
21
+ function PersonEmailShareControl({
22
+ personId,
23
+ reloadToken,
24
+ onChanged
25
+ }) {
26
+ const t = useT();
27
+ const [state, setState] = React.useState(EMPTY_STATE);
28
+ const [busy, setBusy] = React.useState(false);
29
+ const { confirm, ConfirmDialogElement } = useConfirmDialog();
30
+ const { runMutation, retryLastMutation } = useGuardedMutation({
31
+ contextId: CONTEXT_ID,
32
+ blockedMessage: t("ui.forms.flash.saveBlocked", "Save blocked by validation")
33
+ });
34
+ const load = React.useCallback(async () => {
35
+ try {
36
+ const response = await apiCall(
37
+ `/api/customers/people/${encodeURIComponent(personId)}/email-share`,
38
+ {
39
+ method: "GET",
40
+ // Polled alongside the thread list: degrade quietly rather than
41
+ // hijacking the page with a login redirect on an expired session.
42
+ headers: { "x-om-forbidden-redirect": "0", "x-om-unauthorized-redirect": "0" }
43
+ }
44
+ );
45
+ if (!response.ok || !response.result) {
46
+ setState(EMPTY_STATE);
47
+ return;
48
+ }
49
+ const result = response.result;
50
+ setState({
51
+ sharedByMe: !!result.sharedByMe,
52
+ canShare: !!result.canShare,
53
+ updatedAt: typeof result.updatedAt === "string" ? result.updatedAt : null,
54
+ sharedBy: Array.isArray(result.sharedBy) ? result.sharedBy : []
55
+ });
56
+ } catch {
57
+ setState(EMPTY_STATE);
58
+ }
59
+ }, [personId]);
60
+ const busyRef = React.useRef(false);
61
+ React.useEffect(() => {
62
+ busyRef.current = busy;
63
+ }, [busy]);
64
+ React.useEffect(() => {
65
+ if (busyRef.current) return;
66
+ void load();
67
+ }, [load, reloadToken]);
68
+ const applyShared = React.useCallback(
69
+ async (nextShared) => {
70
+ const operation = async () => {
71
+ const response = await withScopedApiRequestHeaders(
72
+ buildOptimisticLockHeader(state.updatedAt),
73
+ () => apiCall(
74
+ `/api/customers/people/${encodeURIComponent(personId)}/email-share`,
75
+ {
76
+ method: "PUT",
77
+ headers: { "content-type": "application/json" },
78
+ body: JSON.stringify({ shared: nextShared })
79
+ }
80
+ )
81
+ );
82
+ if (!response.ok) {
83
+ const err = response.result;
84
+ throw new Error(
85
+ err?.error ?? t("customers.email.conversationShare.errors.updateFailed", "Could not update sharing")
86
+ );
87
+ }
88
+ return true;
89
+ };
90
+ return runMutation({
91
+ operation,
92
+ context: {
93
+ formId: CONTEXT_ID,
94
+ resourceKind: "customers.email_conversation_share",
95
+ resourceId: personId,
96
+ retryLastMutation
97
+ },
98
+ mutationPayload: { shared: nextShared }
99
+ });
100
+ },
101
+ [personId, state.updatedAt, runMutation, retryLastMutation, t]
102
+ );
103
+ const onToggle = React.useCallback(
104
+ async (nextShared) => {
105
+ if (busy) return;
106
+ if (nextShared) {
107
+ const confirmed = await confirm({
108
+ title: t("customers.email.conversationShare.confirm.title", "Share this conversation?"),
109
+ text: t(
110
+ "customers.email.conversationShare.confirm.text",
111
+ "Your colleagues will be able to read your email history with this person, including messages already received. You can stop sharing at any time."
112
+ ),
113
+ confirmText: t("customers.email.conversationShare.confirm.cta", "Share with team")
114
+ });
115
+ if (!confirmed) return;
116
+ }
117
+ setBusy(true);
118
+ try {
119
+ const result = await applyShared(nextShared);
120
+ if (!result) return;
121
+ flash(
122
+ nextShared ? t("customers.email.conversationShare.flash.shared", "Conversation shared with your team") : t("customers.email.conversationShare.flash.unshared", "Conversation is private again"),
123
+ "success"
124
+ );
125
+ await load();
126
+ onChanged?.();
127
+ } catch (err) {
128
+ if (surfaceRecordConflict(err, t)) return;
129
+ flash(
130
+ err instanceof Error ? err.message : t("customers.email.conversationShare.errors.updateFailed", "Could not update sharing"),
131
+ "error"
132
+ );
133
+ } finally {
134
+ setBusy(false);
135
+ }
136
+ },
137
+ [busy, confirm, applyShared, load, onChanged, t]
138
+ );
139
+ const sharedByLabel = React.useMemo(() => {
140
+ if (state.sharedBy.length === 0) return null;
141
+ const names = state.sharedBy.map((entry) => entry.userName).filter((name) => !!name);
142
+ if (names.length === 0) {
143
+ return t("customers.email.conversationShare.sharedByTeammate", "Shared by a teammate");
144
+ }
145
+ return t("customers.email.conversationShare.sharedBy", "Shared by {{names}}", {
146
+ names: names.join(", ")
147
+ });
148
+ }, [state.sharedBy, t]);
149
+ if (!state.canShare && !sharedByLabel) return null;
150
+ return /* @__PURE__ */ jsxs("div", { className: "mb-3 flex flex-wrap items-center justify-between gap-3 rounded-md border border-border bg-muted/40 px-3 py-2", children: [
151
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
152
+ /* @__PURE__ */ jsx(Users, { className: "h-4 w-4 text-muted-foreground", "aria-hidden": "true" }),
153
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
154
+ state.canShare ? /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: t(
155
+ "customers.email.conversationShare.label",
156
+ "Share this conversation with my team"
157
+ ) }) : null,
158
+ sharedByLabel ? /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "w-fit", children: sharedByLabel }) : null,
159
+ state.canShare ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: state.sharedByMe ? t(
160
+ "customers.email.conversationShare.hint.on",
161
+ "Colleagues can read your email history with this person."
162
+ ) : t(
163
+ "customers.email.conversationShare.hint.off",
164
+ "Only you can read your email with this person."
165
+ ) }) : null
166
+ ] })
167
+ ] }),
168
+ state.canShare ? /* @__PURE__ */ jsx(
169
+ Switch,
170
+ {
171
+ checked: state.sharedByMe,
172
+ disabled: busy,
173
+ onCheckedChange: (next) => {
174
+ void onToggle(next);
175
+ },
176
+ "aria-label": t(
177
+ "customers.email.conversationShare.label",
178
+ "Share this conversation with my team"
179
+ )
180
+ }
181
+ ) : null,
182
+ ConfirmDialogElement
183
+ ] });
184
+ }
185
+ var PersonEmailShareControl_default = PersonEmailShareControl;
186
+ export {
187
+ PersonEmailShareControl,
188
+ PersonEmailShareControl_default as default
189
+ };
190
+ //# sourceMappingURL=PersonEmailShareControl.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/modules/customers/components/detail/PersonEmailShareControl.tsx"],
4
+ "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { Users } from 'lucide-react'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { Switch } from '@open-mercato/ui/primitives/switch'\nimport { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\ntype SharedByEntry = {\n userId: string\n userName: string | null\n sharedAt: string | null\n}\n\ntype ShareState = {\n sharedByMe: boolean\n canShare: boolean\n updatedAt: string | null\n sharedBy: SharedByEntry[]\n}\n\ntype PersonEmailShareControlProps = {\n personId: string\n /**\n * Bumped by the host whenever it re-reads the thread list, so this control\n * re-reads with it.\n *\n * Required because `canShare` only turns true once the caller owns a private\n * email interaction with this Person, and that row is written by a queue\n * worker after the send completes \u2014 so the mount-time read is always too\n * early on a first send, and the switch stayed hidden until a manual page\n * refresh (#6455). The host's post-send burst poll covers that window; this\n * control follows it rather than running a second timer of its own.\n */\n reloadToken?: number\n /** Called after a successful flip so the thread list can refetch. */\n onChanged?: () => void\n}\n\nconst CONTEXT_ID = 'customers-person-email-share'\n\nconst EMPTY_STATE: ShareState = {\n sharedByMe: false,\n canShare: false,\n updatedAt: null,\n sharedBy: [],\n}\n\n/**\n * Owner-facing switch that hands the caller's whole email conversation with this\n * Person to the team, plus the teammate-facing \"Shared by <name>\" badge.\n *\n * Rendered above `EmailThreadsPanel` rather than inside it so the shared UI\n * package's panel contract stays untouched.\n */\nexport function PersonEmailShareControl({\n personId,\n reloadToken,\n onChanged,\n}: PersonEmailShareControlProps) {\n const t = useT()\n const [state, setState] = React.useState<ShareState>(EMPTY_STATE)\n const [busy, setBusy] = React.useState(false)\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n formId: string\n resourceKind: string\n resourceId: string\n retryLastMutation: () => Promise<boolean>\n }>({\n contextId: CONTEXT_ID,\n blockedMessage: t('ui.forms.flash.saveBlocked', 'Save blocked by validation'),\n })\n\n const load = React.useCallback(async () => {\n try {\n const response = await apiCall<ShareState>(\n `/api/customers/people/${encodeURIComponent(personId)}/email-share`,\n {\n method: 'GET',\n // Polled alongside the thread list: degrade quietly rather than\n // hijacking the page with a login redirect on an expired session.\n headers: { 'x-om-forbidden-redirect': '0', 'x-om-unauthorized-redirect': '0' },\n },\n )\n if (!response.ok || !response.result) {\n setState(EMPTY_STATE)\n return\n }\n const result = response.result\n setState({\n sharedByMe: !!result.sharedByMe,\n canShare: !!result.canShare,\n updatedAt: typeof result.updatedAt === 'string' ? result.updatedAt : null,\n sharedBy: Array.isArray(result.sharedBy) ? result.sharedBy : [],\n })\n } catch {\n // The control is additive \u2014 hide it rather than break the Emails tab.\n setState(EMPTY_STATE)\n }\n }, [personId])\n\n // Kept in a ref so a flip in progress does not itself retrigger the reload.\n const busyRef = React.useRef(false)\n React.useEffect(() => {\n busyRef.current = busy\n }, [busy])\n\n React.useEffect(() => {\n // A poll landing mid-flip would paint the pre-flip state for a moment and\n // make the switch appear to bounce back; `onToggle` re-reads once the write\n // settles, so skipping here loses nothing.\n if (busyRef.current) return\n void load()\n }, [load, reloadToken])\n\n const applyShared = React.useCallback(\n async (nextShared: boolean) => {\n const operation = async () => {\n const response = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(state.updatedAt),\n () =>\n apiCall<{ ok?: boolean }>(\n `/api/customers/people/${encodeURIComponent(personId)}/email-share`,\n {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ shared: nextShared }),\n },\n ),\n )\n if (!response.ok) {\n const err = response.result as { error?: string } | null\n throw new Error(\n err?.error ??\n t('customers.email.conversationShare.errors.updateFailed', 'Could not update sharing'),\n )\n }\n return true\n }\n\n return runMutation({\n operation,\n context: {\n formId: CONTEXT_ID,\n resourceKind: 'customers.email_conversation_share',\n resourceId: personId,\n retryLastMutation,\n },\n mutationPayload: { shared: nextShared },\n })\n },\n [personId, state.updatedAt, runMutation, retryLastMutation, t],\n )\n\n const onToggle = React.useCallback(\n async (nextShared: boolean) => {\n if (busy) return\n // Only the privacy-widening direction needs a confirmation; un-sharing is\n // the safe direction and should stay one click.\n if (nextShared) {\n const confirmed = await confirm({\n title: t('customers.email.conversationShare.confirm.title', 'Share this conversation?'),\n text: t(\n 'customers.email.conversationShare.confirm.text',\n 'Your colleagues will be able to read your email history with this person, including messages already received. You can stop sharing at any time.',\n ),\n confirmText: t('customers.email.conversationShare.confirm.cta', 'Share with team'),\n })\n if (!confirmed) return\n }\n\n setBusy(true)\n try {\n const result = await applyShared(nextShared)\n if (!result) return\n flash(\n nextShared\n ? t('customers.email.conversationShare.flash.shared', 'Conversation shared with your team')\n : t('customers.email.conversationShare.flash.unshared', 'Conversation is private again'),\n 'success',\n )\n await load()\n onChanged?.()\n } catch (err) {\n if (surfaceRecordConflict(err, t)) return\n flash(\n err instanceof Error\n ? err.message\n : t('customers.email.conversationShare.errors.updateFailed', 'Could not update sharing'),\n 'error',\n )\n } finally {\n setBusy(false)\n }\n },\n [busy, confirm, applyShared, load, onChanged, t],\n )\n\n const sharedByLabel = React.useMemo(() => {\n if (state.sharedBy.length === 0) return null\n const names = state.sharedBy\n .map((entry) => entry.userName)\n .filter((name): name is string => !!name)\n if (names.length === 0) {\n return t('customers.email.conversationShare.sharedByTeammate', 'Shared by a teammate')\n }\n return t('customers.email.conversationShare.sharedBy', 'Shared by {{names}}', {\n names: names.join(', '),\n })\n }, [state.sharedBy, t])\n\n if (!state.canShare && !sharedByLabel) return null\n\n return (\n <div className=\"mb-3 flex flex-wrap items-center justify-between gap-3 rounded-md border border-border bg-muted/40 px-3 py-2\">\n <div className=\"flex items-center gap-2\">\n <Users className=\"h-4 w-4 text-muted-foreground\" aria-hidden=\"true\" />\n <div className=\"flex flex-col\">\n {state.canShare ? (\n <span className=\"text-sm font-medium\">\n {t(\n 'customers.email.conversationShare.label',\n 'Share this conversation with my team',\n )}\n </span>\n ) : null}\n {sharedByLabel ? (\n <Badge variant=\"secondary\" className=\"w-fit\">\n {sharedByLabel}\n </Badge>\n ) : null}\n {state.canShare ? (\n <span className=\"text-xs text-muted-foreground\">\n {state.sharedByMe\n ? t(\n 'customers.email.conversationShare.hint.on',\n 'Colleagues can read your email history with this person.',\n )\n : t(\n 'customers.email.conversationShare.hint.off',\n 'Only you can read your email with this person.',\n )}\n </span>\n ) : null}\n </div>\n </div>\n {state.canShare ? (\n <Switch\n checked={state.sharedByMe}\n disabled={busy}\n onCheckedChange={(next) => {\n void onToggle(next)\n }}\n aria-label={t(\n 'customers.email.conversationShare.label',\n 'Share this conversation with my team',\n )}\n />\n ) : null}\n {ConfirmDialogElement}\n </div>\n )\n}\n\nexport default PersonEmailShareControl\n"],
5
+ "mappings": ";AAgOQ,cACA,YADA;AA9NR,YAAY,WAAW;AACvB,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,SAAS,mCAAmC;AACrD,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,iCAAiC;AAC1C,SAAS,aAAa;AACtB,SAAS,YAAY;AAiCrB,MAAM,aAAa;AAEnB,MAAM,cAA0B;AAAA,EAC9B,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU,CAAC;AACb;AASO,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACF,GAAiC;AAC/B,QAAM,IAAI,KAAK;AACf,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAqB,WAAW;AAChE,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,KAAK;AAC5C,QAAM,EAAE,SAAS,qBAAqB,IAAI,iBAAiB;AAE3D,QAAM,EAAE,aAAa,kBAAkB,IAAI,mBAKxC;AAAA,IACD,WAAW;AAAA,IACX,gBAAgB,EAAE,8BAA8B,4BAA4B;AAAA,EAC9E,CAAC;AAED,QAAM,OAAO,MAAM,YAAY,YAAY;AACzC,QAAI;AACF,YAAM,WAAW,MAAM;AAAA,QACrB,yBAAyB,mBAAmB,QAAQ,CAAC;AAAA,QACrD;AAAA,UACE,QA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yB,CAAC,CAAC,IAAI;AAC1C,QAAI,MAAM,WAAW,GAAG;AACtB,aAAO,EAAE,sDAAsD,sBAAsB;AAAA,IACvF;AACA,WAAO,EAAE,8CAA8C,uBAAuB;AAAA,MAC5E,OAAO,MAAM,KAAK,IAAI;AAAA,IACxB,CAAC;AAAA,EACH,GAAG,CAAC,MAAM,UAAU,CAAC,CAAC;AAEtB,MAAI,CAAC,MAAM,YAAY,CAAC,cAAe,QAAO;AAE9C,SACE,qBAAC,SAAI,WAAU,gHACb;AAAA,yBAAC,SAAI,WAAU,2BACb;AAAA,0BAAC,SAAM,WAAU,iCAAgC,eAAY,QAAO;AAAA,MACpE,qBAAC,SAAI,WAAU,iBACZ;AAAA,cAAM,WACL,oBAAC,UAAK,WAAU,uBACb;AAAA,UACC;AAAA,UACA;AAAA,QACF,GACF,IACE;AAAA,QACH,gBACC,oBAAC,SAAM,SAAQ,aAAY,WAAU,SAClC,yBACH,IACE;AAAA,QACH,MAAM,WACL,oBAAC,UAAK,WAAU,iCACb,gBAAM,aACH;AAAA,UACE;AAAA,UACA;AAAA,QACF,IACA;AAAA,UACE;AAAA,UACA;AAAA,QACF,GACN,IACE;AAAA,SACN;AAAA,OACF;AAAA,IACC,MAAM,WACL;AAAA,MAAC;AAAA;AAAA,QACC,SAAS,MAAM;AAAA,QACf,UAAU;AAAA,QACV,iBAAiB,CAAC,SAAS;AACzB,eAAK,SAAS,IAAI;AAAA,QACpB;AAAA,QACA,cAAY;AAAA,UACV;AAAA,UACA;AAAA,QACF;AAAA;AAAA,IACF,IACE;AAAA,IACH;AAAA,KACH;AAEJ;AAEA,IAAO,kCAAQ;",
6
+ "names": []
7
+ }
@@ -16,6 +16,7 @@ import { useT } from "@open-mercato/shared/lib/i18n/context";
16
16
  import {
17
17
  ComposeEmailDialog
18
18
  } from "./ComposeEmailDialog.js";
19
+ import { PersonEmailShareControl } from "./PersonEmailShareControl.js";
19
20
  const CONTEXT_ID = "customers-person-email-threads";
20
21
  const MAX_REFERENCES = 40;
21
22
  const BACKGROUND_POLL_MS = 2e4;
@@ -53,6 +54,7 @@ function readEventMessageId(event) {
53
54
  function PersonEmailThreadsTab({ personId, defaultRecipient }) {
54
55
  const t = useT();
55
56
  const [threads, setThreads] = React.useState([]);
57
+ const [threadsRevision, setThreadsRevision] = React.useState(0);
56
58
  const [optimistic, setOptimistic] = React.useState([]);
57
59
  const [channels, setChannels] = React.useState([]);
58
60
  const [loading, setLoading] = React.useState(true);
@@ -88,6 +90,7 @@ function PersonEmailThreadsTab({ personId, defaultRecipient }) {
88
90
  setError(err instanceof Error ? err.message : t("customers.email.threads.loadFailed", "Failed to load emails"));
89
91
  } finally {
90
92
  if (opts?.showLoading) setLoading(false);
93
+ setThreadsRevision((value) => value + 1);
91
94
  }
92
95
  },
93
96
  [personId, t]
@@ -146,6 +149,10 @@ function PersonEmailThreadsTab({ personId, defaultRecipient }) {
146
149
  direction: "outbound",
147
150
  fromName: null,
148
151
  fromEmail: channel?.externalIdentifier ?? null,
152
+ // The viewer just composed this one, so it renders as "You" before the
153
+ // server round-trip replaces it with the persisted message.
154
+ authoredByViewer: true,
155
+ authorName: null,
149
156
  to: values.to,
150
157
  cc: values.cc ?? [],
151
158
  subject: values.subject,
@@ -327,6 +334,16 @@ function PersonEmailThreadsTab({ personId, defaultRecipient }) {
327
334
  t("customers.email.compose.noChannel.cta", "Connect your mailbox")
328
335
  ] }) });
329
336
  return /* @__PURE__ */ jsxs(Fragment, { children: [
337
+ /* @__PURE__ */ jsx(
338
+ PersonEmailShareControl,
339
+ {
340
+ personId,
341
+ reloadToken: threadsRevision,
342
+ onChanged: () => {
343
+ void loadThreads();
344
+ }
345
+ }
346
+ ),
330
347
  /* @__PURE__ */ jsx(
331
348
  EmailThreadsPanel,
332
349
  {