Skip to content

Commit

Permalink
provide a strict and a felxible config schema
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskalmar committed Nov 18, 2023
1 parent b8909ab commit c448be5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,13 @@ export const GenerateOnlyModeConfigSchema = BaseConfigSchema.extend({
compareEngine: z.enum(['pixelmatch', 'odiff']).default('pixelmatch'),
});

// use partial() specifically for the inferred type
export const ConfigSchema = z.union([
PlatformModeConfigSchema,
GenerateOnlyModeConfigSchema,
]);

// use partial() specifically for the inferred type
export const FlexibleConfigSchema = z.union([
PlatformModeConfigSchema.extend({
timeouts: TimeoutsSchema.partial(),
}).partial(),
Expand All @@ -462,8 +467,11 @@ export const ConfigSchema = z.union([
}).partial(),
]);

type PlatformModeConfig = z.infer<typeof PlatformModeConfigSchema>;
type GenerateOnlyModeConfig = z.infer<typeof GenerateOnlyModeConfigSchema>;

export type Config = z.infer<typeof ConfigSchema>;
export type CustomProjectConfig = Config;
export type CustomProjectConfig = z.infer<typeof FlexibleConfigSchema>;

export const MEDIA_UPLOAD_CONCURRENCY = 10;

Expand Down

0 comments on commit c448be5

Please sign in to comment.