@open-mercato/core 0.4.2-canary-ed15f2e753 → 0.4.2-canary-f075c3eb92

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 (241) hide show
  1. package/dist/generated/entities.ids.generated.js +0 -1
  2. package/dist/generated/entities.ids.generated.js.map +2 -2
  3. package/dist/generated/entity-fields-registry.js +0 -2
  4. package/dist/generated/entity-fields-registry.js.map +2 -2
  5. package/dist/modules/api_keys/setup.js +11 -0
  6. package/dist/modules/api_keys/setup.js.map +7 -0
  7. package/dist/modules/attachments/components/AttachmentLibrary.js +1 -1
  8. package/dist/modules/attachments/components/AttachmentLibrary.js.map +2 -2
  9. package/dist/modules/attachments/lib/assignmentDetails.js +31 -17
  10. package/dist/modules/attachments/lib/assignmentDetails.js.map +2 -2
  11. package/dist/modules/attachments/lib/partitions.js +3 -3
  12. package/dist/modules/attachments/lib/partitions.js.map +2 -2
  13. package/dist/modules/attachments/setup.js +11 -0
  14. package/dist/modules/attachments/setup.js.map +7 -0
  15. package/dist/modules/audit_logs/setup.js +12 -0
  16. package/dist/modules/audit_logs/setup.js.map +7 -0
  17. package/dist/modules/auth/lib/setup-app.js +29 -159
  18. package/dist/modules/auth/lib/setup-app.js.map +2 -2
  19. package/dist/modules/auth/setup.js +11 -0
  20. package/dist/modules/auth/setup.js.map +7 -0
  21. package/dist/modules/business_rules/data/validators.js +0 -34
  22. package/dist/modules/business_rules/data/validators.js.map +2 -2
  23. package/dist/modules/business_rules/index.js +1 -21
  24. package/dist/modules/business_rules/index.js.map +2 -2
  25. package/dist/modules/business_rules/lib/rule-engine.js +1 -182
  26. package/dist/modules/business_rules/lib/rule-engine.js.map +2 -2
  27. package/dist/modules/business_rules/setup.js +11 -0
  28. package/dist/modules/business_rules/setup.js.map +7 -0
  29. package/dist/modules/catalog/setup.js +22 -0
  30. package/dist/modules/catalog/setup.js.map +7 -0
  31. package/dist/modules/configs/lib/upgrade-actions.js +65 -15
  32. package/dist/modules/configs/lib/upgrade-actions.js.map +2 -2
  33. package/dist/modules/configs/setup.js +16 -0
  34. package/dist/modules/configs/setup.js.map +7 -0
  35. package/dist/modules/currencies/setup.js +16 -0
  36. package/dist/modules/currencies/setup.js.map +7 -0
  37. package/dist/modules/customers/setup.js +36 -0
  38. package/dist/modules/customers/setup.js.map +7 -0
  39. package/dist/modules/dashboards/setup.js +12 -0
  40. package/dist/modules/dashboards/setup.js.map +7 -0
  41. package/dist/modules/dictionaries/setup.js +12 -0
  42. package/dist/modules/dictionaries/setup.js.map +7 -0
  43. package/dist/modules/directory/setup.js +12 -0
  44. package/dist/modules/directory/setup.js.map +7 -0
  45. package/dist/modules/entities/setup.js +11 -0
  46. package/dist/modules/entities/setup.js.map +7 -0
  47. package/dist/modules/feature_toggles/setup.js +11 -0
  48. package/dist/modules/feature_toggles/setup.js.map +7 -0
  49. package/dist/modules/perspectives/setup.js +12 -0
  50. package/dist/modules/perspectives/setup.js.map +7 -0
  51. package/dist/modules/planner/setup.js +21 -0
  52. package/dist/modules/planner/setup.js.map +7 -0
  53. package/dist/modules/query_index/setup.js +11 -0
  54. package/dist/modules/query_index/setup.js.map +7 -0
  55. package/dist/modules/resources/setup.js +21 -0
  56. package/dist/modules/resources/setup.js.map +7 -0
  57. package/dist/modules/sales/acl.js +0 -1
  58. package/dist/modules/sales/acl.js.map +2 -2
  59. package/dist/modules/sales/backend/sales/documents/[id]/page.js +0 -12
  60. package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
  61. package/dist/modules/sales/commands/documents.js +0 -62
  62. package/dist/modules/sales/commands/documents.js.map +2 -2
  63. package/dist/modules/sales/lib/dictionaries.js +0 -3
  64. package/dist/modules/sales/lib/dictionaries.js.map +2 -2
  65. package/dist/modules/sales/setup.js +99 -0
  66. package/dist/modules/sales/setup.js.map +7 -0
  67. package/dist/modules/staff/setup.js +27 -0
  68. package/dist/modules/staff/setup.js.map +7 -0
  69. package/dist/modules/workflows/acl.js +0 -2
  70. package/dist/modules/workflows/acl.js.map +2 -2
  71. package/dist/modules/workflows/api/instances/route.js +6 -18
  72. package/dist/modules/workflows/api/instances/route.js.map +2 -2
  73. package/dist/modules/workflows/api/tasks/route.js +1 -6
  74. package/dist/modules/workflows/api/tasks/route.js.map +2 -2
  75. package/dist/modules/workflows/backend/definitions/[id]/page.js +1 -9
  76. package/dist/modules/workflows/backend/definitions/[id]/page.js.map +2 -2
  77. package/dist/modules/workflows/backend/definitions/[id]/page.meta.js +1 -1
  78. package/dist/modules/workflows/backend/definitions/[id]/page.meta.js.map +2 -2
  79. package/dist/modules/workflows/backend/definitions/create/page.js +15 -24
  80. package/dist/modules/workflows/backend/definitions/create/page.js.map +2 -2
  81. package/dist/modules/workflows/backend/definitions/create/page.meta.js +1 -1
  82. package/dist/modules/workflows/backend/definitions/create/page.meta.js.map +2 -2
  83. package/dist/modules/workflows/backend/definitions/visual-editor/page.js +132 -150
  84. package/dist/modules/workflows/backend/definitions/visual-editor/page.js.map +2 -2
  85. package/dist/modules/workflows/backend/definitions/visual-editor/page.meta.js +1 -1
  86. package/dist/modules/workflows/backend/definitions/visual-editor/page.meta.js.map +2 -2
  87. package/dist/modules/workflows/backend/events/[id]/page.js +1 -1
  88. package/dist/modules/workflows/backend/events/[id]/page.js.map +2 -2
  89. package/dist/modules/workflows/backend/events/[id]/page.meta.js +2 -2
  90. package/dist/modules/workflows/backend/events/[id]/page.meta.js.map +2 -2
  91. package/dist/modules/workflows/backend/instances/[id]/page.meta.js +2 -2
  92. package/dist/modules/workflows/backend/instances/[id]/page.meta.js.map +2 -2
  93. package/dist/modules/workflows/backend/tasks/[id]/page.js +1 -1
  94. package/dist/modules/workflows/backend/tasks/[id]/page.js.map +2 -2
  95. package/dist/modules/workflows/backend/tasks/[id]/page.meta.js +2 -2
  96. package/dist/modules/workflows/backend/tasks/[id]/page.meta.js.map +2 -2
  97. package/dist/modules/workflows/backend/tasks/page.js +6 -5
  98. package/dist/modules/workflows/backend/tasks/page.js.map +2 -2
  99. package/dist/modules/workflows/cli.js +3 -81
  100. package/dist/modules/workflows/cli.js.map +3 -3
  101. package/dist/modules/workflows/data/entities.js +1 -64
  102. package/dist/modules/workflows/data/entities.js.map +2 -2
  103. package/dist/modules/workflows/data/validators.js +0 -115
  104. package/dist/modules/workflows/data/validators.js.map +2 -2
  105. package/dist/modules/workflows/examples/checkout-demo-definition.json +5 -1
  106. package/dist/modules/workflows/lib/activity-executor.js +13 -75
  107. package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
  108. package/dist/modules/workflows/lib/graph-utils.js +2 -71
  109. package/dist/modules/workflows/lib/graph-utils.js.map +2 -2
  110. package/dist/modules/workflows/lib/seeds.js +7 -36
  111. package/dist/modules/workflows/lib/seeds.js.map +2 -2
  112. package/dist/modules/workflows/lib/start-validator.js +23 -33
  113. package/dist/modules/workflows/lib/start-validator.js.map +2 -2
  114. package/dist/modules/workflows/lib/transition-handler.js +45 -157
  115. package/dist/modules/workflows/lib/transition-handler.js.map +3 -3
  116. package/dist/modules/workflows/migrations/Migration20251207131955.js +76 -72
  117. package/dist/modules/workflows/migrations/Migration20251207131955.js.map +2 -2
  118. package/dist/modules/workflows/setup.js +16 -0
  119. package/dist/modules/workflows/setup.js.map +7 -0
  120. package/generated/entities.ids.generated.ts +0 -1
  121. package/generated/entity-fields-registry.ts +0 -2
  122. package/package.json +2 -2
  123. package/src/__tests__/module-decoupling.test.ts +356 -0
  124. package/src/modules/api_keys/setup.ts +9 -0
  125. package/src/modules/attachments/components/AttachmentLibrary.tsx +2 -2
  126. package/src/modules/attachments/lib/assignmentDetails.ts +32 -16
  127. package/src/modules/attachments/lib/partitions.ts +3 -3
  128. package/src/modules/attachments/setup.ts +9 -0
  129. package/src/modules/audit_logs/setup.ts +10 -0
  130. package/src/modules/auth/__tests__/cli-setup-acl.test.ts +30 -0
  131. package/src/modules/auth/lib/setup-app.ts +40 -177
  132. package/src/modules/auth/setup.ts +9 -0
  133. package/src/modules/business_rules/data/validators.ts +0 -40
  134. package/src/modules/business_rules/index.ts +0 -25
  135. package/src/modules/business_rules/lib/rule-engine.ts +1 -281
  136. package/src/modules/business_rules/setup.ts +9 -0
  137. package/src/modules/catalog/setup.ts +22 -0
  138. package/src/modules/configs/lib/upgrade-actions.ts +78 -17
  139. package/src/modules/configs/setup.ts +14 -0
  140. package/src/modules/currencies/setup.ts +15 -0
  141. package/src/modules/customers/setup.ts +36 -0
  142. package/src/modules/dashboards/setup.ts +10 -0
  143. package/src/modules/dictionaries/setup.ts +10 -0
  144. package/src/modules/directory/setup.ts +10 -0
  145. package/src/modules/entities/setup.ts +9 -0
  146. package/src/modules/feature_toggles/setup.ts +9 -0
  147. package/src/modules/perspectives/setup.ts +10 -0
  148. package/src/modules/planner/setup.ts +21 -0
  149. package/src/modules/query_index/setup.ts +9 -0
  150. package/src/modules/resources/setup.ts +21 -0
  151. package/src/modules/sales/acl.ts +0 -1
  152. package/src/modules/sales/backend/sales/documents/[id]/page.tsx +0 -16
  153. package/src/modules/sales/commands/documents.ts +1 -74
  154. package/src/modules/sales/lib/dictionaries.ts +0 -3
  155. package/src/modules/sales/setup.ts +108 -0
  156. package/src/modules/staff/setup.ts +27 -0
  157. package/src/modules/workflows/acl.ts +0 -2
  158. package/src/modules/workflows/api/__tests__/instances.route.test.ts +2 -5
  159. package/src/modules/workflows/api/instances/route.ts +7 -21
  160. package/src/modules/workflows/api/tasks/route.ts +1 -7
  161. package/src/modules/workflows/backend/definitions/[id]/page.meta.ts +1 -1
  162. package/src/modules/workflows/backend/definitions/[id]/page.tsx +0 -9
  163. package/src/modules/workflows/backend/definitions/create/page.meta.ts +1 -1
  164. package/src/modules/workflows/backend/definitions/create/page.tsx +0 -9
  165. package/src/modules/workflows/backend/definitions/visual-editor/page.meta.ts +1 -1
  166. package/src/modules/workflows/backend/definitions/visual-editor/page.tsx +3 -21
  167. package/src/modules/workflows/backend/events/[id]/page.meta.ts +2 -2
  168. package/src/modules/workflows/backend/events/[id]/page.tsx +1 -1
  169. package/src/modules/workflows/backend/instances/[id]/page.meta.ts +2 -2
  170. package/src/modules/workflows/backend/tasks/[id]/page.meta.ts +2 -2
  171. package/src/modules/workflows/backend/tasks/[id]/page.tsx +1 -1
  172. package/src/modules/workflows/backend/tasks/page.tsx +6 -5
  173. package/src/modules/workflows/cli.ts +0 -111
  174. package/src/modules/workflows/data/entities.ts +0 -124
  175. package/src/modules/workflows/data/validators.ts +0 -138
  176. package/src/modules/workflows/examples/checkout-demo-definition.json +5 -1
  177. package/src/modules/workflows/i18n/en.json +0 -71
  178. package/src/modules/workflows/lib/__tests__/activity-executor.test.ts +36 -43
  179. package/src/modules/workflows/lib/__tests__/transition-handler.test.ts +90 -170
  180. package/src/modules/workflows/lib/activity-executor.ts +16 -129
  181. package/src/modules/workflows/lib/graph-utils.ts +2 -117
  182. package/src/modules/workflows/lib/seeds.ts +12 -50
  183. package/src/modules/workflows/lib/start-validator.ts +28 -38
  184. package/src/modules/workflows/lib/transition-handler.ts +55 -208
  185. package/src/modules/workflows/migrations/Migration20251207131955.ts +77 -143
  186. package/src/modules/workflows/setup.ts +15 -0
  187. package/dist/generated/entities/workflow_event_trigger/index.js +0 -33
  188. package/dist/generated/entities/workflow_event_trigger/index.js.map +0 -7
  189. package/dist/modules/auth/events.js +0 -30
  190. package/dist/modules/auth/events.js.map +0 -7
  191. package/dist/modules/business_rules/api/execute/[ruleId]/route.js +0 -145
  192. package/dist/modules/business_rules/api/execute/[ruleId]/route.js.map +0 -7
  193. package/dist/modules/catalog/events.js +0 -34
  194. package/dist/modules/catalog/events.js.map +0 -7
  195. package/dist/modules/customers/events.js +0 -49
  196. package/dist/modules/customers/events.js.map +0 -7
  197. package/dist/modules/directory/events.js +0 -23
  198. package/dist/modules/directory/events.js.map +0 -7
  199. package/dist/modules/sales/events.js +0 -63
  200. package/dist/modules/sales/events.js.map +0 -7
  201. package/dist/modules/sales/lib/frontend/documentDataEvents.js +0 -25
  202. package/dist/modules/sales/lib/frontend/documentDataEvents.js.map +0 -7
  203. package/dist/modules/workflows/components/DefinitionTriggersEditor.js +0 -481
  204. package/dist/modules/workflows/components/DefinitionTriggersEditor.js.map +0 -7
  205. package/dist/modules/workflows/components/EventTriggersEditor.js +0 -553
  206. package/dist/modules/workflows/components/EventTriggersEditor.js.map +0 -7
  207. package/dist/modules/workflows/events.js +0 -38
  208. package/dist/modules/workflows/events.js.map +0 -7
  209. package/dist/modules/workflows/examples/order-approval-definition.json +0 -257
  210. package/dist/modules/workflows/examples/order-approval-guard-rules.json +0 -32
  211. package/dist/modules/workflows/lib/event-trigger-service.js +0 -308
  212. package/dist/modules/workflows/lib/event-trigger-service.js.map +0 -7
  213. package/dist/modules/workflows/migrations/Migration20260123143500.js +0 -36
  214. package/dist/modules/workflows/migrations/Migration20260123143500.js.map +0 -7
  215. package/dist/modules/workflows/subscribers/event-trigger.js +0 -78
  216. package/dist/modules/workflows/subscribers/event-trigger.js.map +0 -7
  217. package/dist/modules/workflows/widgets/injection/order-approval/widget.client.js +0 -323
  218. package/dist/modules/workflows/widgets/injection/order-approval/widget.client.js.map +0 -7
  219. package/dist/modules/workflows/widgets/injection/order-approval/widget.js +0 -17
  220. package/dist/modules/workflows/widgets/injection/order-approval/widget.js.map +0 -7
  221. package/dist/modules/workflows/widgets/injection-table.js +0 -19
  222. package/dist/modules/workflows/widgets/injection-table.js.map +0 -7
  223. package/generated/entities/workflow_event_trigger/index.ts +0 -15
  224. package/src/modules/auth/events.ts +0 -39
  225. package/src/modules/business_rules/api/execute/[ruleId]/route.ts +0 -163
  226. package/src/modules/catalog/events.ts +0 -45
  227. package/src/modules/customers/events.ts +0 -63
  228. package/src/modules/directory/events.ts +0 -31
  229. package/src/modules/sales/events.ts +0 -82
  230. package/src/modules/sales/lib/frontend/documentDataEvents.ts +0 -28
  231. package/src/modules/workflows/components/DefinitionTriggersEditor.tsx +0 -581
  232. package/src/modules/workflows/components/EventTriggersEditor.tsx +0 -664
  233. package/src/modules/workflows/events.ts +0 -49
  234. package/src/modules/workflows/examples/order-approval-definition.json +0 -257
  235. package/src/modules/workflows/examples/order-approval-guard-rules.json +0 -32
  236. package/src/modules/workflows/lib/event-trigger-service.ts +0 -557
  237. package/src/modules/workflows/migrations/Migration20260123143500.ts +0 -38
  238. package/src/modules/workflows/subscribers/event-trigger.ts +0 -109
  239. package/src/modules/workflows/widgets/injection/order-approval/widget.client.tsx +0 -446
  240. package/src/modules/workflows/widgets/injection/order-approval/widget.ts +0 -16
  241. package/src/modules/workflows/widgets/injection-table.ts +0 -21
