@open-mercato/core 0.5.1-develop.2691.d8a0934b37 → 0.5.1-develop.2699.f8b50c8046

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
@@ -1,3 +1,4 @@
1
+ import { sql } from "kysely";
1
2
  const metadata = { event: "query_index.delete_one", persistent: false };
2
3
  async function handle(payload, ctx) {
3
4
  const entityType = String(payload?.entityType || "");
@@ -7,11 +8,8 @@ async function handle(payload, ctx) {
7
8
  const tenantId = payload?.tenantId ?? null;
8
9
  try {
9
10
  const em = ctx.resolve("em");
10
- const knex = em.getConnection().getKnex();
11
- await knex("entity_translations").where({
12
- entity_type: entityType,
13
- entity_id: recordId
14
- }).andWhereRaw("tenant_id is not distinct from ?", [tenantId]).andWhereRaw("organization_id is not distinct from ?", [organizationId]).del();
11
+ const db = em.getKysely();
12
+ await db.deleteFrom("entity_translations").where("entity_type", "=", entityType).where("entity_id", "=", recordId).where(sql`tenant_id is not distinct from ${tenantId}`).where(sql`organization_id is not distinct from ${organizationId}`).execute();
15
13
  } catch (err) {
16
14
  console.warn("[translations/cleanup] Failed to delete translations:", err instanceof Error ? err.message : "unknown");
17
15
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/translations/subscribers/cleanup.ts"],
4
- "sourcesContent": ["import type { Knex } from 'knex'\n\nexport const metadata = { event: 'query_index.delete_one', persistent: false }\n\nexport default async function handle(\n payload: { entityType?: string; recordId?: string; organizationId?: string | null; tenantId?: string | null },\n ctx: { resolve: <T = unknown>(name: string) => T },\n) {\n const entityType = String(payload?.entityType || '')\n const recordId = String(payload?.recordId || '')\n if (!entityType || !recordId) return\n\n const organizationId = payload?.organizationId ?? null\n const tenantId = payload?.tenantId ?? null\n\n try {\n const em = ctx.resolve<{ getConnection(): { getKnex(): Knex } }>('em')\n const knex = em.getConnection().getKnex()\n await knex('entity_translations')\n .where({\n entity_type: entityType,\n entity_id: recordId,\n })\n .andWhereRaw('tenant_id is not distinct from ?', [tenantId])\n .andWhereRaw('organization_id is not distinct from ?', [organizationId])\n .del()\n } catch (err) {\n console.warn('[translations/cleanup] Failed to delete translations:', err instanceof Error ? err.message : 'unknown')\n }\n}\n"],
5
- "mappings": "AAEO,MAAM,WAAW,EAAE,OAAO,0BAA0B,YAAY,MAAM;AAE7E,eAAO,OACL,SACA,KACA;AACA,QAAM,aAAa,OAAO,SAAS,cAAc,EAAE;AACnD,QAAM,WAAW,OAAO,SAAS,YAAY,EAAE;AAC/C,MAAI,CAAC,cAAc,CAAC,SAAU;AAE9B,QAAM,iBAAiB,SAAS,kBAAkB;AAClD,QAAM,WAAW,SAAS,YAAY;AAEtC,MAAI;AACF,UAAM,KAAK,IAAI,QAAkD,IAAI;AACrE,UAAM,OAAO,GAAG,cAAc,EAAE,QAAQ;AACxC,UAAM,KAAK,qBAAqB,EAC7B,MAAM;AAAA,MACL,aAAa;AAAA,MACb,WAAW;AAAA,IACb,CAAC,EACA,YAAY,oCAAoC,CAAC,QAAQ,CAAC,EAC1D,YAAY,0CAA0C,CAAC,cAAc,CAAC,EACtE,IAAI;AAAA,EACT,SAAS,KAAK;AACZ,YAAQ,KAAK,yDAAyD,eAAe,QAAQ,IAAI,UAAU,SAAS;AAAA,EACtH;AACF;",
4
+ "sourcesContent": ["import { type Kysely, sql } from 'kysely'\n\nexport const metadata = { event: 'query_index.delete_one', persistent: false }\n\nexport default async function handle(\n payload: { entityType?: string; recordId?: string; organizationId?: string | null; tenantId?: string | null },\n ctx: { resolve: <T = unknown>(name: string) => T },\n) {\n const entityType = String(payload?.entityType || '')\n const recordId = String(payload?.recordId || '')\n if (!entityType || !recordId) return\n\n const organizationId = payload?.organizationId ?? null\n const tenantId = payload?.tenantId ?? null\n\n try {\n const em = ctx.resolve<{ getKysely<T = any>(): Kysely<T> }>('em')\n const db = em.getKysely<any>() as any\n await db\n .deleteFrom('entity_translations')\n .where('entity_type', '=', entityType)\n .where('entity_id', '=', recordId)\n .where(sql<boolean>`tenant_id is not distinct from ${tenantId}`)\n .where(sql<boolean>`organization_id is not distinct from ${organizationId}`)\n .execute()\n } catch (err) {\n console.warn('[translations/cleanup] Failed to delete translations:', err instanceof Error ? err.message : 'unknown')\n }\n}\n"],
5
+ "mappings": "AAAA,SAAsB,WAAW;AAE1B,MAAM,WAAW,EAAE,OAAO,0BAA0B,YAAY,MAAM;AAE7E,eAAO,OACL,SACA,KACA;AACA,QAAM,aAAa,OAAO,SAAS,cAAc,EAAE;AACnD,QAAM,WAAW,OAAO,SAAS,YAAY,EAAE;AAC/C,MAAI,CAAC,cAAc,CAAC,SAAU;AAE9B,QAAM,iBAAiB,SAAS,kBAAkB;AAClD,QAAM,WAAW,SAAS,YAAY;AAEtC,MAAI;AACF,UAAM,KAAK,IAAI,QAA6C,IAAI;AAChE,UAAM,KAAK,GAAG,UAAe;AAC7B,UAAM,GACH,WAAW,qBAAqB,EAChC,MAAM,eAAe,KAAK,UAAU,EACpC,MAAM,aAAa,KAAK,QAAQ,EAChC,MAAM,qCAA8C,QAAQ,EAAE,EAC9D,MAAM,2CAAoD,cAAc,EAAE,EAC1E,QAAQ;AAAA,EACb,SAAS,KAAK;AACZ,YAAQ,KAAK,yDAAyD,eAAe,QAAQ,IAAI,UAAU,SAAS;AAAA,EACtH;AACF;",
6
6
  "names": []
7
7
  }
@@ -154,7 +154,7 @@ async function POST(request) {
154
154
  createdAt: /* @__PURE__ */ new Date(),
155
155
  updatedAt: /* @__PURE__ */ new Date()
156
156
  });
157
- await em.persistAndFlush(definition);
157
+ await em.persist(definition).flush();
158
158
  return NextResponse.json(
159
159
  {
160
160
  data: serializeWorkflowDefinition(definition),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/workflows/api/definitions/route.ts"],
4
- "sourcesContent": ["/**\n * Workflow Definitions API\n *\n * Endpoints:\n * - GET /api/workflows/definitions - List workflow definitions\n * - POST /api/workflows/definitions - Create workflow definition\n */\n\nimport { NextRequest, NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'\nimport { resolveOrganizationScopeFilter } from '@open-mercato/core/modules/directory/utils/organizationScopeFilter'\nimport { WorkflowDefinition } from '../../data/entities'\nimport {\n createWorkflowDefinitionInputSchema,\n type CreateWorkflowDefinitionApiInput,\n} from '../../data/validators'\nimport { serializeWorkflowDefinition } from './serialize'\n\nexport const metadata = {\n requireAuth: true,\n requireFeatures: ['workflows.definitions.view'],\n}\n\nconst WORKFLOW_ID_TENANT_UNIQUE_CONSTRAINT = 'workflow_definitions_workflow_id_tenant_id_unique'\n\nfunction isWorkflowIdUniqueConstraintError(error: unknown): boolean {\n if (!error || typeof error !== 'object') {\n return false\n }\n\n const value = error as Record<string, unknown>\n const constraint = value.constraint\n const code = value.code\n const message = typeof value.message === 'string' ? value.message : ''\n const detail = typeof value.detail === 'string' ? value.detail : ''\n\n if (constraint === WORKFLOW_ID_TENANT_UNIQUE_CONSTRAINT) {\n return true\n }\n\n if (code === '23505' && detail.includes('(workflow_id, tenant_id)')) {\n return true\n }\n\n return message.includes(WORKFLOW_ID_TENANT_UNIQUE_CONSTRAINT)\n}\n\n/**\n * GET /api/workflows/definitions\n *\n * List workflow definitions with optional filters\n */\nexport async function GET(request: NextRequest) {\n try {\n const container = await createRequestContainer()\n const em = container.resolve('em')\n const auth = await getAuthFromRequest(request)\n\n if (!auth) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request })\n const tenantId = auth.tenantId\n const orgFilter = resolveOrganizationScopeFilter(scope, auth)\n\n const { searchParams } = new URL(request.url)\n const enabled = searchParams.get('enabled')\n const workflowId = searchParams.get('workflowId')\n const search = searchParams.get('search')\n const limit = parseInt(searchParams.get('limit') || '50')\n const offset = parseInt(searchParams.get('offset') || '0')\n\n // Build where clause with tenant scoping\n const where: any = {\n tenantId,\n ...orgFilter.where,\n deletedAt: null,\n }\n\n if (enabled !== null) {\n where.enabled = enabled === 'true'\n }\n\n if (workflowId) {\n where.workflowId = workflowId\n }\n\n if (search) {\n where.$or = [\n { workflowId: { $ilike: `%${search}%` } },\n { workflowName: { $ilike: `%${search}%` } },\n ]\n }\n\n const [definitions, total] = await em.findAndCount(\n WorkflowDefinition,\n where,\n {\n orderBy: { createdAt: 'DESC' },\n limit,\n offset,\n }\n )\n\n return NextResponse.json({\n data: definitions.map(serializeWorkflowDefinition),\n pagination: {\n total,\n limit,\n offset,\n hasMore: offset + limit < total,\n },\n })\n } catch (error) {\n console.error('Error listing workflow definitions:', error)\n return NextResponse.json(\n { error: 'Failed to list workflow definitions' },\n { status: 500 }\n )\n }\n}\n\n/**\n * POST /api/workflows/definitions\n *\n * Create a new workflow definition\n */\nexport async function POST(request: NextRequest) {\n try {\n const container = await createRequestContainer()\n const em = container.resolve('em')\n const auth = await getAuthFromRequest(request)\n\n if (!auth) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request })\n const tenantId = auth.tenantId\n const organizationId = scope?.selectedId ?? auth.orgId\n\n // Check create permission\n const rbacService = container.resolve('rbacService')\n const hasPermission = await rbacService.userHasAllFeatures(\n auth.sub,\n ['workflows.definitions.create'],\n {\n tenantId,\n organizationId,\n }\n )\n\n if (!hasPermission) {\n return NextResponse.json(\n { error: 'Insufficient permissions' },\n { status: 403 }\n )\n }\n\n const body = await request.json()\n\n // Validate input\n const validation = createWorkflowDefinitionInputSchema.safeParse(body)\n if (!validation.success) {\n return NextResponse.json(\n {\n error: 'Validation failed',\n details: validation.error.issues,\n },\n { status: 400 }\n )\n }\n\n const input: CreateWorkflowDefinitionApiInput = validation.data\n\n // workflow_id is unique per tenant; check upfront to return 409 instead of DB error.\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: input.workflowId,\n tenantId,\n })\n\n if (existing) {\n return NextResponse.json(\n {\n error: `Workflow definition with ID \"${input.workflowId}\" already exists`,\n },\n { status: 409 }\n )\n }\n\n // Create workflow definition\n const definition = em.create(WorkflowDefinition, {\n workflowId: input.workflowId,\n workflowName: input.workflowName,\n description: input.description,\n version: input.version,\n definition: input.definition,\n metadata: input.metadata,\n enabled: input.enabled ?? true,\n tenantId,\n organizationId,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n\n await em.persistAndFlush(definition)\n\n return NextResponse.json(\n {\n data: serializeWorkflowDefinition(definition),\n message: 'Workflow definition created successfully',\n },\n { status: 201 }\n )\n } catch (error) {\n if (isWorkflowIdUniqueConstraintError(error)) {\n return NextResponse.json(\n { error: 'Workflow definition with this ID already exists' },\n { status: 409 }\n )\n }\n\n console.error('Error creating workflow definition:', error)\n return NextResponse.json(\n { error: 'Failed to create workflow definition' },\n { status: 500 }\n )\n }\n}\n\nexport const openApi = {\n methods: {\n GET: {\n summary: 'List workflow definitions',\n description: 'Get a list of workflow definitions with optional filters. Supports pagination and search.',\n tags: ['Workflows'],\n query: createWorkflowDefinitionInputSchema.pick({ workflowId: true }).extend({\n enabled: z.boolean().optional(),\n search: z.string().optional(),\n limit: z.number().int().positive().default(50).optional(),\n offset: z.number().int().min(0).default(0).optional(),\n }),\n responses: [\n {\n status: 200,\n description: 'List of workflow definitions with pagination',\n example: {\n data: [\n {\n id: '123e4567-e89b-12d3-a456-426614174000',\n workflowId: 'checkout-flow',\n workflowName: 'Checkout Flow',\n description: 'Complete checkout workflow for processing orders',\n version: 1,\n definition: {\n steps: [\n {\n stepId: 'start',\n stepName: 'Start',\n stepType: 'START',\n },\n {\n stepId: 'validate-cart',\n stepName: 'Validate Cart',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'end',\n stepName: 'End',\n stepType: 'END',\n },\n ],\n transitions: [\n {\n transitionId: 'start-to-validate',\n fromStepId: 'start',\n toStepId: 'validate-cart',\n trigger: 'auto',\n },\n {\n transitionId: 'validate-to-end',\n fromStepId: 'validate-cart',\n toStepId: 'end',\n trigger: 'auto',\n },\n ],\n },\n enabled: true,\n tenantId: '123e4567-e89b-12d3-a456-426614174001',\n organizationId: '123e4567-e89b-12d3-a456-426614174002',\n createdAt: '2025-12-08T10:00:00.000Z',\n updatedAt: '2025-12-08T10:00:00.000Z',\n },\n ],\n pagination: {\n total: 1,\n limit: 50,\n offset: 0,\n hasMore: false,\n },\n },\n },\n ],\n },\n POST: {\n summary: 'Create workflow definition',\n description: 'Create a new workflow definition. The definition must include at least START and END steps with at least one transition connecting them.',\n tags: ['Workflows'],\n requestBody: {\n schema: createWorkflowDefinitionInputSchema,\n example: {\n workflowId: 'checkout-flow',\n workflowName: 'Checkout Flow',\n description: 'Complete checkout workflow for processing orders',\n version: 1,\n definition: {\n steps: [\n {\n stepId: 'start',\n stepName: 'Start',\n stepType: 'START',\n },\n {\n stepId: 'validate-cart',\n stepName: 'Validate Cart',\n stepType: 'AUTOMATED',\n description: 'Validate cart items and check inventory',\n },\n {\n stepId: 'payment',\n stepName: 'Process Payment',\n stepType: 'AUTOMATED',\n description: 'Charge payment method',\n retryPolicy: {\n maxAttempts: 3,\n backoffMs: 1000,\n },\n },\n {\n stepId: 'end',\n stepName: 'End',\n stepType: 'END',\n },\n ],\n transitions: [\n {\n transitionId: 'start-to-validate',\n fromStepId: 'start',\n toStepId: 'validate-cart',\n trigger: 'auto',\n },\n {\n transitionId: 'validate-to-payment',\n fromStepId: 'validate-cart',\n toStepId: 'payment',\n trigger: 'auto',\n },\n {\n transitionId: 'payment-to-end',\n fromStepId: 'payment',\n toStepId: 'end',\n trigger: 'auto',\n activities: [\n {\n activityName: 'Send Order Confirmation',\n activityType: 'SEND_EMAIL',\n config: {\n to: '{{context.customerEmail}}',\n subject: 'Order Confirmation #{{context.orderId}}',\n template: 'order_confirmation',\n },\n },\n ],\n },\n ],\n },\n enabled: true,\n },\n },\n responses: [\n {\n status: 201,\n description: 'Workflow definition created successfully',\n example: {\n data: {\n id: '123e4567-e89b-12d3-a456-426614174000',\n workflowId: 'checkout-flow',\n workflowName: 'Checkout Flow',\n description: 'Complete checkout workflow for processing orders',\n version: 1,\n definition: {\n steps: [\n { stepId: 'start', stepName: 'Start', stepType: 'START' },\n {\n stepId: 'validate-cart',\n stepName: 'Validate Cart',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'payment',\n stepName: 'Process Payment',\n stepType: 'AUTOMATED',\n },\n { stepId: 'end', stepName: 'End', stepType: 'END' },\n ],\n transitions: [\n {\n transitionId: 'start-to-validate',\n fromStepId: 'start',\n toStepId: 'validate-cart',\n trigger: 'auto',\n },\n {\n transitionId: 'validate-to-payment',\n fromStepId: 'validate-cart',\n toStepId: 'payment',\n trigger: 'auto',\n },\n {\n transitionId: 'payment-to-end',\n fromStepId: 'payment',\n toStepId: 'end',\n trigger: 'auto',\n },\n ],\n },\n enabled: true,\n tenantId: '123e4567-e89b-12d3-a456-426614174001',\n organizationId: '123e4567-e89b-12d3-a456-426614174002',\n createdAt: '2025-12-08T10:00:00.000Z',\n updatedAt: '2025-12-08T10:00:00.000Z',\n },\n message: 'Workflow definition created successfully',\n },\n },\n {\n status: 400,\n description: 'Validation error - invalid workflow structure',\n example: {\n error: 'Validation failed',\n details: [\n {\n code: 'invalid_type',\n message: 'Workflow must have at least START and END steps',\n path: ['definition', 'steps'],\n },\n ],\n },\n },\n {\n status: 409,\n description: 'Conflict - workflow with same ID and version already exists',\n example: {\n error: 'Workflow definition with ID \"checkout-flow\" and version 1 already exists',\n },\n },\n ],\n },\n },\n}\n\n// Full OpenAPI documentation (kept for reference but not used by type system)\nexport const _openApiDetailedDocs = {\n get: {\n summary: 'List workflow definitions',\n description: 'Get a list of workflow definitions with optional filters',\n tags: ['Workflows'],\n parameters: [\n {\n name: 'enabled',\n in: 'query',\n description: 'Filter by enabled status',\n schema: { type: 'boolean' },\n },\n {\n name: 'workflowId',\n in: 'query',\n description: 'Filter by workflow ID',\n schema: { type: 'string' },\n },\n {\n name: 'search',\n in: 'query',\n description: 'Search in workflow ID and name',\n schema: { type: 'string' },\n },\n {\n name: 'limit',\n in: 'query',\n description: 'Number of results to return',\n schema: { type: 'integer', default: 50 },\n },\n {\n name: 'offset',\n in: 'query',\n description: 'Offset for pagination',\n schema: { type: 'integer', default: 0 },\n },\n ],\n responses: {\n 200: {\n description: 'List of workflow definitions',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: { $ref: '#/components/schemas/WorkflowDefinition' },\n },\n pagination: {\n type: 'object',\n properties: {\n total: { type: 'integer' },\n limit: { type: 'integer' },\n offset: { type: 'integer' },\n hasMore: { type: 'boolean' },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n post: {\n summary: 'Create workflow definition',\n description: 'Create a new workflow definition',\n tags: ['Workflows'],\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: { $ref: '#/components/schemas/CreateWorkflowDefinition' },\n },\n },\n },\n responses: {\n 201: {\n description: 'Workflow definition created',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n data: { $ref: '#/components/schemas/WorkflowDefinition' },\n message: { type: 'string' },\n },\n },\n },\n },\n },\n 400: {\n description: 'Validation error',\n },\n 409: {\n description: 'Workflow definition already exists',\n },\n },\n },\n}\n"],
5
- "mappings": "AAQA,SAAsB,oBAAoB;AAC1C,SAAS,SAAS;AAClB,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,SAAS,0CAA0C;AACnD,SAAS,sCAAsC;AAC/C,SAAS,0BAA0B;AACnC;AA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K;AAAA,QACH,aAAa;AAAA,MACf;AAAA,MACA,KAAK;AAAA,QACH,aAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/**\n * Workflow Definitions API\n *\n * Endpoints:\n * - GET /api/workflows/definitions - List workflow definitions\n * - POST /api/workflows/definitions - Create workflow definition\n */\n\nimport { NextRequest, NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'\nimport { resolveOrganizationScopeFilter } from '@open-mercato/core/modules/directory/utils/organizationScopeFilter'\nimport { WorkflowDefinition } from '../../data/entities'\nimport {\n createWorkflowDefinitionInputSchema,\n type CreateWorkflowDefinitionApiInput,\n} from '../../data/validators'\nimport { serializeWorkflowDefinition } from './serialize'\n\nexport const metadata = {\n requireAuth: true,\n requireFeatures: ['workflows.definitions.view'],\n}\n\nconst WORKFLOW_ID_TENANT_UNIQUE_CONSTRAINT = 'workflow_definitions_workflow_id_tenant_id_unique'\n\nfunction isWorkflowIdUniqueConstraintError(error: unknown): boolean {\n if (!error || typeof error !== 'object') {\n return false\n }\n\n const value = error as Record<string, unknown>\n const constraint = value.constraint\n const code = value.code\n const message = typeof value.message === 'string' ? value.message : ''\n const detail = typeof value.detail === 'string' ? value.detail : ''\n\n if (constraint === WORKFLOW_ID_TENANT_UNIQUE_CONSTRAINT) {\n return true\n }\n\n if (code === '23505' && detail.includes('(workflow_id, tenant_id)')) {\n return true\n }\n\n return message.includes(WORKFLOW_ID_TENANT_UNIQUE_CONSTRAINT)\n}\n\n/**\n * GET /api/workflows/definitions\n *\n * List workflow definitions with optional filters\n */\nexport async function GET(request: NextRequest) {\n try {\n const container = await createRequestContainer()\n const em = container.resolve('em')\n const auth = await getAuthFromRequest(request)\n\n if (!auth) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request })\n const tenantId = auth.tenantId\n const orgFilter = resolveOrganizationScopeFilter(scope, auth)\n\n const { searchParams } = new URL(request.url)\n const enabled = searchParams.get('enabled')\n const workflowId = searchParams.get('workflowId')\n const search = searchParams.get('search')\n const limit = parseInt(searchParams.get('limit') || '50')\n const offset = parseInt(searchParams.get('offset') || '0')\n\n // Build where clause with tenant scoping\n const where: any = {\n tenantId,\n ...orgFilter.where,\n deletedAt: null,\n }\n\n if (enabled !== null) {\n where.enabled = enabled === 'true'\n }\n\n if (workflowId) {\n where.workflowId = workflowId\n }\n\n if (search) {\n where.$or = [\n { workflowId: { $ilike: `%${search}%` } },\n { workflowName: { $ilike: `%${search}%` } },\n ]\n }\n\n const [definitions, total] = await em.findAndCount(\n WorkflowDefinition,\n where,\n {\n orderBy: { createdAt: 'DESC' },\n limit,\n offset,\n }\n )\n\n return NextResponse.json({\n data: definitions.map(serializeWorkflowDefinition),\n pagination: {\n total,\n limit,\n offset,\n hasMore: offset + limit < total,\n },\n })\n } catch (error) {\n console.error('Error listing workflow definitions:', error)\n return NextResponse.json(\n { error: 'Failed to list workflow definitions' },\n { status: 500 }\n )\n }\n}\n\n/**\n * POST /api/workflows/definitions\n *\n * Create a new workflow definition\n */\nexport async function POST(request: NextRequest) {\n try {\n const container = await createRequestContainer()\n const em = container.resolve('em')\n const auth = await getAuthFromRequest(request)\n\n if (!auth) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request })\n const tenantId = auth.tenantId\n const organizationId = scope?.selectedId ?? auth.orgId\n\n // Check create permission\n const rbacService = container.resolve('rbacService')\n const hasPermission = await rbacService.userHasAllFeatures(\n auth.sub,\n ['workflows.definitions.create'],\n {\n tenantId,\n organizationId,\n }\n )\n\n if (!hasPermission) {\n return NextResponse.json(\n { error: 'Insufficient permissions' },\n { status: 403 }\n )\n }\n\n const body = await request.json()\n\n // Validate input\n const validation = createWorkflowDefinitionInputSchema.safeParse(body)\n if (!validation.success) {\n return NextResponse.json(\n {\n error: 'Validation failed',\n details: validation.error.issues,\n },\n { status: 400 }\n )\n }\n\n const input: CreateWorkflowDefinitionApiInput = validation.data\n\n // workflow_id is unique per tenant; check upfront to return 409 instead of DB error.\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: input.workflowId,\n tenantId,\n })\n\n if (existing) {\n return NextResponse.json(\n {\n error: `Workflow definition with ID \"${input.workflowId}\" already exists`,\n },\n { status: 409 }\n )\n }\n\n // Create workflow definition\n const definition = em.create(WorkflowDefinition, {\n workflowId: input.workflowId,\n workflowName: input.workflowName,\n description: input.description,\n version: input.version,\n definition: input.definition,\n metadata: input.metadata,\n enabled: input.enabled ?? true,\n tenantId,\n organizationId,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n\n await em.persist(definition).flush()\n\n return NextResponse.json(\n {\n data: serializeWorkflowDefinition(definition),\n message: 'Workflow definition created successfully',\n },\n { status: 201 }\n )\n } catch (error) {\n if (isWorkflowIdUniqueConstraintError(error)) {\n return NextResponse.json(\n { error: 'Workflow definition with this ID already exists' },\n { status: 409 }\n )\n }\n\n console.error('Error creating workflow definition:', error)\n return NextResponse.json(\n { error: 'Failed to create workflow definition' },\n { status: 500 }\n )\n }\n}\n\nexport const openApi = {\n methods: {\n GET: {\n summary: 'List workflow definitions',\n description: 'Get a list of workflow definitions with optional filters. Supports pagination and search.',\n tags: ['Workflows'],\n query: createWorkflowDefinitionInputSchema.pick({ workflowId: true }).extend({\n enabled: z.boolean().optional(),\n search: z.string().optional(),\n limit: z.number().int().positive().default(50).optional(),\n offset: z.number().int().min(0).default(0).optional(),\n }),\n responses: [\n {\n status: 200,\n description: 'List of workflow definitions with pagination',\n example: {\n data: [\n {\n id: '123e4567-e89b-12d3-a456-426614174000',\n workflowId: 'checkout-flow',\n workflowName: 'Checkout Flow',\n description: 'Complete checkout workflow for processing orders',\n version: 1,\n definition: {\n steps: [\n {\n stepId: 'start',\n stepName: 'Start',\n stepType: 'START',\n },\n {\n stepId: 'validate-cart',\n stepName: 'Validate Cart',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'end',\n stepName: 'End',\n stepType: 'END',\n },\n ],\n transitions: [\n {\n transitionId: 'start-to-validate',\n fromStepId: 'start',\n toStepId: 'validate-cart',\n trigger: 'auto',\n },\n {\n transitionId: 'validate-to-end',\n fromStepId: 'validate-cart',\n toStepId: 'end',\n trigger: 'auto',\n },\n ],\n },\n enabled: true,\n tenantId: '123e4567-e89b-12d3-a456-426614174001',\n organizationId: '123e4567-e89b-12d3-a456-426614174002',\n createdAt: '2025-12-08T10:00:00.000Z',\n updatedAt: '2025-12-08T10:00:00.000Z',\n },\n ],\n pagination: {\n total: 1,\n limit: 50,\n offset: 0,\n hasMore: false,\n },\n },\n },\n ],\n },\n POST: {\n summary: 'Create workflow definition',\n description: 'Create a new workflow definition. The definition must include at least START and END steps with at least one transition connecting them.',\n tags: ['Workflows'],\n requestBody: {\n schema: createWorkflowDefinitionInputSchema,\n example: {\n workflowId: 'checkout-flow',\n workflowName: 'Checkout Flow',\n description: 'Complete checkout workflow for processing orders',\n version: 1,\n definition: {\n steps: [\n {\n stepId: 'start',\n stepName: 'Start',\n stepType: 'START',\n },\n {\n stepId: 'validate-cart',\n stepName: 'Validate Cart',\n stepType: 'AUTOMATED',\n description: 'Validate cart items and check inventory',\n },\n {\n stepId: 'payment',\n stepName: 'Process Payment',\n stepType: 'AUTOMATED',\n description: 'Charge payment method',\n retryPolicy: {\n maxAttempts: 3,\n backoffMs: 1000,\n },\n },\n {\n stepId: 'end',\n stepName: 'End',\n stepType: 'END',\n },\n ],\n transitions: [\n {\n transitionId: 'start-to-validate',\n fromStepId: 'start',\n toStepId: 'validate-cart',\n trigger: 'auto',\n },\n {\n transitionId: 'validate-to-payment',\n fromStepId: 'validate-cart',\n toStepId: 'payment',\n trigger: 'auto',\n },\n {\n transitionId: 'payment-to-end',\n fromStepId: 'payment',\n toStepId: 'end',\n trigger: 'auto',\n activities: [\n {\n activityName: 'Send Order Confirmation',\n activityType: 'SEND_EMAIL',\n config: {\n to: '{{context.customerEmail}}',\n subject: 'Order Confirmation #{{context.orderId}}',\n template: 'order_confirmation',\n },\n },\n ],\n },\n ],\n },\n enabled: true,\n },\n },\n responses: [\n {\n status: 201,\n description: 'Workflow definition created successfully',\n example: {\n data: {\n id: '123e4567-e89b-12d3-a456-426614174000',\n workflowId: 'checkout-flow',\n workflowName: 'Checkout Flow',\n description: 'Complete checkout workflow for processing orders',\n version: 1,\n definition: {\n steps: [\n { stepId: 'start', stepName: 'Start', stepType: 'START' },\n {\n stepId: 'validate-cart',\n stepName: 'Validate Cart',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'payment',\n stepName: 'Process Payment',\n stepType: 'AUTOMATED',\n },\n { stepId: 'end', stepName: 'End', stepType: 'END' },\n ],\n transitions: [\n {\n transitionId: 'start-to-validate',\n fromStepId: 'start',\n toStepId: 'validate-cart',\n trigger: 'auto',\n },\n {\n transitionId: 'validate-to-payment',\n fromStepId: 'validate-cart',\n toStepId: 'payment',\n trigger: 'auto',\n },\n {\n transitionId: 'payment-to-end',\n fromStepId: 'payment',\n toStepId: 'end',\n trigger: 'auto',\n },\n ],\n },\n enabled: true,\n tenantId: '123e4567-e89b-12d3-a456-426614174001',\n organizationId: '123e4567-e89b-12d3-a456-426614174002',\n createdAt: '2025-12-08T10:00:00.000Z',\n updatedAt: '2025-12-08T10:00:00.000Z',\n },\n message: 'Workflow definition created successfully',\n },\n },\n {\n status: 400,\n description: 'Validation error - invalid workflow structure',\n example: {\n error: 'Validation failed',\n details: [\n {\n code: 'invalid_type',\n message: 'Workflow must have at least START and END steps',\n path: ['definition', 'steps'],\n },\n ],\n },\n },\n {\n status: 409,\n description: 'Conflict - workflow with same ID and version already exists',\n example: {\n error: 'Workflow definition with ID \"checkout-flow\" and version 1 already exists',\n },\n },\n ],\n },\n },\n}\n\n// Full OpenAPI documentation (kept for reference but not used by type system)\nexport const _openApiDetailedDocs = {\n get: {\n summary: 'List workflow definitions',\n description: 'Get a list of workflow definitions with optional filters',\n tags: ['Workflows'],\n parameters: [\n {\n name: 'enabled',\n in: 'query',\n description: 'Filter by enabled status',\n schema: { type: 'boolean' },\n },\n {\n name: 'workflowId',\n in: 'query',\n description: 'Filter by workflow ID',\n schema: { type: 'string' },\n },\n {\n name: 'search',\n in: 'query',\n description: 'Search in workflow ID and name',\n schema: { type: 'string' },\n },\n {\n name: 'limit',\n in: 'query',\n description: 'Number of results to return',\n schema: { type: 'integer', default: 50 },\n },\n {\n name: 'offset',\n in: 'query',\n description: 'Offset for pagination',\n schema: { type: 'integer', default: 0 },\n },\n ],\n responses: {\n 200: {\n description: 'List of workflow definitions',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n data: {\n type: 'array',\n items: { $ref: '#/components/schemas/WorkflowDefinition' },\n },\n pagination: {\n type: 'object',\n properties: {\n total: { type: 'integer' },\n limit: { type: 'integer' },\n offset: { type: 'integer' },\n hasMore: { type: 'boolean' },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n post: {\n summary: 'Create workflow definition',\n description: 'Create a new workflow definition',\n tags: ['Workflows'],\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: { $ref: '#/components/schemas/CreateWorkflowDefinition' },\n },\n },\n },\n responses: {\n 201: {\n description: 'Workflow definition created',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n data: { $ref: '#/components/schemas/WorkflowDefinition' },\n message: { type: 'string' },\n },\n },\n },\n },\n },\n 400: {\n description: 'Validation error',\n },\n 409: {\n description: 'Workflow definition already exists',\n },\n },\n },\n}\n"],
5
+ "mappings": "AAQA,SAAsB,oBAAoB;AAC1C,SAAS,SAAS;AAClB,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,SAAS,0CAA0C;AACnD,SAAS,sCAAsC;AAC/C,SAAS,0BAA0B;AACnC;AAAA,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ACA,KAAK;AAAA,QACH,aAAa;AAAA,MACf;AAAA,MACA,KAAK;AAAA,QACH,aAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -48,7 +48,7 @@ const seedDemo = {
48
48
  tenantId,
49
49
  organizationId
50
50
  });
