/** * Configuration loader for tinybird.json */ export type { DevMode, TinybirdConfig } from "./config-types.js"; import type { DevMode, TinybirdConfig } from "./config-types.js"; /** * Resolved configuration with all values expanded */ export interface ResolvedConfig { /** Array of file paths or glob patterns to scan for datasources and pipes */ include: string[]; /** Resolved API token (workspace main token) */ token: string; /** Tinybird API base URL */ baseUrl: string; /** Path to the config file */ configPath: string; /** Working directory */ cwd: string; /** Current git branch (null if not in git repo or detached HEAD) */ gitBranch: string | null; /** Sanitized branch name for Tinybird (symbols replaced with underscores) */ tinybirdBranch: string | null; /** Whether we're on the main/master branch */ isMainBranch: boolean; /** Development mode: "branch" or "local" */ devMode: DevMode; } /** * Local Tinybird base URL */ export declare const LOCAL_BASE_URL = "http://localhost:7181"; /** * Config file names in priority order * - tinybird.config.mjs: ESM config with dynamic logic * - tinybird.config.cjs: CommonJS config with dynamic logic * - tinybird.config.json: Standard JSON config (default for new projects) * - tinybird.json: Legacy JSON config (backward compatible) */ declare const CONFIG_FILES: readonly ["tinybird.config.mjs", "tinybird.config.cjs", "tinybird.config.json", "tinybird.json"]; type ConfigFileType = (typeof CONFIG_FILES)[number]; /** * Load .env files from a directory. * * Priority: * 1. .env.local * 2. .env * * Existing process.env values are preserved (dotenv default behavior). */ export declare function loadEnvFiles(directory: string): void; /** * Detect if project has a src folder */ export declare function hasSrcFolder(cwd: string): boolean; /** * Get the tinybird file path based on project structure * Returns 'src/lib/tinybird.ts' if project has src folder, otherwise 'lib/tinybird.ts' */ export declare function getTinybirdDir(cwd: string): string; /** * Get the relative tinybird file path based on project structure */ export declare function getRelativeTinybirdDir(cwd: string): string; /** * Get the datasources.ts path based on project structure */ export declare function getDatasourcesPath(cwd: string): string; /** * Get the pipes.ts path based on project structure */ export declare function getPipesPath(cwd: string): string; /** * Get the client.ts path based on project structure */ export declare function getClientPath(cwd: string): string; /** * Result of finding a config file */ export interface ConfigFileResult { /** Full path to the config file */ path: string; /** Type of config file found */ type: ConfigFileType; } /** * Find the config file by walking up the directory tree * Checks for all supported config file names in priority order * * @param startDir - Directory to start searching from * @returns Path and type of the config file, or null if not found */ export declare function findConfigFile(startDir: string): ConfigFileResult | null; /** * Load and resolve the Tinybird configuration * * Supports the following config file formats (in priority order): * - tinybird.config.mjs: ESM config with dynamic logic * - tinybird.config.cjs: CommonJS config with dynamic logic * - tinybird.config.json: Standard JSON config * - tinybird.json: Legacy JSON config (backward compatible) * * @param cwd - Working directory to start searching from (defaults to process.cwd()) * @returns Resolved configuration * * @example * ```ts * const config = loadConfig(); * console.log(config.include); // ['lib/tinybird.ts'] * console.log(config.token); // 'p.xxx' (resolved from ${TINYBIRD_TOKEN}) * ``` */ export declare function loadConfig(cwd?: string): ResolvedConfig; /** * Load and resolve the Tinybird configuration (async version) * * This async version supports all config file formats including JS files * that may contain dynamic logic. * * @param cwd - Working directory to start searching from (defaults to process.cwd()) * @returns Promise resolving to the configuration */ export declare function loadConfigAsync(cwd?: string): Promise; /** * Check if a config file exists in the given directory or its parents */ export declare function configExists(cwd?: string): boolean; /** * Get the path to an existing config file, or the default path for a new config * This is useful for the init command which needs to either update an existing config * or create a new one with the new default name */ export declare function getExistingOrNewConfigPath(cwd?: string): string; /** * Get the expected config file path for a directory * Returns the path for the default config file name (tinybird.config.json) */ export declare function getConfigPath(cwd?: string): string; /** * Find an existing config file in a directory * Returns the path to the first matching config file, or null if none found */ export declare function findExistingConfigPath(cwd?: string): string | null; /** * Update specific fields in a JSON config file * * Note: Only works with JSON config files (.json). For JS config files, * the user needs to update them manually. * * Throws an error if the config file doesn't exist to prevent creating * partial config files that would break loadConfig. * * @param configPath - Path to the config file * @param updates - Fields to update * @throws Error if config file doesn't exist or is not a JSON file */ export declare function updateConfig(configPath: string, updates: Partial): void; /** * Check if a valid token is configured (either in file or via env var) * * Note: For JS config files, this only works if the token is a static value * or environment variable reference in the file. * * @param cwd - Working directory to search from * @returns true if a valid token exists */ export declare function hasValidToken(cwd?: string): boolean; //# sourceMappingURL=config.d.ts.map