@gadmin2n/schematics 0.0.142 → 0.0.144

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/workflow.prisma +5 -23
  2. package/dist/lib/application/files/gadmin2-game-angle-demo/server/scripts/lib/page-helpers.ts +4 -2
  3. package/dist/lib/application/files/gadmin2-game-angle-demo/server/scripts/page-manage.ts +36 -1
  4. package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/agenda.seed.ts +14 -14
  5. package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/bootstrap.ts +18 -13
  6. package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/canvas.seed.ts +14 -14
  7. package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/index.ts +1 -1
  8. package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/workflow-node-types.ts +67 -404
  9. package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/workflow.seed.ts +16 -40
  10. package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/workflows.ts +12 -124
  11. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/app.module.ts +3 -0
  12. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/config/index.ts +0 -21
  13. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/codeRuntime/code-runtime.controller.ts +3 -10
  14. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/codeRuntime/codeRuntime.module.ts +1 -2
  15. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-callback.controller.spec.ts +48 -0
  16. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-callback.controller.ts +96 -0
  17. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-runtime.controller.spec.ts +1 -59
  18. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-runtime.controller.ts +8 -43
  19. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction-runtime.dto.ts +0 -23
  20. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-interaction.service.ts +2 -0
  21. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/external-wait.handler.ts +2 -0
  22. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/externalInteraction.module.ts +7 -3
  23. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/workflow-callback-url.controller.ts +2 -2
  24. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/workflow-callback-url.service.spec.ts +18 -123
  25. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/externalInteraction/workflow-callback-url.service.ts +4 -0
  26. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/httpRequest/http-request-runtime.controller.ts +3 -10
  27. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/httpRequest/httpRequest.module.ts +1 -2
  28. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.controller.ts +0 -10
  29. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.dto.ts +12 -4
  30. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.errors.ts +1 -1
  31. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.external-decision.spec.ts +42 -209
  32. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/human-approval.service.ts +108 -225
  33. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/humanApproval.module.ts +0 -2
  34. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/runtime/human-approval-runtime.controller.ts +27 -22
  35. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/runtime/human-approval-runtime.dto.ts +9 -1
  36. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/runtime/runtime-token.guard.spec.ts +30 -0
  37. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/humanApproval/runtime/runtime-token.guard.ts +8 -15
  38. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/index.ts +0 -2
  39. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/temporalTenantConfig/runtime-connectivity-probe.service.spec.ts +14 -0
  40. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/temporalTenantConfig/runtime-connectivity-probe.service.ts +37 -0
  41. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/temporalTenantConfig/temporalTenantConfig.controller.spec.ts +41 -0
  42. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/temporalTenantConfig/temporalTenantConfig.controller.ts +53 -0
  43. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/temporalTenantConfig/temporalTenantConfig.module.ts +7 -2
  44. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/temporalTenantConfig/workflow-runtime-health.controller.ts +21 -0
  45. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/dsl-validate.util.spec.ts +2 -2
  46. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-callable.spec.ts +16 -88
  47. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-callable.ts +23 -59
  48. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-compiler.service.spec.ts +125 -39
  49. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-compiler.service.ts +95 -28
  50. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-handle-validator.ts +0 -20
  51. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-http-response.spec.ts +23 -26
  52. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow-http-response.ts +6 -52
  53. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.controller.ts +2 -2
  54. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.service.spec.ts +24 -0
  55. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflow/workflow.service.ts +26 -21
  56. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/widget-catalog.service.spec.ts +0 -1
  57. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowConfig/widget-catalog.service.ts +0 -1
  58. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowRuntimeConfig/workflow-runtime-config.service.spec.ts +32 -0
  59. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowRuntimeConfig/workflow-runtime-config.service.ts +41 -0
  60. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/workflowRuntimeConfig/workflowRuntimeConfig.module.ts +10 -0
  61. package/dist/lib/application/files/gadmin2-game-angle-demo/server/tsconfig.build.json +10 -1
  62. package/dist/lib/application/files/gadmin2-game-angle-demo/temporal/README.md +16 -12
  63. package/dist/lib/application/files/gadmin2-game-angle-demo/web/package.json +1 -1
  64. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/PageHeader.tsx +1 -1
  65. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/inspectorActions.ts +19 -19
  66. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/contexts/color-mode/index.tsx +1 -1
  67. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/header.tsx +15 -11
  68. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/config/routeRegistry.tsx +0 -6
  69. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/AddDataModal.tsx +3 -3
  70. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/AddPageModal.tsx +1 -1
  71. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/DeleteDataConfirm.tsx +1 -1
  72. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/EditDataModal.tsx +1 -1
  73. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useDynamicResources.tsx +1 -0
  74. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/locales/en/workflow.json +85 -95
  75. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/locales/zh_CN/workflow.json +85 -95
  76. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agenda/index.tsx +2 -2
  77. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/agendaJob/list.tsx +21 -2
  78. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/game/list.tsx +21 -2
  79. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/human-approval/inbox.tsx +14 -66
  80. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/list.tsx +4 -4
  81. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/list.tsx +3 -3
  82. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/list.tsx +3 -3
  83. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/CustomNode.test.tsx +29 -0
  84. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/CustomNode.tsx +4 -2
  85. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/EnhancedFlowRenderer.tsx +4 -6
  86. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ExecutionStatusNode.test.tsx +3 -0
  87. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/ExecutionStatusNode.tsx +3 -1
  88. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/FlowRenderer.tsx +4 -6
  89. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NewNodeDefaults.test.tsx +23 -92
  90. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodeOutputSummary.tsx +200 -0
  91. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodePropertyPanel.test.tsx +61 -136
  92. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodePropertyPanel.tsx +96 -195
  93. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/components/NodeTypeBadge.tsx +36 -0
  94. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/components/CreateNodeInstanceModal.tsx +5 -10
  95. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/components/NodeInstanceForm.tsx +47 -22
  96. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/create.tsx +7 -5
  97. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/edit.tsx +8 -6
  98. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/node-config.css +35 -0
  99. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/schema-form/default-widgets.tsx +1 -6
  100. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ApproverSourceEditor.tsx +1 -4
  101. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/CodeConfigEditor.tsx +1 -1
  102. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ExternalRequestConfigEditor.tsx +1 -1
  103. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ExternalWaitConfigEditor.tsx +82 -259
  104. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/HttpRequestConfigEditor.tsx +1 -2
  105. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/HumanApprovalConfigEditor.test.tsx +7 -6
  106. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/HumanApprovalConfigEditor.tsx +77 -71
  107. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ReturnResultConfigEditor.test.tsx +10 -57
  108. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ReturnResultConfigEditor.tsx +8 -273
  109. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/temporal-tenant/index.test.tsx +54 -0
  110. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/temporal-tenant/index.tsx +110 -20
  111. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/newNodeConfig.ts +4 -34
  112. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveOutputs.test.ts +3 -10
  113. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/utils/resolveOutputs.ts +2 -37
  114. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflowEventOutbox/list.tsx +26 -2
  115. package/package.json +1 -1
  116. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/approvalChannel/approval-channel.controller.ts +0 -89
  117. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/approvalChannel/approval-channel.dto.ts +0 -68
  118. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/approvalChannel/approval-channel.service.spec.ts +0 -177
  119. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/approvalChannel/approval-channel.service.ts +0 -283
  120. package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/approvalChannel/approvalChannel.module.ts +0 -10
  121. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/approval-channels/ApprovalChannelModal.test.tsx +0 -84
  122. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/approval-channels/ApprovalChannelModal.tsx +0 -141
  123. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/approval-channels/approval-channel.types.ts +0 -16
  124. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/approval-channels/index.tsx +0 -210
  125. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/ApprovalRequestTriggerConfigEditor.tsx +0 -39
  126. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/SubmitApprovalResultConfigEditor.tsx +0 -104
  127. package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/workflow/node-instances/widgets/SubmitExternalResultConfigEditor.tsx +0 -98
  128. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/{Components → components}/AssignRolesModal.tsx +0 -0
  129. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/{Components → components}/CreatePageModal.tsx +0 -0
  130. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/{Components → components}/EditPageModal.tsx +0 -0
  131. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/{Components → components}/PageDetailDrawer.tsx +0 -0
  132. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/{Components → components}/PageFormModal.tsx +0 -0
  133. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/{Components → components}/CreateModal.tsx +0 -0
  134. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/{Components → components}/EditModal.tsx +0 -0
  135. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/{Components → components}/ResourceDetailDrawer.tsx +0 -0
  136. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/{Components → components}/modal.tsx +0 -0
  137. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/{Components → components}/CreateModal.tsx +0 -0
  138. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/{Components → components}/EditModal.tsx +0 -0
  139. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/{Components → components}/RoleDetailDrawer.tsx +0 -0
  140. /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/{Components → components}/modal.tsx +0 -0
