import type { LoggerLike } from "@formspec/core"; import type { FormSpecConfig, ConstraintConfig, ResolvedConstraintConfig } from "./types.js"; /** * Options for loading configuration. * * @public */ export interface LoadConfigOptions { /** * The directory to start searching from. * Defaults to process.cwd(). */ searchFrom?: string; /** * Explicit path to a config file. * If provided, skips file discovery entirely. */ configPath?: string; /** * Optional logger for diagnostic output. Defaults to a no-op logger so * existing callers produce no output. */ logger?: LoggerLike | undefined; } /** * Result when a config file was found and loaded. * * @public */ export interface LoadConfigFoundResult { /** The loaded configuration */ config: FormSpecConfig; /** The absolute path to the config file that was loaded */ configPath: string; /** Whether a config file was found */ found: true; } /** * Result when no config file was found. * * @public */ export interface LoadConfigNotFoundResult { /** Whether a config file was found */ found: false; } /** * Result of loading configuration. * * @public */ export type LoadConfigResult = LoadConfigFoundResult | LoadConfigNotFoundResult; /** * Loads FormSpec configuration from a TypeScript config file. * * Searches for `formspec.config.ts` (and `.mts`, `.js`, `.mjs` variants) * starting from `searchFrom` and walking up the directory tree. Stops at * the filesystem root or a workspace root (a directory with a package.json * containing a "workspaces" field). * * @param options - Options for loading configuration * @returns The loaded configuration, or `{ found: false }` if no config file exists * * @example * ```ts * // Discover config from current directory * const result = await loadFormSpecConfig(); * if (result.found) { * console.log(result.config, result.configPath); * } * * // Discover config from a specific directory * const result = await loadFormSpecConfig({ searchFrom: '/path/to/project' }); * * // Load a specific config file * const result = await loadFormSpecConfig({ configPath: '/path/to/formspec.config.ts' }); * ``` * * @public */ export declare function loadFormSpecConfig(options?: LoadConfigOptions): Promise; /** * Loads FormSpec constraint configuration from a config file. * Returns the resolved constraints with defaults applied. * * @deprecated Use `loadFormSpecConfig` instead, which returns the full `FormSpecConfig`. * * @param options - Options for loading configuration * @returns The loaded configuration with defaults applied * * @public */ export declare function loadConfig(options?: LoadConfigOptions): Promise<{ config: ResolvedConstraintConfig; configPath: string | null; found: boolean; }>; /** * Creates a constraint configuration directly from an object. * Useful for programmatic configuration without a config file. * * @param config - Partial constraint configuration * @returns Complete configuration with defaults applied * * @example * ```ts * const config = defineConstraints({ * fieldTypes: { * dynamicEnum: 'error', * dynamicSchema: 'error', * }, * layout: { * group: 'error', * }, * }); * ``` * * @public */ export declare function defineConstraints(config: ConstraintConfig): ResolvedConstraintConfig; //# sourceMappingURL=loader.d.ts.map