/** * Assert that a key is not a prototype pollution vector. */ export declare function assertSafeKey(key: string, context: string): void; /** * Combined guard for user-supplied property names that will be persisted * or matched as node/relationship properties. Blocks prototype-pollution * names (`assertSafeKey`) THEN validates identifier shape * (`assertSafeIdentifier`) — mirroring the WhereCompiler convention. * * v1.8.7 — pre-1.8.7 the MutationCompiler validated identifier shape * only, so properties literally named `__proto__`/`constructor`/ * `prototype` (own properties via `JSON.parse` or computed keys) were * accepted and persisted to Neo4j. Reads through the OGM stay safe * (`Object.create(null)` in ResultMapper), but downstream consumers * doing `Object.assign({}, node)` would re-trigger setter semantics on * those names. Mutations now reject them, consistent with WHERE filters. */ export declare function assertSafePropertyName(name: string, context: string): void; /** * Validate that a string is a safe Cypher identifier. * Throws if the identifier contains characters that could enable Cypher injection. */ export declare function assertSafeIdentifier(value: string, context: string): void; /** * Escape an identifier for safe interpolation into Cypher queries. * Wraps in backticks and doubles any existing backticks inside. * This handles Cypher reserved words (ORDER, MATCH, SET, CALL, etc.) * since backtick-quoted identifiers bypass keyword interpretation. * * v1.8.0 fast path: identifiers in well-formed schemas effectively * never contain backticks. Skipping the regex-replace + intermediate * string allocation in that case shaves ~7ns per call. Multiplied by * the dozens of escapeIdentifier calls inside a single compile (every * relationship type, every label, every property name), it adds up at * high QPS. */ export declare function escapeIdentifier(identifier: string): string; /** * Validate a label name is a safe identifier and return it backtick-escaped. */ export declare function assertSafeLabel(label: string): string; /** * Validate sort direction is strictly ASC or DESC. */ export declare function assertSortDirection(direction: string): 'ASC' | 'DESC'; /** * Assert that a single `sort` array entry carries exactly one ordering key. * * v2.0.0 — pre-2.0.0 `compileSortClause` read only `Object.entries(entry)[0]` * and silently discarded the rest, so `[{ a: 'ASC', b: 'DESC' }]` compiled to * `ORDER BY n.a ASC` with no error and no log: a successful query answering a * different question. Which key survived depended purely on source insertion * order. * * Ordering precedence must be carried by ARRAY POSITION, never by object key * order. Honoring every key would only move the bug: graphql-js * `coerceInputValue` rebuilds input objects by iterating the schema's field * definitions, so the key order a client wrote is already gone by the time the * object reaches the OGM. * * Callers must validate each key with `assertSafeIdentifier` BEFORE calling * this, so the keys interpolated into the message are known-safe. */ export declare function assertSingleSortKey(entries: ReadonlyArray<[string, unknown]>): void; /** * Assert that a fulltext input object references exactly one index. * * v2.0.0 — the same silent-truncation defect fixed for `sort` (see * `assertSingleSortKey`) also lived in `FulltextCompiler`, at three sites that * each guarded the empty case and then read `Object.keys(input)[0]`. A leaf * naming two indexes searched only the first and dropped the second with no * error, so the query returned a strictly WIDER result set than asked for — a * filter that silently stops filtering. * * Multiple indexes are expressed with the existing `AND` / `OR` combinators, * which compile to correlated subqueries and `UNION` respectively. * * Phrase values are never echoed: they are user data and may carry control * characters or sensitive content. Callers must validate each key with * `assertSafeIdentifier` BEFORE calling this. */ export declare function assertSingleFulltextKey(entries: ReadonlyArray<[string, unknown]>, subject: string): void; /** * Assert that a fulltext input carrying `OR` / `AND` / `NOT` carries nothing * else alongside it. * * v2.0.0 — the dispatch in `FulltextCompiler.compileNode` tests the operators * in order (`OR`, then `AND`, then `NOT`) and returns on the first hit, so any * remaining top-level key was silently discarded: * * - `{ OR: [...], AND: [...] }` compiled the OR branch only. * - `{ OR: [...], SomeIndex: {...} }` compiled the OR branch only. * - `{ NOT: {...}, AND: [...] }` compiled the AND branch only — an exclusion * filter vanished entirely, which inverts the caller's intent rather than * merely widening the result set. * * Operators nest instead of stacking: `{ AND: [{ OR: [...] }, { ... }] }`. * * Only the recognised operator names — fixed literals — are interpolated into * the message. Sibling keys are counted, never echoed, because they have not * been identifier-validated at this point in the pipeline. */ export declare function assertSingleFulltextOperator(keys: readonly string[]): void; /** * Type guard that narrows an unknown value to a plain object. * Returns false for null, arrays, and non-object primitives. */ export declare function isPlainObject(value: unknown): value is Record; /** * Assert that a value the compilers are about to enumerate — with * `Object.entries`, `Object.keys`, or the `in` operator — is a plain object. * * v2.0.0 — without this, `sort: [null]` surfaced as a bare * `TypeError: Cannot convert undefined or null to object` thrown from deep * inside the compiler, and fulltext inputs failed similarly on `'OR' in input`. * Both escaped `catch (e) { if (e instanceof OGMError) … }`, even though every * other malformed input on those paths is an `OGMError`. * * Only the value's KIND is reported, never the value itself — the caller may * have handed us anything. */ export declare function assertPlainObject(value: unknown, subject: string): void; /** * Merge parameter records into the target. Skips merge if `source` is empty * or undefined. Returns the target for chaining. * * Use this instead of `Object.assign(params, result.params)` to keep call sites * declarative and centralize parameter accumulation logic. */ export declare function mergeParams(target: Record, source: Record | undefined): Record; /** * Assert that a `_MATCHES` regex pattern is provably free of catastrophic * backtracking. Throws `OGMError` on anything it cannot prove linear. Only * string values reach here; the value is already parameterized, so this is a * semantic guard on the operator, never string interpolation. */ export declare function assertSafeRegexPattern(pattern: string, context: string): void; //# sourceMappingURL=validation.d.ts.map