@gadmin2n/schematics 0.0.138 → 0.0.140
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/Jenkinsfile +6 -34
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/approval.prisma +199 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/system.prisma +9 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/workflow.prisma +191 -14
- package/dist/lib/application/files/gadmin2-game-angle-demo/gitignore +6 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/readme.md +10 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/migrate-between-pg-schemas.js +6 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/package.json +5 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/prisma.config.ts +12 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/scripts/migrate-human-approval-configs.ts +86 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/workflow-node-types.ts +682 -121
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/workflow.seed.ts +110 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/config/index.ts +28 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/json-body-parser.spec.ts +61 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/json-body-parser.ts +7 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/structured-all-exceptions.filter.spec.ts +54 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/structured-all-exceptions.filter.ts +86 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/main.ts +9 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/approvalChannel/approval-channel.controller.ts +89 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/approvalChannel/approval-channel.dto.ts +68 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/approvalChannel/approval-channel.service.spec.ts +177 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/approvalChannel/approval-channel.service.ts +283 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/approvalChannel/approvalChannel.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/codeRuntime/code-executor.spec.ts +42 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/codeRuntime/code-executor.ts +108 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/codeRuntime/code-runtime.controller.ts +101 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/codeRuntime/code-runtime.dto.ts +29 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/codeRuntime/codeRuntime.module.ts +21 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-handler.registry.ts +30 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-handler.ts +15 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-runtime.controller.spec.ts +105 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-runtime.controller.ts +96 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-runtime.dto.ts +78 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-signal-outbox.service.spec.ts +56 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-signal-outbox.service.ts +111 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-token.spec.ts +23 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-token.ts +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction.service.spec.ts +240 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction.service.ts +339 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction.types.ts +74 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-wait.handler.ts +47 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/externalInteraction.module.ts +41 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/human-approval.handler.spec.ts +70 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/human-approval.handler.ts +76 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/workflow-callback-url.controller.ts +12 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/workflow-callback-url.service.spec.ts +227 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/workflow-callback-url.service.ts +121 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/httpRequest/http-request-runtime.controller.ts +160 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/httpRequest/http-request-runtime.dto.ts +41 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/httpRequest/http-request-runtime.util.spec.ts +171 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/httpRequest/http-request-runtime.util.ts +245 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/httpRequest/httpRequest.module.ts +22 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/approval-rule-evaluator.spec.ts +68 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/approval-rule-evaluator.ts +126 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/approval-rule.types.ts +34 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/approval-signal-outbox.service.ts +115 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/approval-subject-source.util.spec.ts +45 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/approval-subject-source.util.ts +59 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.controller.ts +72 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.dto.ts +144 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.errors.ts +19 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.external-decision.spec.ts +350 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.service.ts +774 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/humanApproval.module.ts +46 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/legacy-approval-config-migration.ts +227 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/outbox-retry.util.ts +14 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/runtime/human-approval-runtime.controller.ts +151 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/runtime/human-approval-runtime.dto.ts +88 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/runtime/runtime-token.guard.ts +43 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/index.ts +21 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/integrationConnection/integration-connection.controller.ts +77 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/integrationConnection/integration-connection.dto.ts +98 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/integrationConnection/integration-connection.service.ts +277 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/integrationConnection/integration-secret-cipher.spec.ts +14 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/integrationConnection/integration-secret-cipher.ts +59 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/integrationConnection/integrationConnection.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/subjectProvider/actor-context.util.ts +27 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/subjectProvider/providers/user-group.provider.ts +208 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/subjectProvider/providers/user.provider.ts +168 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/subjectProvider/subject-provider.controller.spec.ts +157 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/subjectProvider/subject-provider.controller.ts +176 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/subjectProvider/subject-provider.dto.ts +21 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/subjectProvider/subject-provider.errors.ts +78 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/subjectProvider/subject-provider.registry.spec.ts +100 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/subjectProvider/subject-provider.registry.ts +115 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/subjectProvider/subject-provider.types.ts +97 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/subjectProvider/subjectProvider.module.ts +34 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/temporalTenantConfig/temporalTenantConfig.controller.spec.ts +89 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/temporalTenantConfig/temporalTenantConfig.controller.ts +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/userGroup/user-group.controller.ts +119 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/userGroup/user-group.dto.ts +91 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/userGroup/user-group.errors.ts +34 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/userGroup/user-group.service.spec.ts +161 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/userGroup/user-group.service.ts +390 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/userGroup/userGroup.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/dsl-validate.util.spec.ts +17 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/dsl-validate.util.ts +8 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/parameter-binding.ts +93 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-callable.spec.ts +158 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-callable.ts +155 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-compiler.service.spec.ts +363 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-compiler.service.ts +354 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-compiler.types.ts +43 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-data-edge.util.spec.ts +174 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-data-edge.util.ts +149 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-dsl-comparison.ts +43 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-execution.dto.ts +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-export.dto.ts +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-export.service.ts +70 -28
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-handle-validator.ts +128 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.controller.ts +12 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.module.ts +18 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.service.spec.ts +369 -22
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.service.ts +319 -90
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/node-config-validator.service.spec.ts +79 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/node-config-validator.service.ts +62 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/schema.types.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/subject-config-validator.service.spec.ts +124 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/subject-config-validator.service.ts +236 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/widget-catalog.service.spec.ts +49 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/widget-catalog.service.ts +69 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/workflowConfig.module.ts +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/node-instance-config.util.spec.ts +15 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/node-instance-config.util.ts +25 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/workflowNodeInstance.controller.ts +103 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/workflowNodeInstance.dto.ts +98 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/workflowNodeInstance.module.ts +3 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/workflowNodeInstance.service.spec.ts +72 -62
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowNodeInstance/workflowNodeInstance.service.ts +148 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/package.json +13 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/App.tsx +5 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/authProvider.ts +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/BulkActions.tsx +0 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/SearchBar.tsx +26 -18
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/eventList/index.tsx +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/logButton/index.tsx +24 -17
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/logList/index.tsx +7 -18
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/modalDiffViewer/index.tsx +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/contexts/color-mode/index.tsx +288 -33
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/contexts/color-mode/themeStyles.ts +97 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/SettingDrawer.tsx +251 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/header.tsx +47 -19
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/layout.tsx +18 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/menuRenderer.tsx +155 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/sider.tsx +123 -129
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/config/routeRegistry.tsx +16 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/constants/layout.ts +2 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/AddDataModal.tsx +98 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/AddPageModal.tsx +101 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/DevShell.tsx +8 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/style.css +51 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/form.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/list.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/login.ts +40 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/show.tsx +5 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useDynamicResources.tsx +16 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useListPageState.ts +10 -7
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/i18n.ts +4 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/locales/en/common.json +26 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/locales/en/workflow.json +556 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/locales/zh_CN/common.json +26 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/locales/zh_CN/workflow.json +556 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/plugins/devShellPlugin.ts +152 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agenda/index.tsx +6 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agenda/show.tsx +41 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agendaJob/edit.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agendaJob/list.tsx +10 -8
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agendaJob/show.tsx +3 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/components/action-cell.css +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/edit.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/show.tsx +3 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasCell.css +3 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasCell.tsx +45 -13
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasComponentLibrary.tsx +45 -22
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasListPage.tsx +168 -101
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasPage.tsx +248 -74
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasToolbar.tsx +33 -18
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CodeFloatWindow.tsx +16 -10
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/PublishModal.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/canvasContextMenuRegistry.tsx +31 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/canvasDefaults.ts +15 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/BarChartDataSourceModal.tsx +16 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/CanvasAiModal.tsx +25 -21
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/ExportModal.tsx +6 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/LineChartDataSourceModal.tsx +9 -10
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/MultiChartConfigModal.tsx +4 -7
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/MultiChartDataSourceModal.tsx +23 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/NumCardDataSourceModal.tsx +16 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/PromptModal.tsx +2 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/RadarChartDataSourceModal.tsx +16 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/TableConfigModal.tsx +2 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/TableDataSourceModal.tsx +23 -12
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/canvasModalProps.ts +2 -17
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/sectionCompactor.test.ts +149 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/sectionCompactor.ts +111 -17
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/types.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/whiteboardLayout.test.ts +83 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/whiteboardLayout.ts +118 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/whiteboardName.test.ts +26 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas-page/index.tsx +9 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/game/edit.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/game/list.tsx +10 -8
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/game/show.tsx +3 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/human-approval/DecisionModal.tsx +71 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/human-approval/inbox.tsx +216 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/AssignRolesModal.tsx +6 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/permissionReadme/index.tsx +8 -8
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/Components/modal.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/list.tsx +5 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/Components/modal.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/show-drawer.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/approval-channels/ApprovalChannelModal.test.tsx +84 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/approval-channels/ApprovalChannelModal.tsx +141 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/approval-channels/approval-channel.types.ts +16 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/approval-channels/index.tsx +208 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/CreateNodeInstanceDrawer.tsx +154 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/CustomNode.tsx +194 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/DeletableEdge.tsx +76 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/DslView.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/EnhancedFlowRenderer.tsx +176 -22
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ExecutionStatusNode.test.tsx +62 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ExecutionStatusNode.tsx +94 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ExportModal.tsx +15 -10
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/FlowRenderer.tsx +251 -70
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ImportModal.tsx +18 -24
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/InstanceRequiredDialog.tsx +106 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/LookupConnectionDialog.test.tsx +45 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/LookupConnectionDialog.tsx +43 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NewNodeDefaults.test.tsx +279 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodeEditModal.tsx +6 -7
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodePropertyPanel.test.tsx +335 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodePropertyPanel.tsx +433 -237
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ParameterBindingEditor.tsx +179 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/RunWorkflowModal.tsx +18 -16
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/StatusCards.tsx +20 -16
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/VersionPanel.tsx +6 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/connections/ConnectionModal.test.tsx +68 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/connections/ConnectionModal.tsx +367 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/connections/connection.types.ts +21 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/connections/index.tsx +171 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/editor.tsx +38 -22
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/hooks/useNodeInstanceLibrary.ts +41 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/hooks/useWorkflowAgent.ts +6 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/index.tsx +27 -20
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/instance-detail.tsx +8 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/instances.tsx +6 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/components/NodeInstanceForm.tsx +56 -23
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/create.tsx +21 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/edit.tsx +17 -20
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/index.tsx +6 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/SchemaField.tsx +311 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/SchemaForm.test.tsx +218 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/SchemaForm.tsx +83 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/default-widgets.tsx +135 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/schema-defaults.ts +36 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/schema.types.ts +32 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/widget-registry.test.tsx +23 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/widget-registry.tsx +52 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/show.tsx +9 -13
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ApprovalRequestTriggerConfigEditor.tsx +39 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ApprovalRuleEditor.test.tsx +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ApprovalRuleEditor.tsx +72 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ApproverSourceEditor.test.tsx +47 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ApproverSourceEditor.tsx +185 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/CallableInputParametersEditor.test.tsx +102 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/CallableInputParametersEditor.tsx +150 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/CodeConfigEditor.tsx +103 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ExternalRequestConfigEditor.test.tsx +93 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ExternalRequestConfigEditor.tsx +196 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ExternalWaitConfigEditor.tsx +303 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/HttpRequestConfigEditor.test.tsx +189 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/HttpRequestConfigEditor.tsx +706 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/HumanApprovalConfigEditor.test.tsx +86 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/HumanApprovalConfigEditor.tsx +458 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ReturnResultConfigEditor.test.tsx +53 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ReturnResultConfigEditor.tsx +91 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/SubjectPicker.test.tsx +61 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/SubjectPicker.tsx +266 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/SubmitApprovalResultConfigEditor.tsx +104 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/SubmitExternalResultConfigEditor.tsx +98 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/UserGroupCreateModal.tsx +70 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/UserGroupEditModal.tsx +138 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/approver-source.test.ts +25 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/approver-source.ts +42 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/subject-provider.api.ts +95 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/show.tsx +15 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/temporal-tenant/index.tsx +49 -8
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/types/parameter-binding.ts +49 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/types.ts +31 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/lookupConnection.test.ts +208 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/lookupConnection.ts +246 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/newNodeConfig.ts +73 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/removeWorkflowEdges.test.ts +34 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/removeWorkflowEdges.ts +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveLookupPorts.ts +66 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveOutputs.test.ts +39 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveOutputs.ts +48 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveWorkflowDisplay.test.ts +51 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveWorkflowDisplay.ts +32 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/edit.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/list.tsx +10 -8
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/show.tsx +3 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/antd-theme-vars.css +93 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/antd.css +8 -8
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/fc.css +4 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/index.css +20 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/show-drawer.module.css +3 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/show-page.module.css +3 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/theme-styles.css +81 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/test/setup.ts +5 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/vite.config.ts +1 -7
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/vitest.config.ts +12 -0
- package/package.json +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/components/DynamicConfigForm.tsx +0 -154
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { ExternalInteractionHandlerRegistry } from './external-interaction-handler.registry';
|
|
2
|
+
import { createCallbackToken } from './external-interaction-token';
|
|
3
|
+
import { ExternalInteractionService } from './external-interaction.service';
|
|
4
|
+
import { ExternalWaitHandler } from './external-wait.handler';
|
|
5
|
+
|
|
6
|
+
describe('ExternalInteractionService', () => {
|
|
7
|
+
const now = new Date('2026-07-28T00:00:00.000Z');
|
|
8
|
+
|
|
9
|
+
it('creates an idempotent interaction with a caller-provided token', async () => {
|
|
10
|
+
const { token, tokenHash } = createCallbackToken();
|
|
11
|
+
const tx = {
|
|
12
|
+
externalInteraction: {
|
|
13
|
+
findUnique: jest.fn().mockResolvedValue(null),
|
|
14
|
+
create: jest.fn().mockImplementation(({ data }) => ({
|
|
15
|
+
id: BigInt(51),
|
|
16
|
+
status: 'PENDING',
|
|
17
|
+
...data,
|
|
18
|
+
})),
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
const prisma = { $transaction: jest.fn((callback) => callback(tx)) };
|
|
22
|
+
const registry = new ExternalInteractionHandlerRegistry();
|
|
23
|
+
registry.register(new ExternalWaitHandler());
|
|
24
|
+
const service = new ExternalInteractionService(
|
|
25
|
+
prisma as any,
|
|
26
|
+
registry,
|
|
27
|
+
() => now,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
await expect(
|
|
31
|
+
service.createInteraction({
|
|
32
|
+
callbackToken: token,
|
|
33
|
+
tenantNamespace: 'tenant-a',
|
|
34
|
+
handlerType: 'EXTERNAL_WAIT',
|
|
35
|
+
handlerConfig: { allowedOutcomes: ['SIGNED'] },
|
|
36
|
+
workflowInstanceId: '91',
|
|
37
|
+
workflowVersionId: '12',
|
|
38
|
+
temporalRunId: 'wf-91',
|
|
39
|
+
nodeId: 'external-wait-1',
|
|
40
|
+
expiresAt: '2026-07-29T00:00:00.000Z',
|
|
41
|
+
}),
|
|
42
|
+
).resolves.toEqual({
|
|
43
|
+
interactionId: '51',
|
|
44
|
+
callbackToken: token,
|
|
45
|
+
status: 'PENDING',
|
|
46
|
+
});
|
|
47
|
+
expect(tx.externalInteraction.create).toHaveBeenCalledWith({
|
|
48
|
+
data: expect.objectContaining({
|
|
49
|
+
tokenHash,
|
|
50
|
+
workflowInstanceId: BigInt(91),
|
|
51
|
+
workflowVersionId: BigInt(12),
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
function setup(overrides: Record<string, unknown> = {}) {
|
|
57
|
+
const { token, tokenHash } = createCallbackToken();
|
|
58
|
+
const interaction = {
|
|
59
|
+
id: BigInt(41),
|
|
60
|
+
tokenHash,
|
|
61
|
+
tenantNamespace: 'tenant-a',
|
|
62
|
+
handlerType: 'EXTERNAL_WAIT',
|
|
63
|
+
handlerConfig: { allowedOutcomes: ['SIGNED', 'REJECTED'] },
|
|
64
|
+
workflowInstanceId: BigInt(91),
|
|
65
|
+
workflowVersionId: BigInt(12),
|
|
66
|
+
temporalRunId: 'wf-91',
|
|
67
|
+
nodeId: 'external-wait-1',
|
|
68
|
+
status: 'PENDING',
|
|
69
|
+
expiresAt: new Date('2026-07-29T00:00:00.000Z'),
|
|
70
|
+
resolution: null,
|
|
71
|
+
resolvedAt: null,
|
|
72
|
+
...overrides,
|
|
73
|
+
};
|
|
74
|
+
const tx = {
|
|
75
|
+
externalInteraction: {
|
|
76
|
+
findUnique: jest.fn().mockResolvedValue(interaction),
|
|
77
|
+
updateMany: jest.fn().mockResolvedValue({ count: 1 }),
|
|
78
|
+
},
|
|
79
|
+
externalInteractionEvent: {
|
|
80
|
+
findUnique: jest.fn().mockResolvedValue(null),
|
|
81
|
+
create: jest.fn().mockImplementation(({ data }) => ({
|
|
82
|
+
id: BigInt(1),
|
|
83
|
+
...data,
|
|
84
|
+
})),
|
|
85
|
+
},
|
|
86
|
+
externalInteractionSignalOutbox: {
|
|
87
|
+
create: jest.fn().mockResolvedValue({ id: BigInt(1) }),
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
const prisma = {
|
|
91
|
+
$transaction: jest.fn((callback) => callback(tx)),
|
|
92
|
+
};
|
|
93
|
+
const registry = new ExternalInteractionHandlerRegistry();
|
|
94
|
+
registry.register(new ExternalWaitHandler());
|
|
95
|
+
const service = new ExternalInteractionService(
|
|
96
|
+
prisma as any,
|
|
97
|
+
registry,
|
|
98
|
+
() => now,
|
|
99
|
+
);
|
|
100
|
+
return { interaction, prisma, service, token, tx };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
it('resolves an external wait on the first allowed outcome', async () => {
|
|
104
|
+
const { service, token, tx } = setup();
|
|
105
|
+
|
|
106
|
+
await expect(
|
|
107
|
+
service.submitResult('tenant-a', {
|
|
108
|
+
callbackToken: token,
|
|
109
|
+
eventId: 'provider-1001',
|
|
110
|
+
outcome: 'SIGNED',
|
|
111
|
+
operatorId: 'alice',
|
|
112
|
+
data: { fileUrl: 'https://example.test/signed.pdf' },
|
|
113
|
+
}),
|
|
114
|
+
).resolves.toEqual({
|
|
115
|
+
accepted: true,
|
|
116
|
+
duplicate: false,
|
|
117
|
+
interactionStatus: 'RESOLVED',
|
|
118
|
+
resolvedOutcome: 'SIGNED',
|
|
119
|
+
});
|
|
120
|
+
expect(tx.externalInteraction.updateMany).toHaveBeenCalledWith(
|
|
121
|
+
expect.objectContaining({
|
|
122
|
+
where: { id: BigInt(41), status: 'PENDING' },
|
|
123
|
+
data: expect.objectContaining({ status: 'RESOLVED' }),
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
expect(tx.externalInteractionSignalOutbox.create).toHaveBeenCalledTimes(1);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('returns the original response for a duplicate event', async () => {
|
|
130
|
+
const original = {
|
|
131
|
+
accepted: true,
|
|
132
|
+
duplicate: false,
|
|
133
|
+
interactionStatus: 'PENDING',
|
|
134
|
+
};
|
|
135
|
+
const { service, token, tx } = setup();
|
|
136
|
+
tx.externalInteractionEvent.findUnique.mockResolvedValue({
|
|
137
|
+
response: original,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
await expect(
|
|
141
|
+
service.submitResult('tenant-a', {
|
|
142
|
+
callbackToken: token,
|
|
143
|
+
eventId: 'provider-1001',
|
|
144
|
+
outcome: 'SIGNED',
|
|
145
|
+
}),
|
|
146
|
+
).resolves.toEqual({ ...original, duplicate: true });
|
|
147
|
+
expect(tx.externalInteraction.updateMany).not.toHaveBeenCalled();
|
|
148
|
+
expect(tx.externalInteractionEvent.create).not.toHaveBeenCalled();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('records a rejected event without resolving for an unsupported outcome', async () => {
|
|
152
|
+
const { service, token, tx } = setup();
|
|
153
|
+
|
|
154
|
+
await expect(
|
|
155
|
+
service.submitResult('tenant-a', {
|
|
156
|
+
callbackToken: token,
|
|
157
|
+
eventId: 'provider-1002',
|
|
158
|
+
outcome: 'UNKNOWN',
|
|
159
|
+
}),
|
|
160
|
+
).resolves.toEqual({
|
|
161
|
+
accepted: false,
|
|
162
|
+
duplicate: false,
|
|
163
|
+
interactionStatus: 'PENDING',
|
|
164
|
+
errorCode: 'OUTCOME_NOT_ALLOWED',
|
|
165
|
+
message: '当前处理结果不在允许列表中',
|
|
166
|
+
});
|
|
167
|
+
expect(tx.externalInteraction.updateMany).not.toHaveBeenCalled();
|
|
168
|
+
expect(tx.externalInteractionEvent.create).toHaveBeenCalledWith({
|
|
169
|
+
data: expect.objectContaining({ processingStatus: 'REJECTED' }),
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('expires a pending interaction before accepting a late event', async () => {
|
|
174
|
+
const { service, token, tx } = setup({
|
|
175
|
+
expiresAt: new Date('2026-07-27T00:00:00.000Z'),
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
await expect(
|
|
179
|
+
service.submitResult('tenant-a', {
|
|
180
|
+
callbackToken: token,
|
|
181
|
+
eventId: 'provider-1003',
|
|
182
|
+
outcome: 'SIGNED',
|
|
183
|
+
}),
|
|
184
|
+
).resolves.toEqual({
|
|
185
|
+
accepted: false,
|
|
186
|
+
duplicate: false,
|
|
187
|
+
interactionStatus: 'EXPIRED',
|
|
188
|
+
errorCode: 'EXTERNAL_INTERACTION_EXPIRED',
|
|
189
|
+
message: '外部处理已过期',
|
|
190
|
+
});
|
|
191
|
+
expect(tx.externalInteraction.updateMany).toHaveBeenCalledWith({
|
|
192
|
+
where: { id: BigInt(41), status: 'PENDING' },
|
|
193
|
+
data: { status: 'EXPIRED', resolvedAt: now },
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('does not reveal whether a token belongs to another tenant', async () => {
|
|
198
|
+
const { service, token } = setup();
|
|
199
|
+
|
|
200
|
+
await expect(
|
|
201
|
+
service.submitResult('tenant-b', {
|
|
202
|
+
callbackToken: token,
|
|
203
|
+
eventId: 'provider-1004',
|
|
204
|
+
outcome: 'SIGNED',
|
|
205
|
+
}),
|
|
206
|
+
).rejects.toMatchObject({
|
|
207
|
+
response: {
|
|
208
|
+
code: 'EXTERNAL_INTERACTION_TOKEN_INVALID',
|
|
209
|
+
message: '回调凭证无效',
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('returns a concurrently resolved result instead of expiring it', async () => {
|
|
215
|
+
const { interaction, service, token, tx } = setup();
|
|
216
|
+
tx.externalInteraction.updateMany.mockResolvedValue({ count: 0 });
|
|
217
|
+
tx.externalInteraction.findUnique
|
|
218
|
+
.mockResolvedValueOnce(interaction)
|
|
219
|
+
.mockResolvedValueOnce({
|
|
220
|
+
...interaction,
|
|
221
|
+
status: 'RESOLVED',
|
|
222
|
+
resolution: {
|
|
223
|
+
outcome: 'SIGNED',
|
|
224
|
+
output: { outcome: 'SIGNED' },
|
|
225
|
+
completedAt: now.toISOString(),
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
await expect(service.expireInteraction('tenant-a', token)).resolves.toEqual(
|
|
230
|
+
{
|
|
231
|
+
status: 'RESOLVED',
|
|
232
|
+
resolution: {
|
|
233
|
+
outcome: 'SIGNED',
|
|
234
|
+
output: { outcome: 'SIGNED' },
|
|
235
|
+
completedAt: now.toISOString(),
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
ConflictException,
|
|
4
|
+
Inject,
|
|
5
|
+
Injectable,
|
|
6
|
+
Optional,
|
|
7
|
+
} from '@nestjs/common';
|
|
8
|
+
import { Prisma } from '@prisma/client';
|
|
9
|
+
import { PrismaService } from 'nestjs-prisma';
|
|
10
|
+
import { ExternalInteractionHandlerRegistry } from './external-interaction-handler.registry';
|
|
11
|
+
import {
|
|
12
|
+
createCallbackToken,
|
|
13
|
+
hashCallbackToken,
|
|
14
|
+
} from './external-interaction-token';
|
|
15
|
+
import {
|
|
16
|
+
CloseExternalInteractionResponse,
|
|
17
|
+
CreateExternalInteractionInput,
|
|
18
|
+
CreateExternalInteractionResponse,
|
|
19
|
+
ExternalHandlerResult,
|
|
20
|
+
ExternalInteractionRecord,
|
|
21
|
+
ExternalResultInput,
|
|
22
|
+
ExternalResultResponse,
|
|
23
|
+
} from './external-interaction.types';
|
|
24
|
+
|
|
25
|
+
export const EXTERNAL_INTERACTION_CLOCK = Symbol('EXTERNAL_INTERACTION_CLOCK');
|
|
26
|
+
|
|
27
|
+
@Injectable()
|
|
28
|
+
export class ExternalInteractionService {
|
|
29
|
+
private readonly currentTime: () => Date;
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
private readonly prisma: PrismaService,
|
|
33
|
+
private readonly handlers: ExternalInteractionHandlerRegistry,
|
|
34
|
+
@Optional()
|
|
35
|
+
@Inject(EXTERNAL_INTERACTION_CLOCK)
|
|
36
|
+
clock?: () => Date,
|
|
37
|
+
) {
|
|
38
|
+
this.currentTime = clock ?? (() => new Date());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
createInteraction(
|
|
42
|
+
input: CreateExternalInteractionInput,
|
|
43
|
+
): Promise<CreateExternalInteractionResponse> {
|
|
44
|
+
return this.prisma.$transaction((tx) =>
|
|
45
|
+
this.createInteractionInTransaction(input, tx),
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
createInteractionInTransaction(
|
|
50
|
+
input: CreateExternalInteractionInput,
|
|
51
|
+
tx: Pick<Prisma.TransactionClient, 'externalInteraction'>,
|
|
52
|
+
): Promise<CreateExternalInteractionResponse> {
|
|
53
|
+
this.handlers.get(input.handlerType);
|
|
54
|
+
const generated = input.callbackToken
|
|
55
|
+
? {
|
|
56
|
+
token: input.callbackToken,
|
|
57
|
+
tokenHash: hashCallbackToken(input.callbackToken),
|
|
58
|
+
}
|
|
59
|
+
: createCallbackToken();
|
|
60
|
+
const workflowInstanceId = parseId(input.workflowInstanceId);
|
|
61
|
+
const workflowVersionId = parseId(input.workflowVersionId);
|
|
62
|
+
const expiresAt = input.expiresAt ? new Date(input.expiresAt) : undefined;
|
|
63
|
+
if (expiresAt && !Number.isFinite(expiresAt.getTime())) {
|
|
64
|
+
throw new BadRequestException({
|
|
65
|
+
code: 'EXTERNAL_INTERACTION_INPUT_INVALID',
|
|
66
|
+
message: 'expiresAt 必须是有效时间',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (async () => {
|
|
71
|
+
const existing = await tx.externalInteraction.findUnique({
|
|
72
|
+
where: {
|
|
73
|
+
workflowInstanceId_nodeId: {
|
|
74
|
+
workflowInstanceId,
|
|
75
|
+
nodeId: input.nodeId,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
if (existing) {
|
|
80
|
+
if (existing.tokenHash !== generated.tokenHash) {
|
|
81
|
+
throw new ConflictException({
|
|
82
|
+
code: 'EXTERNAL_INTERACTION_TOKEN_CONFLICT',
|
|
83
|
+
message: '该等待节点已经创建了其他回调凭证',
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
interactionId: String(existing.id),
|
|
88
|
+
callbackToken: generated.token,
|
|
89
|
+
status: existing.status,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const interaction = await tx.externalInteraction.create({
|
|
94
|
+
data: {
|
|
95
|
+
tokenHash: generated.tokenHash,
|
|
96
|
+
tenantNamespace: input.tenantNamespace,
|
|
97
|
+
handlerType: input.handlerType,
|
|
98
|
+
handlerConfig: input.handlerConfig as Prisma.InputJsonValue,
|
|
99
|
+
workflowInstanceId,
|
|
100
|
+
workflowVersionId,
|
|
101
|
+
temporalRunId: input.temporalRunId,
|
|
102
|
+
nodeId: input.nodeId,
|
|
103
|
+
...(expiresAt && { expiresAt }),
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
interactionId: String(interaction.id),
|
|
108
|
+
callbackToken: generated.token,
|
|
109
|
+
status: interaction.status,
|
|
110
|
+
};
|
|
111
|
+
})();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
submitResult(
|
|
115
|
+
tenantNamespace: string,
|
|
116
|
+
input: ExternalResultInput,
|
|
117
|
+
): Promise<ExternalResultResponse> {
|
|
118
|
+
const tokenHash = hashCallbackToken(input.callbackToken);
|
|
119
|
+
return this.prisma.$transaction(async (tx) => {
|
|
120
|
+
await lockInteractionByToken(tx, tokenHash);
|
|
121
|
+
const interaction = await tx.externalInteraction.findUnique({
|
|
122
|
+
where: { tokenHash },
|
|
123
|
+
});
|
|
124
|
+
if (!interaction || interaction.tenantNamespace !== tenantNamespace) {
|
|
125
|
+
throw invalidToken();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const duplicate = await tx.externalInteractionEvent.findUnique({
|
|
129
|
+
where: {
|
|
130
|
+
interactionId_eventId: {
|
|
131
|
+
interactionId: interaction.id,
|
|
132
|
+
eventId: input.eventId,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
if (duplicate) {
|
|
137
|
+
return {
|
|
138
|
+
...(duplicate.response as unknown as ExternalResultResponse),
|
|
139
|
+
duplicate: true,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const now = this.currentTime();
|
|
144
|
+
if (
|
|
145
|
+
interaction.status === 'PENDING' &&
|
|
146
|
+
interaction.expiresAt &&
|
|
147
|
+
interaction.expiresAt.getTime() <= now.getTime()
|
|
148
|
+
) {
|
|
149
|
+
await tx.externalInteraction.updateMany({
|
|
150
|
+
where: { id: interaction.id, status: 'PENDING' },
|
|
151
|
+
data: { status: 'EXPIRED', resolvedAt: now },
|
|
152
|
+
});
|
|
153
|
+
return {
|
|
154
|
+
accepted: false,
|
|
155
|
+
duplicate: false,
|
|
156
|
+
interactionStatus: 'EXPIRED',
|
|
157
|
+
errorCode: 'EXTERNAL_INTERACTION_EXPIRED',
|
|
158
|
+
message: '外部处理已过期',
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (interaction.status !== 'PENDING') {
|
|
162
|
+
throw new ConflictException({
|
|
163
|
+
code: 'EXTERNAL_INTERACTION_CLOSED',
|
|
164
|
+
message: '外部处理已经结束',
|
|
165
|
+
status: interaction.status,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const handler = this.handlers.get(interaction.handlerType);
|
|
170
|
+
const result = await handler.handle(
|
|
171
|
+
interaction as ExternalInteractionRecord,
|
|
172
|
+
input,
|
|
173
|
+
tx,
|
|
174
|
+
);
|
|
175
|
+
const response = toResponse(result);
|
|
176
|
+
|
|
177
|
+
if (result.state === 'RESOLVED') {
|
|
178
|
+
const resolution = {
|
|
179
|
+
outcome: result.outcome,
|
|
180
|
+
...(result.output !== undefined && { output: result.output }),
|
|
181
|
+
completedAt: now.toISOString(),
|
|
182
|
+
};
|
|
183
|
+
const changed = await tx.externalInteraction.updateMany({
|
|
184
|
+
where: { id: interaction.id, status: 'PENDING' },
|
|
185
|
+
data: {
|
|
186
|
+
status: 'RESOLVED',
|
|
187
|
+
resolution: resolution as Prisma.InputJsonValue,
|
|
188
|
+
resolvedAt: now,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
if (changed.count !== 1) {
|
|
192
|
+
throw new ConflictException({
|
|
193
|
+
code: 'EXTERNAL_INTERACTION_STATE_CONFLICT',
|
|
194
|
+
message: '外部处理状态已经发生变化',
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
await tx.externalInteractionSignalOutbox.create({
|
|
198
|
+
data: {
|
|
199
|
+
interactionId: interaction.id,
|
|
200
|
+
idempotencyKey: `external-interaction:${interaction.id}:resolved`,
|
|
201
|
+
signalName: result.signal?.name ?? 'externalInteractionResolved',
|
|
202
|
+
payload: (result.signal?.payload ?? {
|
|
203
|
+
nodeId: interaction.nodeId,
|
|
204
|
+
outcome: result.outcome,
|
|
205
|
+
...(input.operatorId && { operatorId: input.operatorId }),
|
|
206
|
+
...(input.data && { data: input.data }),
|
|
207
|
+
completedAt: now.toISOString(),
|
|
208
|
+
}) as Prisma.InputJsonValue,
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
await tx.externalInteractionEvent.create({
|
|
214
|
+
data: {
|
|
215
|
+
interactionId: interaction.id,
|
|
216
|
+
eventId: input.eventId,
|
|
217
|
+
outcome: input.outcome,
|
|
218
|
+
...(input.operatorId && { operatorId: input.operatorId }),
|
|
219
|
+
...(input.data && {
|
|
220
|
+
data: input.data as Prisma.InputJsonValue,
|
|
221
|
+
}),
|
|
222
|
+
processingStatus:
|
|
223
|
+
result.state === 'REJECTED' ? 'REJECTED' : 'ACCEPTED',
|
|
224
|
+
response: response as unknown as Prisma.InputJsonValue,
|
|
225
|
+
...(result.errorCode && { errorCode: result.errorCode }),
|
|
226
|
+
...(result.errorMessage && {
|
|
227
|
+
errorMessage: result.errorMessage,
|
|
228
|
+
}),
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
return response;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
expireInteraction(
|
|
236
|
+
tenantNamespace: string,
|
|
237
|
+
callbackToken: string,
|
|
238
|
+
): Promise<CloseExternalInteractionResponse> {
|
|
239
|
+
return this.closeInteraction(tenantNamespace, callbackToken, 'EXPIRED');
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
cancelInteraction(
|
|
243
|
+
tenantNamespace: string,
|
|
244
|
+
callbackToken: string,
|
|
245
|
+
): Promise<CloseExternalInteractionResponse> {
|
|
246
|
+
return this.closeInteraction(tenantNamespace, callbackToken, 'CANCELLED');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private closeInteraction(
|
|
250
|
+
tenantNamespace: string,
|
|
251
|
+
callbackToken: string,
|
|
252
|
+
target: 'EXPIRED' | 'CANCELLED',
|
|
253
|
+
): Promise<CloseExternalInteractionResponse> {
|
|
254
|
+
const tokenHash = hashCallbackToken(callbackToken);
|
|
255
|
+
return this.prisma.$transaction(async (tx) => {
|
|
256
|
+
await lockInteractionByToken(tx, tokenHash);
|
|
257
|
+
const interaction = await tx.externalInteraction.findUnique({
|
|
258
|
+
where: { tokenHash },
|
|
259
|
+
});
|
|
260
|
+
if (!interaction || interaction.tenantNamespace !== tenantNamespace) {
|
|
261
|
+
throw invalidToken();
|
|
262
|
+
}
|
|
263
|
+
if (interaction.status === 'PENDING') {
|
|
264
|
+
const changed = await tx.externalInteraction.updateMany({
|
|
265
|
+
where: { id: interaction.id, status: 'PENDING' },
|
|
266
|
+
data: { status: target, resolvedAt: this.currentTime() },
|
|
267
|
+
});
|
|
268
|
+
if (changed.count === 1) return { status: target };
|
|
269
|
+
}
|
|
270
|
+
const current = await tx.externalInteraction.findUnique({
|
|
271
|
+
where: { id: interaction.id },
|
|
272
|
+
});
|
|
273
|
+
if (!current) throw invalidToken();
|
|
274
|
+
return {
|
|
275
|
+
status: current.status,
|
|
276
|
+
...(current.resolution && {
|
|
277
|
+
resolution: current.resolution as unknown as {
|
|
278
|
+
outcome: string;
|
|
279
|
+
output?: unknown;
|
|
280
|
+
completedAt?: string;
|
|
281
|
+
},
|
|
282
|
+
}),
|
|
283
|
+
};
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function toResponse(result: ExternalHandlerResult): ExternalResultResponse {
|
|
289
|
+
if (result.state === 'REJECTED') {
|
|
290
|
+
return {
|
|
291
|
+
accepted: false,
|
|
292
|
+
duplicate: false,
|
|
293
|
+
interactionStatus: 'PENDING',
|
|
294
|
+
errorCode: result.errorCode,
|
|
295
|
+
message: result.errorMessage,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
if (result.state === 'PENDING') {
|
|
299
|
+
return {
|
|
300
|
+
accepted: true,
|
|
301
|
+
duplicate: false,
|
|
302
|
+
interactionStatus: 'PENDING',
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
accepted: true,
|
|
307
|
+
duplicate: false,
|
|
308
|
+
interactionStatus: 'RESOLVED',
|
|
309
|
+
resolvedOutcome: result.outcome,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function invalidToken(): BadRequestException {
|
|
314
|
+
return new BadRequestException({
|
|
315
|
+
code: 'EXTERNAL_INTERACTION_TOKEN_INVALID',
|
|
316
|
+
message: '回调凭证无效',
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function parseId(value: string): bigint {
|
|
321
|
+
if (!/^[1-9][0-9]*$/.test(value)) {
|
|
322
|
+
throw new BadRequestException({
|
|
323
|
+
code: 'EXTERNAL_INTERACTION_INPUT_INVALID',
|
|
324
|
+
message: 'Workflow IDs 必须是正整数',
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
return BigInt(value);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
async function lockInteractionByToken(
|
|
331
|
+
tx: Prisma.TransactionClient,
|
|
332
|
+
tokenHash: string,
|
|
333
|
+
): Promise<void> {
|
|
334
|
+
if (typeof (tx as any).$queryRawUnsafe !== 'function') return;
|
|
335
|
+
await (tx as any).$queryRawUnsafe(
|
|
336
|
+
'SELECT id FROM t_external_interaction WHERE token_hash = $1 FOR UPDATE',
|
|
337
|
+
tokenHash,
|
|
338
|
+
);
|
|
339
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export type ExternalInteractionStatus =
|
|
2
|
+
| 'PENDING'
|
|
3
|
+
| 'RESOLVED'
|
|
4
|
+
| 'CANCELLED'
|
|
5
|
+
| 'EXPIRED';
|
|
6
|
+
|
|
7
|
+
export interface ExternalResultInput {
|
|
8
|
+
callbackToken: string;
|
|
9
|
+
eventId: string;
|
|
10
|
+
outcome: string;
|
|
11
|
+
operatorId?: string;
|
|
12
|
+
data?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ExternalResultResponse {
|
|
16
|
+
accepted: boolean;
|
|
17
|
+
duplicate: boolean;
|
|
18
|
+
interactionStatus: ExternalInteractionStatus;
|
|
19
|
+
resolvedOutcome?: string;
|
|
20
|
+
errorCode?: string;
|
|
21
|
+
message?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface CreateExternalInteractionInput {
|
|
25
|
+
callbackToken?: string;
|
|
26
|
+
tenantNamespace: string;
|
|
27
|
+
handlerType: string;
|
|
28
|
+
handlerConfig: Record<string, unknown>;
|
|
29
|
+
workflowInstanceId: string;
|
|
30
|
+
workflowVersionId: string;
|
|
31
|
+
temporalRunId: string;
|
|
32
|
+
nodeId: string;
|
|
33
|
+
expiresAt?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface CreateExternalInteractionResponse {
|
|
37
|
+
interactionId: string;
|
|
38
|
+
callbackToken: string;
|
|
39
|
+
status: ExternalInteractionStatus;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface CloseExternalInteractionResponse {
|
|
43
|
+
status: ExternalInteractionStatus;
|
|
44
|
+
resolution?: {
|
|
45
|
+
outcome: string;
|
|
46
|
+
output?: unknown;
|
|
47
|
+
completedAt?: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ExternalInteractionRecord {
|
|
52
|
+
id: bigint;
|
|
53
|
+
tenantNamespace: string;
|
|
54
|
+
handlerType: string;
|
|
55
|
+
handlerConfig: unknown;
|
|
56
|
+
workflowInstanceId: bigint;
|
|
57
|
+
workflowVersionId: bigint;
|
|
58
|
+
temporalRunId: string;
|
|
59
|
+
nodeId: string;
|
|
60
|
+
status: ExternalInteractionStatus;
|
|
61
|
+
expiresAt: Date | null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ExternalHandlerResult {
|
|
65
|
+
state: 'PENDING' | 'RESOLVED' | 'REJECTED';
|
|
66
|
+
outcome?: string;
|
|
67
|
+
output?: unknown;
|
|
68
|
+
errorCode?: string;
|
|
69
|
+
errorMessage?: string;
|
|
70
|
+
signal?: {
|
|
71
|
+
name: string;
|
|
72
|
+
payload: Record<string, unknown>;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { ExternalInteractionHandler } from './external-interaction-handler';
|
|
3
|
+
import {
|
|
4
|
+
ExternalHandlerResult,
|
|
5
|
+
ExternalInteractionRecord,
|
|
6
|
+
ExternalResultInput,
|
|
7
|
+
} from './external-interaction.types';
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class ExternalWaitHandler implements ExternalInteractionHandler {
|
|
11
|
+
readonly type = 'EXTERNAL_WAIT';
|
|
12
|
+
|
|
13
|
+
handle(
|
|
14
|
+
interaction: ExternalInteractionRecord,
|
|
15
|
+
event: ExternalResultInput,
|
|
16
|
+
): ExternalHandlerResult {
|
|
17
|
+
const config = asObject(interaction.handlerConfig);
|
|
18
|
+
const allowedOutcomes = Array.isArray(config.allowedOutcomes)
|
|
19
|
+
? config.allowedOutcomes.filter(
|
|
20
|
+
(value): value is string =>
|
|
21
|
+
typeof value === 'string' && Boolean(value.trim()),
|
|
22
|
+
)
|
|
23
|
+
: [];
|
|
24
|
+
if (!allowedOutcomes.includes(event.outcome)) {
|
|
25
|
+
return {
|
|
26
|
+
state: 'REJECTED',
|
|
27
|
+
errorCode: 'OUTCOME_NOT_ALLOWED',
|
|
28
|
+
errorMessage: '当前处理结果不在允许列表中',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
state: 'RESOLVED',
|
|
33
|
+
outcome: event.outcome,
|
|
34
|
+
output: {
|
|
35
|
+
outcome: event.outcome,
|
|
36
|
+
...(event.operatorId && { operatorId: event.operatorId }),
|
|
37
|
+
...(event.data && { data: event.data }),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function asObject(value: unknown): Record<string, unknown> {
|
|
44
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
45
|
+
? (value as Record<string, unknown>)
|
|
46
|
+
: {};
|
|
47
|
+
}
|