@open-mercato/core 0.4.2-canary-51881f6bf3 → 0.4.2-canary-5f415b8a44

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 (155) hide show
  1. package/dist/generated/entities/workflow_event_trigger/index.js +33 -0
  2. package/dist/generated/entities/workflow_event_trigger/index.js.map +7 -0
  3. package/dist/generated/entities.ids.generated.js +59 -58
  4. package/dist/generated/entities.ids.generated.js.map +2 -2
  5. package/dist/generated/entity-fields-registry.js +2 -0
  6. package/dist/generated/entity-fields-registry.js.map +2 -2
  7. package/dist/modules/auth/events.js +30 -0
  8. package/dist/modules/auth/events.js.map +7 -0
  9. package/dist/modules/business_rules/api/execute/[ruleId]/route.js +145 -0
  10. package/dist/modules/business_rules/api/execute/[ruleId]/route.js.map +7 -0
  11. package/dist/modules/business_rules/data/validators.js +34 -0
  12. package/dist/modules/business_rules/data/validators.js.map +2 -2
  13. package/dist/modules/business_rules/index.js +21 -1
  14. package/dist/modules/business_rules/index.js.map +2 -2
  15. package/dist/modules/business_rules/lib/rule-engine.js +182 -1
  16. package/dist/modules/business_rules/lib/rule-engine.js.map +2 -2
  17. package/dist/modules/catalog/events.js +34 -0
  18. package/dist/modules/catalog/events.js.map +7 -0
  19. package/dist/modules/customers/events.js +49 -0
  20. package/dist/modules/customers/events.js.map +7 -0
  21. package/dist/modules/directory/events.js +23 -0
  22. package/dist/modules/directory/events.js.map +7 -0
  23. package/dist/modules/sales/acl.js +1 -0
  24. package/dist/modules/sales/acl.js.map +2 -2
  25. package/dist/modules/sales/backend/sales/documents/[id]/page.js +12 -0
  26. package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
  27. package/dist/modules/sales/commands/documents.js +62 -0
  28. package/dist/modules/sales/commands/documents.js.map +2 -2
  29. package/dist/modules/sales/events.js +63 -0
  30. package/dist/modules/sales/events.js.map +7 -0
  31. package/dist/modules/sales/lib/dictionaries.js +3 -0
  32. package/dist/modules/sales/lib/dictionaries.js.map +2 -2
  33. package/dist/modules/sales/lib/frontend/documentDataEvents.js +25 -0
  34. package/dist/modules/sales/lib/frontend/documentDataEvents.js.map +7 -0
  35. package/dist/modules/workflows/acl.js +2 -0
  36. package/dist/modules/workflows/acl.js.map +2 -2
  37. package/dist/modules/workflows/api/instances/route.js +18 -6
  38. package/dist/modules/workflows/api/instances/route.js.map +2 -2
  39. package/dist/modules/workflows/api/tasks/route.js +6 -1
  40. package/dist/modules/workflows/api/tasks/route.js.map +2 -2
  41. package/dist/modules/workflows/backend/definitions/[id]/page.js +9 -1
  42. package/dist/modules/workflows/backend/definitions/[id]/page.js.map +2 -2
  43. package/dist/modules/workflows/backend/definitions/[id]/page.meta.js +1 -1
  44. package/dist/modules/workflows/backend/definitions/[id]/page.meta.js.map +2 -2
  45. package/dist/modules/workflows/backend/definitions/create/page.js +24 -15
  46. package/dist/modules/workflows/backend/definitions/create/page.js.map +2 -2
  47. package/dist/modules/workflows/backend/definitions/create/page.meta.js +1 -1
  48. package/dist/modules/workflows/backend/definitions/create/page.meta.js.map +2 -2
  49. package/dist/modules/workflows/backend/definitions/visual-editor/page.js +150 -132
  50. package/dist/modules/workflows/backend/definitions/visual-editor/page.js.map +2 -2
  51. package/dist/modules/workflows/backend/definitions/visual-editor/page.meta.js +1 -1
  52. package/dist/modules/workflows/backend/definitions/visual-editor/page.meta.js.map +2 -2
  53. package/dist/modules/workflows/backend/events/[id]/page.js +1 -1
  54. package/dist/modules/workflows/backend/events/[id]/page.js.map +2 -2
  55. package/dist/modules/workflows/backend/events/[id]/page.meta.js +2 -2
  56. package/dist/modules/workflows/backend/events/[id]/page.meta.js.map +2 -2
  57. package/dist/modules/workflows/backend/instances/[id]/page.meta.js +2 -2
  58. package/dist/modules/workflows/backend/instances/[id]/page.meta.js.map +2 -2
  59. package/dist/modules/workflows/backend/tasks/[id]/page.js +1 -1
  60. package/dist/modules/workflows/backend/tasks/[id]/page.js.map +2 -2
  61. package/dist/modules/workflows/backend/tasks/[id]/page.meta.js +2 -2
  62. package/dist/modules/workflows/backend/tasks/[id]/page.meta.js.map +2 -2
  63. package/dist/modules/workflows/backend/tasks/page.js +5 -6
  64. package/dist/modules/workflows/backend/tasks/page.js.map +2 -2
  65. package/dist/modules/workflows/cli.js +81 -3
  66. package/dist/modules/workflows/cli.js.map +3 -3
  67. package/dist/modules/workflows/components/DefinitionTriggersEditor.js +481 -0
  68. package/dist/modules/workflows/components/DefinitionTriggersEditor.js.map +7 -0
  69. package/dist/modules/workflows/components/EventTriggersEditor.js +553 -0
  70. package/dist/modules/workflows/components/EventTriggersEditor.js.map +7 -0
  71. package/dist/modules/workflows/data/entities.js +64 -1
  72. package/dist/modules/workflows/data/entities.js.map +2 -2
  73. package/dist/modules/workflows/data/validators.js +115 -0
  74. package/dist/modules/workflows/data/validators.js.map +2 -2
  75. package/dist/modules/workflows/events.js +38 -0
  76. package/dist/modules/workflows/events.js.map +7 -0
  77. package/dist/modules/workflows/examples/checkout-demo-definition.json +1 -5
  78. package/dist/modules/workflows/examples/order-approval-definition.json +257 -0
  79. package/dist/modules/workflows/examples/order-approval-guard-rules.json +32 -0
  80. package/dist/modules/workflows/lib/activity-executor.js +75 -13
  81. package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
  82. package/dist/modules/workflows/lib/event-trigger-service.js +308 -0
  83. package/dist/modules/workflows/lib/event-trigger-service.js.map +7 -0
  84. package/dist/modules/workflows/lib/graph-utils.js +71 -2
  85. package/dist/modules/workflows/lib/graph-utils.js.map +2 -2
  86. package/dist/modules/workflows/lib/seeds.js +22 -5
  87. package/dist/modules/workflows/lib/seeds.js.map +2 -2
  88. package/dist/modules/workflows/lib/start-validator.js +33 -23
  89. package/dist/modules/workflows/lib/start-validator.js.map +2 -2
  90. package/dist/modules/workflows/lib/transition-handler.js +157 -45
  91. package/dist/modules/workflows/lib/transition-handler.js.map +3 -3
  92. package/dist/modules/workflows/migrations/Migration20260123143500.js +36 -0
  93. package/dist/modules/workflows/migrations/Migration20260123143500.js.map +7 -0
  94. package/dist/modules/workflows/subscribers/event-trigger.js +78 -0
  95. package/dist/modules/workflows/subscribers/event-trigger.js.map +7 -0
  96. package/dist/modules/workflows/widgets/injection/order-approval/widget.client.js +323 -0
  97. package/dist/modules/workflows/widgets/injection/order-approval/widget.client.js.map +7 -0
  98. package/dist/modules/workflows/widgets/injection/order-approval/widget.js +17 -0
  99. package/dist/modules/workflows/widgets/injection/order-approval/widget.js.map +7 -0
  100. package/dist/modules/workflows/widgets/injection-table.js +19 -0
  101. package/dist/modules/workflows/widgets/injection-table.js.map +7 -0
  102. package/generated/entities/workflow_event_trigger/index.ts +15 -0
  103. package/generated/entities.ids.generated.ts +59 -58
  104. package/generated/entity-fields-registry.ts +2 -0
  105. package/package.json +3 -5
  106. package/src/modules/auth/events.ts +39 -0
  107. package/src/modules/business_rules/api/execute/[ruleId]/route.ts +163 -0
  108. package/src/modules/business_rules/data/validators.ts +40 -0
  109. package/src/modules/business_rules/index.ts +25 -0
  110. package/src/modules/business_rules/lib/rule-engine.ts +281 -1
  111. package/src/modules/catalog/events.ts +45 -0
  112. package/src/modules/customers/events.ts +63 -0
  113. package/src/modules/directory/events.ts +31 -0
  114. package/src/modules/sales/acl.ts +1 -0
  115. package/src/modules/sales/backend/sales/documents/[id]/page.tsx +16 -0
  116. package/src/modules/sales/commands/documents.ts +74 -1
  117. package/src/modules/sales/events.ts +82 -0
  118. package/src/modules/sales/lib/dictionaries.ts +3 -0
  119. package/src/modules/sales/lib/frontend/documentDataEvents.ts +28 -0
  120. package/src/modules/workflows/acl.ts +2 -0
  121. package/src/modules/workflows/api/instances/route.ts +21 -7
  122. package/src/modules/workflows/api/tasks/route.ts +7 -1
  123. package/src/modules/workflows/backend/definitions/[id]/page.meta.ts +1 -1
  124. package/src/modules/workflows/backend/definitions/[id]/page.tsx +9 -0
  125. package/src/modules/workflows/backend/definitions/create/page.meta.ts +1 -1
  126. package/src/modules/workflows/backend/definitions/create/page.tsx +9 -0
  127. package/src/modules/workflows/backend/definitions/visual-editor/page.meta.ts +1 -1
  128. package/src/modules/workflows/backend/definitions/visual-editor/page.tsx +21 -3
  129. package/src/modules/workflows/backend/events/[id]/page.meta.ts +2 -2
  130. package/src/modules/workflows/backend/events/[id]/page.tsx +1 -1
  131. package/src/modules/workflows/backend/instances/[id]/page.meta.ts +2 -2
  132. package/src/modules/workflows/backend/tasks/[id]/page.meta.ts +2 -2
  133. package/src/modules/workflows/backend/tasks/[id]/page.tsx +1 -1
  134. package/src/modules/workflows/backend/tasks/page.tsx +5 -6
  135. package/src/modules/workflows/cli.ts +111 -0
  136. package/src/modules/workflows/components/DefinitionTriggersEditor.tsx +581 -0
  137. package/src/modules/workflows/components/EventTriggersEditor.tsx +664 -0
  138. package/src/modules/workflows/data/entities.ts +124 -0
  139. package/src/modules/workflows/data/validators.ts +138 -0
  140. package/src/modules/workflows/events.ts +49 -0
  141. package/src/modules/workflows/examples/checkout-demo-definition.json +1 -5
  142. package/src/modules/workflows/examples/order-approval-definition.json +257 -0
  143. package/src/modules/workflows/examples/order-approval-guard-rules.json +32 -0
  144. package/src/modules/workflows/i18n/en.json +71 -0
  145. package/src/modules/workflows/lib/activity-executor.ts +129 -16
  146. package/src/modules/workflows/lib/event-trigger-service.ts +557 -0
  147. package/src/modules/workflows/lib/graph-utils.ts +117 -2
  148. package/src/modules/workflows/lib/seeds.ts +34 -8
  149. package/src/modules/workflows/lib/start-validator.ts +38 -28
  150. package/src/modules/workflows/lib/transition-handler.ts +208 -55
  151. package/src/modules/workflows/migrations/Migration20260123143500.ts +38 -0
  152. package/src/modules/workflows/subscribers/event-trigger.ts +109 -0
  153. package/src/modules/workflows/widgets/injection/order-approval/widget.client.tsx +446 -0
  154. package/src/modules/workflows/widgets/injection/order-approval/widget.ts +16 -0
  155. package/src/modules/workflows/widgets/injection-table.ts +21 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/modules/workflows/backend/definitions/create/page.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { CrudForm } from '@open-mercato/ui/backend/CrudForm'\nimport { apiFetch } from '@open-mercato/ui/backend/utils/api'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport {\n workflowDefinitionFormSchema,\n createFormGroups,\n createFieldDefinitions,\n defaultFormValues,\n buildWorkflowPayload,\n type WorkflowDefinitionFormValues,\n} from '../../../components/formConfig'\nimport { StepsEditor } from '../../../components/StepsEditor'\nimport { TransitionsEditor } from '../../../components/TransitionsEditor'\n\nexport default function CreateWorkflowDefinitionPage() {\n const router = useRouter()\n const t = useT()\n\n const handleSubmit = async (values: WorkflowDefinitionFormValues) => {\n const payload = buildWorkflowPayload(values)\n\n const response = await apiFetch('/api/workflows/definitions', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n })\n\n if (!response.ok) {\n const error = await response.json()\n throw new Error(error.error || t('workflows.errors.createFailed'))\n }\n\n const result = await response.json()\n router.push(`/backend/definitions/${result.id}`)\n router.refresh()\n }\n\n const fields = React.useMemo(() => createFieldDefinitions(t), [t])\n\n const formGroups = React.useMemo(\n () => createFormGroups(t, StepsEditor, TransitionsEditor),\n [t]\n )\n\n return (\n <Page>\n <PageBody>\n <CrudForm\n title={t('workflows.create.title')}\n backHref=\"/backend/definitions\"\n schema={workflowDefinitionFormSchema}\n fields={fields}\n initialValues={defaultFormValues}\n onSubmit={handleSubmit}\n cancelHref=\"/backend/definitions\"\n groups={formGroups}\n submitLabel={t('workflows.form.create')}\n />\n </PageBody>\n </Page>\n )\n}\n"],
