@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
@@ -59,17 +59,23 @@ const addUser: ModuleCli = {
59
59
  organizationId: org.id,
60
60
  tenantId: org.tenant.id,
61
61
  })
62
- await em.persistAndFlush(u)
62
+ await em.persist(u).flush()
63
63
  if (rolesCsv) {
64
64
  const names = rolesCsv.split(',').map(s => s.trim()).filter(Boolean)
65
65
  for (const name of names) {
66
66
  let role = await em.findOne(Role, { name, tenantId: normalizedTenantId })
67
+ if (!role && normalizedTenantId !== null) {
68
+ role = await em.findOne(Role, { name, tenantId: null })
69
+ }
67
70
  if (!role) {
68
71
  role = em.create(Role, { name, tenantId: normalizedTenantId, createdAt: new Date() })
69
- await em.persistAndFlush(role)
72
+ await em.persist(role).flush()
73
+ } else if (normalizedTenantId !== null && role.tenantId !== normalizedTenantId) {
74
+ role.tenantId = normalizedTenantId
75
+ await em.persist(role).flush()
70
76
  }
71
77
  const link = em.create(UserRole, { user: u, role })
72
- await em.persistAndFlush(link)
78
+ await em.persist(link).flush()
73
79
  }
74
80
  }
75
81
  console.log('User created with id', u.id)
@@ -280,16 +286,16 @@ const rotateEncryptionKey: ModuleCli = {
280
286
  const ids = pending.map((row: any) => String(row.id))
281
287
  const users = rotate
282
288
  ? await em.find(
283
- User,
284
- { id: { $in: ids }, tenantId: scopeTenantId, organizationId: scopeOrganizationId },
285
- )
289
+ User,
290
+ { id: { $in: ids }, tenantId: scopeTenantId, organizationId: scopeOrganizationId },
291
+ )
286
292
  : await findWithDecryption(
287
- em,
288
- User,
289
- { id: { $in: ids }, tenantId: scopeTenantId, organizationId: scopeOrganizationId },
290
- {},
291
- { tenantId: scopeTenantId, organizationId: scopeOrganizationId, encryptionService },
292
- )
293
+ em,
294
+ User,
295
+ { id: { $in: ids }, tenantId: scopeTenantId, organizationId: scopeOrganizationId },
296
+ {},
297
+ { tenantId: scopeTenantId, organizationId: scopeOrganizationId, encryptionService },
298
+ )
293
299
  const usersById = new Map(users.map((user) => [String(user.id), user]))
294
300
  let updated = 0
