-
Notifications
You must be signed in to change notification settings - Fork 128
3894 client - Update WorkflowNodeDetailsPanel to support variableOutputResponse when retrieving output schema #3951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a15f4a7
0 Update spring boot to 4.0.2
ivicac c7a1468
3894 client - Update `WorkflowNodeDetailsPanel` to support `variableO…
ivicac 5bb3770
3894 client - client - Add unit tests for `getOutputSchemaFromWorkflo…
ivicac d07c5f5
3894 client - Remove JSDoc comment from getOutputSchemaFromWorkflowNo…
ivicac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
...nt/src/pages/platform/workflow-editor/utils/getOutputSchemaFromWorkflowNodeOutput.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| import {WorkflowNodeOutput} from '@/shared/middleware/platform/configuration'; | ||
| import {PropertyAllType} from '@/shared/types'; | ||
| import {describe, expect, test} from 'vitest'; | ||
|
|
||
| import getOutputSchemaFromWorkflowNodeOutput from './getOutputSchemaFromWorkflowNodeOutput'; | ||
|
|
||
| describe('getOutputSchemaFromWorkflowNodeOutput', () => { | ||
| const mockOutputSchema: PropertyAllType = { | ||
| name: 'testOutput', | ||
| type: 'OBJECT', | ||
| }; | ||
|
|
||
| const mockVariableOutputSchema: PropertyAllType = { | ||
| name: 'variableOutput', | ||
| properties: [ | ||
| {name: 'item', type: 'OBJECT'}, | ||
| {name: 'index', type: 'INTEGER'}, | ||
| ], | ||
| type: 'OBJECT', | ||
| }; | ||
|
|
||
| test('returns undefined when workflowNodeOutput is undefined', () => { | ||
| const result = getOutputSchemaFromWorkflowNodeOutput(undefined); | ||
|
|
||
| expect(result).toBeUndefined(); | ||
| }); | ||
|
|
||
| test('returns outputResponse.outputSchema when available', () => { | ||
| const workflowNodeOutput: WorkflowNodeOutput = { | ||
| outputResponse: { | ||
| outputSchema: mockOutputSchema, | ||
| }, | ||
| workflowNodeName: 'action_1', | ||
| }; | ||
|
|
||
| const result = getOutputSchemaFromWorkflowNodeOutput(workflowNodeOutput); | ||
|
|
||
| expect(result).toBe(mockOutputSchema); | ||
| }); | ||
|
|
||
| test('returns variableOutputResponse.outputSchema when outputResponse is not available', () => { | ||
| const workflowNodeOutput: WorkflowNodeOutput = { | ||
| variableOutputResponse: { | ||
| outputSchema: mockVariableOutputSchema, | ||
| }, | ||
| workflowNodeName: 'loop_1', | ||
| }; | ||
|
|
||
| const result = getOutputSchemaFromWorkflowNodeOutput(workflowNodeOutput); | ||
|
|
||
| expect(result).toBe(mockVariableOutputSchema); | ||
| }); | ||
|
|
||
| test('prefers outputResponse over variableOutputResponse when both are available', () => { | ||
| const workflowNodeOutput: WorkflowNodeOutput = { | ||
| outputResponse: { | ||
| outputSchema: mockOutputSchema, | ||
| }, | ||
| variableOutputResponse: { | ||
| outputSchema: mockVariableOutputSchema, | ||
| }, | ||
| workflowNodeName: 'action_1', | ||
| }; | ||
|
|
||
| const result = getOutputSchemaFromWorkflowNodeOutput(workflowNodeOutput); | ||
|
|
||
| expect(result).toBe(mockOutputSchema); | ||
| }); | ||
|
|
||
| test('returns undefined when neither outputResponse nor variableOutputResponse has outputSchema', () => { | ||
| const workflowNodeOutput: WorkflowNodeOutput = { | ||
| outputResponse: {}, | ||
| variableOutputResponse: {}, | ||
| workflowNodeName: 'action_1', | ||
| }; | ||
|
|
||
| const result = getOutputSchemaFromWorkflowNodeOutput(workflowNodeOutput); | ||
|
|
||
| expect(result).toBeUndefined(); | ||
| }); | ||
|
|
||
| test('returns variableOutputResponse.outputSchema for loop task dispatcher with item and index properties', () => { | ||
| const loopVariableSchema: PropertyAllType = { | ||
| name: 'loopOutput', | ||
| properties: [ | ||
| { | ||
| name: 'item', | ||
| properties: [{name: 'id', type: 'STRING'}], | ||
| type: 'OBJECT', | ||
| }, | ||
| {name: 'index', type: 'INTEGER'}, | ||
| ], | ||
| type: 'OBJECT', | ||
| }; | ||
|
|
||
| const workflowNodeOutput: WorkflowNodeOutput = { | ||
| taskDispatcherDefinition: { | ||
| name: 'loop', | ||
| outputDefined: false, | ||
| variablePropertiesDefined: true, | ||
| version: 1, | ||
| }, | ||
| variableOutputResponse: { | ||
| outputSchema: loopVariableSchema, | ||
| }, | ||
| workflowNodeName: 'loop_1', | ||
| }; | ||
|
|
||
| const result = getOutputSchemaFromWorkflowNodeOutput(workflowNodeOutput); | ||
|
|
||
| expect(result).toBe(loopVariableSchema); | ||
| expect(result?.properties).toHaveLength(2); | ||
| expect(result?.properties?.[0].name).toBe('item'); | ||
| expect(result?.properties?.[1].name).toBe('index'); | ||
| }); | ||
| }); |
16 changes: 16 additions & 0 deletions
16
client/src/pages/platform/workflow-editor/utils/getOutputSchemaFromWorkflowNodeOutput.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import {WorkflowNodeOutput} from '@/shared/middleware/platform/configuration'; | ||
| import {PropertyAllType} from '@/shared/types'; | ||
|
|
||
| /** | ||
| * Gets the output schema from a workflow node output, falling back to variableOutputResponse | ||
| * when outputResponse is not available. This is important for loop task dispatchers which | ||
| * provide variable properties (item, index) via variableOutputResponse. | ||
| * | ||
| * @param workflowNodeOutput - The workflow node output containing outputResponse and/or variableOutputResponse | ||
| * @returns The output schema from outputResponse or variableOutputResponse, or undefined if neither exists | ||
| */ | ||
| export default function getOutputSchemaFromWorkflowNodeOutput( | ||
| workflowNodeOutput: WorkflowNodeOutput | undefined | ||
| ): PropertyAllType | undefined { | ||
| return workflowNodeOutput?.outputResponse?.outputSchema || workflowNodeOutput?.variableOutputResponse?.outputSchema; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.