import type { VeryfrontConfig } from "./schemas/index.js"; import type { RuntimeAdapter } from "../platform/adapters/base.js"; import { type VirtualConfigSourceContext } from "../cache/keys.js"; import { type DeclarativeConfigFileName, type PreparedDeclarativeConfigContext } from "./declarative-evaluator.js"; import { evaluatePreparedDeclarativeConfigInWorker } from "./declarative-evaluator-worker-runner.js"; /** @internal Test-only tracking capacity. */ export declare function __getBunProjectConfigModuleTrackingCapacityForTests(): number; export type { VeryfrontConfig } from "./schemas/index.js"; export type ConfigLoadProvenance = Readonly<{ kind: "file"; configFile: DeclarativeConfigFileName; }> | Readonly<{ kind: "defaults"; }>; export interface ConfigLoadResult { readonly config: VeryfrontConfig; readonly provenance: ConfigLoadProvenance; } interface BunProjectDynamicImportObserver { readonly key: string; readonly dispose: () => void; } interface BunProjectConfigModuleCacheEntry { readonly cache: Record; readonly keys: readonly string[]; readonly projectDirectory: string; readonly dynamicImportObserver?: BunProjectDynamicImportObserver; } type HostedConfigEvaluator = typeof evaluatePreparedDeclarativeConfigInWorker; /** @internal Exported for tests: merges user config over fresh defaults (deep for nested objects). */ export declare function mergeConfigs(userConfig: Partial): VeryfrontConfig; /** @internal */ export declare function loadConfigFromTempFile(source: string, configPath: string, loadUrl: (tempFile: string) => string, rewriteSource?: (source: string) => Promise, bundleProjectImports?: boolean): Promise; /** @internal Test-only Bun async-module preflight seam. */ export declare function __bunConfigHasTopLevelAwaitForTests(source: string, configPath?: string): Promise; /** * Rewrite bare `veryfront` import specifiers to the inline config shim so * temp-file config modules can load. Static and literal dynamic imports are * rewritten; subpaths like * `veryfront/head` are left untouched and will fail loudly, which is correct — * they have no meaning in a config file. * * @internal exported for tests */ export declare function rewriteBareVeryfrontConfigImports(source: string): Promise; type ProjectConfigImportResolver = (specifier: string) => string | Promise; type UnresolvedDynamicProjectConfigImportResolver = (specifier: string, error: unknown) => string; type ResolvedProjectConfigImportObserver = (specifier: string) => void | Promise; /** @internal Rewrite staged imports with a resolver bound to their original project. */ export declare function rewriteProjectConfigImports(// NOSONAR: source rewrite control flow is lexer-driven and regression-covered. source: string, resolveSpecifier: ProjectConfigImportResolver, resolveUnresolvedDynamicSpecifier?: UnresolvedDynamicProjectConfigImportResolver, observeResolvedSpecifier?: ResolvedProjectConfigImportObserver): Promise; /** @internal Resolve staged config imports from the original project module root. */ export declare function rewriteProjectConfigImportsFromProject(source: string, configPath: string, observeResolvedSpecifier?: ResolvedProjectConfigImportObserver): Promise; /** @internal */ export declare function transpileConfigSourceForImport(source: string, configPath: string): Promise; interface DeferredConfigResolveError { readonly constructorName: "Error" | "TypeError" | "RangeError" | "SyntaxError"; readonly name: string; readonly message: string; readonly code?: string; readonly cause?: DeferredConfigResolveError | string | number | boolean | null; } /** @internal Test-only seam for deferred config resolver error serialization. */ export declare function __serializeConfigResolveErrorForTests(error: unknown): DeferredConfigResolveError; /** @internal */ export declare function __getNodeConfigPackageConditionsForTests(execArgv: readonly string[], nodeOptions: string | undefined, moduleCondition?: "import" | "require", moduleSync?: boolean): string[]; /** @internal */ export declare function __getNodeConfigBundleConditionsForTests(execArgv: readonly string[], nodeOptions: string | undefined, moduleSync?: boolean): string[]; /** @internal */ export declare function __resolveNodeConfigPackageTargetForTests(entry: unknown, conditions: readonly string[]): string | null; /** @internal Bundle a trusted local TypeScript config module graph for staged import. */ export declare function bundleProjectConfigSourceForImport(source: string, configPath: string): Promise; /** @internal Test-only dynamic import observer rewrite seam. */ export declare function __rewriteComputedDynamicProjectConfigImportsForTests(source: string, observerKey: string): Promise; /** @internal Test-only Bun project-module eviction seam. */ export declare function __evictBunProjectConfigModulesForTests(entry: Readonly<{ cache: Record; keys: readonly string[]; projectDirectory: string; }>): void; /** @internal Test-only Bun workspace-membership seam. */ export declare function __isBunWorkspaceMemberDirectoryForTests(workspaceRoot: string, projectDirectory: string, workspacesValue: unknown): boolean; /** @internal Test-only Bun project-module collection seam. */ export declare function __collectBunProjectConfigModulesForTests(input: Readonly<{ cache: Record; before?: ReadonlySet; eligibleKeys?: ReadonlySet; projectDirectory: string; includeAllNewModules?: boolean; }>): BunProjectConfigModuleCacheEntry; /** * Options for getConfig */ export interface GetConfigOptions { /** * Cache key for virtual filesystem (API-backed) projects. * When provided, this is used instead of projectDir for caching. * This should be a unique project identifier (e.g., projectId or projectSlug). */ cacheKey?: string; /** * Exact source selected by the trusted caller for a virtual filesystem read. * The source must match the active request context. Mutable branch sources * are never stored in the process-wide config cache. */ sourceContext?: VirtualConfigSourceContext; } /** * Internal server contract for untrusted hosted project configuration. * * This type is intentionally not re-exported from the public configuration * barrels. Hosted callers must establish project, source, and environment * identity before invoking the loader. */ export interface HostedConfigOptions { readonly cacheKey: string; readonly sourceContext: VirtualConfigSourceContext; readonly preparedContext: PreparedDeclarativeConfigContext; readonly signal?: AbortSignal; readonly validationBoundary?: (validate: () => VeryfrontConfig) => VeryfrontConfig; } /** * Authenticated source and environment binding for one hosted evaluation. * * A composition root derives this once from control-plane state and threads it * to every consumer of that request's configuration. Nothing downstream may * re-derive source or environment identity for itself. * * @internal */ export type PreparedHostedConfigContext = Pick; /** Exact declarative source selected by a trusted composition boundary. */ export type HostedConfigSource = Readonly<{ source: string; fileName: DeclarativeConfigFileName; }>; /** * Explicit context for evaluating one hosted configuration source. * * Callers must derive both the source and environment from authenticated * control-plane state. Passing `null` selects immutable framework defaults. */ export interface EvaluateHostedConfigSourceOptions { /** Trusted immutable source identity, including project and release. */ readonly cacheKey: string; readonly source: HostedConfigSource | null; readonly environmentName: string; readonly environment: unknown; readonly signal?: AbortSignal; } export declare function getConfig(projectDir: string, adapter: RuntimeAdapter, options?: GetConfigOptions): Promise; /** * Load trusted configuration together with the explicit source outcome. * * This is an internal composition boundary for callers that must distinguish * an absent config file from a present file whose values happen to match the * framework defaults. * * @internal */ export declare function getConfigWithProvenance(projectDir: string, adapter: RuntimeAdapter, options?: GetConfigOptions): Promise; /** * Load an untrusted hosted project config through the bounded declarative * evaluator. Server composition code must prepare the environment context * from authenticated tenant data before calling this function. * * @internal */ export declare function getHostedConfig(projectDir: string, adapter: RuntimeAdapter, options: HostedConfigOptions): Promise; /** * Evaluate an already-selected untrusted configuration source through the * bounded declarative worker and return the same validated, merged, deeply * frozen snapshot used by hosted request configuration. * * This seam exists for immutable-source jobs (for example release asset * builds) whose source bytes are selected outside the runtime filesystem. It * never imports or evaluates tenant JavaScript in the host realm. * * @internal */ export declare function evaluateHostedConfigSource(options: EvaluateHostedConfigSourceOptions): Promise; /** @internal Test-only evaluator seam. Passing `undefined` restores production behavior. */ export declare function __setHostedConfigEvaluatorForTests(evaluator?: HostedConfigEvaluator): void; /** * @internal Test-only seam for the captured Promise observer. This keeps * adversarial constructor/species coverage independent of unrelated awaits in * tracing and filesystem dependencies. */ export declare function __observePromiseForTests(promise: Promise): Promise; /** * @internal Test-only aggregate source-read admission state. Active reads * remain counted after their final waiter aborts until the adapter settles. */ export declare function __getHostedConfigSourceReadStateForTests(): Readonly<{ active: number; queued: number; flights: number; waiters: number; maxActive: number; maxQueued: number; }>; /** @internal Test-only aggregate state; does not expose project or source identities. */ export declare function __getHostedConfigFlightStateForTests(): Readonly<{ flights: number; waiters: number; }>; /** @internal Test-only aggregate state; does not expose config identities. */ export declare function __getTrustedConfigFlightStateForTests(): Readonly<{ flights: number; maxFlights: number; }>; export declare function clearConfigCache(): void; /** * Synchronous config cache lookup for hot paths. * * Returns cached config immediately without async overhead. * Use this for performance-critical paths when config is likely cached. * * @returns Cached config if valid, null if not cached or stale */ export declare function getCachedConfigSync(projectDir: string): VeryfrontConfig | null; //# sourceMappingURL=loader.d.ts.map