Skip to content

Commit

Permalink
Update WorkflowInput definition to include default value + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Jun 19, 2024
1 parent de29176 commit cccdddd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ inputs:
name: "text_param",
doc: "",
type: "text",
default: "text value",
},
]);
});
Expand Down
13 changes: 9 additions & 4 deletions server/gx-workflow-ls-native/src/nativeWorkflowDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
TextDocument,
WorkflowDataType,
WorkflowDocument,
WorkflowInput,
WorkflowOutput,
} from "@gxwf/server-common/src/languageTypes";
import { JSONDocument } from "vscode-json-languageservice";
import { ToolState, isWorkflowInputType, type ParameterInputToolState } from "./utils";
Expand Down Expand Up @@ -63,11 +65,13 @@ export class NativeWorkflowDocument extends WorkflowDocument {
const toolStateValue = JSON.parse(
toolStateNode?.valueNode?.value ? String(toolStateNode?.valueNode?.value) : "{}"
);
result.inputs.push({
const inputDefinition: WorkflowInput = {
name: String(labelValue),
doc: String(annotationValue ?? ""),
type: this.getInputType(stepTypeValue, toolStateValue),
});
default: toolStateValue.default,
};
result.inputs.push(inputDefinition);
}
});
return result;
Expand Down Expand Up @@ -95,10 +99,11 @@ export class NativeWorkflowDocument extends WorkflowDocument {
}
const uuidNode = workflowOutput.properties.find((property) => property.keyNode.value === "uuid");
const uuidValue = String(uuidNode?.valueNode?.value);
result.outputs.push({
const outputDefinition: WorkflowOutput = {
name: String(labelValue),
uuid: uuidValue,
});
};
result.outputs.push(outputDefinition);
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ describe("NativeWorkflowDocument", () => {
[
TestWorkflowProvider.workflows.validation.withOnlyInputs,
[
{ doc: "", name: "Dataset Input", type: "data" },
{ doc: "", name: "Collection Input", type: "collection" },
{ doc: "", name: "Text Param", type: "text" },
{ doc: "", name: "Integer Param", type: "integer" },
{ doc: "", name: "Float Param", type: "float" },
{ doc: "", name: "Boolean Param", type: "boolean" },
{ doc: "", name: "Color Param", type: "color" },
{ default: undefined, doc: "", name: "Dataset Input", type: "data" },
{ default: undefined, doc: "", name: "Collection Input", type: "collection" },
{ default: undefined, doc: "", name: "Text Param", type: "text" },
{ default: 10, doc: "", name: "Integer Param", type: "integer" },
{ default: undefined, doc: "", name: "Float Param", type: "float" },
{ default: undefined, doc: "", name: "Boolean Param", type: "boolean" },
{ default: undefined, doc: "", name: "Color Param", type: "color" },
],
],
])("returns the expected inputs", (wfContent: string, expectedInputs: WorkflowInput[]) => {
Expand Down
1 change: 1 addition & 0 deletions shared/src/requestsDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface WorkflowInput {
name: string;
type: WorkflowDataType;
doc: string;
default?: unknown;
}

export interface GetWorkflowInputsResult {
Expand Down

0 comments on commit cccdddd

Please sign in to comment.