@open-mercato/core 0.6.8-develop.7100.1.fbf66fca35 → 0.7.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 (967) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/helpers/integration/api.js +1 -13
  3. package/dist/helpers/integration/api.js.map +2 -2
  4. package/dist/helpers/integration/communicationChannelsFixtures.js +0 -19
  5. package/dist/helpers/integration/communicationChannelsFixtures.js.map +2 -2
  6. package/dist/modules/api_keys/api/keys/route.js +1 -1
  7. package/dist/modules/api_keys/api/keys/route.js.map +2 -2
  8. package/dist/modules/api_keys/backend/api-keys/page.js +1 -3
  9. package/dist/modules/api_keys/backend/api-keys/page.js.map +2 -2
  10. package/dist/modules/attachments/api/route.js +2 -2
  11. package/dist/modules/attachments/api/route.js.map +2 -2
  12. package/dist/modules/attachments/components/AttachmentLibrary.js +0 -2
  13. package/dist/modules/attachments/components/AttachmentLibrary.js.map +2 -2
  14. package/dist/modules/attachments/di.js +1 -11
  15. package/dist/modules/attachments/di.js.map +2 -2
  16. package/dist/modules/attachments/index.js.map +1 -1
  17. package/dist/modules/attachments/lib/scoped-upload-service.js +2 -15
  18. package/dist/modules/attachments/lib/scoped-upload-service.js.map +2 -2
  19. package/dist/modules/attachments/lib/upload-limits.js +2 -6
  20. package/dist/modules/attachments/lib/upload-limits.js.map +2 -2
  21. package/dist/modules/audit_logs/backend/audit-logs/page.js +0 -6
  22. package/dist/modules/audit_logs/backend/audit-logs/page.js.map +2 -2
  23. package/dist/modules/audit_logs/lib/display-helpers.js +11 -19
  24. package/dist/modules/audit_logs/lib/display-helpers.js.map +2 -2
  25. package/dist/modules/audit_logs/services/actionLogService.js +12 -57
  26. package/dist/modules/audit_logs/services/actionLogService.js.map +3 -3
  27. package/dist/modules/auth/acl.js +5 -30
  28. package/dist/modules/auth/acl.js.map +2 -2
  29. package/dist/modules/auth/api/feature-check.js +2 -8
  30. package/dist/modules/auth/api/feature-check.js.map +2 -2
  31. package/dist/modules/auth/api/login.js +20 -4
  32. package/dist/modules/auth/api/login.js.map +2 -2
  33. package/dist/modules/auth/api/roles/acl/route.js +33 -28
  34. package/dist/modules/auth/api/roles/acl/route.js.map +2 -2
  35. package/dist/modules/auth/api/routeError.js +11 -0
  36. package/dist/modules/auth/api/routeError.js.map +7 -0
  37. package/dist/modules/auth/api/session/refresh.js +1 -25
  38. package/dist/modules/auth/api/session/refresh.js.map +2 -2
  39. package/dist/modules/auth/api/users/acl/route.js +73 -102
  40. package/dist/modules/auth/api/users/acl/route.js.map +2 -2
  41. package/dist/modules/auth/api/users/route.js +5 -13
  42. package/dist/modules/auth/api/users/route.js.map +2 -2
  43. package/dist/modules/auth/backend/roles/[id]/edit/page.meta.js +1 -5
  44. package/dist/modules/auth/backend/roles/[id]/edit/page.meta.js.map +2 -2
  45. package/dist/modules/auth/backend/roles/page.js +1 -3
  46. package/dist/modules/auth/backend/roles/page.js.map +2 -2
  47. package/dist/modules/auth/backend/users/[id]/edit/page.meta.js +1 -5
  48. package/dist/modules/auth/backend/users/[id]/edit/page.meta.js.map +2 -2
  49. package/dist/modules/auth/backend/users/page.js +1 -2
  50. package/dist/modules/auth/backend/users/page.js.map +2 -2
  51. package/dist/modules/auth/components/AclEditor.js +30 -39
  52. package/dist/modules/auth/components/AclEditor.js.map +2 -2
  53. package/dist/modules/auth/data/entities.js.map +2 -2
  54. package/dist/modules/auth/data/validators.js +1 -5
  55. package/dist/modules/auth/data/validators.js.map +2 -2
  56. package/dist/modules/auth/di.js +9 -35
  57. package/dist/modules/auth/di.js.map +2 -2
  58. package/dist/modules/auth/frontend/reset/[token]/page.js +0 -46
  59. package/dist/modules/auth/frontend/reset/[token]/page.js.map +2 -2
  60. package/dist/modules/auth/lib/grantChecks.js.map +2 -2
  61. package/dist/modules/auth/services/authService.js +2 -16
  62. package/dist/modules/auth/services/authService.js.map +2 -2
  63. package/dist/modules/auth/services/rbacService.js +24 -67
  64. package/dist/modules/auth/services/rbacService.js.map +3 -3
  65. package/dist/modules/business_rules/backend/logs/page.js +1 -3
  66. package/dist/modules/business_rules/backend/logs/page.js.map +2 -2
  67. package/dist/modules/business_rules/backend/rules/[id]/page.meta.js +6 -1
  68. package/dist/modules/business_rules/backend/rules/[id]/page.meta.js.map +2 -2
  69. package/dist/modules/business_rules/backend/rules/create/page.meta.js +5 -1
  70. package/dist/modules/business_rules/backend/rules/create/page.meta.js.map +2 -2
  71. package/dist/modules/business_rules/backend/rules/page.js +1 -3
  72. package/dist/modules/business_rules/backend/rules/page.js.map +2 -2
  73. package/dist/modules/business_rules/backend/sets/[id]/page.meta.js +6 -1
  74. package/dist/modules/business_rules/backend/sets/[id]/page.meta.js.map +2 -2
  75. package/dist/modules/business_rules/backend/sets/create/page.meta.js +5 -1
  76. package/dist/modules/business_rules/backend/sets/create/page.meta.js.map +2 -2
  77. package/dist/modules/business_rules/backend/sets/page.js +1 -3
  78. package/dist/modules/business_rules/backend/sets/page.js.map +2 -2
  79. package/dist/modules/business_rules/lib/expression-evaluator.js +9 -9
  80. package/dist/modules/business_rules/lib/expression-evaluator.js.map +2 -2
  81. package/dist/modules/business_rules/lib/rule-evaluator.js +9 -10
  82. package/dist/modules/business_rules/lib/rule-evaluator.js.map +2 -2
  83. package/dist/modules/catalog/ai-agents.js +1 -1
  84. package/dist/modules/catalog/ai-agents.js.map +1 -1
  85. package/dist/modules/catalog/ai-tools/merchandising-pack.js +2 -2
  86. package/dist/modules/catalog/ai-tools/merchandising-pack.js.map +2 -2
  87. package/dist/modules/catalog/backend/catalog/products/MerchandisingAssistantSheet.js +2 -5
  88. package/dist/modules/catalog/backend/catalog/products/MerchandisingAssistantSheet.js.map +2 -2
  89. package/dist/modules/catalog/components/categories/CategoriesDataTable.js +0 -2
  90. package/dist/modules/catalog/components/categories/CategoriesDataTable.js.map +2 -2
  91. package/dist/modules/catalog/components/products/ProductsDataTable.js +1 -7
  92. package/dist/modules/catalog/components/products/ProductsDataTable.js.map +2 -2
  93. package/dist/modules/catalog/widgets/injection/merchandising-assistant-trigger/widget.client.js +0 -2
  94. package/dist/modules/catalog/widgets/injection/merchandising-assistant-trigger/widget.client.js.map +2 -2
  95. package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js +1 -9
  96. package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js.map +2 -2
  97. package/dist/modules/communication_channels/api/post/test-seed/route.js +10 -95
  98. package/dist/modules/communication_channels/api/post/test-seed/route.js.map +2 -2
  99. package/dist/modules/communication_channels/backend/communication_channels/channels/page.js +0 -3
  100. package/dist/modules/communication_channels/backend/communication_channels/channels/page.js.map +2 -2
  101. package/dist/modules/communication_channels/commands/ingest-inbound-message.js +1 -14
  102. package/dist/modules/communication_channels/commands/ingest-inbound-message.js.map +2 -2
  103. package/dist/modules/communication_channels/di.js +1 -7
  104. package/dist/modules/communication_channels/di.js.map +2 -2
  105. package/dist/modules/communication_channels/lib/email-capabilities.js +1 -4
  106. package/dist/modules/communication_channels/lib/email-capabilities.js.map +2 -2
  107. package/dist/modules/communication_channels/lib/test-seed.js +2 -41
  108. package/dist/modules/communication_channels/lib/test-seed.js.map +2 -2
  109. package/dist/modules/configs/lib/system-status.js +0 -9
  110. package/dist/modules/configs/lib/system-status.js.map +2 -2
  111. package/dist/modules/currencies/backend/currencies/page.js +1 -3
  112. package/dist/modules/currencies/backend/currencies/page.js.map +2 -2
  113. package/dist/modules/currencies/backend/exchange-rates/page.js +1 -3
  114. package/dist/modules/currencies/backend/exchange-rates/page.js.map +2 -2
  115. package/dist/modules/customer_accounts/api/admin/domain-mappings.js +0 -9
  116. package/dist/modules/customer_accounts/api/admin/domain-mappings.js.map +2 -2
  117. package/dist/modules/customer_accounts/backend/customer_accounts/roles/page.js +1 -3
  118. package/dist/modules/customer_accounts/backend/customer_accounts/roles/page.js.map +2 -2
  119. package/dist/modules/customer_accounts/backend/customer_accounts/settings/CustomerAccountsSettingsPageClient.js +84 -0
  120. package/dist/modules/customer_accounts/backend/customer_accounts/settings/CustomerAccountsSettingsPageClient.js.map +7 -0
  121. package/dist/modules/customer_accounts/backend/customer_accounts/settings/page.js +7 -81
  122. package/dist/modules/customer_accounts/backend/customer_accounts/settings/page.js.map +2 -2
  123. package/dist/modules/customer_accounts/backend/customer_accounts/users/PortalUsersPageClient.js +523 -0
  124. package/dist/modules/customer_accounts/backend/customer_accounts/users/PortalUsersPageClient.js.map +7 -0
  125. package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/PortalUserDetailPageClient.js +731 -0
  126. package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/PortalUserDetailPageClient.js.map +7 -0
  127. package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/page.js +7 -727
  128. package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/page.js.map +2 -2
  129. package/dist/modules/customer_accounts/backend/customer_accounts/users/page.js +7 -521
  130. package/dist/modules/customer_accounts/backend/customer_accounts/users/page.js.map +2 -2
  131. package/dist/modules/customer_accounts/extension-points.js +1 -1
  132. package/dist/modules/customer_accounts/extension-points.js.map +2 -2
  133. package/dist/modules/customer_accounts/lib/portalUrl.js +69 -0
  134. package/dist/modules/customer_accounts/lib/portalUrl.js.map +7 -0
  135. package/dist/modules/customer_accounts/services/domainMappingService.js +0 -10
  136. package/dist/modules/customer_accounts/services/domainMappingService.js.map +2 -2
  137. package/dist/modules/customers/ai-tools/companies-pack.js +1 -4
  138. package/dist/modules/customers/ai-tools/companies-pack.js.map +2 -2
  139. package/dist/modules/customers/ai-tools/deal-analyzer-pack.js +2 -13
  140. package/dist/modules/customers/ai-tools/deal-analyzer-pack.js.map +2 -2
  141. package/dist/modules/customers/ai-tools/deals-pack.js +6 -52
  142. package/dist/modules/customers/ai-tools/deals-pack.js.map +2 -2
  143. package/dist/modules/customers/ai-tools/people-pack.js +1 -4
  144. package/dist/modules/customers/ai-tools/people-pack.js.map +2 -2
  145. package/dist/modules/customers/api/activities/route.js +6 -48
  146. package/dist/modules/customers/api/activities/route.js.map +2 -2
  147. package/dist/modules/customers/api/companies/[id]/people/route.js +64 -20
  148. package/dist/modules/customers/api/companies/[id]/people/route.js.map +2 -2
  149. package/dist/modules/customers/api/companies/[id]/route.js +94 -17
  150. package/dist/modules/customers/api/companies/[id]/route.js.map +2 -2
  151. package/dist/modules/customers/api/dashboard/widgets/customer-todos/route.js +5 -8
  152. package/dist/modules/customers/api/dashboard/widgets/customer-todos/route.js.map +2 -2
  153. package/dist/modules/customers/api/deals/[id]/companies/route.js +1 -1
  154. package/dist/modules/customers/api/deals/[id]/companies/route.js.map +2 -2
  155. package/dist/modules/customers/api/deals/[id]/people/route.js +1 -1
  156. package/dist/modules/customers/api/deals/[id]/people/route.js.map +2 -2
  157. package/dist/modules/customers/api/deals/[id]/route.js +25 -8
  158. package/dist/modules/customers/api/deals/[id]/route.js.map +2 -2
  159. package/dist/modules/customers/api/deals/[id]/stats/route.js +22 -3
  160. package/dist/modules/customers/api/deals/[id]/stats/route.js.map +2 -2
  161. package/dist/modules/customers/api/deals/aggregate/route.js +4 -11
  162. package/dist/modules/customers/api/deals/aggregate/route.js.map +2 -2
  163. package/dist/modules/customers/api/deals/map/route.js +1 -2
  164. package/dist/modules/customers/api/deals/map/route.js.map +2 -2
  165. package/dist/modules/customers/api/deals/route.js +1 -38
  166. package/dist/modules/customers/api/deals/route.js.map +2 -2
  167. package/dist/modules/customers/api/entity-roles-factory.js +4 -4
  168. package/dist/modules/customers/api/entity-roles-factory.js.map +2 -2
  169. package/dist/modules/customers/api/interactions/route.js +1 -3
  170. package/dist/modules/customers/api/interactions/route.js.map +2 -2
  171. package/dist/modules/customers/api/interactions/tasks/route.js +4 -27
  172. package/dist/modules/customers/api/interactions/tasks/route.js.map +2 -2
  173. package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js +3 -4
  174. package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js.map +2 -2
  175. package/dist/modules/customers/api/people/[id]/companies/context.js +1 -1
  176. package/dist/modules/customers/api/people/[id]/companies/context.js.map +2 -2
  177. package/dist/modules/customers/api/people/[id]/companies/enriched/route.js +1 -1
  178. package/dist/modules/customers/api/people/[id]/companies/enriched/route.js.map +2 -2
  179. package/dist/modules/customers/api/people/[id]/route.js +10 -11
  180. package/dist/modules/customers/api/people/[id]/route.js.map +2 -2
  181. package/dist/modules/customers/api/people/check-phone/route.js +9 -51
  182. package/dist/modules/customers/api/people/check-phone/route.js.map +2 -2
  183. package/dist/modules/customers/api/todos/route.js +5 -30
  184. package/dist/modules/customers/api/todos/route.js.map +2 -2
  185. package/dist/modules/customers/backend/customers/companies/page.js +4 -6
  186. package/dist/modules/customers/backend/customers/companies/page.js.map +2 -2
  187. package/dist/modules/customers/backend/customers/deals/[id]/page.js +1 -6
  188. package/dist/modules/customers/backend/customers/deals/[id]/page.js.map +2 -2
  189. package/dist/modules/customers/backend/customers/deals/page.js +4 -7
  190. package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
  191. package/dist/modules/customers/backend/customers/deals/pipeline/components/Lane.js +13 -4
  192. package/dist/modules/customers/backend/customers/deals/pipeline/components/Lane.js.map +2 -2
  193. package/dist/modules/customers/backend/customers/deals/pipeline/components/StatusFilterPopover.js +14 -85
  194. package/dist/modules/customers/backend/customers/deals/pipeline/components/StatusFilterPopover.js.map +2 -2
  195. package/dist/modules/customers/backend/customers/people/page.js +4 -6
  196. package/dist/modules/customers/backend/customers/people/page.js.map +2 -2
  197. package/dist/modules/customers/backend/hooks/useEmailDuplicateCheck.js +3 -9
  198. package/dist/modules/customers/backend/hooks/useEmailDuplicateCheck.js.map +2 -2
  199. package/dist/modules/customers/commands/deals.js +34 -21
  200. package/dist/modules/customers/commands/deals.js.map +2 -2
  201. package/dist/modules/customers/commands/interactions.js.map +1 -1
  202. package/dist/modules/customers/commands/personCompanyLinks.js +2 -131
  203. package/dist/modules/customers/commands/personCompanyLinks.js.map +2 -2
  204. package/dist/modules/customers/components/CustomerTodosTable.js +0 -1
  205. package/dist/modules/customers/components/CustomerTodosTable.js.map +2 -2
  206. package/dist/modules/customers/components/DealsKpiStrip.js +6 -7
  207. package/dist/modules/customers/components/DealsKpiStrip.js.map +2 -2
  208. package/dist/modules/customers/components/calendar/AgendaList.js +2 -2
  209. package/dist/modules/customers/components/calendar/AgendaList.js.map +2 -2
  210. package/dist/modules/customers/components/calendar/CalendarEventEditor.js +1 -1
  211. package/dist/modules/customers/components/calendar/CalendarEventEditor.js.map +2 -2
  212. package/dist/modules/customers/components/calendar/CalendarScreen.js +1 -1
  213. package/dist/modules/customers/components/calendar/CalendarScreen.js.map +2 -2
  214. package/dist/modules/customers/components/calendar/CalendarSettingsModal.js +1 -1
  215. package/dist/modules/customers/components/calendar/CalendarSettingsModal.js.map +2 -2
  216. package/dist/modules/customers/components/calendar/EventBlock.js +1 -1
  217. package/dist/modules/customers/components/calendar/EventBlock.js.map +2 -2
  218. package/dist/modules/customers/components/calendar/EventPeekPopover.js +2 -3
  219. package/dist/modules/customers/components/calendar/EventPeekPopover.js.map +2 -2
  220. package/dist/modules/customers/components/calendar/editor/PeopleField.js +5 -40
  221. package/dist/modules/customers/components/calendar/editor/PeopleField.js.map +2 -2
  222. package/dist/modules/customers/components/calendar/editor/hooks.js +1 -2
  223. package/dist/modules/customers/components/calendar/editor/hooks.js.map +2 -2
  224. package/dist/modules/customers/components/calendar/types.js +1 -1
  225. package/dist/modules/customers/components/calendar/types.js.map +2 -2
  226. package/dist/modules/customers/components/detail/AssignRoleDialog.js +33 -28
  227. package/dist/modules/customers/components/detail/AssignRoleDialog.js.map +2 -2
  228. package/dist/modules/customers/components/detail/CompanyKpiBar.js +4 -5
  229. package/dist/modules/customers/components/detail/CompanyKpiBar.js.map +2 -2
  230. package/dist/modules/customers/components/detail/CompanyPeopleSection.js +1 -3
  231. package/dist/modules/customers/components/detail/CompanyPeopleSection.js.map +2 -2
  232. package/dist/modules/customers/components/detail/DealForm.js +7 -19
  233. package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
  234. package/dist/modules/customers/components/detail/DealsSection.js +5 -6
  235. package/dist/modules/customers/components/detail/DealsSection.js.map +2 -2
  236. package/dist/modules/customers/components/detail/EntityTagsDialog.js +11 -35
  237. package/dist/modules/customers/components/detail/EntityTagsDialog.js.map +2 -2
  238. package/dist/modules/customers/components/detail/PersonCompaniesSection.js +1 -3
  239. package/dist/modules/customers/components/detail/PersonCompaniesSection.js.map +2 -2
  240. package/dist/modules/customers/components/detail/hooks/usePersonTasks.js +13 -19
  241. package/dist/modules/customers/components/detail/hooks/usePersonTasks.js.map +2 -2
  242. package/dist/modules/customers/components/detail/schedule/ParticipantsField.js +4 -4
  243. package/dist/modules/customers/components/detail/schedule/ParticipantsField.js.map +2 -2
  244. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js +3 -3
  245. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js.map +2 -2
  246. package/dist/modules/customers/components/detail/utils.js +5 -5
  247. package/dist/modules/customers/components/detail/utils.js.map +2 -2
  248. package/dist/modules/customers/data/entities.js.map +1 -1
  249. package/dist/modules/customers/data/validators.js +3 -32
  250. package/dist/modules/customers/data/validators.js.map +2 -2
  251. package/dist/modules/customers/events.js +0 -5
  252. package/dist/modules/customers/events.js.map +2 -2
  253. package/dist/modules/customers/lib/calendar/conflicts.js +2 -8
  254. package/dist/modules/customers/lib/calendar/conflicts.js.map +2 -2
  255. package/dist/modules/customers/lib/calendar/editorPayload.js +2 -3
  256. package/dist/modules/customers/lib/calendar/editorPayload.js.map +2 -2
  257. package/dist/modules/customers/lib/calendar/mapItem.js +3 -8
  258. package/dist/modules/customers/lib/calendar/mapItem.js.map +2 -2
  259. package/dist/modules/customers/lib/dealStatus.js +0 -30
  260. package/dist/modules/customers/lib/dealStatus.js.map +2 -2
  261. package/dist/modules/customers/lib/findPeopleByAddresses.js +0 -1
  262. package/dist/modules/customers/lib/findPeopleByAddresses.js.map +2 -2
  263. package/dist/modules/customers/lib/personCompanies.js +2 -100
  264. package/dist/modules/customers/lib/personCompanies.js.map +2 -2
  265. package/dist/modules/customers/lib/todoCompatibility.js +0 -12
  266. package/dist/modules/customers/lib/todoCompatibility.js.map +2 -2
  267. package/dist/modules/dashboards/lib/widgetScope.js +1 -6
  268. package/dist/modules/dashboards/lib/widgetScope.js.map +2 -2
  269. package/dist/modules/data_sync/backend/data-sync/page.js +1 -3
  270. package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
  271. package/dist/modules/data_sync/lib/sync-engine.js +6 -72
  272. package/dist/modules/data_sync/lib/sync-engine.js.map +2 -2
  273. package/dist/modules/data_sync/workers/sync-export.js +1 -5
  274. package/dist/modules/data_sync/workers/sync-export.js.map +2 -2
  275. package/dist/modules/data_sync/workers/sync-import.js +1 -5
  276. package/dist/modules/data_sync/workers/sync-import.js.map +2 -2
  277. package/dist/modules/devices/acl.js +1 -9
  278. package/dist/modules/devices/acl.js.map +2 -2
  279. package/dist/modules/devices/api/admin/devices/[id]/route.js +32 -5
  280. package/dist/modules/devices/api/admin/devices/[id]/route.js.map +2 -2
  281. package/dist/modules/devices/api/admin/devices/route.js +1 -14
  282. package/dist/modules/devices/api/admin/devices/route.js.map +2 -2
  283. package/dist/modules/devices/api/deviceList.js +12 -99
  284. package/dist/modules/devices/api/deviceList.js.map +2 -2
  285. package/dist/modules/devices/api/openapi.js +1 -3
  286. package/dist/modules/devices/api/openapi.js.map +2 -2
  287. package/dist/modules/devices/api/route.js +1 -9
  288. package/dist/modules/devices/api/route.js.map +2 -2
  289. package/dist/modules/devices/backend/devices/[id]/page.js +26 -10
  290. package/dist/modules/devices/backend/devices/[id]/page.js.map +2 -2
  291. package/dist/modules/devices/backend/devices/create/page.js +1 -17
  292. package/dist/modules/devices/backend/devices/create/page.js.map +2 -2
  293. package/dist/modules/devices/backend/devices/page.js +34 -28
  294. package/dist/modules/devices/backend/devices/page.js.map +2 -2
  295. package/dist/modules/devices/setup.js +2 -6
  296. package/dist/modules/devices/setup.js.map +2 -2
  297. package/dist/modules/directory/backend/directory/organizations/page.js +1 -2
  298. package/dist/modules/directory/backend/directory/organizations/page.js.map +2 -2
  299. package/dist/modules/directory/backend/directory/tenants/page.js +1 -2
  300. package/dist/modules/directory/backend/directory/tenants/page.js.map +2 -2
  301. package/dist/modules/directory/di.js +0 -9
  302. package/dist/modules/directory/di.js.map +2 -2
  303. package/dist/modules/directory/utils/organizationScope.js.map +2 -2
  304. package/dist/modules/entities/api/records.js +2 -4
  305. package/dist/modules/entities/api/records.js.map +2 -2
  306. package/dist/modules/entities/backend/entities/user/[entityId]/records/page.js +1 -3
  307. package/dist/modules/entities/backend/entities/user/[entityId]/records/page.js.map +2 -2
  308. package/dist/modules/eudr/api/plots/route.js +1 -5
  309. package/dist/modules/eudr/api/plots/route.js.map +2 -2
  310. package/dist/modules/eudr/backend/eudr/evidence-submissions/[id]/page.meta.js +3 -1
  311. package/dist/modules/eudr/backend/eudr/evidence-submissions/[id]/page.meta.js.map +2 -2
  312. package/dist/modules/eudr/backend/eudr/evidence-submissions/create/page.meta.js +1 -0
  313. package/dist/modules/eudr/backend/eudr/evidence-submissions/create/page.meta.js.map +2 -2
  314. package/dist/modules/eudr/backend/eudr/evidence-submissions/page.js +0 -3
  315. package/dist/modules/eudr/backend/eudr/evidence-submissions/page.js.map +2 -2
  316. package/dist/modules/eudr/backend/eudr/evidence-submissions/page.meta.js +4 -1
  317. package/dist/modules/eudr/backend/eudr/evidence-submissions/page.meta.js.map +2 -2
  318. package/dist/modules/eudr/backend/eudr/page.meta.js +2 -2
  319. package/dist/modules/eudr/backend/eudr/page.meta.js.map +2 -2
  320. package/dist/modules/eudr/backend/eudr/plots/[id]/page.js +8 -2
  321. package/dist/modules/eudr/backend/eudr/plots/[id]/page.js.map +2 -2
  322. package/dist/modules/eudr/backend/eudr/plots/[id]/page.meta.js +3 -1
  323. package/dist/modules/eudr/backend/eudr/plots/[id]/page.meta.js.map +2 -2
  324. package/dist/modules/eudr/backend/eudr/plots/create/page.js +8 -2
  325. package/dist/modules/eudr/backend/eudr/plots/create/page.js.map +2 -2
  326. package/dist/modules/eudr/backend/eudr/plots/create/page.meta.js +1 -0
  327. package/dist/modules/eudr/backend/eudr/plots/create/page.meta.js.map +2 -2
  328. package/dist/modules/eudr/backend/eudr/plots/page.js +0 -3
  329. package/dist/modules/eudr/backend/eudr/plots/page.js.map +2 -2
  330. package/dist/modules/eudr/backend/eudr/plots/page.meta.js +4 -1
  331. package/dist/modules/eudr/backend/eudr/plots/page.meta.js.map +2 -2
  332. package/dist/modules/eudr/backend/eudr/product-mappings/[id]/page.meta.js +3 -1
  333. package/dist/modules/eudr/backend/eudr/product-mappings/[id]/page.meta.js.map +2 -2
  334. package/dist/modules/eudr/backend/eudr/product-mappings/create/page.meta.js +1 -0
  335. package/dist/modules/eudr/backend/eudr/product-mappings/create/page.meta.js.map +2 -2
  336. package/dist/modules/eudr/backend/eudr/product-mappings/page.js +0 -3
  337. package/dist/modules/eudr/backend/eudr/product-mappings/page.js.map +2 -2
  338. package/dist/modules/eudr/backend/eudr/product-mappings/page.meta.js +4 -1
  339. package/dist/modules/eudr/backend/eudr/product-mappings/page.meta.js.map +2 -2
  340. package/dist/modules/eudr/backend/eudr/risk-assessments/[id]/page.meta.js +3 -1
  341. package/dist/modules/eudr/backend/eudr/risk-assessments/[id]/page.meta.js.map +2 -2
  342. package/dist/modules/eudr/backend/eudr/risk-assessments/create/page.meta.js +1 -0
  343. package/dist/modules/eudr/backend/eudr/risk-assessments/create/page.meta.js.map +2 -2
  344. package/dist/modules/eudr/backend/eudr/risk-assessments/page.js +0 -3
  345. package/dist/modules/eudr/backend/eudr/risk-assessments/page.js.map +2 -2
  346. package/dist/modules/eudr/backend/eudr/risk-assessments/page.meta.js +4 -1
  347. package/dist/modules/eudr/backend/eudr/risk-assessments/page.meta.js.map +2 -2
  348. package/dist/modules/eudr/backend/eudr/statements/[id]/page.js +2 -0
  349. package/dist/modules/eudr/backend/eudr/statements/[id]/page.js.map +2 -2
  350. package/dist/modules/eudr/backend/eudr/statements/[id]/page.meta.js +3 -1
  351. package/dist/modules/eudr/backend/eudr/statements/[id]/page.meta.js.map +2 -2
  352. package/dist/modules/eudr/backend/eudr/statements/create/page.meta.js +1 -0
  353. package/dist/modules/eudr/backend/eudr/statements/create/page.meta.js.map +2 -2
  354. package/dist/modules/eudr/backend/eudr/statements/page.js +30 -28
  355. package/dist/modules/eudr/backend/eudr/statements/page.js.map +2 -2
  356. package/dist/modules/eudr/backend/eudr/statements/page.meta.js +4 -1
  357. package/dist/modules/eudr/backend/eudr/statements/page.meta.js.map +2 -2
  358. package/dist/modules/eudr/commands/statements.js +8 -3
  359. package/dist/modules/eudr/commands/statements.js.map +2 -2
  360. package/dist/modules/eudr/components/crudErrorI18n.js +21 -1
  361. package/dist/modules/eudr/components/crudErrorI18n.js.map +2 -2
  362. package/dist/modules/eudr/components/formConfig.js +6 -2
  363. package/dist/modules/eudr/components/formConfig.js.map +2 -2
  364. package/dist/modules/eudr/data/validators.js +1 -4
  365. package/dist/modules/eudr/data/validators.js.map +2 -2
  366. package/dist/modules/eudr/lib/statement-lifecycle.js +9 -1
  367. package/dist/modules/eudr/lib/statement-lifecycle.js.map +2 -2
  368. package/dist/modules/feature_toggles/components/FeatureTogglesTable.js +0 -1
  369. package/dist/modules/feature_toggles/components/FeatureTogglesTable.js.map +2 -2
  370. package/dist/modules/feature_toggles/components/OverridesTable.js +0 -1
  371. package/dist/modules/feature_toggles/components/OverridesTable.js.map +2 -2
  372. package/dist/modules/feature_toggles/defaults.json +8 -0
  373. package/dist/modules/inbox_ops/backend/inbox-ops/log/page.js +0 -3
  374. package/dist/modules/inbox_ops/backend/inbox-ops/log/page.js.map +2 -2
  375. package/dist/modules/inbox_ops/backend/inbox-ops/page.js +0 -3
  376. package/dist/modules/inbox_ops/backend/inbox-ops/page.js.map +2 -2
  377. package/dist/modules/inbox_ops/lib/htmlToPlainText.js +12 -1
  378. package/dist/modules/inbox_ops/lib/htmlToPlainText.js.map +2 -2
  379. package/dist/modules/integrations/api/[id]/credentials/route.js +1 -6
  380. package/dist/modules/integrations/api/[id]/credentials/route.js.map +2 -2
  381. package/dist/modules/integrations/backend/integrations/[id]/page.js +29 -38
  382. package/dist/modules/integrations/backend/integrations/[id]/page.js.map +2 -2
  383. package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js +9 -36
  384. package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js.map +2 -2
  385. package/dist/modules/integrations/data/validators.js +3 -11
  386. package/dist/modules/integrations/data/validators.js.map +2 -2
  387. package/dist/modules/integrations/lib/credentials-masking.js +2 -6
  388. package/dist/modules/integrations/lib/credentials-masking.js.map +2 -2
  389. package/dist/modules/messages/api/[id]/route.js +1 -29
  390. package/dist/modules/messages/api/[id]/route.js.map +2 -2
  391. package/dist/modules/messages/api/openapi.js +2 -17
  392. package/dist/modules/messages/api/openapi.js.map +2 -2
  393. package/dist/modules/messages/api/route.js +2 -17
  394. package/dist/modules/messages/api/route.js.map +2 -2
  395. package/dist/modules/messages/components/MessagesInboxPageClient.js +14 -7
  396. package/dist/modules/messages/components/MessagesInboxPageClient.js.map +2 -2
  397. package/dist/modules/messages/components/inboxFilters.js +0 -15
  398. package/dist/modules/messages/components/inboxFilters.js.map +2 -2
  399. package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsConversation.js +1 -11
  400. package/dist/modules/messages/components/message-detail/hooks/useMessageDetailsConversation.js.map +2 -2
  401. package/dist/modules/messages/components/message-detail/panels/MessageHeader.js +1 -3
  402. package/dist/modules/messages/components/message-detail/panels/MessageHeader.js.map +2 -2
  403. package/dist/modules/messages/components/message-detail/panels/thread-panel.js +1 -2
  404. package/dist/modules/messages/components/message-detail/panels/thread-panel.js.map +2 -2
  405. package/dist/modules/messages/components/messageListLabels.js +2 -14
  406. package/dist/modules/messages/components/messageListLabels.js.map +2 -2
  407. package/dist/modules/messages/data/validators.js +4 -18
  408. package/dist/modules/messages/data/validators.js.map +2 -2
  409. package/dist/modules/payment_gateways/api/webhook/[provider]/route.js +6 -4
  410. package/dist/modules/payment_gateways/api/webhook/[provider]/route.js.map +2 -2
  411. package/dist/modules/payment_gateways/backend/payment-gateways/page.js +1 -3
  412. package/dist/modules/payment_gateways/backend/payment-gateways/page.js.map +2 -2
  413. package/dist/modules/payment_gateways/lib/webhook-processor.js +0 -7
  414. package/dist/modules/payment_gateways/lib/webhook-processor.js.map +2 -2
  415. package/dist/modules/planner/backend/planner/availability-rulesets/page.js +0 -3
  416. package/dist/modules/planner/backend/planner/availability-rulesets/page.js.map +2 -2
  417. package/dist/modules/push_notifications/backend/push_notifications/page.js +1 -3
  418. package/dist/modules/push_notifications/backend/push_notifications/page.js.map +2 -2
  419. package/dist/modules/push_notifications/backend/push_notifications/send/page.js +1 -1
  420. package/dist/modules/push_notifications/backend/push_notifications/send/page.js.map +2 -2
  421. package/dist/modules/query_index/lib/engine.js +51 -150
  422. package/dist/modules/query_index/lib/engine.js.map +2 -2
  423. package/dist/modules/query_index/lib/search-tokens.js +3 -79
  424. package/dist/modules/query_index/lib/search-tokens.js.map +2 -2
  425. package/dist/modules/resources/backend/resources/resource-types/page.js +1 -3
  426. package/dist/modules/resources/backend/resources/resource-types/page.js.map +2 -2
  427. package/dist/modules/resources/backend/resources/resources/page.js +1 -3
  428. package/dist/modules/resources/backend/resources/resources/page.js.map +2 -2
  429. package/dist/modules/sales/backend/sales/channels/offers/page.js +0 -3
  430. package/dist/modules/sales/backend/sales/channels/offers/page.js.map +2 -2
  431. package/dist/modules/sales/backend/sales/channels/page.js +0 -3
  432. package/dist/modules/sales/backend/sales/channels/page.js.map +2 -2
  433. package/dist/modules/sales/backend/sales/documents/[id]/page.js +8 -10
  434. package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
  435. package/dist/modules/sales/commands/documents.js +1 -79
  436. package/dist/modules/sales/commands/documents.js.map +2 -2
  437. package/dist/modules/sales/components/PriceWithCurrency.js +5 -7
  438. package/dist/modules/sales/components/PriceWithCurrency.js.map +2 -2
  439. package/dist/modules/sales/components/channels/SalesChannelOffersPanel.js +0 -3
  440. package/dist/modules/sales/components/channels/SalesChannelOffersPanel.js.map +2 -2
  441. package/dist/modules/sales/components/documents/AdjustmentsSection.js +6 -8
  442. package/dist/modules/sales/components/documents/AdjustmentsSection.js.map +2 -2
  443. package/dist/modules/sales/components/documents/ItemsSection.js +22 -51
  444. package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
  445. package/dist/modules/sales/components/documents/LineItemDialog.js +19 -84
  446. package/dist/modules/sales/components/documents/LineItemDialog.js.map +2 -2
  447. package/dist/modules/sales/components/documents/PaymentsSection.js +9 -23
  448. package/dist/modules/sales/components/documents/PaymentsSection.js.map +2 -2
  449. package/dist/modules/sales/components/documents/ReturnsSection.js +6 -8
  450. package/dist/modules/sales/components/documents/ReturnsSection.js.map +2 -2
  451. package/dist/modules/sales/components/documents/SalesDocumentsTable.js +14 -68
  452. package/dist/modules/sales/components/documents/SalesDocumentsTable.js.map +2 -2
  453. package/dist/modules/sales/components/documents/SalesOrderDraftLines.js +5 -6
  454. package/dist/modules/sales/components/documents/SalesOrderDraftLines.js.map +2 -2
  455. package/dist/modules/sales/components/documents/ShipmentDialog.js +4 -5
  456. package/dist/modules/sales/components/documents/ShipmentDialog.js.map +2 -2
  457. package/dist/modules/sales/components/documents/ShipmentsSection.js +6 -8
  458. package/dist/modules/sales/components/documents/ShipmentsSection.js.map +2 -2
  459. package/dist/modules/sales/components/documents/lineItemUtils.js +2 -2
  460. package/dist/modules/sales/components/documents/lineItemUtils.js.map +2 -2
  461. package/dist/modules/sales/data/entities.js +2 -8
  462. package/dist/modules/sales/data/entities.js.map +2 -2
  463. package/dist/modules/sales/extension-points.js +0 -1
  464. package/dist/modules/sales/extension-points.js.map +2 -2
  465. package/dist/modules/sales/setup.js +0 -2
  466. package/dist/modules/sales/setup.js.map +2 -2
  467. package/dist/modules/sales/widgets/injection/document-history/widget.client.js +44 -2
  468. package/dist/modules/sales/widgets/injection/document-history/widget.client.js.map +2 -2
  469. package/dist/modules/sales/widgets/injection/payment-gateway-status-column/widget.js +2 -10
  470. package/dist/modules/sales/widgets/injection/payment-gateway-status-column/widget.js.map +2 -2
  471. package/dist/modules/sales/widgets/injection-table.js +7 -4
  472. package/dist/modules/sales/widgets/injection-table.js.map +2 -2
  473. package/dist/modules/staff/backend/staff/leave-requests/page.js +0 -3
  474. package/dist/modules/staff/backend/staff/leave-requests/page.js.map +2 -2
  475. package/dist/modules/staff/backend/staff/my-leave-requests/page.js +0 -3
  476. package/dist/modules/staff/backend/staff/my-leave-requests/page.js.map +2 -2
  477. package/dist/modules/staff/backend/staff/team-members/page.js +0 -3
  478. package/dist/modules/staff/backend/staff/team-members/page.js.map +2 -2
  479. package/dist/modules/staff/backend/staff/team-roles/page.js +0 -3
  480. package/dist/modules/staff/backend/staff/team-roles/page.js.map +2 -2
  481. package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js +0 -3
  482. package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js.map +2 -2
  483. package/dist/modules/staff/backend/staff/teams/page.js +0 -3
  484. package/dist/modules/staff/backend/staff/teams/page.js.map +2 -2
  485. package/dist/modules/staff/backend/staff/timesheets/page.js +18 -29
  486. package/dist/modules/staff/backend/staff/timesheets/page.js.map +2 -2
  487. package/dist/modules/staff/backend/staff/timesheets/projects/page.js +0 -3
  488. package/dist/modules/staff/backend/staff/timesheets/projects/page.js.map +2 -2
  489. package/dist/modules/sync_excel/lib/adapters/customers.js +0 -1
  490. package/dist/modules/sync_excel/lib/adapters/customers.js.map +2 -2
  491. package/dist/modules/warranty_claims/api/assignees/route.js +3 -3
  492. package/dist/modules/warranty_claims/api/assignees/route.js.map +2 -2
  493. package/dist/modules/warranty_claims/api/portal/attachments/route.js +2 -2
  494. package/dist/modules/warranty_claims/api/portal/attachments/route.js.map +2 -2
  495. package/dist/modules/warranty_claims/api/portal/claims/route.js +9 -12
  496. package/dist/modules/warranty_claims/api/portal/claims/route.js.map +2 -2
  497. package/dist/modules/warranty_claims/backend/page.js +0 -3
  498. package/dist/modules/warranty_claims/backend/page.js.map +2 -2
  499. package/dist/modules/warranty_claims/backend/warranty_claims/registrations/page.js +0 -3
  500. package/dist/modules/warranty_claims/backend/warranty_claims/registrations/page.js.map +2 -2
  501. package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/page.js +0 -3
  502. package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/page.js.map +2 -2
  503. package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/page.js +0 -3
  504. package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/page.js.map +2 -2
  505. package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/page.js +0 -3
  506. package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/page.js.map +2 -2
  507. package/dist/modules/wms/api/warehouses/route.js +9 -13
  508. package/dist/modules/wms/api/warehouses/route.js.map +2 -2
  509. package/dist/modules/wms/api/zones/route.js +2 -15
  510. package/dist/modules/wms/api/zones/route.js.map +2 -2
  511. package/dist/modules/wms/commands/configuration.js +9 -121
  512. package/dist/modules/wms/commands/configuration.js.map +2 -2
  513. package/dist/modules/wms/commands/inventory-actions.js +0 -3
  514. package/dist/modules/wms/commands/inventory-actions.js.map +2 -2
  515. package/dist/modules/wms/commands/shared.js +1 -9
  516. package/dist/modules/wms/commands/shared.js.map +2 -2
  517. package/dist/modules/wms/components/backend/WmsConfigurationPage.js +111 -76
  518. package/dist/modules/wms/components/backend/WmsConfigurationPage.js.map +3 -3
  519. package/dist/modules/wms/components/backend/WmsInventoryConsolePage.js +0 -1
  520. package/dist/modules/wms/components/backend/WmsInventoryConsolePage.js.map +2 -2
  521. package/dist/modules/wms/components/backend/WmsLocationDetailPage.js +20 -16
  522. package/dist/modules/wms/components/backend/WmsLocationDetailPage.js.map +2 -2
  523. package/dist/modules/wms/components/backend/WmsLotDetailPage.js +10 -6
  524. package/dist/modules/wms/components/backend/WmsLotDetailPage.js.map +2 -2
  525. package/dist/modules/wms/components/backend/WmsLotsListPage.js +0 -1
  526. package/dist/modules/wms/components/backend/WmsLotsListPage.js.map +2 -2
  527. package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js +11 -7
  528. package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js.map +2 -2
  529. package/dist/modules/wms/components/backend/WmsSkuDetailPage.js +10 -6
  530. package/dist/modules/wms/components/backend/WmsSkuDetailPage.js.map +2 -2
  531. package/dist/modules/wms/components/backend/inventoryMutationLoaders.js +20 -27
  532. package/dist/modules/wms/components/backend/inventoryMutationLoaders.js.map +2 -2
  533. package/dist/modules/workflows/backend/definitions/page.js +1 -3
  534. package/dist/modules/workflows/backend/definitions/page.js.map +2 -2
  535. package/dist/modules/workflows/backend/events/page.js +1 -3
  536. package/dist/modules/workflows/backend/events/page.js.map +2 -2
  537. package/dist/modules/workflows/backend/instances/page.js +1 -3
  538. package/dist/modules/workflows/backend/instances/page.js.map +2 -2
  539. package/dist/modules/workflows/backend/tasks/page.js +1 -3
  540. package/dist/modules/workflows/backend/tasks/page.js.map +2 -2
  541. package/dist/modules/workflows/lib/activity-executor.js +0 -4
  542. package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
  543. package/package.json +10 -9
  544. package/src/helpers/integration/api.ts +1 -33
  545. package/src/helpers/integration/communicationChannelsFixtures.ts +1 -69
  546. package/src/modules/api_keys/api/keys/route.ts +1 -3
  547. package/src/modules/api_keys/backend/api-keys/page.tsx +1 -4
  548. package/src/modules/attachments/AGENTS.md +0 -15
  549. package/src/modules/attachments/api/route.ts +2 -2
  550. package/src/modules/attachments/components/AttachmentLibrary.tsx +0 -3
  551. package/src/modules/attachments/di.ts +0 -16
  552. package/src/modules/attachments/i18n/de.json +0 -5
  553. package/src/modules/attachments/i18n/en.json +0 -5
  554. package/src/modules/attachments/i18n/es.json +0 -5
  555. package/src/modules/attachments/i18n/ko.json +0 -5
  556. package/src/modules/attachments/i18n/pl.json +0 -5
  557. package/src/modules/attachments/index.ts +0 -10
  558. package/src/modules/attachments/lib/scoped-upload-service.ts +0 -46
  559. package/src/modules/attachments/lib/upload-limits.ts +2 -6
  560. package/src/modules/audit_logs/backend/audit-logs/page.tsx +0 -8
  561. package/src/modules/audit_logs/lib/display-helpers.tsx +32 -42
  562. package/src/modules/audit_logs/services/actionLogService.ts +11 -74
  563. package/src/modules/auth/acl.ts +6 -30
  564. package/src/modules/auth/api/feature-check.ts +3 -10
  565. package/src/modules/auth/api/login.ts +24 -9
  566. package/src/modules/auth/api/roles/acl/route.ts +39 -42
  567. package/src/modules/auth/api/routeError.ts +30 -0
  568. package/src/modules/auth/api/session/refresh.ts +1 -32
  569. package/src/modules/auth/api/users/acl/route.ts +101 -185
  570. package/src/modules/auth/api/users/route.ts +5 -18
  571. package/src/modules/auth/backend/roles/[id]/edit/page.meta.ts +2 -5
  572. package/src/modules/auth/backend/roles/page.tsx +2 -4
  573. package/src/modules/auth/backend/users/[id]/edit/page.meta.ts +2 -5
  574. package/src/modules/auth/backend/users/page.tsx +2 -3
  575. package/src/modules/auth/components/AclEditor.tsx +33 -63
  576. package/src/modules/auth/data/entities.ts +1 -4
  577. package/src/modules/auth/data/validators.ts +0 -5
  578. package/src/modules/auth/di.ts +16 -46
  579. package/src/modules/auth/frontend/reset/[token]/page.tsx +0 -74
  580. package/src/modules/auth/i18n/de.json +0 -389
  581. package/src/modules/auth/i18n/en.json +0 -389
  582. package/src/modules/auth/i18n/es.json +0 -389
  583. package/src/modules/auth/i18n/ko.json +0 -389
  584. package/src/modules/auth/i18n/pl.json +2 -391
  585. package/src/modules/auth/lib/grantChecks.ts +0 -6
  586. package/src/modules/auth/services/authService.ts +2 -18
  587. package/src/modules/auth/services/rbacService.ts +24 -110
  588. package/src/modules/business_rules/backend/logs/page.tsx +1 -4
  589. package/src/modules/business_rules/backend/rules/[id]/page.meta.ts +5 -0
  590. package/src/modules/business_rules/backend/rules/create/page.meta.ts +5 -1
  591. package/src/modules/business_rules/backend/rules/page.tsx +1 -4
  592. package/src/modules/business_rules/backend/sets/[id]/page.meta.ts +5 -0
  593. package/src/modules/business_rules/backend/sets/create/page.meta.ts +5 -1
  594. package/src/modules/business_rules/backend/sets/page.tsx +1 -4
  595. package/src/modules/business_rules/lib/expression-evaluator.ts +9 -9
  596. package/src/modules/business_rules/lib/rule-evaluator.ts +9 -10
  597. package/src/modules/catalog/ai-agents.ts +1 -1
  598. package/src/modules/catalog/ai-tools/merchandising-pack.ts +2 -2
  599. package/src/modules/catalog/backend/catalog/products/MerchandisingAssistantSheet.tsx +5 -12
  600. package/src/modules/catalog/components/categories/CategoriesDataTable.tsx +0 -3
  601. package/src/modules/catalog/components/products/ProductsDataTable.tsx +0 -7
  602. package/src/modules/catalog/i18n/de.json +0 -1
  603. package/src/modules/catalog/i18n/en.json +0 -1
  604. package/src/modules/catalog/i18n/es.json +0 -1
  605. package/src/modules/catalog/i18n/ko.json +0 -1
  606. package/src/modules/catalog/i18n/pl.json +0 -1
  607. package/src/modules/catalog/widgets/injection/merchandising-assistant-trigger/widget.client.tsx +0 -4
  608. package/src/modules/communication_channels/api/post/channels/[id]/test-send/route.ts +1 -17
  609. package/src/modules/communication_channels/api/post/test-seed/route.ts +16 -155
  610. package/src/modules/communication_channels/backend/communication_channels/channels/page.tsx +0 -4
  611. package/src/modules/communication_channels/commands/ingest-inbound-message.ts +1 -38
  612. package/src/modules/communication_channels/di.ts +0 -7
  613. package/src/modules/communication_channels/lib/adapter.ts +0 -14
  614. package/src/modules/communication_channels/lib/email-capabilities.ts +0 -4
  615. package/src/modules/communication_channels/lib/test-seed.ts +4 -64
  616. package/src/modules/configs/i18n/de.json +0 -2
  617. package/src/modules/configs/i18n/en.json +0 -2
  618. package/src/modules/configs/i18n/es.json +0 -2
  619. package/src/modules/configs/i18n/ko.json +0 -2
  620. package/src/modules/configs/i18n/pl.json +0 -2
  621. package/src/modules/configs/lib/system-status.ts +0 -9
  622. package/src/modules/currencies/backend/currencies/page.tsx +1 -4
  623. package/src/modules/currencies/backend/exchange-rates/page.tsx +1 -4
  624. package/src/modules/customer_accounts/api/admin/domain-mappings.ts +0 -7
  625. package/src/modules/customer_accounts/backend/customer_accounts/roles/page.tsx +1 -4
  626. package/src/modules/customer_accounts/backend/customer_accounts/settings/CustomerAccountsSettingsPageClient.tsx +138 -0
  627. package/src/modules/customer_accounts/backend/customer_accounts/settings/page.tsx +8 -132
  628. package/src/modules/customer_accounts/backend/customer_accounts/users/PortalUsersPageClient.tsx +598 -0
  629. package/src/modules/customer_accounts/backend/customer_accounts/users/[id]/PortalUserDetailPageClient.tsx +838 -0
  630. package/src/modules/customer_accounts/backend/customer_accounts/users/[id]/page.tsx +6 -838
  631. package/src/modules/customer_accounts/backend/customer_accounts/users/page.tsx +6 -590
  632. package/src/modules/customer_accounts/extension-points.ts +1 -1
  633. package/src/modules/customer_accounts/lib/portalUrl.ts +112 -0
  634. package/src/modules/customer_accounts/services/domainMappingService.ts +0 -10
  635. package/src/modules/customers/ai-tools/companies-pack.ts +1 -4
  636. package/src/modules/customers/ai-tools/deal-analyzer-pack.ts +2 -17
  637. package/src/modules/customers/ai-tools/deals-pack.ts +1 -66
  638. package/src/modules/customers/ai-tools/people-pack.ts +1 -4
  639. package/src/modules/customers/api/activities/route.ts +0 -45
  640. package/src/modules/customers/api/companies/[id]/people/route.ts +73 -24
  641. package/src/modules/customers/api/companies/[id]/route.ts +107 -24
  642. package/src/modules/customers/api/dashboard/widgets/customer-todos/route.ts +8 -16
  643. package/src/modules/customers/api/deals/[id]/companies/route.ts +1 -4
  644. package/src/modules/customers/api/deals/[id]/people/route.ts +1 -4
  645. package/src/modules/customers/api/deals/[id]/route.ts +28 -17
  646. package/src/modules/customers/api/deals/[id]/stats/route.ts +25 -10
  647. package/src/modules/customers/api/deals/aggregate/route.ts +4 -14
  648. package/src/modules/customers/api/deals/map/route.ts +0 -1
  649. package/src/modules/customers/api/deals/route.ts +1 -50
  650. package/src/modules/customers/api/entity-roles-factory.ts +4 -8
  651. package/src/modules/customers/api/interactions/route.ts +2 -8
  652. package/src/modules/customers/api/interactions/tasks/route.ts +1 -24
  653. package/src/modules/customers/api/people/[id]/companies/[linkId]/route.ts +4 -12
  654. package/src/modules/customers/api/people/[id]/companies/context.ts +1 -4
  655. package/src/modules/customers/api/people/[id]/companies/enriched/route.ts +1 -4
  656. package/src/modules/customers/api/people/[id]/route.ts +11 -16
  657. package/src/modules/customers/api/people/check-phone/route.ts +10 -75
  658. package/src/modules/customers/api/todos/route.ts +2 -27
  659. package/src/modules/customers/backend/customers/companies/page.tsx +4 -7
  660. package/src/modules/customers/backend/customers/deals/[id]/page.tsx +2 -7
  661. package/src/modules/customers/backend/customers/deals/page.tsx +4 -10
  662. package/src/modules/customers/backend/customers/deals/pipeline/components/Lane.tsx +14 -5
  663. package/src/modules/customers/backend/customers/deals/pipeline/components/StatusFilterPopover.tsx +27 -109
  664. package/src/modules/customers/backend/customers/people/page.tsx +4 -7
  665. package/src/modules/customers/backend/hooks/useEmailDuplicateCheck.ts +4 -12
  666. package/src/modules/customers/commands/deals.ts +59 -34
  667. package/src/modules/customers/commands/interactions.ts +1 -1
  668. package/src/modules/customers/commands/personCompanyLinks.ts +8 -224
  669. package/src/modules/customers/components/CustomerTodosTable.tsx +0 -2
  670. package/src/modules/customers/components/DealsKpiStrip.tsx +7 -7
  671. package/src/modules/customers/components/calendar/AgendaList.tsx +3 -3
  672. package/src/modules/customers/components/calendar/CalendarEventEditor.tsx +1 -1
  673. package/src/modules/customers/components/calendar/CalendarScreen.tsx +1 -1
  674. package/src/modules/customers/components/calendar/CalendarSettingsModal.tsx +1 -1
  675. package/src/modules/customers/components/calendar/EventBlock.tsx +2 -2
  676. package/src/modules/customers/components/calendar/EventPeekPopover.tsx +2 -4
  677. package/src/modules/customers/components/calendar/editor/PeopleField.tsx +5 -61
  678. package/src/modules/customers/components/calendar/editor/hooks.ts +1 -7
  679. package/src/modules/customers/components/calendar/types.ts +2 -2
  680. package/src/modules/customers/components/detail/AssignRoleDialog.tsx +12 -7
  681. package/src/modules/customers/components/detail/CompanyKpiBar.tsx +4 -5
  682. package/src/modules/customers/components/detail/CompanyPeopleSection.tsx +1 -8
  683. package/src/modules/customers/components/detail/DealForm.tsx +2 -22
  684. package/src/modules/customers/components/detail/DealsSection.tsx +5 -11
  685. package/src/modules/customers/components/detail/EntityTagsDialog.tsx +12 -58
  686. package/src/modules/customers/components/detail/PersonCompaniesSection.tsx +1 -8
  687. package/src/modules/customers/components/detail/hooks/usePersonTasks.ts +14 -23
  688. package/src/modules/customers/components/detail/schedule/ParticipantsField.tsx +5 -5
  689. package/src/modules/customers/components/detail/schedule/useScheduleFormState.ts +5 -5
  690. package/src/modules/customers/components/detail/types.ts +1 -1
  691. package/src/modules/customers/components/detail/utils.ts +5 -15
  692. package/src/modules/customers/data/entities.ts +1 -1
  693. package/src/modules/customers/data/validators.ts +9 -50
  694. package/src/modules/customers/events.ts +0 -5
  695. package/src/modules/customers/i18n/de.json +1 -9
  696. package/src/modules/customers/i18n/en.json +1 -9
  697. package/src/modules/customers/i18n/es.json +1 -9
  698. package/src/modules/customers/i18n/ko.json +1 -9
  699. package/src/modules/customers/i18n/pl.json +1 -9
  700. package/src/modules/customers/lib/calendar/conflicts.ts +2 -10
  701. package/src/modules/customers/lib/calendar/editorPayload.ts +3 -4
  702. package/src/modules/customers/lib/calendar/mapItem.ts +3 -8
  703. package/src/modules/customers/lib/dealStatus.ts +0 -42
  704. package/src/modules/customers/lib/findPeopleByAddresses.ts +6 -8
  705. package/src/modules/customers/lib/personCompanies.ts +1 -136
  706. package/src/modules/customers/lib/todoCompatibility.ts +1 -19
  707. package/src/modules/dashboards/i18n/es.json +4 -4
  708. package/src/modules/dashboards/i18n/pl.json +7 -7
  709. package/src/modules/dashboards/lib/widgetScope.ts +0 -6
  710. package/src/modules/data_sync/AGENTS.md +1 -1
  711. package/src/modules/data_sync/backend/data-sync/page.tsx +1 -4
  712. package/src/modules/data_sync/lib/adapter.ts +0 -36
  713. package/src/modules/data_sync/lib/sync-engine.ts +5 -113
  714. package/src/modules/data_sync/workers/sync-export.ts +0 -4
  715. package/src/modules/data_sync/workers/sync-import.ts +0 -4
  716. package/src/modules/devices/AGENTS.md +1 -20
  717. package/src/modules/devices/acl.ts +1 -9
  718. package/src/modules/devices/api/admin/devices/[id]/route.ts +34 -5
  719. package/src/modules/devices/api/admin/devices/route.ts +1 -14
  720. package/src/modules/devices/api/deviceList.ts +11 -135
  721. package/src/modules/devices/api/openapi.ts +1 -9
  722. package/src/modules/devices/api/route.ts +1 -9
  723. package/src/modules/devices/backend/devices/[id]/page.tsx +32 -18
  724. package/src/modules/devices/backend/devices/create/page.tsx +1 -17
  725. package/src/modules/devices/backend/devices/page.tsx +45 -44
  726. package/src/modules/devices/i18n/de.json +2 -3
  727. package/src/modules/devices/i18n/en.json +2 -3
  728. package/src/modules/devices/i18n/es.json +2 -3
  729. package/src/modules/devices/i18n/ko.json +2 -3
  730. package/src/modules/devices/i18n/pl.json +2 -3
  731. package/src/modules/devices/setup.ts +2 -6
  732. package/src/modules/directory/backend/directory/organizations/page.tsx +1 -3
  733. package/src/modules/directory/backend/directory/tenants/page.tsx +1 -3
  734. package/src/modules/directory/di.ts +2 -14
  735. package/src/modules/directory/utils/organizationScope.ts +15 -4
  736. package/src/modules/entities/api/records.ts +0 -2
  737. package/src/modules/entities/backend/entities/user/[entityId]/records/page.tsx +1 -4
  738. package/src/modules/eudr/api/plots/route.ts +0 -4
  739. package/src/modules/eudr/backend/eudr/evidence-submissions/[id]/page.meta.ts +2 -0
  740. package/src/modules/eudr/backend/eudr/evidence-submissions/create/page.meta.ts +1 -0
  741. package/src/modules/eudr/backend/eudr/evidence-submissions/page.meta.ts +4 -1
  742. package/src/modules/eudr/backend/eudr/evidence-submissions/page.tsx +0 -4
  743. package/src/modules/eudr/backend/eudr/page.meta.ts +2 -2
  744. package/src/modules/eudr/backend/eudr/plots/[id]/page.meta.ts +2 -0
  745. package/src/modules/eudr/backend/eudr/plots/[id]/page.tsx +8 -2
  746. package/src/modules/eudr/backend/eudr/plots/create/page.meta.ts +1 -0
  747. package/src/modules/eudr/backend/eudr/plots/create/page.tsx +8 -2
  748. package/src/modules/eudr/backend/eudr/plots/page.meta.ts +4 -1
  749. package/src/modules/eudr/backend/eudr/plots/page.tsx +0 -4
  750. package/src/modules/eudr/backend/eudr/product-mappings/[id]/page.meta.ts +2 -0
  751. package/src/modules/eudr/backend/eudr/product-mappings/create/page.meta.ts +1 -0
  752. package/src/modules/eudr/backend/eudr/product-mappings/page.meta.ts +4 -1
  753. package/src/modules/eudr/backend/eudr/product-mappings/page.tsx +0 -4
  754. package/src/modules/eudr/backend/eudr/risk-assessments/[id]/page.meta.ts +2 -0
  755. package/src/modules/eudr/backend/eudr/risk-assessments/create/page.meta.ts +1 -0
  756. package/src/modules/eudr/backend/eudr/risk-assessments/page.meta.ts +4 -1
  757. package/src/modules/eudr/backend/eudr/risk-assessments/page.tsx +0 -4
  758. package/src/modules/eudr/backend/eudr/statements/[id]/page.meta.ts +2 -0
  759. package/src/modules/eudr/backend/eudr/statements/[id]/page.tsx +2 -0
  760. package/src/modules/eudr/backend/eudr/statements/create/page.meta.ts +1 -0
  761. package/src/modules/eudr/backend/eudr/statements/page.meta.ts +4 -1
  762. package/src/modules/eudr/backend/eudr/statements/page.tsx +32 -30
  763. package/src/modules/eudr/commands/statements.ts +7 -2
  764. package/src/modules/eudr/components/crudErrorI18n.ts +31 -0
  765. package/src/modules/eudr/components/formConfig.tsx +9 -1
  766. package/src/modules/eudr/data/validators.ts +1 -16
  767. package/src/modules/eudr/i18n/de.json +3 -2
  768. package/src/modules/eudr/i18n/en.json +3 -2
  769. package/src/modules/eudr/i18n/es.json +3 -2
  770. package/src/modules/eudr/i18n/ko.json +3 -2
  771. package/src/modules/eudr/i18n/pl.json +3 -2
  772. package/src/modules/eudr/lib/statement-lifecycle.ts +8 -0
  773. package/src/modules/feature_toggles/components/FeatureTogglesTable.tsx +1 -2
  774. package/src/modules/feature_toggles/components/OverridesTable.tsx +1 -2
  775. package/src/modules/feature_toggles/defaults.json +8 -0
  776. package/src/modules/inbox_ops/backend/inbox-ops/log/page.tsx +0 -4
  777. package/src/modules/inbox_ops/backend/inbox-ops/page.tsx +0 -4
  778. package/src/modules/inbox_ops/lib/htmlToPlainText.ts +17 -1
  779. package/src/modules/integrations/api/[id]/credentials/route.ts +4 -6
  780. package/src/modules/integrations/backend/integrations/[id]/page.tsx +31 -61
  781. package/src/modules/integrations/backend/integrations/bundle/[id]/page.tsx +9 -44
  782. package/src/modules/integrations/data/validators.ts +2 -12
  783. package/src/modules/integrations/i18n/de.json +0 -1
  784. package/src/modules/integrations/i18n/en.json +0 -1
  785. package/src/modules/integrations/i18n/es.json +0 -1
  786. package/src/modules/integrations/i18n/ko.json +0 -1
  787. package/src/modules/integrations/i18n/pl.json +0 -1
  788. package/src/modules/integrations/lib/credentials-masking.ts +6 -10
  789. package/src/modules/messages/api/[id]/route.ts +1 -55
  790. package/src/modules/messages/api/openapi.ts +0 -20
  791. package/src/modules/messages/api/route.ts +2 -31
  792. package/src/modules/messages/components/MessagesInboxPageClient.tsx +16 -9
  793. package/src/modules/messages/components/inboxFilters.ts +0 -36
  794. package/src/modules/messages/components/message-detail/hooks/useMessageDetailsConversation.ts +1 -14
  795. package/src/modules/messages/components/message-detail/panels/MessageHeader.tsx +1 -3
  796. package/src/modules/messages/components/message-detail/panels/thread-panel.tsx +1 -2
  797. package/src/modules/messages/components/message-detail/types.ts +0 -3
  798. package/src/modules/messages/components/messageListLabels.ts +3 -52
  799. package/src/modules/messages/data/validators.ts +4 -43
  800. package/src/modules/payment_gateways/api/webhook/[provider]/route.ts +6 -4
  801. package/src/modules/payment_gateways/backend/payment-gateways/page.tsx +1 -4
  802. package/src/modules/payment_gateways/lib/webhook-processor.ts +0 -11
  803. package/src/modules/planner/backend/planner/availability-rulesets/page.tsx +0 -4
  804. package/src/modules/push_notifications/backend/push_notifications/page.tsx +1 -4
  805. package/src/modules/push_notifications/backend/push_notifications/send/page.tsx +4 -4
  806. package/src/modules/query_index/lib/engine.ts +61 -249
  807. package/src/modules/query_index/lib/search-tokens.ts +3 -135
  808. package/src/modules/resources/backend/resources/resource-types/page.tsx +1 -4
  809. package/src/modules/resources/backend/resources/resources/page.tsx +1 -4
  810. package/src/modules/sales/backend/sales/channels/offers/page.tsx +0 -4
  811. package/src/modules/sales/backend/sales/channels/page.tsx +0 -4
  812. package/src/modules/sales/backend/sales/documents/[id]/page.tsx +8 -14
  813. package/src/modules/sales/commands/documents.ts +0 -93
  814. package/src/modules/sales/components/PriceWithCurrency.tsx +5 -17
  815. package/src/modules/sales/components/channels/SalesChannelOffersPanel.tsx +0 -4
  816. package/src/modules/sales/components/documents/AdjustmentsSection.tsx +5 -6
  817. package/src/modules/sales/components/documents/ItemsSection.tsx +18 -56
  818. package/src/modules/sales/components/documents/LineItemDialog.tsx +21 -138
  819. package/src/modules/sales/components/documents/PaymentsSection.tsx +9 -20
  820. package/src/modules/sales/components/documents/ReturnsSection.tsx +5 -6
  821. package/src/modules/sales/components/documents/SalesDocumentsTable.tsx +14 -106
  822. package/src/modules/sales/components/documents/SalesOrderDraftLines.tsx +5 -6
  823. package/src/modules/sales/components/documents/ShipmentDialog.tsx +4 -5
  824. package/src/modules/sales/components/documents/ShipmentsSection.tsx +5 -6
  825. package/src/modules/sales/components/documents/lineItemUtils.ts +2 -7
  826. package/src/modules/sales/data/entities.ts +0 -6
  827. package/src/modules/sales/extension-points.ts +0 -1
  828. package/src/modules/sales/i18n/de.json +37 -8
  829. package/src/modules/sales/i18n/en.json +37 -8
  830. package/src/modules/sales/i18n/es.json +37 -8
  831. package/src/modules/sales/i18n/ko.json +37 -8
  832. package/src/modules/sales/i18n/pl.json +37 -8
  833. package/src/modules/sales/migrations/.snapshot-open-mercato.json +0 -60
  834. package/src/modules/sales/setup.ts +0 -2
  835. package/src/modules/sales/widgets/injection/document-history/widget.client.tsx +42 -2
  836. package/src/modules/sales/widgets/injection/payment-gateway-status-column/widget.ts +1 -9
  837. package/src/modules/sales/widgets/injection-table.ts +7 -4
  838. package/src/modules/staff/backend/staff/leave-requests/page.tsx +0 -4
  839. package/src/modules/staff/backend/staff/my-leave-requests/page.tsx +0 -4
  840. package/src/modules/staff/backend/staff/team-members/page.tsx +0 -6
  841. package/src/modules/staff/backend/staff/team-roles/page.tsx +0 -4
  842. package/src/modules/staff/backend/staff/teams/[id]/edit/page.tsx +0 -4
  843. package/src/modules/staff/backend/staff/teams/page.tsx +0 -4
  844. package/src/modules/staff/backend/staff/timesheets/page.tsx +1 -12
  845. package/src/modules/staff/backend/staff/timesheets/projects/page.tsx +0 -4
  846. package/src/modules/sync_excel/lib/adapters/customers.ts +0 -5
  847. package/src/modules/warranty_claims/api/assignees/route.ts +3 -3
  848. package/src/modules/warranty_claims/api/portal/attachments/route.ts +2 -2
  849. package/src/modules/warranty_claims/api/portal/claims/route.ts +9 -12
  850. package/src/modules/warranty_claims/backend/page.tsx +0 -4
  851. package/src/modules/warranty_claims/backend/warranty_claims/registrations/page.tsx +0 -4
  852. package/src/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/page.tsx +0 -4
  853. package/src/modules/warranty_claims/backend/warranty_claims/vendor-policies/page.tsx +0 -4
  854. package/src/modules/warranty_claims/frontend/[orgSlug]/portal/claims/page.tsx +0 -4
  855. package/src/modules/wms/api/warehouses/route.ts +9 -13
  856. package/src/modules/wms/api/zones/route.ts +0 -16
  857. package/src/modules/wms/commands/configuration.ts +10 -159
  858. package/src/modules/wms/commands/inventory-actions.ts +0 -3
  859. package/src/modules/wms/commands/shared.ts +0 -17
  860. package/src/modules/wms/components/backend/WmsConfigurationPage.tsx +141 -95
  861. package/src/modules/wms/components/backend/WmsInventoryConsolePage.tsx +0 -2
  862. package/src/modules/wms/components/backend/WmsLocationDetailPage.tsx +30 -26
  863. package/src/modules/wms/components/backend/WmsLotDetailPage.tsx +21 -17
  864. package/src/modules/wms/components/backend/WmsLotsListPage.tsx +0 -2
  865. package/src/modules/wms/components/backend/WmsOperationalDashboardPage.tsx +17 -13
  866. package/src/modules/wms/components/backend/WmsSkuDetailPage.tsx +16 -12
  867. package/src/modules/wms/components/backend/inventoryMutationLoaders.ts +20 -36
  868. package/src/modules/wms/i18n/de.json +0 -2
  869. package/src/modules/wms/i18n/en.json +0 -2
  870. package/src/modules/wms/i18n/es.json +0 -2
  871. package/src/modules/wms/i18n/ko.json +0 -2
  872. package/src/modules/wms/i18n/pl.json +0 -2
  873. package/src/modules/workflows/backend/definitions/page.tsx +1 -4
  874. package/src/modules/workflows/backend/events/page.tsx +1 -4
  875. package/src/modules/workflows/backend/instances/page.tsx +1 -4
  876. package/src/modules/workflows/backend/tasks/page.tsx +1 -4
  877. package/src/modules/workflows/lib/activity-executor.ts +0 -9
  878. package/dist/modules/api_keys/di.js +0 -9
  879. package/dist/modules/api_keys/di.js.map +0 -7
  880. package/dist/modules/api_keys/services/principalService.js +0 -31
  881. package/dist/modules/api_keys/services/principalService.js.map +0 -7
  882. package/dist/modules/attachments/lib/attachment-service.js +0 -313
  883. package/dist/modules/attachments/lib/attachment-service.js.map +0 -7
  884. package/dist/modules/auth/api/reset/validate.js +0 -55
  885. package/dist/modules/auth/api/reset/validate.js.map +0 -7
  886. package/dist/modules/auth/commands/acl.js +0 -254
  887. package/dist/modules/auth/commands/acl.js.map +0 -7
  888. package/dist/modules/auth/lib/userIdFilter.js +0 -16
  889. package/dist/modules/auth/lib/userIdFilter.js.map +0 -7
  890. package/dist/modules/auth/services/principalService.js +0 -200
  891. package/dist/modules/auth/services/principalService.js.map +0 -7
  892. package/dist/modules/auth/services/roleOrganizationScope.js +0 -41
  893. package/dist/modules/auth/services/roleOrganizationScope.js.map +0 -7
  894. package/dist/modules/communication_channels/lib/outbound-recipient.js +0 -33
  895. package/dist/modules/communication_channels/lib/outbound-recipient.js.map +0 -7
  896. package/dist/modules/communication_channels/lib/resolve-channel-type.js +0 -51
  897. package/dist/modules/communication_channels/lib/resolve-channel-type.js.map +0 -7
  898. package/dist/modules/customers/backend/customers/deals/pipeline/components/toneClasses.js +0 -18
  899. package/dist/modules/customers/backend/customers/deals/pipeline/components/toneClasses.js.map +0 -7
  900. package/dist/modules/customers/lib/calendar/participantIdentity.js +0 -9
  901. package/dist/modules/customers/lib/calendar/participantIdentity.js.map +0 -7
  902. package/dist/modules/customers/lib/closureStage.js +0 -45
  903. package/dist/modules/customers/lib/closureStage.js.map +0 -7
  904. package/dist/modules/customers/lib/detailReadAccess.js +0 -12
  905. package/dist/modules/customers/lib/detailReadAccess.js.map +0 -7
  906. package/dist/modules/data_sync/lib/abandoned-run.js +0 -19
  907. package/dist/modules/data_sync/lib/abandoned-run.js.map +0 -7
  908. package/dist/modules/devices/api/deviceSerialization.js +0 -46
  909. package/dist/modules/devices/api/deviceSerialization.js.map +0 -7
  910. package/dist/modules/devices/backend/devices/useDeviceUserLabels.js +0 -34
  911. package/dist/modules/devices/backend/devices/useDeviceUserLabels.js.map +0 -7
  912. package/dist/modules/devices/backend/devices/userOptions.js +0 -52
  913. package/dist/modules/devices/backend/devices/userOptions.js.map +0 -7
  914. package/dist/modules/directory/services/organizationHierarchyService.js +0 -29
  915. package/dist/modules/directory/services/organizationHierarchyService.js.map +0 -7
  916. package/dist/modules/directory/services/organizationScopeService.js +0 -56
  917. package/dist/modules/directory/services/organizationScopeService.js.map +0 -7
  918. package/dist/modules/integrations/backend/integrations/credential-secret-fields.js +0 -55
  919. package/dist/modules/integrations/backend/integrations/credential-secret-fields.js.map +0 -7
  920. package/dist/modules/messages/lib/channel-sender-identity.js +0 -26
  921. package/dist/modules/messages/lib/channel-sender-identity.js.map +0 -7
  922. package/dist/modules/messages/lib/composeSourceChannelType.js +0 -41
  923. package/dist/modules/messages/lib/composeSourceChannelType.js.map +0 -7
  924. package/dist/modules/query_index/lib/search-entity-policy.js +0 -14
  925. package/dist/modules/query_index/lib/search-entity-policy.js.map +0 -7
  926. package/dist/modules/sales/components/documents/lineItemShipmentLock.js +0 -54
  927. package/dist/modules/sales/components/documents/lineItemShipmentLock.js.map +0 -7
  928. package/dist/modules/sales/lib/salesChannelsToggleSeed.js +0 -33
  929. package/dist/modules/sales/lib/salesChannelsToggleSeed.js.map +0 -7
  930. package/dist/modules/sales/migrations/Migration20260821120000_sales_notes_addresses_context_idx.js +0 -32
  931. package/dist/modules/sales/migrations/Migration20260821120000_sales_notes_addresses_context_idx.js.map +0 -7
  932. package/dist/modules/wms/api/warehouseSearch.js +0 -21
  933. package/dist/modules/wms/api/warehouseSearch.js.map +0 -7
  934. package/dist/modules/wms/components/backend/WarehouseEditDialog.js +0 -158
  935. package/dist/modules/wms/components/backend/WarehouseEditDialog.js.map +0 -7
  936. package/dist/modules/wms/components/backend/warehouseFormOptions.js +0 -66
  937. package/dist/modules/wms/components/backend/warehouseFormOptions.js.map +0 -7
  938. package/src/modules/api_keys/di.ts +0 -7
  939. package/src/modules/api_keys/services/principalService.ts +0 -33
  940. package/src/modules/attachments/lib/attachment-service.ts +0 -468
  941. package/src/modules/auth/api/reset/validate.ts +0 -57
  942. package/src/modules/auth/commands/acl.ts +0 -495
  943. package/src/modules/auth/lib/userIdFilter.ts +0 -31
  944. package/src/modules/auth/services/principalService.ts +0 -266
  945. package/src/modules/auth/services/roleOrganizationScope.ts +0 -70
  946. package/src/modules/communication_channels/lib/outbound-recipient.ts +0 -71
  947. package/src/modules/communication_channels/lib/resolve-channel-type.ts +0 -99
  948. package/src/modules/customers/backend/customers/deals/pipeline/components/toneClasses.ts +0 -21
  949. package/src/modules/customers/lib/calendar/participantIdentity.ts +0 -17
  950. package/src/modules/customers/lib/closureStage.ts +0 -76
  951. package/src/modules/customers/lib/detailReadAccess.ts +0 -35
  952. package/src/modules/data_sync/lib/abandoned-run.ts +0 -56
  953. package/src/modules/devices/api/deviceSerialization.ts +0 -50
  954. package/src/modules/devices/backend/devices/useDeviceUserLabels.ts +0 -45
  955. package/src/modules/devices/backend/devices/userOptions.ts +0 -99
  956. package/src/modules/directory/services/organizationHierarchyService.ts +0 -34
  957. package/src/modules/directory/services/organizationScopeService.ts +0 -85
  958. package/src/modules/integrations/backend/integrations/credential-secret-fields.ts +0 -84
  959. package/src/modules/messages/lib/channel-sender-identity.ts +0 -55
  960. package/src/modules/messages/lib/composeSourceChannelType.ts +0 -95
  961. package/src/modules/query_index/lib/search-entity-policy.ts +0 -46
  962. package/src/modules/sales/components/documents/lineItemShipmentLock.ts +0 -74
  963. package/src/modules/sales/lib/salesChannelsToggleSeed.ts +0 -42
  964. package/src/modules/sales/migrations/Migration20260821120000_sales_notes_addresses_context_idx.ts +0 -87
  965. package/src/modules/wms/api/warehouseSearch.ts +0 -23
  966. package/src/modules/wms/components/backend/WarehouseEditDialog.tsx +0 -216
  967. package/src/modules/wms/components/backend/warehouseFormOptions.ts +0 -72
