import { type CliConfig } from "./base.ts"; /** * A deeply partial `T` used for sparse config overlays; arrays are kept as whole units * rather than partialized element-wise. See `docs/adr/0018-sparse-config-subtraction.md`. */ export type DeepPartial = T extends ReadonlyArray ? T : T extends object ? { readonly [K in keyof T]?: DeepPartial; } : T; type ChildPaths = Paths extends readonly [infer Head, ...infer Rest] ? Head extends K ? K extends Head ? Rest : never : never : never; type IsPlainObject = T extends ReadonlyArray ? false : T extends object ? true : false; type IsEmptiedBy> = IsPlainObject extends true ? [keyof T] extends [never] ? false : [keyof OmitPaths] extends [never] ? true : false : false; /** `T` with every property addressed by a tuple in the `Paths` union removed, at any depth; arrays are left whole and a container emptied by the removal is removed too. */ export type OmitPaths> = [Paths] extends [never] ? T : T extends ReadonlyArray ? T : T extends object ? { [K in keyof T as [] extends ChildPaths ? never : IsEmptiedBy> extends true ? never : K]: OmitPaths>; } : T; export type SparseCliConfig = DeepPartial; /** * The comparison operand shape: a deeply partial {@link CliConfig} without `remotes`. * Every key an operand carries must hold its fully-resolved effective value; an absent key * means the operand doesn't speak for that field, not that the field is at its default. */ export type EffectiveConfig = DeepPartial>; /** * The default config: a {@link CliConfig} decoded from `{}`, so every value carries its * schema-declared default. Memoized and deeply frozen; the frozen result is reused as the * baseline for every {@link omitDefaultValues} call, so callers must not mutate it. */ export declare function getDefaultCliConfig(): CliConfig; /** * Recursively freezes `value` and returns it. Guards against revisiting an already-seen * object with a `WeakSet`, so it stays safe to call against cyclic or untrusted input. */ export declare function deepFreeze(value: T): T; /** * Defines `key` as an own data property. Guards against a `__proto__` key from user config * (a valid function name or remote label) being treated as the prototype setter by a plain * assignment, which would silently drop the entry or swap the target's prototype. */ export declare function setOwnProperty(target: Record, key: string, value: unknown): void; /** * Returns `value − baseline`, or `undefined` when nothing survives. A key missing from the * baseline is kept verbatim (so record entries like `remotes` pass through untouched); a * key present only in the baseline is ignored, since overlay absence means "inherit". */ export declare function subtractValue(value: unknown, baseline: unknown): unknown; /** * Returns the sparse config `config − baseline`. Directional: a value equal to the * baseline is removed even if it differs from the schema default, and kept otherwise. * * Both operands must be effective — every present key holds its fully-resolved value. A * standalone-decoded `[remotes.*]` block does not qualify: decoding it alone materializes * defaults it meant to inherit from the base config. See * `docs/adr/0018-sparse-config-subtraction.md`. */ export declare function subtractCliConfig(config: EffectiveConfig, baseline: EffectiveConfig): SparseCliConfig; /** * Returns the sparse config `config − default config`: only the values differing from * their schema defaults. The result re-decodes to the same effective config. * * Sparse only at the root: record-keyed entries (`functions.*`, `remotes.*`) survive * whole, with their own per-entry defaults materialized, so a consumer rendering the * result directly must strip those defaults itself. */ export declare function omitDefaultValues(config: EffectiveConfig): SparseCliConfig; export {}; //# sourceMappingURL=sparse.d.ts.map