51
- await em.persistAndFlush(workflow);
51
+ await em.persist(workflow).flush();
52
52
  console.log(`\u2705 Seeded demo workflow: ${workflow.workflowName}`);
53
53
  console.log(` - ID: ${workflow.id}`);
54
54
  console.log(` - Workflow ID: ${workflow.workflowId}`);
@@ -109,7 +109,7 @@ const seedDemoWithRules = {
109
109
  tenantId,
110
110
  organizationId
111
111
  });
112
- await em.persistAndFlush(rule);
112
+ await em.persist(rule).flush();
113
113
  console.log(` \u2713 Seeded guard rule: ${rule.ruleName}`);
114
114
  seededCount++;
115
115
  }
@@ -153,7 +153,7 @@ const seedSalesPipeline = {
153
153
  tenantId,
154
154
  organizationId
155
155
  });
156
- await em.persistAndFlush(workflow);
156
+ await em.persist(workflow).flush();
157
157
  console.log(`\u2705 Seeded sales pipeline workflow: ${workflow.workflowName}`);
158
158
  console.log(` - ID: ${workflow.id}`);
159
159
  console.log(` - Workflow ID: ${workflow.workflowId}`);
@@ -198,7 +198,7 @@ const seedSimpleApproval = {
198
198
  tenantId,
199
199
  organizationId
200
200
  });