5
- "mappings": ";AAoDQ;AAlDR,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAC1B,SAAS,MAAM,gBAAgB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAEnB,SAAR,+BAAgD;AACrD,QAAM,SAAS,UAAU;AACzB,QAAM,IAAI,KAAK;AAEf,QAAM,eAAe,OAAO,WAAyC;AACnE,UAAM,UAAU,qBAAqB,MAAM;AAE3C,UAAM,WAAW,MAAM,SAAS,8BAA8B;AAAA,MAC5D,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C,MAAM,KAAK,UAAU,OAAO;AAAA,IAC9B,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,QAAQ,MAAM,SAAS,KAAK;AAClC,YAAM,IAAI,MAAM,MAAM,SAAS,EAAE,+BAA+B,CAAC;AAAA,IACnE;AAEA,UAAM,SAAS,MAAM,SAAS,KAAK;AACnC,WAAO,KAAK,wBAAwB,OAAO,EAAE,EAAE;AAC/C,WAAO,QAAQ;AAAA,EACjB;AAEA,QAAM,SAAS,MAAM,QAAQ,MAAM,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE,QAAM,aAAa,MAAM;AAAA,IACvB,MAAM,iBAAiB,GAAG,aAAa,iBAAiB;AAAA,IACxD,CAAC,CAAC;AAAA,EACJ;AAEA,SACE,oBAAC,QACC,8BAAC,YACC;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,EAAE,wBAAwB;AAAA,MACjC,UAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA,eAAe;AAAA,MACf,UAAU;AAAA,MACV,YAAW;AAAA,MACX,QAAQ;AAAA,MACR,aAAa,EAAE,uBAAuB;AAAA;AAAA,EACxC,GACF,GACF;AAEJ;",
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { CrudForm } from '@open-mercato/ui/backend/CrudForm'\nimport { apiFetch } from '@open-mercato/ui/backend/utils/api'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport {\n workflowDefinitionFormSchema,\n createFormGroups,\n createFieldDefinitions,\n defaultFormValues,\n buildWorkflowPayload,\n type WorkflowDefinitionFormValues,\n} from '../../../components/formConfig'\nimport { StepsEditor } from '../../../components/StepsEditor'\nimport { TransitionsEditor } from '../../../components/TransitionsEditor'\nimport { Alert, AlertDescription, AlertTitle } from '@open-mercato/ui/primitives/alert'\nimport { Zap } from 'lucide-react'\n\nexport default function CreateWorkflowDefinitionPage() {\n const router = useRouter()\n const t = useT()\n\n const handleSubmit = async (values: WorkflowDefinitionFormValues) => {\n const payload = buildWorkflowPayload(values)\n\n const response = await apiFetch('/api/workflows/definitions', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n })\n\n if (!response.ok) {\n const error = await response.json()\n throw new Error(error.error || t('workflows.errors.createFailed'))\n }\n\n const result = await response.json()\n router.push(`/backend/definitions/${result.id}`)\n router.refresh()\n }\n\n const fields = React.useMemo(() => createFieldDefinitions(t), [t])\n\n const formGroups = React.useMemo(\n () => createFormGroups(t, StepsEditor, TransitionsEditor),\n [t]\n )\n\n return (\n <Page>\n <PageBody>\n <Alert variant=\"info\" className=\"mb-6\">\n <Zap className=\"w-4 h-4\" />\n <AlertTitle>Event Triggers</AlertTitle>\n <AlertDescription>\n After creating this workflow definition, you can configure event triggers to automatically start the workflow when specific events occur in the system.\n </AlertDescription>\n </Alert>\n <CrudForm\n title={t('workflows.create.title')}\n backHref=\"/backend/definitions\"\n schema={workflowDefinitionFormSchema}\n fields={fields}\n initialValues={defaultFormValues}\n onSubmit={handleSubmit}\n cancelHref=\"/backend/definitions\"\n groups={formGroups}\n submitLabel={t('workflows.form.create')}\n />\n </PageBody>\n </Page>\n )\n}\n"],
5
+ "mappings": ";AAsDQ,SACE,KADF;AApDR,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAC1B,SAAS,MAAM,gBAAgB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,OAAO,kBAAkB,kBAAkB;AACpD,SAAS,WAAW;AAEL,SAAR,+BAAgD;AACrD,QAAM,SAAS,UAAU;AACzB,QAAM,IAAI,KAAK;AAEf,QAAM,eAAe,OAAO,WAAyC;AACnE,UAAM,UAAU,qBAAqB,MAAM;AAE3C,UAAM,WAAW,MAAM,SAAS,8BAA8B;AAAA,MAC5D,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C,MAAM,KAAK,UAAU,OAAO;AAAA,IAC9B,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,QAAQ,MAAM,SAAS,KAAK;AAClC,YAAM,IAAI,MAAM,MAAM,SAAS,EAAE,+BAA+B,CAAC;AAAA,IACnE;AAEA,UAAM,SAAS,MAAM,SAAS,KAAK;AACnC,WAAO,KAAK,wBAAwB,OAAO,EAAE,EAAE;AAC/C,WAAO,QAAQ;AAAA,EACjB;AAEA,QAAM,SAAS,MAAM,QAAQ,MAAM,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE,QAAM,aAAa,MAAM;AAAA,IACvB,MAAM,iBAAiB,GAAG,aAAa,iBAAiB;AAAA,IACxD,CAAC,CAAC;AAAA,EACJ;AAEA,SACE,oBAAC,QACC,+BAAC,YACC;AAAA,yBAAC,SAAM,SAAQ,QAAO,WAAU,QAC9B;AAAA,0BAAC,OAAI,WAAU,WAAU;AAAA,MACzB,oBAAC,cAAW,4BAAc;AAAA,MAC1B,oBAAC,oBAAiB,qKAElB;AAAA,OACF;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,EAAE,wBAAwB;AAAA,QACjC,UAAS;AAAA,QACT,QAAQ;AAAA,QACR;AAAA,QACA,eAAe;AAAA,QACf,UAAU;AAAA,QACV,YAAW;AAAA,QACX,QAAQ;AAAA,QACR,aAAa,EAAE,uBAAuB;AAAA;AAAA,IACxC;AAAA,KACF,GACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -18,7 +18,7 @@ const metadata = {
18
18
  pageOrder: 100,
