Skip to content

Commit

Permalink
fix(api): null issues (#7076)
Browse files Browse the repository at this point in the history
  • Loading branch information
tatarco authored Nov 20, 2024
1 parent a12756c commit 32b983b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
8 changes: 1 addition & 7 deletions apps/api/src/app/workflows-v2/generate-preview.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,7 @@ function buildInAppControlValuesMissingUrlsAndData() {
target: RedirectTargetEnum.BLANK,
},
},
secondaryAction: {
label: 'Secondary Action',
redirect: {
target: RedirectTargetEnum.BLANK,
url: '',
},
},
secondaryAction: null,
redirect: {
target: RedirectTargetEnum.BLANK,
url: ' ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,28 @@ const redirectZodSchema = z
url: z.string().optional(),
target: z.enum(['_self', '_blank', '_parent', '_top', '_unfencedTop']).default('_blank'),
})
.strict();
.strict()
.optional()
.nullable();

const actionZodSchema = z
.object({
label: z.string().optional(),
redirect: redirectZodSchema.optional(),
})
.strict();
.strict()
.optional()
.nullable();

export const InAppControlZodSchema = z
.object({
subject: z.string().optional(),
body: z.string(),
avatar: z.string().optional(),
primaryAction: actionZodSchema.optional(),
secondaryAction: actionZodSchema.optional(),
primaryAction: actionZodSchema,
secondaryAction: actionZodSchema,
data: z.object({}).catchall(z.unknown()).optional(),
redirect: redirectZodSchema.optional(),
redirect: redirectZodSchema,
})
.strict();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ export class PrepareAndValidateContentUsecase {
const filteredValues: Record<string, unknown> = {};

for (const [key, value] of Object.entries(controlValues)) {
if (value === null) {
continue;
}
if (typeof value !== 'string') {
filteredValues[key] = value;
continue;
Expand Down

0 comments on commit 32b983b

Please sign in to comment.