import { z } from 'zod';
import { type ApiSuccess, type ApiSuccessEmpty } from '../../types/api/success';
import { type DashboardConfig, type DashboardTab, type DashboardTile } from '../../types/dashboard';
import { type DashboardFilters } from '../../types/filter';
import { type KnexPaginateArgs, type KnexPaginatedData } from '../../types/knex-paginate';
import { type MetricQuery } from '../../types/metricQuery';
import { type DashboardParameters } from '../../types/parameters';
import { type ChartConfig, type SavedChart } from '../../types/savedCharts';
/**
 * Ordered pipeline stages. Index position determines progression — used to
 * skip completed stages when a build is retried after a worker crash.
 * 'ready' is included as the final stage; 'error' is terminal but not a
 * stage (not reachable through normal progression).
 */
export declare const APP_VERSION_STAGE_ORDER: readonly ["pending", "sandbox", "catalog", "generating", "building", "packaging", "ready"];
export declare const APP_VERSION_TERMINAL_STATUSES: readonly ["ready", "error"];
/**
 * Error message stamped on a version when the user cancels its build. There is
 * no dedicated 'cancelled' status — cancellation is an 'error' carrying this
 * marker, which the pipeline also reads to detect that a previous prompt was
 * cancelled mid-generation.
 */
export declare const APP_VERSION_CANCELLED_BY_USER = "Cancelled by user";
export type AppVersionStatus = (typeof APP_VERSION_STAGE_ORDER)[number] | 'error';
export declare const isAppVersionInProgress: (status: AppVersionStatus) => boolean;
/**
 * Data apps are created with an empty name and only get an auto-generated
 * title after their first version builds successfully. If that build never
 * completes the name stays blank. Everywhere an app name is shown to the user,
 * fall back to a stable, identifiable placeholder instead of rendering nothing
 * — the uuid suffix keeps two unnamed apps distinguishable. Use this as the
 * single source of truth so the convention stays consistent across the UI.
 */
export declare const getAppDisplayName: (name: string, appUuid: string) => string;
export type ApiGenerateAppResponse = ApiSuccess<{
    appUuid: string;
    version: number;
}>;
export type ApiAppImageUploadResponse = ApiSuccess<{
    imageId: string;
}>;
/** Starter template for a single-tile renderer that emits a typed viz schema. */
export declare const DATA_APP_VIZ_TEMPLATE: "data_app_viz";
export declare const DATA_APP_TEMPLATES: readonly ["dashboard", "slideshow", "pdf", "custom", "data_app_viz"];
export type DataAppTemplate = (typeof DATA_APP_TEMPLATES)[number];
/**
 * Claude model used to generate / iterate the data app inside the sandbox.
 * Mapped to the Claude CLI's `--model <alias>` flag verbatim. Persisted
 * per-version on `AppVersionResources.claudeModel` so the user can switch
 * mid-iteration without losing the record of which model built which version.
 */
export declare const DATA_APP_CLAUDE_MODELS: readonly ["opus", "sonnet", "haiku"];
export type DataAppClaudeModel = (typeof DATA_APP_CLAUDE_MODELS)[number];
export declare const DEFAULT_DATA_APP_CLAUDE_MODEL: DataAppClaudeModel;
/**
 * A saved-chart reference attached to a generation request.
 * `includeSampleData` is opt-in per chart: when true the backend runs the
 * underlying metric query and inlines a small sample of rows into the
 * sandbox so Claude can see actual values (e.g. "season 2026 only").
 */
export type AppChartReference = {
    uuid: string;
    includeSampleData: boolean;
    /** When true the app runs this chart live by UUID (linked) instead of
     *  copying its metric query inline. Optional for backwards compatibility —
     *  omitted (older clients) is treated as false (copy) on the server. */
    linkLive?: boolean;
};
/**
 * A dashboard reference attached to a generation request. The dashboard is
 * expanded server-side into its chart tiles. When `includeSampleData` is
 * true, every resolved chart in the dashboard receives a sample.
 */
export type AppDashboardReference = {
    uuid: string;
    includeSampleData: boolean;
};
/**
 * Structural snapshot of an attached dashboard, written into the sandbox so
 * the agent can recreate the dashboard's design — tabs, tile layout, filters —
 * instead of inventing a layout from the flattened chart queries. Built
 * server-side at enqueue time from the resolved dashboard.
 */
