/** * Deploy resources to Tinybird main workspace * Uses the /v1/deploy endpoint to create a deployment, then sets it live */ import type { GeneratedResources } from "../generator/index.js"; import type { BuildConfig, BuildApiResult } from "./build.js"; /** * Feedback item from deployment response */ export interface DeploymentFeedback { resource: string | null; level: "ERROR" | "WARNING" | "INFO"; message: string; } /** * Deployment object returned by the /v1/deploy endpoint */ export interface Deployment { id: string; status: string; live?: boolean; created_at?: string; updated_at?: string; feedback?: DeploymentFeedback[]; } /** * Response from /v1/deployments list endpoint */ export interface DeploymentsListResponse { deployments: Deployment[]; } /** * Response from /v1/deploy endpoint */ export interface DeployResponse { result: "success" | "failed" | "no_changes"; deployment?: DeploymentDetails; error?: string; errors?: Array<{ filename?: string; error: string; }>; } /** * Detailed deployment information with resource changes */ export interface DeploymentDetails extends Deployment { /** Names of newly created datasources */ new_datasource_names?: string[]; /** Names of changed datasources */ changed_datasource_names?: string[]; /** Names of deleted datasources */ deleted_datasource_names?: string[]; /** Names of newly created pipes */ new_pipe_names?: string[]; /** Names of changed pipes */ changed_pipe_names?: string[]; /** Names of deleted pipes */ deleted_pipe_names?: string[]; /** Names of newly created connections */ new_data_connector_names?: string[]; /** Names of changed connections */ changed_data_connector_names?: string[]; /** Names of deleted connections */ deleted_data_connector_names?: string[]; /** Deployment errors */ errors?: Array<{ filename?: string; error: string; }>; } /** * Response from /v1/deployments/{id} endpoint */ export interface DeploymentStatusResponse { result: string; deployment: Deployment; } /** * Deploy generated resources to Tinybird main workspace * * Uses the /v1/deploy endpoint which accepts all resources in a single * multipart form request. After creating the deployment, this function: * 1. Polls until the deployment is ready (status === 'data_ready') * 2. Sets the deployment as live via /v1/deployments/{id}/set-live * * @param config - Build configuration with API URL and token * @param resources - Generated resources to deploy * @returns Build result * * @example * ```ts * const result = await deployToMain( * { * baseUrl: 'https://api.tinybird.co', * token: 'p.xxx', * }, * { * datasources: [{ name: 'events', content: '...' }], * pipes: [{ name: 'top_events', content: '...' }], * } * ); * * if (result.success) { * console.log('Deployed to main workspace!'); * } * ``` */ /** * Callbacks for deploy progress updates */ /** * Resource changes from deployment */ export interface DeploymentChanges { datasources: { created: string[]; changed: string[]; deleted: string[]; }; pipes: { created: string[]; changed: string[]; deleted: string[]; }; connections: { created: string[]; changed: string[]; deleted: string[]; }; } export interface DeployCallbacks { /** Called when deployment is created and changes are available */ onChanges?: (changes: DeploymentChanges) => void; /** Called when waiting for deployment to be ready */ onWaitingForReady?: () => void; /** Called when deployment is ready */ onDeploymentReady?: () => void; /** Called when waiting for deployment to be promoted */ onWaitingForPromote?: () => void; /** Called when deployment is promoted */ onDeploymentPromoted?: () => void; /** Called when deployment is live */ onDeploymentLive?: (deploymentId: string) => void; /** Called when validating deployment (check mode) */ onValidating?: () => void; } export declare function deployToMain(config: BuildConfig, resources: GeneratedResources, options?: { debug?: boolean; pollIntervalMs?: number; maxPollAttempts?: number; check?: boolean; allowDestructiveOperations?: boolean; callbacks?: DeployCallbacks; }): Promise; //# sourceMappingURL=deploy.d.ts.map