@open-mercato/core 0.5.1-develop.2691.d8a0934b37 → 0.5.1-develop.2694.732417c5ec

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 (414) hide show
  1. package/dist/modules/api_keys/data/entities.js +1 -1
  2. package/dist/modules/api_keys/data/entities.js.map +1 -1
  3. package/dist/modules/api_keys/services/apiKeyService.js +5 -5
  4. package/dist/modules/api_keys/services/apiKeyService.js.map +2 -2
  5. package/dist/modules/attachments/api/library/[id]/route.js +1 -1
  6. package/dist/modules/attachments/api/library/[id]/route.js.map +2 -2
  7. package/dist/modules/attachments/api/library/route.js +7 -9
  8. package/dist/modules/attachments/api/library/route.js.map +2 -2
  9. package/dist/modules/attachments/api/partitions/route.js +3 -3
  10. package/dist/modules/attachments/api/partitions/route.js.map +2 -2
  11. package/dist/modules/attachments/api/route.js +6 -5
  12. package/dist/modules/attachments/api/route.js.map +2 -2
  13. package/dist/modules/attachments/api/transfer/route.js +1 -1
  14. package/dist/modules/attachments/api/transfer/route.js.map +2 -2
  15. package/dist/modules/attachments/data/entities.js +2 -1
  16. package/dist/modules/attachments/data/entities.js.map +2 -2
  17. package/dist/modules/attachments/lib/ocrQueue.js +1 -1
  18. package/dist/modules/attachments/lib/ocrQueue.js.map +2 -2
  19. package/dist/modules/audit_logs/api/audit-logs/actions/export/route.js.map +2 -2
  20. package/dist/modules/audit_logs/api/audit-logs/actions/route.js.map +2 -2
  21. package/dist/modules/audit_logs/data/entities.js +1 -1
  22. package/dist/modules/audit_logs/data/entities.js.map +1 -1
  23. package/dist/modules/audit_logs/services/actionLogService.js +77 -70
  24. package/dist/modules/audit_logs/services/actionLogService.js.map +2 -2
  25. package/dist/modules/auth/api/roles/acl/route.js +1 -1
  26. package/dist/modules/auth/api/roles/acl/route.js.map +2 -2
  27. package/dist/modules/auth/api/users/acl/route.js +2 -2
  28. package/dist/modules/auth/api/users/acl/route.js.map +2 -2
  29. package/dist/modules/auth/api/users/resend-invite/route.js +1 -1
  30. package/dist/modules/auth/api/users/resend-invite/route.js.map +2 -2
  31. package/dist/modules/auth/cli.js +12 -6
  32. package/dist/modules/auth/cli.js.map +2 -2
  33. package/dist/modules/auth/commands/users.js +1 -1
  34. package/dist/modules/auth/commands/users.js.map +2 -2
  35. package/dist/modules/auth/data/entities.js +1 -1
  36. package/dist/modules/auth/data/entities.js.map +2 -2
  37. package/dist/modules/auth/lib/setup-app.js +3 -3
  38. package/dist/modules/auth/lib/setup-app.js.map +2 -2
  39. package/dist/modules/auth/services/authService.js +2 -2
  40. package/dist/modules/auth/services/authService.js.map +2 -2
  41. package/dist/modules/business_rules/api/rules/route.js +3 -3
  42. package/dist/modules/business_rules/api/rules/route.js.map +2 -2
  43. package/dist/modules/business_rules/api/sets/[id]/members/route.js +7 -4
  44. package/dist/modules/business_rules/api/sets/[id]/members/route.js.map +2 -2
  45. package/dist/modules/business_rules/api/sets/route.js +3 -3
  46. package/dist/modules/business_rules/api/sets/route.js.map +2 -2
  47. package/dist/modules/business_rules/cli.js +1 -1
  48. package/dist/modules/business_rules/cli.js.map +2 -2
  49. package/dist/modules/business_rules/data/entities.js +2 -9
  50. package/dist/modules/business_rules/data/entities.js.map +2 -2
  51. package/dist/modules/business_rules/lib/rule-engine.js +1 -1
  52. package/dist/modules/business_rules/lib/rule-engine.js.map +2 -2
  53. package/dist/modules/catalog/api/option-schemas/route.js +0 -1
  54. package/dist/modules/catalog/api/option-schemas/route.js.map +2 -2
  55. package/dist/modules/catalog/data/entities.js +2 -11
  56. package/dist/modules/catalog/data/entities.js.map +2 -2
  57. package/dist/modules/configs/data/entities.js +2 -1
  58. package/dist/modules/configs/data/entities.js.map +2 -2
  59. package/dist/modules/currencies/commands/fetch-configs.js +3 -3
  60. package/dist/modules/currencies/commands/fetch-configs.js.map +2 -2
  61. package/dist/modules/currencies/data/entities.js +1 -1
  62. package/dist/modules/currencies/data/entities.js.map +2 -2
  63. package/dist/modules/customer_accounts/api/signup.js +1 -1
  64. package/dist/modules/customer_accounts/api/signup.js.map +2 -2
  65. package/dist/modules/customer_accounts/data/entities.js +1 -1
  66. package/dist/modules/customer_accounts/data/entities.js.map +2 -2
  67. package/dist/modules/customer_accounts/services/customerInvitationService.js +1 -1
  68. package/dist/modules/customer_accounts/services/customerInvitationService.js.map +2 -2
  69. package/dist/modules/customer_accounts/services/customerSessionService.js +1 -1
  70. package/dist/modules/customer_accounts/services/customerSessionService.js.map +2 -2
  71. package/dist/modules/customer_accounts/services/customerTokenService.js +12 -7
  72. package/dist/modules/customer_accounts/services/customerTokenService.js.map +2 -2
  73. package/dist/modules/customers/api/interactions/conflicts/route.js +19 -17
  74. package/dist/modules/customers/api/interactions/conflicts/route.js.map +2 -2
  75. package/dist/modules/customers/api/interactions/counts/route.js +7 -6
  76. package/dist/modules/customers/api/interactions/counts/route.js.map +2 -2
  77. package/dist/modules/customers/api/interactions/route.js +28 -42
  78. package/dist/modules/customers/api/interactions/route.js.map +2 -2
  79. package/dist/modules/customers/api/utils.js +29 -24
  80. package/dist/modules/customers/api/utils.js.map +2 -2
  81. package/dist/modules/customers/cli.js +45 -40
  82. package/dist/modules/customers/cli.js.map +2 -2
  83. package/dist/modules/customers/commands/dictionaries.js +1 -1
  84. package/dist/modules/customers/commands/dictionaries.js.map +2 -2
  85. package/dist/modules/customers/commands/tags.js +1 -1
  86. package/dist/modules/customers/commands/tags.js.map +2 -2
  87. package/dist/modules/customers/data/entities.js +2 -12
  88. package/dist/modules/customers/data/entities.js.map +2 -2
  89. package/dist/modules/customers/lib/interactionProjection.js +18 -15
  90. package/dist/modules/customers/lib/interactionProjection.js.map +2 -2
  91. package/dist/modules/customers/lib/personCompanyLinkTable.js +6 -8
  92. package/dist/modules/customers/lib/personCompanyLinkTable.js.map +2 -2
  93. package/dist/modules/dashboards/api/roles/widgets/route.js +1 -1
  94. package/dist/modules/dashboards/api/roles/widgets/route.js.map +2 -2
  95. package/dist/modules/dashboards/api/users/widgets/route.js +1 -1
  96. package/dist/modules/dashboards/api/users/widgets/route.js.map +2 -2
  97. package/dist/modules/dashboards/data/entities.js +1 -1
  98. package/dist/modules/dashboards/data/entities.js.map +1 -1
  99. package/dist/modules/data_sync/api/mappings/route.js +1 -1
  100. package/dist/modules/data_sync/api/mappings/route.js.map +2 -2
  101. package/dist/modules/data_sync/data/entities.js +2 -1
  102. package/dist/modules/data_sync/data/entities.js.map +2 -2
  103. package/dist/modules/data_sync/lib/id-mapping.js +1 -1
  104. package/dist/modules/data_sync/lib/id-mapping.js.map +2 -2
  105. package/dist/modules/data_sync/lib/sync-run-service.js +1 -1
  106. package/dist/modules/data_sync/lib/sync-run-service.js.map +2 -2
  107. package/dist/modules/dictionaries/commands/factory.js +1 -1
  108. package/dist/modules/dictionaries/commands/factory.js.map +2 -2
  109. package/dist/modules/dictionaries/data/entities.js +2 -9
  110. package/dist/modules/dictionaries/data/entities.js.map +2 -2
  111. package/dist/modules/directory/commands/organizations.js +4 -4
  112. package/dist/modules/directory/commands/organizations.js.map +2 -2
  113. package/dist/modules/directory/data/entities.js +2 -1
  114. package/dist/modules/directory/data/entities.js.map +2 -2
  115. package/dist/modules/entities/api/definitions.js +2 -2
  116. package/dist/modules/entities/api/definitions.js.map +2 -2
  117. package/dist/modules/entities/api/encryption.js +2 -2
  118. package/dist/modules/entities/api/encryption.js.map +2 -2
  119. package/dist/modules/entities/api/relations/options.js +2 -2
  120. package/dist/modules/entities/api/relations/options.js.map +2 -2
  121. package/dist/modules/entities/cli.js +4 -4
  122. package/dist/modules/entities/cli.js.map +2 -2
  123. package/dist/modules/entities/data/entities.js +1 -1
  124. package/dist/modules/entities/data/entities.js.map +2 -2
  125. package/dist/modules/entities/lib/field-definitions.js +2 -2
  126. package/dist/modules/entities/lib/field-definitions.js.map +2 -2
  127. package/dist/modules/entities/lib/register.js +1 -1
  128. package/dist/modules/entities/lib/register.js.map +2 -2
  129. package/dist/modules/feature_toggles/data/entities.js +2 -9
  130. package/dist/modules/feature_toggles/data/entities.js.map +2 -2
  131. package/dist/modules/inbox_ops/api/proposals/counts/route.js +3 -6
  132. package/dist/modules/inbox_ops/api/proposals/counts/route.js.map +2 -2
  133. package/dist/modules/inbox_ops/data/entities.js +2 -8
  134. package/dist/modules/inbox_ops/data/entities.js.map +2 -2
  135. package/dist/modules/inbox_ops/lib/messagesIntegration.js +6 -6
  136. package/dist/modules/inbox_ops/lib/messagesIntegration.js.map +2 -2
  137. package/dist/modules/integrations/data/entities.js +2 -1
  138. package/dist/modules/integrations/data/entities.js.map +2 -2
  139. package/dist/modules/integrations/lib/credentials-service.js +1 -1
  140. package/dist/modules/integrations/lib/credentials-service.js.map +2 -2
  141. package/dist/modules/integrations/lib/log-service.js +1 -1
  142. package/dist/modules/integrations/lib/log-service.js.map +2 -2
  143. package/dist/modules/integrations/lib/state-service.js +1 -1
  144. package/dist/modules/integrations/lib/state-service.js.map +2 -2
  145. package/dist/modules/messages/api/route.js +90 -93
  146. package/dist/modules/messages/api/route.js.map +2 -2
  147. package/dist/modules/messages/api/unread-count/route.js +8 -7
  148. package/dist/modules/messages/api/unread-count/route.js.map +2 -2
  149. package/dist/modules/messages/commands/confirmations.js +1 -1
  150. package/dist/modules/messages/commands/confirmations.js.map +2 -2
  151. package/dist/modules/messages/commands/messages.js +3 -3
  152. package/dist/modules/messages/commands/messages.js.map +2 -2
  153. package/dist/modules/messages/data/entities.js +2 -1
  154. package/dist/modules/messages/data/entities.js.map +2 -2
  155. package/dist/modules/messages/lib/email-sender.js +1 -1
  156. package/dist/modules/messages/lib/email-sender.js.map +2 -2
  157. package/dist/modules/messages/lib/searchLookup.js +8 -8
  158. package/dist/modules/messages/lib/searchLookup.js.map +2 -2
  159. package/dist/modules/messages/lib/tokenConsumption.js +9 -4
  160. package/dist/modules/messages/lib/tokenConsumption.js.map +2 -2
  161. package/dist/modules/notifications/data/entities.js +2 -1
  162. package/dist/modules/notifications/data/entities.js.map +2 -2
  163. package/dist/modules/notifications/lib/notificationRecipients.js +15 -5
  164. package/dist/modules/notifications/lib/notificationRecipients.js.map +2 -2
  165. package/dist/modules/notifications/lib/notificationService.js +39 -34
  166. package/dist/modules/notifications/lib/notificationService.js.map +2 -2
  167. package/dist/modules/notifications/workers/create-notification.worker.js +14 -13
  168. package/dist/modules/notifications/workers/create-notification.worker.js.map +2 -2
  169. package/dist/modules/payment_gateways/api/transactions/route.js +2 -2
  170. package/dist/modules/payment_gateways/api/transactions/route.js.map +2 -2
  171. package/dist/modules/payment_gateways/data/entities.js +2 -1
  172. package/dist/modules/payment_gateways/data/entities.js.map +2 -2
  173. package/dist/modules/payment_gateways/lib/gateway-service.js +1 -1
  174. package/dist/modules/payment_gateways/lib/gateway-service.js.map +2 -2
  175. package/dist/modules/payment_gateways/lib/webhook-utils.js +2 -2
  176. package/dist/modules/payment_gateways/lib/webhook-utils.js.map +2 -2
  177. package/dist/modules/perspectives/data/entities.js +1 -1
  178. package/dist/modules/perspectives/data/entities.js.map +2 -2
  179. package/dist/modules/planner/data/entities.js +1 -1
  180. package/dist/modules/planner/data/entities.js.map +2 -2
  181. package/dist/modules/progress/data/entities.js +2 -1
  182. package/dist/modules/progress/data/entities.js.map +2 -2
  183. package/dist/modules/progress/lib/progressServiceImpl.js +1 -1
  184. package/dist/modules/progress/lib/progressServiceImpl.js.map +2 -2
  185. package/dist/modules/query_index/api/status.js +66 -57
  186. package/dist/modules/query_index/api/status.js.map +2 -2
  187. package/dist/modules/query_index/cli.js +39 -24
  188. package/dist/modules/query_index/cli.js.map +2 -2
  189. package/dist/modules/query_index/data/entities.js +1 -1
  190. package/dist/modules/query_index/data/entities.js.map +2 -2
  191. package/dist/modules/query_index/di.js +25 -13
  192. package/dist/modules/query_index/di.js.map +2 -2
  193. package/dist/modules/query_index/lib/batch.js +31 -33
  194. package/dist/modules/query_index/lib/batch.js.map +2 -2
  195. package/dist/modules/query_index/lib/coverage.js +63 -50
  196. package/dist/modules/query_index/lib/coverage.js.map +2 -2
  197. package/dist/modules/query_index/lib/engine.js +592 -588
  198. package/dist/modules/query_index/lib/engine.js.map +2 -2
  199. package/dist/modules/query_index/lib/indexer.js +74 -47
  200. package/dist/modules/query_index/lib/indexer.js.map +2 -2
  201. package/dist/modules/query_index/lib/jobs.js +37 -24
  202. package/dist/modules/query_index/lib/jobs.js.map +2 -2
  203. package/dist/modules/query_index/lib/purge.js +19 -11
  204. package/dist/modules/query_index/lib/purge.js.map +2 -2
  205. package/dist/modules/query_index/lib/reindexer.js +47 -44
  206. package/dist/modules/query_index/lib/reindexer.js.map +2 -2
  207. package/dist/modules/query_index/lib/search-tokens.js +47 -25
  208. package/dist/modules/query_index/lib/search-tokens.js.map +2 -2
  209. package/dist/modules/query_index/lib/stale.js +14 -12
  210. package/dist/modules/query_index/lib/stale.js.map +2 -2
  211. package/dist/modules/query_index/lib/subscriber-scope.js +2 -2
  212. package/dist/modules/query_index/lib/subscriber-scope.js.map +2 -2
  213. package/dist/modules/query_index/subscribers/delete_one.js +3 -2
  214. package/dist/modules/query_index/subscribers/delete_one.js.map +2 -2
  215. package/dist/modules/resources/commands/tag-assignments.js +1 -1
  216. package/dist/modules/resources/commands/tag-assignments.js.map +2 -2
  217. package/dist/modules/resources/commands/tags.js +1 -1
  218. package/dist/modules/resources/commands/tags.js.map +2 -2
  219. package/dist/modules/resources/data/entities.js +2 -1
  220. package/dist/modules/resources/data/entities.js.map +2 -2
  221. package/dist/modules/sales/commands/documentAddresses.js +2 -2
  222. package/dist/modules/sales/commands/documentAddresses.js.map +2 -2
  223. package/dist/modules/sales/commands/notes.js.map +2 -2
  224. package/dist/modules/sales/commands/tags.js +1 -1
  225. package/dist/modules/sales/commands/tags.js.map +2 -2
  226. package/dist/modules/sales/data/enrichers.js +9 -8
  227. package/dist/modules/sales/data/enrichers.js.map +2 -2
  228. package/dist/modules/sales/data/entities.js +2 -11
  229. package/dist/modules/sales/data/entities.js.map +2 -2
  230. package/dist/modules/shipping_carriers/data/entities.js +2 -1
  231. package/dist/modules/shipping_carriers/data/entities.js.map +2 -2
  232. package/dist/modules/shipping_carriers/lib/shipping-service.js +1 -1
  233. package/dist/modules/shipping_carriers/lib/shipping-service.js.map +2 -2
  234. package/dist/modules/shipping_carriers/lib/webhook-utils.js +2 -2
  235. package/dist/modules/shipping_carriers/lib/webhook-utils.js.map +2 -2
  236. package/dist/modules/staff/data/entities.js +1 -1
  237. package/dist/modules/staff/data/entities.js.map +2 -2
  238. package/dist/modules/translations/api/[entityType]/[entityId]/route.js +3 -5
  239. package/dist/modules/translations/api/[entityType]/[entityId]/route.js.map +2 -2
  240. package/dist/modules/translations/api/context.js +2 -2
  241. package/dist/modules/translations/api/context.js.map +2 -2
  242. package/dist/modules/translations/commands/translations.js +46 -39
  243. package/dist/modules/translations/commands/translations.js.map +2 -2
  244. package/dist/modules/translations/components/TranslationManager.js +19 -10
  245. package/dist/modules/translations/components/TranslationManager.js.map +2 -2
  246. package/dist/modules/translations/data/entities.js +1 -1
  247. package/dist/modules/translations/data/entities.js.map +2 -2
  248. package/dist/modules/translations/lib/apply.js +4 -4
  249. package/dist/modules/translations/lib/apply.js.map +2 -2
  250. package/dist/modules/translations/lib/batch.js +3 -2
  251. package/dist/modules/translations/lib/batch.js.map +2 -2
  252. package/dist/modules/translations/subscribers/cleanup.js +3 -5
  253. package/dist/modules/translations/subscribers/cleanup.js.map +2 -2
  254. package/dist/modules/workflows/api/definitions/route.js +1 -1
  255. package/dist/modules/workflows/api/definitions/route.js.map +2 -2
  256. package/dist/modules/workflows/cli.js +5 -5
  257. package/dist/modules/workflows/cli.js.map +2 -2
  258. package/dist/modules/workflows/data/entities.js +2 -1
  259. package/dist/modules/workflows/data/entities.js.map +2 -2
  260. package/dist/modules/workflows/lib/event-logger.js +2 -2
  261. package/dist/modules/workflows/lib/event-logger.js.map +2 -2
  262. package/dist/modules/workflows/lib/seeds.js +16 -1
  263. package/dist/modules/workflows/lib/seeds.js.map +2 -2
  264. package/dist/modules/workflows/lib/step-handler.js +3 -3
  265. package/dist/modules/workflows/lib/step-handler.js.map +2 -2
  266. package/dist/modules/workflows/lib/task-handler.js +1 -1
  267. package/dist/modules/workflows/lib/task-handler.js.map +2 -2
  268. package/dist/modules/workflows/lib/transition-handler.js +1 -1
  269. package/dist/modules/workflows/lib/transition-handler.js.map +2 -2
  270. package/dist/modules/workflows/lib/workflow-executor.js +2 -2
  271. package/dist/modules/workflows/lib/workflow-executor.js.map +2 -2
  272. package/jest.config.cjs +4 -2
  273. package/package.json +3 -3
  274. package/src/modules/api_keys/data/entities.ts +1 -1
  275. package/src/modules/api_keys/services/apiKeyService.ts +5 -5
  276. package/src/modules/attachments/api/library/[id]/route.ts +1 -1
  277. package/src/modules/attachments/api/library/route.ts +10 -12
  278. package/src/modules/attachments/api/partitions/route.ts +3 -3
  279. package/src/modules/attachments/api/route.ts +10 -8
  280. package/src/modules/attachments/api/transfer/route.ts +1 -1
  281. package/src/modules/attachments/data/entities.ts +2 -1
  282. package/src/modules/attachments/lib/ocrQueue.ts +1 -1
  283. package/src/modules/audit_logs/api/audit-logs/actions/export/route.ts +4 -4
  284. package/src/modules/audit_logs/api/audit-logs/actions/route.ts +4 -4
  285. package/src/modules/audit_logs/data/entities.ts +1 -1
  286. package/src/modules/audit_logs/services/actionLogService.ts +96 -87
  287. package/src/modules/auth/api/roles/acl/route.ts +1 -1
  288. package/src/modules/auth/api/users/acl/route.ts +2 -2
  289. package/src/modules/auth/api/users/resend-invite/route.ts +1 -1
  290. package/src/modules/auth/cli.ts +46 -40
  291. package/src/modules/auth/commands/users.ts +1 -1
  292. package/src/modules/auth/data/entities.ts +1 -1
  293. package/src/modules/auth/lib/setup-app.ts +3 -3
  294. package/src/modules/auth/services/authService.ts +2 -2
  295. package/src/modules/business_rules/api/rules/route.ts +3 -3
  296. package/src/modules/business_rules/api/sets/[id]/members/route.ts +7 -4
  297. package/src/modules/business_rules/api/sets/route.ts +3 -3
  298. package/src/modules/business_rules/cli.ts +1 -1
  299. package/src/modules/business_rules/data/entities.ts +2 -9
  300. package/src/modules/business_rules/lib/rule-engine.ts +1 -1
  301. package/src/modules/catalog/api/option-schemas/route.ts +0 -1
  302. package/src/modules/catalog/data/entities.ts +2 -11
  303. package/src/modules/configs/data/entities.ts +2 -1
  304. package/src/modules/currencies/commands/fetch-configs.ts +3 -3
  305. package/src/modules/currencies/data/entities.ts +1 -1
  306. package/src/modules/customer_accounts/api/signup.ts +1 -1
  307. package/src/modules/customer_accounts/data/entities.ts +1 -1
  308. package/src/modules/customer_accounts/services/customerInvitationService.ts +1 -1
  309. package/src/modules/customer_accounts/services/customerSessionService.ts +1 -1
  310. package/src/modules/customer_accounts/services/customerTokenService.ts +26 -15
  311. package/src/modules/customers/api/interactions/conflicts/route.ts +26 -23
  312. package/src/modules/customers/api/interactions/counts/route.ts +13 -11
  313. package/src/modules/customers/api/interactions/route.ts +32 -44
  314. package/src/modules/customers/api/utils.ts +45 -37
  315. package/src/modules/customers/cli.ts +88 -67
  316. package/src/modules/customers/commands/dictionaries.ts +1 -1
  317. package/src/modules/customers/commands/tags.ts +1 -1
  318. package/src/modules/customers/data/entities.ts +2 -12
  319. package/src/modules/customers/lib/interactionProjection.ts +36 -25
  320. package/src/modules/customers/lib/personCompanyLinkTable.ts +13 -18
  321. package/src/modules/dashboards/api/roles/widgets/route.ts +1 -1
  322. package/src/modules/dashboards/api/users/widgets/route.ts +1 -1
  323. package/src/modules/dashboards/data/entities.ts +1 -1
  324. package/src/modules/data_sync/api/mappings/route.ts +1 -1
  325. package/src/modules/data_sync/data/entities.ts +2 -1
  326. package/src/modules/data_sync/lib/id-mapping.ts +1 -1
  327. package/src/modules/data_sync/lib/sync-run-service.ts +1 -1
  328. package/src/modules/dictionaries/commands/factory.ts +1 -1
  329. package/src/modules/dictionaries/data/entities.ts +2 -9
  330. package/src/modules/directory/commands/organizations.ts +4 -4
  331. package/src/modules/directory/data/entities.ts +2 -1
  332. package/src/modules/entities/api/definitions.ts +2 -2
  333. package/src/modules/entities/api/encryption.ts +2 -2
  334. package/src/modules/entities/api/relations/options.ts +8 -3
  335. package/src/modules/entities/cli.ts +4 -4
  336. package/src/modules/entities/data/entities.ts +1 -1
  337. package/src/modules/entities/lib/field-definitions.ts +2 -2
  338. package/src/modules/entities/lib/register.ts +1 -1
  339. package/src/modules/feature_toggles/data/entities.ts +2 -9
  340. package/src/modules/inbox_ops/api/proposals/counts/route.ts +10 -10
  341. package/src/modules/inbox_ops/data/entities.ts +2 -8
  342. package/src/modules/inbox_ops/lib/messagesIntegration.ts +12 -11
  343. package/src/modules/integrations/data/entities.ts +2 -1
  344. package/src/modules/integrations/lib/credentials-service.ts +1 -1
  345. package/src/modules/integrations/lib/log-service.ts +1 -1
  346. package/src/modules/integrations/lib/state-service.ts +1 -1
  347. package/src/modules/messages/api/route.ts +134 -123
  348. package/src/modules/messages/api/unread-count/route.ts +19 -16
  349. package/src/modules/messages/commands/confirmations.ts +1 -1
  350. package/src/modules/messages/commands/messages.ts +3 -3
  351. package/src/modules/messages/data/entities.ts +2 -1
  352. package/src/modules/messages/lib/email-sender.ts +1 -1
  353. package/src/modules/messages/lib/searchLookup.ts +16 -13
  354. package/src/modules/messages/lib/tokenConsumption.ts +16 -8
  355. package/src/modules/notifications/data/entities.ts +2 -1
  356. package/src/modules/notifications/lib/notificationRecipients.ts +42 -26
  357. package/src/modules/notifications/lib/notificationService.ts +53 -42
  358. package/src/modules/notifications/workers/create-notification.worker.ts +20 -17
  359. package/src/modules/payment_gateways/api/transactions/route.ts +2 -2
  360. package/src/modules/payment_gateways/data/entities.ts +2 -1
  361. package/src/modules/payment_gateways/lib/gateway-service.ts +1 -1
  362. package/src/modules/payment_gateways/lib/webhook-utils.ts +2 -2
  363. package/src/modules/perspectives/data/entities.ts +1 -1
  364. package/src/modules/planner/data/entities.ts +1 -1
  365. package/src/modules/progress/data/entities.ts +2 -1
  366. package/src/modules/progress/lib/progressServiceImpl.ts +1 -1
  367. package/src/modules/query_index/api/status.ts +85 -71
  368. package/src/modules/query_index/cli.ts +51 -31
  369. package/src/modules/query_index/data/entities.ts +1 -1
  370. package/src/modules/query_index/di.ts +41 -16
  371. package/src/modules/query_index/lib/batch.ts +68 -55
  372. package/src/modules/query_index/lib/coverage.ts +115 -88
  373. package/src/modules/query_index/lib/engine.ts +1036 -1096
  374. package/src/modules/query_index/lib/indexer.ts +115 -79
  375. package/src/modules/query_index/lib/jobs.ts +51 -31
  376. package/src/modules/query_index/lib/purge.ts +25 -19
  377. package/src/modules/query_index/lib/reindexer.ts +97 -84
  378. package/src/modules/query_index/lib/search-tokens.ts +67 -36
  379. package/src/modules/query_index/lib/stale.ts +14 -17
  380. package/src/modules/query_index/lib/subscriber-scope.ts +6 -5
  381. package/src/modules/query_index/subscribers/delete_one.ts +9 -6
  382. package/src/modules/resources/commands/tag-assignments.ts +1 -1
  383. package/src/modules/resources/commands/tags.ts +1 -1
  384. package/src/modules/resources/data/entities.ts +2 -1
  385. package/src/modules/sales/commands/documentAddresses.ts +2 -2
  386. package/src/modules/sales/commands/notes.ts +1 -1
  387. package/src/modules/sales/commands/tags.ts +1 -1
  388. package/src/modules/sales/data/enrichers.ts +17 -13
  389. package/src/modules/sales/data/entities.ts +2 -11
  390. package/src/modules/shipping_carriers/data/entities.ts +2 -1
  391. package/src/modules/shipping_carriers/lib/shipping-service.ts +1 -1
  392. package/src/modules/shipping_carriers/lib/webhook-utils.ts +2 -2
  393. package/src/modules/staff/data/entities.ts +1 -1
  394. package/src/modules/translations/api/[entityType]/[entityId]/route.ts +14 -11
  395. package/src/modules/translations/api/context.ts +4 -4
  396. package/src/modules/translations/commands/translations.ts +116 -81
  397. package/src/modules/translations/components/TranslationManager.tsx +23 -14
  398. package/src/modules/translations/data/entities.ts +1 -1
  399. package/src/modules/translations/i18n/de.json +1 -0
  400. package/src/modules/translations/i18n/en.json +1 -0
  401. package/src/modules/translations/i18n/es.json +1 -0
  402. package/src/modules/translations/i18n/pl.json +1 -0
  403. package/src/modules/translations/lib/apply.ts +6 -6
  404. package/src/modules/translations/lib/batch.ts +9 -7
  405. package/src/modules/translations/subscribers/cleanup.ts +10 -11
  406. package/src/modules/workflows/api/definitions/route.ts +1 -1
  407. package/src/modules/workflows/cli.ts +5 -5
  408. package/src/modules/workflows/data/entities.ts +2 -1
  409. package/src/modules/workflows/lib/event-logger.ts +2 -2
  410. package/src/modules/workflows/lib/seeds.ts +16 -1
  411. package/src/modules/workflows/lib/step-handler.ts +3 -3
  412. package/src/modules/workflows/lib/task-handler.ts +1 -1
  413. package/src/modules/workflows/lib/transition-handler.ts +1 -1
  414. package/src/modules/workflows/lib/workflow-executor.ts +2 -2