export type DashboardBlueprint = {
    dashboardUuid: string;
    name: string;
    description: string | null;
    /** Sorted by `order`. Empty when the dashboard has no tabs. */
    tabs: DashboardTab[];
    /** Tile positions use the dashboard's 36-column grid: `x`/`w` are column
     *  units, `y`/`h` are row units. `tabUuid` links a tile to its tab. Chart
     *  tiles carry `properties.savedChartUuid` — the same uuid as the matching
     *  ChartReference in the sandbox. */
    tiles: DashboardTile[];
    filters: DashboardFilters;
    parameters: DashboardParameters | null;
    config: DashboardConfig | null;
};
/**
 * An external connection attached to a generation request. Linked to the app
 * (under `alias`) server-side at creation — before the catalog stage — so the
 * generated app can call it via `client.externalFetch(alias, …)`. Validated
 * (must belong to the app's project) before linking.
 */
export type AppExternalConnectionReference = {
    externalConnectionUuid: string;
    alias: string;
};
/**
 * A clarifying question the backend posed to the user before the build, paired
 * with the user's answer. Persisted on the version's `resources.clarifications`
 * so the chat can render them as a structured Q&A card on the user message.
 */
export type AppClarification = {
    question: string;
    answer: string;
};
/**
 * Fold clarifications into the prompt sent to the sandbox. The persisted
 * prompt stays as the user's original words — clarifications travel
 * separately on `resources.clarifications` for chat rendering.
 */
export declare const formatPromptWithClarifications: (prompt: string, clarifications: AppClarification[] | undefined) => string;
export type GenerateAppRequestBody = {
    prompt: string;
    template?: DataAppTemplate;
    imageIds?: string[];
    appUuid?: string;
    charts?: AppChartReference[];
    dashboard?: AppDashboardReference;
    clarifications?: AppClarification[];
    spaceUuid?: string;
    claudeModel?: DataAppClaudeModel;
    designUuid?: string | null;
    externalConnections?: AppExternalConnectionReference[];
};
export type ApiClarifyAppRequest = {
    prompt: string;
    template?: DataAppTemplate;
    charts?: AppChartReference[];
    dashboard?: AppDashboardReference;
    imageIds?: string[];
};
export type ApiClarifyAppResponse = ApiSuccess<{
    questions: string[];
}>;
export type ApiPreviewTokenResponse = ApiSuccess<{
    token: string;
}>;
export type AppVersionImageResource = {
    imageId: string;
};
export type AppVersionChartResource = {
    chartUuid: string;
    chartName: string;
    chartKind: string | null;
    /** Whether this chart was attached as a live link — persists the linked
     *  chip indicator across reloads. Optional for backwards compatibility. */
    linkLive?: boolean;
};
export type AppVersionExternalConnectionResource = {
    externalConnectionUuid: string;
    name: string;
    alias: string;
};
export type AppVersionDesignSnapshot = {
    designUuid: string;
    name: string;
    fileCount: number;
};
export type AppVersionResources = {
    images: AppVersionImageResource[];
    charts: AppVersionChartResource[];
    externalConnections?: AppVersionExternalConnectionResource[];
    dashboardName: string | null;
    dashboardUuid?: string | null;
    clarifications: AppClarification[];
    claudeModel?: DataAppClaudeModel;
    design?: AppVersionDesignSnapshot | null;
    vizSchema?: DataAppVizSchema | null;
};
export type AppVersionDependencyEntry = {
    name: string;
    version: string;
};
export type AppVersionDependencies = {
    custom: AppVersionDependencyEntry[];
    lockfileHash: string;
};
export type ApiAppImageUrlResponse = ApiSuccess<{
    imageUrl: string;
}>;
export type ApiAppThumbnailUrlResponse = ApiSuccess<{
    thumbnailUrl: string;
}>;
export type ApiAppVersionSummary = {
    version: number;
    prompt: string;
    status: AppVersionStatus;
    statusMessage: string | null;
    error: string | null;
    createdAt: Date;
    statusUpdatedAt: Date | null;
    createdByUser: {
        userUuid: string;
        firstName: string;
        lastName: string;
    } | null;
    resources: AppVersionResources | null;
    dependencies?: {
        custom: AppVersionDependencyEntry[];
    };
};
export type ApiGetAppResponse = ApiSuccess<{
    appUuid: string;
    name: string;
    description: string;
    createdByUserUuid: string;
    spaceUuid: string | null;
    spaceName: string | null;
    template: Exclude<DataAppTemplate, 'custom'> | null;
    pinnedListUuid: string | null;
    pinnedListOrder: number | null;
    versions: ApiAppVersionSummary[];
    hasMore: boolean;
    latestReadyVersion: number | null;
}>;
export type ApiUpdateAppRequest = {
    name?: string;
    description?: string;
};
export type ApiUpdateAppResponse = ApiSuccess<{
    appUuid: string;
    name: string;
    description: string;
}>;
export type ApiCancelAppVersionResponse = ApiSuccessEmpty;
export type ApiRestoreAppVersionResponse = ApiSuccess<{
    appUuid: string;
    version: number;
}>;
export type ApiDuplicateAppResponse = ApiSuccess<{
    appUuid: string;
    version: number;
}>;
export type PromoteAppAction = 'create' | 'update';
/**
 * Preview of what promoting a data app from a preview project into its
 * upstream (production) project will do. Drives the confirmation dialog.
 */