19
19
  icon: createIcon,
20
20
  breadcrumb: [
21
- { label: "Workflows", labelKey: "workflows.module.name", href: "/backend/workflows/definitions" },
21
+ { label: "Workflows", labelKey: "workflows.module.name", href: "/backend/definitions" },
22
22
  { label: "Create", labelKey: "workflows.common.create" }
23
23
  ]
24
24
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/modules/workflows/backend/definitions/create/page.meta.ts"],
4
- "sourcesContent": ["import React from 'react'\n\nconst createIcon = React.createElement(\n 'svg',\n { width: 16, height: 16, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2 },\n React.createElement('path', { d: 'M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z' }),\n React.createElement('polyline', { points: '14 2 14 8 20 8' }),\n React.createElement('line', { x1: 12, y1: 13, x2: 12, y2: 19 }),\n React.createElement('line', { x1: 9, y1: 16, x2: 15, y2: 16 })\n)\n\nexport const metadata = {\n requireAuth: true,\n requireFeatures: ['workflows.create'],\n pageTitle: 'Create Workflow Definition',\n pageTitleKey: 'workflows.create.title',\n pageGroup: 'Workflows',\n pageGroupKey: 'workflows.module.name',\n pagePriority: 10,\n pageOrder: 100,\n icon: createIcon,\n breadcrumb: [\n { label: 'Workflows', labelKey: 'workflows.module.name', href: '/backend/workflows/definitions' },\n { label: 'Create', labelKey: 'workflows.common.create' },\n ],\n}\n"],
5
- "mappings": "AAAA,OAAO,WAAW;AAElB,MAAM,aAAa,MAAM;AAAA,EACvB;AAAA,EACA,EAAE,OAAO,IAAI,QAAQ,IAAI,SAAS,aAAa,MAAM,QAAQ,QAAQ,gBAAgB,aAAa,EAAE;AAAA,EACpG,MAAM,cAAc,QAAQ,EAAE,GAAG,6DAA6D,CAAC;AAAA,EAC/F,MAAM,cAAc,YAAY,EAAE,QAAQ,iBAAiB,CAAC;AAAA,EAC5D,MAAM,cAAc,QAAQ,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG,CAAC;AAAA,EAC9D,MAAM,cAAc,QAAQ,EAAE,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG,CAAC;AAC/D;AAEO,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,kBAAkB;AAAA,EACpC,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,cAAc;AAAA,EACd,cAAc;AAAA,EACd,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY;AAAA,IACV,EAAE,OAAO,aAAa,UAAU,yBAAyB,MAAM,iCAAiC;AAAA,IAChG,EAAE,OAAO,UAAU,UAAU,0BAA0B;AAAA,EACzD;AACF;",
4
+ "sourcesContent": ["import React from 'react'\n\nconst createIcon = React.createElement(\n 'svg',\n { width: 16, height: 16, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2 },\n React.createElement('path', { d: 'M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z' }),\n React.createElement('polyline', { points: '14 2 14 8 20 8' }),\n React.createElement('line', { x1: 12, y1: 13, x2: 12, y2: 19 }),\n React.createElement('line', { x1: 9, y1: 16, x2: 15, y2: 16 })\n)\n\nexport const metadata = {\n requireAuth: true,\n requireFeatures: ['workflows.create'],\n pageTitle: 'Create Workflow Definition',\n pageTitleKey: 'workflows.create.title',\n pageGroup: 'Workflows',\n pageGroupKey: 'workflows.module.name',\n pagePriority: 10,\n pageOrder: 100,\n icon: createIcon,\n breadcrumb: [\n { label: 'Workflows', labelKey: 'workflows.module.name', href: '/backend/definitions' },\n { label: 'Create', labelKey: 'workflows.common.create' },\n ],\n}\n"],
5
+ "mappings": "AAAA,OAAO,WAAW;AAElB,MAAM,aAAa,MAAM;AAAA,EACvB;AAAA,EACA,EAAE,OAAO,IAAI,QAAQ,IAAI,SAAS,aAAa,MAAM,QAAQ,QAAQ,gBAAgB,aAAa,EAAE;AAAA,EACpG,MAAM,cAAc,QAAQ,EAAE,GAAG,6DAA6D,CAAC;AAAA,EAC/F,MAAM,cAAc,YAAY,EAAE,QAAQ,iBAAiB,CAAC;AAAA,EAC5D,MAAM,cAAc,QAAQ,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG,CAAC;AAAA,EAC9D,MAAM,cAAc,QAAQ,EAAE,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG,CAAC;AAC/D;AAEO,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,kBAAkB;AAAA,EACpC,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,cAAc;AAAA,EACd,cAAc;AAAA,EACd,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY;AAAA,IACV,EAAE,OAAO,aAAa,UAAU,yBAAyB,MAAM,uBAAuB;AAAA,IACtF,EAAE,OAAO,UAAU,UAAU,0BAA0B;AAAA,EACzD;AACF;",
6
6
  "names": []
