Fix VariableValueType typing to match API type

And adapt formUtil functions to handle undefined values
This commit is contained in:
davelopez
2024-07-09 15:07:36 +02:00
parent 93c3cddab1
commit f5dad9db7d
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ export type TemplateVariable =
| components["schemas"]["TemplateVariablePathComponent"]
| components["schemas"]["TemplateVariableBoolean"];
export type TemplateSecret = components["schemas"]["TemplateSecret"];
export type VariableValueType = (string | boolean | number) | undefined;
export type VariableValueType = string | boolean | number;
export type VariableData = { [key: string]: VariableValueType };
export type SecretData = { [key: string]: string };
@@ -39,7 +39,7 @@ export function metadataFormEntryDescription(what: string): FormEntry {
};
}
export function templateVariableFormEntry(variable: TemplateVariable, variableValue: VariableValueType): FormEntry {
export function templateVariableFormEntry(variable: TemplateVariable, variableValue?: VariableValueType): FormEntry {
const common_fields = {
name: variable.name,
label: variable.label ?? variable.name,
@@ -166,7 +166,7 @@ export function createFormDataToPayload(template: TemplateSummary, formData: any
return payload;
}
export function formDataTypedGet(variableDefinition: TemplateVariable, formData: any): VariableValueType {
export function formDataTypedGet(variableDefinition: TemplateVariable, formData: any): VariableValueType | undefined {
// galaxy form library doesn't type values traditionally, so add a typed
// access to the data if coming back as string. Though it does seem to be
// typed properly - this might not be needed anymore?