export type PromoteAppDiff = {
    action: PromoteAppAction;
    upstreamProjectUuid: string;
    upstreamProjectName: string;
    upstreamAppUuid: string | null;
    space: {
        name: string;
        path: string;
    } | null;
};
export type ApiPromoteAppDiffResponse = ApiSuccess<PromoteAppDiff>;
export type ApiPromoteAppResponse = ApiSuccess<{
    appUuid: string;
    projectUuid: string;
    version: number;
    action: PromoteAppAction;
}>;
export type ApiDeleteAppResponse = ApiSuccessEmpty;
export type ApiAppSummary = {
    appUuid: string;
    name: string;
    description: string;
    projectUuid: string;
    projectName: string;
    spaceUuid: string | null;
    spaceName: string | null;
    createdAt: Date;
    lastVersionNumber: number | null;
    lastVersionStatus: AppVersionStatus | null;
};
/** Minimal app shape for the embed config's standalone-app allowlist picker. */
export type EmbedProjectApp = {
    appUuid: string;
    name: string;
};
export type ApiEmbedProjectAppsResponse = ApiSuccess<EmbedProjectApp[]>;
/**
 * Sample of rows from a chart's underlying query, captured at request time
 * and inlined into the sandbox alongside the chart's metric query. Opt-in
 * per chart via `AppChartReference.includeSampleData`.
 *
 * Discriminated on `status`:
 * - `available` — query ran; up to SAMPLE_ROW_LIMIT formatted rows attached
 * - `unavailable` — query failed or was skipped; `reason` is informational
 *   text the prompt surfaces to Claude so it doesn't fabricate values
 */
