/** * Tinybird Resources API client * Functions to list and fetch resources from a workspace */ import type { WorkspaceApiConfig } from "./workspaces.js"; /** * Error thrown by resource API operations */ export declare class ResourceApiError extends Error { readonly status: number; readonly endpoint: string; readonly body?: unknown | undefined; constructor(message: string, status: number, endpoint: string, body?: unknown | undefined); } /** * Column information from Tinybird API */ export interface DatasourceColumn { /** Column name */ name: string; /** ClickHouse type (e.g., "String", "DateTime", "Nullable(String)") */ type: string; /** JSON path for JSON extraction */ jsonpath?: string; /** Default value expression */ default?: string; /** Codec for compression */ codec?: string; } /** * Engine information from Tinybird API */ export interface DatasourceEngine { /** Engine type (e.g., "MergeTree", "ReplacingMergeTree") */ type: string; /** Sorting key columns */ sorting_key?: string; /** Partition key expression */ partition_key?: string; /** Primary key columns */ primary_key?: string; /** TTL expression */ ttl?: string; /** Version column (ReplacingMergeTree) */ ver?: string; /** Sign column (CollapsingMergeTree) */ sign?: string; /** Version column (VersionedCollapsingMergeTree) */ version?: string; /** Summing columns (SummingMergeTree) */ summing_columns?: string; } /** * Full datasource information from Tinybird API */ export interface DatasourceInfo { /** Datasource name */ name: string; /** Human-readable description */ description?: string; /** Column definitions */ columns: DatasourceColumn[]; /** Engine configuration */ engine: DatasourceEngine; /** Forward query for schema evolution */ forward_query?: string; } /** * Node information from a pipe */ export interface PipeNode { /** Node name */ name: string; /** SQL query */ sql: string; /** Node description */ description?: string; } /** * Parameter information from a pipe */ export interface PipeParam { /** Parameter name */ name: string; /** ClickHouse type */ type: string; /** Default value */ default?: string | number; /** Whether the parameter is required */ required: boolean; /** Parameter description */ description?: string; } /** * Pipe type classification */ export type PipeType = "endpoint" | "materialized" | "copy" | "pipe"; /** * Full pipe information from Tinybird API */ export interface PipeInfo { /** Pipe name */ name: string; /** Human-readable description */ description?: string; /** Nodes in the pipe */ nodes: PipeNode[]; /** Query parameters */ params: PipeParam[]; /** Pipe type */ type: PipeType; /** Endpoint configuration (if type is endpoint) */ endpoint?: { enabled: boolean; cache?: { enabled: boolean; ttl?: number; }; }; /** Materialized view configuration (if type is materialized) */ materialized?: { datasource: string; }; /** Copy pipe configuration (if type is copy) */ copy?: { target_datasource: string; copy_schedule?: string; copy_mode?: "append" | "replace"; }; /** Output column schema (for endpoints) */ output_columns: DatasourceColumn[]; } /** * Resource file type returned by pull operations */ export type ResourceFileType = "datasource" | "pipe" | "connection"; /** * Raw Tinybird datafile pulled from API */ export interface ResourceFile { /** Resource name (without extension) */ name: string; /** Resource kind */ type: ResourceFileType; /** Filename with extension */ filename: string; /** Raw datafile content */ content: string; } /** * Grouped resource files returned by pull operations */ export interface PulledResourceFiles { datasources: ResourceFile[]; pipes: ResourceFile[]; connections: ResourceFile[]; } /** * List all datasources in the workspace * * @param config - API configuration * @returns Array of datasource names */ export declare function listDatasources(config: WorkspaceApiConfig): Promise; /** * Get detailed information about a specific datasource * * @param config - API configuration * @param name - Datasource name * @returns Datasource information including schema and engine */ export declare function getDatasource(config: WorkspaceApiConfig, name: string): Promise; /** * List all pipes in the workspace * * @param config - API configuration * @returns Array of pipe names */ export declare function listPipes(config: WorkspaceApiConfig): Promise; /** * List all pipes from the v1 endpoint. * Falls back to v0 when v1 is unavailable. * * @param config - API configuration * @returns Array of pipe names */ export declare function listPipesV1(config: WorkspaceApiConfig): Promise; /** * Get a datasource as native .datasource text * * @param config - API configuration * @param name - Datasource name * @returns Raw .datasource content */ export declare function getDatasourceFile(config: WorkspaceApiConfig, name: string): Promise; /** * Get a pipe as native .pipe text * * @param config - API configuration * @param name - Pipe name * @returns Raw .pipe content */ export declare function getPipeFile(config: WorkspaceApiConfig, name: string): Promise; /** * List all connectors in the workspace * * @param config - API configuration * @returns Array of connector names */ export declare function listConnectors(config: WorkspaceApiConfig): Promise; /** * Get a connector as native .connection text * * @param config - API configuration * @param name - Connector name * @returns Raw .connection content */ export declare function getConnectorFile(config: WorkspaceApiConfig, name: string): Promise; /** * Get detailed information about a specific pipe * * @param config - API configuration * @param name - Pipe name * @returns Pipe information including nodes, params, and output schema */ export declare function getPipe(config: WorkspaceApiConfig, name: string): Promise; /** * Fetch all resources from a workspace * * @param config - API configuration * @returns All datasources and pipes with full details */ export declare function fetchAllResources(config: WorkspaceApiConfig): Promise<{ datasources: DatasourceInfo[]; pipes: PipeInfo[]; }>; /** * Pull all datasource/pipe/connector datafiles from a workspace * * @param config - API configuration * @returns Raw resource files grouped by type */ export declare function pullAllResourceFiles(config: WorkspaceApiConfig): Promise; /** * Check if a workspace has any resources * * @param config - API configuration * @returns True if the workspace has at least one datasource or pipe */ export declare function hasResources(config: WorkspaceApiConfig): Promise; //# sourceMappingURL=resources.d.ts.map