Skip to content

Commit 4975ba9

Browse files
committed
Add validate fn stubs
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent da14028 commit 4975ba9

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

common/interfaces.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export type TemplateEdge = {
5353
export type TemplateFlow = {
5454
user_params?: Map<string, any>;
5555
nodes: TemplateNode[];
56-
edges: TemplateEdge[];
56+
edges?: TemplateEdge[];
5757
};
5858

5959
export type TemplateFlows = {

common/utils.ts

+23
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
generateId,
1313
ReactFlowEdge,
1414
TemplateFlows,
15+
WorkflowTemplate,
1516
} from './';
1617

1718
// TODO: implement this and remove hardcoded return values
@@ -68,3 +69,25 @@ export function toWorkspaceFlow(
6869
edges: [] as ReactFlowEdge[],
6970
};
7071
}
72+
73+
// TODO: implement this
74+
/**
75+
* Validates the UI workflow state.
76+
* Note we don't have to validate connections since that is done via input/output handlers.
77+
*/
78+
export function validateWorkspaceFlow(
79+
workspaceFlow: WorkspaceFlowState
80+
): boolean {
81+
return true;
82+
}
83+
84+
// TODO: implement this
85+
/**
86+
* Validates the backend template. May be used when parsing persisted templates on server-side,
87+
* or when importing/exporting on the UI.
88+
*/
89+
export function validateWorkflowTemplate(
90+
workflowTemplate: WorkflowTemplate
91+
): boolean {
92+
return true;
93+
}

public/pages/workflow_detail/utils/utils.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Workflow,
99
ReactFlowComponent,
1010
toTemplateFlows,
11+
validateWorkspaceFlow,
1112
} from '../../../../common';
1213

1314
export function saveWorkflow(workflow: Workflow, rfInstance: any): void {
@@ -18,7 +19,7 @@ export function saveWorkflow(workflow: Workflow, rfInstance: any): void {
1819
nodes: processNodes(curFlowState.nodes),
1920
};
2021

21-
const isValid = validateFlowState(curFlowState);
22+
const isValid = validateWorkspaceFlow(curFlowState);
2223
if (isValid) {
2324
const updatedWorkflow = {
2425
...workflow,
@@ -35,13 +36,6 @@ export function saveWorkflow(workflow: Workflow, rfInstance: any): void {
3536
}
3637
}
3738

38-
// TODO: implement this. Need more info on UX side to finalize what we need
39-
// to persist, what validation to do, etc.
40-
// Note we don't have to validate connections since that is done via input/output handlers.
41-
function validateFlowState(flowState: WorkspaceFlowState): boolean {
42-
return true;
43-
}
44-
4539
// Process the raw ReactFlow nodes to only persist the fields we need
4640
function processNodes(nodes: ReactFlowComponent[]): ReactFlowComponent[] {
4741
return nodes

server/routes/flow_framework_routes_service.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
GET_WORKFLOW_STATE_NODE_API_PATH,
2222
SEARCH_WORKFLOWS_NODE_API_PATH,
2323
WorkflowTemplate,
24+
validateWorkflowTemplate,
2425
} from '../../common';
2526
import { generateCustomError, getWorkflowsFromResponses } from './helpers';
2627

@@ -226,7 +227,9 @@ export class FlowFrameworkRoutesService {
226227
const workflowTemplate = JSON.parse(
227228
templateData.toString()
228229
) as WorkflowTemplate;
229-
workflowTemplates.push(workflowTemplate);
230+
if (validateWorkflowTemplate(workflowTemplate)) {
231+
workflowTemplates.push(workflowTemplate);
232+
}
230233
});
231234

232235
return res.ok({ body: { workflowTemplates } });

0 commit comments

Comments
 (0)