From 93a44cbee20debd54f4364a5f05b58db82a117cd Mon Sep 17 00:00:00 2001 From: Paul Cowan Date: Thu, 23 Mar 2023 15:00:00 +0000 Subject: [PATCH] make required boolean --- .../workflowDefinitions/recursiveWorks.ts | 12 ++++++------ .../src/models/workflowDefinitionSchema.ts | 18 ++---------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/plugins/parodos/src/mocks/workflowDefinitions/recursiveWorks.ts b/plugins/parodos/src/mocks/workflowDefinitions/recursiveWorks.ts index 65d52db337..2b1a65762b 100644 --- a/plugins/parodos/src/mocks/workflowDefinitions/recursiveWorks.ts +++ b/plugins/parodos/src/mocks/workflowDefinitions/recursiveWorks.ts @@ -20,13 +20,13 @@ export const mockRecursiveWorksWorkflowDefinition = { parameters: { adGroups: { description: 'The ad groups', - required: 'false', + required: false, type: 'string', format: 'text', }, userId: { description: 'The user id', - required: 'true', + required: true, type: 'string', format: 'text', }, @@ -40,13 +40,13 @@ export const mockRecursiveWorksWorkflowDefinition = { parameters: { clusterName: { description: 'The cluster name', - required: 'false', + required: false, type: 'string', format: 'text', }, hostname: { description: 'The hostname', - required: 'false', + required: false, type: 'string', format: 'text', }, @@ -59,7 +59,7 @@ export const mockRecursiveWorksWorkflowDefinition = { type: 'string', format: 'text', description: 'The workflow comment', - required: 'false', + required: false, }, }, }, @@ -70,7 +70,7 @@ export const mockRecursiveWorksWorkflowDefinition = { parameters: { projectId: { description: 'The project id', - required: 'false', + required: false, type: 'number', }, }, diff --git a/plugins/parodos/src/models/workflowDefinitionSchema.ts b/plugins/parodos/src/models/workflowDefinitionSchema.ts index 947f86b977..f0eb55f3d6 100644 --- a/plugins/parodos/src/models/workflowDefinitionSchema.ts +++ b/plugins/parodos/src/models/workflowDefinitionSchema.ts @@ -23,7 +23,7 @@ const processingType = z.union([ export const workFlowTaskParameterTypeSchema = z.object({ description: z.string().optional(), - required: z.string().transform(val => val === 'true'), + required: z.boolean(), type: parameterTypes, format: parameterFormat.optional(), minLength: z.number().optional(), @@ -33,12 +33,6 @@ export const workFlowTaskParameterTypeSchema = z.object({ disabled: z.boolean().default(false).optional(), }); -type Parameter = z.infer; - -type InputParameter = { - [K in keyof Parameter]: K extends 'required' ? string : Parameter[K]; -}; - export const baseWorkSchema = z.object({ id: z.string(), name: z.string(), @@ -65,15 +59,7 @@ export type WorkType = z.infer & { works?: WorkType[]; }; -export type WorkTypeInput = { - [K in keyof WorkType]: K extends 'parameters' - ? Record | null - : K extends 'works' - ? WorkTypeInput[] - : WorkType[K]; -}; - -export const workSchema: z.ZodType = +export const workSchema: z.ZodType = baseWorkSchema.extend({ works: z.lazy(() => workSchema.array()).optional(), });