@@ -1,254 +0,0 @@
1
- import { registerCommand } from "@open-mercato/shared/lib/commands";
2
- import { snapshotsEqual } from "@open-mercato/shared/lib/commands/helpers";
3
- import { withAtomicFlush } from "@open-mercato/shared/lib/commands/flush";
4
- import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
5
- import { createLogger } from "@open-mercato/shared/lib/logger";
6
- import { findOneWithDecryption } from "@open-mercato/shared/lib/encryption/find";
7
- import { Role, RoleAcl, User, UserAcl } from "@open-mercato/core/modules/auth/data/entities";
8
- const logger = createLogger("auth").child({ component: "acl-commands" });
9
- const EMPTY_ACL_SNAPSHOT = {
10
- isSuperAdmin: false,
11
- features: [],
12
- organizations: null
13
- };
14
- function compareIdentifiers(left, right) {
15
- if (left === right) return 0;
16
- return left < right ? -1 : 1;
17
- }
18
- function toSortedList(values) {
19
- if (!Array.isArray(values)) return [];
20
- return [...values].filter((value) => typeof value === "string").sort(compareIdentifiers);
21
- }
22
- function captureAclSnapshot(acl) {
23
- if (!acl) return { ...EMPTY_ACL_SNAPSHOT };
24
- return {
25
- isSuperAdmin: Boolean(acl.isSuperAdmin),
26
- features: toSortedList(acl.featuresJson),
27
- organizations: Array.isArray(acl.organizationsJson) ? toSortedList(acl.organizationsJson) : null
28
- };
29
- }
30
- function holdsGrants(snapshot) {
31
- return snapshot.isSuperAdmin || snapshot.features.length > 0;
32
- }
33
- function resolveEffect(before, after) {
34
- if (!holdsGrants(before) && holdsGrants(after)) return "granted";
35
- if (holdsGrants(before) && !holdsGrants(after)) return "revoked";
36
- return "changed";
37
- }
38
- function resolveEm(ctx) {
39
- return ctx.container.resolve("em");
40
- }
41
- function resolveOrganizationId(ctx, tenantId) {
42
- if ((ctx.auth?.tenantId ?? null) !== tenantId) return null;
43
- return ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null;
44
- }
45
- async function deleteCacheTags(ctx, tags) {
46
- let cache;
47
- try {
48
- cache = ctx.container.resolve("cache");
49
- } catch (err) {
50
- logger.debug("No cache registered for ACL tag invalidation", { err, tags });
51
- return;
52
- }
53
- if (!cache?.deleteByTags) return;
54
- await cache.deleteByTags(tags);
55
- }
56
- const AUTH_ROLE_ACL_UPDATE_COMMAND_ID = "auth.role-acl.update";
57
- const AUTH_USER_ACL_UPDATE_COMMAND_ID = "auth.user-acl.update";
58
- async function loadTargetSafely(config, input, ctx) {
59
- try {
60
- return await config.loadTarget(resolveEm(ctx).fork(), input, ctx);
61
- } catch (err) {
62
- logger.warn("Could not resolve the ACL target for the audit entry", {
63
- err,
64
- commandId: config.id,
65
- resourceId: config.resourceId(input),
66
- tenantId: input.tenantId
67
- });
68
- return null;
69
- }
70
- }
71
- function buildAuditContext(params) {
72
- const context = {};
73
- if (params.target) context.target = params.target;
74
- if (params.effect) context.effect = params.effect;
75
- if (params.sanitizedRequest) context.sanitizedRequest = params.sanitizedRequest;
76
- return Object.keys(context).length ? context : null;
77
- }
78
- function createAclUpdateCommand(config) {
79
- return {
80
- id: config.id,
81
- // See "Auth ACL Commands — Undo Policy" at top of file.
82
- isUndoable: false,
83
- async prepare(input, ctx) {
84
- const existing = await config.loadAcl(resolveEm(ctx).fork(), input);
85
- return { before: captureAclSnapshot(existing) };
86
- },
87
- async execute(input, ctx) {
88
- const em = resolveEm(ctx);
89
- const existing = await config.loadAcl(em, input);
90
- await config.persist({ em, input, existing });
91
- try {
92
- await config.invalidate({ ctx, input });
93
- } catch (err) {
94
- logger.error("ACL cache invalidation failed after a committed permission change", {
95
- err,
96
- commandId: config.id,
97
- resourceId: config.resourceId(input),
98
- tenantId: input.tenantId
99
- });
100
- }
101
- return {
102
- resourceId: config.resourceId(input),
103
- tenantId: input.tenantId,
104
- organizationId: resolveOrganizationId(ctx, input.tenantId)
105
- };
106
- },
107
- captureAfter: async (input, _result, ctx) => {
108
- const persisted = await config.loadAcl(resolveEm(ctx).fork(), input);
109
- if (persisted) return captureAclSnapshot(persisted);
110
- return config.snapshotWhenAbsent(input);
111
- },
112
- buildLog: async ({ input, result, ctx, snapshots }) => {
113
- const before = snapshots.before ?? null;
114
- const after = snapshots.after ?? null;
115
- const changed = !before || !after || !snapshotsEqual(before, after);
116
- const sanitizedRequest = config.sanitizedRequest?.(input) ?? null;
117
- if (!changed && !sanitizedRequest) return { skipLog: true };
118
- const { translate } = await resolveTranslations();
119
- const target = await loadTargetSafely(config, input, ctx);
120
- return {
121
- actionLabel: translate(config.labelKey, config.labelFallback),
122
- resourceKind: config.resourceKind,
123
- resourceId: result.resourceId,
124
- tenantId: result.tenantId,
125
- organizationId: result.organizationId,
126
- snapshotBefore: before,
127
- snapshotAfter: after,
128
- context: buildAuditContext({
129
- target,
130
- // A sanitized-only entry is written *because* nothing changed, so
131
- // labelling it would have the trail assert a permission change that
132
- // never happened.
133
- effect: changed && before && after ? resolveEffect(before, after) : null,
134
- sanitizedRequest
135
- })
136
- };
137
- }
138
- };
139
- }
140
- const updateRoleAclCommand = createAclUpdateCommand({
141
- id: AUTH_ROLE_ACL_UPDATE_COMMAND_ID,
142
- resourceKind: "auth.role_acl",
143
- labelKey: "auth.audit.roleAcl.update",
144
- labelFallback: "Change role permissions",
145
- resourceId: (input) => input.roleId,
146
- loadAcl: (em, input) => em.findOne(RoleAcl, { role: input.roleId, tenantId: input.tenantId }),
147
- persist: async ({ em, input, existing }) => {
148
- const acl = existing ?? em.create(RoleAcl, {
149
- role: em.getReference(Role, input.roleId),
150
- tenantId: input.tenantId,
151
- createdAt: /* @__PURE__ */ new Date(),
152
- isSuperAdmin: false
153
- });
154
- await withAtomicFlush(
155
- em,
156
- [
157
- () => {
158
- acl.organizationsJson = input.organizations;
159
- acl.isSuperAdmin = input.isSuperAdmin;
160
- acl.featuresJson = input.features;
161
- em.persist(acl);
162
- }
163
- ],
164
- { transaction: true, label: AUTH_ROLE_ACL_UPDATE_COMMAND_ID }
165
- );
166
- },
167
- invalidate: async ({ ctx, input }) => {
168
- const rbacService = ctx.container.resolve("rbacService");
169
- await rbacService.invalidateTenantCache(input.tenantId);
170
- await deleteCacheTags(ctx, [`rbac:tenant:${input.tenantId}`]);
171
- },
172
- snapshotWhenAbsent: () => null,
173
- // Looked up by id alone: the entry already names this role through
174
- // `resource_id`, and a tenant predicate would only blank the label when a
175
- // super admin edits a role from outside the tenant scope they are writing in.
176
- loadTarget: async (em, input) => {
177
- const role = await em.findOne(Role, { id: input.roleId });
178
- if (!role) return null;
179
- return { kind: "role", id: input.roleId, name: role.name ?? null };
180
- }
181
- });
182
- const updateUserAclCommand = createAclUpdateCommand({
183
- id: AUTH_USER_ACL_UPDATE_COMMAND_ID,
184
- resourceKind: "auth.user_acl",
185
- labelKey: "auth.audit.userAcl.update",
186
- labelFallback: "Change user permissions",
187
- resourceId: (input) => input.userId,
188
- loadAcl: (em, input) => em.findOne(UserAcl, { user: input.userId, tenantId: input.tenantId }),
189
- persist: async ({ em, input, existing }) => {
190
- if (input.clear) {
191
- if (!existing) return;
192
- const aclToRemove = existing;
193
- await withAtomicFlush(
194
- em,
195
- [
196
- () => {
197
- em.remove(aclToRemove);
198
- }
199
- ],
200
- { transaction: true, label: AUTH_USER_ACL_UPDATE_COMMAND_ID }
201
- );
202
- return;
203
- }
204
- const acl = existing ?? em.create(UserAcl, {
205
- user: em.getReference(User, input.userId),
206
- tenantId: input.tenantId,
207
- createdAt: /* @__PURE__ */ new Date(),
208
- isSuperAdmin: false
209
- });
210
- await withAtomicFlush(
211
- em,
212
- [
213
- () => {
214
- acl.isSuperAdmin = input.isSuperAdmin;
215
- acl.featuresJson = input.features;
216
- acl.organizationsJson = input.organizations;
217
- em.persist(acl);
218
- }
219
- ],
220
- { transaction: true, label: AUTH_USER_ACL_UPDATE_COMMAND_ID }
221
- );
222
- },
223
- invalidate: async ({ ctx, input }) => {
224
- const rbacService = ctx.container.resolve("rbacService");
225
- await rbacService.invalidateUserCache(input.userId);
226
- await deleteCacheTags(ctx, [`rbac:user:${input.userId}`]);
227
- },
228
- // Clearing removes the row, so an absent row is the real post-state here.
229
- snapshotWhenAbsent: (input) => input.clear ? { ...EMPTY_ACL_SNAPSHOT } : null,
230
- // `userId` arrives in the request body and `auth:user` carries encrypted
231
- // personal data, so the lookup is tenant-scoped: an id belonging to another
232
- // tenant must not be decrypted under this scope and stamped into this
233
- // tenant's trail. A global account (`users.tenant_id` is nullable) still
234
- // resolves, mirroring how the role route widens its own lookup.
235
- loadTarget: async (em, input, ctx) => {
236
- const user = await findOneWithDecryption(
237
- em,
238
- User,
239
- { id: input.userId, $or: [{ tenantId: input.tenantId }, { tenantId: null }] },
240
- {},
241
- { tenantId: input.tenantId, organizationId: ctx.auth?.orgId ?? null }
242
- );
243
- if (!user) return null;
244
- return { kind: "user", id: input.userId, email: user.email ?? null, name: user.name ?? null };
245
- },
246
- sanitizedRequest: (input) => input.requested ?? null
247
- });
248
- registerCommand(updateRoleAclCommand);
249
- registerCommand(updateUserAclCommand);
250
- export {
251
- AUTH_ROLE_ACL_UPDATE_COMMAND_ID,
252
- AUTH_USER_ACL_UPDATE_COMMAND_ID
253
- };
254
- //# sourceMappingURL=acl.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/modules/auth/commands/acl.ts"],
4
- "sourcesContent": ["// =============================================================================\n// Auth ACL Commands \u2014 Undo Policy\n// =============================================================================\n//\n// Neither command in this file defines `undo` or `redo`, so the command bus\n// never mints an undo token for them: `CommandBus.isUndoable()` requires a\n// handler-provided `undo`. The explicit `isUndoable: false` below is executable\n// documentation of that intent, not the mechanism \u2014 the guarantee comes from\n// the absence of the handlers, and the unit tests pin both.\n//\n// The policy is deliberate even though an ACL grant is trivially reversible.\n// The undo and redo endpoints are gated on `audit_logs.undo_self` /\n// `audit_logs.undo_tenant` (and their redo counterparts), not on\n// `auth.acl.manage`. `audit_logs.undo_self` is a default `employee` grant and\n// `audit_logs.undo_tenant` reaches every `admin` through `audit_logs.*`, so an\n// undoable ACL command would let a caller revert or replay someone else's\n// permission change without ever holding the feature that authorizes editing\n// permissions.\n//\n// Reversal stays available to the callers who are actually authorized for it:\n// re-submitting the ACL form, gated on `auth.acl.manage` and guarded by\n// `assertActorCanGrantAcl`. The audit log still captures the full before/after\n// via `buildLog`, so any such correction is itself fully traceable.\n// =============================================================================\nimport type { CommandHandler, CommandRuntimeContext } from '@open-mercato/shared/lib/commands'\nimport { registerCommand } from '@open-mercato/shared/lib/commands'\nimport { snapshotsEqual } from '@open-mercato/shared/lib/commands/helpers'\nimport { withAtomicFlush } from '@open-mercato/shared/lib/commands/flush'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport type { EntityManager, FilterQuery } from '@mikro-orm/postgresql'\nimport { Role, RoleAcl, User, UserAcl } from '@open-mercato/core/modules/auth/data/entities'\nimport type { RbacService } from '@open-mercato/core/modules/auth/services/rbacService'\n\nconst logger = createLogger('auth').child({ component: 'acl-commands' })\n\ntype TaggableCache = { deleteByTags?: (tags: string[]) => Promise<void> | void }\n\n/** Structural view of the fields both `RoleAcl` and `UserAcl` expose. */\ntype AclRecord = {\n isSuperAdmin: boolean\n featuresJson?: string[] | null\n organizationsJson?: string[] | null\n}\n\n/**\n * Audit snapshot of a single ACL row.\n *\n * `features` and `organizations` are grant *sets*, but `features_json` /\n * `organizations_json` preserve the client's insertion order. The command bus\n * derives `changes` from these snapshots with a deep equality check that is\n * order-sensitive for arrays, so an unsorted snapshot would report a spurious\n * `features` change every time an admin re-saves an unmodified form. Sorting\n * here makes the derived diff reflect real grant changes only.\n *\n * `organizations: null` (visible in every organization) is deliberately\n * distinct from `[]` (visible in none).\n */\ntype AclSnapshot = {\n isSuperAdmin: boolean\n features: string[]\n organizations: string[] | null\n}\n\nconst EMPTY_ACL_SNAPSHOT: AclSnapshot = {\n isSuperAdmin: false,\n features: [],\n organizations: null,\n}\n\n/**\n * Identity of the role or user an entry is about.\n *\n * `action_logs` keeps only `resource_id`, so an entry degrades to a bare UUID\n * the moment the role or account is deleted \u2014 exactly when the trail matters\n * most. This rides in `context` rather than in the snapshots because the\n * command bus derives `changes` from the two snapshots with a deep comparison:\n * a target renamed between two ACL edits would otherwise be reported as a\n * permission change, and the no-op guard below would stop recognising an\n * unchanged ACL.\n */\ntype AclTarget =\n | { kind: 'user'; id: string; email: string | null; name: string | null }\n | { kind: 'role'; id: string; name: string | null }\n\n/**\n * What the caller asked for when the route trimmed the request instead of\n * refusing it.\n *\n * `sanitizeTenantFeatures` drops restricted grants silently, so such a request\n * leaves `before` and `after` identical and is indistinguishable from a no-op \u2014\n * which `buildLog` skips. Recording the original request both keeps the attempt\n * visible and exempts the entry from that guard.\n *\n * Features are the only axis carried, because they are the only one the route\n * can trim: a super-admin request is honoured or refused outright, and\n * organizations are never sanitized. Recording either would put a value next to\n * the snapshots that always matches them, inviting a reader to diff the two and\n * conclude a grant was refused.\n */\ntype SanitizedAclRequest = {\n features: string[]\n}\n\n/** How the change reads at a glance, without diffing two grant lists. */\ntype AclChangeEffect = 'granted' | 'changed' | 'revoked'\n\n/**\n * Codepoint ordering rather than `localeCompare`: these snapshots are persisted\n * audit records, so the ordering must not shift with the runtime's default\n * locale. Feature and organization ids are opaque ASCII identifiers that are\n * never shown in this order to a user.\n *\n * The default comparator would coerce and compare the same way today, but\n * omitting one is banned repo-wide (`explicit-sort-comparators.test.ts`,\n * #3620): the ordering must be stated rather than inherited, so it cannot\n * silently change meaning if a call site ever drifts to non-strings. This is\n * the canonical-key form that audit prescribes.\n */\nfunction compareIdentifiers(left: string, right: string): number {\n if (left === right) return 0\n return left < right ? -1 : 1\n}\n\nfunction toSortedList(values: unknown): string[] {\n if (!Array.isArray(values)) return []\n return [...values].filter((value): value is string => typeof value === 'string').sort(compareIdentifiers)\n}\n\nfunction captureAclSnapshot(acl: AclRecord | null | undefined): AclSnapshot {\n if (!acl) return { ...EMPTY_ACL_SNAPSHOT }\n return {\n isSuperAdmin: Boolean(acl.isSuperAdmin),\n features: toSortedList(acl.featuresJson),\n organizations: Array.isArray(acl.organizationsJson) ? toSortedList(acl.organizationsJson) : null,\n }\n}\n\nfunction holdsGrants(snapshot: AclSnapshot): boolean {\n return snapshot.isSuperAdmin || snapshot.features.length > 0\n}\n\nfunction resolveEffect(before: AclSnapshot, after: AclSnapshot): AclChangeEffect {\n if (!holdsGrants(before) && holdsGrants(after)) return 'granted'\n if (holdsGrants(before) && !holdsGrants(after)) return 'revoked'\n return 'changed'\n}\n\nfunction resolveEm(ctx: CommandRuntimeContext): EntityManager {\n return ctx.container.resolve('em') as EntityManager\n}\n\n/**\n * The log row's organization must belong to the same tenant as the row itself.\n *\n * A super admin may edit a role in a tenant other than their own, and\n * `ActionLogService.buildListQuery` filters with strict equality\n * (`organization_id = ?`, applied only when the reader supplies one). Stamping\n * the actor's organization onto a row scoped to a different tenant produces a\n * (tenant B, organization from tenant A) pair that no reader can ever match, so\n * the cross-tenant permission change \u2014 exactly the record worth keeping \u2014\n * becomes invisible. `null` is the honest value there: it still reaches\n * tenant-scoped readers whose organization filter is unset.\n */\nfunction resolveOrganizationId(ctx: CommandRuntimeContext, tenantId: string): string | null {\n if ((ctx.auth?.tenantId ?? null) !== tenantId) return null\n return ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null\n}\n\n/**\n * A runtime with no cache registered (CLI, workers, tests) is a configuration,\n * not a failure, so resolution is guarded here. An adapter that *is* wired and\n * then throws is a failure, and it propagates to the single error-level guard\n * in `execute` \u2014 the same one that covers the `rbacService` half of this\n * invalidation. Reporting one half at `debug` and the other at `error` would\n * hide a nav cache still serving revoked grants.\n */\nasync function deleteCacheTags(ctx: CommandRuntimeContext, tags: string[]): Promise<void> {\n let cache: TaggableCache | undefined\n try {\n cache = ctx.container.resolve('cache') as TaggableCache | undefined\n } catch (err) {\n logger.debug('No cache registered for ACL tag invalidation', { err, tags })\n return\n }\n if (!cache?.deleteByTags) return\n await cache.deleteByTags(tags)\n}\n\ntype AclCommandValues = {\n isSuperAdmin: boolean\n features: string[]\n organizations: string[] | null\n}\n\ntype AclCommandInput = AclCommandValues & { tenantId: string }\n\nexport type RoleAclUpdateInput = AclCommandInput & {\n roleId: string\n}\n\nexport type UserAclUpdateInput = AclCommandInput & {\n userId: string\n /** Mirrors the route's `!hasCustomAcl`: drop the override row instead of upserting it. */\n clear: boolean\n /** Set by the route only when it wrote less than the caller asked for. */\n requested?: SanitizedAclRequest | null\n}\n\nexport type AclUpdateResult = {\n resourceId: string\n tenantId: string\n organizationId: string | null\n}\n\nexport const AUTH_ROLE_ACL_UPDATE_COMMAND_ID = 'auth.role-acl.update'\nexport const AUTH_USER_ACL_UPDATE_COMMAND_ID = 'auth.user-acl.update'\n\ntype AclCommandConfig<TInput extends AclCommandInput> = {\n id: string\n resourceKind: string\n labelKey: string\n labelFallback: string\n resourceId: (input: TInput) => string\n loadAcl: (em: EntityManager, input: TInput) => Promise<AclRecord | null>\n persist: (params: { em: EntityManager; input: TInput; existing: AclRecord | null }) => Promise<void>\n invalidate: (params: { ctx: CommandRuntimeContext; input: TInput }) => Promise<void>\n /**\n * Post-state when the row is absent after the write. Only the user command's\n * clear path legitimately removes the row; anywhere else a missing row means\n * the re-read failed, which must be logged as \"unknown\" rather than guessed.\n */\n snapshotWhenAbsent: (input: TInput) => AclSnapshot | null\n /** Human-readable identity of the target; `null` when it cannot be resolved. */\n loadTarget: (em: EntityManager, input: TInput, ctx: CommandRuntimeContext) => Promise<AclTarget | null>\n /** Only the user route sanitizes, so only it can report a trimmed request. */\n sanitizedRequest?: (input: TInput) => SanitizedAclRequest | null\n}\n\n/**\n * Enrichment must never cost the entry.\n *\n * The bus persists the log after `execute` has already committed the permission\n * change, so a throw from the target lookup would leave the write recorded\n * nowhere \u2014 the same \"committed but unaudited\" hole the cache-invalidation\n * guard in `execute` closes. A missing label is a far smaller loss.\n */\nasync function loadTargetSafely<TInput extends AclCommandInput>(\n config: AclCommandConfig<TInput>,\n input: TInput,\n ctx: CommandRuntimeContext,\n): Promise<AclTarget | null> {\n try {\n return await config.loadTarget(resolveEm(ctx).fork(), input, ctx)\n } catch (err) {\n logger.warn('Could not resolve the ACL target for the audit entry', {\n err,\n commandId: config.id,\n resourceId: config.resourceId(input),\n tenantId: input.tenantId,\n })\n return null\n }\n}\n\nfunction buildAuditContext(params: {\n target: AclTarget | null\n effect: AclChangeEffect | null\n sanitizedRequest: SanitizedAclRequest | null\n}): Record<string, unknown> | null {\n const context: Record<string, unknown> = {}\n if (params.target) context.target = params.target\n if (params.effect) context.effect = params.effect\n if (params.sanitizedRequest) context.sanitizedRequest = params.sanitizedRequest\n return Object.keys(context).length ? context : null\n}\n\n/**\n * Both ACL commands differ only in entity, lookup key, cache invalidation and\n * labels \u2014 `prepare`, `captureAfter` and `buildLog` are otherwise identical.\n * Sharing them here keeps the two audit-entry shapes from drifting apart.\n */\nfunction createAclUpdateCommand<TInput extends AclCommandInput>(\n config: AclCommandConfig<TInput>,\n): CommandHandler<TInput, AclUpdateResult> {\n return {\n id: config.id,\n // See \"Auth ACL Commands \u2014 Undo Policy\" at top of file.\n isUndoable: false,\n async prepare(input, ctx) {\n const existing = await config.loadAcl(resolveEm(ctx).fork(), input)\n return { before: captureAclSnapshot(existing) }\n },\n async execute(input, ctx) {\n const em = resolveEm(ctx)\n const existing = await config.loadAcl(em, input)\n await config.persist({ em, input, existing })\n // Cache invalidation runs only after the write commits, never inside the\n // atomic flush \u2014 and must never propagate. The command bus persists the\n // action log *after* `execute` returns, so a throw here would commit the\n // permission change and then suppress its audit entry: precisely the\n // \"committed but unaudited\" hole these commands exist to close, and it\n // would open exactly when infrastructure is already degraded.\n // `RbacService.deleteCacheByTags` awaits the cache adapter without a\n // guard of its own, so an outage does reach us here.\n //\n // The resulting staleness (a revoked grant served from cache until its\n // TTL) is not introduced by swallowing \u2014 it happens either way once the\n // adapter is down. Logging at error level keeps it alarmable instead of\n // trading a recorded change for an HTTP 500 that misreports a write which\n // did commit.\n try {\n await config.invalidate({ ctx, input })\n } catch (err) {\n logger.error('ACL cache invalidation failed after a committed permission change', {\n err,\n commandId: config.id,\n resourceId: config.resourceId(input),\n tenantId: input.tenantId,\n })\n }\n return {\n resourceId: config.resourceId(input),\n tenantId: input.tenantId,\n organizationId: resolveOrganizationId(ctx, input.tenantId),\n }\n },\n captureAfter: async (input, _result, ctx) => {\n // Read the committed row back rather than echoing the request, so a grant\n // the route sanitized away can never be logged as if it had been applied.\n const persisted = await config.loadAcl(resolveEm(ctx).fork(), input)\n if (persisted) return captureAclSnapshot(persisted)\n return config.snapshotWhenAbsent(input)\n },\n buildLog: async ({ input, result, ctx, snapshots }) => {\n const before = (snapshots.before as AclSnapshot | undefined) ?? null\n const after = (snapshots.after as AclSnapshot | undefined) ?? null\n // An unknown post-state (`after: null`, the failed re-read) counts as a\n // change: it is the one case where the entry is the only evidence left.\n // Both snapshots leave `captureAclSnapshot` with their grant lists sorted,\n // so the shared order-sensitive comparison is a set comparison here.\n const changed = !before || !after || !snapshotsEqual(before, after)\n const sanitizedRequest = config.sanitizedRequest?.(input) ?? null\n // The admin user-edit page PUTs the ACL on every save, even when only the\n // name or the roles changed, and most accounts carry no per-user override\n // at all \u2014 so recording an unchanged ACL faithfully buries the real\n // permission changes under identical empty entries. A request the route\n // trimmed rather than refused also arrives with `before == after`; that\n // one is an escalation attempt and must survive this guard.\n if (!changed && !sanitizedRequest) return { skipLog: true }\n const { translate } = await resolveTranslations()\n const target = await loadTargetSafely(config, input, ctx)\n return {\n actionLabel: translate(config.labelKey, config.labelFallback),\n resourceKind: config.resourceKind,\n resourceId: result.resourceId,\n tenantId: result.tenantId,\n organizationId: result.organizationId,\n snapshotBefore: before,\n snapshotAfter: after,\n context: buildAuditContext({\n target,\n // A sanitized-only entry is written *because* nothing changed, so\n // labelling it would have the trail assert a permission change that\n // never happened.\n effect: changed && before && after ? resolveEffect(before, after) : null,\n sanitizedRequest,\n }),\n }\n },\n }\n}\n\nconst updateRoleAclCommand = createAclUpdateCommand<RoleAclUpdateInput>({\n id: AUTH_ROLE_ACL_UPDATE_COMMAND_ID,\n resourceKind: 'auth.role_acl',\n labelKey: 'auth.audit.roleAcl.update',\n labelFallback: 'Change role permissions',\n resourceId: (input) => input.roleId,\n loadAcl: (em, input) =>\n em.findOne(RoleAcl, { role: input.roleId as unknown as Role, tenantId: input.tenantId }),\n persist: async ({ em, input, existing }) => {\n const acl =\n (existing as RoleAcl | null) ??\n em.create(RoleAcl, {\n role: em.getReference(Role, input.roleId),\n tenantId: input.tenantId,\n createdAt: new Date(),\n isSuperAdmin: false,\n })\n await withAtomicFlush(\n em,\n [\n () => {\n acl.organizationsJson = input.organizations\n acl.isSuperAdmin = input.isSuperAdmin\n acl.featuresJson = input.features\n em.persist(acl)\n },\n ],\n { transaction: true, label: AUTH_ROLE_ACL_UPDATE_COMMAND_ID },\n )\n },\n invalidate: async ({ ctx, input }) => {\n // Every user in the tenant inherits this role's grants, so the whole tenant\n // scope is invalidated.\n const rbacService = ctx.container.resolve('rbacService') as RbacService\n await rbacService.invalidateTenantCache(input.tenantId)\n // Sidebar nav caches depend on RBAC; invalidate tenant scope nav caches\n await deleteCacheTags(ctx, [`rbac:tenant:${input.tenantId}`])\n },\n snapshotWhenAbsent: () => null,\n // Looked up by id alone: the entry already names this role through\n // `resource_id`, and a tenant predicate would only blank the label when a\n // super admin edits a role from outside the tenant scope they are writing in.\n loadTarget: async (em, input) => {\n const role = await em.findOne(Role, { id: input.roleId } as FilterQuery<Role>)\n if (!role) return null\n return { kind: 'role', id: input.roleId, name: role.name ?? null }\n },\n})\n\nconst updateUserAclCommand = createAclUpdateCommand<UserAclUpdateInput>({\n id: AUTH_USER_ACL_UPDATE_COMMAND_ID,\n resourceKind: 'auth.user_acl',\n labelKey: 'auth.audit.userAcl.update',\n labelFallback: 'Change user permissions',\n resourceId: (input) => input.userId,\n loadAcl: (em, input) =>\n em.findOne(UserAcl, { user: input.userId as unknown as User, tenantId: input.tenantId }),\n persist: async ({ em, input, existing }) => {\n if (input.clear) {\n if (!existing) return\n const aclToRemove = existing as UserAcl\n await withAtomicFlush(\n em,\n [\n () => {\n em.remove(aclToRemove)\n },\n ],\n { transaction: true, label: AUTH_USER_ACL_UPDATE_COMMAND_ID },\n )\n return\n }\n const acl =\n (existing as UserAcl | null) ??\n em.create(UserAcl, {\n user: em.getReference(User, input.userId),\n tenantId: input.tenantId,\n createdAt: new Date(),\n isSuperAdmin: false,\n })\n await withAtomicFlush(\n em,\n [\n () => {\n acl.isSuperAdmin = input.isSuperAdmin\n acl.featuresJson = input.features\n acl.organizationsJson = input.organizations\n em.persist(acl)\n },\n ],\n { transaction: true, label: AUTH_USER_ACL_UPDATE_COMMAND_ID },\n )\n },\n invalidate: async ({ ctx, input }) => {\n const rbacService = ctx.container.resolve('rbacService') as RbacService\n await rbacService.invalidateUserCache(input.userId)\n await deleteCacheTags(ctx, [`rbac:user:${input.userId}`])\n },\n // Clearing removes the row, so an absent row is the real post-state here.\n snapshotWhenAbsent: (input) => (input.clear ? { ...EMPTY_ACL_SNAPSHOT } : null),\n // `userId` arrives in the request body and `auth:user` carries encrypted\n // personal data, so the lookup is tenant-scoped: an id belonging to another\n // tenant must not be decrypted under this scope and stamped into this\n // tenant's trail. A global account (`users.tenant_id` is nullable) still\n // resolves, mirroring how the role route widens its own lookup.\n loadTarget: async (em, input, ctx) => {\n const user = await findOneWithDecryption(\n em,\n User,\n { id: input.userId, $or: [{ tenantId: input.tenantId }, { tenantId: null }] } as FilterQuery<User>,\n {},\n { tenantId: input.tenantId, organizationId: ctx.auth?.orgId ?? null },\n )\n if (!user) return null\n return { kind: 'user', id: input.userId, email: user.email ?? null, name: user.name ?? null }\n },\n sanitizedRequest: (input) => input.requested ?? null,\n})\n\nregisterCommand(updateRoleAclCommand)\nregisterCommand(updateUserAclCommand)\n"],
5
- "mappings": "AAyBA,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AAEtC,SAAS,MAAM,SAAS,MAAM,eAAe;AAG7C,MAAM,SAAS,aAAa,MAAM,EAAE,MAAM,EAAE,WAAW,eAAe,CAAC;AA8BvE,MAAM,qBAAkC;AAAA,EACtC,cAAc;AAAA,EACd,UAAU,CAAC;AAAA,EACX,eAAe;AACjB;AAmDA,SAAS,mBAAmB,MAAc,OAAuB;AAC/D,MAAI,SAAS,MAAO,QAAO;AAC3B,SAAO,OAAO,QAAQ,KAAK;AAC7B;AAEA,SAAS,aAAa,QAA2B;AAC/C,MAAI,CAAC,MAAM,QAAQ,MAAM,EAAG,QAAO,CAAC;AACpC,SAAO,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,UAA2B,OAAO,UAAU,QAAQ,EAAE,KAAK,kBAAkB;AAC1G;AAEA,SAAS,mBAAmB,KAAgD;AAC1E,MAAI,CAAC,IAAK,QAAO,EAAE,GAAG,mBAAmB;AACzC,SAAO;AAAA,IACL,cAAc,QAAQ,IAAI,YAAY;AAAA,IACtC,UAAU,aAAa,IAAI,YAAY;AAAA,IACvC,eAAe,MAAM,QAAQ,IAAI,iBAAiB,IAAI,aAAa,IAAI,iBAAiB,IAAI;AAAA,EAC9F;AACF;AAEA,SAAS,YAAY,UAAgC;AACnD,SAAO,SAAS,gB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AX_USER_LOOKUP_IDS = 100;
3
- function resolveUserIdFilter(rawIds, id, maxIds = MAX_USER_LOOKUP_IDS) {
4
- const single = typeof id === "string" && id.trim() ? id.trim() : null;
5
- if (!isIdsParamProvided(rawIds)) {
6
- return single ? { kind: "ids", ids: [single] } : { kind: "unfiltered" };
7
- }
8
- const parsed = parseIdsParam(rawIds, maxIds);
9
- const ids = single ? parsed.filter((value) => value === single) : parsed;
10
- return ids.length ? { kind: "ids", ids } : { kind: "none" };
11
- }
12
- export {
13
- MAX_USER_LOOKUP_IDS,
14
- resolveUserIdFilter
15
- };
16
- //# sourceMappingURL=userIdFilter.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/modules/auth/lib/userIdFilter.ts"],
4
- "sourcesContent": ["import { isIdsParamProvided, parseIdsParam } from '@open-mercato/shared/lib/crud/ids'\n\n// Batch id lookup shares the list's page cap, so `?ids=` can never pull more rows than `?pageSize=`.\nexport const MAX_USER_LOOKUP_IDS = 100\n\nexport type UserIdFilter =\n /** Neither `?id=` nor `?ids=` was supplied \u2014 the list is filtered by the other params only. */\n | { kind: 'unfiltered' }\n /** Restrict the list to these ids. */\n | { kind: 'ids'; ids: string[] }\n /**\n * `?ids=` was supplied but nothing usable survived \u2014 either no value was a UUID, or the\n * intersection with `?id=` is empty. Match nothing rather than dropping the filter and returning\n * the full first page, which would turn a malformed request into a record-count side channel\n * (the same rule `mergeIdFilter` enforces for CRUD list routes, #4143 Finding 3).\n */\n | { kind: 'none' }\n\nexport function resolveUserIdFilter(\n rawIds: unknown,\n id?: string | null,\n maxIds: number = MAX_USER_LOOKUP_IDS,\n): UserIdFilter {\n const single = typeof id === 'string' && id.trim() ? id.trim() : null\n if (!isIdsParamProvided(rawIds)) {\n return single ? { kind: 'ids', ids: [single] } : { kind: 'unfiltered' }\n }\n const parsed = parseIdsParam(rawIds, maxIds)\n const ids = single ? parsed.filter((value) => value === single) : parsed\n return ids.length ? { kind: 'ids', ids } : { kind: 'none' }\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB,qBAAqB;AAG3C,MAAM,sBAAsB;AAe5B,SAAS,oBACd,QACA,IACA,SAAiB,qBACH;AACd,QAAM,SAAS,OAAO,OAAO,YAAY,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI;AACjE,MAAI,CAAC,mBAAmB,MAAM,GAAG;AAC/B,WAAO,SAAS,EAAE,MAAM,OAAO,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,aAAa;AAAA,EACxE;AACA,QAAM,SAAS,cAAc,QAAQ,MAAM;AAC3C,QAAM,MAAM,SAAS,OAAO,OAAO,CAAC,UAAU,UAAU,MAAM,IAAI;AAClE,SAAO,IAAI,SAAS,EAAE,MAAM,OAAO,IAAI,IAAI,EAAE,MAAM,OAAO;AAC5D;",
6
- "names": []
7
- }
@@ -1,200 +0,0 @@
1
- import { sql } from "kysely";
2
- import { escapeLikePattern } from "@open-mercato/shared/lib/db/escapeLikePattern";
3
- import { findOneWithDecryption, findWithDecryption } from "@open-mercato/shared/lib/encryption/find";
4
- import { Role, RoleAcl, User, UserRole } from "../data/entities.js";
5
- import { listSuperAdminUserIds } from "../lib/grantChecks.js";
6
- import { resolveRoleOrganizationScope, roleAclGrantsPrincipalOrganization } from "./roleOrganizationScope.js";
7
- const MAX_ROLE_PAGE_SIZE = 100;
8
- const MAX_ROLE_RESULTS = 1e3;
9
- function normalizeIds(ids) {
10
- return Array.from(new Set(ids.map((id) => id.trim()).filter(Boolean)));
11
- }
12
- function relationId(value) {
13
- if (typeof value === "string") return value.trim() || null;
14
- if (!value || typeof value !== "object") return null;
15
- const id = value.id;
16
- return typeof id === "string" && id.trim().length > 0 ? id.trim() : null;
17
- }
18
- class DefaultAuthPrincipalService {
19
- constructor(em, organizationHierarchyService) {
20
- this.em = em;
21
- this.organizationHierarchyService = organizationHierarchyService;
22
- }
23
- async principalExists(input) {
24
- if (input.type === "role") {
25
- return (await this.filterActiveRoleIds([input.id], input.scope)).includes(input.id);
26
- }
27
- return Boolean(await findOneWithDecryption(
28
- this.em,
29
- User,
30
- {
31
- id: input.id,
32
- tenantId: input.scope.tenantId,
33
- deletedAt: null,
34
- $or: [{ organizationId: null }, { organizationId: input.scope.organizationId }]
35
- },
36
- { fields: ["id"] },
37
- input.scope
38
- ));
39
- }
40
- async resolveActiveUserRoleIds(userId, scope) {
41
- const links = await findWithDecryption(
42
- this.em,
43
- UserRole,
44
- {
45
- user: userId,
46
- deletedAt: null,
47
- role: { tenantId: scope.tenantId, deletedAt: null }
48
- },
49
- { fields: ["role"] },
50
- scope
51
- );
52
- return this.filterActiveRoleIds(
53
- normalizeIds(links.flatMap((link) => {
54
- const id = relationId(link.role);
55
- return id ? [id] : [];
56
- })),
57
- scope
58
- );
59
- }
60
- async filterActiveRoleIds(roleIds, scope) {
61
- const ids = normalizeIds(roleIds);
62
- if (ids.length === 0) return [];
63
- const roles = await findWithDecryption(
64
- this.em,
65
- Role,
66
- { id: { $in: ids }, tenantId: scope.tenantId, deletedAt: null },
67
- { fields: ["id"] },
68
- scope
69
- );
70
- const activeIds = normalizeIds(roles.map((role) => role.id));
71
- if (activeIds.length === 0) return [];
72
- const roleOrganizationScope = await resolveRoleOrganizationScope(
73
- this.organizationHierarchyService,
74
- scope.tenantId,
75
- scope.organizationId
76
- );
77
- const acls = await findWithDecryption(
78
- this.em,
79
- RoleAcl,
80
- {
81
- tenantId: scope.tenantId,
82
- role: { $in: activeIds },
83
- deletedAt: null
84
- },
85
- { fields: ["role", "organizationsJson"] },
86
- scope
87
- );
88
- const eligibilityById = /* @__PURE__ */ new Map();
89
- for (const acl of acls) {
90
- const id = relationId(acl.role);
91
- if (!id) continue;
92
- eligibilityById.set(
93
- id,
94
- eligibilityById.get(id) === true || roleAclGrantsPrincipalOrganization(acl, roleOrganizationScope)
95
- );
96
- }
97
- return activeIds.filter((id) => eligibilityById.get(id) !== false);
98
- }
99
- async resolveLabels(input) {
100
- const ids = normalizeIds(input.ids);
101
- if (ids.length === 0) return [];
102
- if (input.type === "role") {
103
- const eligibleIds = await this.filterActiveRoleIds(ids, input.scope);
104
- if (eligibleIds.length === 0) return [];
105
- const roles = await findWithDecryption(
106
- this.em,
107
- Role,
108
- { id: { $in: eligibleIds }, tenantId: input.scope.tenantId, deletedAt: null },
109
- { fields: ["id", "name"] },
110
- input.scope
111
- );
112
- return roles.map((role) => ({ id: role.id, label: role.name, secondary: null }));
113
- }
114
- const users = await findWithDecryption(
115
- this.em,
116
- User,
117
- {
118
- id: { $in: ids },
119
- tenantId: input.scope.tenantId,
120
- deletedAt: null,
121
- $or: [{ organizationId: null }, { organizationId: input.scope.organizationId }]
122
- },
123
- { fields: ["id", "name", "email"] },
124
- input.scope
125
- );
126
- return users.map((user) => ({
127
- id: user.id,
128
- label: user.name?.trim() || user.email,
129
- secondary: user.name?.trim() && user.email !== user.name.trim() ? user.email : null
130
- }));
131
- }
132
- async queryActiveRolePage(input) {
133
- const page = Math.max(1, Math.floor(input.page));
134
- const pageSize = Math.min(MAX_ROLE_PAGE_SIZE, Math.max(1, Math.floor(input.pageSize)));
135
- const offset = (page - 1) * pageSize;
136
- const excludedIds = normalizeIds(input.excludedIds ?? []);
137
- const roleOrganizationScope = await resolveRoleOrganizationScope(
138
- this.organizationHierarchyService,
139
- input.scope.tenantId,
140
- input.scope.organizationId
141
- );
142
- const db = this.em.getKysely();
143
- let eligibleRoles = db.selectFrom("roles as r").where("r.tenant_id", "=", input.scope.tenantId).where("r.deleted_at", "is", null);
144
- if (roleOrganizationScope) {
145
- const allowedOrganizations = Array.from(roleOrganizationScope);
146
- const organizationPredicates = [
147
- sql`ra.organizations_json is null`,
148
- sql`ra.organizations_json::jsonb @> ${JSON.stringify(["__all__"])}::jsonb`,
149
- ...allowedOrganizations.map((organizationId) => sql`ra.organizations_json::jsonb @> ${JSON.stringify([organizationId])}::jsonb`)
150
- ];
151
- const organizationAllowed = sql`(${sql.join(organizationPredicates, sql` or `)})`;
152
- eligibleRoles = eligibleRoles.where(sql`(
153
- not exists (
154
- select 1
155
- from role_acls as ra_any
156
- where ra_any.role_id = r.id
157
- and ra_any.tenant_id = ${input.scope.tenantId}
158
- and ra_any.deleted_at is null
159
- )
160
- or exists (
161
- select 1
162
- from role_acls as ra
163
- where ra.role_id = r.id
164
- and ra.tenant_id = ${input.scope.tenantId}
165
- and ra.deleted_at is null
166
- and ${organizationAllowed}
167
- )
168
- )`);
169
- }
170
- if (input.search?.trim()) {
171
- const searchPattern = `%${escapeLikePattern(input.search.trim())}%`;
172
- eligibleRoles = eligibleRoles.where(sql`r.name ilike ${searchPattern}`);
173
- }
174
- if (excludedIds.length > 0) {
175
- eligibleRoles = eligibleRoles.where("r.id", "not in", excludedIds);
176
- }
177
- const boundedRoleIds = eligibleRoles.select("r.id").limit(MAX_ROLE_RESULTS).as("bounded_roles");
178
- const countQuery = db.selectFrom(boundedRoleIds).select(sql`count(*)`.as("count"));
179
- const pageQuery = eligibleRoles.select(["r.id", "r.name"]).orderBy("r.id", "asc").limit(offset < MAX_ROLE_RESULTS ? Math.min(pageSize, MAX_ROLE_RESULTS - offset) : 0).offset(Math.min(offset, MAX_ROLE_RESULTS));
180
- const [rows, countRow] = await Promise.all([
181
- pageQuery.execute(),
182
- countQuery.executeTakeFirst()
183
- ]);
184
- const parsedTotal = Number(countRow?.count ?? 0);
185
- const total = Number.isFinite(parsedTotal) ? Math.min(MAX_ROLE_RESULTS, Math.max(0, Math.floor(parsedTotal))) : 0;
186
- return {
187
- items: rows.map((role) => ({ id: role.id, label: role.name, secondary: null })),
188
- page,
189
- pageSize,
190
- total
191
- };
192
- }
193
- async listSuperAdminUserIds(tenantId) {
194
- return Array.from(await listSuperAdminUserIds(this.em, tenantId));
195
- }
196
- }
197
- export {
198
- DefaultAuthPrincipalService
199
- };
200
- //# sourceMappingURL=principalService.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/modules/auth/services/principalService.ts"],
4
- "sourcesContent": ["import type { FilterQuery } from '@mikro-orm/core'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { sql } from 'kysely'\nimport type {\n AuthPrincipalLabel,\n AuthPrincipalRolePage,\n AuthPrincipalService,\n OrganizationHierarchyService,\n PrincipalScope,\n} from '@open-mercato/shared/lib/auth/principal-service'\nimport { escapeLikePattern } from '@open-mercato/shared/lib/db/escapeLikePattern'\nimport { findOneWithDecryption, findWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { Role, RoleAcl, User, UserRole } from '../data/entities'\nimport { listSuperAdminUserIds } from '../lib/grantChecks'\nimport { resolveRoleOrganizationScope, roleAclGrantsPrincipalOrganization } from './roleOrganizationScope'\n\nconst MAX_ROLE_PAGE_SIZE = 100\nconst MAX_ROLE_RESULTS = 1_000\n\ntype AuthPrincipalDatabase = {\n roles: {\n id: string\n tenant_id: string\n name: string\n deleted_at: Date | null\n }\n role_acls: {\n role_id: string\n tenant_id: string\n organizations_json: string[] | null\n deleted_at: Date | null\n }\n}\n\nfunction normalizeIds(ids: string[]): string[] {\n return Array.from(new Set(ids.map((id) => id.trim()).filter(Boolean)))\n}\n\nfunction relationId(value: unknown): string | null {\n if (typeof value === 'string') return value.trim() || null\n if (!value || typeof value !== 'object') return null\n const id = (value as { id?: unknown }).id\n return typeof id === 'string' && id.trim().length > 0 ? id.trim() : null\n}\n\nexport class DefaultAuthPrincipalService implements AuthPrincipalService {\n constructor(\n private readonly em: EntityManager,\n private readonly organizationHierarchyService?: OrganizationHierarchyService,\n ) {}\n\n async principalExists(input: {\n type: 'user' | 'role'\n id: string\n scope: PrincipalScope\n }): Promise<boolean> {\n if (input.type === 'role') {\n return (await this.filterActiveRoleIds([input.id], input.scope)).includes(input.id)\n }\n return Boolean(await findOneWithDecryption(\n this.em,\n User,\n {\n id: input.id,\n tenantId: input.scope.tenantId,\n deletedAt: null,\n $or: [{ organizationId: null }, { organizationId: input.scope.organizationId }],\n } as FilterQuery<User>,\n { fields: ['id'] as const },\n input.scope,\n ))\n }\n\n async resolveActiveUserRoleIds(userId: string, scope: PrincipalScope): Promise<string[]> {\n const links = await findWithDecryption(\n this.em,\n UserRole,\n {\n user: userId,\n deletedAt: null,\n role: { tenantId: scope.tenantId, deletedAt: null },\n } as FilterQuery<UserRole>,\n { fields: ['role'] as const },\n scope,\n )\n return this.filterActiveRoleIds(\n normalizeIds(links.flatMap((link) => {\n const id = relationId(link.role)\n return id ? [id] : []\n })),\n scope,\n )\n }\n\n async filterActiveRoleIds(roleIds: string[], scope: PrincipalScope): Promise<string[]> {\n const ids = normalizeIds(roleIds)\n if (ids.length === 0) return []\n const roles = await findWithDecryption(\n this.em,\n Role,\n { id: { $in: ids }, tenantId: scope.tenantId, deletedAt: null } as FilterQuery<Role>,\n { fields: ['id'] as const },\n scope,\n )\n const activeIds = normalizeIds(roles.map((role) => role.id))\n if (activeIds.length === 0) return []\n const roleOrganizationScope = await resolveRoleOrganizationScope(\n this.organizationHierarchyService,\n scope.tenantId,\n scope.organizationId,\n )\n const acls = await findWithDecryption(\n this.em,\n RoleAcl,\n {\n tenantId: scope.tenantId,\n role: { $in: activeIds },\n deletedAt: null,\n } as FilterQuery<RoleAcl>,\n { fields: ['role', 'organizationsJson'] as const },\n scope,\n )\n const eligibilityById = new Map<string, boolean>()\n for (const acl of acls) {\n const id = relationId(acl.role)\n if (!id) continue\n eligibilityById.set(\n id,\n eligibilityById.get(id) === true || roleAclGrantsPrincipalOrganization(acl, roleOrganizationScope),\n )\n }\n // A tenant role without an ACL remains a valid explicit-share principal.\n // Only an existing ACL can restrict that role away from this organization.\n return activeIds.filter((id) => eligibilityById.get(id) !== false)\n }\n\n async resolveLabels(input: {\n type: 'user' | 'role'\n ids: string[]\n scope: PrincipalScope\n }): Promise<AuthPrincipalLabel[]> {\n const ids = normalizeIds(input.ids)\n if (ids.length === 0) return []\n if (input.type === 'role') {\n const eligibleIds = await this.filterActiveRoleIds(ids, input.scope)\n if (eligibleIds.length === 0) return []\n const roles = await findWithDecryption(\n this.em,\n Role,\n { id: { $in: eligibleIds }, tenantId: input.scope.tenantId, deletedAt: null } as FilterQuery<Role>,\n { fields: ['id', 'name'] as const },\n input.scope,\n )\n return roles.map((role) => ({ id: role.id, label: role.name, secondary: null }))\n }\n const users = await findWithDecryption(\n this.em,\n User,\n {\n id: { $in: ids },\n tenantId: input.scope.tenantId,\n deletedAt: null,\n $or: [{ organizationId: null }, { organizationId: input.scope.organizationId }],\n } as FilterQuery<User>,\n { fields: ['id', 'name', 'email'] as const },\n input.scope,\n )\n return users.map((user) => ({\n id: user.id,\n label: user.name?.trim() || user.email,\n secondary: user.name?.trim() && user.email !== user.name.trim() ? user.email : null,\n }))\n }\n\n async queryActiveRolePage(input: {\n scope: PrincipalScope\n search?: string\n excludedIds?: string[]\n page: number\n pageSize: number\n }): Promise<AuthPrincipalRolePage> {\n const page = Math.max(1, Math.floor(input.page))\n const pageSize = Math.min(MAX_ROLE_PAGE_SIZE, Math.max(1, Math.floor(input.pageSize)))\n const offset = (page - 1) * pageSize\n const excludedIds = normalizeIds(input.excludedIds ?? [])\n const roleOrganizationScope = await resolveRoleOrganizationScope(\n this.organizationHierarchyService,\n input.scope.tenantId,\n input.scope.organizationId,\n )\n const db = this.em.getKysely<AuthPrincipalDatabase>()\n let eligibleRoles = db\n .selectFrom('roles as r')\n .where('r.tenant_id', '=', input.scope.tenantId)\n .where('r.deleted_at', 'is', null)\n\n if (roleOrganizationScope) {\n const allowedOrganizations = Array.from(roleOrganizationScope)\n const organizationPredicates = [\n sql<boolean>`ra.organizations_json is null`,\n sql<boolean>`ra.organizations_json::jsonb @> ${JSON.stringify(['__all__'])}::jsonb`,\n ...allowedOrganizations.map((organizationId) => (\n sql<boolean>`ra.organizations_json::jsonb @> ${JSON.stringify([organizationId])}::jsonb`\n )),\n ]\n const organizationAllowed = sql<boolean>`(${sql.join(organizationPredicates, sql` or `)})`\n eligibleRoles = eligibleRoles.where(sql<boolean>`(\n not exists (\n select 1\n from role_acls as ra_any\n where ra_any.role_id = r.id\n and ra_any.tenant_id = ${input.scope.tenantId}\n and ra_any.deleted_at is null\n )\n or exists (\n select 1\n from role_acls as ra\n where ra.role_id = r.id\n and ra.tenant_id = ${input.scope.tenantId}\n and ra.deleted_at is null\n and ${organizationAllowed}\n )\n )`)\n }\n if (input.search?.trim()) {\n const searchPattern = `%${escapeLikePattern(input.search.trim())}%`\n eligibleRoles = eligibleRoles.where(sql<boolean>`r.name ilike ${searchPattern}`)\n }\n if (excludedIds.length > 0) {\n eligibleRoles = eligibleRoles.where('r.id', 'not in', excludedIds)\n }\n\n const boundedRoleIds = eligibleRoles\n .select('r.id')\n .limit(MAX_ROLE_RESULTS)\n .as('bounded_roles')\n const countQuery = db\n .selectFrom(boundedRoleIds)\n .select(sql<string>`count(*)`.as('count'))\n const pageQuery = eligibleRoles\n .select(['r.id', 'r.name'])\n .orderBy('r.id', 'asc')\n .limit(offset < MAX_ROLE_RESULTS ? Math.min(pageSize, MAX_ROLE_RESULTS - offset) : 0)\n .offset(Math.min(offset, MAX_ROLE_RESULTS))\n\n const [rows, countRow] = await Promise.all([\n pageQuery.execute() as Promise<Array<{ id: string; name: string }>>,\n countQuery.executeTakeFirst() as Promise<{ count?: string | number } | undefined>,\n ])\n const parsedTotal = Number(countRow?.count ?? 0)\n const total = Number.isFinite(parsedTotal)\n ? Math.min(MAX_ROLE_RESULTS, Math.max(0, Math.floor(parsedTotal)))\n : 0\n\n return {\n items: rows.map((role) => ({ id: role.id, label: role.name, secondary: null })),\n page,\n pageSize,\n total,\n }\n }\n\n async listSuperAdminUserIds(tenantId: string): Promise<string[]> {\n return Array.from(await listSuperAdminUserIds(this.em, tenantId))\n }\n}\n"],
5
- "mappings": "AAEA,SAAS,WAAW;AAQpB,SAAS,yBAAyB;AAClC,SAAS,uBAAuB,0BAA0B;AAC1D,SAAS,MAAM,SAAS,MAAM,gBAAgB;AAC9C,SAAS,6BAA6B;AACtC,SAAS,8BAA8B,0CAA0C;AAEjF,MAAM,qBAAqB;AA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AiB,cACpB,OAAO,MAAM,EACb,MAAM,gBAAgB,EACtB,GAAG,eAAe;AACrB,UAAM,aAAa,GAChB,WAAW,cAAc,EACzB,OAAO,cAAsB,GAAG,OAAO,CAAC;AAC3C,UAAM,YAAY,cACf,OAAO,CAAC,QAAQ,QAAQ,CAAC,EACzB,QAAQ,QAAQ,KAAK,EACrB,MAAM,SAAS,mBAAmB,KAAK,IAAI,UAAU,mBAAmB,MAAM,IAAI,CAAC,EACnF,OAAO,KAAK,IAAI,QAAQ,gBAAgB,CAAC;AAE5C,UAAM,CAAC,MAAM,QAAQ,IAAI,MAAM,QAAQ,IAAI;AAAA,MACzC,UAAU,QAAQ;AAAA,MAClB,WAAW,iBAAiB;AAAA,IAC9B,CAAC;AACD,UAAM,cAAc,OAAO,UAAU,SAAS,CAAC;AAC/C,UAAM,QAAQ,OAAO,SAAS,WAAW,IACrC,KAAK,IAAI,kBAAkB,KAAK,IAAI,GAAG,KAAK,MAAM,WAAW,CAAC,CAAC,IAC/D;AAEJ,WAAO;AAAA,MACL,OAAO,KAAK,IAAI,CAAC,UAAU,EAAE,IAAI,KAAK,IAAI,OAAO,KAAK,MAAM,WAAW,KAAK,EAAE;AAAA,MAC9E;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,sBAAsB,UAAqC;AAC/D,WAAO,MAAM,KAAK,MAAM,sBAAsB,KAAK,IAAI,QAAQ,CAAC;AAAA,EAClE;AACF;",
6
- "names": []
7
- }
@@ -1,41 +0,0 @@
1
- function normalizeId(value) {
2
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
3
- }
4
- async function resolveRoleOrganizationScope(hierarchyService, tenantId, organizationId) {
5
- const selectedId = normalizeId(organizationId);
6
- if (!selectedId) return null;
7
- const normalizedTenantId = normalizeId(tenantId);
8
- if (!normalizedTenantId) return /* @__PURE__ */ new Set();
9
- const ids = /* @__PURE__ */ new Set([selectedId]);
10
- if (!hierarchyService) return ids;
11
- const ancestorIds = await hierarchyService.resolveAncestorIds({
12
- tenantId: normalizedTenantId,
13
- organizationId: selectedId
14
- });
15
- if (ancestorIds === null) return /* @__PURE__ */ new Set();
16
- for (const ancestorId of ancestorIds) {
17
- const normalized = normalizeId(ancestorId);
18
- if (normalized) ids.add(normalized);
19
- }
20
- return ids;
21
- }
22
- function roleAclAllowsOrganization(acl, scope) {
23
- if (!scope) return true;
24
- const organizations = Array.isArray(acl.organizationsJson) ? acl.organizationsJson : null;
25
- if (!organizations || organizations.length === 0 || organizations.includes("__all__")) return true;
26
- return organizations.some((organizationId) => scope.has(organizationId));
27
- }
28
- function roleAclGrantsPrincipalOrganization(acl, scope) {
29
- if (!scope) return true;
30
- const organizations = Array.isArray(acl.organizationsJson) ? acl.organizationsJson : null;
31
- if (!organizations) return true;
32
- if (organizations.length === 0) return false;
33
- if (organizations.includes("__all__")) return true;
34
- return organizations.some((organizationId) => scope.has(organizationId));
35
- }
36
- export {
37
- resolveRoleOrganizationScope,
38
- roleAclAllowsOrganization,
39
- roleAclGrantsPrincipalOrganization
40
- };
41
- //# sourceMappingURL=roleOrganizationScope.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/modules/auth/services/roleOrganizationScope.ts"],
4
- "sourcesContent": ["import type { OrganizationHierarchyService } from '@open-mercato/shared/lib/auth/principal-service'\nimport type { RoleAcl } from '../data/entities'\n\nexport type RoleOrganizationScope = ReadonlySet<string> | null\n\nfunction normalizeId(value: unknown): string | null {\n return typeof value === 'string' && value.trim().length > 0 ? value.trim() : null\n}\n\nexport async function resolveRoleOrganizationScope(\n hierarchyService: OrganizationHierarchyService | null | undefined,\n tenantId: string | null | undefined,\n organizationId: string | null | undefined,\n): Promise<RoleOrganizationScope> {\n const selectedId = normalizeId(organizationId)\n if (!selectedId) return null\n const normalizedTenantId = normalizeId(tenantId)\n if (!normalizedTenantId) return new Set()\n\n const ids = new Set<string>([selectedId])\n // Auth remains independently usable when Directory is disabled: exact-org\n // grants still apply, while parent-to-descendant expansion fails closed.\n if (!hierarchyService) return ids\n\n const ancestorIds = await hierarchyService.resolveAncestorIds({\n tenantId: normalizedTenantId,\n organizationId: selectedId,\n })\n // A registered Directory seam can prove an invalid/wrong-tenant selection.\n // Fail closed for restricted roles in that case.\n if (ancestorIds === null) return new Set()\n for (const ancestorId of ancestorIds) {\n const normalized = normalizeId(ancestorId)\n if (normalized) ids.add(normalized)\n }\n return ids\n}\n\nexport function roleAclAllowsOrganization(\n acl: Pick<RoleAcl, 'organizationsJson'>,\n scope: RoleOrganizationScope,\n): boolean {\n if (!scope) return true\n const organizations = Array.isArray(acl.organizationsJson) ? acl.organizationsJson : null\n if (!organizations || organizations.length === 0 || organizations.includes('__all__')) return true\n return organizations.some((organizationId) => scope.has(organizationId))\n}\n\n/**\n * Principal eligibility \u2014 which roles may be selected as, or resolved into, an explicit share\n * target \u2014 follows the human-principal deny-all contract instead: an empty allowlist grants no\n * organization reach, so such a role must not become a share principal here (#4033).\n *\n * This deliberately differs from `roleAclAllowsOrganization` above, which governs *feature*\n * evaluation and keeps the wider \"an empty list applies everywhere\" meaning, and from the\n * API-key projection, where an empty list means \"inherit the key's own organization binding\".\n * Without this split a user who reaches an organization through a second role could inherit\n * viewer/editor access from a share assigned to a deny-all role.\n */\nexport function roleAclGrantsPrincipalOrganization(\n acl: Pick<RoleAcl, 'organizationsJson'>,\n scope: RoleOrganizationScope,\n): boolean {\n if (!scope) return true\n const organizations = Array.isArray(acl.organizationsJson) ? acl.organizationsJson : null\n if (!organizations) return true\n if (organizations.length === 0) return false\n if (organizations.includes('__all__')) return true\n return organizations.some((organizationId) => scope.has(organizationId))\n}\n"],
5
- "mappings": "AAKA,SAAS,YAAY,OAA+B;AAClD,SAAO,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,SAAS,IAAI,MAAM,KAAK,IAAI;AAC/E;AAEA,eAAsB,6BACpB,kBACA,UACA,gBACgC;AAChC,QAAM,aAAa,YAAY,cAAc;AAC7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