"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toolCreateScheduledDeliveryOutputSchema = exports.toolCreateScheduledDeliveryArgsSchema = exports.TOOL_CREATE_SCHEDULED_DELIVERY_DESCRIPTION = void 0;
const zod_1 = require("zod");
exports.TOOL_CREATE_SCHEDULED_DELIVERY_DESCRIPTION = [
    'Create a LIVE scheduled delivery that sends a saved chart or dashboard to Slack channels and/or email recipients on a cron schedule.',
    'IMPORTANT: before calling this tool, propose the full configuration to the user (name, schedule in plain words, timezone, destinations, format, AI augmentation prompt if any) and wait for their explicit confirmation in the conversation.',
    'Requires an existing saved chart or dashboard — if the content only exists in this conversation, create it with createContent first, then schedule the created uuid.',
    'On success, share the returned href with the user — the delivery is managed (paused, edited, deleted) from that page.',
].join(' ');
const slackTargetSchema = zod_1.z.object({
    type: zod_1.z.literal('slack'),
    channel: zod_1.z
        .string()
        .min(1)
        .describe('Slack channel ID (preferred, e.g. "C0123ABCDEF") or channel name. The Lightdash Slack app must be able to join it.'),
});
const emailTargetSchema = zod_1.z.object({
    type: zod_1.z.literal('email'),
    recipient: zod_1.z.string().min(3).describe('Email address of the recipient.'),
});
exports.toolCreateScheduledDeliveryArgsSchema = zod_1.z.object({
    resourceType: zod_1.z
        .enum(['chart', 'dashboard'])
        .describe('Type of saved content to deliver.'),
    resourceUuidOrSlug: zod_1.z
        .string()
        .describe('UUID (preferred) or slug of the saved chart or dashboard to deliver. Use the uuid from createContent/findContent results — slugs are not guaranteed unique.'),
    name: zod_1.z.string().min(1).describe('Human-readable delivery name.'),
    cron: zod_1.z
        .string()
        .describe('5-part cron expression, e.g. "0 9 * * 1". Minimum frequency is hourly — sub-hourly minute patterns (e.g. "*/15") are rejected.'),
    timezone: zod_1.z
        .string()
        .nullable()
        .describe('IANA timezone the cron runs in (e.g. "Europe/London"). null = project default.'),
    format: zod_1.z
        .enum(['csv', 'image'])
        .describe('"image" sends a rendered image of the chart/dashboard; "csv" sends the results as CSV.'),
    csvOptions: zod_1.z
        .object({
        formatted: zod_1.z
            .boolean()
            .describe('Apply Lightdash value formatting.'),
        limit: zod_1.z
            .union([
            zod_1.z.literal('table'),
            zod_1.z.literal('all'),
            zod_1.z.number().int().positive(),
        ])
            .describe('"table" = the chart\'s own limit, "all" = all results, or an explicit row count.'),
    })
        .nullable()
        .describe('Only used when format is "csv". null = defaults (formatted, table limit).'),
    message: zod_1.z
        .string()
        .nullable()
        .describe('Optional static message included with every delivery. Ignored when aiAugmentationPrompt is set (the AI writes the message instead).'),
    targets: zod_1.z
        .array(zod_1.z.discriminatedUnion('type', [
        slackTargetSchema,
        emailTargetSchema,
    ]))
        .min(1)
        .describe('At least one Slack channel or email recipient.'),
    enabled: zod_1.z
        .boolean()
        .describe('Whether the delivery starts firing immediately. Use true only when the user explicitly confirmed it should go live; when in doubt, create it paused (false) — the user can enable it from the UI.'),
    aiAugmentationPrompt: zod_1.z
        .string()
        .nullable()
        .describe('Instructions for the AI-written delivery message, regenerated from the delivered data on every send. null = plain delivery without AI augmentation.'),
});
const toolCreateScheduledDeliveryMetadataSchema = zod_1.z.discriminatedUnion('status', [
    zod_1.z.object({ status: zod_1.z.literal('error') }),
    zod_1.z.object({
        status: zod_1.z.literal('success'),
        schedulerUuid: zod_1.z.string(),
        name: zod_1.z.string(),
        cron: zod_1.z.string(),
        resourceType: zod_1.z.enum(['chart', 'dashboard']),
        resourceUuid: zod_1.z.string(),
        href: zod_1.z.string(),
        aiAugmentationAttached: zod_1.z.boolean(),
        warnings: zod_1.z.array(zod_1.z.string()),
    }),
]);
exports.toolCreateScheduledDeliveryOutputSchema = zod_1.z.object({
    result: zod_1.z.string(),
    metadata: toolCreateScheduledDeliveryMetadataSchema,
});
//# sourceMappingURL=toolCreateScheduledDeliveryArgs.js.map