7
7
  }
@@ -33,6 +33,7 @@ import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
33
33
  import { flash } from "@open-mercato/ui/backend/FlashMessages";
34
34
  import { CircleQuestionMark, Info, PanelTopClose, PanelTopOpen, Play, Save, Trash2 } from "lucide-react";
35
35
  import { NODE_TYPE_ICONS, NODE_TYPE_COLORS, NODE_TYPE_LABELS } from "../../../lib/node-type-icons.js";
36
+ import { DefinitionTriggersEditor } from "../../../components/DefinitionTriggersEditor.js";
36
37
  function VisualEditorPage() {
37
38
  const t = useT();
38
39
  const router = useRouter();
@@ -58,6 +59,7 @@ function VisualEditorPage() {
58
59
  const [icon, setIcon] = useState("");
59
60
  const [effectiveFrom, setEffectiveFrom] = useState("");
60
61
  const [effectiveTo, setEffectiveTo] = useState("");
62
+ const [triggers, setTriggers] = useState([]);
61
63
  useEffect(() => {
62
64
  const loadDefinition = async () => {
63
65
  if (!definitionId) {
@@ -85,6 +87,7 @@ function VisualEditorPage() {
85
87
  const graph = definitionToGraph(definition.definition);
86
88
  setNodes(graph.nodes);
87
89
  setEdges(graph.edges);
90
+ setTriggers(definition.definition?.triggers || []);
88
91
  flash("Workflow loaded successfully", "success");
89
92
  } catch (error) {
90
93
  console.error("Error loading workflow definition:", error);
@@ -209,7 +212,11 @@ function VisualEditorPage() {
209
212
  flash(`Cannot save: ${criticalErrors.length} validation error(s) found. Please fix them first.`, "error");
210
213
  return;
211
214
  }
212
- const definitionData = graphToDefinition(nodes, edges, { includePositions: true });
215
+ const graphDefinition = graphToDefinition(nodes, edges, { includePositions: true });
216
+ const definitionData = {
217
+ ...graphDefinition,
218
+ triggers: triggers.length > 0 ? triggers : void 0
219
+ };
213
220
  const schemaResult = workflowDefinitionDataSchema.safeParse(definitionData);
214
221
  if (!schemaResult.success) {
215
222
  const firstIssue = schemaResult.error.issues[0];
@@ -265,7 +272,7 @@ function VisualEditorPage() {
265
272
  } finally {
266
273
  setIsSaving(false);
267
274
  }
268
- }, [nodes, edges, workflowId, workflowName, description, version, enabled, category, tags, definitionId, router]);
275
+ }, [nodes, edges, workflowId, workflowName, description, version, enabled, category, tags, triggers, definitionId, router]);
269
276
  const handleTest = useCallback(() => {
270
277
  const errors = validateWorkflowGraph(nodes, edges);
271
278
  const criticalErrors = errors.filter((e) => e.type === "error");
@@ -368,6 +375,7 @@ function VisualEditorPage() {
368
375
  setIcon("");
369
376
  setEffectiveFrom("");
370
377
  setEffectiveTo("");
378
+ setTriggers([]);
371
379
  setShowClearConfirm(false);
372
380
  flash("Canvas cleared", "success");
373
381
  }, []);
@@ -466,142 +474,152 @@ function VisualEditorPage() {
466
474
  )
467
475
  ] })
468
476
  ] }) }),
