@gadmin2n/schematics 0.0.72 → 0.0.74
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.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/job.prisma +62 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/system.prisma +0 -21
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/workflow.prisma +171 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/AgendaJob.ts +60 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/Event.ts +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/WorkflowEventOutbox.ts +62 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/WorkflowNodeInstance.ts +62 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/WorkflowNodeType.ts +62 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/.env +5 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/package.json +5 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/prisma.config.ts +14 -7
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/index.ts +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/permissions.ts +49 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/workflow-node-types.ts +746 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/workflows.ts +786 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/agenda/agenda.controller.ts +6 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/agenda/agenda.service.ts +79 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/agendaJob/agendaJob.controller.spec.ts +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/agendaJob/agendaJob.controller.ts +145 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/agendaJob/agendaJob.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/{canvas/canvas.service.spec.ts → agendaJob/agendaJob.service.spec.ts} +71 -65
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/agendaJob/agendaJob.service.ts +83 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/index.ts +2 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/temporal.module.ts +9 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/temporal.service.ts +100 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-execution.dto.ts +19 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-export.dto.ts +43 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-export.service.ts +317 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-node-type.controller.ts +16 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-node-type.service.ts +13 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.controller.ts +220 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.dto.ts +82 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.module.ts +16 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.service.ts +505 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowEventOutbox/workflowEventOutbox.controller.spec.ts +22 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowEventOutbox/workflowEventOutbox.controller.ts +147 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowEventOutbox/workflowEventOutbox.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowEventOutbox/workflowEventOutbox.service.spec.ts +356 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowEventOutbox/workflowEventOutbox.service.ts +110 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/workflowNodeInstance.controller.spec.ts +22 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/workflowNodeInstance.controller.ts +216 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/workflowNodeInstance.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/workflowNodeInstance.service.spec.ts +356 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/workflowNodeInstance.service.ts +168 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeType/workflowNodeType.controller.spec.ts +22 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeType/workflowNodeType.controller.ts +199 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeType/workflowNodeType.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeType/workflowNodeType.service.spec.ts +348 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeType/workflowNodeType.service.ts +106 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/yarn.lock +579 -1082
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/README.md +278 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/config/development-sql.yaml +5 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/docker-compose.yml +25 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/package.json +13 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/sql/create-event-trigger.sql +87 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/.env +7 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/SANDBOX.md +122 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/package-lock.json +4285 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/package.json +28 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/__tests__/activities/code-execute.test.ts +44 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/__tests__/activities/http-request.test.ts +87 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/__tests__/helpers.test.ts +225 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/__tests__/node-type-consistency.test.ts +101 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/activities/code-execute.ts +51 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/activities/db-execute.ts +85 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/activities/db-query.ts +35 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/activities/http-request.ts +54 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/activities/index.ts +6 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/activities/reporting.ts +62 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/activities/send-notification.ts +47 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/config.ts +13 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/dsl/condition.ts +101 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/dsl/context.ts +58 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/dsl/graph.ts +184 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/dsl/helpers.ts +133 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/dsl/node-types.ts +57 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/dsl/types.ts +77 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/index.ts +36 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/outbox-poller.ts +226 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/src/workflows/dsl-workflow.ts +411 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/tsconfig.json +19 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/vitest.config.ts +8 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/worker/yarn.lock +1905 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/package-lock.json +17555 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/package.json +5 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/App.tsx +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/sider.tsx +5 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/title.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/config/routeRegistry.tsx +63 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/DevShell.tsx +91 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/list.tsx +48 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/show.tsx +43 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/locales/en/common.json +14 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/locales/zh_CN/common.json +14 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agenda/index.tsx +309 -56
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agenda/show.tsx +1 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agendaJob/create.tsx +108 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agendaJob/edit.tsx +124 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agendaJob/index.tsx +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agendaJob/list.tsx +245 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agendaJob/show.tsx +70 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasListPage.tsx +0 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasPage.tsx +160 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasToolbar.tsx +120 -148
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CodeFloatWindow.tsx +74 -181
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/LivePreview.tsx +15 -13
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/canvasConfigRegistry.tsx +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/canvasContextMenuRegistry.tsx +338 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/canvasDefaults.ts +18 -17
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/BarChartDataSourceModal.tsx +10 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/LineChartDataSourceModal.tsx +10 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/{ChartViewerConfigModal.tsx → MultiChartConfigModal.tsx} +30 -18
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/MultiChartDataSourceModal.tsx +427 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/NumCardDataSourceModal.tsx +10 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/PromptModal.tsx +6 -14
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/RadarChartDataSourceModal.tsx +10 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/TableDataSourceModal.tsx +10 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/canvasModalProps.ts +24 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/demos.ts +45 -63
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/CustomNode.tsx +99 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ExportModal.tsx +87 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/FlowRenderer.tsx +322 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ImportModal.tsx +175 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodeEditModal.tsx +60 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodePropertyPanel.tsx +1150 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/RunWorkflowModal.tsx +101 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/StatusCards.tsx +198 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/VersionPanel.tsx +81 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/editor.tsx +566 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/hooks/useWorkflowAgent.ts +224 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/index.tsx +524 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/instance-detail.tsx +343 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/instances.tsx +243 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/components/CreateNodeInstanceModal.tsx +363 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/components/DynamicConfigForm.tsx +154 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/components/NodeInstanceForm.tsx +176 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/create.tsx +77 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/edit.tsx +112 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/index.tsx +305 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/show.tsx +282 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/show.tsx +469 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/types.ts +92 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/create.tsx +111 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/edit.tsx +127 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/index.tsx +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/list.tsx +254 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/show.tsx +74 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/yarn.lock +1501 -1199
- package/package.json +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/app.controller.spec.ts +0 -22
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/BarChart/index.tsx +0 -896
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/ChartSwitcher/index.tsx +0 -219
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/ChartViewer/index.tsx +0 -159
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/Filter/index.tsx +0 -192
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/LineChart/index.tsx +0 -1034
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/NumCard/NumCard.module.css +0 -8
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/NumCard/index.tsx +0 -509
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/NumLineCard/index.tsx +0 -66
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/PieChart/index.tsx +0 -552
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/RadarChart/index.tsx +0 -263
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/Section/index.tsx +0 -35
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/Table/index.tsx +0 -207
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/TreemapChart/index.tsx +0 -382
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/WorldMap/index.tsx +0 -135
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/chart-constants.ts +0 -53
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/icon/InfoIcon.tsx +0 -8
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/icon/index.ts +0 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/map/config.ts +0 -31
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/map/nameMap.json +0 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/map/world.geo.json +0 -39349
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/metric-info-tooltip/index.tsx +0 -19
|
@@ -0,0 +1,786 @@
|
|
|
1
|
+
import { Prisma, PrismaClient } from '@prisma/client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mock workflow data with DSL, versions, instances, and node executions.
|
|
5
|
+
*/
|
|
6
|
+
const WORKFLOWS = [
|
|
7
|
+
{
|
|
8
|
+
code: 'daily_data_sync',
|
|
9
|
+
name: '每日数据同步',
|
|
10
|
+
description: '每天凌晨2点从外部API同步用户数据到本地数据库',
|
|
11
|
+
status: 'PUBLISHED' as const,
|
|
12
|
+
isEnabled: true,
|
|
13
|
+
creator: 'admin',
|
|
14
|
+
dsl: {
|
|
15
|
+
nodes: [
|
|
16
|
+
{
|
|
17
|
+
id: 'trigger_1',
|
|
18
|
+
type: 'cron_trigger',
|
|
19
|
+
label: 'Cron 触发',
|
|
20
|
+
position: { x: 100, y: 200 },
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'action_1',
|
|
24
|
+
type: 'http_request',
|
|
25
|
+
label: '拉取外部数据',
|
|
26
|
+
position: { x: 350, y: 200 },
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'action_2',
|
|
30
|
+
type: 'code',
|
|
31
|
+
label: '数据转换',
|
|
32
|
+
position: { x: 600, y: 200 },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'action_3',
|
|
36
|
+
type: 'db_execute',
|
|
37
|
+
label: '写入数据库',
|
|
38
|
+
position: { x: 850, y: 200 },
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'action_4',
|
|
42
|
+
type: 'send_notification',
|
|
43
|
+
label: '发送通知',
|
|
44
|
+
position: { x: 1100, y: 200 },
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
edges: [
|
|
48
|
+
{ id: 'e-trigger_1-action_1', source: 'trigger_1', target: 'action_1' },
|
|
49
|
+
{ id: 'e-action_1-action_2', source: 'action_1', target: 'action_2' },
|
|
50
|
+
{ id: 'e-action_2-action_3', source: 'action_2', target: 'action_3' },
|
|
51
|
+
{ id: 'e-action_3-action_4', source: 'action_3', target: 'action_4' },
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
code: 'user_reg_approval',
|
|
57
|
+
name: '新用户注册审批',
|
|
58
|
+
description: '新用户注册后触发审批流程,管理员审批通过后发送欢迎邮件',
|
|
59
|
+
status: 'PUBLISHED' as const,
|
|
60
|
+
isEnabled: true,
|
|
61
|
+
creator: 'admin',
|
|
62
|
+
dsl: {
|
|
63
|
+
nodes: [
|
|
64
|
+
{
|
|
65
|
+
id: 'trigger_1',
|
|
66
|
+
type: 'webhook_trigger',
|
|
67
|
+
label: 'Webhook 接收注册',
|
|
68
|
+
position: { x: 100, y: 200 },
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'action_1',
|
|
72
|
+
type: 'set_variable',
|
|
73
|
+
label: '提取用户信息',
|
|
74
|
+
position: { x: 350, y: 200 },
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 'approval_1',
|
|
78
|
+
type: 'approval',
|
|
79
|
+
label: '管理员审批',
|
|
80
|
+
position: { x: 600, y: 200 },
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: 'condition_1',
|
|
84
|
+
type: 'if_else',
|
|
85
|
+
label: '审批结果判断',
|
|
86
|
+
position: { x: 850, y: 200 },
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 'action_2',
|
|
90
|
+
type: 'db_execute',
|
|
91
|
+
label: '激活用户',
|
|
92
|
+
position: { x: 1100, y: 100 },
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 'action_3',
|
|
96
|
+
type: 'send_notification',
|
|
97
|
+
label: '发送欢迎邮件',
|
|
98
|
+
position: { x: 1350, y: 100 },
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 'action_4',
|
|
102
|
+
type: 'send_notification',
|
|
103
|
+
label: '发送拒绝通知',
|
|
104
|
+
position: { x: 1100, y: 300 },
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
edges: [
|
|
108
|
+
{ id: 'e-trigger_1-action_1', source: 'trigger_1', target: 'action_1' },
|
|
109
|
+
{
|
|
110
|
+
id: 'e-action_1-approval_1',
|
|
111
|
+
source: 'action_1',
|
|
112
|
+
target: 'approval_1',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: 'e-approval_1-condition_1',
|
|
116
|
+
source: 'approval_1',
|
|
117
|
+
target: 'condition_1',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: 'e-condition_1-action_2',
|
|
121
|
+
source: 'condition_1',
|
|
122
|
+
target: 'action_2',
|
|
123
|
+
label: 'true',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: 'e-condition_1-action_4',
|
|
127
|
+
source: 'condition_1',
|
|
128
|
+
target: 'action_4',
|
|
129
|
+
label: 'false',
|
|
130
|
+
},
|
|
131
|
+
{ id: 'e-action_2-action_3', source: 'action_2', target: 'action_3' },
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
code: 'error_monitor_alert',
|
|
137
|
+
name: '异常监控告警',
|
|
138
|
+
description: '监听系统事件,当错误率超过阈值时触发告警通知',
|
|
139
|
+
status: 'PUBLISHED' as const,
|
|
140
|
+
isEnabled: true,
|
|
141
|
+
creator: 'system',
|
|
142
|
+
dsl: {
|
|
143
|
+
nodes: [
|
|
144
|
+
{
|
|
145
|
+
id: 'trigger_1',
|
|
146
|
+
type: 'event_trigger',
|
|
147
|
+
label: '监听错误事件',
|
|
148
|
+
position: { x: 100, y: 200 },
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: 'action_1',
|
|
152
|
+
type: 'db_query',
|
|
153
|
+
label: '查询近5分钟错误数',
|
|
154
|
+
position: { x: 350, y: 200 },
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: 'condition_1',
|
|
158
|
+
type: 'if_else',
|
|
159
|
+
label: '错误率 > 5%?',
|
|
160
|
+
position: { x: 600, y: 200 },
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: 'action_2',
|
|
164
|
+
type: 'send_notification',
|
|
165
|
+
label: '发送告警',
|
|
166
|
+
position: { x: 850, y: 100 },
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: 'action_3',
|
|
170
|
+
type: 'code',
|
|
171
|
+
label: '记录日志',
|
|
172
|
+
position: { x: 850, y: 300 },
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
edges: [
|
|
176
|
+
{ id: 'e-trigger_1-action_1', source: 'trigger_1', target: 'action_1' },
|
|
177
|
+
{
|
|
178
|
+
id: 'e-action_1-condition_1',
|
|
179
|
+
source: 'action_1',
|
|
180
|
+
target: 'condition_1',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
id: 'e-condition_1-action_2',
|
|
184
|
+
source: 'condition_1',
|
|
185
|
+
target: 'action_2',
|
|
186
|
+
label: 'true',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
id: 'e-condition_1-action_3',
|
|
190
|
+
source: 'condition_1',
|
|
191
|
+
target: 'action_3',
|
|
192
|
+
label: 'false',
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
code: 'batch_data_export',
|
|
199
|
+
name: '批量数据导出',
|
|
200
|
+
description: '手动触发导出指定表的数据为CSV文件并发送邮件',
|
|
201
|
+
status: 'DRAFT' as const,
|
|
202
|
+
isEnabled: false,
|
|
203
|
+
creator: 'admin',
|
|
204
|
+
dsl: {
|
|
205
|
+
nodes: [
|
|
206
|
+
{
|
|
207
|
+
id: 'trigger_1',
|
|
208
|
+
type: 'manual_trigger',
|
|
209
|
+
label: '手动触发',
|
|
210
|
+
position: { x: 100, y: 200 },
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
id: 'action_1',
|
|
214
|
+
type: 'db_query',
|
|
215
|
+
label: '查询数据',
|
|
216
|
+
position: { x: 350, y: 200 },
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
id: 'loop_1',
|
|
220
|
+
type: 'for_each',
|
|
221
|
+
label: '遍历分页',
|
|
222
|
+
position: { x: 600, y: 200 },
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
id: 'action_2',
|
|
226
|
+
type: 'code',
|
|
227
|
+
label: '转换为CSV',
|
|
228
|
+
position: { x: 850, y: 200 },
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
id: 'action_3',
|
|
232
|
+
type: 'send_notification',
|
|
233
|
+
label: '发送邮件',
|
|
234
|
+
position: { x: 1100, y: 200 },
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
edges: [
|
|
238
|
+
{ id: 'e-trigger_1-action_1', source: 'trigger_1', target: 'action_1' },
|
|
239
|
+
{ id: 'e-action_1-loop_1', source: 'action_1', target: 'loop_1' },
|
|
240
|
+
{ id: 'e-loop_1-action_2', source: 'loop_1', target: 'action_2' },
|
|
241
|
+
{ id: 'e-action_2-action_3', source: 'action_2', target: 'action_3' },
|
|
242
|
+
],
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
code: 'multi_env_deploy',
|
|
247
|
+
name: '多环境部署流水线',
|
|
248
|
+
description: '并行部署到staging和production环境,需人工审批production',
|
|
249
|
+
status: 'PUBLISHED' as const,
|
|
250
|
+
isEnabled: true,
|
|
251
|
+
creator: 'devops',
|
|
252
|
+
dsl: {
|
|
253
|
+
nodes: [
|
|
254
|
+
{
|
|
255
|
+
id: 'trigger_1',
|
|
256
|
+
type: 'webhook_trigger',
|
|
257
|
+
label: 'CI 回调',
|
|
258
|
+
position: { x: 100, y: 200 },
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
id: 'parallel_1',
|
|
262
|
+
type: 'parallel',
|
|
263
|
+
label: '并行部署',
|
|
264
|
+
position: { x: 350, y: 200 },
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
id: 'action_1',
|
|
268
|
+
type: 'http_request',
|
|
269
|
+
label: '部署 Staging',
|
|
270
|
+
position: { x: 600, y: 100 },
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
id: 'approval_1',
|
|
274
|
+
type: 'approval',
|
|
275
|
+
label: 'Production 审批',
|
|
276
|
+
position: { x: 600, y: 300 },
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
id: 'action_2',
|
|
280
|
+
type: 'http_request',
|
|
281
|
+
label: '部署 Production',
|
|
282
|
+
position: { x: 850, y: 300 },
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
id: 'action_3',
|
|
286
|
+
type: 'send_notification',
|
|
287
|
+
label: '部署完成通知',
|
|
288
|
+
position: { x: 1100, y: 200 },
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
edges: [
|
|
292
|
+
{
|
|
293
|
+
id: 'e-trigger_1-parallel_1',
|
|
294
|
+
source: 'trigger_1',
|
|
295
|
+
target: 'parallel_1',
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: 'e-parallel_1-action_1',
|
|
299
|
+
source: 'parallel_1',
|
|
300
|
+
target: 'action_1',
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
id: 'e-parallel_1-approval_1',
|
|
304
|
+
source: 'parallel_1',
|
|
305
|
+
target: 'approval_1',
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
id: 'e-approval_1-action_2',
|
|
309
|
+
source: 'approval_1',
|
|
310
|
+
target: 'action_2',
|
|
311
|
+
},
|
|
312
|
+
{ id: 'e-action_1-action_3', source: 'action_1', target: 'action_3' },
|
|
313
|
+
{ id: 'e-action_2-action_3', source: 'action_2', target: 'action_3' },
|
|
314
|
+
],
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
code: 'user_role_change',
|
|
319
|
+
name: '用户角色变更通知',
|
|
320
|
+
description:
|
|
321
|
+
'当 t_admin_user_role 表中用户角色发生变更时,记录审计日志并通知相关人员',
|
|
322
|
+
status: 'PUBLISHED' as const,
|
|
323
|
+
isEnabled: true,
|
|
324
|
+
creator: 'admin',
|
|
325
|
+
dsl: {
|
|
326
|
+
nodes: [
|
|
327
|
+
{
|
|
328
|
+
id: 'trigger_1',
|
|
329
|
+
type: 'event_trigger',
|
|
330
|
+
label: '监听角色变更事件',
|
|
331
|
+
position: { x: 100, y: 200 },
|
|
332
|
+
config: { eventName: 'user_role.updated' },
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
id: 'action_1',
|
|
336
|
+
type: 'db_query',
|
|
337
|
+
label: '查询用户详情',
|
|
338
|
+
position: { x: 350, y: 200 },
|
|
339
|
+
config: {
|
|
340
|
+
query:
|
|
341
|
+
'SELECT userid, username, roles FROM t_admin_user_role WHERE userid = $1',
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
id: 'action_2',
|
|
346
|
+
type: 'code',
|
|
347
|
+
label: '对比角色差异',
|
|
348
|
+
position: { x: 600, y: 200 },
|
|
349
|
+
config: {
|
|
350
|
+
script:
|
|
351
|
+
'const prev = JSON.parse(input.previousRoles); const curr = JSON.parse(input.currentRoles); return { added: curr.filter(r => !prev.includes(r)), removed: prev.filter(r => !curr.includes(r)) };',
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
id: 'condition_1',
|
|
356
|
+
type: 'if_else',
|
|
357
|
+
label: '是否涉及ADMIN角色',
|
|
358
|
+
position: { x: 850, y: 200 },
|
|
359
|
+
config: {
|
|
360
|
+
conditions: [
|
|
361
|
+
{ field: 'added', operator: 'contains', value: 'SYSTEM_ADMIN' },
|
|
362
|
+
],
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
id: 'action_3',
|
|
367
|
+
type: 'send_notification',
|
|
368
|
+
label: '发送安全告警',
|
|
369
|
+
position: { x: 1100, y: 100 },
|
|
370
|
+
config: {
|
|
371
|
+
channel: 'wecom',
|
|
372
|
+
recipients: ['security-team'],
|
|
373
|
+
message: '用户 {{username}} 被授予 SYSTEM_ADMIN 角色',
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
id: 'action_4',
|
|
378
|
+
type: 'db_execute',
|
|
379
|
+
label: '写入审计日志',
|
|
380
|
+
position: { x: 1100, y: 300 },
|
|
381
|
+
config: { operation: 'insert', table: 't_admin_audit_log' },
|
|
382
|
+
},
|
|
383
|
+
],
|
|
384
|
+
edges: [
|
|
385
|
+
{ id: 'e-trigger_1-action_1', source: 'trigger_1', target: 'action_1' },
|
|
386
|
+
{ id: 'e-action_1-action_2', source: 'action_1', target: 'action_2' },
|
|
387
|
+
{
|
|
388
|
+
id: 'e-action_2-condition_1',
|
|
389
|
+
source: 'action_2',
|
|
390
|
+
target: 'condition_1',
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
id: 'e-condition_1-action_3',
|
|
394
|
+
source: 'condition_1',
|
|
395
|
+
target: 'action_3',
|
|
396
|
+
label: 'true',
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
id: 'e-condition_1-action_4',
|
|
400
|
+
source: 'condition_1',
|
|
401
|
+
target: 'action_4',
|
|
402
|
+
label: 'false',
|
|
403
|
+
},
|
|
404
|
+
{ id: 'e-action_3-action_4', source: 'action_3', target: 'action_4' },
|
|
405
|
+
],
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
code: 'event_remind_sync',
|
|
410
|
+
name: 'Event活动提醒与同步',
|
|
411
|
+
description:
|
|
412
|
+
'当 t_event 表新增活动或活动即将开始时,自动同步到 ServiceNow 并通知参与人员',
|
|
413
|
+
status: 'PUBLISHED' as const,
|
|
414
|
+
isEnabled: true,
|
|
415
|
+
creator: 'admin',
|
|
416
|
+
dsl: {
|
|
417
|
+
nodes: [
|
|
418
|
+
{
|
|
419
|
+
id: 'trigger_1',
|
|
420
|
+
type: 'cron_trigger',
|
|
421
|
+
label: '每日9点检查',
|
|
422
|
+
position: { x: 100, y: 200 },
|
|
423
|
+
config: { cron: '0 9 * * *', timezone: 'Asia/Shanghai' },
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
id: 'action_1',
|
|
427
|
+
type: 'db_query',
|
|
428
|
+
label: '查询3天内活动',
|
|
429
|
+
position: { x: 350, y: 200 },
|
|
430
|
+
config: {
|
|
431
|
+
query:
|
|
432
|
+
"SELECT * FROM t_event WHERE start_date BETWEEN NOW() AND NOW() + INTERVAL '3 days'",
|
|
433
|
+
},
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
id: 'condition_1',
|
|
437
|
+
type: 'if_else',
|
|
438
|
+
label: '有即将开始的活动?',
|
|
439
|
+
position: { x: 600, y: 200 },
|
|
440
|
+
config: {
|
|
441
|
+
conditions: [{ field: 'rowCount', operator: 'gt', value: '0' }],
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
id: 'loop_1',
|
|
446
|
+
type: 'for_each',
|
|
447
|
+
label: '遍历活动列表',
|
|
448
|
+
position: { x: 850, y: 150 },
|
|
449
|
+
config: { iteratorField: 'rows', concurrency: 3 },
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
id: 'condition_2',
|
|
453
|
+
type: 'if_else',
|
|
454
|
+
label: '已同步ServiceNow?',
|
|
455
|
+
position: { x: 1100, y: 150 },
|
|
456
|
+
config: {
|
|
457
|
+
conditions: [
|
|
458
|
+
{
|
|
459
|
+
field: 'currentItem.sn_sys_id',
|
|
460
|
+
operator: 'isNotEmpty',
|
|
461
|
+
value: '',
|
|
462
|
+
},
|
|
463
|
+
],
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
id: 'action_2',
|
|
468
|
+
type: 'http_request',
|
|
469
|
+
label: '同步到ServiceNow',
|
|
470
|
+
position: { x: 1350, y: 80 },
|
|
471
|
+
config: {
|
|
472
|
+
url: 'https://servicenow.example.com/api/events',
|
|
473
|
+
method: 'POST',
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
id: 'action_3',
|
|
478
|
+
type: 'db_execute',
|
|
479
|
+
label: '更新sn_sys_id',
|
|
480
|
+
position: { x: 1600, y: 80 },
|
|
481
|
+
config: { operation: 'update', table: 't_event', where: 'id = $1' },
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
id: 'action_4',
|
|
485
|
+
type: 'send_notification',
|
|
486
|
+
label: '通知OIT负责人',
|
|
487
|
+
position: { x: 1350, y: 250 },
|
|
488
|
+
config: {
|
|
489
|
+
channel: 'email',
|
|
490
|
+
message:
|
|
491
|
+
'活动 {{currentItem.city}} - {{currentItem.eventType}} 将于 {{currentItem.start_date}} 开始',
|
|
492
|
+
},
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
id: 'action_5',
|
|
496
|
+
type: 'code',
|
|
497
|
+
label: '记录检查完成',
|
|
498
|
+
position: { x: 600, y: 350 },
|
|
499
|
+
config: {
|
|
500
|
+
script: 'return { checked: true, noUpcomingEvents: true };',
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
],
|
|
504
|
+
edges: [
|
|
505
|
+
{ id: 'e-trigger_1-action_1', source: 'trigger_1', target: 'action_1' },
|
|
506
|
+
{
|
|
507
|
+
id: 'e-action_1-condition_1',
|
|
508
|
+
source: 'action_1',
|
|
509
|
+
target: 'condition_1',
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
id: 'e-condition_1-loop_1',
|
|
513
|
+
source: 'condition_1',
|
|
514
|
+
target: 'loop_1',
|
|
515
|
+
label: 'true',
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
id: 'e-condition_1-action_5',
|
|
519
|
+
source: 'condition_1',
|
|
520
|
+
target: 'action_5',
|
|
521
|
+
label: 'false',
|
|
522
|
+
},
|
|
523
|
+
{ id: 'e-loop_1-condition_2', source: 'loop_1', target: 'condition_2' },
|
|
524
|
+
{
|
|
525
|
+
id: 'e-condition_2-action_2',
|
|
526
|
+
source: 'condition_2',
|
|
527
|
+
target: 'action_2',
|
|
528
|
+
label: 'false',
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
id: 'e-condition_2-action_4',
|
|
532
|
+
source: 'condition_2',
|
|
533
|
+
target: 'action_4',
|
|
534
|
+
label: 'true',
|
|
535
|
+
},
|
|
536
|
+
{ id: 'e-action_2-action_3', source: 'action_2', target: 'action_3' },
|
|
537
|
+
{ id: 'e-action_3-action_4', source: 'action_3', target: 'action_4' },
|
|
538
|
+
],
|
|
539
|
+
},
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
code: 'new_user_onboard',
|
|
543
|
+
name: '新增用户自动化流程',
|
|
544
|
+
description:
|
|
545
|
+
'当 t_admin_user_role 新增用户时,自动分配默认角色、同步到外部系统并发送欢迎通知',
|
|
546
|
+
status: 'PUBLISHED' as const,
|
|
547
|
+
isEnabled: true,
|
|
548
|
+
creator: 'admin',
|
|
549
|
+
dsl: {
|
|
550
|
+
nodes: [
|
|
551
|
+
{
|
|
552
|
+
id: 'trigger_1',
|
|
553
|
+
type: 'event_trigger',
|
|
554
|
+
label: '监听用户创建事件',
|
|
555
|
+
position: { x: 100, y: 200 },
|
|
556
|
+
config: { eventName: 'user.created' },
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
id: 'action_1',
|
|
560
|
+
type: 'db_query',
|
|
561
|
+
label: '查询新用户信息',
|
|
562
|
+
position: { x: 350, y: 200 },
|
|
563
|
+
config: {
|
|
564
|
+
query:
|
|
565
|
+
'SELECT userid, username, roles, is_active FROM t_admin_user_role WHERE userid = $1',
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
id: 'action_2',
|
|
570
|
+
type: 'code',
|
|
571
|
+
label: '初始化默认角色',
|
|
572
|
+
position: { x: 600, y: 200 },
|
|
573
|
+
config: {
|
|
574
|
+
script:
|
|
575
|
+
'const user = input.rows[0]; if (!user.roles || user.roles === "[]") { return { ...user, roles: JSON.stringify(["GUEST"]), needsUpdate: true }; } return { ...user, needsUpdate: false };',
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
id: 'condition_1',
|
|
580
|
+
type: 'if_else',
|
|
581
|
+
label: '需要分配默认角色?',
|
|
582
|
+
position: { x: 850, y: 200 },
|
|
583
|
+
config: {
|
|
584
|
+
conditions: [
|
|
585
|
+
{ field: 'needsUpdate', operator: 'eq', value: 'true' },
|
|
586
|
+
],
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
id: 'action_3',
|
|
591
|
+
type: 'db_execute',
|
|
592
|
+
label: '写入默认角色',
|
|
593
|
+
position: { x: 1100, y: 100 },
|
|
594
|
+
config: {
|
|
595
|
+
operation: 'update',
|
|
596
|
+
table: 't_admin_user_role',
|
|
597
|
+
data: { roles: '["GUEST"]' },
|
|
598
|
+
where: 'userid = $1',
|
|
599
|
+
},
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
id: 'action_4',
|
|
603
|
+
type: 'http_request',
|
|
604
|
+
label: '同步到企业通讯录',
|
|
605
|
+
position: { x: 1100, y: 300 },
|
|
606
|
+
config: {
|
|
607
|
+
url: 'https://api.wecom.example.com/user/sync',
|
|
608
|
+
method: 'POST',
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
id: 'action_5',
|
|
613
|
+
type: 'send_notification',
|
|
614
|
+
label: '发送欢迎通知',
|
|
615
|
+
position: { x: 1350, y: 200 },
|
|
616
|
+
config: {
|
|
617
|
+
channel: 'wecom',
|
|
618
|
+
recipients: ['{{userid}}'],
|
|
619
|
+
message:
|
|
620
|
+
'欢迎加入系统!您的初始角色为 GUEST,如需更多权限请联系管理员。',
|
|
621
|
+
},
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
id: 'action_6',
|
|
625
|
+
type: 'db_execute',
|
|
626
|
+
label: '记录审计日志',
|
|
627
|
+
position: { x: 1600, y: 200 },
|
|
628
|
+
config: {
|
|
629
|
+
operation: 'insert',
|
|
630
|
+
table: 't_admin_audit_log',
|
|
631
|
+
data: { action: 'user.onboarded', resource: 'user' },
|
|
632
|
+
},
|
|
633
|
+
},
|
|
634
|
+
],
|
|
635
|
+
edges: [
|
|
636
|
+
{ id: 'e-trigger_1-action_1', source: 'trigger_1', target: 'action_1' },
|
|
637
|
+
{ id: 'e-action_1-action_2', source: 'action_1', target: 'action_2' },
|
|
638
|
+
{
|
|
639
|
+
id: 'e-action_2-condition_1',
|
|
640
|
+
source: 'action_2',
|
|
641
|
+
target: 'condition_1',
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
id: 'e-condition_1-action_3',
|
|
645
|
+
source: 'condition_1',
|
|
646
|
+
target: 'action_3',
|
|
647
|
+
label: 'true',
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
id: 'e-condition_1-action_4',
|
|
651
|
+
source: 'condition_1',
|
|
652
|
+
target: 'action_4',
|
|
653
|
+
label: 'false',
|
|
654
|
+
},
|
|
655
|
+
{ id: 'e-action_3-action_4', source: 'action_3', target: 'action_4' },
|
|
656
|
+
{ id: 'e-action_4-action_5', source: 'action_4', target: 'action_5' },
|
|
657
|
+
{ id: 'e-action_5-action_6', source: 'action_5', target: 'action_6' },
|
|
658
|
+
],
|
|
659
|
+
},
|
|
660
|
+
},
|
|
661
|
+
];
|
|
662
|
+
|
|
663
|
+
export async function seedWorkflows(prisma: PrismaClient) {
|
|
664
|
+
console.log('Seeding workflows...');
|
|
665
|
+
|
|
666
|
+
for (const wf of WORKFLOWS) {
|
|
667
|
+
// Upsert workflow by code
|
|
668
|
+
const workflow = await prisma.workflow.upsert({
|
|
669
|
+
where: { code: wf.code },
|
|
670
|
+
update: {
|
|
671
|
+
name: wf.name,
|
|
672
|
+
description: wf.description,
|
|
673
|
+
status: wf.status,
|
|
674
|
+
isEnabled: wf.isEnabled,
|
|
675
|
+
dsl: wf.dsl,
|
|
676
|
+
},
|
|
677
|
+
create: {
|
|
678
|
+
code: wf.code,
|
|
679
|
+
name: wf.name,
|
|
680
|
+
description: wf.description,
|
|
681
|
+
status: wf.status,
|
|
682
|
+
isEnabled: wf.isEnabled,
|
|
683
|
+
dsl: wf.dsl,
|
|
684
|
+
creator: wf.creator,
|
|
685
|
+
},
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
// Create version 1
|
|
689
|
+
await prisma.workflowVersion.upsert({
|
|
690
|
+
where: { workflowId_version: { workflowId: workflow.id, version: 1 } },
|
|
691
|
+
update: {},
|
|
692
|
+
create: {
|
|
693
|
+
workflowId: workflow.id,
|
|
694
|
+
version: 1,
|
|
695
|
+
dsl: wf.dsl,
|
|
696
|
+
prompt: `创建工作流: ${wf.name}`,
|
|
697
|
+
changeSummary: '初始版本',
|
|
698
|
+
creator: wf.creator,
|
|
699
|
+
},
|
|
700
|
+
});
|
|
701
|
+
|
|
702
|
+
// For published workflows, create some mock instances
|
|
703
|
+
if (wf.status === 'PUBLISHED') {
|
|
704
|
+
const version = await prisma.workflowVersion.findFirst({
|
|
705
|
+
where: { workflowId: workflow.id, version: 1 },
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
if (!version) continue;
|
|
709
|
+
|
|
710
|
+
// Create 3 instances per published workflow with different statuses
|
|
711
|
+
const instanceConfigs = [
|
|
712
|
+
{ status: 'COMPLETED' as const, daysAgo: 3 },
|
|
713
|
+
{ status: 'COMPLETED' as const, daysAgo: 1 },
|
|
714
|
+
{ status: 'RUNNING' as const, daysAgo: 0 },
|
|
715
|
+
];
|
|
716
|
+
|
|
717
|
+
for (const cfg of instanceConfigs) {
|
|
718
|
+
const startedAt = new Date(
|
|
719
|
+
Date.now() - cfg.daysAgo * 24 * 60 * 60 * 1000,
|
|
720
|
+
);
|
|
721
|
+
const finishedAt =
|
|
722
|
+
cfg.status === 'COMPLETED'
|
|
723
|
+
? new Date(startedAt.getTime() + 30000) // 30s later
|
|
724
|
+
: null;
|
|
725
|
+
|
|
726
|
+
const instance = await prisma.workflowInstance.create({
|
|
727
|
+
data: {
|
|
728
|
+
workflowId: workflow.id,
|
|
729
|
+
versionId: version.id,
|
|
730
|
+
status: cfg.status,
|
|
731
|
+
context: { trigger: 'auto', env: 'production' },
|
|
732
|
+
result:
|
|
733
|
+
cfg.status === 'COMPLETED'
|
|
734
|
+
? { success: true, processedCount: 128 }
|
|
735
|
+
: Prisma.JsonNull,
|
|
736
|
+
startedAt,
|
|
737
|
+
finishedAt,
|
|
738
|
+
creator: wf.creator,
|
|
739
|
+
},
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
// Create node executions for each instance
|
|
743
|
+
const nodes = (wf.dsl as any).nodes || [];
|
|
744
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
745
|
+
const node = nodes[i];
|
|
746
|
+
const nodeStarted = new Date(startedAt.getTime() + i * 5000);
|
|
747
|
+
const isLastNode = i === nodes.length - 1;
|
|
748
|
+
|
|
749
|
+
let nodeStatus: 'COMPLETED' | 'RUNNING' | 'PENDING' = 'COMPLETED';
|
|
750
|
+
if (cfg.status === 'RUNNING') {
|
|
751
|
+
if (i === nodes.length - 1) nodeStatus = 'RUNNING';
|
|
752
|
+
if (i > nodes.length - 1) nodeStatus = 'PENDING';
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
await prisma.workflowNodeExecution.upsert({
|
|
756
|
+
where: {
|
|
757
|
+
instanceId_nodeId: { instanceId: instance.id, nodeId: node.id },
|
|
758
|
+
},
|
|
759
|
+
update: {},
|
|
760
|
+
create: {
|
|
761
|
+
instanceId: instance.id,
|
|
762
|
+
nodeId: node.id,
|
|
763
|
+
nodeType: node.type,
|
|
764
|
+
nodeLabel: node.label,
|
|
765
|
+
status: nodeStatus,
|
|
766
|
+
input: { data: `mock_input_${i}` },
|
|
767
|
+
output:
|
|
768
|
+
nodeStatus === 'COMPLETED'
|
|
769
|
+
? { data: `mock_output_${i}` }
|
|
770
|
+
: Prisma.JsonNull,
|
|
771
|
+
startedAt: nodeStarted,
|
|
772
|
+
finishedAt:
|
|
773
|
+
nodeStatus === 'COMPLETED'
|
|
774
|
+
? new Date(nodeStarted.getTime() + 3000)
|
|
775
|
+
: null,
|
|
776
|
+
},
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
console.log(
|
|
784
|
+
`Seeded ${WORKFLOWS.length} workflows with versions, instances, and node executions.`,
|
|
785
|
+
);
|
|
786
|
+
}
|