201
- await em.persistAndFlush(workflow);
201
+ await em.persist(workflow).flush();
202
202
  console.log(`\u2705 Seeded simple approval workflow: ${workflow.workflowName}`);
203
203
  console.log(` - ID: ${workflow.id}`);
204
204
  console.log(` - Workflow ID: ${workflow.workflowId}`);
@@ -270,7 +270,7 @@ const seedOrderApproval = {
270
270
  tenantId,
271
271
  organizationId
272
272
  });
273
- await em.persistAndFlush(workflow);
273
+ await em.persist(workflow).flush();
274
274
  console.log(`\u2705 Seeded order approval workflow: ${workflow.workflowName}`);
275
275
  console.log(` - ID: ${workflow.id}`);
276
276
  console.log(` - Workflow ID: ${workflow.workflowId}`);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/modules/workflows/cli.ts"],
4
- "sourcesContent": ["import type { ModuleCli } from '@open-mercato/shared/modules/registry'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { getRedisUrl, getRedisUrlOrThrow } from '@open-mercato/shared/lib/redis/connection'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { WorkflowDefinition } from './data/entities'\nimport { BusinessRule, type RuleType } from '@open-mercato/core/modules/business_rules/data/entities'\nimport * as fs from 'fs'\nimport * as path from 'path'\nimport { fileURLToPath } from 'url'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\n/**\n * Parse CLI arguments\n */\nfunction parseArgs(args: string[]) {\n const result: Record<string, string> = {}\n for (let i = 0; i < args.length; i += 2) {\n const key = args[i]?.replace(/^-+/, '') // Remove one or more dashes\n const value = args[i + 1]\n if (key && value) {\n result[key] = value\n }\n }\n return result\n}\n\n/**\n * Seed demo checkout workflow\n */\nconst seedDemo: ModuleCli = {\n command: 'seed-demo',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-demo --tenant <tenantId> --org <organizationId>')\n console.error(' or: mercato workflows seed-demo -t <tenantId> -o <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Read the demo workflow definition\n const demoPath = path.join(__dirname, 'examples', 'checkout-demo-definition.json')\n const demoData = JSON.parse(fs.readFileSync(demoPath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: demoData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2139\uFE0F Demo workflow '${demoData.workflowId}' already exists (ID: ${existing.id})`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...demoData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(workflow)\n\n console.log(`\u2705 Seeded demo workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log('')\n console.log('Demo workflow is ready! You can now:')\n console.log(' 1. View it in admin: /backend/definitions')\n console.log(' 2. Try the demo page: /checkout-demo')\n console.log(' 3. Start an instance via API: POST /api/workflows/instances')\n console.log('')\n console.log('Note: This workflow includes a USER_TASK step for customer information.')\n console.log('When the workflow reaches this step, it will pause and require user input.')\n console.log('Complete pending tasks at: /backend/tasks')\n } catch (error) {\n console.error('Error seeding demo workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed demo checkout workflow with guard rules\n */\nconst seedDemoWithRules: ModuleCli = {\n command: 'seed-demo-with-rules',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-demo-with-rules --tenant <tenantId> --org <organizationId>')\n console.error(' or: mercato workflows seed-demo-with-rules -t <tenantId> -o <organizationId>')\n return\n }\n\n console.log('\uD83E\uDDE9 Seeding demo workflow with guard rules...\\n')\n\n try {\n // Seed the workflow definition\n console.log('1. \uD83E\uDDE9 Seeding demo workflow...')\n await seedDemo.run(rest)\n\n // Seed the guard rules\n console.log('\\n2. \uD83E\uDDE0 Seeding guard rules...')\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Import BusinessRule entity\n const { BusinessRule } = await import('../business_rules/data/entities')\n\n // Read guard rules\n const rulesPath = path.join(__dirname, 'examples', 'guard-rules-example.json')\n const rulesData = JSON.parse(fs.readFileSync(rulesPath, 'utf8'))\n\n let seededCount = 0\n let skippedCount = 0\n\n for (const ruleData of rulesData) {\n const existing = await em.findOne(BusinessRule, {\n ruleId: ruleData.ruleId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(` \u2298 Guard rule '${ruleData.ruleId}' already exists`)\n skippedCount++\n continue\n }\n\n const rule = em.create(BusinessRule, {\n ...ruleData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(rule)\n console.log(` \u2713 Seeded guard rule: ${rule.ruleName}`)\n seededCount++\n }\n\n console.log(`\\n\u2705 Demo workflow with guard rules seeded successfully!`)\n console.log(` - Workflow: checkout_simple_v1`)\n console.log(` - Guard rules seeded: ${seededCount}`)\n console.log(` - Guard rules skipped: ${skippedCount}`)\n } catch (error) {\n console.error('Error seeding demo with rules:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed sales pipeline example\n */\nconst seedSalesPipeline: ModuleCli = {\n command: 'seed-sales-pipeline',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-sales-pipeline --tenant <tenantId> --org <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Read the sales pipeline workflow definition\n const pipelinePath = path.join(__dirname, 'examples', 'sales-pipeline-definition.json')\n const pipelineData = JSON.parse(fs.readFileSync(pipelinePath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: pipelineData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2139\uFE0F Sales pipeline workflow '${pipelineData.workflowId}' already exists (ID: ${existing.id})`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...pipelineData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(workflow)\n\n console.log(`\u2705 Seeded sales pipeline workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log(` - Activities: ${workflow.definition.transitions.reduce((sum, t) => sum + (t.activities?.length || 0), 0)}`)\n console.log('')\n console.log('Sales pipeline workflow is ready!')\n } catch (error) {\n console.error('Error seeding sales pipeline workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed simple approval example\n */\nconst seedSimpleApproval: ModuleCli = {\n command: 'seed-simple-approval',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-simple-approval --tenant <tenantId> --org <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Read the simple approval workflow definition\n const approvalPath = path.join(__dirname, 'examples', 'simple-approval-definition.json')\n const approvalData = JSON.parse(fs.readFileSync(approvalPath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: approvalData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2139\uFE0F Simple approval workflow '${approvalData.workflowId}' already exists (ID: ${existing.id})`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...approvalData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(workflow)\n\n console.log(`\u2705 Seeded simple approval workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log('')\n console.log('Simple approval workflow is ready!')\n } catch (error) {\n console.error('Error seeding simple approval workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed order approval example\n */\nconst seedOrderApproval: ModuleCli = {\n command: 'seed-order-approval',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-order-approval --tenant <tenantId> --org <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // 1. Seed order approval guard rules first\n const guardRulesPath = path.join(__dirname, 'examples', 'order-approval-guard-rules.json')\n const guardRulesData = JSON.parse(fs.readFileSync(guardRulesPath, 'utf8')) as Array<{\n ruleId: string\n ruleName: string\n ruleType: RuleType\n entityType: string\n description?: string\n eventType?: string\n conditionExpression?: Record<string, unknown>\n enabled?: boolean\n priority?: number\n }>\n\n let rulesSeeded = 0\n let rulesSkipped = 0\n for (const rule of guardRulesData) {\n const existingRule = await em.findOne(BusinessRule, {\n ruleId: rule.ruleId,\n tenantId,\n organizationId,\n })\n\n if (existingRule) {\n rulesSkipped++\n continue\n }\n\n const newRule = em.create(BusinessRule, {\n ...rule,\n tenantId,\n organizationId,\n })\n em.persist(newRule)\n console.log(` \u2713 Seeded guard rule: ${rule.ruleName}`)\n rulesSeeded++\n }\n\n if (rulesSeeded > 0) {\n await em.flush()\n }\n\n // 2. Read the order approval workflow definition\n const approvalPath = path.join(__dirname, 'examples', 'order-approval-definition.json')\n const approvalData = JSON.parse(fs.readFileSync(approvalPath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: approvalData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2705 Order approval workflow '${approvalData.workflowId}' already exists (ID: ${existing.id})`)\n console.log(` - Guard rules seeded: ${rulesSeeded}`)\n console.log(` - Guard rules skipped: ${rulesSkipped}`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...approvalData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(workflow)\n\n console.log(`\u2705 Seeded order approval workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log(` - Guard rules seeded: ${rulesSeeded}`)\n console.log(` - Guard rules skipped: ${rulesSkipped}`)\n console.log('')\n console.log('Order approval workflow is ready!')\n } catch (error) {\n console.error('Error seeding order approval workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Start workflow activity worker\n */\nconst startWorker: ModuleCli = {\n command: 'start-worker',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const concurrency = parseInt(args.concurrency ?? args.c ?? '5')\n\n const strategy = process.env.QUEUE_STRATEGY === 'async' ? 'async' : 'local'\n\n console.log('[Workflow Worker] Starting activity worker...')\n console.log(`[Workflow Worker] Strategy: ${strategy}`)\n\n if (strategy === 'local') {\n const pollMs = process.env.LOCAL_QUEUE_POLL_MS || '5000'\n console.log(`[Workflow Worker] Polling interval: ${pollMs}ms`)\n console.log('[Workflow Worker] NOTE: Local strategy is for development only.')\n console.log('[Workflow Worker] Use QUEUE_STRATEGY=async with Redis for production.')\n } else {\n console.log(`[Workflow Worker] Concurrency: ${concurrency}`)\n console.log(`[Workflow Worker] Redis: ${getRedisUrl('QUEUE') ?? '(not configured)'}`)\n }\n\n try {\n const container = await createRequestContainer()\n const em = container.resolve<EntityManager>('em')\n\n // Import queue and handler\n const { runWorker } = await import('@open-mercato/queue/worker')\n const { createActivityWorkerHandler } = await import('./lib/activity-worker-handler')\n const { WORKFLOW_ACTIVITIES_QUEUE_NAME } = await import('./lib/activity-queue-types')\n\n // Create handler\n const handler = createActivityWorkerHandler(em, container)\n\n // Run worker\n await runWorker({\n queueName: WORKFLOW_ACTIVITIES_QUEUE_NAME,\n handler,\n connection: strategy === 'async' ? {\n url: getRedisUrlOrThrow('QUEUE'),\n } : undefined,\n concurrency,\n gracefulShutdown: true,\n })\n } catch (error) {\n console.error('[Workflow Worker] Failed to start worker:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed all example workflows\n */\nconst seedAll: ModuleCli = {\n command: 'seed-all',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-all --tenant <tenantId> --org <organizationId>')\n return\n }\n\n console.log('\uD83E\uDDE9 Seeding all example workflows...\\n')\n\n try {\n // Seed demo checkout with rules\n await seedDemoWithRules.run(rest)\n console.log('')\n\n // Seed sales pipeline\n await seedSalesPipeline.run(rest)\n console.log('')\n\n // Seed simple approval\n await seedSimpleApproval.run(rest)\n console.log('')\n\n // Seed order approval\n await seedOrderApproval.run(rest)\n console.log('')\n\n console.log('\u2705 All example workflows seeded successfully!')\n } catch (error) {\n console.error('Error seeding workflows:', error)\n throw error\n }\n },\n}\n\n/**\n * Manually process pending workflow activities\n */\nconst processActivities: ModuleCli = {\n command: 'process-activities',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const limit = parseInt(args.limit ?? args.l ?? '0')\n\n console.log('[Workflow Activities] Processing pending activities...')\n if (limit > 0) {\n console.log(`[Workflow Activities] Limit: ${limit} jobs`)\n }\n\n try {\n const container = await createRequestContainer()\n const em = container.resolve<EntityManager>('em')\n\n // Import queue and handler\n const { createQueue } = await import('@open-mercato/queue')\n const { createActivityWorkerHandler } = await import('./lib/activity-worker-handler')\n const { WORKFLOW_ACTIVITIES_QUEUE_NAME } = await import('./lib/activity-queue-types')\n\n // Create queue instance\n const queue = createQueue(WORKFLOW_ACTIVITIES_QUEUE_NAME, 'local')\n\n // Create handler\n const handler = createActivityWorkerHandler(em, container)\n\n // Get initial counts\n const initialCounts = await queue.getJobCounts()\n console.log(`[Workflow Activities] Pending jobs: ${initialCounts.waiting}`)\n\n if (initialCounts.waiting === 0) {\n console.log('[Workflow Activities] No jobs to process')\n await queue.close()\n return\n }\n\n // Process jobs\n const result = await queue.process(handler as any, limit > 0 ? { limit } : undefined)\n\n console.log(`\\n[Workflow Activities] \u2713 Processed ${result.processed} activities`)\n if (result.failed > 0) {\n console.log(`[Workflow Activities] \u2717 Failed: ${result.failed} activities`)\n }\n\n // Show remaining\n const finalCounts = await queue.getJobCounts()\n if (finalCounts.waiting > 0) {\n console.log(`[Workflow Activities] Remaining: ${finalCounts.waiting} jobs`)\n }\n\n await queue.close()\n } catch (error) {\n console.error('[Workflow Activities] Error processing activities:', error)\n throw error\n }\n },\n}\n\nconst workflowsCliCommands = [\n startWorker,\n processActivities,\n seedDemo,\n seedDemoWithRules,\n seedSalesPipeline,\n seedSimpleApproval,\n seedOrderApproval,\n seedAll,\n]\n\nexport default workflowsCliCommands\n"],
5
- "mappings": "AACA,SAAS,8BAA8B;AACvC,SAAS,aAAa,0BAA0B;AAEhD,SAAS,0BAA0B;AACnC,SAAS,oBAAmC;AAC5C,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,qBAAqB;AAE9B,MAAM,aAAa,cAAc,YAAY,GAAG;AAChD,MAAM,YAAY,KAAK,QAAQ,UAAU;AAKzC,SAAS,UAAU,MAAgB;AACjC,QAAM,SAAiC,CAAC;AACxC,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;AACvC,UAAM,MAAM,KAAK,CAAC,GAAG,QAAQ,OAAO,EAAE;AACtC,UAAM,QAAQ,KAAK,IAAI,CAAC;AACx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",
4
+ "sourcesContent": ["import type { ModuleCli } from '@open-mercato/shared/modules/registry'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { getRedisUrl, getRedisUrlOrThrow } from '@open-mercato/shared/lib/redis/connection'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { WorkflowDefinition } from './data/entities'\nimport { BusinessRule, type RuleType } from '@open-mercato/core/modules/business_rules/data/entities'\nimport * as fs from 'fs'\nimport * as path from 'path'\nimport { fileURLToPath } from 'url'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\n/**\n * Parse CLI arguments\n */\nfunction parseArgs(args: string[]) {\n const result: Record<string, string> = {}\n for (let i = 0; i < args.length; i += 2) {\n const key = args[i]?.replace(/^-+/, '') // Remove one or more dashes\n const value = args[i + 1]\n if (key && value) {\n result[key] = value\n }\n }\n return result\n}\n\n/**\n * Seed demo checkout workflow\n */\nconst seedDemo: ModuleCli = {\n command: 'seed-demo',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-demo --tenant <tenantId> --org <organizationId>')\n console.error(' or: mercato workflows seed-demo -t <tenantId> -o <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Read the demo workflow definition\n const demoPath = path.join(__dirname, 'examples', 'checkout-demo-definition.json')\n const demoData = JSON.parse(fs.readFileSync(demoPath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: demoData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2139\uFE0F Demo workflow '${demoData.workflowId}' already exists (ID: ${existing.id})`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...demoData,\n tenantId,\n organizationId,\n })\n\n await em.persist(workflow).flush()\n\n console.log(`\u2705 Seeded demo workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log('')\n console.log('Demo workflow is ready! You can now:')\n console.log(' 1. View it in admin: /backend/definitions')\n console.log(' 2. Try the demo page: /checkout-demo')\n console.log(' 3. Start an instance via API: POST /api/workflows/instances')\n console.log('')\n console.log('Note: This workflow includes a USER_TASK step for customer information.')\n console.log('When the workflow reaches this step, it will pause and require user input.')\n console.log('Complete pending tasks at: /backend/tasks')\n } catch (error) {\n console.error('Error seeding demo workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed demo checkout workflow with guard rules\n */\nconst seedDemoWithRules: ModuleCli = {\n command: 'seed-demo-with-rules',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-demo-with-rules --tenant <tenantId> --org <organizationId>')\n console.error(' or: mercato workflows seed-demo-with-rules -t <tenantId> -o <organizationId>')\n return\n }\n\n console.log('\uD83E\uDDE9 Seeding demo workflow with guard rules...\\n')\n\n try {\n // Seed the workflow definition\n console.log('1. \uD83E\uDDE9 Seeding demo workflow...')\n await seedDemo.run(rest)\n\n // Seed the guard rules\n console.log('\\n2. \uD83E\uDDE0 Seeding guard rules...')\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Import BusinessRule entity\n const { BusinessRule } = await import('../business_rules/data/entities')\n\n // Read guard rules\n const rulesPath = path.join(__dirname, 'examples', 'guard-rules-example.json')\n const rulesData = JSON.parse(fs.readFileSync(rulesPath, 'utf8'))\n\n let seededCount = 0\n let skippedCount = 0\n\n for (const ruleData of rulesData) {\n const existing = await em.findOne(BusinessRule, {\n ruleId: ruleData.ruleId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(` \u2298 Guard rule '${ruleData.ruleId}' already exists`)\n skippedCount++\n continue\n }\n\n const rule = em.create(BusinessRule, {\n ...ruleData,\n tenantId,\n organizationId,\n })\n\n await em.persist(rule).flush()\n console.log(` \u2713 Seeded guard rule: ${rule.ruleName}`)\n seededCount++\n }\n\n console.log(`\\n\u2705 Demo workflow with guard rules seeded successfully!`)\n console.log(` - Workflow: checkout_simple_v1`)\n console.log(` - Guard rules seeded: ${seededCount}`)\n console.log(` - Guard rules skipped: ${skippedCount}`)\n } catch (error) {\n console.error('Error seeding demo with rules:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed sales pipeline example\n */\nconst seedSalesPipeline: ModuleCli = {\n command: 'seed-sales-pipeline',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-sales-pipeline --tenant <tenantId> --org <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Read the sales pipeline workflow definition\n const pipelinePath = path.join(__dirname, 'examples', 'sales-pipeline-definition.json')\n const pipelineData = JSON.parse(fs.readFileSync(pipelinePath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: pipelineData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2139\uFE0F Sales pipeline workflow '${pipelineData.workflowId}' already exists (ID: ${existing.id})`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...pipelineData,\n tenantId,\n organizationId,\n })\n\n await em.persist(workflow).flush()\n\n console.log(`\u2705 Seeded sales pipeline workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log(` - Activities: ${workflow.definition.transitions.reduce((sum, t) => sum + (t.activities?.length || 0), 0)}`)\n console.log('')\n console.log('Sales pipeline workflow is ready!')\n } catch (error) {\n console.error('Error seeding sales pipeline workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed simple approval example\n */\nconst seedSimpleApproval: ModuleCli = {\n command: 'seed-simple-approval',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-simple-approval --tenant <tenantId> --org <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Read the simple approval workflow definition\n const approvalPath = path.join(__dirname, 'examples', 'simple-approval-definition.json')\n const approvalData = JSON.parse(fs.readFileSync(approvalPath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: approvalData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2139\uFE0F Simple approval workflow '${approvalData.workflowId}' already exists (ID: ${existing.id})`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...approvalData,\n tenantId,\n organizationId,\n })\n\n await em.persist(workflow).flush()\n\n console.log(`\u2705 Seeded simple approval workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log('')\n console.log('Simple approval workflow is ready!')\n } catch (error) {\n console.error('Error seeding simple approval workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed order approval example\n */\nconst seedOrderApproval: ModuleCli = {\n command: 'seed-order-approval',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-order-approval --tenant <tenantId> --org <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // 1. Seed order approval guard rules first\n const guardRulesPath = path.join(__dirname, 'examples', 'order-approval-guard-rules.json')\n const guardRulesData = JSON.parse(fs.readFileSync(guardRulesPath, 'utf8')) as Array<{\n ruleId: string\n ruleName: string\n ruleType: RuleType\n entityType: string\n description?: string\n eventType?: string\n conditionExpression?: Record<string, unknown>\n enabled?: boolean\n priority?: number\n }>\n\n let rulesSeeded = 0\n let rulesSkipped = 0\n for (const rule of guardRulesData) {\n const existingRule = await em.findOne(BusinessRule, {\n ruleId: rule.ruleId,\n tenantId,\n organizationId,\n })\n\n if (existingRule) {\n rulesSkipped++\n continue\n }\n\n const newRule = em.create(BusinessRule, {\n ...rule,\n tenantId,\n organizationId,\n })\n em.persist(newRule)\n console.log(` \u2713 Seeded guard rule: ${rule.ruleName}`)\n rulesSeeded++\n }\n\n if (rulesSeeded > 0) {\n await em.flush()\n }\n\n // 2. Read the order approval workflow definition\n const approvalPath = path.join(__dirname, 'examples', 'order-approval-definition.json')\n const approvalData = JSON.parse(fs.readFileSync(approvalPath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: approvalData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2705 Order approval workflow '${approvalData.workflowId}' already exists (ID: ${existing.id})`)\n console.log(` - Guard rules seeded: ${rulesSeeded}`)\n console.log(` - Guard rules skipped: ${rulesSkipped}`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...approvalData,\n tenantId,\n organizationId,\n })\n\n await em.persist(workflow).flush()\n\n console.log(`\u2705 Seeded order approval workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log(` - Guard rules seeded: ${rulesSeeded}`)\n console.log(` - Guard rules skipped: ${rulesSkipped}`)\n console.log('')\n console.log('Order approval workflow is ready!')\n } catch (error) {\n console.error('Error seeding order approval workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Start workflow activity worker\n */\nconst startWorker: ModuleCli = {\n command: 'start-worker',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const concurrency = parseInt(args.concurrency ?? args.c ?? '5')\n\n const strategy = process.env.QUEUE_STRATEGY === 'async' ? 'async' : 'local'\n\n console.log('[Workflow Worker] Starting activity worker...')\n console.log(`[Workflow Worker] Strategy: ${strategy}`)\n\n if (strategy === 'local') {\n const pollMs = process.env.LOCAL_QUEUE_POLL_MS || '5000'\n console.log(`[Workflow Worker] Polling interval: ${pollMs}ms`)\n console.log('[Workflow Worker] NOTE: Local strategy is for development only.')\n console.log('[Workflow Worker] Use QUEUE_STRATEGY=async with Redis for production.')\n } else {\n console.log(`[Workflow Worker] Concurrency: ${concurrency}`)\n console.log(`[Workflow Worker] Redis: ${getRedisUrl('QUEUE') ?? '(not configured)'}`)\n }\n\n try {\n const container = await createRequestContainer()\n const em = container.resolve<EntityManager>('em')\n\n // Import queue and handler\n const { runWorker } = await import('@open-mercato/queue/worker')\n const { createActivityWorkerHandler } = await import('./lib/activity-worker-handler')\n const { WORKFLOW_ACTIVITIES_QUEUE_NAME } = await import('./lib/activity-queue-types')\n\n // Create handler\n const handler = createActivityWorkerHandler(em, container)\n\n // Run worker\n await runWorker({\n queueName: WORKFLOW_ACTIVITIES_QUEUE_NAME,\n handler,\n connection: strategy === 'async' ? {\n url: getRedisUrlOrThrow('QUEUE'),\n } : undefined,\n concurrency,\n gracefulShutdown: true,\n })\n } catch (error) {\n console.error('[Workflow Worker] Failed to start worker:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed all example workflows\n */\nconst seedAll: ModuleCli = {\n command: 'seed-all',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-all --tenant <tenantId> --org <organizationId>')\n return\n }\n\n console.log('\uD83E\uDDE9 Seeding all example workflows...\\n')\n\n try {\n // Seed demo checkout with rules\n await seedDemoWithRules.run(rest)\n console.log('')\n\n // Seed sales pipeline\n await seedSalesPipeline.run(rest)\n console.log('')\n\n // Seed simple approval\n await seedSimpleApproval.run(rest)\n console.log('')\n\n // Seed order approval\n await seedOrderApproval.run(rest)\n console.log('')\n\n console.log('\u2705 All example workflows seeded successfully!')\n } catch (error) {\n console.error('Error seeding workflows:', error)\n throw error\n }\n },\n}\n\n/**\n * Manually process pending workflow activities\n */\nconst processActivities: ModuleCli = {\n command: 'process-activities',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const limit = parseInt(args.limit ?? args.l ?? '0')\n\n console.log('[Workflow Activities] Processing pending activities...')\n if (limit > 0) {\n console.log(`[Workflow Activities] Limit: ${limit} jobs`)\n }\n\n try {\n const container = await createRequestContainer()\n const em = container.resolve<EntityManager>('em')\n\n // Import queue and handler\n const { createQueue } = await import('@open-mercato/queue')\n const { createActivityWorkerHandler } = await import('./lib/activity-worker-handler')\n const { WORKFLOW_ACTIVITIES_QUEUE_NAME } = await import('./lib/activity-queue-types')\n\n // Create queue instance\n const queue = createQueue(WORKFLOW_ACTIVITIES_QUEUE_NAME, 'local')\n\n // Create handler\n const handler = createActivityWorkerHandler(em, container)\n\n // Get initial counts\n const initialCounts = await queue.getJobCounts()\n console.log(`[Workflow Activities] Pending jobs: ${initialCounts.waiting}`)\n\n if (initialCounts.waiting === 0) {\n console.log('[Workflow Activities] No jobs to process')\n await queue.close()\n return\n }\n\n // Process jobs\n const result = await queue.process(handler as any, limit > 0 ? { limit } : undefined)\n\n console.log(`\\n[Workflow Activities] \u2713 Processed ${result.processed} activities`)\n if (result.failed > 0) {\n console.log(`[Workflow Activities] \u2717 Failed: ${result.failed} activities`)\n }\n\n // Show remaining\n const finalCounts = await queue.getJobCounts()\n if (finalCounts.waiting > 0) {\n console.log(`[Workflow Activities] Remaining: ${finalCounts.waiting} jobs`)\n }\n\n await queue.close()\n } catch (error) {\n console.error('[Workflow Activities] Error processing activities:', error)\n throw error\n }\n },\n}\n\nconst workflowsCliCommands = [\n startWorker,\n processActivities,\n seedDemo,\n seedDemoWithRules,\n seedSalesPipeline,\n seedSimpleApproval,\n seedOrderApproval,\n seedAll,\n]\n\nexport default workflowsCliCommands\n"],
5
+ "mappings": "AACA,SAAS,8BAA8B;AACvC,SAAS,aAAa,0BAA0B;AAEhD,SAAS,0BAA0B;AACnC,SAAS,oBAAmC;AAC5C,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,qBAAqB;AAE9B,MAAM,aAAa,cAAc,YAAY,GAAG;AAChD,MAAM,YAAY,KAAK,QAAQ,UAAU;AAKzC,SAAS,UAAU,MAAgB;AACjC,QAAM,SAAiC,CAAC;AACxC,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;AACvC,UAAM,MAAM,KAAK,CAAC,GAAG,QAAQ,OAAO,EAAE;AACtC,UAAM,QAAQ,KAAK,IAAI,CAAC;AACxB,QAAI,OAAO,OAAO;AAChB,aAAO,GAAG,IAAI;AAAA,IAChB;AAAA,EACF;AACA,SAAO;AAC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
7
  }