469
- showMetadata && /* @__PURE__ */ jsx("div", { className: "bg-white border-b border-gray-200 px-6 py-4", children: /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4", children: [
470
- /* @__PURE__ */ jsx("h2", { className: "text-sm font-semibold uppercase text-muted-foreground mb-4", children: "Workflow Metadata" }),
471
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-4", children: [
472
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
473
- /* @__PURE__ */ jsx(Label, { htmlFor: "workflowId", className: "text-xs", children: "Workflow ID *" }),
474
- /* @__PURE__ */ jsx(
475
- Input,
476
- {
477
- id: "workflowId",
478
- value: workflowId,
479
- onChange: (e) => setWorkflowId(e.target.value),
480
- placeholder: "checkout_workflow",
481
- disabled: !!definitionId
482
- }
483
- ),
484
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: definitionId ? "Cannot be changed when editing" : "Lowercase, numbers, hyphens, underscores" })
485
- ] }),
486
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
487
- /* @__PURE__ */ jsx(Label, { htmlFor: "workflowName", className: "text-xs", children: "Workflow Name *" }),
488
- /* @__PURE__ */ jsx(
489
- Input,
490
- {
491
- id: "workflowName",
492
- value: workflowName,
493
- onChange: (e) => setWorkflowName(e.target.value),
494
- placeholder: "Checkout Process"
495
- }
496
- )
497
- ] }),
498
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
499
- /* @__PURE__ */ jsx(Label, { htmlFor: "category", className: "text-xs", children: "Category" }),
500
- /* @__PURE__ */ jsx(
501
- Input,
502
- {
503
- id: "category",
504
- value: category,
505
- onChange: (e) => setCategory(e.target.value),
506
- placeholder: "E-Commerce"
507
- }
508
- )
509
- ] }),
510
- /* @__PURE__ */ jsxs("div", { className: "col-span-3 space-y-1", children: [
511
- /* @__PURE__ */ jsx(Label, { htmlFor: "description", className: "text-xs", children: "Description" }),
512
- /* @__PURE__ */ jsx(
513
- Textarea,
514
- {
515
- id: "description",
516
- value: description,
517
- onChange: (e) => setDescription(e.target.value),
518
- placeholder: "Describe the purpose of this workflow...",
519
- rows: 2
520
- }
521
- )
522
- ] }),
523
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
524
- /* @__PURE__ */ jsx(Label, { htmlFor: "version", className: "text-xs", children: "Version *" }),
525
- /* @__PURE__ */ jsx(
526
- Input,
527
- {
528
- id: "version",
529
- type: "number",
530
- value: version,
531
- onChange: (e) => setVersion(parseInt(e.target.value) || 1),
532
- min: 1,
533
- disabled: !!definitionId
534
- }
535
- ),
536
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Version number (increment for major changes)" })
537
- ] }),
538
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
539
- /* @__PURE__ */ jsx(Label, { className: "text-xs", children: "Enabled" }),
540
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mt-2", children: [
477
+ showMetadata && /* @__PURE__ */ jsxs("div", { className: "bg-white border-b border-gray-200 px-6 py-4", children: [
478
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4", children: [
479
+ /* @__PURE__ */ jsx("h2", { className: "text-sm font-semibold uppercase text-muted-foreground mb-4", children: "Workflow Metadata" }),
480
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-4", children: [
481
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
482
+ /* @__PURE__ */ jsx(Label, { htmlFor: "workflowId", className: "text-xs", children: "Workflow ID *" }),
541
483
  /* @__PURE__ */ jsx(
542
- Switch,
484
+ Input,
543
485
  {
544
- id: "enabled",
545
- checked: enabled,
546
- onCheckedChange: setEnabled
486
+ id: "workflowId",
487
+ value: workflowId,
488
+ onChange: (e) => setWorkflowId(e.target.value),
489
+ placeholder: "checkout_workflow",
490
+ disabled: !!definitionId
547
491
  }
548
492
  ),
549
- /* @__PURE__ */ jsx(Label, { htmlFor: "enabled", className: "text-sm font-normal cursor-pointer", children: "Only enabled workflows can be started" })
493
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: definitionId ? "Cannot be changed when editing" : "Lowercase, numbers, hyphens, underscores" })
494
+ ] }),
495
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
496
+ /* @__PURE__ */ jsx(Label, { htmlFor: "workflowName", className: "text-xs", children: "Workflow Name *" }),
497
+ /* @__PURE__ */ jsx(
498
+ Input,
499
+ {
500
+ id: "workflowName",
501
+ value: workflowName,
502
+ onChange: (e) => setWorkflowName(e.target.value),
503
+ placeholder: "Checkout Process"
504
+ }
505
+ )
506
+ ] }),
507
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
508
+ /* @__PURE__ */ jsx(Label, { htmlFor: "category", className: "text-xs", children: "Category" }),
509
+ /* @__PURE__ */ jsx(
510
+ Input,
511
+ {
512
+ id: "category",
513
+ value: category,
514
+ onChange: (e) => setCategory(e.target.value),
515
+ placeholder: "E-Commerce"
516
+ }
517
+ )
518
+ ] }),
519
+ /* @__PURE__ */ jsxs("div", { className: "col-span-3 space-y-1", children: [
520
+ /* @__PURE__ */ jsx(Label, { htmlFor: "description", className: "text-xs", children: "Description" }),
521
+ /* @__PURE__ */ jsx(
522
+ Textarea,
523
+ {
524
+ id: "description",
525
+ value: description,
526
+ onChange: (e) => setDescription(e.target.value),
527
+ placeholder: "Describe the purpose of this workflow...",
528
+ rows: 2
529
+ }
530
+ )
531
+ ] }),
532
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
533
+ /* @__PURE__ */ jsx(Label, { htmlFor: "version", className: "text-xs", children: "Version *" }),
534
+ /* @__PURE__ */ jsx(
535
+ Input,
536
+ {
537
+ id: "version",
538
+ type: "number",
539
+ value: version,
540
+ onChange: (e) => setVersion(parseInt(e.target.value) || 1),
541
+ min: 1,
542
+ disabled: !!definitionId
543
+ }
544
+ ),
545
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Version number (increment for major changes)" })
546
+ ] }),
547
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
548
+ /* @__PURE__ */ jsx(Label, { className: "text-xs", children: "Enabled" }),
549
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mt-2", children: [
550
+ /* @__PURE__ */ jsx(
551
+ Switch,
552
+ {
553
+ id: "enabled",
554
+ checked: enabled,
555
+ onCheckedChange: setEnabled
556
+ }
557
+ ),
558
+ /* @__PURE__ */ jsx(Label, { htmlFor: "enabled", className: "text-sm font-normal cursor-pointer", children: "Only enabled workflows can be started" })
559
+ ] })
560
+ ] }),
561
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
562
+ /* @__PURE__ */ jsx(Label, { className: "text-xs", children: "Tags" }),
563
+ /* @__PURE__ */ jsx(
564
+ TagsInput,
565
+ {
566
+ value: tags,
567
+ onChange: setTags,
568
+ placeholder: t("workflows.form.placeholders.tags")
569
+ }
570
+ ),
571
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("workflows.form.descriptions.tags") })
572
+ ] }),
573
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
574
+ /* @__PURE__ */ jsx(Label, { htmlFor: "icon", className: "text-xs", children: "Icon" }),
575
+ /* @__PURE__ */ jsx(
576
+ Input,
577
+ {
578
+ id: "icon",
579
+ value: icon,
580
+ onChange: (e) => setIcon(e.target.value),
581
+ placeholder: "ShoppingCart"
582
+ }
583
+ ),
584
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Icon name for visual identification" })
585
+ ] }),
586
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
587
+ /* @__PURE__ */ jsx(Label, { htmlFor: "effectiveFrom", className: "text-xs", children: "Effective From" }),
588
+ /* @__PURE__ */ jsx(
589
+ Input,
590
+ {
591
+ id: "effectiveFrom",
592
+ type: "date",
593
+ value: effectiveFrom,
594
+ onChange: (e) => setEffectiveFrom(e.target.value)
595
+ }
596
+ ),
597
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Workflow becomes active from this date" })
598
+ ] }),
599
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
600
+ /* @__PURE__ */ jsx(Label, { htmlFor: "effectiveTo", className: "text-xs", children: "Effective To" }),
601
+ /* @__PURE__ */ jsx(
602
+ Input,
603
+ {
604
+ id: "effectiveTo",
605
+ type: "date",
606
+ value: effectiveTo,
607
+ onChange: (e) => setEffectiveTo(e.target.value)
608
+ }
609
+ ),
610
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Workflow deactivates after this date" })
550
611
  ] })
