/** * Data-model primitives for the A2UI engine: RFC 6901 JSON Pointer get/set/delete * and the `resolveDynamic` union resolver. Pure TS, no Svelte. * * Security posture (this file is on the untrusted-payload path): * - `__proto__` / `constructor` / `prototype` are rejected at **every** pointer * segment — prototype pollution never reaches the model. * - Writes never merge or spread payload objects; they navigate and assign a * single leaf, creating intermediate containers explicitly. * - Array index deletion leaves a hole (length preserved), matching the spec's * sparse-array semantics. * * A2UI convention (deviation from strict RFC 6901): the pointers `''` **and** * `'/'` both address the whole model. Strict RFC treats `'/'` as the key `""`; * A2UI's `updateDataModel` uses `'/'` to mean "the entire data model", and no * A2UI payload ever addresses an empty-string key, so we honor the spec's own * convention here for ergonomics. */ import { type A2uiValidationIssue } from './a2ui.types.js'; /** Property names that must never be used as an object key on the write path. */ export declare const PROTO_KEYS: ReadonlySet; /** * Read the value at `pointer`. `''` / `'/'` return the whole model. Missing * paths, holes and type-mismatches resolve to `undefined` (never throw) — the * spec renders an empty string / skeleton for unresolved bindings. */ export declare function getAtPointer(model: unknown, pointer: string): unknown; /** * Write `value` at `pointer`, creating intermediate objects/arrays as needed. * The document root cannot be replaced through this function (the processor * assigns `dataModel` directly for whole-model updates); a root pointer returns * `ok: false`. Prototype-pollution segments are rejected with an issue. */ export declare function setAtPointer(model: unknown, pointer: string, value: unknown): { ok: boolean; issue?: A2uiValidationIssue; }; /** * Delete the leaf at `pointer`. Object keys are removed; array indices are * `delete`d in place (leaving a hole, preserving length). No-ops for missing * paths, non-container parents, and root pointers (the processor clears * `dataModel` directly for whole-model deletes). */ export declare function deleteAtPointer(model: unknown, pointer: string): void; /** * Resolve a Dynamic value union to a concrete value. * - `{ path }` (data binding) → the pointed-at model value (relative paths are * resolved against `scopePrefix`, the current template item). * - `{ call, ... }` (function call) → `undefined` + a warning (unsupported in v1). * - anything else (string/number/boolean/array/plain object) → returned as-is. * * Never throws; unresolved bindings yield `undefined` for graceful rendering. */ export declare function resolveDynamic(value: unknown, model: unknown, scopePrefix: string | undefined): { value: unknown; issue?: A2uiValidationIssue; }; /** * Deep-clone JSON data for ingest into the model, stripping any own * `__proto__`/`constructor`/`prototype` keys (harmless as own props, but never * addressable, so we drop them). Functions/symbols are dropped. Used by the * processor so that later two-way edits never mutate the source payload and no * prototype key ever enters the model. */ export declare function cloneData(value: unknown): unknown;