@@ -8,7 +8,8 @@ var __decorateClass = (decorators, target, key, kind) => {
8
8
  if (kind && result) __defProp(target, key, result);
9
9
  return result;
10
10
  };
11
- import { Entity, PrimaryKey, Property, Index, Unique, OptionalProps } from "@mikro-orm/core";
11
+ import { OptionalProps } from "@mikro-orm/core";
12
+ import { Entity, Index, PrimaryKey, Property, Unique } from "@mikro-orm/decorators/legacy";
12
13
  OptionalProps;
13
14
  let WorkflowDefinition = class {
14
15
  constructor() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/workflows/data/entities.ts"],
4
- "sourcesContent": ["/**\n * Workflows Module - Database Entities\n *\n * MikroORM entities for workflow engine.\n */\n\nimport { Entity, PrimaryKey, Property, Index, Unique, OptionalProps } from '@mikro-orm/core'\n\n// ============================================================================\n// Type Definitions\n// ============================================================================\n\nexport type WorkflowStepType =\n | 'START'\n | 'END'\n | 'USER_TASK'\n | 'AUTOMATED'\n | 'PARALLEL_FORK'\n | 'PARALLEL_JOIN'\n | 'SUB_WORKFLOW'\n | 'WAIT_FOR_SIGNAL'\n | 'WAIT_FOR_TIMER'\n\nexport type WorkflowInstanceStatus =\n | 'RUNNING'\n | 'PAUSED'\n | 'COMPLETED'\n | 'FAILED'\n | 'CANCELLED'\n | 'COMPENSATING'\n | 'COMPENSATED'\n | 'WAITING_FOR_ACTIVITIES'\n\nexport type StepInstanceStatus =\n | 'PENDING'\n | 'ACTIVE'\n | 'COMPLETED'\n | 'FAILED'\n | 'SKIPPED'\n | 'CANCELLED'\n\nexport type UserTaskStatus =\n | 'PENDING'\n | 'IN_PROGRESS'\n | 'COMPLETED'\n | 'CANCELLED'\n | 'ESCALATED'\n\n// ============================================================================\n// Event Trigger Types\n// ============================================================================\n\nexport type TriggerFilterOperator =\n | 'eq'\n | 'neq'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'contains'\n | 'startsWith'\n | 'endsWith'\n | 'in'\n | 'notIn'\n | 'exists'\n | 'notExists'\n | 'regex'\n\nexport interface TriggerFilterCondition {\n field: string // JSON path (e.g., \"status\", \"metadata.type\")\n operator: TriggerFilterOperator\n value: unknown\n}\n\nexport interface TriggerContextMapping {\n targetKey: string // Key in workflow initial context\n sourceExpression: string // Path from event payload (supports dot notation)\n defaultValue?: unknown\n}\n\nexport interface WorkflowEventTriggerConfig {\n filterConditions?: TriggerFilterCondition[]\n contextMapping?: TriggerContextMapping[]\n debounceMs?: number // Debounce rapid events\n maxConcurrentInstances?: number // Limit concurrent instances\n entityType?: string // Entity type for workflow instance metadata (e.g., \"SalesOrder\")\n}\n\n/**\n * WorkflowDefinitionTrigger - Embedded trigger configuration\n *\n * Triggers are now embedded directly in the workflow definition,\n * allowing users to configure event-based workflow starts during\n * workflow creation in the visual editor.\n */\nexport interface WorkflowDefinitionTrigger {\n triggerId: string\n name: string\n description?: string | null\n eventPattern: string // e.g., \"sales.orders.created\", \"customers.*\"\n config?: WorkflowEventTriggerConfig | null\n enabled: boolean\n priority: number\n}\n\n// ============================================================================\n// JSONB Structure Interfaces\n// ============================================================================\n\nexport interface WorkflowDefinitionData {\n steps: any[] // WorkflowStep[] - will define schema in validators.ts\n transitions: any[] // WorkflowTransition[] - will define schema in validators.ts\n triggers?: WorkflowDefinitionTrigger[] // Event triggers for automatic workflow start\n activities?: any[] // ActivityDefinition[] - will define schema in validators.ts\n queries?: any[]\n signals?: any[]\n timers?: any[]\n}\n\nexport interface WorkflowMetadata {\n tags?: string[]\n category?: string\n icon?: string\n}\n\nexport interface WorkflowInstanceMetadata {\n entityType?: string\n entityId?: string\n initiatedBy?: string\n labels?: Record<string, string>\n}\n\n// ============================================================================\n// Entity: WorkflowDefinition\n// ============================================================================\n\n/**\n * WorkflowDefinition entity\n *\n * Stores workflow definitions (templates) that can be instantiated\n * to create workflow instances.\n */\n@Entity({ tableName: 'workflow_definitions' })\n@Unique({ properties: ['workflowId', 'tenantId'] })\n@Index({ name: 'workflow_definitions_enabled_idx', properties: ['enabled'] })\n@Index({ name: 'workflow_definitions_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\n@Index({ name: 'workflow_definitions_workflow_id_idx', properties: ['workflowId'] })\nexport class WorkflowDefinition {\n [OptionalProps]?: 'enabled' | 'version' | 'createdAt' | 'updatedAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_id', type: 'varchar', length: 100 })\n workflowId!: string\n\n @Property({ name: 'workflow_name', type: 'varchar', length: 255 })\n workflowName!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'version', type: 'integer', default: 1 })\n version: number = 1\n\n @Property({ name: 'definition', type: 'jsonb' })\n definition!: WorkflowDefinitionData\n\n @Property({ name: 'metadata', type: 'jsonb', nullable: true })\n metadata?: WorkflowMetadata | null\n\n @Property({ name: 'enabled', type: 'boolean', default: true })\n enabled: boolean = true\n\n @Property({ name: 'effective_from', type: Date, nullable: true })\n effectiveFrom?: Date | null\n\n @Property({ name: 'effective_to', type: Date, nullable: true })\n effectiveTo?: Date | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_by', type: 'varchar', length: 255, nullable: true })\n createdBy?: string | null\n\n @Property({ name: 'updated_by', type: 'varchar', length: 255, nullable: true })\n updatedBy?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// ============================================================================\n// Entity: WorkflowInstance\n// ============================================================================\n\n/**\n * WorkflowInstance entity\n *\n * Represents a running instance of a workflow definition.\n * Tracks the current state, context data, and execution status.\n */\n@Entity({ tableName: 'workflow_instances' })\n@Index({ name: 'workflow_instances_definition_status_idx', properties: ['definitionId', 'status'] })\n@Index({ name: 'workflow_instances_correlation_key_idx', properties: ['correlationKey'] })\n@Index({ name: 'workflow_instances_status_tenant_idx', properties: ['status', 'tenantId'] })\n@Index({ name: 'workflow_instances_current_step_idx', properties: ['currentStepId', 'status'] })\n@Index({ name: 'workflow_instances_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class WorkflowInstance {\n [OptionalProps]?: 'retryCount' | 'createdAt' | 'updatedAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'definition_id', type: 'uuid' })\n definitionId!: string\n\n @Property({ name: 'workflow_id', type: 'varchar', length: 100 })\n workflowId!: string\n\n @Property({ name: 'version', type: 'integer' })\n version!: number\n\n @Property({ name: 'status', type: 'varchar', length: 30 })\n status!: WorkflowInstanceStatus\n\n @Property({ name: 'current_step_id', type: 'varchar', length: 100 })\n currentStepId!: string\n\n @Property({ name: 'context', type: 'jsonb' })\n context!: Record<string, any>\n\n @Property({ name: 'correlation_key', type: 'varchar', length: 255, nullable: true })\n correlationKey?: string | null\n\n @Property({ name: 'metadata', type: 'jsonb', nullable: true })\n metadata?: WorkflowInstanceMetadata | null\n\n @Property({ name: 'started_at', type: Date })\n startedAt!: Date\n\n @Property({ name: 'completed_at', type: Date, nullable: true })\n completedAt?: Date | null\n\n @Property({ name: 'paused_at', type: Date, nullable: true })\n pausedAt?: Date | null\n\n @Property({ name: 'cancelled_at', type: Date, nullable: true })\n cancelledAt?: Date | null\n\n @Property({ name: 'error_message', type: 'text', nullable: true })\n errorMessage?: string | null\n\n @Property({ name: 'error_details', type: 'jsonb', nullable: true })\n errorDetails?: any | null\n\n @Property({ name: 'pending_transition', type: 'jsonb', nullable: true })\n pendingTransition?: {\n toStepId: string\n activityResults: any[]\n timestamp: Date\n } | null\n\n @Property({ name: 'retry_count', type: 'integer', default: 0 })\n retryCount: number = 0\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// ============================================================================\n// Entity: StepInstance\n// ============================================================================\n\n/**\n * StepInstance entity\n *\n * Tracks individual step executions within a workflow instance.\n * Records input/output data, timing, and execution status for each step.\n */\n@Entity({ tableName: 'step_instances' })\n@Index({ name: 'step_instances_workflow_instance_idx', properties: ['workflowInstanceId', 'status'] })\n@Index({ name: 'step_instances_step_id_idx', properties: ['stepId', 'status'] })\n@Index({ name: 'step_instances_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class StepInstance {\n [OptionalProps]?: 'retryCount' | 'createdAt' | 'updatedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n @Property({ name: 'step_id', type: 'varchar', length: 100 })\n stepId!: string\n\n @Property({ name: 'step_name', type: 'varchar', length: 255 })\n stepName!: string\n\n @Property({ name: 'step_type', type: 'varchar', length: 50 })\n stepType!: string\n\n @Property({ name: 'status', type: 'varchar', length: 20 })\n status!: StepInstanceStatus\n\n @Property({ name: 'input_data', type: 'jsonb', nullable: true })\n inputData?: any | null\n\n @Property({ name: 'output_data', type: 'jsonb', nullable: true })\n outputData?: any | null\n\n @Property({ name: 'error_data', type: 'jsonb', nullable: true })\n errorData?: any | null\n\n @Property({ name: 'entered_at', type: Date, nullable: true })\n enteredAt?: Date | null\n\n @Property({ name: 'exited_at', type: Date, nullable: true })\n exitedAt?: Date | null\n\n @Property({ name: 'execution_time_ms', type: 'integer', nullable: true })\n executionTimeMs?: number | null\n\n @Property({ name: 'retry_count', type: 'integer', default: 0 })\n retryCount: number = 0\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n// ============================================================================\n// Entity: UserTask\n// ============================================================================\n\n/**\n * UserTask entity\n *\n * Represents user tasks that require human interaction within a workflow.\n * Tracks assignment, SLA, escalation, and completion status.\n */\n@Entity({ tableName: 'user_tasks' })\n@Index({ name: 'user_tasks_workflow_instance_idx', properties: ['workflowInstanceId'] })\n@Index({ name: 'user_tasks_status_assigned_idx', properties: ['status', 'assignedTo'] })\n@Index({ name: 'user_tasks_status_due_date_idx', properties: ['status', 'dueDate'] })\n@Index({ name: 'user_tasks_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class UserTask {\n [OptionalProps]?: 'createdAt' | 'updatedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n @Property({ name: 'step_instance_id', type: 'uuid' })\n stepInstanceId!: string\n\n @Property({ name: 'task_name', type: 'varchar', length: 255 })\n taskName!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'status', type: 'varchar', length: 20 })\n status!: UserTaskStatus\n\n @Property({ name: 'form_schema', type: 'jsonb', nullable: true })\n formSchema?: any | null\n\n @Property({ name: 'form_data', type: 'jsonb', nullable: true })\n formData?: any | null\n\n @Property({ name: 'assigned_to', type: 'varchar', length: 255, nullable: true })\n assignedTo?: string | null\n\n @Property({ name: 'assigned_to_roles', type: 'text[]', nullable: true })\n assignedToRoles?: string[] | null\n\n @Property({ name: 'claimed_by', type: 'varchar', length: 255, nullable: true })\n claimedBy?: string | null\n\n @Property({ name: 'claimed_at', type: Date, nullable: true })\n claimedAt?: Date | null\n\n @Property({ name: 'due_date', type: Date, nullable: true })\n dueDate?: Date | null\n\n @Property({ name: 'escalated_at', type: Date, nullable: true })\n escalatedAt?: Date | null\n\n @Property({ name: 'escalated_to', type: 'varchar', length: 255, nullable: true })\n escalatedTo?: string | null\n\n @Property({ name: 'completed_by', type: 'varchar', length: 255, nullable: true })\n completedBy?: string | null\n\n @Property({ name: 'completed_at', type: Date, nullable: true })\n completedAt?: Date | null\n\n @Property({ name: 'comments', type: 'text', nullable: true })\n comments?: string | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n// ============================================================================\n// Entity: WorkflowEvent\n// ============================================================================\n\n/**\n * WorkflowEvent entity\n *\n * Event sourcing log for workflow execution history.\n * Records all events that occur during workflow execution for audit and replay.\n */\n@Entity({ tableName: 'workflow_events' })\n@Index({ name: 'workflow_events_instance_occurred_idx', properties: ['workflowInstanceId', 'occurredAt'] })\n@Index({ name: 'workflow_events_event_type_idx', properties: ['eventType', 'occurredAt'] })\n@Index({ name: 'workflow_events_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class WorkflowEvent {\n @PrimaryKey({ type: 'bigint', autoincrement: true })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n @Property({ name: 'step_instance_id', type: 'uuid', nullable: true })\n stepInstanceId?: string | null\n\n @Property({ name: 'event_type', type: 'varchar', length: 50 })\n eventType!: string\n\n @Property({ name: 'event_data', type: 'jsonb' })\n eventData!: any\n\n @Property({ name: 'occurred_at', type: Date, onCreate: () => new Date() })\n occurredAt: Date = new Date()\n\n @Property({ name: 'user_id', type: 'varchar', length: 255, nullable: true })\n userId?: string | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n}\n\n// ============================================================================\n// Entity: WorkflowEventTrigger\n// ============================================================================\n\n/**\n * WorkflowEventTrigger entity\n *\n * Maps event patterns to workflow definitions for automatic triggering.\n * When a matching event is emitted, the corresponding workflow is started\n * with context mapped from the event payload.\n */\n@Entity({ tableName: 'workflow_event_triggers' })\n@Index({ name: 'workflow_event_triggers_event_pattern_idx', properties: ['eventPattern', 'enabled'] })\n@Index({ name: 'workflow_event_triggers_definition_idx', properties: ['workflowDefinitionId'] })\n@Index({ name: 'workflow_event_triggers_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\n@Index({ name: 'workflow_event_triggers_enabled_priority_idx', properties: ['enabled', 'priority'] })\nexport class WorkflowEventTrigger {\n [OptionalProps]?: 'enabled' | 'priority' | 'createdAt' | 'updatedAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'name', type: 'varchar', length: 255 })\n name!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'workflow_definition_id', type: 'uuid' })\n workflowDefinitionId!: string\n\n @Property({ name: 'event_pattern', type: 'varchar', length: 255 })\n eventPattern!: string\n\n @Property({ name: 'config', type: 'jsonb', nullable: true })\n config?: WorkflowEventTriggerConfig | null\n\n @Property({ name: 'enabled', type: 'boolean', default: true })\n enabled: boolean = true\n\n @Property({ name: 'priority', type: 'integer', default: 0 })\n priority: number = 0\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_by', type: 'varchar', length: 255, nullable: true })\n createdBy?: string | null\n\n @Property({ name: 'updated_by', type: 'varchar', length: 255, nullable: true })\n updatedBy?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// Export all entities as default for MikroORM discovery\nexport default [\n WorkflowDefinition,\n WorkflowInstance,\n StepInstance,\n UserTask,\n WorkflowEvent,\n WorkflowEventTrigger,\n]\n"],
5
- "mappings": ";;;;;;;;;;AAMA,SAAS,QAAQ,YAAY,UAAU,OAAO,QAAQ,qBAAqB;AA8IxE;AADI,IAAM,qBAAN,MAAyB;AAAA,EAAzB;AAgBL,mBAAkB;AASlB,mBAAmB;AAqBnB,qBAAkB,oBAAI,KAAK;AAG3B,qBAAkB,oBAAI,KAAK;AAAA;AAI7B;AAjDE;AAAA,EADC,WAAW,EAAE,MAAM,QAAQ,YAAY,oBAAoB,CAAC;AAAA,GAHlD,mBAIX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,WAAW,QAAQ,IAAI,CAAC;AAAA,GANpD,mBAOX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,iBAAiB,MAAM,WAAW,QAAQ,IAAI,CAAC;AAAA,GATtD,mBAUX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,QAAQ,UAAU,KAAK,CAAC;AAAA,GAZpD,mBAaX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,WAAW,MAAM,WAAW,SAAS,EAAE,CAAC;AAAA,GAf/C,mBAgBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,QAAQ,CAAC;AAAA,GAlBpC,mBAmBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,YAAY,MAAM,SAAS,UAAU,KAAK,CAAC;AAAA,GArBlD,mBAsBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,WAAW,MAAM,WAAW,SAAS,KAAK,CAAC;AAAA,GAxBlD,mBAyBX;AAGA;AAAA,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AAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,MAAM,UAAU,KAAK,CAAC;AAAA,GA7CjD,qBA8CX;AA9CW,uBAAN;AAAA,EALN,OAAO,EAAE,WAAW,0BAA0B,CAAC;AAAA,EAC/C,MAAM,EAAE,MAAM,6CAA6C,YAAY,CAAC,gBAAgB,SAAS,EAAE,CAAC;AAAA,EACpG,MAAM,EAAE,MAAM,0CAA0C,YAAY,CAAC,sBAAsB,EAAE,CAAC;AAAA,EAC9F,MAAM,EAAE,MAAM,0CAA0C,YAAY,CAAC,YAAY,gBAAgB,EAAE,CAAC;AAAA,EACpG,MAAM,EAAE,MAAM,gDAAgD,YAAY,CAAC,WAAW,UAAU,EAAE,CAAC;AAAA,GACvF;AAkDb,IAAO,mBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
4
+ "sourcesContent": ["/**\n * Workflows Module - Database Entities\n *\n * MikroORM entities for workflow engine.\n */\n\nimport { OptionalProps } from '@mikro-orm/core'\nimport { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'\n\n// ============================================================================\n// Type Definitions\n// ============================================================================\n\nexport type WorkflowStepType =\n | 'START'\n | 'END'\n | 'USER_TASK'\n | 'AUTOMATED'\n | 'PARALLEL_FORK'\n | 'PARALLEL_JOIN'\n | 'SUB_WORKFLOW'\n | 'WAIT_FOR_SIGNAL'\n | 'WAIT_FOR_TIMER'\n\nexport type WorkflowInstanceStatus =\n | 'RUNNING'\n | 'PAUSED'\n | 'COMPLETED'\n | 'FAILED'\n | 'CANCELLED'\n | 'COMPENSATING'\n | 'COMPENSATED'\n | 'WAITING_FOR_ACTIVITIES'\n\nexport type StepInstanceStatus =\n | 'PENDING'\n | 'ACTIVE'\n | 'COMPLETED'\n | 'FAILED'\n | 'SKIPPED'\n | 'CANCELLED'\n\nexport type UserTaskStatus =\n | 'PENDING'\n | 'IN_PROGRESS'\n | 'COMPLETED'\n | 'CANCELLED'\n | 'ESCALATED'\n\n// ============================================================================\n// Event Trigger Types\n// ============================================================================\n\nexport type TriggerFilterOperator =\n | 'eq'\n | 'neq'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'contains'\n | 'startsWith'\n | 'endsWith'\n | 'in'\n | 'notIn'\n | 'exists'\n | 'notExists'\n | 'regex'\n\nexport interface TriggerFilterCondition {\n field: string // JSON path (e.g., \"status\", \"metadata.type\")\n operator: TriggerFilterOperator\n value: unknown\n}\n\nexport interface TriggerContextMapping {\n targetKey: string // Key in workflow initial context\n sourceExpression: string // Path from event payload (supports dot notation)\n defaultValue?: unknown\n}\n\nexport interface WorkflowEventTriggerConfig {\n filterConditions?: TriggerFilterCondition[]\n contextMapping?: TriggerContextMapping[]\n debounceMs?: number // Debounce rapid events\n maxConcurrentInstances?: number // Limit concurrent instances\n entityType?: string // Entity type for workflow instance metadata (e.g., \"SalesOrder\")\n}\n\n/**\n * WorkflowDefinitionTrigger - Embedded trigger configuration\n *\n * Triggers are now embedded directly in the workflow definition,\n * allowing users to configure event-based workflow starts during\n * workflow creation in the visual editor.\n */\nexport interface WorkflowDefinitionTrigger {\n triggerId: string\n name: string\n description?: string | null\n eventPattern: string // e.g., \"sales.orders.created\", \"customers.*\"\n config?: WorkflowEventTriggerConfig | null\n enabled: boolean\n priority: number\n}\n\n// ============================================================================\n// JSONB Structure Interfaces\n// ============================================================================\n\nexport interface WorkflowDefinitionData {\n steps: any[] // WorkflowStep[] - will define schema in validators.ts\n transitions: any[] // WorkflowTransition[] - will define schema in validators.ts\n triggers?: WorkflowDefinitionTrigger[] // Event triggers for automatic workflow start\n activities?: any[] // ActivityDefinition[] - will define schema in validators.ts\n queries?: any[]\n signals?: any[]\n timers?: any[]\n}\n\nexport interface WorkflowMetadata {\n tags?: string[]\n category?: string\n icon?: string\n}\n\nexport interface WorkflowInstanceMetadata {\n entityType?: string\n entityId?: string\n initiatedBy?: string\n labels?: Record<string, string>\n}\n\n// ============================================================================\n// Entity: WorkflowDefinition\n// ============================================================================\n\n/**\n * WorkflowDefinition entity\n *\n * Stores workflow definitions (templates) that can be instantiated\n * to create workflow instances.\n */\n@Entity({ tableName: 'workflow_definitions' })\n@Unique({ properties: ['workflowId', 'tenantId'] })\n@Index({ name: 'workflow_definitions_enabled_idx', properties: ['enabled'] })\n@Index({ name: 'workflow_definitions_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\n@Index({ name: 'workflow_definitions_workflow_id_idx', properties: ['workflowId'] })\nexport class WorkflowDefinition {\n [OptionalProps]?: 'enabled' | 'version' | 'createdAt' | 'updatedAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_id', type: 'varchar', length: 100 })\n workflowId!: string\n\n @Property({ name: 'workflow_name', type: 'varchar', length: 255 })\n workflowName!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'version', type: 'integer', default: 1 })\n version: number = 1\n\n @Property({ name: 'definition', type: 'jsonb' })\n definition!: WorkflowDefinitionData\n\n @Property({ name: 'metadata', type: 'jsonb', nullable: true })\n metadata?: WorkflowMetadata | null\n\n @Property({ name: 'enabled', type: 'boolean', default: true })\n enabled: boolean = true\n\n @Property({ name: 'effective_from', type: Date, nullable: true })\n effectiveFrom?: Date | null\n\n @Property({ name: 'effective_to', type: Date, nullable: true })\n effectiveTo?: Date | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_by', type: 'varchar', length: 255, nullable: true })\n createdBy?: string | null\n\n @Property({ name: 'updated_by', type: 'varchar', length: 255, nullable: true })\n updatedBy?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// ============================================================================\n// Entity: WorkflowInstance\n// ============================================================================\n\n/**\n * WorkflowInstance entity\n *\n * Represents a running instance of a workflow definition.\n * Tracks the current state, context data, and execution status.\n */\n@Entity({ tableName: 'workflow_instances' })\n@Index({ name: 'workflow_instances_definition_status_idx', properties: ['definitionId', 'status'] })\n@Index({ name: 'workflow_instances_correlation_key_idx', properties: ['correlationKey'] })\n@Index({ name: 'workflow_instances_status_tenant_idx', properties: ['status', 'tenantId'] })\n@Index({ name: 'workflow_instances_current_step_idx', properties: ['currentStepId', 'status'] })\n@Index({ name: 'workflow_instances_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class WorkflowInstance {\n [OptionalProps]?: 'retryCount' | 'createdAt' | 'updatedAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'definition_id', type: 'uuid' })\n definitionId!: string\n\n @Property({ name: 'workflow_id', type: 'varchar', length: 100 })\n workflowId!: string\n\n @Property({ name: 'version', type: 'integer' })\n version!: number\n\n @Property({ name: 'status', type: 'varchar', length: 30 })\n status!: WorkflowInstanceStatus\n\n @Property({ name: 'current_step_id', type: 'varchar', length: 100 })\n currentStepId!: string\n\n @Property({ name: 'context', type: 'jsonb' })\n context!: Record<string, any>\n\n @Property({ name: 'correlation_key', type: 'varchar', length: 255, nullable: true })\n correlationKey?: string | null\n\n @Property({ name: 'metadata', type: 'jsonb', nullable: true })\n metadata?: WorkflowInstanceMetadata | null\n\n @Property({ name: 'started_at', type: Date })\n startedAt!: Date\n\n @Property({ name: 'completed_at', type: Date, nullable: true })\n completedAt?: Date | null\n\n @Property({ name: 'paused_at', type: Date, nullable: true })\n pausedAt?: Date | null\n\n @Property({ name: 'cancelled_at', type: Date, nullable: true })\n cancelledAt?: Date | null\n\n @Property({ name: 'error_message', type: 'text', nullable: true })\n errorMessage?: string | null\n\n @Property({ name: 'error_details', type: 'jsonb', nullable: true })\n errorDetails?: any | null\n\n @Property({ name: 'pending_transition', type: 'jsonb', nullable: true })\n pendingTransition?: {\n toStepId: string\n activityResults: any[]\n timestamp: Date\n } | null\n\n @Property({ name: 'retry_count', type: 'integer', default: 0 })\n retryCount: number = 0\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// ============================================================================\n// Entity: StepInstance\n// ============================================================================\n\n/**\n * StepInstance entity\n *\n * Tracks individual step executions within a workflow instance.\n * Records input/output data, timing, and execution status for each step.\n */\n@Entity({ tableName: 'step_instances' })\n@Index({ name: 'step_instances_workflow_instance_idx', properties: ['workflowInstanceId', 'status'] })\n@Index({ name: 'step_instances_step_id_idx', properties: ['stepId', 'status'] })\n@Index({ name: 'step_instances_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class StepInstance {\n [OptionalProps]?: 'retryCount' | 'createdAt' | 'updatedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n @Property({ name: 'step_id', type: 'varchar', length: 100 })\n stepId!: string\n\n @Property({ name: 'step_name', type: 'varchar', length: 255 })\n stepName!: string\n\n @Property({ name: 'step_type', type: 'varchar', length: 50 })\n stepType!: string\n\n @Property({ name: 'status', type: 'varchar', length: 20 })\n status!: StepInstanceStatus\n\n @Property({ name: 'input_data', type: 'jsonb', nullable: true })\n inputData?: any | null\n\n @Property({ name: 'output_data', type: 'jsonb', nullable: true })\n outputData?: any | null\n\n @Property({ name: 'error_data', type: 'jsonb', nullable: true })\n errorData?: any | null\n\n @Property({ name: 'entered_at', type: Date, nullable: true })\n enteredAt?: Date | null\n\n @Property({ name: 'exited_at', type: Date, nullable: true })\n exitedAt?: Date | null\n\n @Property({ name: 'execution_time_ms', type: 'integer', nullable: true })\n executionTimeMs?: number | null\n\n @Property({ name: 'retry_count', type: 'integer', default: 0 })\n retryCount: number = 0\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n// ============================================================================\n// Entity: UserTask\n// ============================================================================\n\n/**\n * UserTask entity\n *\n * Represents user tasks that require human interaction within a workflow.\n * Tracks assignment, SLA, escalation, and completion status.\n */\n@Entity({ tableName: 'user_tasks' })\n@Index({ name: 'user_tasks_workflow_instance_idx', properties: ['workflowInstanceId'] })\n@Index({ name: 'user_tasks_status_assigned_idx', properties: ['status', 'assignedTo'] })\n@Index({ name: 'user_tasks_status_due_date_idx', properties: ['status', 'dueDate'] })\n@Index({ name: 'user_tasks_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class UserTask {\n [OptionalProps]?: 'createdAt' | 'updatedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n @Property({ name: 'step_instance_id', type: 'uuid' })\n stepInstanceId!: string\n\n @Property({ name: 'task_name', type: 'varchar', length: 255 })\n taskName!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'status', type: 'varchar', length: 20 })\n status!: UserTaskStatus\n\n @Property({ name: 'form_schema', type: 'jsonb', nullable: true })\n formSchema?: any | null\n\n @Property({ name: 'form_data', type: 'jsonb', nullable: true })\n formData?: any | null\n\n @Property({ name: 'assigned_to', type: 'varchar', length: 255, nullable: true })\n assignedTo?: string | null\n\n @Property({ name: 'assigned_to_roles', type: 'text[]', nullable: true })\n assignedToRoles?: string[] | null\n\n @Property({ name: 'claimed_by', type: 'varchar', length: 255, nullable: true })\n claimedBy?: string | null\n\n @Property({ name: 'claimed_at', type: Date, nullable: true })\n claimedAt?: Date | null\n\n @Property({ name: 'due_date', type: Date, nullable: true })\n dueDate?: Date | null\n\n @Property({ name: 'escalated_at', type: Date, nullable: true })\n escalatedAt?: Date | null\n\n @Property({ name: 'escalated_to', type: 'varchar', length: 255, nullable: true })\n escalatedTo?: string | null\n\n @Property({ name: 'completed_by', type: 'varchar', length: 255, nullable: true })\n completedBy?: string | null\n\n @Property({ name: 'completed_at', type: Date, nullable: true })\n completedAt?: Date | null\n\n @Property({ name: 'comments', type: 'text', nullable: true })\n comments?: string | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n// ============================================================================\n// Entity: WorkflowEvent\n// ============================================================================\n\n/**\n * WorkflowEvent entity\n *\n * Event sourcing log for workflow execution history.\n * Records all events that occur during workflow execution for audit and replay.\n */\n@Entity({ tableName: 'workflow_events' })\n@Index({ name: 'workflow_events_instance_occurred_idx', properties: ['workflowInstanceId', 'occurredAt'] })\n@Index({ name: 'workflow_events_event_type_idx', properties: ['eventType', 'occurredAt'] })\n@Index({ name: 'workflow_events_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class WorkflowEvent {\n @PrimaryKey({ type: 'bigint', autoincrement: true })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n @Property({ name: 'step_instance_id', type: 'uuid', nullable: true })\n stepInstanceId?: string | null\n\n @Property({ name: 'event_type', type: 'varchar', length: 50 })\n eventType!: string\n\n @Property({ name: 'event_data', type: 'jsonb' })\n eventData!: any\n\n @Property({ name: 'occurred_at', type: Date, onCreate: () => new Date() })\n occurredAt: Date = new Date()\n\n @Property({ name: 'user_id', type: 'varchar', length: 255, nullable: true })\n userId?: string | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n}\n\n// ============================================================================\n// Entity: WorkflowEventTrigger\n// ============================================================================\n\n/**\n * WorkflowEventTrigger entity\n *\n * Maps event patterns to workflow definitions for automatic triggering.\n * When a matching event is emitted, the corresponding workflow is started\n * with context mapped from the event payload.\n */\n@Entity({ tableName: 'workflow_event_triggers' })\n@Index({ name: 'workflow_event_triggers_event_pattern_idx', properties: ['eventPattern', 'enabled'] })\n@Index({ name: 'workflow_event_triggers_definition_idx', properties: ['workflowDefinitionId'] })\n@Index({ name: 'workflow_event_triggers_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\n@Index({ name: 'workflow_event_triggers_enabled_priority_idx', properties: ['enabled', 'priority'] })\nexport class WorkflowEventTrigger {\n [OptionalProps]?: 'enabled' | 'priority' | 'createdAt' | 'updatedAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'name', type: 'varchar', length: 255 })\n name!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'workflow_definition_id', type: 'uuid' })\n workflowDefinitionId!: string\n\n @Property({ name: 'event_pattern', type: 'varchar', length: 255 })\n eventPattern!: string\n\n @Property({ name: 'config', type: 'jsonb', nullable: true })\n config?: WorkflowEventTriggerConfig | null\n\n @Property({ name: 'enabled', type: 'boolean', default: true })\n enabled: boolean = true\n\n @Property({ name: 'priority', type: 'integer', default: 0 })\n priority: number = 0\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_by', type: 'varchar', length: 255, nullable: true })\n createdBy?: string | null\n\n @Property({ name: 'updated_by', type: 'varchar', length: 255, nullable: true })\n updatedBy?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// Export all entities as default for MikroORM discovery\nexport default [\n WorkflowDefinition,\n WorkflowInstance,\n StepInstance,\n UserTask,\n WorkflowEvent,\n WorkflowEventTrigger,\n]\n"],
5
+ "mappings": ";;;;;;;;;;AAMA,SAAS,qBAAqB;AAC9B,SAAS,QAAQ,OAAO,YAAY,UAAU,cAAc;AA8IzD;AADI,IAAM,qBAAN,MAAyB;AAAA,EAAzB;AAgBL,mBAAkB;AASlB,mBAAmB;AAqBnB,qBAAkB,oBAAI,KAAK;AAG3B,qBAAkB,oBAAI,KAAK;AAAA;AAI7B;AAjDE;AAAA,EADC,WAAW,EAAE,MAAM,QAAQ,YAAY,oBAAoB,CAAC;AAAA,GAHlD,mBAIX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,WAAW,QAAQ,IAAI,CAAC;AAAA,GANpD,mBAOX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,iBAAiB,MAAM,WAAW,QAAQ,IAAI,CAAC;AAAA,GATtD,mBAUX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,QAAQ,UAAU,KAAK,CAAC;AAAA,GAZpD,mBAaX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,WAAW,MAAM,WAAW,SAAS,EAAE,CAAC;AAAA,GAf/C,mBAgBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,QAAQ,CAAC;AAAA,GA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S,EAAE,MAAM,cAAc,MAAM,MAAM,UAAU,MAAM,oBAAI,KAAK,EAAE,CAAC;AAAA,GAvC7D,qBAwCX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,MAAM,UAAU,MAAM,oBAAI,KAAK,EAAE,CAAC;AAAA,GA1C7D,qBA2CX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,MAAM,UAAU,KAAK,CAAC;AAAA,GA7CjD,qBA8CX;AA9CW,uBAAN;AAAA,EALN,OAAO,EAAE,WAAW,0BAA0B,CAAC;AAAA,EAC/C,MAAM,EAAE,MAAM,6CAA6C,YAAY,CAAC,gBAAgB,SAAS,EAAE,CAAC;AAAA,EACpG,MAAM,EAAE,MAAM,0CAA0C,YAAY,CAAC,sBAAsB,EAAE,CAAC;AAAA,EAC9F,MAAM,EAAE,MAAM,0CAA0C,YAAY,CAAC,YAAY,gBAAgB,EAAE,CAAC;AAAA,EACpG,MAAM,EAAE,MAAM,gDAAgD,YAAY,CAAC,WAAW,UAAU,EAAE,CAAC;AAAA,GACvF;AAkDb,IAAO,mBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
6
6
  "names": []
7
7
  }
@@ -61,7 +61,7 @@ async function logWorkflowEvent(em, event) {
61
61
  organizationId: event.organizationId,
62
62
  occurredAt: /* @__PURE__ */ new Date()
63
63
  });
64
- await em.persistAndFlush(workflowEvent);
64
+ await em.persist(workflowEvent).flush();
65
65
  return workflowEvent;
66
66
  }
67
67
  async function logWorkflowEvents(em, events) {
@@ -77,7 +77,7 @@ async function logWorkflowEvents(em, events) {
77
77
  occurredAt: /* @__PURE__ */ new Date()
78
78
  })
79
79
  );
80
- await em.persistAndFlush(workflowEvents);
80
+ await em.persist(workflowEvents).flush();
81
81
  return workflowEvents;
82
82
  }
83
83
  async function getWorkflowEvents(em, instanceId, options) {