551
- ] }),
552
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
553
- /* @__PURE__ */ jsx(Label, { className: "text-xs", children: "Tags" }),
554
- /* @__PURE__ */ jsx(
555
- TagsInput,
556
- {
557
- value: tags,
558
- onChange: setTags,
559
- placeholder: t("workflows.form.placeholders.tags")
560
- }
561
- ),
562
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("workflows.form.descriptions.tags") })
563
- ] }),
564
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
565
- /* @__PURE__ */ jsx(Label, { htmlFor: "icon", className: "text-xs", children: "Icon" }),
566
- /* @__PURE__ */ jsx(
567
- Input,
568
- {
569
- id: "icon",
570
- value: icon,
571
- onChange: (e) => setIcon(e.target.value),
572
- placeholder: "ShoppingCart"
573
- }
574
- ),
575
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Icon name for visual identification" })
576
- ] }),
577
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
578
- /* @__PURE__ */ jsx(Label, { htmlFor: "effectiveFrom", className: "text-xs", children: "Effective From" }),
579
- /* @__PURE__ */ jsx(
580
- Input,
581
- {
582
- id: "effectiveFrom",
583
- type: "date",
584
- value: effectiveFrom,
585
- onChange: (e) => setEffectiveFrom(e.target.value)
586
- }
587
- ),
588
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Workflow becomes active from this date" })
589
- ] }),
590
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
591
- /* @__PURE__ */ jsx(Label, { htmlFor: "effectiveTo", className: "text-xs", children: "Effective To" }),
592
- /* @__PURE__ */ jsx(
593
- Input,
594
- {
595
- id: "effectiveTo",
596
- type: "date",
597
- value: effectiveTo,
598
- onChange: (e) => setEffectiveTo(e.target.value)
599
- }
600
- ),
601
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Workflow deactivates after this date" })
602
612
  ] })
603
- ] })
604
- ] }) }),
613
+ ] }),
614
+ /* @__PURE__ */ jsx(
615
+ DefinitionTriggersEditor,
616
+ {
617
+ value: triggers,
618
+ onChange: setTriggers,
619
+ className: "mt-4"
620
+ }
621
+ )
622
+ ] }),
605
623
  /* @__PURE__ */ jsxs(PageBody, { className: "flex-1 flex overflow-hidden", children: [
606
624
  /* @__PURE__ */ jsx("div", { className: "w-88 bg-white border-r border-gray-200 p-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4", children: [
607
625
  /* @__PURE__ */ jsx("h2", { className: "text-sm font-semibold uppercase text-muted-foreground mb-2", children: "Step Palette" }),