@@ -7,7 +7,7 @@ describe('HumanApprovalService external decisions', () => {
7
7
  workflowInstanceId: BigInt(7),
8
8
  nodeId: 'approval-1',
9
9
  status: 'PENDING',
10
- configSnapshot: { channelRef: 'external-main' },
10
+ configSnapshot: { approvalWorkflowId: '11' },
11
11
  approvalRule: { mode: 'ANY' },
12
12
  rejectionRule: { mode: 'ANY' },
13
13
  candidates: [
@@ -37,9 +37,6 @@ describe('HumanApprovalService external decisions', () => {
37
37
  approvalSignalOutbox: {
38
38
  upsert: jest.fn().mockResolvedValue({ id: BigInt(201) }),
39
39
  },
40
- workflowEventOutbox: {
41
- create: jest.fn().mockResolvedValue({ id: BigInt(301) }),
42
- },
43
40
  };
44
41
  const prisma = {
45
42
  $transaction: jest.fn((callback) => callback(tx)),
@@ -47,15 +44,11 @@ describe('HumanApprovalService external decisions', () => {
47
44
  findUnique: jest.fn().mockResolvedValue(null),
48
45
  findUniqueOrThrow: jest.fn(),
49
46
  },
50
- approvalChannel: {
51
- findUnique: jest.fn().mockResolvedValue({ isEnabled: true }),
52
- },
53
- workflowEventOutbox: {
54
- findFirst: jest.fn(),
55
- create: jest.fn(),
56
- },
57
- workflowInstance: {
58
- findFirst: jest.fn(),
47
+ workflow: {
48
+ findUnique: jest.fn().mockResolvedValue({
49
+ isEnabled: true,
50
+ status: 'PUBLISHED',
51
+ }),
59
52
  },
60
53
  };
61
54
  const providers = {
@@ -79,9 +72,9 @@ describe('HumanApprovalService external decisions', () => {
79
72
  jest.clearAllMocks();
80
73
  });
81
74
 
82
- it('maps a provider callback to the configured approval candidate', async () => {
75
+ it('maps a returned Workflow result to the configured approval candidate', async () => {
83
76
  await service.submitExternalDecision(BigInt(41), {
84
- channelRef: 'external-main',
77
+ approvalWorkflowId: '11',
85
78
  eventId: 'myoa:workitem:123',
86
79
  approverId: 'alice',
87
80
  decision: 'APPROVE',
@@ -93,96 +86,32 @@ describe('HumanApprovalService external decisions', () => {
93
86
  requestId: BigInt(41),
94
87
  candidateId: BigInt(91),
95
88
  decision: 'APPROVE',
96
- creator: 'external:external-main:alice',
89
+ creator: 'external:11:alice',
97
90
  payload: {
98
91
  sourceStatus: 200,
99
92
  externalEventId: 'myoa:workitem:123',
100
- approvalChannel: 'external-main',
93
+ approvalWorkflowId: '11',
101
94
  },
102
95
  }),
103
96
  });
104
97
  expect(tx.approvalSignalOutbox.upsert).toHaveBeenCalled();
105
98
  });
106
99
 
107
- it('rejects a callback from a channel not selected by the AP node', async () => {
100
+ it('rejects a result from a Workflow not selected by the approval node', async () => {
108
101
  await expect(
109
102
  service.submitExternalDecision(BigInt(41), {
110
- channelRef: 'somewhere-else',
103
+ approvalWorkflowId: '12',
111
104
  eventId: 'event-2',
112
105
  approverId: 'alice',
113
106
  decision: 'APPROVE',
114
107
  }),
115
108
  ).rejects.toMatchObject({
116
- response: { code: 'APPROVAL_CHANNEL_MISMATCH' },
109
+ response: { code: 'APPROVAL_WORKFLOW_MISMATCH' },
117
110
  });
118
111
  expect(tx.approvalDecision.create).not.toHaveBeenCalled();
119
112
  });
120
113
 
121
- it('separates resolved AP arguments from system-provided dispatch data', async () => {
122
- const configSnapshot = {
123
- channelRef: 'external-main',
124
- subjects: [
125
- { source: 'STATIC' as const, provider: 'USER', refs: ['alice'] },
126
- ],
127
- approvalRule: { mode: 'ANY' as const },
128
- rejectionRule: { mode: 'ANY' as const },
129
- timeout: { durationSeconds: 0, action: 'REJECTED' as const },
130
- };
131
-
132
- await service.startRequest(
133
- {
134
- workflowInstanceId: '7',
135
- workflowVersionId: '3',
136
- nodeId: 'approval-1',
137
- configHash: hashNodeInstanceConfig(configSnapshot),
138
- configSnapshot,
139
- dynamicInputs: { orderId: 'SO-1001' },
140
- channelInputs: {
141
- title: '服务器权限申请',
142
- content: { orderId: 'SO-1001' },
143
- channelRef: 'business-value-is-allowed',
144
- },
145
- },
146
- { userId: 'runtime:default' },
147
- );
148
-
149
- expect(tx.workflowEventOutbox.create).toHaveBeenCalledWith({
150
- data: {
151
- eventName: 'approval.requested.external-main',
152
- payload: {
153
- workflow: {
154
- title: '服务器权限申请',
155
- content: { orderId: 'SO-1001' },
156
- channelRef: 'business-value-is-allowed',
157
- },
158
- system: {
159
- approval: {
160
- channel: 'external-main',
161
- requestId: '42',
162
- candidates: [
163
- {
164
- approverId: 'alice',
165
- displayName: 'Alice',
166
- principalType: 'USER',
167
- },
168
- ],
169
- expiresAt: null,
170
- },
171
- caller: {
172
- workflowInstanceId: '7',
173
- workflowVersionId: '3',
174
- nodeId: 'approval-1',
175
- },
176
- invocation: {
177
- id: 'approval:42:external-main',
178
- },
179
- },
180
- },
181
- },
182
- });
183
- });
184
-
185
- it('adds a generic callback token to a new external approval dispatch', async () => {
114
+ it('starts the selected approval Workflow with business and system inputs', async () => {
186
115
  const externalInteractions = {
187
116
  createInteractionInTransaction: jest.fn().mockResolvedValue({
188
117
  interactionId: '51',
@@ -196,155 +125,59 @@ describe('HumanApprovalService external decisions', () => {
196
125
  externalInteractions as any,
197
126
  );
198
127
  const configSnapshot = {
199
- channelRef: 'external-main',
128
+ approvalWorkflowId: '11',
200
129
  subjects: [
201
130
  { source: 'STATIC' as const, provider: 'USER', refs: ['alice'] },
202
131
  ],
203
132
  approvalRule: { mode: 'ANY' as const },
204
133
  rejectionRule: { mode: 'ANY' as const },
205
- timeout: { durationSeconds: 3600, action: 'REJECTED' as const },
134
+ timeout: { durationSeconds: 0, action: 'REJECTED' as const },
206
135
  };
207
136
 
208
- await integratedService.startRequest(
137
+ const result = await integratedService.startRequest(
209
138
  {
210
139
  workflowInstanceId: '7',
211
140
  workflowVersionId: '3',
212
141
  tenantNamespace: 'tenant-a',
213
142
  temporalRunId: 'wf-7',
143
+ approvalWorkflowRunId: 'wf-approval-7-approval-1',
144
+ callbackToken: 'ext_cb_approval',
214
145
  nodeId: 'approval-1',
215
146
  configHash: hashNodeInstanceConfig(configSnapshot),
216
147
  configSnapshot,
148
+ dynamicInputs: { orderId: 'SO-1001' },
149
+ approvalWorkflowInputs: {
150
+ title: '服务器权限申请',
151
+ content: { orderId: 'SO-1001' },
152
+ },
217
153
  },
218
- { userId: 'runtime:tenant-a' },
154
+ { userId: 'runtime:default' },
219
155
  );
220
156
 
157
+ expect(result).toMatchObject({
158
+ approvalWorkflowInvocation: {
159
+ workflowId: '11',
160
+ workflow: {
161
+ title: '服务器权限申请',
162
+ content: { orderId: 'SO-1001' },
163
+ requestId: '42',
164
+ callbackToken: 'ext_cb_approval',
165
+ expiresAt: null,
166
+ candidates: [expect.objectContaining({ approverId: 'alice' })],
167
+ },
168
+ },
169
+ });
221
170
  expect(
222
171
  externalInteractions.createInteractionInTransaction,
223
172
  ).toHaveBeenCalledWith(
224
173
  expect.objectContaining({
225
- handlerType: 'HUMAN_APPROVAL',
226
- temporalRunId: 'wf-7',
174
+ callbackToken: 'ext_cb_approval',
175
+ handlerType: 'EXTERNAL_WAIT',
176
+ handlerConfig: { allowedOutcomes: ['RECEIVED'] },
177
+ temporalRunId: 'wf-approval-7-approval-1',
227
178
  nodeId: 'approval-1',
228
179
  }),
229
180
  tx,
230
181
  );
231
- expect(tx.workflowEventOutbox.create).toHaveBeenCalledWith({
232
- data: expect.objectContaining({
233
- payload: expect.objectContaining({
234
- workflow: {},
235
- system: expect.objectContaining({
236
- callback: { token: 'ext_cb_approval' },
237
- approval: expect.objectContaining({
238
- requestId: '42',
239
- channel: 'external-main',
240
- }),
241
- }),
242
- }),
243
- }),
244
- });
245
- });
246
-
247
- it('merges automatic approver results with fixed approvers', async () => {
248
- const configSnapshot = {
249
- subjects: [
250
- { source: 'STATIC' as const, provider: 'USER', refs: ['alice'] },
251
- ],
252
- approvalRule: { mode: 'ANY' as const },
253
- rejectionRule: { mode: 'ANY' as const },
254
- timeout: { durationSeconds: 0, action: 'REJECTED' as const },
255
- };
256
-
257
- await service.startRequest(
258
- {
259
- workflowInstanceId: '8',
260
- workflowVersionId: '3',
261
- nodeId: 'approval-2',
262
- configHash: hashNodeInstanceConfig(configSnapshot),
263
- configSnapshot,
264
- resolvedSubjects: [
265
- { provider: 'USER_GROUP', refs: ['finance-managers'] },
266
- ],
267
- },
268
- { userId: 'runtime:default' },
269
- );
270
-
271
- expect(providers.get).toHaveBeenCalledWith('USER');
272
- expect(providers.get).toHaveBeenCalledWith('USER_GROUP');
273
- });
274
-
275
- it('reports a failed dispatch without closing the approval request', async () => {
276
- prisma.approvalRequest.findUniqueOrThrow.mockResolvedValue({
277
- ...request,
278
- configSnapshot: { channelRef: 'external-main' },
279
- blockedReason: null,
280
- startedAt: new Date('2026-07-24T00:00:00.000Z'),
281
- expiresAt: null,
282
- completedAt: null,
283
- updatedAt: new Date('2026-07-24T00:01:00.000Z'),
284
- });
285
- prisma.workflowEventOutbox.findFirst.mockResolvedValue({
286
- id: BigInt(301),
287
- processed: true,
288
- lastError: null,
289
- payload: {
290
- requestId: '41',
291
- channelRef: 'external-main',
292
- dispatchKey: 'approval:41:external-main',
293
- },
294
- });
295
- prisma.workflowInstance.findFirst.mockResolvedValue({
296
- status: 'FAILED',
297
- result: { error: 'OA is unavailable' },
298
- });
299
-
300
- await expect(service.status(BigInt(41))).resolves.toMatchObject({
301
- id: BigInt(41),
302
- status: 'PENDING',
303
- dispatch: {
304
- state: 'DISPATCH_FAILED',
305
- canRetry: true,
306
- error: 'OA is unavailable',
307
- },
308
- });
309
- });
310
-
311
- it('retries a failed dispatch with the same idempotency key', async () => {
312
- prisma.approvalRequest.findUnique.mockResolvedValueOnce({
313
- ...request,
314
- configSnapshot: { channelRef: 'external-main' },
315
- });
316
- prisma.workflowEventOutbox.findFirst.mockResolvedValue({
317
- id: BigInt(301),
318
- eventName: 'approval.requested.external-main',
319
- processed: true,
320
- lastError: null,
321
- payload: {
322
- requestId: '41',
323
- channelRef: 'external-main',
324
- dispatchKey: 'approval:41:external-main',
325
- businessData: { orderId: 'SO-1001' },
326
- },
327
- });
328
- prisma.workflowInstance.findFirst.mockResolvedValue({
329
- status: 'FAILED',
330
- result: { error: 'OA is unavailable' },
331
- });
332
- prisma.workflowEventOutbox.create.mockResolvedValue({
333
- id: BigInt(302),
334
- });
335
-
336
- await service.retryDispatch(BigInt(41));
337
-
338
- expect(prisma.workflowEventOutbox.create).toHaveBeenCalledWith({
339
- data: {
340
- eventName: 'approval.requested.external-main',
341
- payload: {
342
- requestId: '41',
343
- channelRef: 'external-main',
344
- dispatchKey: 'approval:41:external-main',
345
- businessData: { orderId: 'SO-1001' },
346
- },
347
- },
348
- });
349
182
  });
350
183
  });