@gadmin2n/schematics 0.0.143 → 0.0.145
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/lib/application/files/gadmin2-game-angle-demo/config/.types.d.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/approval.prisma +2 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/workflow.prisma +140 -19
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/package.json +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/data-mngt.seed.ts +0 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/workflow-node-types.ts +694 -327
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/workflow-outbox.ts +57 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/workflow.seed.ts +35 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/workflows.ts +224 -59
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/codeRuntime/code-executor.spec.ts +23 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/codeRuntime/code-executor.ts +16 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/codeRuntime/code-runtime.controller.spec.ts +98 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/codeRuntime/code-runtime.controller.ts +26 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/codeRuntime/code-runtime.dto.ts +17 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-runtime.controller.spec.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-runtime.controller.ts +3 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-runtime.dto.ts +0 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-signal-outbox.service.spec.ts +30 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-signal-outbox.service.ts +28 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction.service.spec.ts +63 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction.service.ts +151 -38
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-wait.handler.ts +4 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/human-approval.handler.spec.ts +16 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/human-approval.handler.ts +23 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/httpRequest/http-request-runtime.controller.spec.ts +130 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/httpRequest/http-request-runtime.controller.ts +62 -62
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/httpRequest/http-request-runtime.dto.ts +15 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/httpRequest/http-request-runtime.util.spec.ts +70 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/httpRequest/http-request-runtime.util.ts +31 -7
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/approval-signal-outbox.service.spec.ts +30 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/approval-signal-outbox.service.ts +28 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/approval-subject-source.util.spec.ts +50 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/approval-subject-source.util.ts +26 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.dto.ts +53 -47
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.errors.ts +0 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.service.spec.ts +541 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.service.ts +442 -200
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/outbox-retry.util.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/runtime/human-approval-runtime.controller.spec.ts +150 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/runtime/human-approval-runtime.controller.ts +56 -40
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/runtime/human-approval-runtime.dto.ts +16 -60
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/integrationConnection/integration-connection.controller.ts +13 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/integrationConnection/integration-connection.service.spec.ts +44 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/integrationConnection/integration-connection.service.ts +6 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/dsl-validate.util.spec.ts +258 -12
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/dsl-validate.util.ts +127 -14
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/manual-workflow-execution.spec.ts +85 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/manual-workflow-execution.ts +108 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/parameter-binding.ts +5 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/temporal.service.spec.ts +96 -25
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/temporal.service.ts +77 -34
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-callable.spec.ts +23 -34
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-callable.ts +0 -21
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-cancellation.spec.ts +245 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-compiler.service.spec.ts +639 -188
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-compiler.service.ts +408 -235
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-compiler.types.ts +1 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-data-edge.util.spec.ts +279 -95
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-data-edge.util.ts +360 -80
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-event-catalog.spec.ts +323 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-execution-idempotency.spec.ts +773 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-execution.dto.ts +7 -13
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-export.dto.ts +0 -16
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-export.service.spec.ts +184 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-export.service.ts +69 -138
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-handle-validator.spec.ts +113 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-handle-validator.ts +59 -13
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-runtime.facade.ts +86 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-switch-config.spec.ts +25 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-switch-config.ts +45 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.controller.spec.ts +78 -43
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.controller.ts +103 -40
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.dto.ts +57 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.module.ts +3 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.service.spec.ts +1000 -240
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.service.ts +2184 -317
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/node-config-validator.service.spec.ts +279 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/node-config-validator.service.ts +5 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/subject-config-validator.service.spec.ts +4 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/subject-config-validator.service.ts +5 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/widget-catalog.service.spec.ts +12 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/widget-catalog.service.ts +10 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/workflowNodeInstance.service.spec.ts +2 -24
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/workflowNodeInstance.service.ts +3 -70
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/package.json +3 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/RowActions.tsx +25 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/WorkflowActionButton.test.tsx +71 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/WorkflowActionButton.tsx +89 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/index.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/header.tsx +52 -12
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/config/routeRegistry.tsx +12 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/constants/layout.ts +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/AddDataModal.tsx +10 -33
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/AddPageModal.tsx +13 -37
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/DevShell.tsx +55 -7
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/style.css +14 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/http.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/list.tsx +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/workflowAction.ts +19 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/index.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/types.ts +3 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useDynamicResources.tsx +1 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useReferenceUpload.ts +95 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/locales/en/common.json +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/locales/en/workflow.json +672 -110
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/locales/zh_CN/common.json +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/locales/zh_CN/workflow.json +676 -114
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/plugins/devShellPlugin.ts +13 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agenda/index.tsx +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasEditPage.tsx +38 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasListPage.tsx +276 -376
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/CanvasAiModal.tsx +126 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/human-approval/DecisionModal.test.tsx +50 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/human-approval/DecisionModal.tsx +48 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/human-approval/inbox.tsx +32 -34
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/business-events/RegisterBusinessEventModal.test.tsx +111 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/business-events/RegisterBusinessEventModal.tsx +167 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/business-events/business-events.css +99 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/business-events/detail.test.tsx +106 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/business-events/detail.tsx +324 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/business-events/index.test.tsx +73 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/business-events/index.tsx +359 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/CanvasZoomControls.tsx +46 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/CreateNodeInstanceDrawer.tsx +9 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/CustomNode.test.tsx +105 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/CustomNode.tsx +90 -48
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/DeletableEdge.tsx +3 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/DslView.test.tsx +259 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/DslView.tsx +167 -103
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/EnhancedFlowRenderer.tsx +142 -140
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ExecutionStatusNode.test.tsx +60 -15
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ExecutionStatusNode.tsx +25 -12
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/FlowRenderer.tsx +364 -200
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NewNodeDefaults.test.tsx +220 -52
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodeOutputSummary.test.tsx +260 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodeOutputSummary.tsx +300 -130
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodePropertyPanel.test.tsx +507 -33
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodePropertyPanel.tsx +630 -592
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ParameterBindingEditor.tsx +67 -70
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ReadonlyNodePanel.test.tsx +90 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ReadonlyNodePanel.tsx +325 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/RunWorkflowModal.test.tsx +52 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/RunWorkflowModal.tsx +14 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/StatusCards.tsx +2 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/VersionPanel.tsx +2 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/WorkflowCodeEditor.test.tsx +42 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/WorkflowCodeEditor.tsx +76 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/WorkflowWorkspaceHeader.tsx +56 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/parameter-binding-editor.css +46 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/workflow-code-editor.css +34 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/connections/ConnectionModal.test.tsx +53 -7
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/connections/ConnectionModal.tsx +123 -62
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/connections/connections.css +85 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/connections/connectionsApi.ts +29 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/connections/index.test.tsx +75 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/connections/index.tsx +69 -36
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/editor.test.tsx +494 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/editor.tsx +665 -194
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/hooks/useReferencedNodeInstanceConfigs.test.tsx +92 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/hooks/useReferencedNodeInstanceConfigs.ts +96 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/hooks/useWorkflowAgent.test.tsx +297 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/hooks/useWorkflowAgent.ts +135 -65
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/index.tsx +53 -42
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/instance-detail.tsx +344 -155
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/instances.tsx +79 -58
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/components/CreateNodeInstanceModal.tsx +123 -144
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/components/NodeInstanceForm.tsx +169 -98
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/components/node-instance-form.css +91 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/index.tsx +54 -31
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/node-config.css +854 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/SchemaField.tsx +41 -14
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/SchemaForm.test.tsx +75 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/SchemaForm.tsx +3 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/default-widgets.tsx +20 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/widget-registry.tsx +2 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/show.tsx +61 -66
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ApprovalRuleEditor.test.tsx +33 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ApprovalRuleEditor.tsx +47 -15
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/BranchConfigEditors.test.tsx +104 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/CallableInputParametersEditor.tsx +22 -52
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/CodeConfigEditor.test.tsx +72 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/CodeConfigEditor.tsx +78 -70
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/CronTriggerConfigEditor.tsx +569 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/DbExecuteConfigEditor.tsx +130 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/DelayConfigEditor.tsx +100 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/EventTriggerConfigEditor.tsx +620 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ExternalRequestConfigEditor.test.tsx +22 -45
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ExternalRequestConfigEditor.tsx +25 -92
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ExternalWaitConfigEditor.tsx +3 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ForEachConfigEditor.test.tsx +58 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ForEachConfigEditor.tsx +107 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/HttpRequestConfigEditor.test.tsx +212 -31
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/HttpRequestConfigEditor.tsx +214 -304
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/HumanApprovalConfigEditor.test.tsx +175 -40
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/HumanApprovalConfigEditor.tsx +693 -293
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/IfElseConfigEditor.tsx +190 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ManualTriggerConfigEditor.test.tsx +152 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ManualTriggerConfigEditor.tsx +286 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ParallelConfigEditor.tsx +101 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ParameterBindingListEditor.tsx +99 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/SimplifiedNodeEditors.test.tsx +495 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/SubWorkflowConfigEditor.test.tsx +124 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/SubWorkflowConfigEditor.tsx +222 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/SubjectPicker.tsx +2 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/SwitchConfigEditor.tsx +204 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/UserGroupCreateModal.tsx +3 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/UserGroupEditModal.tsx +9 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/callable-workflow.ts +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/code-config.css +96 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/event-catalog.api.ts +117 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/http-request-config.css +242 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/human-approval-config.css +194 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/show.tsx +264 -167
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/temporal-tenant/index.tsx +6 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/types/parameter-binding.ts +19 -16
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/types.ts +28 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/useWorkflowFormValidation.test.tsx +59 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/useWorkflowFormValidation.ts +24 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/forEachConnection.test.ts +311 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/forEachConnection.ts +198 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/mainFlowConnection.test.ts +143 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/mainFlowConnection.ts +19 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/newNodeConfig.ts +103 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/removeWorkflowEdges.test.ts +158 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/removeWorkflowEdges.ts +117 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveEffectiveOutput.test.ts +70 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveEffectiveOutput.ts +48 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveLookupPorts.test.ts +55 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveLookupPorts.ts +95 -22
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveOutputs.test.ts +148 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveOutputs.ts +62 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveWorkflowDisplay.test.ts +19 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveWorkflowDisplay.ts +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/subWorkflowChange.test.ts +45 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/subWorkflowChange.ts +26 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/validateWorkflowDsl.test.ts +502 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/validateWorkflowDsl.ts +694 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/workflowDateTime.test.ts +27 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/workflowDateTime.ts +33 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/workflowHistory.test.ts +34 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/workflowHistory.ts +52 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/workflowPublishError.test.ts +99 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/workflowPublishError.ts +91 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/workflowSkillPrompt.test.ts +74 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/workflowSkillPrompt.ts +120 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/workflow-ui.css +481 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/index.css +1 -1
- package/package.json +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/WorkflowEventOutbox.ts +0 -62
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/scripts/migrate-human-approval-configs.ts +0 -86
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/workflow-event-trigger.ts +0 -60
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.external-decision.spec.ts +0 -183
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/legacy-approval-config-migration.ts +0 -227
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-http-response.spec.ts +0 -82
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-http-response.ts +0 -111
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowEventOutbox/workflowEventOutbox.controller.spec.ts +0 -54
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowEventOutbox/workflowEventOutbox.controller.ts +0 -147
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowEventOutbox/workflowEventOutbox.module.ts +0 -10
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowEventOutbox/workflowEventOutbox.service.spec.ts +0 -350
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowEventOutbox/workflowEventOutbox.service.ts +0 -110
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/index.ts +0 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/InstanceRequiredDialog.tsx +0 -106
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/LookupConnectionDialog.test.tsx +0 -45
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/LookupConnectionDialog.tsx +0 -43
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodeTypeBadge.tsx +0 -36
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/hooks/useNodeInstanceLibrary.ts +0 -41
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ApproverSourceEditor.test.tsx +0 -47
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ApproverSourceEditor.tsx +0 -182
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ReturnResultConfigEditor.test.tsx +0 -34
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ReturnResultConfigEditor.tsx +0 -16
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/approver-source.test.ts +0 -25
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/approver-source.ts +0 -42
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/lookupConnection.test.ts +0 -208
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/lookupConnection.ts +0 -246
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/create.tsx +0 -111
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/edit.tsx +0 -127
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/index.tsx +0 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/list.tsx +0 -282
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/show.tsx +0 -74
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
import { ConflictException } from '@nestjs/common';
|
|
2
|
+
import { Prisma } from '@prisma/client';
|
|
3
|
+
import { WorkflowService } from './workflow.service';
|
|
4
|
+
|
|
5
|
+
describe('Workflow execution idempotency', () => {
|
|
6
|
+
const workflowId = BigInt(7);
|
|
7
|
+
const version = {
|
|
8
|
+
id: BigInt(11),
|
|
9
|
+
version: 1,
|
|
10
|
+
dsl: { nodes: [{ type: 'webhook_trigger' }], edges: [] },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function setup() {
|
|
14
|
+
const prisma: any = {
|
|
15
|
+
workflow: {
|
|
16
|
+
findUnique: jest.fn().mockResolvedValue({
|
|
17
|
+
id: workflowId,
|
|
18
|
+
status: 'PUBLISHED',
|
|
19
|
+
isEnabled: true,
|
|
20
|
+
versions: [version],
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
workflowVersion: {
|
|
24
|
+
findFirst: jest.fn().mockResolvedValue(version),
|
|
25
|
+
findUnique: jest.fn(),
|
|
26
|
+
},
|
|
27
|
+
workflowInstance: {
|
|
28
|
+
create: jest.fn(),
|
|
29
|
+
findFirst: jest.fn().mockResolvedValue(null),
|
|
30
|
+
findUnique: jest.fn(),
|
|
31
|
+
findMany: jest.fn().mockResolvedValue([]),
|
|
32
|
+
update: jest.fn(),
|
|
33
|
+
updateMany: jest.fn().mockResolvedValue({ count: 0 }),
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
prisma.$transaction = jest.fn(async (callback: any) =>
|
|
37
|
+
callback({
|
|
38
|
+
$queryRaw: jest.fn().mockResolvedValue([{ isEnabled: true }]),
|
|
39
|
+
workflowInstance: prisma.workflowInstance,
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
const temporal: any = {
|
|
43
|
+
startWorkflow: jest.fn().mockResolvedValue({
|
|
44
|
+
temporalRunId: 'wf-7-21',
|
|
45
|
+
}),
|
|
46
|
+
cancelWorkflow: jest.fn().mockResolvedValue(undefined),
|
|
47
|
+
inspectWorkflow: jest.fn(),
|
|
48
|
+
};
|
|
49
|
+
const service = new WorkflowService(prisma, temporal, {} as any, {} as any);
|
|
50
|
+
return { prisma, temporal, service };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
it('persists the key and starts one deterministic Temporal execution', async () => {
|
|
54
|
+
const { prisma, temporal, service } = setup();
|
|
55
|
+
const created = {
|
|
56
|
+
id: BigInt(21),
|
|
57
|
+
workflowId,
|
|
58
|
+
versionId: version.id,
|
|
59
|
+
status: 'PENDING',
|
|
60
|
+
context: { workflow: { orderId: 'O-1' }, nodes: {} },
|
|
61
|
+
idempotencyRequestHash:
|
|
62
|
+
'6d288206d621b9052da3914713fb30b193ca75b1123e29d3ead4db81be833904',
|
|
63
|
+
temporalRunId: null,
|
|
64
|
+
};
|
|
65
|
+
prisma.workflowInstance.create.mockResolvedValue(created);
|
|
66
|
+
prisma.workflowInstance.updateMany.mockResolvedValue({ count: 1 });
|
|
67
|
+
prisma.workflowInstance.findUnique.mockResolvedValue({
|
|
68
|
+
...created,
|
|
69
|
+
temporalRunId: 'wf-7-21',
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
await expect(
|
|
73
|
+
service.executeWorkflow(
|
|
74
|
+
workflowId,
|
|
75
|
+
{
|
|
76
|
+
workflow: { orderId: 'O-1' },
|
|
77
|
+
workflowVersionId: version.id,
|
|
78
|
+
idempotencyKey: 'webhook:key-1',
|
|
79
|
+
},
|
|
80
|
+
'webhook',
|
|
81
|
+
temporal,
|
|
82
|
+
),
|
|
83
|
+
).resolves.toMatchObject({
|
|
84
|
+
instanceId: '21',
|
|
85
|
+
temporalRunId: 'wf-7-21',
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(prisma.workflowInstance.create).toHaveBeenCalledWith({
|
|
89
|
+
data: expect.objectContaining({
|
|
90
|
+
idempotencyKey: 'webhook:key-1',
|
|
91
|
+
idempotencyRequestHash: expect.stringMatching(/^[a-f0-9]{64}$/),
|
|
92
|
+
}),
|
|
93
|
+
});
|
|
94
|
+
expect(temporal.startWorkflow).toHaveBeenCalledTimes(1);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('rechecks enabled state while holding the Workflow row lock', async () => {
|
|
98
|
+
const { prisma, temporal, service } = setup();
|
|
99
|
+
prisma.$transaction.mockImplementationOnce(async (callback: any) =>
|
|
100
|
+
callback({
|
|
101
|
+
$queryRaw: jest.fn().mockResolvedValue([{ isEnabled: false }]),
|
|
102
|
+
workflowInstance: prisma.workflowInstance,
|
|
103
|
+
}),
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
await expect(
|
|
107
|
+
service.executeWorkflow(workflowId, {}, 'manual', temporal),
|
|
108
|
+
).rejects.toThrow('Workflow is disabled');
|
|
109
|
+
expect(prisma.workflowInstance.create).not.toHaveBeenCalled();
|
|
110
|
+
expect(temporal.startWorkflow).not.toHaveBeenCalled();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('returns the existing execution for the same key and equivalent input', async () => {
|
|
114
|
+
const { prisma, temporal, service } = setup();
|
|
115
|
+
prisma.workflowInstance.create.mockRejectedValue(
|
|
116
|
+
new Prisma.PrismaClientKnownRequestError('duplicate', {
|
|
117
|
+
code: 'P2002',
|
|
118
|
+
clientVersion: '6.19.3',
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
prisma.workflowInstance.findUnique.mockResolvedValue({
|
|
122
|
+
id: BigInt(21),
|
|
123
|
+
workflowId,
|
|
124
|
+
versionId: version.id,
|
|
125
|
+
status: 'COMPLETED',
|
|
126
|
+
context: {
|
|
127
|
+
workflow: { orderId: 'O-1', receivedAt: 'first' },
|
|
128
|
+
nodes: {},
|
|
129
|
+
},
|
|
130
|
+
idempotencyRequestHash:
|
|
131
|
+
'6d288206d621b9052da3914713fb30b193ca75b1123e29d3ead4db81be833904',
|
|
132
|
+
temporalRunId: 'wf-7-21',
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
await expect(
|
|
136
|
+
service.executeWorkflow(
|
|
137
|
+
workflowId,
|
|
138
|
+
{
|
|
139
|
+
workflow: { receivedAt: 'retry', orderId: 'O-1' },
|
|
140
|
+
workflowVersionId: version.id,
|
|
141
|
+
idempotencyKey: 'webhook:key-1',
|
|
142
|
+
idempotencyIgnoredWorkflowFields: ['receivedAt'],
|
|
143
|
+
},
|
|
144
|
+
'webhook',
|
|
145
|
+
temporal,
|
|
146
|
+
),
|
|
147
|
+
).resolves.toMatchObject({
|
|
148
|
+
instanceId: '21',
|
|
149
|
+
status: 'COMPLETED',
|
|
150
|
+
});
|
|
151
|
+
expect(temporal.startWorkflow).not.toHaveBeenCalled();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('does not start Temporal twice when an equivalent execution is already reserved', async () => {
|
|
155
|
+
const { prisma, temporal, service } = setup();
|
|
156
|
+
prisma.workflowInstance.create.mockRejectedValue(
|
|
157
|
+
new Prisma.PrismaClientKnownRequestError('duplicate', {
|
|
158
|
+
code: 'P2002',
|
|
159
|
+
clientVersion: '6.19.3',
|
|
160
|
+
}),
|
|
161
|
+
);
|
|
162
|
+
prisma.workflowInstance.findUnique.mockResolvedValue({
|
|
163
|
+
id: BigInt(21),
|
|
164
|
+
workflowId,
|
|
165
|
+
versionId: version.id,
|
|
166
|
+
status: 'PENDING',
|
|
167
|
+
context: { workflow: { orderId: 'O-1' }, nodes: {} },
|
|
168
|
+
idempotencyRequestHash:
|
|
169
|
+
'6d288206d621b9052da3914713fb30b193ca75b1123e29d3ead4db81be833904',
|
|
170
|
+
temporalRunId: 'wf-7-21',
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
await expect(
|
|
174
|
+
service.executeWorkflow(
|
|
175
|
+
workflowId,
|
|
176
|
+
{
|
|
177
|
+
workflow: { orderId: 'O-1' },
|
|
178
|
+
workflowVersionId: version.id,
|
|
179
|
+
idempotencyKey: 'retry:20',
|
|
180
|
+
},
|
|
181
|
+
'retry',
|
|
182
|
+
temporal,
|
|
183
|
+
),
|
|
184
|
+
).resolves.toMatchObject({
|
|
185
|
+
instanceId: '21',
|
|
186
|
+
temporalRunId: 'wf-7-21',
|
|
187
|
+
status: 'PENDING',
|
|
188
|
+
});
|
|
189
|
+
expect(temporal.startWorkflow).not.toHaveBeenCalled();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('rejects the same key with different input', async () => {
|
|
193
|
+
const { prisma, temporal, service } = setup();
|
|
194
|
+
prisma.workflowInstance.create.mockRejectedValue(
|
|
195
|
+
new Prisma.PrismaClientKnownRequestError('duplicate', {
|
|
196
|
+
code: 'P2002',
|
|
197
|
+
clientVersion: '6.19.3',
|
|
198
|
+
}),
|
|
199
|
+
);
|
|
200
|
+
prisma.workflowInstance.findUnique.mockResolvedValue({
|
|
201
|
+
id: BigInt(21),
|
|
202
|
+
versionId: version.id,
|
|
203
|
+
status: 'COMPLETED',
|
|
204
|
+
context: { workflow: { orderId: 'O-1' }, nodes: {} },
|
|
205
|
+
idempotencyRequestHash: 'different-request-hash',
|
|
206
|
+
temporalRunId: 'wf-7-21',
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
await expect(
|
|
210
|
+
service.executeWorkflow(
|
|
211
|
+
workflowId,
|
|
212
|
+
{
|
|
213
|
+
workflow: { orderId: 'O-2' },
|
|
214
|
+
workflowVersionId: version.id,
|
|
215
|
+
idempotencyKey: 'webhook:key-1',
|
|
216
|
+
},
|
|
217
|
+
'webhook',
|
|
218
|
+
temporal,
|
|
219
|
+
),
|
|
220
|
+
).rejects.toBeInstanceOf(ConflictException);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('marks a reserved instance failed when Temporal cannot start it', async () => {
|
|
224
|
+
const { prisma, temporal, service } = setup();
|
|
225
|
+
const created = {
|
|
226
|
+
id: BigInt(21),
|
|
227
|
+
workflowId,
|
|
228
|
+
versionId: version.id,
|
|
229
|
+
status: 'PENDING',
|
|
230
|
+
context: { workflow: {}, nodes: {} },
|
|
231
|
+
temporalRunId: null,
|
|
232
|
+
};
|
|
233
|
+
prisma.workflowInstance.create.mockResolvedValue(created);
|
|
234
|
+
prisma.workflowInstance.updateMany.mockResolvedValue({ count: 1 });
|
|
235
|
+
temporal.startWorkflow.mockRejectedValue(new Error('Temporal unavailable'));
|
|
236
|
+
|
|
237
|
+
await expect(
|
|
238
|
+
service.executeWorkflow(workflowId, {}, 'manual', temporal),
|
|
239
|
+
).rejects.toThrow('Temporal unavailable');
|
|
240
|
+
|
|
241
|
+
expect(prisma.workflowInstance.updateMany).toHaveBeenLastCalledWith(
|
|
242
|
+
expect.objectContaining({
|
|
243
|
+
where: expect.objectContaining({
|
|
244
|
+
id: BigInt(21),
|
|
245
|
+
status: 'PENDING',
|
|
246
|
+
temporalRunId: 'wf-7-21',
|
|
247
|
+
}),
|
|
248
|
+
data: expect.objectContaining({ status: 'FAILED' }),
|
|
249
|
+
}),
|
|
250
|
+
);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('cancels Temporal immediately when cancellation wins the launch race', async () => {
|
|
254
|
+
const { prisma, temporal, service } = setup();
|
|
255
|
+
const created = {
|
|
256
|
+
id: BigInt(21),
|
|
257
|
+
workflowId,
|
|
258
|
+
versionId: version.id,
|
|
259
|
+
status: 'PENDING',
|
|
260
|
+
context: { workflow: {}, nodes: {} },
|
|
261
|
+
temporalRunId: null,
|
|
262
|
+
};
|
|
263
|
+
prisma.workflowInstance.create.mockResolvedValue(created);
|
|
264
|
+
prisma.workflowInstance.updateMany.mockResolvedValue({ count: 1 });
|
|
265
|
+
prisma.workflowInstance.findUnique.mockResolvedValue({
|
|
266
|
+
...created,
|
|
267
|
+
temporalRunId: 'wf-7-21',
|
|
268
|
+
status: 'CANCELLED',
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
await service.executeWorkflow(workflowId, {}, 'manual', temporal);
|
|
272
|
+
|
|
273
|
+
expect(temporal.cancelWorkflow).toHaveBeenCalledWith('wf-7-21');
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('reuses the original side-effect scope when retrying a failed instance', async () => {
|
|
277
|
+
const { prisma, temporal, service } = setup();
|
|
278
|
+
prisma.workflowInstance.findUnique.mockResolvedValueOnce({
|
|
279
|
+
id: BigInt(22),
|
|
280
|
+
workflowId,
|
|
281
|
+
versionId: version.id,
|
|
282
|
+
status: 'FAILED',
|
|
283
|
+
context: {
|
|
284
|
+
workflow: { orderId: 'O-1' },
|
|
285
|
+
nodes: {},
|
|
286
|
+
system: { operationScopeId: '21' },
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
const execute = jest
|
|
290
|
+
.spyOn(service, 'executeWorkflow')
|
|
291
|
+
.mockResolvedValue({ instanceId: '23' } as any);
|
|
292
|
+
|
|
293
|
+
await service.retryInstance(BigInt(22), 'alice', temporal);
|
|
294
|
+
|
|
295
|
+
expect(execute).toHaveBeenCalledWith(
|
|
296
|
+
workflowId,
|
|
297
|
+
{
|
|
298
|
+
workflow: { orderId: 'O-1' },
|
|
299
|
+
workflowVersionId: version.id,
|
|
300
|
+
idempotencyKey: 'retry:22',
|
|
301
|
+
},
|
|
302
|
+
'alice',
|
|
303
|
+
temporal,
|
|
304
|
+
{
|
|
305
|
+
operationScopeId: '21',
|
|
306
|
+
retryOfInstanceId: BigInt(22),
|
|
307
|
+
},
|
|
308
|
+
);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it('uses one stable execution for concurrent retries of the same failed instance', async () => {
|
|
312
|
+
const { prisma, temporal, service } = setup();
|
|
313
|
+
const failed = {
|
|
314
|
+
id: BigInt(22),
|
|
315
|
+
workflowId,
|
|
316
|
+
versionId: version.id,
|
|
317
|
+
status: 'FAILED',
|
|
318
|
+
context: { workflow: { orderId: 'O-1' }, nodes: {} },
|
|
319
|
+
};
|
|
320
|
+
prisma.workflowInstance.findUnique.mockResolvedValue(failed);
|
|
321
|
+
const execute = jest
|
|
322
|
+
.spyOn(service, 'executeWorkflow')
|
|
323
|
+
.mockResolvedValue({ instanceId: '23' } as any);
|
|
324
|
+
|
|
325
|
+
await Promise.all([
|
|
326
|
+
service.retryInstance(BigInt(22), 'alice', temporal),
|
|
327
|
+
service.retryInstance(BigInt(22), 'alice', temporal),
|
|
328
|
+
]);
|
|
329
|
+
|
|
330
|
+
expect(execute).toHaveBeenCalledTimes(2);
|
|
331
|
+
expect(execute).toHaveBeenNthCalledWith(
|
|
332
|
+
1,
|
|
333
|
+
workflowId,
|
|
334
|
+
expect.objectContaining({ idempotencyKey: 'retry:22' }),
|
|
335
|
+
'alice',
|
|
336
|
+
temporal,
|
|
337
|
+
{
|
|
338
|
+
operationScopeId: '22',
|
|
339
|
+
retryOfInstanceId: BigInt(22),
|
|
340
|
+
},
|
|
341
|
+
);
|
|
342
|
+
expect(execute).toHaveBeenNthCalledWith(
|
|
343
|
+
2,
|
|
344
|
+
workflowId,
|
|
345
|
+
expect.objectContaining({ idempotencyKey: 'retry:22' }),
|
|
346
|
+
'alice',
|
|
347
|
+
temporal,
|
|
348
|
+
{
|
|
349
|
+
operationScopeId: '22',
|
|
350
|
+
retryOfInstanceId: BigInt(22),
|
|
351
|
+
},
|
|
352
|
+
);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it('returns the existing recovery instead of creating another retry from the same failed run', async () => {
|
|
356
|
+
const { prisma, temporal, service } = setup();
|
|
357
|
+
prisma.workflowInstance.findUnique.mockResolvedValueOnce({
|
|
358
|
+
id: BigInt(22),
|
|
359
|
+
workflowId,
|
|
360
|
+
versionId: version.id,
|
|
361
|
+
status: 'FAILED',
|
|
362
|
+
context: { workflow: { orderId: 'O-1' }, nodes: {} },
|
|
363
|
+
nodeExecutions: [],
|
|
364
|
+
});
|
|
365
|
+
prisma.workflowInstance.findFirst.mockResolvedValueOnce({
|
|
366
|
+
id: BigInt(23),
|
|
367
|
+
workflowId,
|
|
368
|
+
versionId: version.id,
|
|
369
|
+
status: 'COMPLETED',
|
|
370
|
+
temporalRunId: 'wf-7-23',
|
|
371
|
+
});
|
|
372
|
+
const execute = jest.spyOn(service, 'executeWorkflow');
|
|
373
|
+
|
|
374
|
+
await expect(
|
|
375
|
+
service.retryInstanceFromNode(BigInt(22), 'request', 'alice', temporal),
|
|
376
|
+
).resolves.toEqual({
|
|
377
|
+
instanceId: '23',
|
|
378
|
+
temporalRunId: 'wf-7-23',
|
|
379
|
+
workflowVersionId: '11',
|
|
380
|
+
status: 'COMPLETED',
|
|
381
|
+
});
|
|
382
|
+
expect(execute).not.toHaveBeenCalled();
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
it('creates a checkpointed retry that preserves the original side-effect scope', async () => {
|
|
386
|
+
const { prisma, temporal, service } = setup();
|
|
387
|
+
const approvalOutput = {
|
|
388
|
+
previous: { eventId: 'event-1' },
|
|
389
|
+
result: { requestId: '6', result: 'APPROVED', approved: true },
|
|
390
|
+
};
|
|
391
|
+
prisma.workflowInstance.findUnique.mockResolvedValueOnce({
|
|
392
|
+
id: BigInt(22),
|
|
393
|
+
workflowId,
|
|
394
|
+
versionId: version.id,
|
|
395
|
+
status: 'FAILED',
|
|
396
|
+
context: {
|
|
397
|
+
workflow: { eventId: 'event-1' },
|
|
398
|
+
nodes: {},
|
|
399
|
+
system: { operationScopeId: '21' },
|
|
400
|
+
},
|
|
401
|
+
nodeExecutions: [
|
|
402
|
+
{
|
|
403
|
+
nodeId: 'approval',
|
|
404
|
+
status: 'COMPLETED',
|
|
405
|
+
output: approvalOutput,
|
|
406
|
+
},
|
|
407
|
+
{ nodeId: 'request', status: 'FAILED', output: null },
|
|
408
|
+
],
|
|
409
|
+
});
|
|
410
|
+
prisma.workflowVersion.findUnique.mockResolvedValueOnce({
|
|
411
|
+
dsl: {
|
|
412
|
+
nodes: [
|
|
413
|
+
{ id: 'start', type: 'event_trigger', label: '业务事件触发' },
|
|
414
|
+
{ id: 'approval', type: 'approval', label: '人工审批' },
|
|
415
|
+
{ id: 'request', type: 'http_request', label: '确认报废' },
|
|
416
|
+
],
|
|
417
|
+
edges: [
|
|
418
|
+
{ source: 'start', target: 'approval', kind: 'FLOW' },
|
|
419
|
+
{
|
|
420
|
+
source: 'approval',
|
|
421
|
+
target: 'request',
|
|
422
|
+
sourceHandle: 'true',
|
|
423
|
+
kind: 'FLOW',
|
|
424
|
+
},
|
|
425
|
+
],
|
|
426
|
+
},
|
|
427
|
+
});
|
|
428
|
+
const execute = jest
|
|
429
|
+
.spyOn(service, 'executeWorkflow')
|
|
430
|
+
.mockResolvedValue({ instanceId: '23' } as any);
|
|
431
|
+
|
|
432
|
+
await service.retryInstanceFromNode(
|
|
433
|
+
BigInt(22),
|
|
434
|
+
'request',
|
|
435
|
+
'alice',
|
|
436
|
+
temporal,
|
|
437
|
+
);
|
|
438
|
+
|
|
439
|
+
expect(execute).toHaveBeenCalledWith(
|
|
440
|
+
workflowId,
|
|
441
|
+
{
|
|
442
|
+
workflow: { eventId: 'event-1' },
|
|
443
|
+
workflowVersionId: version.id,
|
|
444
|
+
idempotencyKey: 'retry:22',
|
|
445
|
+
},
|
|
446
|
+
'alice',
|
|
447
|
+
temporal,
|
|
448
|
+
{
|
|
449
|
+
operationScopeId: '21',
|
|
450
|
+
retryCheckpoint: {
|
|
451
|
+
startNodeId: 'request',
|
|
452
|
+
completedNodeIds: ['approval'],
|
|
453
|
+
outputs: { approval: approvalOutput },
|
|
454
|
+
},
|
|
455
|
+
retryOfInstanceId: BigInt(22),
|
|
456
|
+
retryFromNodeId: 'request',
|
|
457
|
+
},
|
|
458
|
+
);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it('does not retry from inside a private branch pipeline', async () => {
|
|
462
|
+
const { prisma, temporal, service } = setup();
|
|
463
|
+
prisma.workflowInstance.findUnique.mockResolvedValueOnce({
|
|
464
|
+
id: BigInt(22),
|
|
465
|
+
workflowId,
|
|
466
|
+
versionId: version.id,
|
|
467
|
+
status: 'FAILED',
|
|
468
|
+
context: { workflow: {}, nodes: {} },
|
|
469
|
+
nodeExecutions: [
|
|
470
|
+
{ nodeId: 'branch-request', status: 'FAILED', output: null },
|
|
471
|
+
],
|
|
472
|
+
});
|
|
473
|
+
prisma.workflowVersion.findUnique.mockResolvedValueOnce({
|
|
474
|
+
dsl: {
|
|
475
|
+
nodes: [
|
|
476
|
+
{ id: 'start', type: 'event_trigger', label: '业务事件触发' },
|
|
477
|
+
{ id: 'parallel', type: 'parallel', label: '并行执行' },
|
|
478
|
+
{
|
|
479
|
+
id: 'branch-request',
|
|
480
|
+
type: 'http_request',
|
|
481
|
+
label: '分支请求',
|
|
482
|
+
},
|
|
483
|
+
],
|
|
484
|
+
edges: [
|
|
485
|
+
{ source: 'start', target: 'parallel', kind: 'FLOW' },
|
|
486
|
+
{
|
|
487
|
+
source: 'parallel',
|
|
488
|
+
target: 'branch-request',
|
|
489
|
+
kind: 'CALL',
|
|
490
|
+
pairId: 'branch-a',
|
|
491
|
+
},
|
|
492
|
+
],
|
|
493
|
+
},
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
await expect(
|
|
497
|
+
service.retryInstanceFromNode(
|
|
498
|
+
BigInt(22),
|
|
499
|
+
'branch-request',
|
|
500
|
+
'alice',
|
|
501
|
+
temporal,
|
|
502
|
+
),
|
|
503
|
+
).rejects.toThrow('暂不支持从循环或并行分支内部重试');
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
it('keeps inherited checkpoint outputs when a resumed run fails farther downstream', async () => {
|
|
507
|
+
const { prisma, temporal, service } = setup();
|
|
508
|
+
const approvalOutput = {
|
|
509
|
+
result: { requestId: '6', result: 'APPROVED', approved: true },
|
|
510
|
+
};
|
|
511
|
+
const requestOutput = { status: 200, data: { resolved: true } };
|
|
512
|
+
prisma.workflowInstance.findUnique.mockResolvedValueOnce({
|
|
513
|
+
id: BigInt(23),
|
|
514
|
+
workflowId,
|
|
515
|
+
versionId: version.id,
|
|
516
|
+
status: 'FAILED',
|
|
517
|
+
context: {
|
|
518
|
+
workflow: { eventId: 'event-1' },
|
|
519
|
+
nodes: {},
|
|
520
|
+
system: {
|
|
521
|
+
operationScopeId: '21',
|
|
522
|
+
retryCheckpoint: {
|
|
523
|
+
startNodeId: 'request',
|
|
524
|
+
completedNodeIds: ['approval'],
|
|
525
|
+
outputs: { approval: approvalOutput },
|
|
526
|
+
},
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
nodeExecutions: [
|
|
530
|
+
{ nodeId: 'request', status: 'COMPLETED', output: requestOutput },
|
|
531
|
+
{ nodeId: 'notify', status: 'FAILED', output: null },
|
|
532
|
+
],
|
|
533
|
+
});
|
|
534
|
+
prisma.workflowVersion.findUnique.mockResolvedValueOnce({
|
|
535
|
+
dsl: {
|
|
536
|
+
nodes: [
|
|
537
|
+
{ id: 'start', type: 'event_trigger', label: '业务事件触发' },
|
|
538
|
+
{ id: 'approval', type: 'approval', label: '人工审批' },
|
|
539
|
+
{ id: 'request', type: 'http_request', label: '确认报废' },
|
|
540
|
+
{ id: 'notify', type: 'http_request', label: '发送通知' },
|
|
541
|
+
],
|
|
542
|
+
edges: [
|
|
543
|
+
{ source: 'start', target: 'approval', kind: 'FLOW' },
|
|
544
|
+
{ source: 'approval', target: 'request', kind: 'FLOW' },
|
|
545
|
+
{ source: 'request', target: 'notify', kind: 'FLOW' },
|
|
546
|
+
],
|
|
547
|
+
},
|
|
548
|
+
});
|
|
549
|
+
const execute = jest
|
|
550
|
+
.spyOn(service, 'executeWorkflow')
|
|
551
|
+
.mockResolvedValue({ instanceId: '24' } as any);
|
|
552
|
+
|
|
553
|
+
await service.retryInstanceFromNode(
|
|
554
|
+
BigInt(23),
|
|
555
|
+
'notify',
|
|
556
|
+
'alice',
|
|
557
|
+
temporal,
|
|
558
|
+
);
|
|
559
|
+
|
|
560
|
+
expect(execute).toHaveBeenCalledWith(
|
|
561
|
+
workflowId,
|
|
562
|
+
expect.objectContaining({
|
|
563
|
+
idempotencyKey: 'retry:23',
|
|
564
|
+
}),
|
|
565
|
+
'alice',
|
|
566
|
+
temporal,
|
|
567
|
+
expect.objectContaining({
|
|
568
|
+
operationScopeId: '21',
|
|
569
|
+
retryCheckpoint: {
|
|
570
|
+
startNodeId: 'notify',
|
|
571
|
+
completedNodeIds: ['approval', 'request'],
|
|
572
|
+
outputs: {
|
|
573
|
+
approval: approvalOutput,
|
|
574
|
+
request: requestOutput,
|
|
575
|
+
},
|
|
576
|
+
},
|
|
577
|
+
}),
|
|
578
|
+
);
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
it('restarts a stale reserved instance when Temporal has no execution', async () => {
|
|
582
|
+
const { prisma, temporal, service } = setup();
|
|
583
|
+
const reserved = {
|
|
584
|
+
id: BigInt(21),
|
|
585
|
+
workflowId,
|
|
586
|
+
versionId: version.id,
|
|
587
|
+
status: 'PENDING',
|
|
588
|
+
context: { workflow: { orderId: 'O-1' }, nodes: {} },
|
|
589
|
+
temporalRunId: 'wf-7-21',
|
|
590
|
+
};
|
|
591
|
+
prisma.workflowInstance.findMany.mockResolvedValueOnce([reserved]);
|
|
592
|
+
prisma.workflowVersion.findUnique.mockResolvedValueOnce({
|
|
593
|
+
dsl: version.dsl,
|
|
594
|
+
});
|
|
595
|
+
temporal.inspectWorkflow
|
|
596
|
+
.mockResolvedValueOnce({ kind: 'MISSING' })
|
|
597
|
+
.mockResolvedValueOnce({
|
|
598
|
+
kind: 'FOUND',
|
|
599
|
+
status: 'RUNNING',
|
|
600
|
+
startedAt: new Date('2026-08-13T00:00:00.000Z'),
|
|
601
|
+
});
|
|
602
|
+
prisma.workflowInstance.updateMany
|
|
603
|
+
.mockResolvedValueOnce({ count: 0 })
|
|
604
|
+
.mockResolvedValueOnce({ count: 1 });
|
|
605
|
+
|
|
606
|
+
await service.reconcileUnstartedInstances();
|
|
607
|
+
|
|
608
|
+
expect(temporal.startWorkflow).toHaveBeenCalledWith({
|
|
609
|
+
instanceId: 21,
|
|
610
|
+
workflowId: 7,
|
|
611
|
+
versionId: 11,
|
|
612
|
+
dsl: version.dsl,
|
|
613
|
+
context: reserved.context,
|
|
614
|
+
});
|
|
615
|
+
expect(prisma.workflowInstance.updateMany).toHaveBeenLastCalledWith(
|
|
616
|
+
expect.objectContaining({
|
|
617
|
+
where: expect.objectContaining({
|
|
618
|
+
id: BigInt(21),
|
|
619
|
+
temporalRunId: 'wf-7-21',
|
|
620
|
+
status: 'PENDING',
|
|
621
|
+
}),
|
|
622
|
+
data: expect.objectContaining({ status: 'RUNNING' }),
|
|
623
|
+
}),
|
|
624
|
+
);
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
it('cancels a reconciled execution when cancellation wins the restart race', async () => {
|
|
628
|
+
const { prisma, temporal, service } = setup();
|
|
629
|
+
const reserved = {
|
|
630
|
+
id: BigInt(21),
|
|
631
|
+
workflowId,
|
|
632
|
+
versionId: version.id,
|
|
633
|
+
status: 'PENDING',
|
|
634
|
+
context: { workflow: {}, nodes: {} },
|
|
635
|
+
temporalRunId: 'wf-7-21',
|
|
636
|
+
};
|
|
637
|
+
prisma.workflowInstance.findMany.mockResolvedValueOnce([reserved]);
|
|
638
|
+
prisma.workflowVersion.findUnique.mockResolvedValueOnce({
|
|
639
|
+
dsl: version.dsl,
|
|
640
|
+
});
|
|
641
|
+
prisma.workflowInstance.updateMany
|
|
642
|
+
.mockResolvedValueOnce({ count: 0 })
|
|
643
|
+
.mockResolvedValueOnce({ count: 0 });
|
|
644
|
+
prisma.workflowInstance.findUnique.mockResolvedValueOnce({
|
|
645
|
+
...reserved,
|
|
646
|
+
status: 'CANCELLED',
|
|
647
|
+
});
|
|
648
|
+
temporal.inspectWorkflow
|
|
649
|
+
.mockResolvedValueOnce({ kind: 'MISSING' })
|
|
650
|
+
.mockResolvedValueOnce({
|
|
651
|
+
kind: 'FOUND',
|
|
652
|
+
status: 'RUNNING',
|
|
653
|
+
startedAt: new Date('2026-08-13T00:00:00.000Z'),
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
await service.reconcileUnstartedInstances();
|
|
657
|
+
|
|
658
|
+
expect(temporal.cancelWorkflow).toHaveBeenCalledWith('wf-7-21');
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
it('recovers a completed Temporal result without exposing internal context', async () => {
|
|
662
|
+
const { prisma, temporal, service } = setup();
|
|
663
|
+
prisma.workflowInstance.findMany.mockResolvedValueOnce([
|
|
664
|
+
{
|
|
665
|
+
id: BigInt(21),
|
|
666
|
+
workflowId,
|
|
667
|
+
versionId: version.id,
|
|
668
|
+
status: 'PENDING',
|
|
669
|
+
context: { workflow: { orderId: 'O-1' }, nodes: {} },
|
|
670
|
+
temporalRunId: 'wf-7-21',
|
|
671
|
+
},
|
|
672
|
+
]);
|
|
673
|
+
prisma.workflowInstance.updateMany
|
|
674
|
+
.mockResolvedValueOnce({ count: 0 })
|
|
675
|
+
.mockResolvedValueOnce({ count: 1 });
|
|
676
|
+
temporal.inspectWorkflow.mockResolvedValueOnce({
|
|
677
|
+
kind: 'FOUND',
|
|
678
|
+
status: 'COMPLETED',
|
|
679
|
+
startedAt: new Date('2026-08-13T00:00:00.000Z'),
|
|
680
|
+
finishedAt: new Date('2026-08-13T00:00:01.000Z'),
|
|
681
|
+
result: {
|
|
682
|
+
status: 'COMPLETED',
|
|
683
|
+
context: {
|
|
684
|
+
workflow: { orderId: 'O-1' },
|
|
685
|
+
nodes: { internalNodeId: { secret: true } },
|
|
686
|
+
},
|
|
687
|
+
output: { approved: true },
|
|
688
|
+
},
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
await service.reconcileUnstartedInstances();
|
|
692
|
+
|
|
693
|
+
expect(prisma.workflowInstance.updateMany).toHaveBeenLastCalledWith(
|
|
694
|
+
expect.objectContaining({
|
|
695
|
+
data: expect.objectContaining({
|
|
696
|
+
status: 'COMPLETED',
|
|
697
|
+
result: {
|
|
698
|
+
workflow: { orderId: 'O-1' },
|
|
699
|
+
output: { approved: true },
|
|
700
|
+
},
|
|
701
|
+
}),
|
|
702
|
+
}),
|
|
703
|
+
);
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
it('reconciles a stale RUNNING instance after Temporal reaches a terminal state', async () => {
|
|
707
|
+
const { prisma, temporal, service } = setup();
|
|
708
|
+
prisma.workflowInstance.findMany.mockResolvedValueOnce([
|
|
709
|
+
{
|
|
710
|
+
id: BigInt(21),
|
|
711
|
+
workflowId,
|
|
712
|
+
versionId: version.id,
|
|
713
|
+
status: 'RUNNING',
|
|
714
|
+
context: { workflow: { orderId: 'O-1' }, nodes: {} },
|
|
715
|
+
temporalRunId: 'wf-7-21',
|
|
716
|
+
},
|
|
717
|
+
]);
|
|
718
|
+
temporal.inspectWorkflow.mockResolvedValueOnce({
|
|
719
|
+
kind: 'FOUND',
|
|
720
|
+
status: 'FAILED',
|
|
721
|
+
startedAt: new Date('2026-08-13T00:00:00.000Z'),
|
|
722
|
+
finishedAt: new Date('2026-08-13T00:00:01.000Z'),
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
await service.reconcileUnstartedInstances();
|
|
726
|
+
|
|
727
|
+
expect(prisma.workflowInstance.updateMany).toHaveBeenLastCalledWith(
|
|
728
|
+
expect.objectContaining({
|
|
729
|
+
where: {
|
|
730
|
+
id: BigInt(21),
|
|
731
|
+
status: { in: ['PENDING', 'RUNNING'] },
|
|
732
|
+
temporalRunId: 'wf-7-21',
|
|
733
|
+
},
|
|
734
|
+
data: expect.objectContaining({ status: 'FAILED' }),
|
|
735
|
+
}),
|
|
736
|
+
);
|
|
737
|
+
expect(temporal.startWorkflow).not.toHaveBeenCalled();
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
it('fails a stale RUNNING instance when its Temporal execution is missing', async () => {
|
|
741
|
+
const { prisma, temporal, service } = setup();
|
|
742
|
+
prisma.workflowInstance.findMany.mockResolvedValueOnce([
|
|
743
|
+
{
|
|
744
|
+
id: BigInt(21),
|
|
745
|
+
workflowId,
|
|
746
|
+
versionId: version.id,
|
|
747
|
+
status: 'RUNNING',
|
|
748
|
+
context: { workflow: {}, nodes: {} },
|
|
749
|
+
temporalRunId: 'wf-7-21',
|
|
750
|
+
},
|
|
751
|
+
]);
|
|
752
|
+
temporal.inspectWorkflow.mockResolvedValueOnce({ kind: 'MISSING' });
|
|
753
|
+
|
|
754
|
+
await service.reconcileUnstartedInstances();
|
|
755
|
+
|
|
756
|
+
expect(prisma.workflowInstance.updateMany).toHaveBeenLastCalledWith(
|
|
757
|
+
expect.objectContaining({
|
|
758
|
+
where: {
|
|
759
|
+
id: BigInt(21),
|
|
760
|
+
status: 'RUNNING',
|
|
761
|
+
temporalRunId: 'wf-7-21',
|
|
762
|
+
},
|
|
763
|
+
data: expect.objectContaining({
|
|
764
|
+
status: 'FAILED',
|
|
765
|
+
result: expect.objectContaining({
|
|
766
|
+
code: 'TEMPORAL_EXECUTION_MISSING',
|
|
767
|
+
}),
|
|
768
|
+
}),
|
|
769
|
+
}),
|
|
770
|
+
);
|
|
771
|
+
expect(temporal.startWorkflow).not.toHaveBeenCalled();
|
|
772
|
+
});
|
|
773
|
+
});
|