/** * Measure serialized JSON object text in one linear pass, without decoding it. * * Approval RunState bounds are checked on text that is already in memory * (before a save) or already limited to its byte bound (after a read). This * scanner validates that text against the JSON grammar PostgreSQL's `jsonb` * input accepts and counts what `jsonb_path_query(value, 'strict $.**')` * would return, without building any objects. It replaces measuring the same * text inside PostgreSQL: `jsonb_path_query` materializes every result and * hands each one out with `list_delete_first`, which moves the rest of the * list, so counting n nodes there costs O(n^2) memory traffic regardless of * any LIMIT. A 200,000-element array took seconds of server CPU, and much * longer on hosts with slower memory. * * - `nodes` counts every JSON value, including the root, like `strict $.**`. * - `properties` counts every object member. * - Duplicate keys are counted each time they appear. `jsonb` keeps only the * last one, so these counts are never lower than what the database would * measure on the stored value; `JSON.stringify` never emits duplicates. * - `\u0000` and unpaired UTF-16 surrogate escapes are invalid here because * `jsonb` cannot store them; text containing them could be saved but never * decoded by the database again. * * Counts are zero unless the text is one valid JSON object. */ export type JsonObjectTextMeasurement = { validJsonObject: boolean; nodes: number; properties: number; }; export declare function measureJsonObjectText(text: string): JsonObjectTextMeasurement;