import { ENCODE_METHOD, DECODE_METHOD } from "../utils/encoder_symbols"; import type { AdkEncodableSnapshot } from "./encodable"; /** * A controlled-mutation key-value store with dot-path access and deep-clone isolation. * * @remarks * The registry enforces a safe read/write contract: callers never hold a live reference into * the internal store. Every value that enters (`set`) or leaves (`get`, `all`) is deep-cloned * via `klona`, so mutations to a retrieved value cannot affect stored state and vice versa. * * Keys are dot-delimited paths (e.g. `"user.profile.name"`), resolved via `dlv` for reads and * `dset` for writes; intermediate objects are created automatically on write. */ export declare class Registry { #private; /** * @param initial - Optional plain object to seed the registry. Deep-cloned on construction. * @throws {@link @nhtio/adk!E_INVALID_INITIAL_REGISTRY_VALUE} when `initial` is defined but not a plain object. */ constructor(initial?: Record); /** * Returns `true` if `value` is a {@link Registry} instance. * * @remarks * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety. * * @param value - The value to test. * @returns `true` when `value` is a {@link Registry} instance. */ static isRegistry(value: unknown): value is Registry; /** * Retrieves the value at `key`, returning `defaultValue` if the path is absent. * * @remarks * The returned value is a deep clone — mutating it will not affect the stored state. * * @typeParam T - Expected type of the value at `key`. * @param key - Dot-delimited path into the store (e.g. `"user.name"`). * @param defaultValue - Fallback returned when the path resolves to `undefined`. * @returns A deep clone of the stored value cast to `T`, or `defaultValue` when the path is absent. */ get(key: string, defaultValue?: T): T; /** * Sets the value at `key`, creating intermediate objects as needed. * * @remarks * The stored value is isolated from the caller — mutating `value` after this call will not * affect what is held in the registry. * * @param key - Dot-delimited path into the store (e.g. `"user.name"`). * @param value - Value to store at the path. */ set(key: string, value: unknown): void; /** * Returns `true` if the registry has a value at `key`, `false` otherwise. * * @remarks * A key resolving to `undefined` is treated as absent — same convention as {@link Registry.get}'s * `defaultValue` fallback. No clone is performed; this is a pure existence check. * * @param key - Dot-delimited path into the store (e.g. `"user.name"`). * @returns `true` when the path resolves to a value other than `undefined`. */ has(key: string): boolean; /** * Returns all leaf dot-paths present in the registry. * * @remarks * The store is deep-cloned before traversal. Plain objects are walked recursively with path * segments joined by dots; arrays, primitives, `null`, and class instances are treated as leaves. * * @returns A string array of dot-delimited paths to leaf values in the store. */ keys(): string[]; /** * Returns a deep clone of the entire store contents. * * @returns A plain object snapshot of all stored key-value pairs. */ all(): Record; /** * Serialise this Registry into an `@nhtio/encoder` snapshot. * * @remarks * The snapshot is a deep clone of the store ({@link Registry.all}). Leaf values that are themselves * registered encodable instances round-trip; anything the encoder cannot serialise throws at encode * time (standard encoder behaviour). Round-trips via {@link Registry.[DECODE_METHOD]}. * * @returns A deep-cloned plain-object snapshot of the store. */ [ENCODE_METHOD](): AdkEncodableSnapshot; /** * Reconstruct a {@link Registry} from a {@link Registry.[ENCODE_METHOD]} snapshot. * * @param data - The store snapshot produced by {@link Registry.[ENCODE_METHOD]}. * @returns A fresh {@link Registry} seeded with the snapshot. */ static [DECODE_METHOD](data: AdkEncodableSnapshot): Registry; }