import z from 'zod';
export const AddOnSelectOptionSchema = z.object({
    type: z.literal('select'),
    label: z.string(),
    description: z.string().optional(),
    default: z.string(),
    options: z.array(z.object({
        value: z.string(),
        label: z.string(),
    })),
});
export const AddOnOptionSchema = z.discriminatedUnion('type', [
    AddOnSelectOptionSchema,
]);
export const AddOnOptionsSchema = z.record(z.string(), AddOnOptionSchema);
export const AddOnBaseSchema = z.object({
    id: z.string(),
    name: z.string(),
    description: z.string(),
    author: z.string().optional(),
    version: z.string().optional(),
    link: z.string().optional(),
    license: z.string().optional(),
    warning: z.string().optional(),
    tailwind: z.boolean().optional(),
    type: z.enum(['add-on', 'example', 'starter', 'toolchain', 'deployment']),
    category: z
        .enum([
        'tanstack',
        'database',
        'orm',
        'auth',
        'deploy',
        'styling',
        'monitoring',
        'cms',
        'api',
        'analytics',
        'i18n',
        'tooling',
        'other',
    ])
        .optional(),
    exclusive: z
        .array(z.enum(['orm', 'auth', 'deploy', 'database', 'linter']))
        .optional(),
    color: z.string().optional(),
    priority: z.number().optional(),
    command: z
        .object({
        command: z.string(),
        args: z.array(z.string()).optional(),
    })
        .optional(),
    routes: z
        .array(z.object({
        url: z.string().optional(),
        name: z.string().optional(),
        path: z.string(),
        jsName: z.string(),
    }))
        .optional(),
    packageAdditions: z
        .object({
        dependencies: z.record(z.string(), z.string()).optional(),
        devDependencies: z.record(z.string(), z.string()).optional(),
        scripts: z.record(z.string(), z.string()).optional(),
    })
        .optional(),
    shadcnComponents: z.array(z.string()).optional(),
    dependsOn: z.array(z.string()).optional(),
    smallLogo: z.string().optional(),
    logo: z.string().optional(),
    addOnSpecialSteps: z.array(z.string()).optional(),
    createSpecialSteps: z.array(z.string()).optional(),
    postInitSpecialSteps: z.array(z.string()).optional(),
    options: AddOnOptionsSchema.optional(),
    envVars: z
        .array(z.object({
        name: z.string(),
        description: z.string().optional(),
        required: z.boolean().optional(),
        default: z.string().optional(),
        secret: z.boolean().optional(),
        file: z.enum(['.env', '.env.local']).optional(),
    }))
        .optional(),
    default: z.boolean().optional(),
});
export const StarterSchema = AddOnBaseSchema.extend({
    framework: z.string(),
    mode: z.string(),
    typescript: z.boolean(),
    banner: z.string().optional(),
});
export const StarterCompiledSchema = StarterSchema.extend({
    files: z.record(z.string(), z.string()),
    deletedFiles: z.array(z.string()),
});
export const IntegrationSchema = z.object({
    type: z.string().optional(),
    path: z.string().optional(),
    jsName: z.string().optional(),
    import: z.string().optional(),
    code: z.string().optional(),
});
export const AddOnInfoSchema = AddOnBaseSchema.extend({
    modes: z.array(z.string()),
    integrations: z.array(IntegrationSchema).optional(),
    phase: z.enum(['setup', 'add-on']),
    readme: z.string().optional(),
    readmeIsEjs: z.boolean().optional(),
});
export const AddOnCompiledSchema = AddOnInfoSchema.extend({
    files: z.record(z.string(), z.string()),
    deletedFiles: z.array(z.string()),
    packageTemplate: z.string().optional(),
});
