/** * Input resolver for omnify-ts. * * Accepts a `schemas.json` source spec and returns a local file path the * caller can read directly. Three source types are supported: * * - **Local** (path/relative path) — read directly from disk. * - **HTTP/HTTPS** (URL) — fetch, cache under `.omnify/cache/`, and pin * the SHA-256 hash in `.omnify/input.lock.json` for reproducible builds. * - **NPM** (package specifier like `@org/pkg/schemas.json`) — resolve via * Node module resolution from the consumer project's node_modules. * * Lockfile semantics (HTTP only): * - Default mode: re-fetch when the cache is stale, auto-update the * lockfile, and warn the user when the upstream hash changes so they * can review and commit the lockfile change. * - `--frozen-lockfile` mode: fail loudly if the lockfile is missing, * points at a different URL, or its hash differs from upstream. Use * this in CI to guarantee build reproducibility. * * Local and NPM specs do not need an omnify lockfile because: * - Local files are read every run; there is no fetch step that could * introduce drift. * - NPM packages are already version-pinned by `package-lock.json` / * `pnpm-lock.yaml` / `yarn.lock`. */ export type InputKind = 'local' | 'http' | 'npm'; export interface ResolveOptions { /** * Directory containing the omnify.yaml that declared the input. Used as * the base for resolving relative paths and as the root for the * `.omnify/cache/` and `.omnify/input.lock.json` files. */ configDir: string; /** * CI mode. When true, refuse to fetch if the lockfile is missing or its * hash doesn't match upstream. Caller should set this from * `--frozen-lockfile`. */ frozen?: boolean; /** * Force re-fetch even when the cache is valid and the lockfile matches. * Use this when the user explicitly asked for an update (e.g. * `omnify-ts --update`). */ forceUpdate?: boolean; } export interface ResolveResult { /** Absolute path to a local file the caller can read with fs APIs. */ localPath: string; kind: InputKind; /** SHA-256 of the resolved file. Always set for http/npm; set for local * too as a courtesy for diagnostics. */ sha256: string; } /** * Subset of the WHATWG fetch API used by the resolver. Injectable so tests * can stub it without monkey-patching globalThis. */ export interface HttpFetcher { (url: string): Promise<{ ok: boolean; status: number; statusText: string; text(): Promise; }>; } /** * Decide which kind of source a spec string is. Heuristic — explicit * prefixes win, ambiguous bare names default to local. Unscoped npm * packages are intentionally NOT supported because they collide with * relative path semantics; users should publish under a scope. */ export declare function sniffInputKind(spec: string): InputKind; /** * Resolve an input spec to a concrete local file path. Dispatches by kind: * local files are read directly, npm packages are resolved through Node * module resolution, and HTTP URLs are fetched, cached, and pinned in the * lockfile. * * The `fetcher` parameter is exposed only for tests; production callers * should leave it at the default (`globalThis.fetch`). */ export declare function resolveInput(spec: string, opts: ResolveOptions, fetcher?: HttpFetcher): Promise;