@@ -104,7 +104,7 @@ export async function POST(req: Request) {
104
104
  : resolveDefaultAttachmentOcrEnabled(),
105
105
  ocrModel: parsed.data.ocrModel?.trim() || null,
106
106
  })
107
- await em.persistAndFlush(entry)
107
+ await em.persist(entry).flush()
108
108
  return NextResponse.json({ item: serializePartition(entry) }, { status: 201 })
109
109
  }
110
110
 
@@ -146,7 +146,7 @@ export async function PUT(req: Request) {
146
146
  if (parsed.data.ocrModel !== undefined) {
147
147
  entry.ocrModel = parsed.data.ocrModel?.trim() || null
148
148
  }
149
- await em.persistAndFlush(entry)
149
+ await em.persist(entry).flush()
150
150
  return NextResponse.json({ item: serializePartition(entry) })
151
151
  }
152
152
 
@@ -179,7 +179,7 @@ export async function DELETE(req: Request) {
179
179
  if (usage > 0) {
180
180
  return NextResponse.json({ error: 'Partition is in use and cannot be removed.' }, { status: 409 })
181
181
  }
182
- await em.removeAndFlush(entry)
182
+ await em.remove(entry).flush()
183
183
  return NextResponse.json({ ok: true })
184
184
  }
185
185
 
