|
| 1 | +import { z } from 'zod'; |
| 2 | +import { pluginConfigSchema } from './plugins'; |
| 3 | +import { categoryConfigSchema } from './category-config'; |
| 4 | +import { uploadConfigSchema } from './upload'; |
| 5 | +import { budgetSchema } from './budgets'; |
| 6 | +import { persistConfigSchema } from './persist'; |
| 7 | + |
| 8 | +/** |
| 9 | + * Define Zod schema for the CoreConfig type |
| 10 | + * |
| 11 | + * @example |
| 12 | + * |
| 13 | + * // Example data for the CoreConfig type |
| 14 | + * const coreConfigData = { |
| 15 | + * // ... populate with example data ... |
| 16 | + * }; |
| 17 | + * |
| 18 | + * // Validate the data against the schema |
| 19 | + * const validationResult = coreConfigSchema.safeParse(coreConfigData); |
| 20 | + * |
| 21 | + * if (validationResult.success) { |
| 22 | + * console.log('Valid plugin config:', validationResult.data); |
| 23 | + * } else { |
| 24 | + * console.error('Invalid plugin config:', validationResult.error); |
| 25 | + * } |
| 26 | + */ |
| 27 | +export const coreConfigSchema = z.object({ |
| 28 | + plugins: z.array(pluginConfigSchema, { |
| 29 | + description: 'list of plugins to be used (built-in, 3rd party, or custom)', |
| 30 | + }), |
| 31 | + /** portal configuration for persisting results */ |
| 32 | + persist: persistConfigSchema, |
| 33 | + /** portal configuration for uploading results */ |
| 34 | + upload: uploadConfigSchema.optional(), |
| 35 | + categories: z.array(categoryConfigSchema, { |
| 36 | + description: 'categorization of individual audits', |
| 37 | + }), |
| 38 | + budgets: z |
| 39 | + .array(budgetSchema, { |
| 40 | + description: 'budget rules for assertion', |
| 41 | + }) |
| 42 | + .optional(), |
| 43 | +}); |
| 44 | + |
| 45 | +export type CoreConfigSchema = z.infer<typeof coreConfigSchema>; |
0 commit comments