Skip to content

Commit

Permalink
Merge pull request janus-idp#66 from thefrontside/pc/required-api-update
Browse files Browse the repository at this point in the history
make required boolean
  • Loading branch information
RichardW98 authored Mar 23, 2023
2 parents edc3dbf + 93a44cb commit 63ab358
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
12 changes: 6 additions & 6 deletions plugins/parodos/src/mocks/workflowDefinitions/recursiveWorks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand All @@ -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',
},
Expand All @@ -59,7 +59,7 @@ export const mockRecursiveWorksWorkflowDefinition = {
type: 'string',
format: 'text',
description: 'The workflow comment',
required: 'false',
required: false,
},
},
},
Expand All @@ -70,7 +70,7 @@ export const mockRecursiveWorksWorkflowDefinition = {
parameters: {
projectId: {
description: 'The project id',
required: 'false',
required: false,
type: 'number',
},
},
Expand Down
18 changes: 2 additions & 16 deletions plugins/parodos/src/models/workflowDefinitionSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -33,12 +33,6 @@ export const workFlowTaskParameterTypeSchema = z.object({
disabled: z.boolean().default(false).optional(),
});

type Parameter = z.infer<typeof workFlowTaskParameterTypeSchema>;

type InputParameter = {
[K in keyof Parameter]: K extends 'required' ? string : Parameter[K];
};

export const baseWorkSchema = z.object({
id: z.string(),
name: z.string(),
Expand All @@ -65,15 +59,7 @@ export type WorkType = z.infer<typeof baseWorkSchema> & {
works?: WorkType[];
};

export type WorkTypeInput = {
[K in keyof WorkType]: K extends 'parameters'
? Record<string, InputParameter> | null
: K extends 'works'
? WorkTypeInput[]
: WorkType[K];
};

export const workSchema: z.ZodType<WorkType, z.ZodTypeDef, WorkTypeInput> =
export const workSchema: z.ZodType<WorkType, z.ZodTypeDef> =
baseWorkSchema.extend({
works: z.lazy(() => workSchema.array()).optional(),
});
Expand Down

0 comments on commit 63ab358

Please sign in to comment.