@@ -2,6 +2,7 @@ import { NextResponse } from 'next/server'
2
2
  import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
3
3
  import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
4
4
  import { z } from 'zod'
5
+ import { sql } from 'kysely'
5
6
  import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
6
7
  import { buildAttachmentFileUrl, buildAttachmentImageUrl, slugifyAttachmentFileName } from '../lib/imageUrls'
7
8
  import { ensureDefaultPartitions, resolveDefaultPartitionCode, sanitizePartitionCode } from '../lib/partitions'
@@ -429,7 +430,7 @@ export async function POST(req: Request) {
429
430
  content: extractedContent,
430
431
  storageMetadata: metadata,
431
432
  })
432
- await em.persistAndFlush(att)
433
+ await em.persist(att).flush()
433
434
 
434
435
  if (useLlmOcr) {
435
436
  requestOcrProcessing(em, att, stored.absolutePath).catch((error) => {
@@ -491,12 +492,13 @@ export async function POST(req: Request) {
491
492
 
492
493
  async function readTenantAttachmentUsageBytes(em: EntityManager, tenantId: string): Promise<number> {
493
494
  try {
494
- const knex = (em as any).getConnection().getKnex()
495
- const row = await knex('attachments')
496
- .where({ tenant_id: tenantId })
497
- .sum({ totalSize: 'file_size' })
498
- .first()
499
- const total = row?.totalSize
495
+ const db = em.getKysely<any>() as any
496
+ const row = await db
497
+ .selectFrom('attachments')
498
+ .select(sql<string>`sum(file_size)`.as('total_size'))
499
+ .where('tenant_id', '=', tenantId)
500
+ .executeTakeFirst() as { total_size: string | number | null } | undefined
501
+ const total = row?.total_size
500
502
  if (typeof total === 'number') return Number.isFinite(total) ? total : 0
501
503
  if (typeof total === 'string') {
502
504
  const parsed = Number(total)
@@ -520,7 +522,7 @@ export async function DELETE(req: Request) {
520
522
  const deleteFilter: Record<string, unknown> = { id, tenantId: auth.tenantId!, organizationId: auth.orgId }
521
523
  const record = await em.findOne(Attachment, deleteFilter)
522
524
  if (!record) return NextResponse.json({ error: 'Attachment not found' }, { status: 404 })
523
- await em.removeAndFlush(record)
525
+ await em.remove(record).flush()
524
526
  await clearAttachmentThumbnailCache(record.partitionCode, record.id).catch((error) => {
525
527
  console.error('[attachments] failed to cleanup cached thumbnails', error)
526
528
  })
@@ -72,7 +72,7 @@ export async function POST(req: Request) {
72
72
  }) ?? []
73
73
  record.storageMetadata = mergeAttachmentMetadata(record.storageMetadata, { assignments: nextAssignments })
74
74
  }
75
- await em.persistAndFlush(records)
75
+ await em.persist(records).flush()
76
76
  return NextResponse.json({ ok: true, updated: records.length })
77
77
  }
78
78
 
@@ -1,4 +1,5 @@
1
- import { Entity, Index, OptionalProps, PrimaryKey, Property, Unique } from '@mikro-orm/core'
1
+ import { OptionalProps } from '@mikro-orm/core'
2
+ import { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
2
3
  import { resolveDefaultAttachmentOcrEnabled } from '../lib/ocrConfig'
3
4
 
4
5
  @Entity({ tableName: 'attachment_partitions' })
@@ -49,7 +49,7 @@ export async function processAttachmentOcr(
49
49
  }
50
50
 
51
51
  attachment.content = result.content
52
- await em.persistAndFlush(attachment)
52
+ await em.persist(attachment).flush()
53
53
 
54
54
  console.log(`[attachments.ocr] Processing completed:`, {
55
55
  attachmentId,
@@ -178,12 +178,12 @@ export async function GET(req: Request) {
178
178
  const entries = entriesResult.items
179
179
 
180
180
  const displayMaps = await loadAuditLogDisplayMaps(em, {
181
- userIds: entries.map((entry) => entry.actorUserId).filter((value): value is string => Boolean(value)),
182
- tenantIds: entries.map((entry) => entry.tenantId).filter((value): value is string => Boolean(value)),
183
- organizationIds: entries.map((entry) => entry.organizationId).filter((value): value is string => Boolean(value)),
181
+ userIds: entries.map((entry: any) => entry.actorUserId).filter((value: any): value is string => Boolean(value)),
182
+ tenantIds: entries.map((entry: any) => entry.tenantId).filter((value: any): value is string => Boolean(value)),
183
+ organizationIds: entries.map((entry: any) => entry.organizationId).filter((value: any): value is string => Boolean(value)),
184
184
  })
185
185
 
186
- const rows = entries.flatMap((entry) => {
186
+ const rows = entries.flatMap((entry: any) => {
187
187
  const actionType = deriveActionLogActionType(entry)
188
188
  const actionLabel = actionType === 'system'
189
189
  ? entry.actionLabel ?? 'System'
@@ -229,12 +229,12 @@ export async function GET(req: Request) {
229
229
  const list = await actionLogs.list(listQuery)
230
230
 
231
231
  const displayMaps = await loadAuditLogDisplayMaps(em, {
232
- userIds: list.items.map((entry) => entry.actorUserId).filter((value): value is string => !!value),
233
- tenantIds: list.items.map((entry) => entry.tenantId).filter((value): value is string => !!value),
234
- organizationIds: list.items.map((entry) => entry.organizationId).filter((value): value is string => !!value),
232
+ userIds: list.items.map((entry: any) => entry.actorUserId).filter((value: any): value is string => !!value),
233
+ tenantIds: list.items.map((entry: any) => entry.tenantId).filter((value: any): value is string => !!value),
234
+ organizationIds: list.items.map((entry: any) => entry.organizationId).filter((value: any): value is string => !!value),
235
235
  })
236
236
 
237
- const items = list.items.map((entry) => ({
237
+ const items = list.items.map((entry: any) => ({
238
238
  id: entry.id,
239
239
  commandId: entry.commandId,
240
240
  actionLabel: entry.actionLabel,
@@ -1,4 +1,4 @@
1
- import { Entity, Index, PrimaryKey, Property } from '@mikro-orm/core'
1
+ import { Entity, Index, PrimaryKey, Property } from '@mikro-orm/decorators/legacy'
2
2
  import type { ActionLogProjectionType, ActionLogSourceKey } from '@open-mercato/core/modules/audit_logs/lib/projections'
3
3
 
4
4
  export type ActionLogExecutionState = 'done' | 'undone' | 'failed' | 'redone'
@@ -1,5 +1,6 @@
1
1
  import type { FilterQuery } from '@mikro-orm/core'
2
2
  import type { EntityManager } from '@mikro-orm/postgresql'
3
+ import { sql } from 'kysely'
3
4
  import { ActionLog } from '@open-mercato/core/modules/audit_logs/data/entities'
4
5
  import {
5
6
  actionLogCreateSchema,
@@ -184,7 +185,7 @@ export class ActionLogService {
184
185
  const data = this.parseCreateInput(input)
185
186
  const fork = this.em.fork()
186
187
  const log = this.createLogEntity(fork, data)
187
- await fork.persistAndFlush(log)
188
+ await fork.persist(log).flush()
188
189
  await this.decryptEntries(log)
189
190
  return log
190
191
  }
@@ -353,15 +354,15 @@ export class ActionLogService {
353
354
  }
354
355
 
355
356
  private async loadEntries(parsed: ActionLogListQuery, options?: { paginate?: boolean }) {
356
- const query = this.buildListQuery(parsed).select<{ id: string }[]>('action_logs.id as id')
357
+ let query = (this.buildListQuery(parsed) as any).select('action_logs.id as id')
357
358
 
358
359
  if (options?.paginate !== false) {
359
360
  const { limit, offset } = this.resolvePagination(parsed)
360
- query.limit(limit).offset(offset)
361
+ query = query.limit(limit).offset(offset)
361
362
  }
362
363
 
363
- const rows = await query
364
- const ids = rows.map((row) => row.id).filter(Boolean)
364
+ const rows = await query.execute()
365
+ const ids = rows.map((row: any) => row.id).filter(Boolean)
365
366
  if (ids.length === 0) return []
366
367
 
367
368
  const results = await this.em.find(ActionLog, {
@@ -370,90 +371,92 @@ export class ActionLogService {
370
371
  })
371
372
  await this.decryptEntries(results)
372
373
 
373
- const byId = new Map(results.map((entry) => [entry.id, entry]))
374
+ const byId = new Map(results.map((entry: any) => [entry.id, entry]))
374
375
  return ids
375
- .map((id) => byId.get(id))
376
- .filter((entry): entry is ActionLog => Boolean(entry))
376
+ .map((id: any) => byId.get(id))
377
+ .filter((entry: any): entry is ActionLog => Boolean(entry))
377
378
  }
378
379
 
379
- private buildListQuery(parsed: ActionLogListQuery) {
380
- const query = this.em.getKnex()('action_logs').whereNull('action_logs.deleted_at')
380
+ private buildListQuery(parsed: ActionLogListQuery): any {
381
+ let query = (this.em.getKysely<any>() as any)
382
+ .selectFrom('action_logs')
383
+ .selectAll()
384
+ .where('action_logs.deleted_at', 'is', null) as any
381
385
 
382
- if (parsed.tenantId) query.andWhere('action_logs.tenant_id', parsed.tenantId)
383
- if (parsed.organizationId) query.andWhere('action_logs.organization_id', parsed.organizationId)
386
+ if (parsed.tenantId) query = query.where('action_logs.tenant_id', '=', parsed.tenantId)
387
+ if (parsed.organizationId) query = query.where('action_logs.organization_id', '=', parsed.organizationId)
384
388
 
385
389
  const actorUserIds = this.resolveActorUserIds(parsed)
386
- if (actorUserIds.length === 1) query.andWhere('action_logs.actor_user_id', actorUserIds[0])
387
- if (actorUserIds.length > 1) query.whereIn('action_logs.actor_user_id', actorUserIds)
390
+ if (actorUserIds.length === 1) query = query.where('action_logs.actor_user_id', '=', actorUserIds[0])
391
+ if (actorUserIds.length > 1) query = query.where('action_logs.actor_user_id', 'in', actorUserIds)
388
392
 
389
393
  if (parsed.includeRelated && parsed.resourceKind && parsed.resourceId) {
390
- query.andWhere(function applyRelatedScope() {
391
- this.where({
392
- 'action_logs.resource_kind': parsed.resourceKind,
393
- 'action_logs.resource_id': parsed.resourceId,
394
- }).orWhere({
395
- 'action_logs.parent_resource_kind': parsed.resourceKind,
396
- 'action_logs.parent_resource_id': parsed.resourceId,
397
- })
398
- })
394
+ query = query.where((eb: any) =>
395
+ eb.or([
396
+ eb.and([
397
+ eb('action_logs.resource_kind', '=', parsed.resourceKind),
398
+ eb('action_logs.resource_id', '=', parsed.resourceId),
399
+ ]),
400
+ eb.and([
401
+ eb('action_logs.parent_resource_kind', '=', parsed.resourceKind),
402
+ eb('action_logs.parent_resource_id', '=', parsed.resourceId),
403
+ ]),
404
+ ])
405
+ )
399
406
  } else {
400
- if (parsed.resourceKind) query.andWhere('action_logs.resource_kind', parsed.resourceKind)
401
- if (parsed.resourceId) query.andWhere('action_logs.resource_id', parsed.resourceId)
407
+ if (parsed.resourceKind) query = query.where('action_logs.resource_kind', '=', parsed.resourceKind)
408
+ if (parsed.resourceId) query = query.where('action_logs.resource_id', '=', parsed.resourceId)
402
409
  }
403
410
 
404
- if (parsed.undoableOnly) query.whereNotNull('action_logs.undo_token')
405
- if (parsed.before) query.andWhere('action_logs.created_at', '<', parsed.before)
406
- if (parsed.after) query.andWhere('action_logs.created_at', '>', parsed.after)
411
+ if (parsed.undoableOnly) query = query.where('action_logs.undo_token', 'is not', null)
412
+ if (parsed.before) query = query.where('action_logs.created_at', '<', parsed.before)
413
+ if (parsed.after) query = query.where('action_logs.created_at', '>', parsed.after)
407
414
 
408
415
  const fieldNames = this.resolveFieldNames(parsed)
409
- if (fieldNames.length > 0) {
410
- const placeholders = fieldNames.map(() => '?').join(', ')
411
- query.andWhereRaw(
412
- `coalesce(action_logs.changed_fields, ARRAY[]::text[]) && ARRAY[${placeholders}]::text[]`,
413
- fieldNames,
414
- )
415
- }
416
+ if (fieldNames.length === 1) query = query.where('action_logs.primary_changed_field', '=', fieldNames[0])
417
+ if (fieldNames.length > 1) query = query.where('action_logs.primary_changed_field', 'in', fieldNames)
416
418
 
417
419
  const actionTypes = this.resolveActionTypes(parsed)
418
- if (actionTypes.length === 1) query.andWhere('action_logs.action_type', actionTypes[0])
419
- if (actionTypes.length > 1) query.whereIn('action_logs.action_type', actionTypes)
420
+ if (actionTypes.length === 1) query = query.where('action_logs.action_type', '=', actionTypes[0])
421
+ if (actionTypes.length > 1) query = query.where('action_logs.action_type', 'in', actionTypes)
420
422
 
421
423
  if (parsed.sortField === 'user') {
422
- query.leftJoin('users as audit_actor', 'audit_actor.id', 'action_logs.actor_user_id')
424
+ query = query.leftJoin('users as audit_actor', 'audit_actor.id', 'action_logs.actor_user_id')
423
425
  }
424
426
 
425
427
  const sortDir = parsed.sortDir === 'asc' ? 'asc' : 'desc'
426
428
  switch (parsed.sortField) {
427
429
  case 'user':
428
- query.orderByRaw(`coalesce(nullif(audit_actor.name, ''), audit_actor.email, '') ${sortDir}`)
430
+ query = query.orderBy(sql`coalesce(nullif(audit_actor.name, ''), audit_actor.email, '')`, sortDir)
429
431
  break
430
432
  case 'action':
431
- query.orderByRaw(`coalesce(action_logs.action_type, '') ${sortDir}`)
433
+ query = query.orderBy(sql`coalesce(action_logs.action_type, '')`, sortDir)
432
434
  break
433
435
  case 'field':
434
- query.orderByRaw(`coalesce(action_logs.primary_changed_field, '') ${sortDir}`)
436
+ query = query.orderBy(sql`coalesce(action_logs.primary_changed_field, '')`, sortDir)
435
437
  break
436
438
  case 'source':
437
- query.orderByRaw(`coalesce(action_logs.source_key, '') ${sortDir}`)
439
+ query = query.orderBy(sql`coalesce(action_logs.source_key, '')`, sortDir)
438
440
  break
439
441
  case 'createdAt':
440
442
  default:
441
- query.orderBy(SORT_FIELDS.createdAt, sortDir)
442
- query.orderBy('action_logs.id', sortDir)
443
+ query = query.orderBy(SORT_FIELDS.createdAt, sortDir)
444
+ query = query.orderBy('action_logs.id', sortDir)
443
445
  return query
444
446
  }
445
447
 
446
- query.orderBy('action_logs.created_at', 'desc')
447
- query.orderBy('action_logs.id', 'desc')
448
+ query = query.orderBy('action_logs.created_at', 'desc')
449
+ query = query.orderBy('action_logs.id', 'desc')
448
450
  return query
449
451
  }
450
452
 
451
453
  async count(query: Partial<ActionLogListQuery>) {
452
454
  const parsed = this.parseListQuery(query)
453
- const row = await this.buildListQuery(parsed)
454
- .clearOrder()
455
- .count<{ count: string | number }>({ count: '*' })
456
- .first()
455
+ const row = await (this.buildListQuery(parsed) as any)
456
+ .clearSelect()
457
+ .clearOrderBy()
458
+ .select(sql<string>`count(*)`.as('count'))
459
+ .executeTakeFirst()
457
460
 
458
461
  if (!row) return 0
459
462
  const rawCount = row.count ?? 0
@@ -579,45 +582,49 @@ export class ActionLogService {
579
582
  let cursorId: string | null = null
580
583
 
581
584
  while (true) {
582
- const rowsQuery = this.em.getKnex()<BackfillRow>('action_logs')
583
- .select(
584
- 'id',
585
- 'tenant_id',
586
- 'organization_id',
587
- 'actor_user_id',
588
- 'command_id',
589
- 'action_label',
590
- 'snapshot_before',
591
- 'changes_json',
592
- 'context_json',
593
- 'action_type',
594
- 'source_key',
595
- 'changed_fields',
596
- 'primary_changed_field',
597
- 'created_at',
598
- )
599
- .whereNull('deleted_at')
600
-
601
- if (options.tenantId) rowsQuery.andWhere('tenant_id', options.tenantId)
602
- if (options.organizationId) rowsQuery.andWhere('organization_id', options.organizationId)
585
+ const rowsQuery = (this.em.getKysely<any>() as any)
586
+ .selectFrom('action_logs')
587
+ .select([
588
+ 'action_logs.id',
589
+ 'action_logs.tenant_id',
590
+ 'action_logs.organization_id',
591
+ 'action_logs.actor_user_id',
592
+ 'action_logs.command_id',
593
+ 'action_logs.action_label',
594
+ 'action_logs.snapshot_before',
595
+ 'action_logs.changes_json',
596
+ 'action_logs.context_json',
597
+ 'action_logs.action_type',
598
+ 'action_logs.source_key',
599
+ 'action_logs.changed_fields',
600
+ 'action_logs.primary_changed_field',
601
+ 'action_logs.created_at',
602
+ ])
603
+ .where('action_logs.deleted_at', 'is', null) as any
604
+
605
+ if (options.tenantId) rowsQuery.where('action_logs.tenant_id', '=', options.tenantId)
606
+ if (options.organizationId) rowsQuery.where('action_logs.organization_id', '=', options.organizationId)
603
607
 
604
608
  if (!options.force) {
605
- rowsQuery.andWhere((builder) => {
606
- builder
607
- .whereNull('action_type')
608
- .orWhereNull('source_key')
609
- .orWhereNull('changed_fields')
610
- })
609
+ rowsQuery.where((eb: any) =>
610
+ eb.or([
611
+ eb('action_logs.action_type', 'is', null),
612
+ eb('action_logs.source_key', 'is', null),
613
+ eb('action_logs.changed_fields', 'is', null),
614
+ ])
615
+ )
611
616
  }
612
617
 
613
618
  if (cursorCreatedAt && cursorId) {
614
- rowsQuery.andWhere((builder) => {
615
- builder
616
- .where('created_at', '>', cursorCreatedAt)
617
- .orWhere((nested) => {
618
- nested.where('created_at', cursorCreatedAt).andWhere('id', '>', cursorId)
619
- })
620
- })
619
+ rowsQuery.where((eb: any) =>
620
+ eb.or([
621
+ eb('action_logs.created_at', '>', cursorCreatedAt),
622
+ eb.and([
623
+ eb('action_logs.created_at', '=', cursorCreatedAt),
624
+ eb('action_logs.id', '>', cursorId),
625
+ ]),
626
+ ])
627
+ )
621
628
  }
622
629
 
623
630
  const rows = await rowsQuery
@@ -652,14 +659,16 @@ export class ActionLogService {
652
659
  continue
653
660
  }
654
661
 
655
- await this.em.getKnex()('action_logs')
656
- .where({ id: row.id })
657
- .update({
662
+ await (this.em.getKysely<any>() as any)
663
+ .updateTable('action_logs')
664
+ .set({
658
665
  action_type: projection.actionType,
659
666
  changed_fields: projection.changedFields,
660
667
  primary_changed_field: projection.primaryChangedField,
661
668
  source_key: projection.sourceKey,
662
669
  })
670
+ .where('id', '=', row.id)
671
+ .execute()
663
672
 
664
673
  result.updated += 1
665
674
  } catch (err) {
@@ -170,7 +170,7 @@ export async function PUT(req: Request) {
170
170
  if (parsed.data.organizations !== undefined) acl.organizationsJson = parsed.data.organizations
171
171
  acl.isSuperAdmin = effectiveIsSuperAdmin
172
172
  acl.featuresJson = effectiveFeatures
173
- await em.persistAndFlush(acl)
173
+ await em.persist(acl).flush()
174
174
 
175
175
  // Invalidate cache for all users in this tenant since role ACL changed
176
176
  if (targetTenantId) {
@@ -111,7 +111,7 @@ export async function PUT(req: Request) {
111
111
  const hasCustomAcl = effectiveIsSuperAdmin || effectiveFeatures.length > 0
112
112
 
113
113
  if (!hasCustomAcl) {
114
- if (acl) await em.removeAndFlush(acl)
114
+ if (acl) await em.remove(acl).flush()
115
115
  } else {
116
116
  if (!acl) {
117
117
  acl = em.create(UserAcl, { user: parsed.data.userId as any, tenantId: auth.tenantId as any })
@@ -120,7 +120,7 @@ export async function PUT(req: Request) {
120
120
  aclRecord.isSuperAdmin = effectiveIsSuperAdmin
121
121
  aclRecord.featuresJson = effectiveFeatures
122
122
  aclRecord.organizationsJson = organizations
123
- await em.persistAndFlush(acl)
123
+ await em.persist(acl).flush()
124
124
  }
125
125
 
126
126
  // Invalidate cache for this user
@@ -129,7 +129,7 @@ export async function POST(req: Request) {
129
129
  const tokenHash = hashAuthToken(rawToken)
130
130
  const expiresAt = new Date(Date.now() + INVITE_TOKEN_TTL_MS)
131
131
  const row = em.create(PasswordReset, { user, token: tokenHash, expiresAt, createdAt: new Date() })
132
- await em.persistAndFlush(row)
132
+ await em.persist(row).flush()
133
133
 
134
134
  const inviteUrl = `${base}/reset/${rawToken}`
135
135