295
301
  for (const row of pending) {
@@ -389,9 +395,9 @@ const addOrganization: ModuleCli = {
389
395
  const em = resolve('em') as any
390
396
  // Create tenant implicitly for simplicity
391
397
  const tenant = em.create(Tenant, { name: `${name} Tenant` })
392
- await em.persistAndFlush(tenant)
398
+ await em.persist(tenant).flush()
393
399
  const org = em.create(Organization, { name, tenant })
394
- await em.persistAndFlush(org)
400
+ await em.persist(org).flush()
395
401
  await rebuildHierarchyForTenant(em, String(tenant.id))
396
402
  console.log('Organization created with id', org.id, 'in tenant', tenant.id)
397
403
  },
@@ -448,7 +454,7 @@ const setupApp: ModuleCli = {
448
454
  console.log('⚠️ Updated roles if missing and reused tenant/organization.')
449
455
  }
450
456
 
451
- if(env.NODE_ENV !== 'test') {
457
+ if (env.NODE_ENV !== 'test') {
452
458
  for (const snapshot of result.users) {
453
459
  if (snapshot.created) {
454
460
  if (snapshot.user.email === email && password) {
@@ -462,7 +468,7 @@ const setupApp: ModuleCli = {
462
468
  }
463
469
  }
464
470
 
465
- if(env.NODE_ENV !== 'test') console.log('✅ Setup complete:', { tenantId: result.tenantId, organizationId: result.organizationId })
471
+ if (env.NODE_ENV !== 'test') console.log('✅ Setup complete:', { tenantId: result.tenantId, organizationId: result.organizationId })
466
472
  } catch (err) {
467
473
  if (err instanceof Error && err.message === 'USER_EXISTS') {
468
474
  console.error('Setup aborted: user already exists with the provided email.')
@@ -485,17 +491,17 @@ const listOrganizations: ModuleCli = {
485
491
  { populate: ['tenant'] },
486
492
  { tenantId: null, organizationId: null },
487
493
  )
488
-
494
+
489
495
  if (orgs.length === 0) {
490
496
  console.log('No organizations found')
491
497
  return
492
498
  }
493
-
499
+
494
500
  console.log(`Found ${orgs.length} organization(s):`)
495
501
  console.log('')
496
502
  console.log('ID | Name | Tenant ID | Created')
497
503
  console.log('-------------------------------------|-------------------------|-------------------------------------|-------------------')
498
-
504
+
499
505
  for (const org of orgs) {
500
506
  const created = org.createdAt ? new Date(org.createdAt).toLocaleDateString() : 'N/A'
501
507
  const id = org.id || 'N/A'
@@ -512,17 +518,17 @@ const listTenants: ModuleCli = {
512
518
  const { resolve } = await createRequestContainer()
513
519
  const em = resolve('em') as any
514
520
  const tenants = await em.find(Tenant, {})
515
-
521
+
516
522
  if (tenants.length === 0) {
517
523
  console.log('No tenants found')
518
524
  return
519
525
  }
520
-
526
+
521
527
  console.log(`Found ${tenants.length} tenant(s):`)
522
528
  console.log('')
523
529
  console.log('ID | Name | Created')
524
530
  console.log('-------------------------------------|-------------------------|-------------------')
525
-
531
+
526
532
  for (const tenant of tenants) {
527
533
  const created = tenant.createdAt ? new Date(tenant.createdAt).toLocaleDateString() : 'N/A'
528
534
  const id = tenant.id || 'N/A'
@@ -541,10 +547,10 @@ const listUsers: ModuleCli = {
541
547
  const v = rest[i + 1]
542
548
  if (k) args[k] = v
543
549
  }
544
-
550
+
545
551
  const { resolve } = await createRequestContainer()
546
552
  const em = resolve('em') as any
547
-
553
+
548
554
  // Build query with optional filters
549
555
  const where: any = {}
550
556
  if (args.organizationId || args.orgId || args.org) {
@@ -553,19 +559,19 @@ const listUsers: ModuleCli = {
553
559
  if (args.tenantId || args.tenant) {
554
560
  where.tenantId = args.tenantId || args.tenant
555
561
  }
556
-
562
+
557
563
  const users = await em.find(User, where)
558
-
564
+
559
565
  if (users.length === 0) {
560
566
  console.log('No users found')
561
567
  return
562
568
  }
563
-
569
+
564
570
  console.log(`Found ${users.length} user(s):`)
565
571
  console.log('')
566
572
  console.log('ID | Email | Name | Organization ID | Tenant ID | Roles')
567
573
  console.log('-------------------------------------|-------------------------|-------------------------|---------------------|---------------------|-------------------')
568
-
574
+
569
575
  for (const user of users) {
570
576
  // Get user roles separately
571
577
  const userRoles = await findWithDecryption(
@@ -576,25 +582,25 @@ const listUsers: ModuleCli = {
576
582
  { tenantId: user.tenantId ?? null, organizationId: user.organizationId ?? null },
577
583
  )
578
584
  const roles = userRoles.map((ur: any) => ur.role?.name).filter(Boolean).join(', ') || 'None'
579
-
585
+
580
586
  // Get organization and tenant names if IDs exist
581
587
  let orgName = 'N/A'
582
588
  let tenantName = 'N/A'
583
-
589
+
584
590
  if (user.organizationId) {
585
591
  const org = await em.findOne(Organization, { id: user.organizationId })
586
592
  orgName = org?.name?.substring(0, 19) + '...' || user.organizationId.substring(0, 8) + '...'
587
593
  }
588
-
594
+
589
595
  if (user.tenantId) {
590
596
  const tenant = await em.findOne(Tenant, { id: user.tenantId })
591
597
  tenantName = tenant?.name?.substring(0, 19) + '...' || user.tenantId.substring(0, 8) + '...'
592
598
  }
593
-
599
+
594
600
  const id = user.id || 'N/A'
595
601
  const email = (user.email || 'N/A').padEnd(23)
596
602
  const name = (user.name || 'Unnamed').padEnd(23)
597
-
603
+
598
604
  console.log(`${id.padEnd(35)} | ${email} | ${name} | ${orgName.padEnd(19)} | ${tenantName.padEnd(19)} | ${roles}`)
599
605
  }
600
606
  },
@@ -609,29 +615,29 @@ const setPassword: ModuleCli = {
609
615
  const v = rest[i + 1]
610
616
  if (k) args[k] = v
611
617
  }
612
-
618
+
613
619
  const email = args.email
614
620
  const password = args.password
615
-
621
+
616
622
  if (!email || !password) {
617
623
  console.error('Usage: mercato auth set-password --email <email> --password <newPassword>')
618
624
  return
619
625
  }
620
626
  if (!ensurePasswordPolicy(password)) return
621
-
627
+
622
628
  const { resolve } = await createRequestContainer()
623
629
  const em = resolve('em') as any
624
630
  const emailHash = computeEmailHash(email)
625
631
  const user = await em.findOne(User, { $or: [{ email }, { emailHash }] })
626
-
632
+
627
633
  if (!user) {
628
634
  console.error(`User with email "${email}" not found`)
629
635
  return
630
636
  }
631
-
637
+
632
638
  user.passwordHash = await hash(password, 10)
633
- await em.persistAndFlush(user)
634
-
639
+ await em.persist(user).flush()
640
+
635
641
  console.log(`✅ Password updated successfully for user: ${email}`)
636
642
  },
637
643
  }
@@ -341,7 +341,7 @@ async function sendInviteToUser(
341
341
  const tokenHash = hashAuthToken(rawToken)
342
342
  const expiresAt = new Date(Date.now() + INVITE_TOKEN_TTL_MS)
343
343
  const row = em.create(PasswordReset, { user, token: tokenHash, expiresAt, createdAt: new Date() })
344
- await em.persistAndFlush(row)
344
+ await em.persist(row).flush()
345
345
 
346
346
  const base = getSecurityEmailBaseUrl()
347
347
  const inviteUrl = `${base}/reset/${rawToken}`
@@ -1,4 +1,4 @@
1
- import { Entity, PrimaryKey, Property, ManyToOne, Unique, Index } from '@mikro-orm/core'
1
+ import { Entity, Index, ManyToOne, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
2
2
 
3
3
  @Entity({ tableName: 'users' })
4
4
  export class User {
@@ -517,7 +517,7 @@ async function ensureRoleAclFor(
517
517
  isSuperAdmin: !!options.isSuperAdmin,
518
518
  createdAt: new Date(),
519
519
  })
520
- await em.persistAndFlush(acl)
520
+ await em.persist(acl).flush()
521
521
  return
522
522
  }
523
523
  const currentFeatures = Array.isArray(existing.featuresJson) ? existing.featuresJson : []
@@ -530,7 +530,7 @@ async function ensureRoleAclFor(
530
530
  existing.isSuperAdmin = true
531
531
  }
532
532
  if (changed || options.isSuperAdmin) {
533
- await em.persistAndFlush(existing)
533
+ await em.persist(existing).flush()
534
534
  }
535
535
  }
536
536
 
@@ -550,7 +550,7 @@ async function deactivateDemoSuperAdminIfSelfOnboardingEnabled(em: EntityManager
550
550
  dirty = true
551
551
  }
552
552
  if (dirty) {
553
- await em.persistAndFlush(user)
553
+ await em.persist(user).flush()
554
554
  }
555
555
  } catch (error) {
556
556
  console.error('[auth.setup] failed to deactivate demo superadmin user', error)
@@ -78,7 +78,7 @@ export class AuthService {
78
78
  const rawToken = generateAuthToken()
79
79
  const tokenHash = hashAuthToken(rawToken)
80
80
  const sess = this.em.create(Session as any, { user, token: tokenHash, expiresAt, createdAt: new Date() } as any)
81
- await this.em.persistAndFlush(sess)
81
+ await this.em.persist(sess).flush()
82
82
  return { session: sess as Session, token: rawToken }
83
83
  }
84
84
 
@@ -126,7 +126,7 @@ export class AuthService {
126
126
  const tokenHash = hashAuthToken(rawToken)
127
127
  const expiresAt = new Date(Date.now() + 60 * 60 * 1000)
128
128
  const row = this.em.create(PasswordReset as any, { user, token: tokenHash, expiresAt, createdAt: new Date() } as any)
129
- await this.em.persistAndFlush(row)
129
+ await this.em.persist(row).flush()
130
130
  return { user, token: rawToken }
131
131
  }
132
132
 
@@ -211,7 +211,7 @@ export async function POST(req: Request) {
211
211
  const rule = em.create(BusinessRule, data)
212
212
 
213
213
  try {
214
- await em.persistAndFlush(rule)
214
+ await em.persist(rule).flush()
215
215
  } catch (error) {
216
216
  console.error('[business_rules.rules] Failed to persist new rule:', error)
217
217
  return NextResponse.json(
@@ -273,7 +273,7 @@ export async function PUT(req: Request) {
273
273
  em.assign(rule, parsed.data)
274
274
 
275
275
  try {
276
- await em.persistAndFlush(rule)
276
+ await em.persist(rule).flush()
277
277
  } catch (error) {
278
278
  console.error('[business_rules.rules] Failed to persist rule update:', error)
279
279
  return NextResponse.json(
@@ -313,7 +313,7 @@ export async function DELETE(req: Request) {
313
313
  }
314
314
 
315
315
  rule.deletedAt = new Date()
316
- await em.persistAndFlush(rule)
316
+ await em.persist(rule).flush()
317
317
 
318
318
  return NextResponse.json({ ok: true })
319
319
  }
@@ -119,12 +119,15 @@ export async function POST(req: Request, ctx: { params?: { id?: string } }) {
119
119
  const validatedPayload = createRuleSetMemberSchema.parse(payload)
120
120
 
121
121
  const member = em.create(RuleSetMember, {
122
- ...validatedPayload,
122
+ sequence: validatedPayload.sequence,
123
+ enabled: validatedPayload.enabled,
124
+ tenantId: validatedPayload.tenantId,
125
+ organizationId: validatedPayload.organizationId,
123
126
  ruleSet: ruleSet,
124
127
  rule: rule,
125
128
  })
126
129
 
127
- await em.persistAndFlush(member)
130
+ await em.persist(member).flush()
128
131
 
129
132
  return NextResponse.json({ id: member.id }, { status: 201 })
130
133
  }
@@ -174,7 +177,7 @@ export async function PUT(req: Request, ctx: { params?: { id?: string } }) {
174
177
  member.enabled = parsed.data.enabled
175
178
  }
176
179
 
177
- await em.persistAndFlush(member)
180
+ await em.persist(member).flush()
178
181
 
179
182
  return NextResponse.json({ ok: true })
180
183
  }
@@ -211,7 +214,7 @@ export async function DELETE(req: Request, ctx: { params?: { id?: string } }) {
211
214
  return NextResponse.json({ error: 'Member not found' }, { status: 404 })
212
215
  }
213
216
 
214
- await em.removeAndFlush(member)
217
+ await em.remove(member).flush()
215
218
 
216
219
  return NextResponse.json({ ok: true })
217
220
  }
@@ -171,7 +171,7 @@ export async function POST(req: Request) {
171
171
  }
172
172
 
173
173
  const ruleSet = em.create(RuleSet, parsed.data)
174
- await em.persistAndFlush(ruleSet)
174
+ await em.persist(ruleSet).flush()
175
175
 
176
176
  return NextResponse.json({ id: ruleSet.id }, { status: 201 })
177
177
  }
@@ -222,7 +222,7 @@ export async function PUT(req: Request) {
222
222
  }
223
223
 
224
224
  em.assign(ruleSet, parsed.data)
225
- await em.persistAndFlush(ruleSet)
225
+ await em.persist(ruleSet).flush()
226
226
 
227
227
  return NextResponse.json({ ok: true })
228
228
  }
@@ -255,7 +255,7 @@ export async function DELETE(req: Request) {
255
255
  }
256
256
 
257
257
  ruleSet.deletedAt = new Date()
258
- await em.persistAndFlush(ruleSet)
258
+ await em.persist(ruleSet).flush()
259
259
 
260
260
  return NextResponse.json({ ok: true })
261
261
  }
@@ -69,7 +69,7 @@ const seedGuardRules: ModuleCli = {
69
69
  organizationId,
70
70
  })
71
71
 
72
- await em.persistAndFlush(rule)
72
+ await em.persist(rule).flush()
73
73
  console.log(` ✓ Seeded guard rule: ${rule.ruleName}`)
74
74
  seededCount++
75
75
  }
@@ -1,12 +1,5 @@
1
- import {
2
- Entity,
3
- PrimaryKey,
4
- Property,
5
- Index,
6
- Unique,
7
- OptionalProps,
8
- ManyToOne,
9
- } from '@mikro-orm/core'
1
+ import { OptionalProps } from '@mikro-orm/core'
2
+ import { Entity, Index, ManyToOne, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
10
3
 
11
4
  export type RuleType = 'GUARD' | 'VALIDATION' | 'CALCULATION' | 'ACTION' | 'ASSIGNMENT'
12
5
  export type ExecutionResult = 'SUCCESS' | 'FAILURE' | 'ERROR'
@@ -865,7 +865,7 @@ export async function logRuleExecution(
865
865
  executedBy: context.executedBy || null,
866
866
  })
867
867
 
868
- await em.persistAndFlush(log)
868
+ await em.persist(log).flush()
869
869
 
870
870
  return String(log.id)
871
871
  }
@@ -62,7 +62,6 @@ export async function buildOptionSchemaFilters(
62
62
  }
63
63
  const active = parseBooleanFlag(query.isActive)
64
64
  if (active !== undefined) filters.is_active = active
65
- if (!query.withDeleted) filters.deleted_at = null
66
65
  const tenantId = ctx.auth?.tenantId ?? null
67
66
  if (tenantId) {
68
67
  try {
@@ -1,14 +1,5 @@
1
- import {
2
- Collection,
3
- Entity,
4
- Index,
5
- ManyToOne,
6
- OneToMany,
7
- OptionalProps,
8
- PrimaryKey,
9
- Property,
10
- Unique,
11
- } from '@mikro-orm/core'
1
+ import { Collection, OptionalProps } from '@mikro-orm/core'
2
+ import { Entity, Index, ManyToOne, OneToMany, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
12
3
  import type {
13
4
  CatalogPriceDisplayMode,
14
5
  CatalogProductOptionSchema,
@@ -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
 
3
4
  @Entity({ tableName: 'module_configs' })
4
5
  @Unique({ name: 'module_configs_module_name_unique', properties: ['moduleId', 'name'] })
@@ -40,7 +40,7 @@ export async function createFetchConfig(
40
40
  updatedAt: new Date(),
41
41
  })
42
42
 
43
- await em.persistAndFlush(config)
43
+ await em.persist(config).flush()
44
44
  return config
45
45
  }
46
46
 
@@ -63,7 +63,7 @@ export async function updateFetchConfig(
63
63
  }
64
64
 
65
65
  em.assign(config, validated)
66
- await em.persistAndFlush(config)
66
+ await em.persist(config).flush()
67
67
 
68
68
  return config
69
69
  }
@@ -83,5 +83,5 @@ export async function deleteFetchConfig(
83
83
  throw new Error('Fetch config not found')
84
84
  }
85
85
 
86
- await em.removeAndFlush(config)
86
+ await em.remove(config).flush()
87
87
  }
@@ -1,4 +1,4 @@
1
- import { Entity, PrimaryKey, Property, Index, Unique } from '@mikro-orm/core'
1
+ import { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
2
2
 
3
3
  @Entity({ tableName: 'currencies' })
4
4
  @Index({
@@ -138,7 +138,7 @@ export async function POST(req: Request) {
138
138
  em.persist(userRole)
139
139
  }
140
140
 
141
- await em.persistAndFlush(user)
141
+ await em.persist(user).flush()
142
142
 
143
143
  const verificationToken = await customerTokenService.createEmailVerification(user.id, tenantId)
144
144
  const verifyUrl = resolvePortalVerifyUrl(baseUrl, verificationToken, orgRow.slug)
@@ -1,4 +1,4 @@
1
- import { Entity, PrimaryKey, Property, ManyToOne, Unique, Index } from '@mikro-orm/core'
1
+ import { Entity, Index, ManyToOne, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
2
2
 
3
3
  @Entity({ tableName: 'customer_users' })
4
4
  @Unique({ properties: ['tenantId', 'emailHash'], name: 'customer_users_tenant_email_hash_uniq' })
@@ -46,7 +46,7 @@ export class CustomerInvitationService {
46
46
  expiresAt,
47
47
  createdAt: new Date(),
48
48
  } as any) as CustomerUserInvitation
49
- await this.em.persistAndFlush(invitation)
49
+ await this.em.persist(invitation).flush()
50
50
  return { invitation, rawToken: token }
51
51
  }
52
52
 
@@ -43,7 +43,7 @@ export class CustomerSessionService {
43
43
  lastUsedAt: new Date(),
44
44
  createdAt: new Date(),
45
45
  } as any) as CustomerUserSession
46
- await this.em.persistAndFlush(session)
46
+ await this.em.persist(session).flush()
47
47
 
48
48
  const jwt = this.signCustomerJwt(user, resolvedFeatures, session.id)
49
49
 
@@ -1,4 +1,5 @@
1
1
  import { EntityManager } from '@mikro-orm/postgresql'
2
+ import type { Kysely } from 'kysely'
2
3
  import {
3
4
  CustomerUser,
4
5
  CustomerUserEmailVerification,
@@ -6,6 +7,10 @@ import {
6
7
  } from '@open-mercato/core/modules/customer_accounts/data/entities'
7
8
  import { generateSecureToken, hashToken } from '@open-mercato/core/modules/customer_accounts/lib/tokenGenerator'
8
9
 
10
+ function getKysely(em: EntityManager): Kysely<any> {
11
+ return (em as unknown as { getKysely: () => Kysely<any> }).getKysely()
12
+ }
13
+
9
14
  const EMAIL_VERIFICATION_TTL_MS = 24 * 60 * 60 * 1000 // 24 hours
10
15
  const MAGIC_LINK_TTL_MS = 15 * 60 * 1000 // 15 minutes
11
16
  const PASSWORD_RESET_TTL_MS = 60 * 60 * 1000 // 60 minutes
@@ -24,7 +29,7 @@ export class CustomerTokenService {
24
29
  expiresAt,
25
30
  createdAt: new Date(),
26
31
  } as any)
27
- await this.em.persistAndFlush(record)
32
+ await this.em.persist(record).flush()
28
33
  return rawToken
29
34
  }
30
35
 
@@ -39,7 +44,7 @@ export class CustomerTokenService {
39
44
  expiresAt,
40
45
  createdAt: new Date(),
41
46
  } as any)
42
- await this.em.persistAndFlush(record)
47
+ await this.em.persist(record).flush()
43
48
  return rawToken
44
49
  }
45
50
 
@@ -53,7 +58,7 @@ export class CustomerTokenService {
53
58
  expiresAt,
54
59
  createdAt: new Date(),
55
60
  } as any)
56
- await this.em.persistAndFlush(record)
61
+ await this.em.persist(record).flush()
57
62
  return rawToken
58
63
  }
59
64
 
@@ -70,12 +75,15 @@ export class CustomerTokenService {
70
75
  const user = record.user as CustomerUser
71
76
  if (tenantId && user?.tenantId !== tenantId) return null
72
77
 
73
- const knex = this.em.getKnex()
74
- const consumed = await knex('customer_user_email_verifications')
75
- .where('id', record.id)
76
- .whereNull('used_at')
77
- .where('expires_at', '>', new Date())
78
- .update({ used_at: new Date() })
78
+ const db = getKysely(this.em)
79
+ const updateResult = await db
80
+ .updateTable('customer_user_email_verifications' as any)
81
+ .set({ used_at: new Date() } as any)
82
+ .where('id' as any, '=', record.id)
83
+ .where('used_at' as any, 'is', null)
84
+ .where('expires_at' as any, '>', new Date())
85
+ .executeTakeFirst()
86
+ const consumed = Number(updateResult?.numUpdatedRows ?? 0n)
79
87
  if (consumed === 0) return null
80
88
 
81
89
  const resolvedUserId = typeof user === 'string' ? user : user.id
@@ -95,12 +103,15 @@ export class CustomerTokenService {
95
103
  const user = record.user as CustomerUser
96
104
  if (tenantId && user?.tenantId !== tenantId) return null
97
105
 
98
- const knex = this.em.getKnex()
99
- const consumed = await knex('customer_user_password_resets')
100
- .where('id', record.id)
101
- .whereNull('used_at')
102
- .where('expires_at', '>', new Date())
103
- .update({ used_at: new Date() })
106
+ const db = getKysely(this.em)
107
+ const updateResult = await db
108
+ .updateTable('customer_user_password_resets' as any)
109
+ .set({ used_at: new Date() } as any)
110
+ .where('id' as any, '=', record.id)
111
+ .where('used_at' as any, 'is', null)
112
+ .where('expires_at' as any, '>', new Date())
113
+ .executeTakeFirst()
114
+ const consumed = Number(updateResult?.numUpdatedRows ?? 0n)
104
115
  if (consumed === 0) return null
105
116
 
106
117
  const resolvedUserId = typeof user === 'string' ? user : user.id