@@ -1,23 +0,0 @@
1
- import { createModuleEvents } from "@open-mercato/shared/modules/events";
2
- const events = [
3
- // Tenants
4
- { id: "directory.tenants.created", label: "Tenant Created", entity: "tenants", category: "crud" },
5
- { id: "directory.tenants.updated", label: "Tenant Updated", entity: "tenants", category: "crud" },
6
- { id: "directory.tenants.deleted", label: "Tenant Deleted", entity: "tenants", category: "crud" },
7
- // Organizations
8
- { id: "directory.organizations.created", label: "Organization Created", entity: "organizations", category: "crud" },
9
- { id: "directory.organizations.updated", label: "Organization Updated", entity: "organizations", category: "crud" },
10
- { id: "directory.organizations.deleted", label: "Organization Deleted", entity: "organizations", category: "crud" }
11
- ];
12
- const eventsConfig = createModuleEvents({
13
- moduleId: "directory",
14
- events
15
- });
16
- const emitDirectoryEvent = eventsConfig.emit;
17
- var events_default = eventsConfig;
18
- export {
19
- events_default as default,
20
- emitDirectoryEvent,
21
- eventsConfig
22
- };
23
- //# sourceMappingURL=events.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/modules/directory/events.ts"],
4
- "sourcesContent": ["import { createModuleEvents } from '@open-mercato/shared/modules/events'\n\n/**\n * Directory Module Events\n *\n * Declares all events that can be emitted by the directory module.\n */\nconst events = [\n // Tenants\n { id: 'directory.tenants.created', label: 'Tenant Created', entity: 'tenants', category: 'crud' },\n { id: 'directory.tenants.updated', label: 'Tenant Updated', entity: 'tenants', category: 'crud' },\n { id: 'directory.tenants.deleted', label: 'Tenant Deleted', entity: 'tenants', category: 'crud' },\n\n // Organizations\n { id: 'directory.organizations.created', label: 'Organization Created', entity: 'organizations', category: 'crud' },\n { id: 'directory.organizations.updated', label: 'Organization Updated', entity: 'organizations', category: 'crud' },\n { id: 'directory.organizations.deleted', label: 'Organization Deleted', entity: 'organizations', category: 'crud' },\n] as const\n\nexport const eventsConfig = createModuleEvents({\n moduleId: 'directory',\n events,\n})\n\n/** Type-safe event emitter for directory module */\nexport const emitDirectoryEvent = eventsConfig.emit\n\n/** Event IDs that can be emitted by the directory module */\nexport type DirectoryEventId = typeof events[number]['id']\n\nexport default eventsConfig\n"],
5
- "mappings": "AAAA,SAAS,0BAA0B;AAOnC,MAAM,SAAS;AAAA;AAAA,EAEb,EAAE,IAAI,6BAA6B,OAAO,kBAAkB,QAAQ,WAAW,UAAU,OAAO;AAAA,EAChG,EAAE,IAAI,6BAA6B,OAAO,kBAAkB,QAAQ,WAAW,UAAU,OAAO;AAAA,EAChG,EAAE,IAAI,6BAA6B,OAAO,kBAAkB,QAAQ,WAAW,UAAU,OAAO;AAAA;AAAA,EAGhG,EAAE,IAAI,mCAAmC,OAAO,wBAAwB,QAAQ,iBAAiB,UAAU,OAAO;AAAA,EAClH,EAAE,IAAI,mCAAmC,OAAO,wBAAwB,QAAQ,iBAAiB,UAAU,OAAO;AAAA,EAClH,EAAE,IAAI,mCAAmC,OAAO,wBAAwB,QAAQ,iBAAiB,UAAU,OAAO;AACpH;AAEO,MAAM,eAAe,mBAAmB;AAAA,EAC7C,UAAU;AAAA,EACV;AACF,CAAC;AAGM,MAAM,qBAAqB,aAAa;AAK/C,IAAO,iBAAQ;",
6
- "names": []
7
- }
@@ -1,63 +0,0 @@
1
- import { createModuleEvents } from "@open-mercato/shared/modules/events";
2
- const events = [
3
- // Orders
4
- { id: "sales.orders.created", label: "Sales Order Created", entity: "orders", category: "crud" },
5
- { id: "sales.orders.updated", label: "Sales Order Updated", entity: "orders", category: "crud" },
6
- { id: "sales.orders.deleted", label: "Sales Order Deleted", entity: "orders", category: "crud" },
7
- // Quotes
8
- { id: "sales.quotes.created", label: "Quote Created", entity: "quotes", category: "crud" },
9
- { id: "sales.quotes.updated", label: "Quote Updated", entity: "quotes", category: "crud" },
10
- { id: "sales.quotes.deleted", label: "Quote Deleted", entity: "quotes", category: "crud" },
11
- // Invoices
12
- { id: "sales.invoices.created", label: "Invoice Created", entity: "invoices", category: "crud" },
13
- { id: "sales.invoices.updated", label: "Invoice Updated", entity: "invoices", category: "crud" },
14
- { id: "sales.invoices.deleted", label: "Invoice Deleted", entity: "invoices", category: "crud" },
15
- // Order Lines
16
- { id: "sales.lines.created", label: "Order Line Created", entity: "lines", category: "crud" },
17
- { id: "sales.lines.updated", label: "Order Line Updated", entity: "lines", category: "crud" },
18
- { id: "sales.lines.deleted", label: "Order Line Deleted", entity: "lines", category: "crud" },
19
- // Payments
20
- { id: "sales.payments.created", label: "Payment Created", entity: "payments", category: "crud" },
21
- { id: "sales.payments.updated", label: "Payment Updated", entity: "payments", category: "crud" },
22
- { id: "sales.payments.deleted", label: "Payment Deleted", entity: "payments", category: "crud" },
23
- // Shipments
24
- { id: "sales.shipments.created", label: "Shipment Created", entity: "shipments", category: "crud" },
25
- { id: "sales.shipments.updated", label: "Shipment Updated", entity: "shipments", category: "crud" },
26
- { id: "sales.shipments.deleted", label: "Shipment Deleted", entity: "shipments", category: "crud" },
27
- // Notes
28
- { id: "sales.notes.created", label: "Note Created", entity: "notes", category: "crud" },
29
- { id: "sales.notes.updated", label: "Note Updated", entity: "notes", category: "crud" },
30
- { id: "sales.notes.deleted", label: "Note Deleted", entity: "notes", category: "crud" },
31
- // Configuration
32
- { id: "sales.configuration.created", label: "Configuration Created", entity: "configuration", category: "crud" },
33
- { id: "sales.configuration.updated", label: "Configuration Updated", entity: "configuration", category: "crud" },
34
- { id: "sales.configuration.deleted", label: "Configuration Deleted", entity: "configuration", category: "crud" },
35
- // Lifecycle events - Document calculations
36
- { id: "sales.document.totals.calculated", label: "Document Totals Calculated", category: "lifecycle" },
37
- { id: "sales.document.calculate.before", label: "Before Document Calculate", category: "lifecycle", excludeFromTriggers: true },
38
- { id: "sales.document.calculate.after", label: "After Document Calculate", category: "lifecycle", excludeFromTriggers: true },
39
- // Lifecycle events - Line calculations
40
- { id: "sales.line.calculate.before", label: "Before Line Calculate", category: "lifecycle", excludeFromTriggers: true },
41
- { id: "sales.line.calculate.after", label: "After Line Calculate", category: "lifecycle", excludeFromTriggers: true },
42
- // Lifecycle events - Tax calculations
43
- { id: "sales.tax.calculate.before", label: "Before Tax Calculate", category: "lifecycle", excludeFromTriggers: true },
44
- { id: "sales.tax.calculate.after", label: "After Tax Calculate", category: "lifecycle", excludeFromTriggers: true },
45
- // Lifecycle events - Shipping adjustments
46
- { id: "sales.shipping.adjustments.apply.before", label: "Before Shipping Adjustments", category: "lifecycle", excludeFromTriggers: true },
47
- { id: "sales.shipping.adjustments.apply.after", label: "After Shipping Adjustments", category: "lifecycle", excludeFromTriggers: true },
48
- // Lifecycle events - Payment adjustments
49
- { id: "sales.payment.adjustments.apply.before", label: "Before Payment Adjustments", category: "lifecycle", excludeFromTriggers: true },
50
- { id: "sales.payment.adjustments.apply.after", label: "After Payment Adjustments", category: "lifecycle", excludeFromTriggers: true }
51
- ];
52
- const eventsConfig = createModuleEvents({
53
- moduleId: "sales",
54
- events
55
- });
56
- const emitSalesEvent = eventsConfig.emit;
57
- var events_default = eventsConfig;
58
- export {
59
- events_default as default,
60
- emitSalesEvent,
61
- eventsConfig
62
- };
63
- //# sourceMappingURL=events.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/modules/sales/events.ts"],
4
- "sourcesContent": ["import { createModuleEvents } from '@open-mercato/shared/modules/events'\n\n/**\n * Sales Module Events\n *\n * Declares all events that can be emitted by the sales module.\n */\nconst events = [\n // Orders\n { id: 'sales.orders.created', label: 'Sales Order Created', entity: 'orders', category: 'crud' },\n { id: 'sales.orders.updated', label: 'Sales Order Updated', entity: 'orders', category: 'crud' },\n { id: 'sales.orders.deleted', label: 'Sales Order Deleted', entity: 'orders', category: 'crud' },\n\n // Quotes\n { id: 'sales.quotes.created', label: 'Quote Created', entity: 'quotes', category: 'crud' },\n { id: 'sales.quotes.updated', label: 'Quote Updated', entity: 'quotes', category: 'crud' },\n { id: 'sales.quotes.deleted', label: 'Quote Deleted', entity: 'quotes', category: 'crud' },\n\n // Invoices\n { id: 'sales.invoices.created', label: 'Invoice Created', entity: 'invoices', category: 'crud' },\n { id: 'sales.invoices.updated', label: 'Invoice Updated', entity: 'invoices', category: 'crud' },\n { id: 'sales.invoices.deleted', label: 'Invoice Deleted', entity: 'invoices', category: 'crud' },\n\n // Order Lines\n { id: 'sales.lines.created', label: 'Order Line Created', entity: 'lines', category: 'crud' },\n { id: 'sales.lines.updated', label: 'Order Line Updated', entity: 'lines', category: 'crud' },\n { id: 'sales.lines.deleted', label: 'Order Line Deleted', entity: 'lines', category: 'crud' },\n\n // Payments\n { id: 'sales.payments.created', label: 'Payment Created', entity: 'payments', category: 'crud' },\n { id: 'sales.payments.updated', label: 'Payment Updated', entity: 'payments', category: 'crud' },\n { id: 'sales.payments.deleted', label: 'Payment Deleted', entity: 'payments', category: 'crud' },\n\n // Shipments\n { id: 'sales.shipments.created', label: 'Shipment Created', entity: 'shipments', category: 'crud' },\n { id: 'sales.shipments.updated', label: 'Shipment Updated', entity: 'shipments', category: 'crud' },\n { id: 'sales.shipments.deleted', label: 'Shipment Deleted', entity: 'shipments', category: 'crud' },\n\n // Notes\n { id: 'sales.notes.created', label: 'Note Created', entity: 'notes', category: 'crud' },\n { id: 'sales.notes.updated', label: 'Note Updated', entity: 'notes', category: 'crud' },\n { id: 'sales.notes.deleted', label: 'Note Deleted', entity: 'notes', category: 'crud' },\n\n // Configuration\n { id: 'sales.configuration.created', label: 'Configuration Created', entity: 'configuration', category: 'crud' },\n { id: 'sales.configuration.updated', label: 'Configuration Updated', entity: 'configuration', category: 'crud' },\n { id: 'sales.configuration.deleted', label: 'Configuration Deleted', entity: 'configuration', category: 'crud' },\n\n // Lifecycle events - Document calculations\n { id: 'sales.document.totals.calculated', label: 'Document Totals Calculated', category: 'lifecycle' },\n { id: 'sales.document.calculate.before', label: 'Before Document Calculate', category: 'lifecycle', excludeFromTriggers: true },\n { id: 'sales.document.calculate.after', label: 'After Document Calculate', category: 'lifecycle', excludeFromTriggers: true },\n\n // Lifecycle events - Line calculations\n { id: 'sales.line.calculate.before', label: 'Before Line Calculate', category: 'lifecycle', excludeFromTriggers: true },\n { id: 'sales.line.calculate.after', label: 'After Line Calculate', category: 'lifecycle', excludeFromTriggers: true },\n\n // Lifecycle events - Tax calculations\n { id: 'sales.tax.calculate.before', label: 'Before Tax Calculate', category: 'lifecycle', excludeFromTriggers: true },\n { id: 'sales.tax.calculate.after', label: 'After Tax Calculate', category: 'lifecycle', excludeFromTriggers: true },\n\n // Lifecycle events - Shipping adjustments\n { id: 'sales.shipping.adjustments.apply.before', label: 'Before Shipping Adjustments', category: 'lifecycle', excludeFromTriggers: true },\n { id: 'sales.shipping.adjustments.apply.after', label: 'After Shipping Adjustments', category: 'lifecycle', excludeFromTriggers: true },\n\n // Lifecycle events - Payment adjustments\n { id: 'sales.payment.adjustments.apply.before', label: 'Before Payment Adjustments', category: 'lifecycle', excludeFromTriggers: true },\n { id: 'sales.payment.adjustments.apply.after', label: 'After Payment Adjustments', category: 'lifecycle', excludeFromTriggers: true },\n] as const\n\nexport const eventsConfig = createModuleEvents({\n moduleId: 'sales',\n events,\n})\n\n/** Type-safe event emitter for sales module */\nexport const emitSalesEvent = eventsConfig.emit\n\n/** Event IDs that can be emitted by the sales module */\nexport type SalesEventId = typeof events[number]['id']\n\nexport default eventsConfig\n"],
5
- "mappings": "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",
6
- "names": []
7
- }
@@ -1,25 +0,0 @@
1
- "use client";
2
- const SALES_DOCUMENT_DATA_REFRESH_EVENT = "sales:document:data:refresh";
3
- function emitSalesDocumentDataRefresh(detail) {
4
- if (typeof window === "undefined" || typeof CustomEvent === "undefined") return;
5
- window.dispatchEvent(
6
- new CustomEvent(SALES_DOCUMENT_DATA_REFRESH_EVENT, { detail })
7
- );
8
- }
9
- function subscribeSalesDocumentDataRefresh(handler) {
10
- if (typeof window === "undefined") return () => {
11
- };
12
- const listener = (event) => {
13
- const detail = event.detail;
14
- if (!detail) return;
15
- handler(detail);
16
- };
17
- window.addEventListener(SALES_DOCUMENT_DATA_REFRESH_EVENT, listener);
18
- return () => window.removeEventListener(SALES_DOCUMENT_DATA_REFRESH_EVENT, listener);
19
- }
20
- export {
21
- SALES_DOCUMENT_DATA_REFRESH_EVENT,
22
- emitSalesDocumentDataRefresh,
23
- subscribeSalesDocumentDataRefresh
24
- };
25
- //# sourceMappingURL=documentDataEvents.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/modules/sales/lib/frontend/documentDataEvents.ts"],
4
- "sourcesContent": ["\"use client\"\n\nexport const SALES_DOCUMENT_DATA_REFRESH_EVENT = 'sales:document:data:refresh'\n\nexport type SalesDocumentDataRefreshDetail = {\n documentId: string\n kind?: 'order' | 'quote'\n}\n\nexport function emitSalesDocumentDataRefresh(detail: SalesDocumentDataRefreshDetail): void {\n if (typeof window === 'undefined' || typeof CustomEvent === 'undefined') return\n window.dispatchEvent(\n new CustomEvent<SalesDocumentDataRefreshDetail>(SALES_DOCUMENT_DATA_REFRESH_EVENT, { detail }),\n )\n}\n\nexport function subscribeSalesDocumentDataRefresh(\n handler: (detail: SalesDocumentDataRefreshDetail) => void,\n): () => void {\n if (typeof window === 'undefined') return () => {}\n const listener = (event: Event) => {\n const detail = (event as CustomEvent<SalesDocumentDataRefreshDetail>).detail\n if (!detail) return\n handler(detail)\n }\n window.addEventListener(SALES_DOCUMENT_DATA_REFRESH_EVENT, listener as EventListener)\n return () => window.removeEventListener(SALES_DOCUMENT_DATA_REFRESH_EVENT, listener as EventListener)\n}\n"],
5
- "mappings": ";AAEO,MAAM,oCAAoC;AAO1C,SAAS,6BAA6B,QAA8C;AACzF,MAAI,OAAO,WAAW,eAAe,OAAO,gBAAgB,YAAa;AACzE,SAAO;AAAA,IACL,IAAI,YAA4C,mCAAmC,EAAE,OAAO,CAAC;AAAA,EAC/F;AACF;AAEO,SAAS,kCACd,SACY;AACZ,MAAI,OAAO,WAAW,YAAa,QAAO,MAAM;AAAA,EAAC;AACjD,QAAM,WAAW,CAAC,UAAiB;AACjC,UAAM,SAAU,MAAsD;AACtE,QAAI,CAAC,OAAQ;AACb,YAAQ,MAAM;AAAA,EAChB;AACA,SAAO,iBAAiB,mCAAmC,QAAyB;AACpF,SAAO,MAAM,OAAO,oBAAoB,mCAAmC,QAAyB;AACtG;",
6
- "names": []
7
- }
@@ -1,481 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useState, useCallback } from "react";
4
- import { Button } from "@open-mercato/ui/primitives/button";
5
- import { Input } from "@open-mercato/ui/primitives/input";
6
- import { Textarea } from "@open-mercato/ui/primitives/textarea";
7
- import { Label } from "@open-mercato/ui/primitives/label";
8
- import { Switch } from "@open-mercato/ui/primitives/switch";
9
- import { Badge } from "@open-mercato/ui/primitives/badge";
10
- import {
11
- Dialog,
12
- DialogContent,
13
- DialogDescription,
14
- DialogFooter,
15
- DialogHeader,
16
- DialogTitle
17
- } from "@open-mercato/ui/primitives/dialog";
18
- import { Alert, AlertDescription, AlertTitle } from "@open-mercato/ui/primitives/alert";
19
- import { EventSelect } from "@open-mercato/ui/backend/inputs/EventSelect";
20
- import { useT } from "@open-mercato/shared/lib/i18n/context";
21
- import { Plus, Trash2, Edit2, Zap, Info, X } from "lucide-react";
22
- const FILTER_OPERATORS = [
23
- { value: "eq", label: "Equals" },
24
- { value: "neq", label: "Not Equals" },
25
- { value: "gt", label: "Greater Than" },
26
- { value: "gte", label: "Greater Than or Equal" },
27
- { value: "lt", label: "Less Than" },
28
- { value: "lte", label: "Less Than or Equal" },
29
- { value: "contains", label: "Contains" },
30
- { value: "startsWith", label: "Starts With" },
31
- { value: "endsWith", label: "Ends With" },
32
- { value: "in", label: "In (array)" },
33
- { value: "notIn", label: "Not In (array)" },
34
- { value: "exists", label: "Exists" },
35
- { value: "notExists", label: "Not Exists" },
36
- { value: "regex", label: "Regex Match" }
37
- ];
38
- const defaultFormValues = {
39
- triggerId: "",
40
- name: "",
41
- description: "",
42
- eventPattern: "",
43
- enabled: true,
44
- priority: 0,
45
- filterConditions: [],
46
- contextMappings: [],
47
- debounceMs: "",
48
- maxConcurrentInstances: ""
49
- };
50
- function DefinitionTriggersEditor({
51
- value,
52
- onChange,
53
- className
54
- }) {
55
- const t = useT();
56
- const [showDialog, setShowDialog] = useState(false);
57
- const [editingTrigger, setEditingTrigger] = useState(null);
58
- const [formValues, setFormValues] = useState(defaultFormValues);
59
- const [deleteConfirmId, setDeleteConfirmId] = useState(null);
60
- const generateTriggerId = useCallback((name) => {
61
- return name.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").substring(0, 50) || `trigger_${Date.now()}`;
62
- }, []);
63
- const parseConditionValue = (valueStr) => {
64
- try {
65
- return JSON.parse(valueStr);
66
- } catch {
67
- return valueStr;
68
- }
69
- };
70
- const buildTriggerFromForm = useCallback((values) => {
71
- const config = {};
72
- if (values.filterConditions.length > 0) {
73
- config.filterConditions = values.filterConditions.map((fc) => ({
74
- field: fc.field,
75
- operator: fc.operator,
76
- value: parseConditionValue(fc.value)
77
- }));
78
- }
79
- if (values.contextMappings.length > 0) {
80
- config.contextMapping = values.contextMappings.map((cm) => ({
81
- targetKey: cm.targetKey,
82
- sourceExpression: cm.sourceExpression,
83
- defaultValue: cm.defaultValue ? parseConditionValue(cm.defaultValue) : void 0
84
- }));
85
- }
86
- if (values.debounceMs) {
87
- config.debounceMs = parseInt(values.debounceMs, 10);
88
- }
89
- if (values.maxConcurrentInstances) {
90
- config.maxConcurrentInstances = parseInt(values.maxConcurrentInstances, 10);
91
- }
92
- return {
93
- triggerId: values.triggerId || generateTriggerId(values.name),
94
- name: values.name,
95
- description: values.description || null,
96
- eventPattern: values.eventPattern,
97
- enabled: values.enabled,
98
- priority: values.priority,
99
- config: Object.keys(config).length > 0 ? config : null
100
- };
101
- }, [generateTriggerId]);
102
- const handleCreateNew = useCallback(() => {
103
- setEditingTrigger(null);
104
- setFormValues(defaultFormValues);
105
- setShowDialog(true);
106
- }, []);
107
- const handleEdit = useCallback((trigger) => {
108
- setEditingTrigger(trigger);
109
- setFormValues({
110
- triggerId: trigger.triggerId,
111
- name: trigger.name,
112
- description: trigger.description || "",
113
- eventPattern: trigger.eventPattern,
114
- enabled: trigger.enabled,
115
- priority: trigger.priority,
116
- filterConditions: trigger.config?.filterConditions?.map((fc) => ({
117
- field: fc.field,
118
- operator: fc.operator,
119
- value: typeof fc.value === "string" ? fc.value : JSON.stringify(fc.value)
120
- })) || [],
121
- contextMappings: trigger.config?.contextMapping?.map((cm) => ({
122
- targetKey: cm.targetKey,
123
- sourceExpression: cm.sourceExpression,
124
- defaultValue: cm.defaultValue !== void 0 ? typeof cm.defaultValue === "string" ? cm.defaultValue : JSON.stringify(cm.defaultValue) : ""
125
- })) || [],
126
- debounceMs: trigger.config?.debounceMs?.toString() || "",
127
- maxConcurrentInstances: trigger.config?.maxConcurrentInstances?.toString() || ""
128
- });
129
- setShowDialog(true);
130
- }, []);
131
- const handleCloseDialog = useCallback(() => {
132
- setShowDialog(false);
133
- setEditingTrigger(null);
134
- setFormValues(defaultFormValues);
135
- }, []);
136
- const handleSubmit = useCallback(() => {
137
- if (!formValues.name.trim()) {
138
- return;
139
- }
140
- if (!formValues.eventPattern.trim()) {
141
- return;
142
- }
143
- const newTrigger = buildTriggerFromForm(formValues);
144
- if (editingTrigger) {
145
- onChange(value.map((t2) => t2.triggerId === editingTrigger.triggerId ? newTrigger : t2));
146
- } else {
147
- const existingIds = new Set(value.map((t2) => t2.triggerId));
148
- if (existingIds.has(newTrigger.triggerId)) {
149
- newTrigger.triggerId = `${newTrigger.triggerId}_${Date.now()}`;
150
- }
151
- onChange([...value, newTrigger]);
152
- }
153
- handleCloseDialog();
154
- }, [formValues, editingTrigger, buildTriggerFromForm, value, onChange, handleCloseDialog]);
155
- const handleDelete = useCallback((triggerId) => {
156
- onChange(value.filter((t2) => t2.triggerId !== triggerId));
157
- setDeleteConfirmId(null);
158
- }, [value, onChange]);
159
- const addFilterCondition = useCallback(() => {
160
- setFormValues((prev) => ({
161
- ...prev,
162
- filterConditions: [...prev.filterConditions, { field: "", operator: "eq", value: "" }]
163
- }));
164
- }, []);
165
- const removeFilterCondition = useCallback((index) => {
166
- setFormValues((prev) => ({
167
- ...prev,
168
- filterConditions: prev.filterConditions.filter((_, i) => i !== index)
169
- }));
170
- }, []);
171
- const updateFilterCondition = useCallback((index, field, fieldValue) => {
172
- setFormValues((prev) => ({
173
- ...prev,
174
- filterConditions: prev.filterConditions.map(
175
- (fc, i) => i === index ? { ...fc, [field]: fieldValue } : fc
176
- )
177
- }));
178
- }, []);
179
- const addContextMapping = useCallback(() => {
180
- setFormValues((prev) => ({
181
- ...prev,
182
- contextMappings: [...prev.contextMappings, { targetKey: "", sourceExpression: "", defaultValue: "" }]
183
- }));
184
- }, []);
185
- const removeContextMapping = useCallback((index) => {
186
- setFormValues((prev) => ({
187
- ...prev,
188
- contextMappings: prev.contextMappings.filter((_, i) => i !== index)
189
- }));
190
- }, []);
191
- const updateContextMapping = useCallback((index, field, fieldValue) => {
192
- setFormValues((prev) => ({
193
- ...prev,
194
- contextMappings: prev.contextMappings.map(
195
- (cm, i) => i === index ? { ...cm, [field]: fieldValue } : cm
196
- )
197
- }));
198
- }, []);
199
- return /* @__PURE__ */ jsxs("div", { className, children: [
200
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4", children: [
201
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-4", children: [
202
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
203
- /* @__PURE__ */ jsx(Zap, { className: "w-5 h-5 text-amber-500" }),
204
- /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold uppercase text-muted-foreground", children: t("workflows.triggers.title", "Event Triggers") })
205
- ] }),
206
- /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", onClick: handleCreateNew, children: [
207
- /* @__PURE__ */ jsx(Plus, { className: "w-4 h-4 mr-1" }),
208
- t("workflows.triggers.add", "Add Trigger")
209
- ] })
210
- ] }),
211
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mb-4", children: t("workflows.triggers.description", "Configure events that automatically start this workflow. When a matching event occurs in the system, a new workflow instance will be created with the mapped context.") }),
212
- value.length === 0 ? /* @__PURE__ */ jsxs(Alert, { variant: "info", children: [
213
- /* @__PURE__ */ jsx(Info, { className: "w-4 h-4" }),
214
- /* @__PURE__ */ jsx(AlertTitle, { children: t("workflows.triggers.empty.title", "No triggers configured") }),
215
- /* @__PURE__ */ jsx(AlertDescription, { children: t("workflows.triggers.empty.description", 'Click "Add Trigger" to create an event trigger that automatically starts this workflow.') })
216
- ] }) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: value.map((trigger) => /* @__PURE__ */ jsxs(
217
- "div",
218
- {
219
- className: "flex items-center justify-between p-3 rounded-lg border bg-background hover:bg-accent/50 transition-colors",
220
- children: [
221
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
222
- /* @__PURE__ */ jsx(Badge, { variant: trigger.enabled ? "default" : "secondary", children: trigger.enabled ? t("common.active", "Active") : t("common.disabled", "Disabled") }),
223
- /* @__PURE__ */ jsxs("div", { children: [
224
- /* @__PURE__ */ jsx("div", { className: "font-medium text-sm", children: trigger.name }),
225
- /* @__PURE__ */ jsx("code", { className: "text-xs text-muted-foreground", children: trigger.eventPattern })
226
- ] })
227
- ] }),
228
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
229
- /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: () => handleEdit(trigger), children: /* @__PURE__ */ jsx(Edit2, { className: "w-4 h-4" }) }),
230
- /* @__PURE__ */ jsx(
231
- Button,
232
- {
233
- size: "sm",
234
- variant: "ghost",
235
- className: "text-destructive hover:text-destructive",
236
- onClick: () => setDeleteConfirmId(trigger.triggerId),
237
- children: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" })
238
- }
239
- )
240
- ] })
241
- ]
242
- },
243
- trigger.triggerId
244
- )) })
245
- ] }),
246
- /* @__PURE__ */ jsx(Dialog, { open: showDialog, onOpenChange: setShowDialog, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-2xl max-h-[90vh] overflow-y-auto", children: [
247
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
248
- /* @__PURE__ */ jsx(DialogTitle, { children: editingTrigger ? t("workflows.triggers.dialog.edit.title", "Edit Event Trigger") : t("workflows.triggers.dialog.create.title", "Create Event Trigger") }),
249
- /* @__PURE__ */ jsx(DialogDescription, { children: t("workflows.triggers.dialog.description", "Configure when this workflow should be automatically started based on system events.") })
250
- ] }),
251
- /* @__PURE__ */ jsxs("div", { className: "space-y-4 py-4", children: [
252
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
253
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
254
- /* @__PURE__ */ jsxs(Label, { htmlFor: "trigger-name", children: [
255
- t("workflows.triggers.fields.name", "Name"),
256
- " *"
257
- ] }),
258
- /* @__PURE__ */ jsx(
259
- Input,
260
- {
261
- id: "trigger-name",
262
- value: formValues.name,
263
- onChange: (e) => setFormValues((prev) => ({ ...prev, name: e.target.value })),
264
- placeholder: t("workflows.triggers.placeholders.name", "Order Created Trigger")
265
- }
266
- )
267
- ] }),
268
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
269
- /* @__PURE__ */ jsx(Label, { htmlFor: "trigger-priority", children: t("workflows.triggers.fields.priority", "Priority") }),
270
- /* @__PURE__ */ jsx(
271
- Input,
272
- {
273
- id: "trigger-priority",
274
- type: "number",
275
- value: formValues.priority,
276
- onChange: (e) => setFormValues((prev) => ({ ...prev, priority: parseInt(e.target.value) || 0 })),
277
- placeholder: "0"
278
- }
279
- ),
280
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("workflows.triggers.hints.priority", "Higher priority triggers execute first") })
281
- ] })
282
- ] }),
283
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
284
- /* @__PURE__ */ jsx(Label, { htmlFor: "trigger-description", children: t("workflows.triggers.fields.description", "Description") }),
285
- /* @__PURE__ */ jsx(
286
- Textarea,
287
- {
288
- id: "trigger-description",
289
- value: formValues.description,
290
- onChange: (e) => setFormValues((prev) => ({ ...prev, description: e.target.value })),
291
- placeholder: t("workflows.triggers.placeholders.description", "Describe when this trigger should fire..."),
292
- rows: 2
293
- }
294
- )
295
- ] }),
296
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
297
- /* @__PURE__ */ jsxs(Label, { htmlFor: "trigger-pattern", children: [
298
- t("workflows.triggers.fields.eventPattern", "Event Pattern"),
299
- " *"
300
- ] }),
301
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
302
- /* @__PURE__ */ jsx(
303
- Input,
304
- {
305
- id: "trigger-pattern",
306
- value: formValues.eventPattern,
307
- onChange: (e) => setFormValues((prev) => ({ ...prev, eventPattern: e.target.value })),
308
- placeholder: "sales.orders.created",
309
- className: "flex-1"
310
- }
311
- ),
312
- /* @__PURE__ */ jsx(
313
- EventSelect,
314
- {
315
- value: "",
316
- onChange: (eventId) => setFormValues((prev) => ({ ...prev, eventPattern: eventId })),
317
- placeholder: t("workflows.triggers.placeholders.quickSelect", "Quick select..."),
318
- className: "w-[200px]"
319
- }
320
- )
321
- ] }),
322
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("workflows.triggers.hints.eventPattern", 'Use * as wildcard: "sales.orders.*" matches any order event') })
323
- ] }),
324
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
325
- /* @__PURE__ */ jsx(
326
- Switch,
327
- {
328
- id: "trigger-enabled",
329
- checked: formValues.enabled,
330
- onCheckedChange: (checked) => setFormValues((prev) => ({ ...prev, enabled: checked }))
331
- }
332
- ),
333
- /* @__PURE__ */ jsx(Label, { htmlFor: "trigger-enabled", children: t("workflows.triggers.fields.enabled", "Enabled") })
334
- ] }),
335
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
336
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
337
- /* @__PURE__ */ jsx(Label, { children: t("workflows.triggers.fields.filterConditions", "Filter Conditions") }),
338
- /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "ghost", onClick: addFilterCondition, children: [
339
- /* @__PURE__ */ jsx(Plus, { className: "w-4 h-4 mr-1" }),
340
- t("workflows.triggers.addCondition", "Add Condition")
341
- ] })
342
- ] }),
343
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("workflows.triggers.hints.filterConditions", "Only trigger when the event payload matches these conditions (all must match)") }),
344
- formValues.filterConditions.map((fc, index) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
345
- /* @__PURE__ */ jsx(
346
- Input,
347
- {
348
- value: fc.field,
349
- onChange: (e) => updateFilterCondition(index, "field", e.target.value),
350
- placeholder: "status",
351
- className: "w-1/3"
352
- }
353
- ),
354
- /* @__PURE__ */ jsx(
355
- "select",
356
- {
357
- value: fc.operator,
358
- onChange: (e) => updateFilterCondition(index, "operator", e.target.value),
359
- className: "h-10 w-[140px] rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
360
- children: FILTER_OPERATORS.map((op) => /* @__PURE__ */ jsx("option", { value: op.value, children: op.label }, op.value))
361
- }
362
- ),
363
- /* @__PURE__ */ jsx(
364
- Input,
365
- {
366
- value: fc.value,
367
- onChange: (e) => updateFilterCondition(index, "value", e.target.value),
368
- placeholder: "submitted",
369
- className: "flex-1"
370
- }
371
- ),
372
- /* @__PURE__ */ jsx(Button, { size: "icon", variant: "ghost", onClick: () => removeFilterCondition(index), children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" }) })
373
- ] }, index))
374
- ] }),
375
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
376
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
377
- /* @__PURE__ */ jsx(Label, { children: t("workflows.triggers.fields.contextMapping", "Context Mapping") }),
378
- /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "ghost", onClick: addContextMapping, children: [
379
- /* @__PURE__ */ jsx(Plus, { className: "w-4 h-4 mr-1" }),
380
- t("workflows.triggers.addMapping", "Add Mapping")
381
- ] })
382
- ] }),
383
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("workflows.triggers.hints.contextMapping", "Map values from the event payload to the workflow's initial context") }),
384
- formValues.contextMappings.map((cm, index) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
385
- /* @__PURE__ */ jsx(
386
- Input,
387
- {
388
- value: cm.targetKey,
389
- onChange: (e) => updateContextMapping(index, "targetKey", e.target.value),
390
- placeholder: "orderId",
391
- className: "w-1/3"
392
- }
393
- ),
394
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "=" }),
395
- /* @__PURE__ */ jsx(
396
- Input,
397
- {
398
- value: cm.sourceExpression,
399
- onChange: (e) => updateContextMapping(index, "sourceExpression", e.target.value),
400
- placeholder: "id",
401
- className: "flex-1"
402
- }
403
- ),
404
- /* @__PURE__ */ jsx(
405
- Input,
406
- {
407
- value: cm.defaultValue,
408
- onChange: (e) => updateContextMapping(index, "defaultValue", e.target.value),
409
- placeholder: "default",
410
- className: "w-24"
411
- }
412
- ),
413
- /* @__PURE__ */ jsx(Button, { size: "icon", variant: "ghost", onClick: () => removeContextMapping(index), children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" }) })
414
- ] }, index))
415
- ] }),
416
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
417
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
418
- /* @__PURE__ */ jsx(Label, { htmlFor: "trigger-debounce", children: t("workflows.triggers.fields.debounceMs", "Debounce (ms)") }),
419
- /* @__PURE__ */ jsx(
420
- Input,
421
- {
422
- id: "trigger-debounce",
423
- type: "number",
424
- value: formValues.debounceMs,
425
- onChange: (e) => setFormValues((prev) => ({ ...prev, debounceMs: e.target.value })),
426
- placeholder: "0"
427
- }
428
- ),
429
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("workflows.triggers.hints.debounce", "Delay to prevent rapid re-triggers") })
430
- ] }),
431
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
432
- /* @__PURE__ */ jsx(Label, { htmlFor: "trigger-max-concurrent", children: t("workflows.triggers.fields.maxConcurrent", "Max Concurrent Instances") }),
433
- /* @__PURE__ */ jsx(
434
- Input,
435
- {
436
- id: "trigger-max-concurrent",
437
- type: "number",
438
- value: formValues.maxConcurrentInstances,
439
- onChange: (e) => setFormValues((prev) => ({ ...prev, maxConcurrentInstances: e.target.value })),
440
- placeholder: t("workflows.triggers.placeholders.unlimited", "Unlimited")
441
- }
442
- ),
443
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("workflows.triggers.hints.maxConcurrent", "Limit simultaneous workflow instances") })
444
- ] })
445
- ] })
446
- ] }),
447
- /* @__PURE__ */ jsxs(DialogFooter, { children: [
448
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: handleCloseDialog, children: t("common.cancel", "Cancel") }),
449
- /* @__PURE__ */ jsx(
450
- Button,
451
- {
452
- onClick: handleSubmit,
453
- disabled: !formValues.name.trim() || !formValues.eventPattern.trim(),
454
- children: editingTrigger ? t("common.update", "Update") : t("common.create", "Create")
455
- }
456
- )
457
- ] })
458
- ] }) }),
459
- /* @__PURE__ */ jsx(Dialog, { open: !!deleteConfirmId, onOpenChange: () => setDeleteConfirmId(null), children: /* @__PURE__ */ jsxs(DialogContent, { children: [
460
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
461
- /* @__PURE__ */ jsx(DialogTitle, { children: t("workflows.triggers.delete.title", "Delete Event Trigger?") }),
462
- /* @__PURE__ */ jsx(DialogDescription, { children: t("workflows.triggers.delete.description", "This will remove the event trigger. The change will take effect when you save the workflow definition.") })
463
- ] }),
464
- /* @__PURE__ */ jsxs(DialogFooter, { children: [
465
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => setDeleteConfirmId(null), children: t("common.cancel", "Cancel") }),
466
- /* @__PURE__ */ jsx(
467
- Button,
468
- {
469
- variant: "destructive",
470
- onClick: () => deleteConfirmId && handleDelete(deleteConfirmId),
471
- children: t("common.delete", "Delete")
472
- }
473
- )
474
- ] })
475
- ] }) })
476
- ] });
477
- }
478
- export {
479
- DefinitionTriggersEditor
480
- };
481
- //# sourceMappingURL=DefinitionTriggersEditor.js.map