export type ChartSampleData = {
    status: 'available';
    rows: Record<string, string>[];
    truncated: boolean;
} | {
    status: 'unavailable';
    reason: string;
};
export type ChartReference = {
    chartName: string;
    chartDescription: string;
    exploreName: string;
    metricQuery: MetricQuery;
    /** Saved visualization config (bar/line/table/big number…) so the agent
     *  can reproduce the chart type and styling, not just the query. */
    chartConfig: ChartConfig;
    /** Saved pivot layout, including ordered row fields when configured. */
    pivotConfig: NonNullable<SavedChart['pivotConfig']> | null;
    sampleData: ChartSampleData | null;
    /** Saved chart UUID — surfaced into the sandbox so a linked chart can be
     *  run live via savedChart(uuid). */
    chartUuid: string;
    /** true = run live by UUID; false = inline the metricQuery (copy). */
    linked: boolean;
};
export type ApiMyAppsResponse = ApiSuccess<{
    data: ApiAppSummary[];
    pagination?: KnexPaginateArgs & {
        totalPageCount: number;
        totalResults: number;
    };
}>;
export type DataAppVizFieldType = 'dimension' | 'metric' | 'series';
export type DataAppVizField = {
    name: string;
    label: string;
    type: DataAppVizFieldType;
    required: boolean;
};
export type DataAppVizConfigOptionType = 'boolean' | 'select' | 'number' | 'text' | 'color' | 'palette';
export type DataAppVizConfigOption = {
    type: 'boolean';
    name: string;
    label: string;
    group?: string;
    default: boolean;
} | {
    type: 'select';
    name: string;
    label: string;
    group?: string;
    choices: {
        value: string;
        label: string;
    }[];
    default: string;
} | {
    type: 'number';
    name: string;
    label: string;
    group?: string;
    default: number;
    min?: number;
    max?: number;
} | {
    type: 'text';
    name: string;
    label: string;
    group?: string;
    default: string;
} | {
    type: 'color';
    name: string;
    label: string;
    group?: string;
    default: string;
} | {
    type: 'palette';
    name: string;
    label: string;
    group?: string;
    default: string[];
};
/** A persisted config value; its shape is set by the option's declared `type`. */
export type DataAppVizOptionValue = boolean | number | string | string[];
/** The full declaration a data app viz emits: data-binding fields + config form. */
export type DataAppVizSchema = {
    fields: DataAppVizField[];
    configOptions: DataAppVizConfigOption[];
};
export declare const dataAppVizSchema: z.ZodObject<{
    fields: z.ZodEffects<z.ZodArray<z.ZodObject<{
        name: z.ZodString;
        label: z.ZodString;
        type: z.ZodEnum<["dimension", "metric", "series"]>;
        required: z.ZodBoolean;
    }, "strip", z.ZodTypeAny, {
        name: string;
        required: boolean;
        label: string;
        type: "metric" | "dimension" | "series";
    }, {
        name: string;
        required: boolean;
        label: string;
        type: "metric" | "dimension" | "series";
    }>, "many">, {
        name: string;
        required: boolean;
        label: string;
        type: "metric" | "dimension" | "series";
    }[], {
        name: string;
        required: boolean;
        label: string;
        type: "metric" | "dimension" | "series";
    }[]>;
    configOptions: z.ZodEffects<z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
        type: z.ZodLiteral<"boolean">;
        default: z.ZodBoolean;
        name: z.ZodString;
        label: z.ZodString;
        group: z.ZodOptional<z.ZodString>;
    }, "strip", z.ZodTypeAny, {
        name: string;
        label: string;
        default: boolean;
        type: "boolean";
        group?: string | undefined;
    }, {
        name: string;
        label: string;
        default: boolean;
        type: "boolean";
        group?: string | undefined;
    }>, z.ZodObject<{
        type: z.ZodLiteral<"select">;
        choices: z.ZodArray<z.ZodObject<{
            value: z.ZodString;
            label: z.ZodString;
        }, "strip", z.ZodTypeAny, {
            label: string;
            value: string;
        }, {
            label: string;
            value: string;
        }>, "many">;
        default: z.ZodString;
        name: z.ZodString;
        label: z.ZodString;
        group: z.ZodOptional<z.ZodString>;
    }, "strip", z.ZodTypeAny, {
        name: string;
        label: string;
        default: string;
        type: "select";
        choices: {
            label: string;
            value: string;
        }[];
        group?: string | undefined;
    }, {
        name: string;
        label: string;
        default: string;
        type: "select";
        choices: {
            label: string;
            value: string;
        }[];
        group?: string | undefined;
    }>, z.ZodObject<{
        type: z.ZodLiteral<"number">;
        default: z.ZodNumber;
        min: z.ZodOptional<z.ZodNumber>;
        max: z.ZodOptional<z.ZodNumber>;
        name: z.ZodString;
        label: z.ZodString;
        group: z.ZodOptional<z.ZodString>;
    }, "strip", z.ZodTypeAny, {
        name: string;
        label: string;
        default: number;
        type: "number";
        min?: number | undefined;
        max?: number | undefined;
        group?: string | undefined;
    }, {
        name: string;
        label: string;
        default: number;
        type: "number";
        min?: number | undefined;
        max?: number | undefined;
        group?: string | undefined;
    }>, z.ZodObject<{
        type: z.ZodLiteral<"text">;
        default: z.ZodString;
        name: z.ZodString;
        label: z.ZodString;
        group: z.ZodOptional<z.ZodString>;
    }, "strip", z.ZodTypeAny, {
        name: string;
        label: string;
        default: string;
        type: "text";
        group?: string | undefined;
    }, {
        name: string;
        label: string;
        default: string;
        type: "text";
        group?: string | undefined;
    }>, z.ZodObject<{
        type: z.ZodLiteral<"color">;
        default: z.ZodString;
        name: z.ZodString;
        label: z.ZodString;
        group: z.ZodOptional<z.ZodString>;
    }, "strip", z.ZodTypeAny, {
        name: string;
        label: string;
        default: string;
        type: "color";
        group?: string | undefined;
    }, {
        name: string;
        label: string;
        default: string;
        type: "color";
        group?: string | undefined;
    }>, z.ZodObject<{
        type: z.ZodLiteral<"palette">;
        default: z.ZodArray<z.ZodString, "many">;
        name: z.ZodString;
        label: z.ZodString;
        group: z.ZodOptional<z.ZodString>;
    }, "strip", z.ZodTypeAny, {
        name: string;
        label: string;
        default: string[];
        type: "palette";
        group?: string | undefined;
    }, {
        name: string;
        label: string;
        default: string[];
        type: "palette";
        group?: string | undefined;
    }>]>, "many">>, ({
        name: string;
        label: string;
        default: boolean;
        type: "boolean";
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string;
        type: "select";
        choices: {
            label: string;
            value: string;
        }[];
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: number;
        type: "number";
        min?: number | undefined;
        max?: number | undefined;
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string;
        type: "text";
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string;
        type: "color";
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string[];
        type: "palette";
        group?: string | undefined;
    })[], ({
        name: string;
        label: string;
        default: boolean;
        type: "boolean";
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string;
        type: "select";
        choices: {
            label: string;
            value: string;
        }[];
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: number;
        type: "number";
        min?: number | undefined;
        max?: number | undefined;
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string;
        type: "text";
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string;
        type: "color";
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string[];
        type: "palette";
        group?: string | undefined;
    })[] | undefined>;
}, "strip", z.ZodTypeAny, {
    fields: {
        name: string;
        required: boolean;
        label: string;
        type: "metric" | "dimension" | "series";
    }[];
    configOptions: ({
        name: string;
        label: string;
        default: boolean;
        type: "boolean";
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string;
        type: "select";
        choices: {
            label: string;
            value: string;
        }[];
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: number;
        type: "number";
        min?: number | undefined;
        max?: number | undefined;
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string;
        type: "text";
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string;
        type: "color";
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string[];
        type: "palette";
        group?: string | undefined;
    })[];
}, {
    fields: {
        name: string;
        required: boolean;
        label: string;
        type: "metric" | "dimension" | "series";
    }[];
    configOptions?: ({
        name: string;
        label: string;
        default: boolean;
        type: "boolean";
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string;
        type: "select";
        choices: {
            label: string;
            value: string;
        }[];
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: number;
        type: "number";
        min?: number | undefined;
        max?: number | undefined;
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string;
        type: "text";
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string;
        type: "color";
        group?: string | undefined;
    } | {
        name: string;
        label: string;
        default: string[];
        type: "palette";
        group?: string | undefined;
    })[] | undefined;
}>;
export declare const dataAppVizJsonSchema: import("zod-to-json-schema").JsonSchema7Type & {
    $schema?: string | undefined;
    definitions?: {
        [key: string]: import("zod-to-json-schema").JsonSchema7Type;
    } | undefined;
};
/** Effective option values = stored value ?? declared default (derive, never seed). */
export declare const getEffectiveOptionValues: (configOptions: DataAppVizConfigOption[], optionValues: Record<string, DataAppVizOptionValue>) => Record<string, DataAppVizOptionValue>;
export type DataAppViz = {
    dataAppVizUuid: string;
    name: string;
    description: string;
    projectUuid: string;
    spaceUuid: string | null;
    schema: DataAppVizSchema | null;
    createdAt: Date;
    createdByUserUuid: string;
};
export type ApiListDataAppVizsResponse = ApiSuccess<KnexPaginatedData<DataAppViz[]>>;
export type ApiGetDataAppVizResponse = ApiSuccess<DataAppViz>;
export declare const APP_SDK_DATA_APP_VIZ_CONTEXT_MESSAGE = "lightdash:sdk:data-app-viz-context";
export declare const APP_SDK_VIZ_CONTEXT_REQUEST_MESSAGE = "lightdash:sdk:viz-context-request";
export type DataAppVizContext = {
    fieldMapping: Record<string, string>;
    rows: Record<string, unknown>[];
};
//# sourceMappingURL=types.d.ts.map