"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toolCreateContentOutputSchema = exports.toolCreateContentArgsSchema = exports.toolChartAsCodeMetricQuerySchema = exports.TOOL_CREATE_CONTENT_DESCRIPTION = void 0;
const zod_1 = require("zod");
exports.TOOL_CREATE_CONTENT_DESCRIPTION = 'Create a new dashboard or chart, consult the skills for the required fields. Returns the created content with the final persisted slug.';
const TOOL_CHART_AS_CODE_METRIC_QUERY_DESCRIPTION = 'Chart-as-code metricQuery object. Required fields: exploreName, dimensions, metrics, filters, sorts, limit, tableCalculations. Optional passthrough fields: additionalMetrics, customDimensions, metricOverrides, dimensionOverrides, timezone, pivotDimensions, metadata. Every dimension in dimensions must appear in exactly one of: layout.xField, layout.yField, or pivotConfig.columns.';
const chartAsCodeMetricQueryShape = {
    exploreName: zod_1.z.unknown(),
    dimensions: zod_1.z.array(zod_1.z.unknown()),
    metrics: zod_1.z.array(zod_1.z.unknown()),
    filters: zod_1.z.unknown(),
    sorts: zod_1.z.array(zod_1.z.unknown()),
    limit: zod_1.z.unknown(),
    tableCalculations: zod_1.z.array(zod_1.z.unknown()),
};
exports.toolChartAsCodeMetricQuerySchema = zod_1.z
    .object(chartAsCodeMetricQueryShape)
    // Strict OpenAI schemas cannot use optional fields; passthrough preserves optional chart-as-code fields when present.
    .passthrough()
    .describe(TOOL_CHART_AS_CODE_METRIC_QUERY_DESCRIPTION);
const baseContentSchema = zod_1.z.object({
    slug: zod_1.z
        .string()
        .min(1)
        .describe('Requested slug. Lightdash may append a suffix if this slug already exists.'),
    name: zod_1.z.string().min(1),
    description: zod_1.z.string().nullable(),
    spaceSlug: zod_1.z.string().min(1),
    version: zod_1.z.number(),
    contentType: zod_1.z.string(),
    updatedAt: zod_1.z.unknown(),
    downloadedAt: zod_1.z.unknown(),
    verified: zod_1.z.boolean(),
    verification: zod_1.z.unknown(),
});
exports.toolCreateContentArgsSchema = zod_1.z.object({
    type: zod_1.z
        .enum(['dashboard', 'chart'])
        .describe('Type of Lightdash content to create.'),
    content: zod_1.z.union([
        baseContentSchema
            .extend({
            tiles: zod_1.z.array(zod_1.z.unknown()),
            tabs: zod_1.z.array(zod_1.z.unknown()),
            config: zod_1.z.unknown(),
            filters: zod_1.z.unknown(),
            parameters: zod_1.z.unknown(),
        })
            .passthrough()
            .describe('Full Dashboard JSON to create.'),
        baseContentSchema
            .extend({
            tableName: zod_1.z.string().min(1),
            metricQuery: exports.toolChartAsCodeMetricQuerySchema,
            chartConfig: zod_1.z.unknown(),
            pivotConfig: zod_1.z.unknown(),
            tableConfig: zod_1.z.unknown(),
            dashboardSlug: zod_1.z.string(),
            parameters: zod_1.z.unknown(),
        })
            .passthrough()
            .describe('Full Chart JSON to create.'),
    ]),
});
const toolCreateContentMetadataSchema = 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'),
        slug: zod_1.z.string(),
        name: zod_1.z.string(),
        uuid: zod_1.z.string(),
        href: zod_1.z.string(),
        warnings: zod_1.z.array(zod_1.z.string()),
    }),
]);
exports.toolCreateContentOutputSchema = zod_1.z.object({
    result: zod_1.z.string(),
    metadata: toolCreateContentMetadataSchema,
});
//# sourceMappingURL=toolCreateContentArgs.js.map