{"version":3,"file":"index.mjs","names":["EbecBaseError","isDetachedCondition","isPromiseLike"],"sources":["../src/utils/object.ts","../src/utils/mapping.ts","../src/utils/input.ts","../src/utils/key.ts","../src/utils/relation.ts","../src/utils/visitor.ts","../src/utils/property-name.ts","../src/constants.ts","../src/utils/parameter.ts","../src/errors/check.ts","../src/errors/code.ts","../src/errors/base.ts","../src/errors/adapter.ts","../src/errors/build.ts","../src/errors/codec.ts","../src/errors/issue/constants.ts","../src/errors/issue/module.ts","../src/errors/merge.ts","../src/errors/messages.ts","../src/errors/parse.ts","../src/errors/schema.ts","../src/parameter/fields/record/check.ts","../src/parameter/fields/record/module.ts","../src/parameter/fields/collection/check.ts","../src/schema/parameter/filters/constants.ts","../src/schema/indexes/module.ts","../src/schema/parameter/fields/constants.ts","../src/schema/base.ts","../src/schema/key-validatable.ts","../src/schema/parameter/fields/schema.ts","../src/schema/parameter/fields/define.ts","../src/schema/parameter/filters/schema.ts","../src/schema/parameter/filters/define.ts","../src/schema/parameter/pagination/schema.ts","../src/schema/parameter/pagination/define.ts","../src/schema/parameter/relations/schema.ts","../src/schema/parameter/relations/define.ts","../src/schema/parameter/sort/constants.ts","../src/schema/parameter/sort/schema.ts","../src/schema/parameter/sort/define.ts","../src/schema/parameter/sort/deprecated.ts","../src/schema/module.ts","../src/schema/registry/module.ts","../src/schema/resolver/constants.ts","../src/parser/parameter/fields/error.ts","../src/parser/parameter/filters/error.ts","../src/parser/parameter/pagination/error.ts","../src/parser/parameter/relations/error.ts","../src/parser/parameter/sort/error.ts","../src/parser/issue/constants.ts","../src/schema/resolver/module.ts","../src/schema/define.ts","../src/parameter/fields/collection/module.ts","../src/parameter/filters/collection/check.ts","../src/parameter/filters/condition.ts","../src/parameter/filters/collection/module.ts","../src/parameter/filters/constants.ts","../src/parameter/filters/record/check.ts","../src/parameter/filters/record/module.ts","../src/parameter/filters/helpers/module.ts","../src/parameter/filters/plan/constants.ts","../src/parameter/filters/plan/distribute.ts","../src/parameter/filters/regex.ts","../src/parameter/filters/plan/module.ts","../src/parameter/filters/preserve.ts","../src/parameter/pagination/check.ts","../src/parameter/pagination/pagination.ts","../src/parameter/relations/record/check.ts","../src/parameter/relations/record/module.ts","../src/parameter/relations/collection/check.ts","../src/parameter/relations/collection/module.ts","../src/parameter/sorts/record/check.ts","../src/parameter/sorts/record/module.ts","../src/parameter/sorts/collection/check.ts","../src/parameter/sorts/collection/module.ts","../src/parameter/check.ts","../src/parameter/module.ts","../src/parameter/merge.ts","../src/build/utils.ts","../src/build/parameter/fields/module.ts","../src/build/parameter/filters/value.ts","../src/build/parameter/filters/merge.ts","../src/build/parameter/filters/module.ts","../src/build/parameter/pagination/module.ts","../src/build/parameter/relations/module.ts","../src/build/parameter/sorts/module.ts","../src/build/module.ts","../src/parser/parameter/filters/validate.ts","../src/parser/parameter/validate.ts","../src/parser/issue/module.ts","../src/parser/base.ts","../src/parser/relation-prune.ts","../src/parser/index-policy.ts","../src/parser/query.ts"],"sourcesContent":["/*\n * Copyright (c) 2021-2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n/**\n * Check whether the input is a plain (non-array) object.\n */\nexport function isObject(item: unknown) : item is Record<string, any> {\n    return (\n        !!item &&\n        typeof item === 'object' &&\n        !Array.isArray(item)\n    );\n}\n\nexport function hasOwnProperty<\n    X extends Record<string, any>,\n    Y extends PropertyKey,\n>(obj: X, prop: Y): obj is X & Record<Y, unknown> {\n    return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\n/**\n * Check whether an own property is set on the given object.\n */\nexport function isPropertySet<X extends Record<string, any>, K extends keyof X>(\n    obj: X,\n    prop: K,\n) : boolean {\n    return hasOwnProperty(obj, prop);\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty } from './object';\n\nexport function applyMapping(\n    name: string,\n    map?: Record<string, string>,\n) {\n    if (typeof map === 'undefined') {\n        return name;\n    }\n\n    const keys = Object.keys(map);\n    if (keys.length === 0) {\n        return name;\n    }\n\n    let parts = name.split('.');\n\n    const output = [];\n    while (parts.length > 0) {\n        const value = parts.shift();\n        if (typeof value === 'undefined') {\n            break;\n        }\n\n        if (hasOwnProperty(map, value)) {\n            output.push(map[value]);\n        } else {\n            let found = false;\n\n            const rest : string[] = [];\n            const copy = [...parts];\n            while (copy.length > 0) {\n                const key = [value, ...copy].join('.');\n                if (hasOwnProperty(map, key)) {\n                    output.push(map[key]);\n                    found = true;\n                    break;\n                } else {\n                    const last = copy.pop();\n                    if (last) {\n                        rest.unshift(last);\n                    }\n                }\n            }\n\n            if (found) {\n                parts = rest;\n            } else {\n                output.push(value);\n            }\n        }\n    }\n\n    if (output.length === 0) {\n        return name;\n    }\n\n    return output.join('.');\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ObjectLiteral } from '../types';\nimport { isPropertySet } from './object';\n\n/**\n * Spellings that are not input keys but are close enough to be typed\n * by accident: the URL wire names (`filter`, `page`, `include`) and\n * obvious singulars. A mistyped key would otherwise be dropped, and a\n * dropped filter means unfiltered data rather than no data.\n */\nconst INPUT_KEY_SUGGESTIONS : Record<string, string> = {\n    field: 'fields',\n    filter: 'filters',\n    include: 'relations',\n    limit: 'pagination',\n    offset: 'pagination',\n    page: 'pagination',\n    relation: 'relations',\n};\n\nexport function suggestInputKey(key: string) : string | undefined {\n    return INPUT_KEY_SUGGESTIONS[key];\n}\n\n/**\n * Reject any top-level key the surface does not understand. Only for\n * developer-authored input (build input, schema options), never for\n * client input: a decoded URL legitimately carries unrelated keys.\n */\nexport function assertKnownInputKeys(\n    input: ObjectLiteral,\n    known: string[],\n    createError: (key: string, suggestion?: string) => Error,\n) : void {\n    const keys = Object.keys(input);\n\n    for (const key of keys) {\n        if (!known.includes(key)) {\n            throw createError(key, suggestInputKey(key));\n        }\n    }\n}\n\n/**\n * Read a canonical key or its deprecated alias. Supplying both with a\n * defined value each is a caller mistake, never a merge: the two spell\n * one parameter, and picking a winner would silently drop the other.\n * An `undefined` side (including one that is present but unset, e.g.\n * `{ sorts: undefined }` from a spread migration wrapper) never\n * triggers the ambiguity check, since there is nothing to drop.\n *\n * Presence is still checked as an OWN property (`isPropertySet`), not a\n * bare `typeof` read: a bare read walks the prototype chain, so an\n * array input would see `Array.prototype.sort` as a \"defined\" alias.\n */\nexport function resolveAliasedKey(\n    input: ObjectLiteral,\n    canonical: string,\n    alias: string,\n    createError: (canonical: string, alias: string) => Error,\n) : unknown {\n    const hasCanonical = isPropertySet(input, canonical) && typeof input[canonical] !== 'undefined';\n    const hasAlias = isPropertySet(input, alias) && typeof input[alias] !== 'undefined';\n\n    if (hasCanonical && hasAlias) {\n        throw createError(canonical, alias);\n    }\n\n    if (hasCanonical) {\n        return input[canonical];\n    }\n\n    if (hasAlias) {\n        return input[alias];\n    }\n\n    return undefined;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { pathToArray } from 'pathtrace';\n\nexport type KeyDetails = {\n    name: string,\n    group?: string,\n    path?: string\n};\n\nconst KEY_REGEX = /^(?:([0-9]+):)?((?:[a-zA-Z0-9-_]+\\.)*)([a-zA-Z0-9-_]+)$/;\n\n/**\n * Path segments that address an inherited `Object.prototype` member.\n * They match the permitted key pattern, so they have to be rejected\n * by name: a parser accumulates client-controlled path prefixes into\n * plain objects, and writing through one of these mutates the\n * prototype (or trips over an inherited member) instead of setting\n * a field.\n */\nconst UNSAFE_KEY_SEGMENTS = new Set(['__proto__', 'constructor', 'prototype']);\n\n/**\n * Check whether any segment of a (dotted) key path addresses an\n * inherited prototype member.\n */\nexport function isUnsafeKey(input: string) : boolean {\n    // the key grammar allows a leading numeric group (\"0:items.title\"),\n    // so it is stripped before the segments are checked: without this\n    // \"0:__proto__.x\" reads as a segment named \"0:__proto__\" and slips\n    // through.\n    const separatorIndex = input.indexOf(':');\n    const path = separatorIndex === -1 ?\n        input :\n        input.substring(separatorIndex + 1);\n\n    if (!path.includes('.')) {\n        return UNSAFE_KEY_SEGMENTS.has(path);\n    }\n\n    for (const segment of path.split('.')) {\n        if (UNSAFE_KEY_SEGMENTS.has(segment)) {\n            return true;\n        }\n    }\n\n    return false;\n}\n\n/**\n * Parse a raw key (\"[group:][path.]name\", e.g. \"0:items.title\")\n * into its group, relation path and leaf name.\n */\nexport function parseKey(\n    input: string,\n) : KeyDetails {\n    const matches = KEY_REGEX.exec(input);\n    if (!matches) {\n        return { name: input };\n    }\n\n    const [, group, path, key] = matches;\n\n    return {\n        group,\n        path: (path && path.at(-1) === '.' ? path.substring(0, path.length - 1) : path),\n        name: key ?? input,\n    };\n}\n\n/**\n * Serialize key details back into the \"[group:][path.]name\" form.\n */\nexport function stringifyKey(\n    key: KeyDetails,\n) : string {\n    return `${key.group ? `${key.group}:` : ''}${key.path ? `${key.path}.` : ''}${key.name}`;\n}\n\n/**\n * The canonical segments of a dotted key, as an {@link Issue} records them.\n *\n * `pathToArray` rather than `split('.')`, so a key whose segment carries an\n * escaped dot is not torn in half, and bracket indices survive. Segments are\n * stringified: an issue path is what a client reads back, not an accessor.\n */\nexport function toIssuePath(input: string) : string[] {\n    return pathToArray(input).map((segment) => String(segment));\n}\n","/*\n * Copyright (c) 2021-2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Relations } from '../parameter';\n\nexport function isPathAllowed(\n    path: string,\n    allowed?: Relations | string[],\n) : boolean {\n    if (typeof allowed === 'undefined') {\n        return true;\n    }\n\n    if (Array.isArray(allowed)) {\n        return allowed.includes(\n            path,\n        );\n    }\n\n    return allowed.value.some((include) => include.name === path);\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from './object';\n\n/**\n * Check whether the input is an AST node dispatching to the given\n * visitor method. Every built-in node using this guard performs double\n * dispatch to exactly one visit* method, so the dispatch target identifies\n * the node kind reliably across package instances (where instanceof\n * fails) and for structurally identical nodes (e.g. Fields & Sorts),\n * which member checks cannot tell apart.\n */\nexport function dispatchesTo<VISITOR>(\n    input: unknown,\n    method: keyof VISITOR & string,\n) : boolean {\n    if (\n        !isObject(input) ||\n        typeof input.accept !== 'function'\n    ) {\n        return false;\n    }\n\n    let output = false;\n\n    const visitor = {\n        [method]: () => {\n            output = true;\n        },\n    };\n\n    try {\n        input.accept(visitor);\n    } catch {\n        // a foreign node dispatches to a visit* method\n        // the probe visitor does not implement.\n    }\n\n    return output;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isPropertyNameValid(input: string): boolean {\n    return /^[a-zA-Z_][a-zA-Z0-9_]*$/gu.test(input);\n}\n","/*\n * Copyright (c) 2021-2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum Parameter {\n    FILTERS = 'filters',\n    FIELDS = 'fields',\n    PAGINATION = 'pagination',\n    RELATIONS = 'relations',\n    SORTS = 'sorts',\n    /**\n     * @deprecated use {@link Parameter.SORTS}. The value stays `sort`,\n     * so `parameters` masks and `describe()` output keep working.\n     * Removed in 3.0.\n     */\n    SORT = 'sort',\n}\n\n// -----------------------------------------------------------\n\nexport const DEFAULT_ID = '__DEFAULT__';\n\n// -----------------------------------------------------------\n\n/**\n * Shared upper bound for recursive traversal: schema relation\n * resolution, expression compound nesting and mongo document\n * nesting all consume this cap, so every dialect accepts and\n * rejects the same depth.\n */\nexport const MAX_TRAVERSAL_DEPTH = 32;\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { Parameter } from '../constants';\n\n/**\n * Fold the deprecated `sort` spelling onto the canonical `sorts`.\n * Applied wherever a caller-supplied parameter name is compared\n * against a list, so both spellings select the same parameter.\n */\nexport function normalizeParameter(input: string) : string {\n    return input === Parameter.SORT ? Parameter.SORTS : input;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { matchesInstanceof } from '@ebec/core';\nimport type { IBaseError, IParseError } from './types';\n\n/**\n * Cross-realm brands for the error hierarchy, mirroring `CONDITION_MARKER`.\n *\n * `instanceof` compares class identity, which two copies of `@rapiq/core` in\n * one process (mixed ESM/bundled builds, a dual-packaged dependency) do not\n * share. The failure mode is quiet and bad: a parse would rethrow a foreign\n * `ParseError` instead of recording it, and the trace would come back empty.\n *\n * `@ebec/core` owns the mechanism, which is the house standard and stronger\n * than one boolean per level: the markers form a CHAIN under one\n * non-enumerable `@instanceof` key, so a subclass is recognized as its\n * ancestors without marking itself twice, and the chain is serialized by\n * {@link BaseError.toJSON}, so `matchesInstanceof` also recognizes an\n * error that crossed a boundary as JSON and came back as a plain object.\n *\n * Only the brand utilities are borrowed. rapiq keeps its own `BaseError`,\n * interfaces and wire shape, and deliberately does NOT take ebec's error-group\n * mechanism (`errors: Error[]`): everything rapiq aggregates is a client-input\n * rejection, which is data, and lives in `issues`.\n */\nexport const BASE_ERROR_MARKER : unique symbol = Symbol.for('@rapiq/core/error');\n\nexport const PARSE_ERROR_MARKER : unique symbol = Symbol.for('@rapiq/core/error/parse');\n\n/**\n * Whether the value is an error this library raised.\n *\n * Prefer it to `instanceof BaseError` on any boundary a foreign copy of the\n * library, or a serialized error, could reach.\n */\nexport function isBaseError(input: unknown) : input is IBaseError {\n    return matchesInstanceof(input, BASE_ERROR_MARKER);\n}\n\n/**\n * Whether the value is a client-input failure.\n */\nexport function isParseError(input: unknown) : input is IParseError {\n    return matchesInstanceof(input, PARSE_ERROR_MARKER);\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum ErrorCode {\n    NONE = 'none',\n\n    /**\n     * One or more parts of the input were rejected. The code of an aggregated\n     * parse failure: what was rejected, and why, is in `error.issues`: a\n     * request can violate several policies at once, and naming one of them on\n     * the error would describe a subset of what went wrong.\n     */\n    INPUT_REJECTED = 'inputRejected',\n\n    INPUT_INVALID = 'inputInvalid',\n\n    SYNTAX_INVALID = 'syntaxInvalid',\n\n    KEY_INVALID = 'keyInvalid',\n\n    KEY_PATH_INVALID = 'keyPathInvalid',\n\n    KEY_NOT_ALLOWED = 'keyNotAllowed',\n\n    KEY_PATH_NOT_ALLOWED = 'keyPathNotAllowed',\n\n    KEY_VALUE_INVALID = 'keyValueInvalid',\n\n    KEY_VALIDATE_REJECTED = 'keyValidateRejected',\n\n    KEY_UNKNOWN = 'keyUnknown',\n\n    KEY_AMBIGUOUS = 'keyAmbiguous',\n\n    KEY_COMBINATION_NOT_INDEXED = 'keyCombinationNotIndexed',\n\n    LIMIT_EXCEEDED = 'limitExceeded',\n\n    OPERATOR_UNSUPPORTED = 'operatorUnsupported',\n\n    FEATURE_UNSUPPORTED = 'featureUnsupported',\n\n    FIELDS_CONDITION_DISCARDED = 'fieldsConditionDiscarded',\n\n    CONDITION_DETACHED = 'conditionDetached',\n\n    CODEC_UNRESOLVABLE = 'codecUnresolvable',\n\n    SCHEMA_ENTITY_INDEX_MISMATCH = 'schemaEntityIndexMismatch',\n\n    SCHEMA_ENTITY_MISMATCH = 'schemaEntityMismatch',\n\n    SCHEMA_KEY_VALIDATOR_CONFLICT = 'schemaKeyValidatorConflict',\n\n    SCHEMA_NAME_INVALID = 'schemaNameInvalid',\n\n    SCHEMA_PRESERVED_CONDITION_PRUNED = 'schemaPreservedConditionPruned',\n\n    SCHEMA_UNRESOLVABLE = 'schemaUnresolvable',\n\n    SCHEMA_VALIDATOR_ASYNC_REQUIRES_ASYNC_PARSER = 'schemaValidatorAsyncRequiresAsyncParser',\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BaseError as EbecBaseError, markInstanceof } from '@ebec/core';\nimport type { Issue } from 'blemish';\nimport { BASE_ERROR_MARKER } from './check';\nimport { ErrorCode } from './code';\nimport type { BaseErrorOptions, IBaseError, SerializedError } from './types';\n\nfunction serializeIssue(input: Issue) : Issue {\n    const output = { ...input };\n    if (output.type === 'group') {\n        output.issues = output.issues.map(serializeIssue);\n    } else {\n        delete output.expected;\n        delete output.received;\n    }\n\n    return output;\n}\n\n/**\n * The root of rapiq's error hierarchy.\n *\n * Extends `@ebec/core`'s, the house error substrate, for everything an error\n * base does the same way everywhere: the class name, the stack capture, the\n * `code`, the `cause` passthrough and the brand chain. rapiq adds the one\n * thing that is its own, the trace, and narrows `code` to its vocabulary.\n *\n * What it does NOT take is the group half. `errors: Error[]` stays unset,\n * because everything rapiq aggregates is a client-input rejection, which is\n * data and lives in {@link issues}; minting an `Error` per rejected key is the\n * carrier this design exists to avoid.\n */\nexport class BaseError extends EbecBaseError implements IBaseError {\n    /**\n     * Every rejection the operation recorded, in the order it hit them.\n     * Empty unless the operation collected a trace.\n     *\n     * An ordinary enumerable property, so it shows up when the error is\n     * inspected or spread. The cost, chosen deliberately: deep equality reads\n     * enumerable properties, so two failures of the same kind compare equal\n     * only when their traces match: `toThrow(SomeError.keyNotPermitted('x'))`\n     * asserts the trace too. Assert the class or the code, or reach into\n     * `issues`, rather than comparing whole errors.\n     */\n    public readonly issues : readonly Issue[];\n\n    constructor(input: BaseErrorOptions | string) {\n        // both forms default the code to NONE: left to the base, a bare\n        // message would get the class name as its code, a value outside\n        // rapiq's vocabulary.\n        const options : BaseErrorOptions = typeof input === 'string' ?\n            { message: input } :\n            input;\n\n        super({ ...options, code: options.code || ErrorCode.NONE });\n\n        this.issues = options.issues ?? [];\n\n        markInstanceof(this, BASE_ERROR_MARKER);\n    }\n\n    /**\n     * The wire form: the base's, plus the one thing rapiq adds.\n     *\n     * An error whose trace does not survive the boundary has nothing to say on\n     * the far side, and the `@instanceof` chain the base emits is what lets\n     * `isParseError` answer for the plain object that arrives.\n     */\n    override toJSON() : SerializedError {\n        return {\n            ...super.toJSON(),\n            issues: this.issues.map(serializeIssue),\n        } as SerializedError;\n    }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '../utils';\nimport { BaseError } from './base';\nimport { ErrorCode } from './code';\nimport type { BaseErrorOptions } from './types';\n\nexport type AdapterErrorOptions = BaseErrorOptions & {\n    /**\n     * The capability tag {@link AdapterError.featureUnsupported} refuses\n     * (e.g. `regexp`, `filters:mod`, `filters:regex`), structured\n     * alongside `code` so a consumer can build a capability matrix\n     * without parsing the message. `undefined` for every other factory.\n     */\n    feature?: string,\n};\n\nexport class AdapterError extends BaseError {\n    public readonly feature : string | undefined;\n\n    constructor(message?: string | AdapterErrorOptions) {\n        if (isObject(message)) {\n            message.message = message.message || 'An adapter error has occurred.';\n        }\n\n        super(message || 'An adapter error has occurred.');\n\n        this.feature = isObject(message) ? message.feature : undefined;\n    }\n\n    static operatorUnsupported(operator: string) {\n        return new this({\n            message: `The filter operator ${operator} is not supported.`,\n            code: ErrorCode.OPERATOR_UNSUPPORTED,\n        });\n    }\n\n    /**\n     * A condition the built-in consumer cannot lower: either a live custom\n     * implementation that needs its own consumer or detached transport data\n     * that lost its behavior. Dropping it would silently widen the result set.\n     */\n    static conditionDetached(operator?: string) {\n        return new this({\n            message: `The condition${operator ? ` (${operator})` : ''} cannot be lowered by this built-in consumer. ` +\n                'A custom condition needs a compatible consumer; detached transport data must be rebuilt ' +\n                'with the condition helpers (eq, and, or, …) before passing it to an adapter.',\n            code: ErrorCode.CONDITION_DETACHED,\n        });\n    }\n\n    static featureUnsupported(feature: string) {\n        return new this({\n            message: `The feature ${feature} is not supported by the dialect.`,\n            code: ErrorCode.FEATURE_UNSUPPORTED,\n            feature,\n        });\n    }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '../utils';\nimport { BaseError } from './base';\nimport { ErrorCode } from './code';\nimport type { BaseErrorOptions } from './types';\n\nexport class BuildError extends BaseError {\n    constructor(message?: string | BaseErrorOptions) {\n        if (isObject(message)) {\n            message.message = message.message || 'A building error has occurred.';\n        }\n\n        super(message || 'A building error has occurred.');\n    }\n\n    static inputInvalid() {\n        return new this({\n            message: 'The shape of the input is not valid.',\n            code: ErrorCode.INPUT_INVALID,\n        });\n    }\n\n    static keyInvalid(key: string) {\n        return new this({\n            message: `The key ${key} is invalid.`,\n            code: ErrorCode.KEY_INVALID,\n        });\n    }\n\n    static keyValueInvalid(key: string) {\n        return new this({\n            message: `The value of the key ${key} is invalid.`,\n            code: ErrorCode.KEY_VALUE_INVALID,\n        });\n    }\n\n    static operatorUnsupported(operator: string) {\n        return new this({\n            message: `The operator ${operator} is not supported.`,\n            code: ErrorCode.OPERATOR_UNSUPPORTED,\n        });\n    }\n\n    static keyUnknown(key: string, suggestion?: string) {\n        return new this({\n            message: suggestion ?\n                `The key ${key} is unknown. Did you mean ${suggestion}?` :\n                `The key ${key} is unknown.`,\n            code: ErrorCode.KEY_UNKNOWN,\n        });\n    }\n\n    static keyAmbiguous(canonical: string, alias: string) {\n        return new this({\n            message: `The keys ${canonical} and ${alias} are two spellings of the ` +\n                `same parameter. Use ${canonical}.`,\n            code: ErrorCode.KEY_AMBIGUOUS,\n        });\n    }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '../utils';\nimport { BaseError } from './base';\nimport { ErrorCode } from './code';\nimport type { BaseErrorOptions } from './types';\n\nexport class CodecError extends BaseError {\n    constructor(message?: string | BaseErrorOptions) {\n        if (isObject(message)) {\n            message.message = message.message || 'A codec error has occurred.';\n        }\n\n        super(message || 'A codec error has occurred.');\n    }\n\n    static notResolvable(name?: string) {\n        return new this({\n            message: name ?\n                `The codec ${name} could not be resolved.` :\n                'No codec could be resolved.',\n            code: ErrorCode.CODEC_UNRESOLVABLE,\n        });\n    }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n/**\n * Upper bound of leaf issues one parse records. Hostile input can violate a\n * policy once per key, and the trace is a diagnostic, not a transcript: what\n * the parse raises (`INPUT_REJECTED`, as the parse that failed) does not\n * depend on how many rejections it holds, so a truncated tail changes nothing\n * about the outcome.\n */\nexport const MAX_ISSUES = 100;\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { defineIssueItem } from 'blemish';\nimport type { Issue, IssueItem } from 'blemish';\nimport type { Parameter } from '../../constants';\nimport { normalizeParameter } from '../../utils';\nimport type { IssueInput } from './types';\n\n/**\n * Build the issue a rapiq site reports.\n *\n * The parameter is normalized here, at the one point where it is still\n * typed: past this call it lives in blemish's open `meta` bag, where the\n * deprecated `sort` spelling would survive unnoticed.\n */\nexport function buildIssue(input: IssueInput) : IssueItem {\n    const meta : Record<string, unknown> = {};\n    if (input.parameter) {\n        meta.parameter = normalizeParameter(input.parameter) as `${Parameter}`;\n    }\n\n    if (typeof input.key !== 'undefined') {\n        meta.key = input.key;\n    }\n\n    const output = defineIssueItem({\n        code: input.code,\n        path: input.path,\n        message: input.message,\n    });\n\n    if (Object.keys(meta).length > 0) {\n        output.meta = meta;\n    }\n\n    if (Object.hasOwn(input, 'received')) {\n        output.received = input.received;\n    }\n\n    return output;\n}\n\n/**\n * The parameter that owns the policy an issue reports, or undefined for an\n * issue no single parameter owns.\n *\n * `meta` is an open bag by design (issues cross library boundaries), so the\n * read is narrowed here once rather than at every consumer.\n */\nexport function extractIssueParameter(input: Issue) : `${Parameter}` | undefined {\n    const value = input.meta?.parameter;\n\n    return typeof value === 'string' ?\n        value as `${Parameter}` :\n        undefined;\n}\n\n/**\n * The raw client key an issue was recorded for, when it differs from the\n * canonical (alias-resolved) path.\n */\nexport function extractIssueKey(input: Issue) : string | undefined {\n    const value = input.meta?.key;\n\n    return typeof value === 'string' ? value : undefined;\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '../utils';\nimport { BaseError } from './base';\nimport { ErrorCode } from './code';\nimport type { BaseErrorOptions } from './types';\n\nexport class MergeError extends BaseError {\n    constructor(message?: string | BaseErrorOptions) {\n        if (isObject(message)) {\n            message.message = message.message || 'A merging error has occurred.';\n        }\n\n        super(message || 'A merging error has occurred.');\n    }\n\n    static fieldsConditionDiscarded(name: string) {\n        return new this({\n            message: `Merging fields would discard the visibility condition on \"${name}\". ` +\n                'A gated field cannot be displaced; keep the gated query as the receiver or remove the colliding field first.',\n            code: ErrorCode.FIELDS_CONDITION_DISCARDED,\n        });\n    }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n/**\n * The message text of every client-input failure, as pure builders.\n *\n * A failure surfaces through two channels, a thrown {@link ParseError} and a\n * plain-data {@link Issue}, and both must read identically: an aggregated\n * error is rebuilt from its issue, so a divergence here would change a thrown\n * message depending on the failure policy. Building the text without\n * constructing an `Error` also keeps the drop-mode trace free of stack capture.\n */\nexport const ErrorMessage = {\n    inputInvalid: () => 'The shape of the input is not valid.',\n\n    inputRejected: (count: number) => (count === 1 ?\n        'The input was rejected: 1 violation.' :\n        `The input was rejected: ${count} violations.`),\n\n    syntaxInvalid: (details?: string) => (details ?\n        `The input syntax is invalid: ${details}` :\n        'The input syntax is invalid.'),\n\n    keyNotPermitted: (name: string) => `The key ${name} is not permitted.`,\n\n    keyInvalid: (key: string) => `The key ${key} is invalid.`,\n\n    keyPathInvalid: (key: string) => `The key path ${key} is invalid.`,\n\n    keyPathNotPermitted: (key: string) => `The key path ${key} is not permitted.`,\n\n    keyValueInvalid: (key: string) => `The value of the key ${key} is invalid.`,\n\n    keyValidateRejected: (key: string) => `The key ${key} was rejected by the schema validator.`,\n\n    keyCombinationNotIndexed: (keys: string[]) => `The key combination ${keys.join(', ')} is not indexed.`,\n\n    operatorUnsupported: (operator: string) => `The operator ${operator} is not supported.`,\n\n    featureUnsupported: (feature: string) => `The feature ${feature} is not supported.`,\n\n    keyAmbiguous: (canonical: string, alias: string) => `The keys ${canonical} and ${alias} are two spellings of the ` +\n        `same parameter. Use ${canonical}.`,\n\n    limitExceeded: (limit: number) => `The pagination limit must not exceed the value of ${limit}.`,\n} as const;\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '../utils';\nimport { BaseError } from './base';\nimport { markInstanceof } from '@ebec/core';\nimport { PARSE_ERROR_MARKER } from './check';\nimport { ErrorCode } from './code';\nimport { ErrorMessage } from './messages';\nimport { flattenIssueItems } from 'blemish';\nimport type { Issue } from 'blemish';\nimport type { BaseErrorOptions, IParseError } from './types';\n\nexport class ParseError extends BaseError implements IParseError {\n    constructor(message?: string | BaseErrorOptions) {\n        if (isObject(message)) {\n            message.message = message.message || 'A parsing error has occurred.';\n        }\n\n        super(message || 'A parsing error has occurred.');\n\n        markInstanceof(this, PARSE_ERROR_MARKER);\n    }\n\n    /**\n     * The failure an aggregated parse raises: every violation it found, on\n     * `issues`. Deliberately NOT the first violation's own class and code:\n     * a parse that rejected keys in four parameters would then advertise one\n     * of them, and a consumer branching on that would act on a subset of what\n     * went wrong. The specific classes stay what a single violation throws\n     * where no trace is collecting.\n     *\n     * A structural abort caught on the way is not carried either: only branded\n     * parse errors are ever caught (a server bug propagates untouched), and\n     * everything a client-input failure knows is already in its issue.\n     */\n    static inputRejected(issues: readonly Issue[]) {\n        return new this({\n            message: ErrorMessage.inputRejected(flattenIssueItems([...issues]).length),\n            code: ErrorCode.INPUT_REJECTED,\n            issues,\n        });\n    }\n\n    static inputInvalid() {\n        return new this({\n            message: ErrorMessage.inputInvalid(),\n            code: ErrorCode.INPUT_INVALID,\n        });\n    }\n\n    static syntaxInvalid(details?: string) {\n        return new this({\n            message: ErrorMessage.syntaxInvalid(details),\n            code: ErrorCode.SYNTAX_INVALID,\n        });\n    }\n\n    static keyNotPermitted(name: string, issues: readonly Issue[] = []) {\n        return new this({\n            message: ErrorMessage.keyNotPermitted(name),\n            code: ErrorCode.KEY_NOT_ALLOWED,\n            issues,\n        });\n    }\n\n    static keyInvalid(key: string, issues: readonly Issue[] = []) {\n        return new this({\n            message: ErrorMessage.keyInvalid(key),\n            code: ErrorCode.KEY_INVALID,\n            issues,\n        });\n    }\n\n    static keyPathInvalid(key: string, issues: readonly Issue[] = []) {\n        return new this({\n            message: ErrorMessage.keyPathInvalid(key),\n            code: ErrorCode.KEY_PATH_INVALID,\n            issues,\n        });\n    }\n\n    static keyPathNotPermitted(key: string, issues: readonly Issue[] = []) {\n        return new this({\n            message: ErrorMessage.keyPathNotPermitted(key),\n            code: ErrorCode.KEY_PATH_NOT_ALLOWED,\n            issues,\n        });\n    }\n\n    static keyValueInvalid(key: string) {\n        return new this({\n            message: ErrorMessage.keyValueInvalid(key),\n            code: ErrorCode.KEY_VALUE_INVALID,\n        });\n    }\n\n    static keyValidateRejected(key: string, issues: readonly Issue[] = []) {\n        return new this({\n            message: ErrorMessage.keyValidateRejected(key),\n            code: ErrorCode.KEY_VALIDATE_REJECTED,\n            issues,\n        });\n    }\n\n    static keyCombinationNotIndexed(keys: string[]) {\n        return new this({\n            message: ErrorMessage.keyCombinationNotIndexed(keys),\n            code: ErrorCode.KEY_COMBINATION_NOT_INDEXED,\n        });\n    }\n\n    static operatorUnsupported(operator: string) {\n        return new this({\n            message: ErrorMessage.operatorUnsupported(operator),\n            code: ErrorCode.OPERATOR_UNSUPPORTED,\n        });\n    }\n\n    static featureUnsupported(feature: string) {\n        return new this({\n            message: ErrorMessage.featureUnsupported(feature),\n            code: ErrorCode.FEATURE_UNSUPPORTED,\n        });\n    }\n\n    static keyAmbiguous(canonical: string, alias: string) {\n        return new this({\n            message: ErrorMessage.keyAmbiguous(canonical, alias),\n            code: ErrorCode.KEY_AMBIGUOUS,\n        });\n    }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '../utils';\nimport { BaseError } from './base';\nimport { ErrorCode } from './code';\nimport type { BaseErrorOptions } from './types';\n\nexport class SchemaError extends BaseError {\n    constructor(message?: string | BaseErrorOptions) {\n        if (isObject(message)) {\n            message.message = message.message || 'A schema error has occurred.';\n        }\n\n        super(message || 'A schema error has occurred.');\n    }\n\n    static nameUndefined() {\n        return new this({\n            message: 'The schema name is not defined.',\n            code: ErrorCode.SCHEMA_NAME_INVALID,\n        });\n    }\n\n    static notResolvable(name: string) {\n        return new this({\n            message: `The schema \"${name}\" could not be resolved.`,\n            code: ErrorCode.SCHEMA_UNRESOLVABLE,\n        });\n    }\n\n    static keyValidatorConflict(parameter: string) {\n        return new this({\n            message: `The ${parameter} schema declares both validate and validateMany.`,\n            code: ErrorCode.SCHEMA_KEY_VALIDATOR_CONFLICT,\n        });\n    }\n\n    static preservedConditionPruned(relation: string, field: string) {\n        return new this({\n            message: `The relations validator rejected \"${relation}\", but the preserved filter condition on ` +\n                `\"${field}\" traverses it. A preserved condition must not be dropped, and a rejected relation ` +\n                'must not be joined: align the relations validator with the filters validator that preserved it.',\n            code: ErrorCode.SCHEMA_PRESERVED_CONDITION_PRUNED,\n        });\n    }\n\n    static preservedConditionNotIndexed(keys: string[]) {\n        return new this({\n            message: `The filter combination ${keys.join(', ')} violates the index policy, but the tree carries ` +\n                'a preserved condition that must not be dropped: let the validator residual anchor a declared ' +\n                'index, or enable throwOnFailure to reject the request instead.',\n            code: ErrorCode.SCHEMA_PRESERVED_CONDITION_PRUNED,\n        });\n    }\n\n    static validatorAsyncRequiresAsyncParser() {\n        return new this({\n            message: 'Asynchronous schema validators require parseAsync().',\n            code: ErrorCode.SCHEMA_VALIDATOR_ASYNC_REQUIRES_ASYNC_PARSER,\n        });\n    }\n\n    static keyUnknown(key: string, suggestion?: string) {\n        return new this({\n            message: suggestion ?\n                `The schema key ${key} is unknown. Did you mean ${suggestion}?` :\n                `The schema key ${key} is unknown.`,\n            code: ErrorCode.KEY_UNKNOWN,\n        });\n    }\n\n    static keyAmbiguous(canonical: string, alias: string) {\n        return new this({\n            message: `The schema keys ${canonical} and ${alias} are two spellings of ` +\n                `the same parameter. Use ${canonical}.`,\n            code: ErrorCode.KEY_AMBIGUOUS,\n        });\n    }\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { dispatchesTo } from '../../../utils';\nimport type { IField, IFieldVisitor } from './types';\n\n/**\n * A `Field` record is identified by its visitor dispatch: accept() of a\n * field node calls visitField and nothing else. Works across package\n * instances, where instanceof fails, and distinguishes the structurally\n * overlapping record nodes (Field, Sort, Relation).\n */\nexport function isField(input: unknown) : input is IField {\n    return dispatchesTo<IFieldVisitor<unknown>>(input, 'visitField');\n}\n","/*\n * Copyright (c) 2025-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ICondition } from '../../filters';\nimport type { IField, IFieldVisitor } from './types';\n\nexport class Field implements IField {\n    readonly name: string;\n\n    readonly operator: string | undefined;\n\n    readonly condition: ICondition | undefined;\n\n    constructor(name: string, operator?: string, condition?: ICondition) {\n        this.name = name;\n        this.operator = operator;\n        this.condition = condition;\n    }\n\n    accept<R>(visitor: IFieldVisitor<R>): R {\n        return visitor.visitField(this);\n    }\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { dispatchesTo } from '../../../utils';\nimport type { IFields, IFieldsVisitor } from './types';\n\n/**\n * A `Fields` collection is identified by its visitor dispatch: accept()\n * of a fields node calls visitFields and nothing else. Works across\n * package instances, where instanceof fails, and distinguishes the\n * structurally identical collection nodes (Fields, Sorts, ...).\n */\nexport function isFields(input: unknown) : input is IFields {\n    return dispatchesTo<IFieldsVisitor<unknown>>(input, 'visitFields');\n}\n\n/**\n * Whether any field of the selection carries a visibility condition\n * (see `IField.condition`). The gate is only applied while projecting\n * by `@rapiq/adapter-memory`; the SQL backends fetch the column for every row\n * and rely on the consumer running the fetched rows through\n * `applyFieldConditions` before serializing them. This is the check a\n * response path can assert on to guarantee no gated column ships\n * unredacted.\n */\nexport function hasFieldConditions(input: IFields | { fields: IFields }) : boolean {\n    const fields = isFields(input) ? input : input.fields;\n\n    return fields.value.some(\n        (field) => typeof field.condition !== 'undefined',\n    );\n}\n","/*\n * Copyright (c) 2022-2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum FilterFieldOperator {\n    EQUAL = 'eq',\n    NOT_EQUAL = 'ne',\n\n    LESS_THAN_EQUAL = 'lte',\n    LESS_THAN = 'lt',\n\n    GREATER_THAN_EQUAL = 'gte',\n    GREATER_THAN = 'gt',\n\n    IN = 'in',\n    NOT_IN = 'nin',\n\n    STARTS_WITH = 'startsWith',\n    NOT_STARTS_WITH = 'notStartsWith',\n\n    ENDS_WITH = 'endsWith',\n    NOT_ENDS_WITH = 'notEndsWith',\n\n    CONTAINS = 'contains',\n    NOT_CONTAINS = 'notContains',\n\n    REGEX = 'regex',\n\n    MOD = 'mod',\n    SIZE = 'size',\n    EXISTS = 'exists',\n    ELEM_MATCH = 'elemMatch',\n}\n\nexport enum FilterCompoundOperator {\n    AND = 'and',\n    OR = 'or',\n    NOT = 'not',\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isFilter, isFilters } from '../../parameter';\nimport type { ICondition, IFilter } from '../../parameter';\nimport { parseKey } from '../../utils';\nimport { FilterCompoundOperator } from '../parameter/filters/constants';\nimport type {\n    IndexCheckResult,\n    IndexedMode,\n    IndexesResolver,\n} from './types';\n\ntype NodeVerdict = {\n    pass: boolean,\n    /**\n     * The subtree guarantees index-backed narrowing on its own. An OR\n     * only anchors when every branch does; a skipped (custom) condition\n     * never does.\n     */\n    anchors: boolean,\n    /**\n     * Nothing checkable inside (custom conditions, empty groups): the\n     * node passes vacuously and never satisfies an anchor requirement.\n     */\n    skipped: boolean,\n    violation?: { path: string, keys: string[] },\n};\n\nfunction leafTarget(field: string) : { path: string, name: string } {\n    const details = parseKey(field);\n\n    return { path: details.path ?? '', name: details.name };\n}\n\nfunction leafAnchors(leaf: IFilter, resolve: IndexesResolver) : boolean {\n    const { path, name } = leafTarget(leaf.field);\n    const indexes = resolve(path);\n    if (!indexes) {\n        return false;\n    }\n\n    return indexes.some((index) => index[0] === name);\n}\n\nfunction coversGroup(keys: string[], indexes: string[][] | null) : boolean {\n    if (!indexes) {\n        return false;\n    }\n\n    const set = new Set(keys);\n\n    return indexes.some((index) => {\n        if (set.size > index.length) {\n            return false;\n        }\n\n        for (let i = 0; i < set.size; i++) {\n            if (!set.has(index[i] as string)) {\n                return false;\n            }\n        }\n\n        return true;\n    });\n}\n\nfunction violationFor(leaves: IFilter[]) : { path: string, keys: string[] } {\n    const paths = new Set(leaves.map((leaf) => leafTarget(leaf.field).path));\n    const [first] = paths;\n\n    return {\n        // the shared relation path when the group has exactly one,\n        // '' for mixed-path (or empty) groups.\n        path: paths.size === 1 ? first as string : '',\n        keys: leaves.map((leaf) => leaf.field),\n    };\n}\n\n/**\n * Pool a conjunction's leaves: direct ones and those of nested AND\n * compounds. The walk deliberately ignores the preserved flag, since\n * preservation is a pruning policy and this check only analyzes: a\n * preserved residual's leaves count toward the parent group, so a\n * conjunction that jointly forms an index prefix passes cover mode\n * regardless of how validate hooks grouped it.\n */\nfunction collectConjunction(\n    children: ICondition[],\n    leaves: IFilter[],\n    compounds: ICondition[],\n) : void {\n    for (const child of children) {\n        if (isFilter(child)) {\n            leaves.push(child);\n        } else if (\n            isFilters(child) &&\n            child.operator === FilterCompoundOperator.AND\n        ) {\n            collectConjunction(child.value, leaves, compounds);\n        } else {\n            compounds.push(child);\n        }\n    }\n}\n\n/**\n * Verdict for one conjunction: leaves grouped per relation path,\n * compound children judged recursively. Shared by AND, NOT (interior\n * conjunction) and the lone-leaf case (an AND group of one).\n */\nfunction checkGroup(\n    leaves: IFilter[],\n    compounds: ICondition[],\n    resolve: IndexesResolver,\n    mode: IndexedMode,\n) : NodeVerdict {\n    if (mode === 'cover') {\n        // group coverage first: cheap, and a failure short-circuits\n        // the compound recursion.\n        const groups = new Map<string, string[]>();\n        for (const leaf of leaves) {\n            const { path, name } = leafTarget(leaf.field);\n            const group = groups.get(path);\n            if (group) {\n                group.push(name);\n            } else {\n                groups.set(path, [name]);\n            }\n        }\n\n        for (const [path, keys] of groups) {\n            if (!coversGroup(keys, resolve(path))) {\n                return {\n                    pass: false,\n                    anchors: false,\n                    skipped: false,\n                    violation: { path, keys },\n                };\n            }\n        }\n\n        const verdicts = compounds.map((child) => checkNode(child, resolve, mode));\n        const failed = verdicts.find((verdict) => !verdict.pass);\n        if (failed) {\n            return failed;\n        }\n\n        const checkable = leaves.length > 0 ||\n            verdicts.some((verdict) => !verdict.skipped);\n        if (!checkable) {\n            return {\n                pass: true, \n                anchors: false, \n                skipped: true, \n            };\n        }\n\n        return {\n            pass: true, \n            anchors: true, \n            skipped: false, \n        };\n    }\n\n    // anchor mode: a leaf anchor settles the verdict without recursing\n    // into compound conjuncts, which are residual once the group is\n    // anchored.\n    if (leaves.some((leaf) => leafAnchors(leaf, resolve))) {\n        return {\n            pass: true, \n            anchors: true, \n            skipped: false, \n        };\n    }\n\n    const verdicts = compounds.map((child) => checkNode(child, resolve, mode));\n    if (verdicts.some((verdict) => verdict.anchors)) {\n        return {\n            pass: true, \n            anchors: true, \n            skipped: false, \n        };\n    }\n\n    const checkable = leaves.length > 0 ||\n        verdicts.some((verdict) => !verdict.skipped);\n    if (!checkable) {\n        return {\n            pass: true, \n            anchors: false, \n            skipped: true, \n        };\n    }\n\n    const failed = verdicts.find((verdict) => !verdict.pass);\n\n    return {\n        pass: false,\n        anchors: false,\n        skipped: false,\n        violation: failed?.violation ?? violationFor(leaves),\n    };\n}\n\nfunction checkNode(\n    node: ICondition,\n    resolve: IndexesResolver,\n    mode: IndexedMode,\n) : NodeVerdict {\n    if (isFilter(node)) {\n        return checkGroup([node], [], resolve, mode);\n    }\n\n    if (isFilters(node)) {\n        if (node.operator === FilterCompoundOperator.OR) {\n            let skipped = true;\n            for (const child of node.value) {\n                const verdict = checkNode(child, resolve, mode);\n                if (!verdict.pass) {\n                    return verdict;\n                }\n\n                skipped = skipped && verdict.skipped;\n            }\n\n            return {\n                pass: true, \n                anchors: !skipped, \n                skipped, \n            };\n        }\n\n        // AND and NOT judge their interior conjunction; nested AND\n        // compounds pool into one group (see collectConjunction), OR\n        // children recurse as compound conjuncts.\n        const leaves : IFilter[] = [];\n        const compounds : ICondition[] = [];\n        collectConjunction(node.value, leaves, compounds);\n\n        return checkGroup(leaves, compounds, resolve, mode);\n    }\n\n    // Custom condition kinds only enter through server-authored\n    // validate replacements: they neither anchor nor violate.\n    return {\n        pass: true, \n        anchors: false, \n        skipped: true, \n    };\n}\n\n/**\n * Structural index check for a filter condition tree. Operators,\n * negation semantics and case folding are deliberately out of scope:\n * the check is uniform across engines and trusts the declaration.\n */\nexport function checkConditionIndexed(\n    condition: ICondition,\n    resolve: IndexesResolver,\n    mode: IndexedMode,\n) : IndexCheckResult {\n    const verdict = checkNode(condition, resolve, mode);\n    if (verdict.pass) {\n        return { ok: true };\n    }\n\n    return { ok: false, ...(verdict.violation ?? { path: '', keys: [] }) };\n}\n\n/**\n * Ordered leftmost-prefix check for a sort key list. All keys must\n * share one relation path: no single index serves cross-table\n * ordering. Directions are ignored (structural check).\n */\nexport function checkSortKeysIndexed(\n    names: string[],\n    resolve: IndexesResolver,\n) : IndexCheckResult {\n    if (names.length === 0) {\n        return { ok: true };\n    }\n\n    const targets = names.map(leafTarget);\n    const { path } = (targets[0] as { path: string });\n\n    const violation : IndexCheckResult = {\n        ok: false, \n        path, \n        keys: names, \n    };\n\n    if (targets.some((target) => target.path !== path)) {\n        return violation;\n    }\n\n    const indexes = resolve(path);\n    if (!indexes) {\n        return violation;\n    }\n\n    const keys = targets.map((target) => target.name);\n    for (const index of indexes) {\n        if (\n            keys.length <= index.length &&\n            keys.every((key, i) => index[i] === key)\n        ) {\n            return { ok: true };\n        }\n    }\n\n    return violation;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum FieldOperator {\n    INCLUDE = '+',\n    EXCLUDE = '-',\n}\n","/*\n * Copyright (c) 2025.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport type { BaseSchemaOptions } from './types';\n\nexport class BaseSchema<OPTIONS extends BaseSchemaOptions = BaseSchemaOptions> {\n    protected options: OPTIONS;\n\n    // ---------------------------------------------------------\n\n    constructor(options: OPTIONS) {\n        this.options = options;\n    }\n\n    // ---------------------------------------------------------\n\n    set name(input: string | undefined) {\n        this.options.name = input;\n    }\n\n    get name() : string | undefined {\n        return this.options.name;\n    }\n\n    // ---------------------------------------------------------\n\n    set throwOnFailure(input: boolean | undefined) {\n        this.options.throwOnFailure = input;\n    }\n\n    get throwOnFailure() : boolean | undefined {\n        return this.options.throwOnFailure;\n    }\n\n    // ---------------------------------------------------------\n\n    set strict(input: boolean | undefined) {\n        this.options.strict = input;\n    }\n\n    get strict() : boolean | undefined {\n        return this.options.strict;\n    }\n\n    // ---------------------------------------------------------\n\n    mapSchema(input: string) {\n        if (this.options.schemaMapping) {\n            return this.options.schemaMapping[input] || input;\n        }\n\n        return input;\n    }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Parameter } from '../constants';\nimport { SchemaError } from '../errors';\nimport type { MaybeAsync } from '../types';\nimport { BaseSchema } from './base';\nimport type {\n    KeyValidatableSchemaOptions,\n    KeyValidationScope,\n    KeyValidationVerdict,\n    KeyValidationVerdictRecord,\n} from './types';\n\n/**\n * Shared base of the three sub-schemas whose keys go through the\n * key-validation pass: fields, relations and sorts. Owns the `validate` /\n * `validateMany` hook pair so the mutual-exclusion rule and the\n * no-hook fast path are stated once.\n */\nexport class BaseKeyValidatableSchema<\n    OPTIONS extends KeyValidatableSchemaOptions = KeyValidatableSchemaOptions,\n> extends BaseSchema<OPTIONS> {\n    /**\n     * The parameter this sub-schema governs. Declared once, by the\n     * subclass — the validation driver derives the hook scope and the\n     * condition rules from it, so call sites never respecify it.\n     */\n    readonly parameter: `${Parameter}`;\n\n    constructor(options: OPTIONS, parameter: `${Parameter}`) {\n        super(options);\n\n        this.parameter = parameter;\n\n        // a schema carrying both hooks has no sensible precedence, so fail at\n        // definition time rather than silently shadowing one of them.\n        if (\n            typeof this.options.validate !== 'undefined' &&\n            typeof this.options.validateMany !== 'undefined'\n        ) {\n            throw SchemaError.keyValidatorConflict(parameter);\n        }\n    }\n\n    // ---------------------------------------------------------\n\n    hasValidator() {\n        return typeof this.options.validate !== 'undefined' ||\n            typeof this.options.validateMany !== 'undefined';\n    }\n\n    hasManyValidator() {\n        return typeof this.options.validateMany !== 'undefined';\n    }\n\n    /**\n     * Invoke the per-key hook for `name`. The caller supplies only the\n     * dotted relation path of the position being validated (`''` at the\n     * query root) — the schema completes the hook scope from what it\n     * already knows about itself (its parameter, its registered name).\n     */\n    validate(\n        name: string,\n        context: any,\n        path = '',\n    ) : MaybeAsync<KeyValidationVerdict> {\n        if (typeof this.options.validate === 'undefined') {\n            return true;\n        }\n\n        return this.options.validate(name, context, this.scope(path));\n    }\n\n    validateMany(\n        names: string[],\n        context: any,\n        path = '',\n    ) : MaybeAsync<KeyValidationVerdictRecord> {\n        if (typeof this.options.validateMany === 'undefined') {\n            return {};\n        }\n\n        return this.options.validateMany(names, context, this.scope(path));\n    }\n\n    protected scope(path: string) : KeyValidationScope {\n        return {\n            parameter: this.parameter,\n            path,\n            schema: this.name,\n        };\n    }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { Parameter } from '../../../constants';\nimport type { FieldKeys, ObjectLiteral } from '../../../types';\nimport {\n    isPropertyNameValid,\n} from '../../../utils';\nimport type { FieldsOptions, FieldsSchemaDescription } from './types';\nimport { BaseKeyValidatableSchema } from '../../key-validatable';\n\nexport class FieldsSchema<\n    RECORD extends ObjectLiteral = ObjectLiteral,\n    CONTEXT = any,\n> extends BaseKeyValidatableSchema<FieldsOptions<RECORD, CONTEXT>> {\n    public default : string[];\n\n    public defaultIsUndefined : boolean;\n\n    public allowed : string[];\n\n    public allowedIsUndefined : boolean;\n\n    public reverseMapping : Record<string, string>;\n\n    // ---------------------------------------------------------\n\n    constructor(input: FieldsOptions<RECORD, CONTEXT> = {}) {\n        super(input, Parameter.FIELDS);\n\n        this.allowed = [];\n        this.allowedIsUndefined = true;\n\n        this.default = [];\n        this.defaultIsUndefined = true;\n\n        this.reverseMapping = {};\n\n        this.setDefault(this.options.default);\n        this.setAllowed(this.options.allowed);\n\n        this.initReverseMapping();\n    }\n\n    // ---------------------------------------------------------\n\n    /**\n     * Check whether all fields are denied.\n     */\n    get allDenied() {\n        return !this.allowedIsUndefined &&\n            this.allowed.length === 0 &&\n            !this.defaultIsUndefined &&\n            this.default.length === 0;\n    }\n\n    get mapping() {\n        return this.options.mapping;\n    }\n\n    // ---------------------------------------------------------\n\n    setDefault(input?: FieldKeys<RECORD>[]) {\n        if (typeof input === 'undefined') {\n            this.default = [];\n            this.defaultIsUndefined = true;\n            return;\n        }\n\n        this.default = input;\n        this.defaultIsUndefined = false;\n    }\n\n    setAllowed(input?: FieldKeys<RECORD>[]) {\n        if (typeof input === 'undefined') {\n            this.allowed = [];\n            this.allowedIsUndefined = true;\n            return;\n        }\n\n        this.allowed = input;\n        this.allowedIsUndefined = false;\n    }\n\n    // ---------------------------------------------------------\n\n    hasDefaults() {\n        return !this.defaultIsUndefined && this.default.length > 0;\n    }\n\n    // ---------------------------------------------------------\n\n    /**\n     * Serialize the declared constraints. Arrays are cloned, so a\n     * consumer mutating the description never touches the schema.\n     */\n    describe() : FieldsSchemaDescription {\n        return {\n            default: this.defaultIsUndefined ? null : [...this.default],\n            allowed: this.allowedIsUndefined ? null : [...this.allowed],\n        };\n    }\n\n    // ---------------------------------------------------------\n\n    /**\n     * Check whether a name exists for a group.\n     *\n     * @param name\n     */\n    isValid(\n        name: string,\n    ): boolean {\n        if (!this.allowedIsUndefined) {\n            const index = this.allowed.indexOf(name);\n            if (index !== -1) {\n                return true;\n            }\n        }\n\n        if (!this.defaultIsUndefined) {\n            const index = this.default.indexOf(name);\n            if (index !== -1) {\n                return true;\n            }\n        }\n\n        if (\n            this.allowedIsUndefined &&\n            this.defaultIsUndefined\n        ) {\n            return isPropertyNameValid(name);\n        }\n\n        return false;\n    }\n\n    // ---------------------------------------------------------\n\n    protected initReverseMapping() {\n        if (typeof this.options.mapping === 'undefined') {\n            return;\n        }\n\n        this.reverseMapping = this.buildReverseRecord(this.options.mapping);\n    }\n\n    private buildReverseRecord(\n        record: Record<string, string>,\n    ) : Record<string, string> {\n        const output : Record<string, string> = {};\n\n        for (const [key, value] of Object.entries(record)) {\n            output[value] = key;\n        }\n\n        return output;\n    }\n}\n","/*\n * Copyright (c) 2025.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ObjectLiteral } from '../../../types';\nimport type { FieldsOptions } from './types';\nimport { FieldsSchema } from './schema';\n\nexport function defineFieldsSchema<\n    RECORD extends ObjectLiteral = ObjectLiteral,\n    CONTEXT = any,\n>(options: FieldsOptions<RECORD, CONTEXT> = {}) : FieldsSchema<RECORD, CONTEXT> {\n    return new FieldsSchema(options);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ICondition, IFilter } from '../../../parameter';\nimport type { MaybeAsync, ObjectLiteral, SimpleKeys } from '../../../types';\nimport type { IndexedMode } from '../../indexes';\nimport type {\n    FiltersOptions,\n    FiltersSchemaDescription,\n} from './types';\nimport { BaseSchema } from '../../base';\n\nexport class FiltersSchema<\n    T extends ObjectLiteral = ObjectLiteral,\n    CONTEXT = any,\n> extends BaseSchema<FiltersOptions<T, CONTEXT>> {\n    public default : ICondition | undefined;\n\n    public defaultIsUndefined : boolean;\n\n    public allowed : string[];\n\n    public allowedIsUndefined : boolean;\n\n    public caseSensitive : string[];\n\n    public caseSensitiveIsUndefined : boolean;\n\n    public indexes : string[][];\n\n    public indexesIsUndefined : boolean;\n\n    public indexed : IndexedMode | false;\n\n    // ---------------------------------------------------------\n\n    constructor(input: FiltersOptions<T> = {}) {\n        super(input);\n\n        this.allowed = [];\n        this.allowedIsUndefined = true;\n\n        this.default = undefined;\n        this.defaultIsUndefined = true;\n\n        this.caseSensitive = [];\n        this.caseSensitiveIsUndefined = true;\n\n        this.indexes = [];\n        this.indexesIsUndefined = true;\n        this.indexed = this.options.indexed === true ?\n            'anchor' :\n            (this.options.indexed || false);\n\n        this.setDefault(this.options.default);\n        this.setAllowed(this.options.allowed);\n        this.setCaseSensitive(this.options.caseSensitive);\n    }\n\n    // ---------------------------------------------------------\n\n    get mapping() {\n        return this.options.mapping;\n    }\n\n    // ---------------------------------------------------------\n\n    hasDefaults() {\n        return !this.defaultIsUndefined;\n    }\n\n    // ---------------------------------------------------------\n\n    /**\n     * Serialize the declared constraints. Arrays are cloned, so a\n     * consumer mutating the description never touches the schema.\n     */\n    describe() : FiltersSchemaDescription {\n        return {\n            allowed: this.allowedIsUndefined ? null : [...this.allowed],\n            caseSensitive: this.caseSensitiveIsUndefined ? null : [...this.caseSensitive],\n            indexed: this.indexed,\n        };\n    }\n\n    // ---------------------------------------------------------\n\n    hasValidator() {\n        return typeof this.options.validate !== 'undefined';\n    }\n\n    validate(input: IFilter, context: CONTEXT) : MaybeAsync<ICondition | undefined> {\n        if (typeof this.options.validate === 'undefined') {\n            return input;\n        }\n\n        return this.options.validate(input, context);\n    }\n\n    // ---------------------------------------------------------\n\n    setDefault(input?: ICondition) {\n        this.default = input;\n        this.defaultIsUndefined = !input;\n    }\n\n    setAllowed(input?: SimpleKeys<T>[]) {\n        if (typeof input === 'undefined') {\n            this.allowed = [];\n            this.allowedIsUndefined = true;\n            return;\n        }\n\n        this.allowed = input;\n        this.allowedIsUndefined = false;\n    }\n\n    setCaseSensitive(input?: SimpleKeys<T>[]) {\n        if (typeof input === 'undefined') {\n            this.caseSensitive = [];\n            this.caseSensitiveIsUndefined = true;\n            return;\n        }\n\n        this.caseSensitive = input;\n        this.caseSensitiveIsUndefined = false;\n    }\n\n    setIndexes(input?: string[][]) {\n        if (typeof input === 'undefined') {\n            this.indexes = [];\n            this.indexesIsUndefined = true;\n            return;\n        }\n\n        this.indexes = input;\n        this.indexesIsUndefined = false;\n    }\n\n    // ---------------------------------------------------------\n}\n","/*\n * Copyright (c) 2025.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ObjectLiteral } from '../../../types';\nimport type { FiltersOptions } from './types';\nimport { FiltersSchema } from './schema';\n\nexport function defineFiltersSchema<\n    RECORD extends ObjectLiteral = ObjectLiteral,\n    CONTEXT = any,\n>(options: FiltersOptions<RECORD, CONTEXT> = {}) : FiltersSchema<RECORD, CONTEXT> {\n    return new FiltersSchema(options);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { PaginationOptions, PaginationSchemaDescription } from './types';\nimport { BaseSchema } from '../../base';\n\nexport class PaginationSchema extends BaseSchema<PaginationOptions> {\n    get maxLimit() {\n        return this.options.maxLimit;\n    }\n\n    // ---------------------------------------------------------\n\n    /**\n     * Serialize the declared constraints.\n     */\n    describe() : PaginationSchemaDescription {\n        return { maxLimit: this.options.maxLimit ?? null };\n    }\n}\n","/*\n * Copyright (c) 2025.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport type { PaginationOptions } from './types';\nimport { PaginationSchema } from './schema';\n\nexport function definePaginationSchema(\n    options: PaginationOptions = {},\n) : PaginationSchema {\n    return new PaginationSchema(options);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { Parameter } from '../../../constants';\nimport type { ObjectLiteral } from '../../../types';\nimport { BaseKeyValidatableSchema } from '../../key-validatable';\nimport type { RelationsOptions, RelationsSchemaDescription } from './types';\n\nexport class RelationsSchema<\n    T extends ObjectLiteral = ObjectLiteral,\n    CONTEXT = any,\n> extends BaseKeyValidatableSchema<RelationsOptions<T, CONTEXT>> {\n    constructor(input: RelationsOptions<T, CONTEXT> = {}) {\n        super(input, Parameter.RELATIONS);\n    }\n\n    get allowed() {\n        return this.options.allowed;\n    }\n\n    get mapping() {\n        return this.options.mapping || {};\n    }\n\n    // ---------------------------------------------------------\n\n    /**\n     * Serialize the declared constraints. The array is cloned, so a\n     * consumer mutating the description never touches the schema.\n     * The `schemas` target map is composed by {@link Schema.describe},\n     * since the schema mapping lives on the parent schema.\n     */\n    describe() : RelationsSchemaDescription {\n        return {\n            allowed: typeof this.options.allowed === 'undefined' ?\n                null :\n                [...this.options.allowed],\n            schemas: null,\n        };\n    }\n}\n","/*\n * Copyright (c) 2025.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { RelationsSchema } from './schema';\nimport type { ObjectLiteral } from '../../../types';\nimport type { RelationsOptions } from './types';\n\nexport function defineRelationsSchema<\n    T extends ObjectLiteral= ObjectLiteral,\n    CONTEXT = any,\n>(\n    options: RelationsOptions<T, CONTEXT> = {},\n) : RelationsSchema<T, CONTEXT> {\n    return new RelationsSchema(options);\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum SortDirection {\n    ASC = 'ASC',\n    DESC = 'DESC',\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { Parameter } from '../../../constants';\nimport type { ObjectLiteral } from '../../../types';\nimport type {\n    SortsOptions,\n    SortsSchemaDescription,\n} from './types';\nimport { BaseKeyValidatableSchema } from '../../key-validatable';\n\nexport class SortsSchema<\n    T extends ObjectLiteral = ObjectLiteral,\n    CONTEXT = any,\n> extends BaseKeyValidatableSchema<SortsOptions<T, CONTEXT>> {\n    public default : Record<string, any>;\n\n    public defaultKeys : string[];\n\n    public defaultIsUndefined : boolean;\n\n    public allowed : string[];\n\n    public allowedIsUndefined : boolean;\n\n    public indexes : string[][];\n\n    public indexesIsUndefined : boolean;\n\n    public indexed : boolean;\n\n    // ---------------------------------------------------------\n\n    constructor(input: SortsOptions<T, CONTEXT> = {}) {\n        super(input, Parameter.SORTS);\n\n        this.allowed = [];\n        this.allowedIsUndefined = true;\n\n        this.default = {};\n        this.defaultKeys = [];\n        this.defaultIsUndefined = true;\n\n        this.indexes = [];\n        this.indexesIsUndefined = true;\n        this.indexed = this.options.indexed ?? false;\n\n        this.buildDefault();\n        this.buildAllowed();\n    }\n\n    // ---------------------------------------------------------\n\n    get mapping() : Record<string, string> | undefined {\n        return this.options.mapping;\n    }\n\n    // ---------------------------------------------------------\n\n    /**\n     * Serialize the declared constraints. Arrays and records are\n     * cloned, so a consumer mutating the description never touches\n     * the schema. An allow-list derived from `default` keys (see\n     * {@link SortsSchema.buildAllowed}) serializes like a declared one.\n     */\n    describe() : SortsSchemaDescription {\n        return {\n            allowed: this.allowedIsUndefined ? null : [...this.allowed],\n            default: this.defaultIsUndefined ? null : { ...this.default },\n            indexed: this.indexed,\n        };\n    }\n\n    // ---------------------------------------------------------\n\n    setIndexes(input?: string[][]) {\n        if (typeof input === 'undefined') {\n            this.indexes = [];\n            this.indexesIsUndefined = true;\n            return;\n        }\n\n        this.indexes = input;\n        this.indexesIsUndefined = false;\n    }\n\n    // ---------------------------------------------------------\n\n    protected buildDefault() {\n        if (!this.options.default) {\n            this.default = {};\n            this.defaultKeys = [];\n            this.defaultIsUndefined = true;\n            return;\n        }\n\n        this.default = this.options.default;\n        this.defaultKeys = Object.keys(this.default);\n        this.defaultIsUndefined = false;\n    }\n\n    protected buildAllowed() {\n        if (typeof this.options.allowed === 'undefined') {\n            if (typeof this.options.default !== 'undefined') {\n                const flatten = this.options.default;\n                const allowed = Object.keys(flatten);\n                if (allowed.length > 0) {\n                    this.allowed = allowed;\n                    this.allowedIsUndefined = false;\n                    return;\n                }\n            }\n\n            this.allowed = [];\n            this.allowedIsUndefined = true;\n            return;\n        }\n\n        this.allowed = this.options.allowed;\n        this.allowedIsUndefined = false;\n    }\n}\n","/*\n * Copyright (c) 2025.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport type { SortsOptions } from './types';\nimport { SortsSchema } from './schema';\nimport type { ObjectLiteral } from '../../../types';\n\nexport function defineSortsSchema<\n    T extends ObjectLiteral= ObjectLiteral,\n    CONTEXT = any,\n>(\n    options: SortsOptions<T, CONTEXT> = {},\n) : SortsSchema<T, CONTEXT> {\n    return new SortsSchema(options);\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ObjectLiteral } from '../../../types';\nimport { defineSortsSchema } from './define';\nimport { SortsSchema } from './schema';\nimport type {\n    SortsOptionDefault,\n    SortsOptions,\n    SortsSchemaDescription,\n} from './types';\n\n/**\n * @deprecated use {@link SortsSchema}. Removed in 3.0.\n */\nexport const SortSchema = SortsSchema;\n\n/**\n * @deprecated use {@link SortsSchema}. Removed in 3.0.\n */\nexport type SortSchema<\n    T extends ObjectLiteral = ObjectLiteral,\n    CONTEXT = any,\n> = SortsSchema<T, CONTEXT>;\n\n/**\n * @deprecated use {@link defineSortsSchema}. Removed in 3.0.\n */\nexport const defineSortSchema = defineSortsSchema;\n\n/**\n * @deprecated use {@link SortsOptions}. Removed in 3.0.\n */\nexport type SortOptions<\n    T extends Record<string, any> = Record<string, any>,\n    CONTEXT = any,\n> = SortsOptions<T, CONTEXT>;\n\n/**\n * @deprecated use {@link SortsOptionDefault}. Removed in 3.0.\n */\nexport type SortOptionDefault<T extends Record<string, any>> = SortsOptionDefault<T>;\n\n/**\n * @deprecated use {@link SortsSchemaDescription}. Removed in 3.0.\n */\nexport type SortSchemaDescription = SortsSchemaDescription;\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport {\n    FieldsSchema,\n    FiltersSchema,\n    PaginationSchema,\n    RelationsSchema,\n    SortsSchema,\n\n    defineFieldsSchema,\n    defineFiltersSchema,\n    definePaginationSchema,\n    defineRelationsSchema,\n    defineSortsSchema,\n} from './parameter';\nimport type { SortsOptions } from './parameter';\nimport type {\n    SchemaDescribeOptions,\n    SchemaDescription,\n    SchemaOptions,\n} from './types';\nimport { Parameter } from '../constants';\nimport { SchemaError } from '../errors';\nimport type { ObjectLiteral } from '../types';\nimport { assertKnownInputKeys, normalizeParameter, resolveAliasedKey } from '../utils';\nimport { BaseSchema } from './base';\n\nconst SCHEMA_INPUT_KEYS : string[] = [\n    'name',\n    'throwOnFailure',\n    'strict',\n    'schemaMapping',\n    'indexes',\n    Parameter.FIELDS,\n    Parameter.FILTERS,\n    Parameter.PAGINATION,\n    Parameter.RELATIONS,\n    Parameter.SORTS,\n    Parameter.SORT,\n];\n\nexport class Schema<\n    RECORD extends ObjectLiteral = ObjectLiteral,\n    CONTEXT = any,\n> extends BaseSchema<SchemaOptions<RECORD, CONTEXT>> {\n    public readonly fields : FieldsSchema<RECORD, CONTEXT>;\n\n    public readonly filters : FiltersSchema<RECORD, CONTEXT>;\n\n    public readonly pagination : PaginationSchema;\n\n    public readonly relations: RelationsSchema<RECORD, CONTEXT>;\n\n    public readonly sorts: SortsSchema<RECORD, CONTEXT>;\n\n    /**\n     * @deprecated use {@link Schema.sorts}. The identical instance.\n     * Removed in 3.0.\n     */\n    public readonly sort: SortsSchema<RECORD, CONTEXT>;\n\n    public readonly indexes : string[][];\n\n    public readonly indexesIsUndefined : boolean;\n\n    // ---------------------------------------------------------\n\n    constructor(options: SchemaOptions<RECORD, CONTEXT> = {}) {\n        super(options);\n\n        assertKnownInputKeys(\n            options,\n            SCHEMA_INPUT_KEYS,\n            (key, suggestion) => SchemaError.keyUnknown(key, suggestion),\n        );\n\n        if (options.fields instanceof FieldsSchema) {\n            this.fields = options.fields;\n        } else {\n            this.fields = defineFieldsSchema(options.fields);\n        }\n\n        if (options.filters instanceof FiltersSchema) {\n            this.filters = options.filters;\n        } else {\n            this.filters = defineFiltersSchema(options.filters);\n        }\n\n        if (options.pagination instanceof PaginationSchema) {\n            this.pagination = options.pagination;\n        } else {\n            this.pagination = definePaginationSchema(options.pagination);\n        }\n\n        if (options.relations instanceof RelationsSchema) {\n            this.relations = options.relations;\n        } else {\n            this.relations = defineRelationsSchema(options.relations);\n        }\n\n        const sortsInput = resolveAliasedKey(\n            options,\n            Parameter.SORTS,\n            Parameter.SORT,\n            (canonical, alias) => SchemaError.keyAmbiguous(canonical, alias),\n        ) as SortsOptions<RECORD, CONTEXT> | SortsSchema<RECORD, CONTEXT> | undefined;\n\n        if (sortsInput instanceof SortsSchema) {\n            this.sorts = sortsInput;\n        } else {\n            this.sorts = defineSortsSchema(sortsInput);\n        }\n\n        this.sort = this.sorts;\n\n        if (typeof options.indexes === 'undefined') {\n            this.indexes = [];\n            this.indexesIsUndefined = true;\n        } else {\n            this.indexes = options.indexes.map((index) => [...index]);\n            this.indexesIsUndefined = false;\n        }\n\n        this.extendSchemasOptions();\n    }\n\n    // ---------------------------------------------------------\n\n    /**\n     * Reassigning the name restamps every sub-schema, which the\n     * constructor otherwise does once. A sub-schema reaches back into\n     * the registry by the name it carries, so a stale one would resolve\n     * to the schema this one used to be.\n     */\n    override set name(input: string | undefined) {\n        super.name = input;\n\n        this.propagateName();\n    }\n\n    override get name() : string | undefined {\n        return super.name;\n    }\n\n    private propagateName() {\n        this.fields.name = this.options.name;\n        this.filters.name = this.options.name;\n        this.pagination.name = this.options.name;\n        this.relations.name = this.options.name;\n        this.sorts.name = this.options.name;\n    }\n\n    // ---------------------------------------------------------\n\n    /**\n     * Serialize the declared constraints of every (selected)\n     * parameter into a JSON-safe {@link SchemaDescription}. The\n     * relation target map is composed here, since the schema\n     * mapping lives on this schema — an unmapped relation maps to\n     * itself, mirroring registry resolution.\n     */\n    describe(options: SchemaDescribeOptions = {}) : SchemaDescription {\n        const output : SchemaDescription = {\n            name: this.options.name ?? null,\n            strict: this.options.strict ?? false,\n            indexes: this.indexesIsUndefined ?\n                null :\n                this.indexes.map((index) => [...index]),\n        };\n\n        const parameters : string[] = (options.parameters || Object.values(Parameter))\n            .map((parameter) => normalizeParameter(parameter));\n\n        if (parameters.includes(Parameter.FIELDS)) {\n            output.fields = this.fields.describe();\n        }\n\n        if (parameters.includes(Parameter.FILTERS)) {\n            output.filters = this.filters.describe();\n        }\n\n        if (parameters.includes(Parameter.PAGINATION)) {\n            output.pagination = this.pagination.describe();\n        }\n\n        if (parameters.includes(Parameter.RELATIONS)) {\n            output.relations = this.relations.describe();\n\n            if (output.relations.allowed) {\n                const schemas : Record<string, string> = {};\n                for (const relation of output.relations.allowed) {\n                    schemas[relation] = this.mapSchema(relation);\n                }\n\n                output.relations.schemas = schemas;\n            }\n        }\n\n        if (parameters.includes(Parameter.SORTS)) {\n            output.sorts = this.sorts.describe();\n        }\n\n        return output;\n    }\n\n    // ---------------------------------------------------------\n\n    private extendSchemasOptions() {\n        this.extendSchemaOptions(this.fields);\n        this.extendSchemaOptions(this.filters);\n        this.extendSchemaOptions(this.pagination);\n        this.extendSchemaOptions(this.relations);\n        this.extendSchemaOptions(this.sorts);\n\n        if (!this.indexesIsUndefined) {\n            this.filters.setIndexes(this.indexes);\n            this.sorts.setIndexes(this.indexes);\n        }\n    }\n\n    private extendSchemaOptions(schema: BaseSchema<any>) {\n        if (\n            typeof this.options.throwOnFailure !== 'undefined' &&\n            typeof schema.throwOnFailure === 'undefined'\n        ) {\n            schema.throwOnFailure = this.options.throwOnFailure;\n        }\n\n        if (\n            typeof this.options.strict !== 'undefined' &&\n            typeof schema.strict === 'undefined'\n        ) {\n            schema.strict = this.options.strict;\n        }\n\n        if (typeof this.options.name !== 'undefined') {\n            schema.name = this.options.name;\n        }\n    }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SchemaError } from '../../errors';\nimport { Schema } from '../module';\nimport type { ObjectLiteral } from '../../types';\n\nexport class SchemaRegistry<CONTEXT = any> {\n    protected entities : Map<string, Schema<any, CONTEXT>>;\n\n    // ----------------------------------------------------\n\n    constructor() {\n        this.entities = new Map<string, Schema<any, CONTEXT>>();\n    }\n\n    // ----------------------------------------------------\n\n    add<T extends ObjectLiteral>(schema: Schema<T, CONTEXT>) {\n        if (typeof schema.name === 'undefined') {\n            throw SchemaError.nameUndefined();\n        }\n\n        this.entities.set(schema.name, schema);\n    }\n\n    drop(name: string) {\n        this.entities.delete(name);\n    }\n\n    // ----------------------------------------------------\n\n    get<\n        T extends ObjectLiteral = ObjectLiteral,\n    >(name: Schema<T, CONTEXT> | string): Schema<T, CONTEXT> | undefined {\n        if (typeof name === 'string') {\n            return this.entities.get(name);\n        }\n\n        return name;\n    }\n\n    getOrFail<\n        T extends ObjectLiteral = ObjectLiteral,\n    >(name: string | Schema<T, CONTEXT>): Schema<T, CONTEXT> {\n        const schema = this.get(name);\n        if (typeof schema === 'undefined') {\n            throw SchemaError.notResolvable(name as string);\n        }\n\n        return schema;\n    }\n\n    /**\n     * Every registered schema, in registration order. The array is a fresh\n     * snapshot the caller owns: sorting or splicing it changes nothing here,\n     * and a later {@link add} or {@link drop} leaves an array already held\n     * untouched. Its elements are the live instances {@link get} returns, so\n     * one can be handed straight back to a parser, a codec or an adapter.\n     */\n    getAll() : Schema<any, CONTEXT>[] {\n        return Array.from(this.entities.values());\n    }\n\n    // ----------------------------------------------------\n\n    resolve(...input: (undefined | Schema | string)[]) : Schema | undefined {\n        const normalized : (Schema | string)[] = [];\n        for (const current of input) {\n            if (typeof current === 'string') {\n                normalized.push(...current.split('.'));\n            } else if (current instanceof Schema) {\n                normalized.push(current);\n            }\n        }\n\n        let current : Schema | undefined;\n        while (normalized.length > 0) {\n            const next = normalized.shift();\n            if (next) {\n                if (next instanceof Schema) {\n                    current = next;\n                } else if (current) {\n                    current = this.get(current.mapSchema(next));\n                } else {\n                    current = this.get(next);\n                }\n            }\n        }\n\n        return current;\n    }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const KeyResolutionErrorCode = {\n    KEY_INVALID: 'keyInvalid',\n    KEY_NOT_PERMITTED: 'keyNotPermitted',\n    PATH_NOT_PERMITTED: 'pathNotPermitted',\n    SCHEMA_UNRESOLVABLE: 'schemaUnresolvable',\n} as const;\n\nexport type KeyResolutionErrorCode = typeof KeyResolutionErrorCode[keyof typeof KeyResolutionErrorCode];\n","/*\n * Copyright (c) 2023-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ParseError } from '../../../errors';\n\nexport class FieldsParseError extends ParseError {\n\n}\n","/*\n * Copyright (c) 2023-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ParseError } from '../../../errors';\n\nexport class FiltersParseError extends ParseError {\n\n}\n","/*\n * Copyright (c) 2023-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode, ErrorMessage, ParseError } from '../../../errors';\n\nexport class PaginationParseError extends ParseError {\n    static limitExceeded(limit: number) {\n        return new this({\n            code: ErrorCode.LIMIT_EXCEEDED,\n            message: ErrorMessage.limitExceeded(limit),\n        });\n    }\n}\n","/*\n * Copyright (c) 2023-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ParseError } from '../../../errors';\n\nexport class RelationsParseError extends ParseError {\n\n}\n","/*\n * Copyright (c) 2023-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ParseError } from '../../../errors';\n\nexport class SortsParseError extends ParseError {\n\n}\n\n/**\n * @deprecated use {@link SortsParseError}. Removed in 3.0.\n */\nexport const SortParseError = SortsParseError;\n\n/**\n * @deprecated use {@link SortsParseError}. Removed in 3.0.\n */\nexport type SortParseError = SortsParseError;\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { Parameter } from '../../constants';\nimport type { ParseError } from '../../errors';\nimport { FieldsParseError } from '../parameter/fields/error';\nimport { FiltersParseError } from '../parameter/filters/error';\nimport { PaginationParseError } from '../parameter/pagination/error';\nimport { RelationsParseError } from '../parameter/relations/error';\nimport { SortsParseError } from '../parameter/sort/error';\n\n/**\n * The error class each parameter rejects client input with, where the\n * rejection is thrown rather than recorded: a `ResolutionScope` used outside a\n * parse fails on ONE violation, and naming its parameter is the whole truth\n * there. A collecting parse raises the general `INPUT_REJECTED` instead, since\n * it may have rejected input in several parameters at once.\n *\n * Typed by the class, not by a constructor signature: the resolver and the\n * raise path both reach for the static factories through it.\n */\nexport const PARAMETER_ERROR_CLASSES : Record<`${Parameter}`, typeof ParseError> = {\n    [Parameter.FIELDS]: FieldsParseError,\n    [Parameter.FILTERS]: FiltersParseError,\n    [Parameter.PAGINATION]: PaginationParseError,\n    [Parameter.RELATIONS]: RelationsParseError,\n    [Parameter.SORTS]: SortsParseError,\n    [Parameter.SORT]: SortsParseError,\n};\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { MAX_TRAVERSAL_DEPTH, Parameter } from '../../constants';\nimport {\n    ErrorCode,\n    ErrorMessage,\n    buildIssue,\n} from '../../errors';\nimport type { IssueInput, ParseError } from '../../errors';\nimport type { IRelations } from '../../parameter';\nimport type { IIssueCollector } from '../../parser/issue';\nimport { PARAMETER_ERROR_CLASSES } from '../../parser/issue/constants';\nimport type { PendingKeyValidation } from '../../parser/parameter/validate';\nimport type { ObjectLiteral } from '../../types';\nimport { applyMapping, isPathAllowed, isPropertyNameValid } from '../../utils';\nimport { Schema } from '../module';\nimport {\n    FieldsSchema,\n    FiltersSchema,\n    PaginationSchema,\n    RelationsSchema,\n    SortsSchema,\n} from '../parameter';\nimport type { SchemaRegistry } from '../registry';\nimport { KeyResolutionErrorCode } from './constants';\nimport type {\n    KeyResolution,\n    KeyResolutionFailure,\n    ParameterSchema,\n    ResolutionScopeContext,\n} from './types';\nimport type { Issue } from 'blemish';\n\nconst PARAMETER_SCHEMA_CLASSES = {\n    [Parameter.FIELDS]: FieldsSchema,\n    [Parameter.FILTERS]: FiltersSchema,\n    [Parameter.PAGINATION]: PaginationSchema,\n    [Parameter.RELATIONS]: RelationsSchema,\n    [Parameter.SORTS]: SortsSchema,\n    [Parameter.SORT]: SortsSchema,\n} as const;\n\n/**\n * How a key-resolution verdict reads on both failure channels: the\n * {@link ErrorCode} and message text a thrown error carries, and the issue a\n * collecting parse records instead.\n */\nconst KEY_RESOLUTION_FAILURES : Record<KeyResolutionErrorCode, {\n    code: `${ErrorCode}`,\n    message: (name: string) => string,\n}> = {\n    [KeyResolutionErrorCode.KEY_INVALID]: {\n        code: ErrorCode.KEY_INVALID,\n        message: ErrorMessage.keyInvalid,\n    },\n    [KeyResolutionErrorCode.KEY_NOT_PERMITTED]: {\n        code: ErrorCode.KEY_NOT_ALLOWED,\n        message: ErrorMessage.keyNotPermitted,\n    },\n    [KeyResolutionErrorCode.PATH_NOT_PERMITTED]: {\n        code: ErrorCode.KEY_PATH_NOT_ALLOWED,\n        message: ErrorMessage.keyPathNotPermitted,\n    },\n    [KeyResolutionErrorCode.SCHEMA_UNRESOLVABLE]: {\n        code: ErrorCode.KEY_PATH_INVALID,\n        message: ErrorMessage.keyPathInvalid,\n    },\n};\n\n/**\n * Relation names may contain digits and dashes (unlike attribute names).\n */\nconst RELATION_NAME_REGEX = /^[a-zA-Z0-9_-]+([.]*[a-zA-Z0-9_-])*$/u;\n\n/**\n * Upper bound for relation traversal. Mapping aliases may expand at every\n * level, so a cyclic mapping/schemaMapping configuration could otherwise\n * recurse without ever consuming input.\n */\nconst MAX_DEPTH = MAX_TRAVERSAL_DEPTH;\n\ntype ResolutionScopeOptions<\n    P extends `${Parameter}`,\n    RECORD extends ObjectLiteral = ObjectLiteral,\n> = {\n    registry: SchemaRegistry,\n    parameter: P,\n    schema: ParameterSchema<P, RECORD>,\n    bound: boolean,\n    base?: Schema<RECORD>,\n    rootBase?: Schema<RECORD>,\n    rootSchema?: ParameterSchema<P, RECORD>,\n    relations?: IRelations,\n    segment?: string,\n    path?: string[],\n    obligationSink?: PendingKeyValidation[],\n    issueCollector?: IIssueCollector,\n    depth?: number,\n    throwOnFailure?: boolean,\n    resolutionThrowOnFailure?: boolean,\n    strict?: boolean\n};\n\n/**\n * An immutable handle on one parameter of one schema, under one failure policy.\n *\n * Owns the shared resolution pipeline every parser previously duplicated:\n * schema-input normalization, alias mapping, allow-list verdicts,\n * relation-path traversal through the registry (schemaMapping-aware)\n * and the throw-vs-drop failure policy including error-class selection.\n */\nexport class ResolutionScope<\n    P extends `${Parameter}`,\n    RECORD extends ObjectLiteral = ObjectLiteral,\n> {\n    readonly parameter: P;\n\n    /**\n     * The resolved parameter sub-schema — escape hatch for parameter quirks.\n     */\n    readonly schema: ParameterSchema<P, RECORD>;\n\n    /**\n     * The parameter sub-schema this scope chain STARTED from. A descended\n     * scope with no registered child schema falls back to an empty one, so\n     * the original is kept: for a bare (base-less) relations sub-schema it\n     * is the only authorization authority there is, and it has to govern\n     * every hop rather than the first one alone.\n     */\n    protected rootSchema: ParameterSchema<P, RECORD>;\n\n    /**\n     * Parsed relations governing which relation segments may be entered.\n     */\n    readonly relations: IRelations | undefined;\n\n    /**\n     * Canonical (alias-resolved) relation segment this scope was entered through,\n     * undefined for root scopes.\n     */\n    readonly segment: string | undefined;\n\n    /**\n     * Canonical (alias-resolved) relation path from the parameter root to this\n     * scope (root: `[]`). Drives absolute obligation/prune paths across the\n     * grouping recursion — see {@link relationObligations}.\n     */\n    readonly path: string[];\n\n    protected registry: SchemaRegistry;\n\n    protected base: Schema<RECORD> | undefined;\n\n    /**\n     * The parameter root record schema, propagated unchanged through descents.\n     * The anchor {@link relationObligations} walks to reach the relations\n     * sub-schema governing each traversed segment.\n     */\n    protected rootBase: Schema<RECORD> | undefined;\n\n    /**\n     * Relation-authorization ledger this scope records into on every successful\n     * {@link resolveKey}; propagated to descendants. Undefined for scopes whose\n     * caller does not authorize relations.\n     */\n    protected obligationSink: PendingKeyValidation[] | undefined;\n\n    /**\n     * Trace of the parse this scope resolves for; propagated to descendants.\n     * Present: {@link fail} records its verdict and lets the parse continue on\n     * the drop path, and the owning parse call raises the whole trace at the\n     * end. Absent (a scope built outside a parse): failures throw where they\n     * are found, as they always did.\n     */\n    readonly issueCollector: IIssueCollector | undefined;\n\n    protected bound: boolean;\n\n    protected depth: number;\n\n    protected throwOnFailureContext: boolean | undefined;\n\n    /**\n     * Key-resolution policy a dialect forces on this scope, overriding\n     * {@link throwOnFailureContext} for allow-list and traversal verdicts\n     * alone.\n     */\n    protected resolutionThrowOnFailureContext: boolean | undefined;\n\n    protected strictContext: boolean | undefined;\n\n    // ---------------------------------------------------------\n\n    protected constructor(options: ResolutionScopeOptions<P, RECORD>) {\n        this.registry = options.registry;\n        this.parameter = options.parameter;\n        this.schema = options.schema;\n        this.rootSchema = options.rootSchema ?? options.schema;\n        this.bound = options.bound;\n        this.base = options.base;\n        this.rootBase = options.rootBase;\n        this.relations = options.relations;\n        this.segment = options.segment;\n        this.path = options.path ?? [];\n        this.obligationSink = options.obligationSink;\n        this.issueCollector = options.issueCollector;\n        this.depth = options.depth ?? 0;\n        this.throwOnFailureContext = options.throwOnFailure;\n        this.resolutionThrowOnFailureContext = options.resolutionThrowOnFailure;\n        this.strictContext = options.strict;\n    }\n\n    // ---------------------------------------------------------\n\n    /**\n     * Effective failure policy for key resolution: the dialect's forced one\n     * ({@link ResolutionScopeContext.resolutionThrowOnFailure}) ?? context\n     * override ?? schema setting ?? false.\n     */\n    get throwOnFailure() : boolean {\n        return this.resolutionThrowOnFailureContext ??\n            this.throwOnFailureContext ??\n            this.schema.throwOnFailure ??\n            false;\n    }\n\n    /**\n     * Failure policy governing relation authorization for this scope's record:\n     * the call-time override, backed by the relations sub-schema's own\n     * `throwOnFailure` (schema-level intent), the same\n     * `throwOnFailure ?? schema.relations.throwOnFailure ?? false` the query\n     * pass applies, so standalone and query parses agree.\n     *\n     * Deliberately blind to {@link throwOnFailure}'s forced half: a dialect\n     * that cannot resolve keys partially (expression) must still *drop* an\n     * unauthorized relation unless the caller or the relations schema opts\n     * into throwing.\n     */\n    get relationsThrowOnFailure() : boolean {\n        if (typeof this.throwOnFailureContext !== 'undefined') {\n            return this.throwOnFailureContext;\n        }\n\n        if (this.rootBase) {\n            return this.rootBase.relations.throwOnFailure ?? false;\n        }\n\n        // mirrors relationObligationForTerminal: a bare relations\n        // sub-schema carries its own failure policy.\n        if (this.parameter === Parameter.RELATIONS) {\n            return (this.rootSchema as RelationsSchema<RECORD>).throwOnFailure ?? false;\n        }\n\n        return false;\n    }\n\n    /**\n     * Effective strict policy: context override ?? schema setting ?? false.\n     * Under strict mode a parameter without an explicit allow-list rejects\n     * every client key instead of falling back to the syntactic name check.\n     */\n    get strict() : boolean {\n        return this.strictContext ?? this.schema.strict ?? false;\n    }\n\n    // ---------------------------------------------------------\n\n    /**\n     * Entry point. Normalizes every schema input shape\n     * (registry name | Schema | parameter sub-schema | undefined → empty schema)\n     * and binds the parse context.\n     */\n    static for<\n        P extends `${Parameter}`,\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        registry: SchemaRegistry,\n        parameter: P,\n        schema?: string | Schema<RECORD> | ParameterSchema<P, RECORD>,\n        context: ResolutionScopeContext = {},\n    ) : ResolutionScope<P, RECORD> {\n        let base : Schema<RECORD> | undefined;\n        let parameterSchema : ParameterSchema<P, RECORD>;\n\n        if (typeof schema === 'string' || schema instanceof Schema) {\n            base = registry.getOrFail(schema);\n            parameterSchema = base[parameter] as ParameterSchema<P, RECORD>;\n        } else if (schema instanceof PARAMETER_SCHEMA_CLASSES[parameter as Parameter]) {\n            parameterSchema = schema as ParameterSchema<P, RECORD>;\n        } else {\n            parameterSchema = buildEmptyParameterSchema<P, RECORD>(parameter);\n        }\n\n        // the record anchor for relation-authorization obligations: the bound\n        // schema, or the one the parameter sub-schema names (registered).\n        let rootBase = base;\n        if (!rootBase && parameterSchema.name) {\n            rootBase = registry.get(parameterSchema.name);\n        }\n\n        return new ResolutionScope<P, RECORD>({\n            registry,\n            parameter,\n            schema: parameterSchema,\n            bound: typeof schema !== 'undefined',\n            base,\n            rootBase,\n            relations: context.relations,\n            throwOnFailure: context.throwOnFailure,\n            resolutionThrowOnFailure: context.resolutionThrowOnFailure,\n            strict: context.strict,\n            obligationSink: context.obligationSink,\n            issueCollector: context.issueCollector,\n        });\n    }\n\n    // ---------------------------------------------------------\n\n    /**\n     * Resolve a raw client key (local \"title\", aliased \"abc\" or dotted \"items.title\").\n     * Applies mapping aliases, checks the allow-list (or the property-name pattern when\n     * no allow-list is set) and for dotted keys walks the relation path through the\n     * registry honoring schemaMapping — validating the leaf against the target schema.\n     *\n     * Throws the parameter's ParseError subclass instead of returning `{ success: false }`\n     * when the effective failure policy is set.\n     */\n    resolveKey(key: string, raw: string = key) : KeyResolution<P, RECORD> {\n        const mapped = applyMapping(key, this.mapping);\n\n        const separatorIndex = mapped.indexOf('.');\n        if (separatorIndex === -1) {\n            const code = this.checkName(mapped);\n            if (code) {\n                return this.fail(code, key, mapped, raw);\n            }\n\n            // resolution reached the leaf: record the authorization obligations\n            // for the relations it traversed (this scope's absolute path) plus a\n            // leaf that is itself a relation (an array operator's target). This\n            // is the single choke point — every dialect resolves through here, so\n            // no join source can silently escape the relations gate.\n            this.recordObligations(mapped);\n\n            return {\n                success: true,\n                name: mapped,\n                path: [],\n                scope: this,\n            };\n        }\n\n        const segment = mapped.substring(0, separatorIndex);\n        const rest = mapped.substring(separatorIndex + 1);\n\n        const child = this.descendSegment(segment, key, raw);\n        if (!(child instanceof ResolutionScope)) {\n            return child;\n        }\n\n        const resolved = child.resolveKey(rest, raw);\n        if (!resolved.success) {\n            return { ...resolved, input: key };\n        }\n\n        return {\n            success: true,\n            name: resolved.name,\n            path: [segment, ...resolved.path],\n            scope: resolved.scope,\n        };\n    }\n\n    /**\n     * Report a violation this scope's parameter found on its own (an input of\n     * the wrong shape, an unparseable value, a limit above the maximum)\n     * rather than one key resolution decided.\n     *\n     * Same policy as {@link resolveKey}: nothing at all while the policy\n     * drops, and under a throwing one recorded into the parse's trace when\n     * there is one (the owning call raises it once every parameter has been\n     * seen), thrown here when there is not. The caller always continues on its\n     * drop path; whether that path's result is ever observed is the trace's\n     * decision, not the caller's.\n     */\n    refuse(input: {\n        code: `${ErrorCode}`,\n        message: string,\n        /**\n         * Canonical position, defaulting to this scope's relation path.\n         */\n        path?: string[],\n        key?: string,\n        input?: unknown,\n        /**\n         * Policy override, for a site governed by another sub-schema's\n         * failure policy than its own scope's.\n         */\n        throwOnFailure?: boolean,\n    }) : void {\n        const throwOnFailure = input.throwOnFailure ?? this.throwOnFailure;\n        if (!throwOnFailure) {\n            return;\n        }\n\n        const issue : IssueInput = {\n            code: input.code,\n            parameter: this.parameter,\n            path: input.path ?? [...this.path],\n            message: input.message,\n        };\n\n        if (typeof input.key !== 'undefined') {\n            issue.key = input.key;\n        }\n\n        if (Object.hasOwn(input, 'input')) {\n            issue.received = input.input;\n        }\n\n        if (this.issueCollector) {\n            this.issueCollector.add(issue);\n\n            return;\n        }\n\n        const ErrorClass = PARAMETER_ERROR_CLASSES[\n            this.parameter as `${Parameter}`\n        ];\n\n        throw new ErrorClass({\n            code: input.code,\n            message: input.message,\n            issues: [\n                buildIssue(issue),\n            ],\n        });\n    }\n\n    /**\n     * Enter a relation: checks the (alias-resolved) segment against the permitted\n     * relations, resolves the child schema via the registry (schemaMapping-aware,\n     * starting from the schema instance when available), extracts the child\n     * relations sub-tree and returns a child scope inheriting the failure policy.\n     *\n     * A mapping alias may expand to a dotted path — every segment is walked,\n     * and the returned scope reports the full relative path as its segment.\n     *\n     * `optional` marks a descent whose target may legitimately not be a\n     * relation at all: an array operator's interior (`elemMatch`) addresses\n     * the elements of whatever it names, so \"no schema for this key\" is an\n     * answer, not a violation, and is returned as a bare verdict without\n     * being thrown or recorded. Every other failure stays a failure.\n     */\n    descend(\n        key: string,\n        options: { optional?: boolean } = {},\n    ) : ResolutionScope<P, RECORD> | KeyResolutionFailure {\n        const mapped = applyMapping(key, this.mapping);\n\n        const separatorIndex = mapped.indexOf('.');\n        if (separatorIndex === -1) {\n            return this.descendSegment(mapped, key, key, options.optional);\n        }\n\n        const segments = mapped.split('.');\n\n        let scope = this.descendSegment(segments[0] as string, key, key, options.optional);\n        for (const segment of segments.slice(1)) {\n            if (!(scope instanceof ResolutionScope)) {\n                return scope;\n            }\n\n            scope = scope.descendSegment(segment, key, key, options.optional);\n        }\n\n        if (!(scope instanceof ResolutionScope)) {\n            return scope;\n        }\n\n        return scope.withSegment(mapped);\n    }\n\n    // ---------------------------------------------------------\n\n    protected descendSegment(\n        segment: string,\n        input: string,\n        raw: string = input,\n        optional?: boolean,\n    ) : ResolutionScope<P, RECORD> | KeyResolutionFailure {\n        if (this.depth >= MAX_DEPTH) {\n            return this.fail(KeyResolutionErrorCode.SCHEMA_UNRESOLVABLE, input, segment, raw);\n        }\n\n        const code = this.checkSegment(segment);\n        if (code) {\n            return this.fail(code, input, segment, raw);\n        }\n\n        const base = this.resolveBase();\n\n        let childBase : Schema<RECORD> | undefined;\n        if (base) {\n            childBase = this.registry.get(base.mapSchema(segment));\n        } else {\n            childBase = this.registry.get(segment);\n        }\n\n        if (\n            !childBase &&\n            this.parameter !== Parameter.RELATIONS &&\n            !this.isUnbound()\n        ) {\n            // relations semantics differ: child schemas are optional refinements.\n            // Unbound scopes (no schema identity) impose no traversal constraints,\n            // so both descend into an unbound child scope instead of failing.\n            if (optional) {\n                return {\n                    success: false,\n                    code: KeyResolutionErrorCode.SCHEMA_UNRESOLVABLE,\n                    input: raw,\n                    segment,\n                };\n            }\n\n            return this.fail(KeyResolutionErrorCode.SCHEMA_UNRESOLVABLE, input, segment, raw);\n        }\n\n        let schema : ParameterSchema<P, RECORD>;\n        if (childBase) {\n            schema = childBase[this.parameter] as ParameterSchema<P, RECORD>;\n        } else {\n            schema = buildEmptyParameterSchema<P, RECORD>(this.parameter);\n        }\n\n        let relations : IRelations | undefined;\n        if (this.relations) {\n            relations = this.relations.extract(segment);\n        }\n\n        return new ResolutionScope<P, RECORD>({\n            registry: this.registry,\n            parameter: this.parameter,\n            schema,\n            rootSchema: this.rootSchema,\n            bound: !!childBase,\n            base: childBase,\n            rootBase: this.rootBase,\n            relations,\n            segment,\n            path: [...this.path, segment],\n            obligationSink: this.obligationSink,\n            issueCollector: this.issueCollector,\n            depth: this.depth + 1,\n            throwOnFailure: this.throwOnFailureContext,\n            resolutionThrowOnFailure: this.resolutionThrowOnFailureContext,\n            strict: this.strictContext,\n        });\n    }\n\n    /**\n     * Record — into {@link obligationSink}, when present — the relation-\n     * authorization obligations a resolved leaf `name` implies: every relation on\n     * this scope's absolute {@link path}, plus `name` itself when it is a relation\n     * an operator targets directly. Invoked from the {@link resolveKey} leaf case,\n     * so it fires exactly once per resolved key across every dialect.\n     */\n    protected recordObligations(name: string) : void {\n        if (!this.obligationSink) {\n            return;\n        }\n\n        this.obligationSink.push(...this.relationObligations([]));\n        this.obligationSink.push(...this.relationObligationForTerminal(name));\n    }\n\n    /**\n     * The relation-authorization obligations incurred by traversing a resolved\n     * relation path: one {@link PendingKeyValidation} per segment, against the\n     * governing record's relations sub-schema. The emitted `schema` is the very\n     * `RelationsSchema` instance the relations parser records for the same\n     * relation (registry identity), so the query-level pass dedups include-driven\n     * and traversal-driven obligations for one relation into a single hook call.\n     *\n     * `relativeSegments` are canonical (alias-resolved) relation names relative to\n     * this scope; they are joined onto this scope's absolute {@link path} so the\n     * obligation paths are absolute and prune the dependent keys directly — no\n     * per-recursion prefixing. Returns `[]` for an unbound scope (no record\n     * identity, nothing to authorize). Obligations against a validator-less\n     * relations schema are harmless — the evaluation pass skips them.\n     */\n    protected relationObligations(relativeSegments: string[]) : PendingKeyValidation[] {\n        const segments = [...this.path, ...relativeSegments];\n        if (segments.length === 0) {\n            return [];\n        }\n\n        const output : PendingKeyValidation[] = [];\n        let base = this.rootBase;\n        const prefix : string[] = [];\n        for (const segment of segments) {\n            if (!base) {\n                break;\n            }\n\n            prefix.push(segment);\n            output.push({\n                key: segment,\n                path: prefix.join('.'),\n                schema: base.relations,\n            });\n\n            base = this.registry.get(base.mapSchema(segment));\n        }\n\n        return output;\n    }\n\n    /**\n     * The obligation for a leaf `name` that is *itself* a relation of this\n     * scope's record. For the relations parameter the leaf always is one (an\n     * include). For fields/filters/sorts it is one only when it maps to a related\n     * schema — an operator applied directly to a relation array\n     * (`$size`/`$all`/`$elemMatch`) that the backends join; unlike a dotted path,\n     * {@link resolveKey} classifies such a leaf as the terminal `name` (empty\n     * `path`), so {@link relationObligations} would miss it. Returns `[]` for a\n     * scalar / JSON-array leaf (no join). A pure registry lookup — no relation\n     * gating, never throws (so it is safe on every resolved leaf, including\n     * scalars, regardless of the failure policy).\n     */\n    protected relationObligationForTerminal(name: string) : PendingKeyValidation[] {\n        const base = this.resolveBase();\n        if (!base) {\n            // a bare relations sub-schema is its own authorization anchor:\n            // there is no record schema to reach its hook through, so the\n            // obligation is recorded against the schema the chain started\n            // from. Without this a standalone relations parse skips the hook\n            // entirely and every relation is admitted; using `schema` rather\n            // than `rootSchema` would gate the first hop alone, because a\n            // descended scope with no registered child falls back to an\n            // empty sub-schema carrying no hook.\n            if (this.parameter === Parameter.RELATIONS) {\n                return [{\n                    key: name,\n                    path: [...this.path, name].join('.'),\n                    schema: this.rootSchema as RelationsSchema<RECORD>,\n                }];\n            }\n\n            return [];\n        }\n\n        if (\n            this.parameter !== Parameter.RELATIONS &&\n            !this.registry.get(base.mapSchema(name))\n        ) {\n            return [];\n        }\n\n        return [{\n            key: name,\n            path: [...this.path, name].join('.'),\n            schema: base.relations,\n        }];\n    }\n\n    /**\n     * Allow-list verdict for a local (alias-resolved) name.\n     */\n    protected checkName(name: string) : KeyResolutionErrorCode | undefined {\n        switch (this.parameter as `${Parameter}`) {\n            case Parameter.FIELDS: {\n                const schema = this.schema as FieldsSchema<RECORD>;\n                if (schema.allowedIsUndefined && schema.defaultIsUndefined) {\n                    if (this.strict) {\n                        return KeyResolutionErrorCode.KEY_NOT_PERMITTED;\n                    }\n\n                    return isPropertyNameValid(name) ?\n                        undefined :\n                        KeyResolutionErrorCode.KEY_INVALID;\n                }\n\n                return schema.isValid(name) ?\n                    undefined :\n                    KeyResolutionErrorCode.KEY_NOT_PERMITTED;\n            }\n            case Parameter.FILTERS: {\n                const schema = this.schema as FiltersSchema<RECORD>;\n                if (schema.allowedIsUndefined) {\n                    if (this.strict) {\n                        return KeyResolutionErrorCode.KEY_NOT_PERMITTED;\n                    }\n\n                    return isPropertyNameValid(name) ?\n                        undefined :\n                        KeyResolutionErrorCode.KEY_INVALID;\n                }\n\n                return schema.allowed.includes(name) ?\n                    undefined :\n                    KeyResolutionErrorCode.KEY_NOT_PERMITTED;\n            }\n            case Parameter.SORTS:\n            case Parameter.SORT: {\n                const schema = this.schema as SortsSchema<RECORD>;\n                if (schema.allowedIsUndefined) {\n                    if (this.strict) {\n                        return KeyResolutionErrorCode.KEY_NOT_PERMITTED;\n                    }\n\n                    return isPropertyNameValid(name) ?\n                        undefined :\n                        KeyResolutionErrorCode.KEY_INVALID;\n                }\n\n                return schema.allowed.includes(name) ?\n                    undefined :\n                    KeyResolutionErrorCode.KEY_NOT_PERMITTED;\n            }\n            case Parameter.RELATIONS: {\n                const schema = this.schema as RelationsSchema<RECORD>;\n                if (typeof schema.allowed === 'undefined') {\n                    if (this.strict) {\n                        return KeyResolutionErrorCode.KEY_NOT_PERMITTED;\n                    }\n\n                    return RELATION_NAME_REGEX.test(name) ?\n                        undefined :\n                        KeyResolutionErrorCode.KEY_INVALID;\n                }\n\n                return isPathAllowed(name, schema.allowed) ?\n                    undefined :\n                    KeyResolutionErrorCode.KEY_NOT_PERMITTED;\n            }\n            default:\n                return undefined;\n        }\n    }\n\n    /**\n     * Permission verdict for entering a relation segment.\n     */\n    protected checkSegment(segment: string) : KeyResolutionErrorCode | undefined {\n        if (this.parameter === Parameter.RELATIONS) {\n            const schema = this.schema as RelationsSchema<RECORD>;\n            if (typeof schema.allowed === 'undefined') {\n                return this.strict ?\n                    KeyResolutionErrorCode.PATH_NOT_PERMITTED :\n                    undefined;\n            }\n\n            if (!isPathAllowed(segment, schema.allowed)) {\n                return KeyResolutionErrorCode.PATH_NOT_PERMITTED;\n            }\n\n            return undefined;\n        }\n\n        return isPathAllowed(segment, this.relations) ?\n            undefined :\n            KeyResolutionErrorCode.PATH_NOT_PERMITTED;\n    }\n\n    protected resolveBase() : Schema<RECORD> | undefined {\n        if (this.base) {\n            return this.base;\n        }\n\n        if (this.schema.name) {\n            return this.registry.get(this.schema.name);\n        }\n\n        return undefined;\n    }\n\n    /**\n     * A scope created without any schema input describes no record\n     * and imposes no traversal constraints.\n     */\n    protected isUnbound() : boolean {\n        return !this.bound;\n    }\n\n    protected withSegment(segment: string) : ResolutionScope<P, RECORD> {\n        return new ResolutionScope<P, RECORD>({\n            registry: this.registry,\n            parameter: this.parameter,\n            schema: this.schema,\n            rootSchema: this.rootSchema,\n            bound: this.bound,\n            base: this.base,\n            rootBase: this.rootBase,\n            relations: this.relations,\n            segment,\n            path: this.path,\n            obligationSink: this.obligationSink,\n            issueCollector: this.issueCollector,\n            depth: this.depth,\n            throwOnFailure: this.throwOnFailureContext,\n            resolutionThrowOnFailure: this.resolutionThrowOnFailureContext,\n            strict: this.strictContext,\n        });\n    }\n\n    protected fail(\n        code: KeyResolutionErrorCode,\n        input: string,\n        segment?: string,\n        raw: string = input,\n    ) : KeyResolutionFailure {\n        const { throwOnFailure } = this;\n\n        if (throwOnFailure) {\n            const failure = KEY_RESOLUTION_FAILURES[code] ??\n                KEY_RESOLUTION_FAILURES[KeyResolutionErrorCode.SCHEMA_UNRESOLVABLE];\n            const name = segment ?? input;\n\n            const issue : IssueInput = {\n                code: failure.code,\n                parameter: this.parameter,\n                path: segment ? [...this.path, segment] : [...this.path],\n                key: raw,\n                message: failure.message(name),\n            };\n\n            if (this.issueCollector) {\n                this.issueCollector.add(issue);\n            } else {\n                // no trace to finish: a scope built outside a parse still fails\n                // where the violation is, exactly as it always did, carrying\n                // that position, so a catch can merge it into its own trace.\n                throw this.raise(code, name, [\n                    buildIssue(issue),\n                ]);\n            }\n        }\n\n        const output : KeyResolutionFailure = {\n            success: false,\n            code,\n            input,\n        };\n        if (typeof segment !== 'undefined') {\n            output.segment = segment;\n        }\n\n        return output;\n    }\n\n    /**\n     * The error one key-resolution verdict fails with, through the parameter's\n     * own static factories, so class, `code` and message stay what the\n     * fail-fast path has always thrown.\n     */\n    protected raise(\n        code: KeyResolutionErrorCode,\n        name: string,\n        issues: readonly Issue[] = [],\n    ) : ParseError {\n        const error = PARAMETER_ERROR_CLASSES[\n            this.parameter as `${Parameter}`\n        ];\n\n        switch (code) {\n            case KeyResolutionErrorCode.KEY_INVALID:\n                return error.keyInvalid(name, issues);\n            case KeyResolutionErrorCode.KEY_NOT_PERMITTED:\n                return error.keyNotPermitted(name, issues);\n            case KeyResolutionErrorCode.PATH_NOT_PERMITTED:\n                return error.keyPathNotPermitted(name, issues);\n            default:\n                return error.keyPathInvalid(name, issues);\n        }\n    }\n\n    protected get mapping() : Record<string, string> | undefined {\n        const schema = this.schema as { mapping?: Record<string, string> };\n\n        return schema.mapping;\n    }\n}\n\nfunction buildEmptyParameterSchema<\n    P extends `${Parameter}`,\n    RECORD extends ObjectLiteral = ObjectLiteral,\n>(parameter: P) : ParameterSchema<P, RECORD> {\n    const SchemaClass = PARAMETER_SCHEMA_CLASSES[parameter as Parameter] as\n        new (options: ObjectLiteral) => ParameterSchema<P, RECORD>;\n\n    return new SchemaClass({});\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { Schema } from './module';\nimport type { SchemaOptions } from './types';\nimport type { ObjectLiteral } from '../types';\n\nexport function defineSchema<\n    RECORD extends ObjectLiteral = ObjectLiteral,\n    CONTEXT = any,\n>(options: SchemaOptions<RECORD, CONTEXT> = {}) : Schema<RECORD, CONTEXT> {\n    return new Schema(options);\n}\n","/*\n * Copyright (c) 2025-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { MergeError } from '../../../errors';\nimport type { IField } from '../record';\nimport { Field } from '../record';\nimport { FieldOperator } from '../../../schema';\nimport type { IFields, IFieldsVisitor } from './types';\n\ntype FieldsExecuteOptions = {\n    default: string[],\n    allowed: string[],\n};\n\nexport class Fields implements IFields {\n    readonly value : IField[];\n\n    constructor(value : IField[] = []) {\n        this.value = value;\n    }\n\n    accept<R>(visitor: IFieldsVisitor<R>): R {\n        return visitor.visitFields(this);\n    }\n\n    /**\n     * Keyed by name, left/receiver priority; order = first occurrence.\n     * Immutable — returns a new collection.\n     *\n     * A name collision that would discard a visibility condition (see\n     * `IField.condition`) throws a typed MergeError instead: a gate is a\n     * server-authored authorization decision, and dropping it silently\n     * would widen disclosure. The surviving node keeping the identical\n     * condition instance is fine; anything else refuses. Filters express\n     * the same protection differently: a preserved condition stays atomic\n     * through `Filters.merge()` because a filter can be combined as a\n     * conjunct while a field is either gated or not.\n     */\n    merge(other: IFields) : IFields {\n        const output : IField[] = [];\n\n        const seen = new Map<string, IField>();\n        for (const item of [...this.value, ...other.value]) {\n            const survivor = seen.get(item.name);\n            if (survivor) {\n                if (\n                    typeof item.condition !== 'undefined' &&\n                    item.condition !== survivor.condition\n                ) {\n                    throw MergeError.fieldsConditionDiscarded(item.name);\n                }\n\n                continue;\n            }\n\n            seen.set(item.name, item);\n            output.push(item);\n        }\n\n        return new Fields(output);\n    }\n\n    /**\n     * Extract field set, with includes and excludes.\n     *\n     * @param options\n     */\n    execute(options: FieldsExecuteOptions) : IFields {\n        const includes : string[] = [];\n        const excludes : string[] = [];\n        const explicates : string[] = [];\n\n        for (const item of this.value) {\n            if (item.operator === FieldOperator.EXCLUDE) {\n                excludes.push(item.name);\n            } else if (item.operator === FieldOperator.INCLUDE) {\n                includes.push(item.name);\n            } else {\n                explicates.push(item.name);\n            }\n        }\n\n        if (\n            options.default.length === 0 &&\n            options.allowed.length === 0\n        ) {\n            if (explicates.length > 0) {\n                return new Fields(this.toUnique(explicates).map((item) => this.rebuild(item)));\n            }\n\n            return new Fields(this.toUnique(includes).map((item) => this.rebuild(item)));\n        }\n\n        const output : string[] = [];\n\n        this.applyExplicates(output, explicates, options);\n\n        if (output.length === 0) {\n            output.push(...options.default);\n        }\n\n        this.applyIncludes(output, includes, options);\n\n        if (output.length === 0) {\n            output.push(...options.allowed);\n        }\n\n        return new Fields(\n            this.applyExcludes(\n                this.toUnique(output),\n                excludes,\n            ).map((el) => this.rebuild(el)),\n        );\n    }\n\n    /**\n     * Rebuild the resolved field `name`. The include/exclude operator is\n     * deliberately consumed (execute() resolves it), but a visibility\n     * condition is orthogonal metadata and must survive, so a gated field\n     * cannot lose its gate by being run through the projection resolver.\n     */\n    protected rebuild(name: string) : IField {\n        const source = this.value.find((item) => item.name === name);\n\n        return new Field(name, undefined, source?.condition);\n    }\n\n    protected toUnique(input: string[]) : string[] {\n        return Array.from(new Set([...input]));\n    }\n\n    protected applyExplicates(\n        input: string[],\n        explicates: string[],\n        options: FieldsExecuteOptions,\n    ) {\n        for (const explicate of explicates) {\n            let index = options.default.findIndex((item) => item === explicate);\n            if (index !== -1) {\n                input.push(explicate);\n                continue;\n            }\n\n            index = options.allowed.findIndex((item) => item === explicate);\n            if (index !== -1) {\n                input.push(explicate);\n            }\n        }\n    }\n\n    protected applyIncludes(\n        input: string[],\n        includes: string[],\n        options: FieldsExecuteOptions,\n    ) {\n        for (const include of includes) {\n            let index = options.default.findIndex((item) => item === include);\n            if (index !== -1) {\n                input.push(include);\n                continue;\n            }\n\n            index = options.allowed.findIndex((item) => item === include);\n            if (index !== -1) {\n                input.push(include);\n            }\n        }\n    }\n\n    protected applyExcludes(\n        input: string[],\n        excludes: string[],\n    ) : string[] {\n        for (const exclude of excludes) {\n            const index = input.findIndex((item) => item === exclude);\n            if (index === -1) {\n                continue;\n            }\n\n            input.splice(index, 1);\n        }\n\n        return input;\n    }\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ICondition } from '../condition';\nimport { dispatchesTo } from '../../../utils';\nimport type { IFilters, IFiltersVisitor } from './types';\n\nexport function isFilters(\n    input: ICondition,\n    operator?: string,\n) : input is IFilters {\n    if (!dispatchesTo<IFiltersVisitor<unknown>>(input, 'visitFilters')) {\n        return false;\n    }\n\n    return operator ? operator === input.operator : true;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '../../utils';\n\nexport const CONDITION_MARKER: unique symbol = Symbol.for('@rapiq/core/condition');\n\nexport interface ICondition<\n    T = unknown,\n> {\n    readonly [CONDITION_MARKER]: true;\n\n    /**\n     * Relation-pruning protection marker. A preserved group stays atomic\n     * during normalization and pruning applies its contract to the subtree.\n     */\n    readonly preserved?: boolean;\n\n    readonly operator: string;\n\n    readonly value: T;\n}\n\n/**\n * Identify a live condition by its non-serializable marker. Visitor dispatch\n * is deliberately not part of this check.\n */\nexport function isCondition(input: unknown) : input is ICondition {\n    if (!isObject(input)) {\n        return false;\n    }\n\n    // the brand is asserted, not merely present: reading the value keeps a\n    // `[CONDITION_MARKER]: false` object out, which the interface now\n    // rejects at compile time too.\n    const marker : unknown = (input as { [CONDITION_MARKER]?: unknown })[CONDITION_MARKER];\n    if (marker !== true) {\n        return false;\n    }\n\n    if (typeof input.operator !== 'string') {\n        return false;\n    }\n\n    if (!('value' in input)) {\n        return false;\n    }\n\n    return typeof input.preserved === 'undefined' ||\n        typeof input.preserved === 'boolean';\n}\n\n/**\n * Construction options shared only by the built-in filter nodes.\n */\nexport type ConditionOptions = {\n    preserved?: boolean,\n};\n\n/**\n * Optional implementation base for conditions; structural implementations\n * can implement {@link ICondition} without extending this class.\n */\nexport abstract class Condition<\n    T = unknown,\n> implements ICondition<T> {\n    get [CONDITION_MARKER]() : true {\n        return true;\n    }\n\n    readonly operator: string;\n\n    readonly value: T;\n\n    protected constructor(\n        operator: string,\n        value: T,\n    ) {\n        this.operator = operator;\n        this.value = value;\n    }\n}\n","/*\n * Copyright (c) 2025-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { FilterCompoundOperator } from '../../../schema';\nimport { Condition } from '../condition';\nimport type { ConditionOptions, ICondition } from '../condition';\nimport type { IFilters, IFiltersVisitor } from './types';\nimport { isFilters } from './check';\n\nexport class Filters<\n    T extends ICondition = ICondition,\n> extends Condition<T[]> implements IFilters<T> {\n    readonly preserved?: boolean;\n\n    constructor(\n        operator: string,\n        conditions: T[],\n        options: ConditionOptions = {},\n    ) {\n        super(operator, conditions);\n\n        if (options.preserved) {\n            this.preserved = true;\n        }\n    }\n\n    accept<R>(visitor: IFiltersVisitor<R>) : R {\n        return visitor.visitFilters(this);\n    }\n\n    flatten(aggregatedResult?: T[]) : IFilters<T> {\n        // this.value.splice(0, this.value.length, ...next);\n\n        return new Filters(\n            this.operator,\n            this.flattenInternal(this.value, this.operator, aggregatedResult),\n            { preserved: this.preserved },\n        );\n    }\n\n    protected flattenInternal<F extends ICondition>(\n        conditions: F[],\n        operator: string,\n        aggregatedResult?: F[],\n    ) {\n        const flatConditions: F[] = aggregatedResult || [];\n\n        for (const currentNode of conditions) {\n            // Merging same-operator children relies on associativity.\n            // NOT groups are not associative (not(not(x)) is not not(x)).\n            // A preserved group stays atomic so pruning protection remains.\n            if (\n                isFilters(currentNode, operator) &&\n                operator !== FilterCompoundOperator.NOT &&\n                !currentNode.preserved\n            ) {\n                currentNode.flatten(flatConditions);\n            } else {\n                flatConditions.push(currentNode);\n            }\n        }\n\n        return flatConditions;\n    }\n\n    /**\n     * Ordered logical conjunction. Each condition from both sides survives\n     * in argument order. A non-preserved root AND contributes its flattened\n     * child conjuncts, while every other root remains one conjunct.\n     */\n    merge(other: IFilters) : IFilters {\n        if (this.value.length === 0) {\n            return other;\n        }\n\n        if (other.value.length === 0) {\n            return this;\n        }\n\n        return new Filters(FilterCompoundOperator.AND, [\n            ...toConjuncts(this),\n            ...toConjuncts(other),\n        ]);\n    }\n\n    /**\n     * Wrap and append immutably: combine the given conditions with the\n     * receiver under an AND group while retaining their object identity.\n     */\n    and(...conditions: ICondition[]) : IFilters {\n        return this.wrap(FilterCompoundOperator.AND, conditions);\n    }\n\n    /**\n     * Wrap & inject (immutable), OR variant of {@link Filters.and}.\n     */\n    or(...conditions: ICondition[]) : IFilters {\n        return this.wrap(FilterCompoundOperator.OR, conditions);\n    }\n\n    protected wrap(operator: string, conditions: ICondition[]) : IFilters {\n        if (conditions.length === 0) {\n            return this;\n        }\n\n        // an empty receiver constrains nothing, so it must not become a\n        // child: under OR it would widen the group to everything.\n        if (this.value.length === 0) {\n            return new Filters(operator, conditions);\n        }\n\n        // a receiver already carrying that operator contributes its\n        // conditions directly (associativity), which keeps the group flat.\n        if (\n            this.operator === operator &&\n            operator !== FilterCompoundOperator.NOT &&\n            !this.preserved\n        ) {\n            return new Filters(operator, [...this.value, ...conditions]);\n        }\n\n        return new Filters(operator, [this, ...conditions]);\n    }\n}\n\n/**\n * The conjuncts a {@link Filters.merge} operates on: the flattened\n * children of a non-preserved root AND, or the whole node for a preserved\n * tree or any other compound operator.\n */\nfunction toConjuncts(input: IFilters) : ICondition[] {\n    if (\n        input.operator === FilterCompoundOperator.AND &&\n        !input.preserved\n    ) {\n        return input.flatten().value;\n    }\n\n    return [input];\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n/**\n * Reserved self-reference marker (spelled `$this` on the wire).\n *\n * Legal only as the complete field of a condition inside an\n * elemMatch interior. A leaf condition uses it to address the bound\n * array element itself instead of one of its properties; a nested\n * elemMatch may take it as its own field for arrays of arrays:\n *\n * ```ts\n * elemMatch('scores', gt(ITSELF, 5))                     // some score > 5\n * elemMatch('matrix', elemMatch(ITSELF, gt(ITSELF, 5)))  // some row has a value > 5\n * ```\n *\n * Anywhere else the marker is a typed error — build layer and parsers\n * reject it, backend adapters without element semantics\n * (`@rapiq/adapter-sql`, `@rapiq/adapter-typeorm`) throw `featureUnsupported`.\n */\nexport const ITSELF = '$this';\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { dispatchesTo } from '../../../utils';\nimport type { IFilter, IFilterVisitor } from './types';\n\nexport function isFilter(input: unknown) : input is IFilter {\n    return dispatchesTo<IFilterVisitor<unknown>>(input, 'visitFilter');\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { FilterFieldOperator } from '../../../schema';\nimport { Condition } from '../condition';\nimport type { ConditionOptions } from '../condition';\nimport type { IFilter, IFilterVisitor } from './types';\n\nexport class Filter<\n    OPERATOR extends string = `${FilterFieldOperator}`,\n    VALUE = unknown,\n> extends Condition<VALUE> implements IFilter<OPERATOR, VALUE> {\n    readonly field: string;\n\n    readonly preserved?: boolean;\n\n    constructor(\n        operator: string,\n        field: string,\n        value: VALUE,\n        options: ConditionOptions = {},\n    ) {\n        super(operator, value);\n        this.field = field;\n\n        if (options.preserved) {\n            this.preserved = true;\n        }\n    }\n\n    accept<R>(visitor: IFilterVisitor<R>) : R {\n        return visitor.visitFilter(this);\n    }\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { FilterCompoundOperator, FilterFieldOperator } from '../../../schema';\nimport type { NestedKeys, ObjectLiteral } from '../../../types';\nimport { Filters } from '../collection';\nimport type { ICondition } from '../condition';\nimport { Filter } from '../record';\n\n/**\n * Field paths are typed against the record generic when one is supplied\n * (helper<User>('realm.name', ...)); without a generic the parameter\n * falls back to a plain string.\n */\ntype FieldKey<RECORD extends ObjectLiteral> = string extends keyof RECORD ?\n    string :\n    NestedKeys<RECORD>;\n\n/**\n * One helper per {@link FilterFieldOperator}, named after the operator's\n * enum value, mirroring the expression dialect (eq('name', 'John') in\n * code ≙ eq(name, 'John') on the wire). Sole exception: `in` is a\n * reserved word in JavaScript, so the IN helper is named {@link inArray}.\n */\n\nexport function eq<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: unknown,\n) : Filter {\n    return new Filter(FilterFieldOperator.EQUAL, field, value);\n}\n\nexport function ne<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: unknown,\n) : Filter {\n    return new Filter(FilterFieldOperator.NOT_EQUAL, field, value);\n}\n\nexport function lt<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: unknown,\n) : Filter {\n    return new Filter(FilterFieldOperator.LESS_THAN, field, value);\n}\n\nexport function lte<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: unknown,\n) : Filter {\n    return new Filter(FilterFieldOperator.LESS_THAN_EQUAL, field, value);\n}\n\nexport function gt<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: unknown,\n) : Filter {\n    return new Filter(FilterFieldOperator.GREATER_THAN, field, value);\n}\n\nexport function gte<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: unknown,\n) : Filter {\n    return new Filter(FilterFieldOperator.GREATER_THAN_EQUAL, field, value);\n}\n\n/**\n * IN condition (wire keyword: `in`). `null` is a legal element;\n * backend adapters own the `OR IS NULL` rewrite.\n */\nexport function inArray<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: unknown[],\n) : Filter {\n    return new Filter(FilterFieldOperator.IN, field, value);\n}\n\nexport function nin<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: unknown[],\n) : Filter {\n    return new Filter(FilterFieldOperator.NOT_IN, field, value);\n}\n\nexport function startsWith<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: string,\n) : Filter {\n    return new Filter(FilterFieldOperator.STARTS_WITH, field, value);\n}\n\nexport function notStartsWith<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: string,\n) : Filter {\n    return new Filter(FilterFieldOperator.NOT_STARTS_WITH, field, value);\n}\n\nexport function endsWith<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: string,\n) : Filter {\n    return new Filter(FilterFieldOperator.ENDS_WITH, field, value);\n}\n\nexport function notEndsWith<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: string,\n) : Filter {\n    return new Filter(FilterFieldOperator.NOT_ENDS_WITH, field, value);\n}\n\nexport function contains<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: string,\n) : Filter {\n    return new Filter(FilterFieldOperator.CONTAINS, field, value);\n}\n\nexport function notContains<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: string,\n) : Filter {\n    return new Filter(FilterFieldOperator.NOT_CONTAINS, field, value);\n}\n\nexport function regex<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: RegExp | string,\n) : Filter {\n    return new Filter(FilterFieldOperator.REGEX, field, value);\n}\n\nexport function mod<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    divisor: number,\n    remainder: number,\n) : Filter {\n    return new Filter(FilterFieldOperator.MOD, field, [divisor, remainder]);\n}\n\n/**\n * Match arrays with exactly the given number of elements\n * (a non-negative integer); missing or non-array values never match.\n */\nexport function size<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: number,\n) : Filter {\n    return new Filter(FilterFieldOperator.SIZE, field, value);\n}\n\nexport function exists<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: boolean = true,\n) : Filter {\n    return new Filter(FilterFieldOperator.EXISTS, field, value);\n}\n\n/**\n * Match array elements against a condition; field paths inside the\n * condition are relative to the array element.\n */\nexport function elemMatch<RECORD extends ObjectLiteral = ObjectLiteral>(\n    field: FieldKey<RECORD>,\n    value: ICondition,\n) : Filter {\n    return new Filter(FilterFieldOperator.ELEM_MATCH, field, value);\n}\n\nexport function and(...conditions: ICondition[]) : Filters {\n    return new Filters(FilterCompoundOperator.AND, conditions);\n}\n\nexport function or(...conditions: ICondition[]) : Filters {\n    return new Filters(FilterCompoundOperator.OR, conditions);\n}\n\n/**\n * Negation: matches exactly what the interior does not match — the\n * null-inclusive complement law extended from negated leaf operators\n * to arbitrary condition trees. Multiple conditions negate their\n * conjunction: not(a, b) ≙ not(and(a, b)).\n */\nexport function not(...conditions: ICondition[]) : Filters {\n    return new Filters(FilterCompoundOperator.NOT, conditions);\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { FilterFieldOperator } from '../../../schema';\nimport type { FilterOperatorSemantics } from './types';\n\n/**\n * The operator-semantics table — one row per filter operator, the\n * single source of truth for what an operator MEANS: its family,\n * its negation twin (complement law), its anchor placement, its\n * comparison range and its case-fold participation.\n *\n * The {@link planCondition} lowering derives every policy decision\n * from this table. Adding an operator means adding a row (plus a\n * lowering rule when it opens a new family) — not editing backends.\n */\nexport const FILTER_OPERATOR_SEMANTICS = {\n    eq: {\n        family: 'equality',\n        foldable: true,\n    },\n    ne: {\n        family: 'equality',\n        complementOf: 'eq',\n        foldable: true,\n    },\n    lt: {\n        family: 'ordering',\n        compare: { min: -1, max: -1 },\n        foldable: false,\n    },\n    lte: {\n        family: 'ordering',\n        compare: { min: -1, max: 0 },\n        foldable: false,\n    },\n    gt: {\n        family: 'ordering',\n        compare: { min: 1, max: 1 },\n        foldable: false,\n    },\n    gte: {\n        family: 'ordering',\n        compare: { min: 0, max: 1 },\n        foldable: false,\n    },\n    in: {\n        family: 'membership',\n        foldable: true,\n    },\n    nin: {\n        family: 'membership',\n        complementOf: 'in',\n        foldable: true,\n    },\n    startsWith: {\n        family: 'anchored',\n        anchor: { start: true, end: false },\n        foldable: false,\n    },\n    notStartsWith: {\n        family: 'anchored',\n        complementOf: 'startsWith',\n        anchor: { start: true, end: false },\n        foldable: false,\n    },\n    endsWith: {\n        family: 'anchored',\n        anchor: { start: false, end: true },\n        foldable: false,\n    },\n    notEndsWith: {\n        family: 'anchored',\n        complementOf: 'endsWith',\n        anchor: { start: false, end: true },\n        foldable: false,\n    },\n    contains: {\n        family: 'anchored',\n        anchor: { start: false, end: false },\n        foldable: false,\n    },\n    notContains: {\n        family: 'anchored',\n        complementOf: 'contains',\n        anchor: { start: false, end: false },\n        foldable: false,\n    },\n    regex: {\n        family: 'regex',\n        foldable: false,\n    },\n    mod: {\n        family: 'arithmetic',\n        foldable: false,\n    },\n    size: {\n        family: 'cardinality',\n        foldable: false,\n    },\n    exists: {\n        family: 'existence',\n        foldable: false,\n    },\n    elemMatch: {\n        family: 'structural',\n        foldable: false,\n    },\n} satisfies Record<`${FilterFieldOperator}`, FilterOperatorSemantics>;\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { AdapterError } from '../../../errors';\nimport { FILTER_OPERATOR_SEMANTICS } from './constants';\nimport type {\n    ComparePlan,\n    ConditionPlan,\n    PlanCompareOperator,\n} from './types';\n\n/**\n * The ordering complement, derived from the semantics table: the\n * operator accepting exactly the complementary three-way comparison\n * range (lt {-1..-1} complements gte {0..1}, and so on). Derived\n * rather than hardcoded, so the table stays the single authority.\n */\nconst ORDERING_COMPLEMENTS : Partial<Record<PlanCompareOperator, PlanCompareOperator>> = {};\n\n{\n    const entries = Object.entries(FILTER_OPERATOR_SEMANTICS)\n        .filter((entry) => entry[1].family === 'ordering') as [\n        PlanCompareOperator,\n        { compare: { min: number, max: number } },\n    ][];\n\n    for (const [name, semantics] of entries) {\n        const match = entries.find(([, other]) => (\n            other.compare.min === (semantics.compare.max === 1 ? -1 : semantics.compare.max + 1) &&\n            other.compare.max === (semantics.compare.min === -1 ? 1 : semantics.compare.min - 1)\n        ));\n\n        if (match) {\n            ORDERING_COMPLEMENTS[name] = match[0];\n        }\n    }\n}\n\n/**\n * Push group negation down to the leaves, eliminating\n * `CompoundPlan.negated` from the tree.\n *\n * `planCondition` keeps group negation because SQL and the in-memory\n * backend render it two-valued cheaply (a CASE wrapper, a `!`).\n * Backends without a two-valued NOT of their own (prisma, and the\n * other structured-args ORMs of plan 023) instead consume this\n * transform. It is semantics-preserving under the settled negation\n * contract:\n *\n * - group negation is the two-valued complement PER BINDING, with the\n *   binding quantifier outermost (SQL applies its CASE wrapper per\n *   join row; the in-memory backend negates per binding context):\n *   so De Morgan applies, negation commutes through `elemMatch`\n *   (`not(elemMatch(c))` selects bindings where an element fails `c`,\n *   NOT records without a matching element), and leaves flip to their\n *   null-inclusive complement twins.\n * - the complement of an ordering comparison has no leaf twin; it\n *   becomes the complementary operator OR a null check: expressible\n *   in the existing plan vocabulary, so backends need no new node\n *   kinds and their usual constant folding (e.g. a non-nullable\n *   column) applies unchanged.\n * - `mod` and `size` have no complement form and stay wrapped in a\n *   residual negated single-child compound; a backend that cannot\n *   render that keeps failing typed, exactly as before.\n */\nexport function distributeNegation(plan: ConditionPlan) : ConditionPlan {\n    return distribute(plan, false);\n}\n\nfunction distribute(plan: ConditionPlan, negated: boolean) : ConditionPlan {\n    switch (plan.kind) {\n        case 'compound': {\n            const effective = negated !== plan.negated;\n\n            const children = plan.children.map((child) => distribute(child, effective));\n\n            // a single-child group carries no operator of its own;\n            // unwrapping keeps the tree in the shape the lowering\n            // produces for positive input.\n            if (children.length === 1) {\n                return children[0] as ConditionPlan;\n            }\n\n            let { operator } = plan;\n            if (effective) {\n                operator = plan.operator === 'and' ? 'or' : 'and';\n            }\n\n            return {\n                kind: 'compound',\n                operator,\n                negated: false,\n                children,\n            };\n        }\n        case 'constant': {\n            return negated ? { ...plan, verdict: !plan.verdict } : plan;\n        }\n        case 'null-check':\n        case 'one-of':\n        case 'match': {\n            return negated ? { ...plan, negated: !plan.negated } : plan;\n        }\n        case 'compare': {\n            return distributeCompare(plan, negated);\n        }\n        case 'elem-match': {\n            // negation commutes through the element quantifier: it\n            // applies per binding, the ∃ stays outside.\n            return {\n                ...plan,\n                condition: distribute(plan.condition, negated),\n            };\n        }\n        case 'mod':\n        case 'size': {\n            if (!negated) {\n                return plan;\n            }\n\n            // no complement form exists; the residual wrapper keeps\n            // the negation explicit for backends that can render it.\n            return {\n                kind: 'compound',\n                operator: 'and',\n                negated: true,\n                children: [plan],\n            };\n        }\n        default: {\n            throw AdapterError.featureUnsupported(\n                `filters:${(plan as { kind: string }).kind}`,\n            );\n        }\n    }\n}\n\nfunction distributeCompare(plan: ComparePlan, negated: boolean) : ConditionPlan {\n    if (!negated) {\n        return plan;\n    }\n\n    if (plan.op === 'eq') {\n        return { ...plan, negated: !plan.negated };\n    }\n\n    const complement = ORDERING_COMPLEMENTS[plan.op];\n    if (!complement) {\n        throw AdapterError.operatorUnsupported(plan.op);\n    }\n\n    // the null-inclusive complement of an ordering comparison: the\n    // complementary operator, or no value at all.\n    return {\n        kind: 'compound',\n        operator: 'or',\n        negated: false,\n        children: [\n            { ...plan, op: complement },\n            {\n                kind: 'null-check',\n                field: plan.field,\n                negated: false,\n                elementwise: true,\n            },\n        ],\n    };\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum FilterRegexFlag {\n    STARTS_WITH = 1 << 0,\n    ENDS_WITH = 1 << 1,\n    CONTAINS = 1 << 2,\n    NEGATION = 1 << 3,\n}\n\nexport function createFilterRegex(\n    input: string,\n    flag: number = 0,\n): RegExp {\n    const pattern = createFilterRegexPattern(input, flag);\n\n    return new RegExp(pattern, 'i');\n}\n\nexport function createFilterRegexPattern(\n    input: string,\n    flag: number = 0,\n) : string {\n    // the input is a literal filter value, not a regex:\n    // escape metacharacters so it matches verbatim.\n    const escaped = input.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n    let pattern : string;\n    if (flag & FilterRegexFlag.NEGATION) {\n        if (flag & FilterRegexFlag.STARTS_WITH) {\n            pattern = `^(?!${escaped}).*`;\n        } else if (flag & FilterRegexFlag.ENDS_WITH) {\n            pattern = `^(?!.*${escaped}$).*`;\n        } else {\n            // CONTAINS or no anchor flag\n            pattern = `^(?!.*${escaped}).*`;\n        }\n\n        return pattern;\n    }\n\n    if (flag & FilterRegexFlag.STARTS_WITH) {\n        pattern = `^${escaped}`;\n    } else if (flag & FilterRegexFlag.ENDS_WITH) {\n        pattern = `${escaped}$`;\n    } else {\n        // CONTAINS or no anchor flag\n        pattern = `${escaped}`;\n    }\n\n    return pattern;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { AdapterError } from '../../../errors';\nimport { isObject } from '../../../utils';\nimport type { IFilters } from '../collection';\nimport { isFilters } from '../collection';\nimport type { ICondition } from '../condition';\nimport { ITSELF } from '../constants';\nimport type { IFilter } from '../record';\nimport { isFilter } from '../record';\nimport { FilterRegexFlag, createFilterRegexPattern } from '../regex';\nimport { FILTER_OPERATOR_SEMANTICS } from './constants';\nimport type {\n    ConditionPlan,\n    IPlanInterpreter,\n    MatchPlan,\n    PlanCompareOperator,\n    PlanConditionOptions,\n} from './types';\n\n/**\n * A condition-shaped value the built-in lowering cannot classify. This may\n * be a live custom condition or detached transport data. The check is\n * deliberately looser than the build layer's namesake: an `elemMatch`\n * interior is either a condition or nothing at all.\n */\nfunction isDetachedCondition(input: unknown) : boolean {\n    return isObject(input) && typeof (input as ICondition).operator === 'string';\n}\n\n/**\n * Lower a built-in condition tree into a\n * {@link ConditionPlan} with every semantic policy decision already\n * made: negation twins resolved to `negated` leaf flags, null\n * equality turned into null checks, in/nin decomposed (empty list,\n * null members), the case-fold policy verdict computed, anchored\n * operators derived into positive patterns, value shapes validated\n * and ITSELF placement checked.\n *\n * Backends interpret the plan via {@link interpretPlan} — they\n * render or compile primitives, they never re-derive operator\n * semantics.\n *\n * Returns `null` when the tree is empty (an empty compound\n * vanishes).\n */\nexport function planCondition(\n    input: ICondition,\n    options: PlanConditionOptions = {},\n) : ConditionPlan | null {\n    return new ConditionLowering(options).lower(input);\n}\n\n/**\n * Dispatch a plan node to the matching interpreter handler.\n *\n * The single support-enforcement point: a missing optional handler\n * (`mod`/`size`/`elemMatch`) and an ITSELF leaf without the\n * `itself` declaration throw the typed feature error here — never\n * inside a backend.\n */\nexport function interpretPlan<R>(\n    plan: ConditionPlan,\n    interpreter: IPlanInterpreter<R>,\n) : R {\n    if (\n        'field' in plan &&\n        plan.field === ITSELF &&\n        !interpreter.itself\n    ) {\n        throw AdapterError.featureUnsupported('filters:itself');\n    }\n\n    switch (plan.kind) {\n        case 'compound': {\n            return interpreter.compound(plan);\n        }\n        case 'constant': {\n            return interpreter.constant(plan);\n        }\n        case 'null-check': {\n            return interpreter.nullCheck(plan);\n        }\n        case 'compare': {\n            return interpreter.compare(plan);\n        }\n        case 'one-of': {\n            return interpreter.oneOf(plan);\n        }\n        case 'match': {\n            return interpreter.match(plan);\n        }\n        case 'mod': {\n            if (!interpreter.mod) {\n                throw AdapterError.featureUnsupported('filters:mod');\n            }\n\n            return interpreter.mod(plan);\n        }\n        case 'size': {\n            if (!interpreter.size) {\n                throw AdapterError.featureUnsupported('filters:size');\n            }\n\n            return interpreter.size(plan);\n        }\n        case 'elem-match': {\n            if (!interpreter.elemMatch) {\n                throw AdapterError.featureUnsupported('filters:elemMatch');\n            }\n\n            return interpreter.elemMatch(plan);\n        }\n        default: {\n            throw AdapterError.featureUnsupported(\n                `filters:${(plan as { kind: string }).kind}`,\n            );\n        }\n    }\n}\n\n// -----------------------------------------------------------\n\nclass ConditionLowering {\n    protected caseSensitiveAll : boolean;\n\n    protected caseSensitiveFields : Set<string>;\n\n    protected fieldPrefix : string;\n\n    protected elementDepth : number;\n\n    constructor(options: PlanConditionOptions) {\n        this.caseSensitiveAll = options.caseSensitive === true;\n        this.caseSensitiveFields = new Set(\n            Array.isArray(options.caseSensitive) ? options.caseSensitive : [],\n        );\n        this.fieldPrefix = '';\n        this.elementDepth = 0;\n    }\n\n    // -----------------------------------------------------------\n\n    lower(input: ICondition) : ConditionPlan | null {\n        if (isFilters(input)) {\n            return this.lowerCompound(input);\n        }\n\n        if (isFilter(input)) {\n            return this.lowerLeaf(input);\n        }\n\n        throw AdapterError.conditionDetached(\n            (input as Partial<ICondition>)?.operator,\n        );\n    }\n\n    // -----------------------------------------------------------\n\n    protected lowerCompound(input: IFilters) : ConditionPlan | null {\n        let operator : 'and' | 'or';\n        let negated = false;\n\n        switch (input.operator) {\n            case 'and': {\n                operator = 'and';\n                break;\n            }\n            case 'or': {\n                operator = 'or';\n                break;\n            }\n            // group negation is the exact complement of the group\n            // verdict — the null-inclusive complement law extended\n            // from negated leaf operators to whole trees.\n            case 'nor': {\n                operator = 'or';\n                negated = true;\n                break;\n            }\n            case 'not': {\n                operator = 'and';\n                negated = true;\n                break;\n            }\n            default: {\n                throw AdapterError.operatorUnsupported(input.operator);\n            }\n        }\n\n        const children : ConditionPlan[] = [];\n        for (let i = 0; i < input.value.length; i++) {\n            const child = input.value[i];\n            if (!child) {\n                continue;\n            }\n\n            if (isFilter(child) || isFilters(child)) {\n                const plan = this.lower(child);\n                if (plan) {\n                    children.push(plan);\n                }\n\n                continue;\n            }\n\n            // a child that is not a built-in condition cannot be lowered by\n            // this consumer. Dropping it would silently widen the result set\n            // because a scoping conjunct would simply vanish.\n            throw AdapterError.conditionDetached(\n                (child as Partial<ICondition>)?.operator,\n            );\n        }\n\n        // an empty compound vanishes.\n        if (children.length === 0) {\n            return null;\n        }\n\n        // a single-child negation normalizes onto the child's own\n        // negated form where one exists (not(eq) ≙ ne — identical\n        // plan, identical rendering); only interiors without a\n        // negatable leaf form stay wrapped in a negated compound.\n        const [firstChild] = children;\n        if (negated && children.length === 1 && firstChild) {\n            return this.negatePlan(firstChild);\n        }\n\n        return {\n            kind: 'compound',\n            operator,\n            negated,\n            children,\n        };\n    }\n\n    /**\n     * The exact complement of a plan node. Leaf kinds carrying a\n     * `negated` flag flip it (their negated contract already IS the\n     * null-inclusive complement); a constant flips its verdict; a\n     * compound flips its group negation. Kinds without a negated\n     * form (ordering compare, mod, size, elemMatch) wrap in a\n     * negated single-child compound for the backend to complement.\n     */\n    protected negatePlan(plan: ConditionPlan) : ConditionPlan {\n        switch (plan.kind) {\n            case 'constant': {\n                return { ...plan, verdict: !plan.verdict };\n            }\n            case 'null-check':\n            case 'one-of':\n            case 'match': {\n                return { ...plan, negated: !plan.negated };\n            }\n            case 'compare': {\n                if (plan.op === 'eq') {\n                    return { ...plan, negated: !plan.negated };\n                }\n\n                break;\n            }\n            case 'compound': {\n                return { ...plan, negated: !plan.negated };\n            }\n            default: {\n                break;\n            }\n        }\n\n        return {\n            kind: 'compound',\n            operator: 'and',\n            negated: true,\n            children: [plan],\n        };\n    }\n\n    // -----------------------------------------------------------\n\n    protected lowerLeaf(input: IFilter) : ConditionPlan | null {\n        const semantics = FILTER_OPERATOR_SEMANTICS[\n            input.operator as keyof typeof FILTER_OPERATOR_SEMANTICS\n        ];\n        if (!semantics) {\n            throw AdapterError.operatorUnsupported(input.operator);\n        }\n\n        // the ITSELF marker addresses the element bound by an\n        // enclosing elemMatch scope; outside one it has no referent.\n        if (input.field === ITSELF && this.elementDepth === 0) {\n            throw AdapterError.featureUnsupported('filters:itself');\n        }\n\n        const negated = typeof (\n            semantics as { complementOf?: string }\n        ).complementOf === 'string';\n\n        // a single absent value: unify undefined and null so every\n        // downstream decision only reasons about null.\n        const value = input.value === undefined ? null : input.value;\n\n        switch (semantics.family) {\n            case 'equality': {\n                if (value === null) {\n                    return {\n                        kind: 'null-check', \n                        field: input.field, \n                        negated, \n                        elementwise: true,\n                    };\n                }\n\n                return {\n                    kind: 'compare',\n                    field: input.field,\n                    op: 'eq',\n                    value,\n                    caseFold: typeof value === 'string' && this.isFoldableField(input.field),\n                    negated,\n                };\n            }\n            case 'ordering': {\n                return {\n                    kind: 'compare',\n                    field: input.field,\n                    op: input.operator as PlanCompareOperator,\n                    value,\n                    caseFold: false,\n                    negated: false,\n                };\n            }\n            case 'membership': {\n                return this.lowerMembership(input.field, value, negated);\n            }\n            case 'anchored': {\n                const anchor = (\n                    semantics as { anchor?: { start: boolean, end: boolean } }\n                ).anchor || { start: false, end: false };\n                const text = `${value}`;\n\n                let mode : 'starts' | 'ends' | 'contains';\n                let flag : number;\n                if (anchor.start) {\n                    mode = 'starts';\n                    flag = FilterRegexFlag.STARTS_WITH;\n                } else if (anchor.end) {\n                    mode = 'ends';\n                    flag = FilterRegexFlag.ENDS_WITH;\n                } else {\n                    mode = 'contains';\n                    flag = FilterRegexFlag.CONTAINS;\n                }\n\n                return {\n                    kind: 'match',\n                    field: input.field,\n                    pattern: { mode, text },\n                    regexSource: createFilterRegexPattern(text, flag),\n                    ignoreCase: true,\n                    negated,\n                };\n            }\n            case 'regex': {\n                return this.lowerRegex(input.field, value);\n            }\n            case 'existence': {\n                return {\n                    kind: 'null-check', \n                    field: input.field, \n                    negated: !!value, \n                    elementwise: false,\n                };\n            }\n            case 'arithmetic': {\n                return this.lowerMod(input.field, value);\n            }\n            case 'cardinality': {\n                const valid = typeof value === 'number' &&\n                    Number.isInteger(value) &&\n                    value >= 0;\n\n                return {\n                    kind: 'size',\n                    field: input.field,\n                    count: valid ? value as number : null,\n                };\n            }\n            case 'structural': {\n                return this.lowerElemMatch(input);\n            }\n            default: {\n                throw AdapterError.operatorUnsupported(input.operator);\n            }\n        }\n    }\n\n    protected lowerMembership(\n        field: string,\n        value: unknown,\n        negated: boolean,\n    ) : ConditionPlan {\n        if (!Array.isArray(value) || value.length === 0) {\n            return { kind: 'constant', verdict: negated };\n        }\n\n        const normalized = value.map(\n            (item) => (item === undefined ? null : item),\n        );\n        const values = normalized.filter((item) => item !== null);\n\n        if (values.length === 0) {\n            return {\n                kind: 'null-check', \n                field, \n                negated, \n                elementwise: true,\n            };\n        }\n\n        return {\n            kind: 'one-of',\n            field,\n            values,\n            includesNull: values.length !== normalized.length,\n            caseFold: this.isFoldableField(field),\n            negated,\n        };\n    }\n\n    protected lowerRegex(field: string, value: unknown) : MatchPlan {\n        if (value instanceof RegExp) {\n            // strip the stateful flags, so repeated test() calls\n            // never depend on lastIndex.\n            const flags = value.flags.replace(/[gy]/g, '');\n\n            return {\n                kind: 'match',\n                field,\n                pattern: {\n                    mode: 'regex', \n                    source: value.source, \n                    flags, \n                },\n                regexSource: value.source,\n                ignoreCase: value.ignoreCase,\n                negated: false,\n            };\n        }\n\n        // a string pattern passes through unvalidated — the\n        // consuming engine (database or RegExp) interprets it.\n        if (typeof value === 'string') {\n            return {\n                kind: 'match',\n                field,\n                pattern: {\n                    mode: 'regex', \n                    source: value, \n                    flags: '', \n                },\n                regexSource: value,\n                ignoreCase: false,\n                negated: false,\n            };\n        }\n\n        throw AdapterError.featureUnsupported('filters:regex:value');\n    }\n\n    protected lowerMod(field: string, value: unknown) : ConditionPlan {\n        if (\n            !Array.isArray(value) ||\n            value.length !== 2 ||\n            typeof value[0] !== 'number' ||\n            !Number.isFinite(value[0]) ||\n            typeof value[1] !== 'number' ||\n            !Number.isFinite(value[1]) ||\n            value[0] === 0\n        ) {\n            // a malformed divisor/remainder pair matches nothing\n            // (mongo parity), on every backend.\n            return { kind: 'constant', verdict: false };\n        }\n\n        return {\n            kind: 'mod', \n            field, \n            divisor: value[0], \n            remainder: value[1],\n        };\n    }\n\n    protected lowerElemMatch(input: IFilter) : ConditionPlan | null {\n        const interior = input.value;\n        if (\n            !isFilter(interior) &&\n            !isFilters(interior as ICondition)\n        ) {\n            // Report a condition-shaped interior through the dedicated\n            // diagnostic, whether it is a live custom condition or detached\n            // transport data. Anything else is an unsupported interior value.\n            if (isDetachedCondition(interior)) {\n                throw AdapterError.conditionDetached(\n                    (interior as Partial<ICondition>).operator,\n                );\n            }\n\n            throw AdapterError.featureUnsupported('filters:elemMatch:value');\n        }\n\n        const oldPrefix = this.fieldPrefix;\n\n        this.fieldPrefix = `${oldPrefix}${input.field}.`;\n        this.elementDepth += 1;\n\n        try {\n            const condition = this.lower(interior as ICondition);\n            if (!condition) {\n                return null;\n            }\n\n            return {\n                kind: 'elem-match', \n                field: input.field, \n                condition, \n            };\n        } finally {\n            this.fieldPrefix = oldPrefix;\n            this.elementDepth -= 1;\n        }\n    }\n\n    // -----------------------------------------------------------\n\n    /**\n     * The settled case policy: equality-family comparisons on the\n     * field fold unless opted out via `caseSensitive` (matched on\n     * the full path composed through elemMatch scopes). Backends\n     * apply only their remaining capability veto.\n     */\n    protected isFoldableField(field: string) : boolean {\n        if (this.caseSensitiveAll) {\n            return false;\n        }\n\n        return !this.caseSensitiveFields.has(`${this.fieldPrefix}${field}`);\n    }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { FilterCompoundOperator } from '../../schema';\nimport type { ICondition } from './condition';\nimport { Filters, isFilters } from './collection';\nimport type { IFilters } from './collection';\nimport { Filter, isFilter } from './record';\nimport type { IFilter } from './record';\n\nexport function preserve<OP extends string, V>(condition: IFilter<OP, V>): IFilter<OP, V>;\nexport function preserve<T extends ICondition>(condition: IFilters<T>): IFilters<T>;\n/**\n * The catch-all admits every subtype too, so it cannot promise the\n * {@link IFilters} wrapper a custom condition receives: an argument merely\n * *typed* as {@link ICondition} may still be a leaf at runtime. Narrow the\n * result with `isFilter` / `isFilters` when the kind matters.\n */\nexport function preserve(condition: ICondition): ICondition;\nexport function preserve(condition: ICondition): ICondition {\n    if (isFilter(condition)) {\n        return condition.preserved ? condition :\n            new Filter(condition.operator, condition.field, condition.value, { preserved: true });\n    }\n\n    if (isFilters(condition)) {\n        return condition.preserved ? condition :\n            new Filters(condition.operator, condition.value, { preserved: true });\n    }\n\n    return new Filters(FilterCompoundOperator.AND, [condition], { preserved: true });\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { dispatchesTo } from '../../utils';\nimport type { IPagination, IPaginationVisitor } from './types';\n\n/**\n * A `Pagination` node is identified by its visitor dispatch: accept()\n * of a pagination node calls visitPagination and nothing else. Works\n * across package instances, where instanceof fails.\n */\nexport function isPagination(input: unknown) : input is IPagination {\n    return dispatchesTo<IPaginationVisitor<unknown>>(input, 'visitPagination');\n}\n","/*\n * Copyright (c) 2025.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IPagination, IPaginationVisitor } from './types';\n\nexport class Pagination implements IPagination {\n    limit : number | undefined;\n\n    offset : number | undefined;\n\n    constructor(limit?: number, offset?: number) {\n        this.limit = limit;\n        this.offset = offset;\n    }\n\n    accept<R>(visitor: IPaginationVisitor<R>) : R {\n        return visitor.visitPagination(this);\n    }\n\n    /**\n     * Per-property left/receiver priority — limit and offset are merged\n     * independently. Immutable — returns a new instance.\n     */\n    merge(other: IPagination) : IPagination {\n        return new Pagination(\n            this.limit ?? other.limit,\n            this.offset ?? other.offset,\n        );\n    }\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { dispatchesTo } from '../../../utils';\nimport type { IRelation, IRelationVisitor } from './types';\n\n/**\n * A `Relation` record is identified by its visitor dispatch: accept()\n * of a relation node calls visitRelation and nothing else. Works across\n * package instances, where instanceof fails, and distinguishes the\n * structurally overlapping record nodes (Relation, Field, Sort).\n */\nexport function isRelation(input: unknown) : input is IRelation {\n    return dispatchesTo<IRelationVisitor<unknown>>(input, 'visitRelation');\n}\n","/*\n * Copyright (c) 2025-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IRelation, IRelationVisitor } from './types';\n\nexport class Relation implements IRelation {\n    readonly name: string;\n\n    constructor(name: string) {\n        this.name = name;\n    }\n\n    accept<R>(visitor: IRelationVisitor<R>) : R {\n        return visitor.visitRelation(this);\n    }\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { dispatchesTo } from '../../../utils';\nimport type { IRelations, IRelationsVisitor } from './types';\n\n/**\n * A `Relations` collection is identified by its visitor dispatch:\n * accept() of a relations node calls visitRelations and nothing else.\n * Works across package instances, where instanceof fails, and\n * distinguishes the structurally identical collection nodes\n * (Relations, Sorts, ...).\n */\nexport function isRelations(input: unknown) : input is IRelations {\n    return dispatchesTo<IRelationsVisitor<unknown>>(input, 'visitRelations');\n}\n","/*\n * Copyright (c) 2025-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IRelation } from '../record';\nimport { Relation } from '../record';\nimport type { IRelations, IRelationsVisitor } from './types';\n\nexport class Relations implements IRelations {\n    readonly value: IRelation[];\n\n    constructor(value: IRelation[] = []) {\n        this.value = value;\n    }\n\n    accept<R>(visitor: IRelationsVisitor<R>) : R {\n        return visitor.visitRelations(this);\n    }\n\n    /**\n     * Collect the child relations below a given root\n     * (e.g. root \"items\" yields \"realm\" for \"items.realm\").\n     *\n     * The collection itself is left untouched — parsers share one\n     * relations instance across all parameters, so consuming entries\n     * here would corrupt the parsed query.\n     */\n    extract(root: string): IRelations {\n        const children: Relations = new Relations();\n\n        const prefix = `${root}.`;\n        for (const relation of this.value) {\n            if (relation.name.substring(0, prefix.length) === prefix) {\n                children.value.push(new Relation(relation.name.substring(prefix.length)));\n            }\n        }\n\n        return children;\n    }\n\n    /**\n     * Keyed by name, left/receiver priority; order = first occurrence.\n     * Immutable — returns a new collection.\n     */\n    merge(other: IRelations) : IRelations {\n        const output : IRelation[] = [];\n\n        const seen = new Set<string>();\n        for (const item of [...this.value, ...other.value]) {\n            if (seen.has(item.name)) {\n                continue;\n            }\n\n            seen.add(item.name);\n            output.push(item);\n        }\n\n        return new Relations(output);\n    }\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { dispatchesTo } from '../../../utils';\nimport type { ISort, ISortVisitor } from './types';\n\n/**\n * A `Sort` record is identified by its visitor dispatch: accept() of a\n * sort node calls visitSort and nothing else. Works across package\n * instances, where instanceof fails, and distinguishes the structurally\n * overlapping record nodes (Sort, Field, Relation).\n */\nexport function isSort(input: unknown) : input is ISort {\n    return dispatchesTo<ISortVisitor<unknown>>(input, 'visitSort');\n}\n","/*\n * Copyright (c) 2025-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SortDirection } from '../../../schema';\nimport type { ISort, ISortVisitor } from './types';\n\nexport class Sort implements ISort {\n    readonly name: string;\n\n    readonly operator: `${SortDirection}`;\n\n    constructor(name: string, operator?: `${SortDirection}`) {\n        this.name = name;\n        this.operator = operator || SortDirection.ASC;\n    }\n\n    accept<R>(visitor: ISortVisitor<R>) : R {\n        return visitor.visitSort(this);\n    }\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { dispatchesTo } from '../../../utils';\nimport type { ISorts, ISortsVisitor } from './types';\n\n/**\n * A `Sorts` collection is identified by its visitor dispatch: accept()\n * of a sorts node calls visitSorts and nothing else. Works across\n * package instances, where instanceof fails, and distinguishes the\n * structurally identical collection nodes (Sorts, Fields, ...).\n */\nexport function isSorts(input: unknown) : input is ISorts {\n    return dispatchesTo<ISortsVisitor<unknown>>(input, 'visitSorts');\n}\n","/*\n * Copyright (c) 2025-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ISort } from '../record';\nimport type { ISorts, ISortsVisitor } from './types';\n\nexport class Sorts implements ISorts {\n    readonly value: ISort[];\n\n    constructor(value: ISort[] = []) {\n        this.value = value;\n    }\n\n    accept<R>(visitor: ISortsVisitor<R>) : R {\n        return visitor.visitSorts(this);\n    }\n\n    /**\n     * Keyed by name, left/receiver priority; order = first occurrence.\n     * Immutable — returns a new collection.\n     */\n    merge(other: ISorts) : ISorts {\n        const output : ISort[] = [];\n\n        const seen = new Set<string>();\n        for (const item of [...this.value, ...other.value]) {\n            if (seen.has(item.name)) {\n                continue;\n            }\n\n            seen.add(item.name);\n            output.push(item);\n        }\n\n        return new Sorts(output);\n    }\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { dispatchesTo } from '../utils';\nimport type { IQuery, IQueryVisitor } from './types';\n\n/**\n * A `Query` node is identified by its visitor dispatch: accept() of a\n * query node calls visitQuery and nothing else. Works across package\n * instances, where instanceof fails.\n */\nexport function isQuery(input: unknown) : input is IQuery {\n    return dispatchesTo<IQueryVisitor<unknown>>(input, 'visitQuery');\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IFields } from './fields';\nimport {\n    Fields,\n} from './fields';\nimport type { IFilters } from './filters';\nimport {\n    Filters,\n} from './filters';\nimport type { IPagination } from './pagination';\nimport { Pagination } from './pagination';\nimport type { IRelations } from './relations';\nimport { Relations } from './relations';\nimport type { ISorts } from './sorts';\nimport {\n    Sorts,\n} from './sorts';\nimport type { IQuery, IQueryVisitor, QueryContext } from './types';\nimport { FilterCompoundOperator } from '../schema';\n\nexport class Query implements IQuery {\n    readonly fields : IFields;\n\n    readonly filters : IFilters;\n\n    readonly relations : IRelations;\n\n    readonly pagination : IPagination;\n\n    readonly sorts : ISorts;\n\n    constructor(options: QueryContext = {}) {\n        this.fields = options.fields || new Fields();\n        this.filters = options.filters || new Filters(FilterCompoundOperator.AND, []);\n        this.relations = options.relations || new Relations();\n        this.pagination = options.pagination || new Pagination();\n        this.sorts = options.sorts || new Sorts();\n    }\n\n    accept<R>(visitor: IQueryVisitor<R>) : R {\n        return visitor.visitQuery(this);\n    }\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { Query } from './module';\nimport type { IQuery } from './types';\n\n/**\n * Merge queries (the IR). Fields, relations and sorts have left priority:\n * the first occurrence sets value and position. Pagination merges\n * limit/offset independently. Filters use {@link IFilters.merge} as an\n * ordered logical AND, retaining every condition.\n *\n * Immutable — inputs stay untouched, a new {@link Query} is returned.\n */\nexport function mergeQueries(...input: IQuery[]) : Query {\n    const [first, ...rest] = input;\n    if (!first) {\n        return new Query();\n    }\n\n    let {\n        fields, \n        filters, \n        pagination, \n        relations, \n        sorts,\n    } = first;\n\n    for (const query of rest) {\n        fields = fields.merge(query.fields);\n        filters = filters.merge(query.filters);\n        pagination = pagination.merge(query.pagination);\n        relations = relations.merge(query.relations);\n        sorts = sorts.merge(query.sorts);\n    }\n\n    return new Query({\n        fields, \n        filters, \n        pagination, \n        relations, \n        sorts,\n    });\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '../utils';\n\nexport type ParameterNode = { accept: (visitor: any) => any };\n\n/**\n * Every AST parameter node (Fields, Filters, Filter, Pagination, ...)\n * carries an accept method for visitor dispatch; plain build input never\n * does. This separates already-built fragments from raw input.\n */\nexport function isParameterNode<T extends ParameterNode = ParameterNode>(\n    input: unknown,\n) : input is T {\n    return isObject(input) && typeof input.accept === 'function';\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { BuildError } from '../../../errors';\nimport type { IField, IFields } from '../../../parameter';\nimport { Field, Fields } from '../../../parameter';\nimport { FieldOperator } from '../../../schema';\nimport type { ObjectLiteral } from '../../../types';\nimport { isObject } from '../../../utils';\nimport { isParameterNode } from '../../utils';\nimport type { FieldsBuildInput } from './types';\n\n/**\n * The generic-less overload comes first: without an explicit record\n * generic, input is checked against the plain-string grammar instead of\n * letting inference derive RECORD from the argument (a bare string would\n * otherwise become the record type and yield nonsense key types).\n */\nexport function defineFields(input: FieldsBuildInput<ObjectLiteral> | IFields) : IFields;\nexport function defineFields<\n    RECORD extends ObjectLiteral,\n>(input: FieldsBuildInput<RECORD> | IFields) : IFields;\nexport function defineFields(input: FieldsBuildInput<ObjectLiteral> | IFields) : IFields {\n    if (isParameterNode<IFields>(input)) {\n        return input;\n    }\n\n    const output : IField[] = [];\n    buildFields(output, input);\n\n    return new Fields(output);\n}\n\nfunction buildFields(\n    output: IField[],\n    input: unknown,\n    prefix?: string,\n) : void {\n    if (typeof input === 'string') {\n        for (const part of input.split(',')) {\n            const name = part.trim();\n            if (!name) {\n                continue;\n            }\n\n            pushField(output, name, prefix);\n        }\n\n        return;\n    }\n\n    if (Array.isArray(input)) {\n        // tuple form: [simple keys, relation record]\n        if (\n            input.length === 2 &&\n            Array.isArray(input[0]) &&\n            isObject(input[1])\n        ) {\n            buildFields(output, input[0], prefix);\n            buildFields(output, input[1], prefix);\n\n            return;\n        }\n\n        for (const element of input) {\n            if (typeof element !== 'string') {\n                throw BuildError.inputInvalid();\n            }\n\n            pushField(output, element, prefix);\n        }\n\n        return;\n    }\n\n    if (isObject(input)) {\n        const keys = Object.keys(input);\n        for (const key of keys) {\n            if (typeof input[key] === 'undefined') {\n                continue;\n            }\n\n            buildFields(output, input[key], prefix ? `${prefix}.${key}` : key);\n        }\n\n        return;\n    }\n\n    throw BuildError.inputInvalid();\n}\n\nfunction pushField(\n    output: IField[],\n    input: string,\n    prefix?: string,\n) : void {\n    let name = input;\n    let operator : `${FieldOperator}` | undefined;\n\n    const character = name.substring(0, 1);\n    if (\n        character === FieldOperator.INCLUDE ||\n        character === FieldOperator.EXCLUDE\n    ) {\n        operator = character;\n        name = name.substring(1);\n    }\n\n    output.push(new Field(prefix ? `${prefix}.${name}` : name, operator));\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { ITSELF, isCondition } from '../../../parameter';\nimport { isObject } from '../../../utils';\nimport { isParameterNode } from '../../utils';\n\n/**\n * Whether a field value opens a nested record to traverse into rather than\n * describing the field itself. Everything else is a leaf: a scalar, `null`,\n * a bare array (`in` sugar), a `RegExp`, a `Date`, or an operator object.\n *\n * Internal, and single-sourced deliberately. `buildFieldConditions` lowers a\n * value with this rule and `mergeFiltersInput` canonicalizes key paths with\n * it, so a value shape that moved between leaf and branch without both\n * agreeing would silently yield a different set of paths than it yields\n * conditions. It lives here rather than in either consumer so neither owns\n * it, and it is kept out of the barrel because it is not public API.\n */\nexport function isNestedRecordValue(field: string, value: unknown) : boolean {\n    return (\n        isObject(value) &&\n        !Array.isArray(value) &&\n        !(value instanceof RegExp) &&\n        !(value instanceof Date) &&\n        !isCondition(value) &&\n        !isParameterNode(value) &&\n        !Object.keys(value).some((key) => key.substring(0, 1) === '$') &&\n        field !== ITSELF\n    );\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { BuildError } from '../../../errors';\nimport { isCondition } from '../../../parameter';\nimport type { CONDITION_MARKER } from '../../../parameter';\nimport type { ObjectLiteral } from '../../../types';\nimport { isObject } from '../../../utils';\nimport type { FiltersBuildInput } from './types';\nimport { isNestedRecordValue } from './value';\n\n/**\n * Excludes a live condition from an input position at compile time. The\n * generic-less arm resolves `FiltersBuildInput<ObjectLiteral>` to a bag of\n * `any` values, which a condition object structurally satisfies, so without\n * this the type-level half of the guard would hold only for callers who\n * supply the record generic.\n */\ntype NotACondition = { [CONDITION_MARKER]?: never };\n\n/**\n * Per-field replace over filter build input: the first input to constrain a\n * field wins it, and every field only one side constrains survives. This is\n * the override-a-default operation, and it lives here rather than on the\n * `Query` because a build input is plain data: it cannot carry a\n * server-authored scope, so replacement cannot displace one. Composition of\n * queries is conjunction and never drops a predicate ({@link mergeQueries}).\n *\n * Both notations {@link FiltersBuildInput} admits address the same fields —\n * `{ 'realm.name': v }` and `{ realm: { name: v } }` — so inputs are reduced\n * to their canonical dotted paths before being compared. Two inputs written\n * in different notations therefore still replace each other, and a nested\n * record is replaced key by key instead of wholesale the way an object\n * spread would.\n *\n * ```typescript\n * mergeFiltersInput<User>(\n *     { realm: { name: 'b' } },\n *     { 'realm.name': 'a', 'realm.id': 1 },\n * );\n * // { 'realm.name': 'b', 'realm.id': 1 }\n * ```\n *\n * Replacement is per field, not per operator: `{ age: { $gte: 18 } }` beating\n * `{ age: { $lt: 65 } }` yields the lower bound alone. Keeping both is\n * conjunction, which is what composing two queries does.\n *\n * A `$elemMatch` interior is a value, replaced whole. An `undefined` value\n * claims no field, so a later input still supplies it. The result is the flat\n * notation, itself valid input for {@link defineFilters} or another merge.\n */\nexport function mergeFiltersInput(\n    ...input: (FiltersBuildInput<ObjectLiteral> & NotACondition)[]\n) : FiltersBuildInput<ObjectLiteral>;\nexport function mergeFiltersInput<\n    RECORD extends ObjectLiteral,\n>(...input: (FiltersBuildInput<RECORD> & NotACondition)[]) : FiltersBuildInput<RECORD>;\nexport function mergeFiltersInput(\n    ...input: FiltersBuildInput<ObjectLiteral>[]\n) : FiltersBuildInput<ObjectLiteral> {\n    const output : Record<string, unknown> = {};\n\n    for (const current of input) {\n        collectPaths(current, '', output);\n    }\n\n    return output as FiltersBuildInput<ObjectLiteral>;\n}\n\n/**\n * Reduce one input to canonical dotted paths, keeping the first value seen\n * for each. First-occurrence priority is applied here rather than by the\n * caller so it holds within a single input too: an input naming one field\n * under both notations resolves the same way two inputs do.\n */\nfunction collectPaths(\n    input: unknown,\n    prefix: string,\n    output: Record<string, unknown>,\n) : void {\n    // a live condition is not build input. Admitting one would make this a\n    // second composition path over server-authored trees, which is the\n    // primitive filter composition was made conjunctive to remove.\n    if (isCondition(input)) {\n        throw BuildError.inputInvalid();\n    }\n\n    if (!isObject(input)) {\n        throw BuildError.inputInvalid();\n    }\n\n    for (const key of Object.keys(input)) {\n        const value = input[key];\n\n        // skipped rather than recorded, so `{ name: undefined }` states no\n        // opinion instead of claiming the field and blanking it. Mirrors the\n        // build layer, which lowers such a key to no condition at all.\n        if (typeof value === 'undefined') {\n            continue;\n        }\n\n        const field = prefix ? `${prefix}.${key}` : key;\n\n        // a `$`-prefixed root key is not a field. It is passed through\n        // unresolved so defineFilters still reports it, rather than being\n        // reinterpreted as a path segment here.\n        if (!prefix && key.substring(0, 1) === '$') {\n            if (!Object.hasOwn(output, key)) {\n                output[key] = value;\n            }\n\n            continue;\n        }\n\n        if (isNestedRecordValue(field, value)) {\n            collectPaths(value, field, output);\n\n            continue;\n        }\n\n        if (!Object.hasOwn(output, field)) {\n            output[field] = value;\n        }\n    }\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { BuildError } from '../../../errors';\nimport type { ICondition, IFilters } from '../../../parameter';\nimport {\n    Filter, \n    Filters, \n    ITSELF, \n    isCondition,\n    isFilter, \n    isFilters,\n} from '../../../parameter';\nimport { FilterCompoundOperator, FilterFieldOperator } from '../../../schema';\nimport type { ObjectLiteral } from '../../../types';\nimport { isObject } from '../../../utils';\nimport { isParameterNode } from '../../utils';\nimport type { FiltersBuildInput } from './types';\nimport { isNestedRecordValue } from './value';\n\nconst OPERATORS : Record<string, string> = {};\nfor (const operator of Object.values(FilterFieldOperator)) {\n    OPERATORS[`$${operator}`] = operator;\n}\n\n/**\n * The generic-less overload comes first: without an explicit record\n * generic, input is checked against the plain-string grammar instead of\n * letting inference derive RECORD from the argument.\n */\nexport function defineFilters(input: FiltersBuildInput<ObjectLiteral> | ICondition) : IFilters;\nexport function defineFilters<\n    RECORD extends ObjectLiteral,\n>(input: FiltersBuildInput<RECORD> | ICondition) : IFilters;\nexport function defineFilters(input: FiltersBuildInput<ObjectLiteral> | ICondition) : IFilters {\n    if (isCondition(input)) {\n        assertConditionFields(input, false);\n\n        if (isFilters(input)) {\n            return input;\n        }\n\n        // a single leaf condition — wrap it into the canonical root-AND.\n        return new Filters(FilterCompoundOperator.AND, [input]);\n    }\n\n    if (isDetachedCondition(input)) {\n        throw BuildError.inputInvalid();\n    }\n\n    return new Filters(\n        FilterCompoundOperator.AND,\n        buildConditions(input),\n    );\n}\n\n/**\n * Detect condition-shaped runtime data that lost its non-serializable brand\n * in a JSON/RPC/cache round trip. Without the brand it would otherwise be\n * read as a record of field/value pairs and filter on columns literally\n * named `operator` and `value`.\n *\n * Deliberately narrow: only an object whose own keys are exactly the\n * condition properties, with a recognized operator, qualifies. A build\n * input that merely happens to carry an `operator` column keeps\n * working.\n */\nfunction isDetachedCondition(input: unknown) : boolean {\n    if (!isObject(input)) {\n        return false;\n    }\n\n    const keys = Object.keys(input);\n    if (keys.length === 0) {\n        return false;\n    }\n\n    for (const key of keys) {\n        if (key !== 'operator' && key !== 'value' && key !== 'preserved' && key !== 'field') {\n            return false;\n        }\n    }\n\n    // a real condition always carries its operand, so requiring one keeps\n    // a single-column record filter (`{ operator: 'eq' }`, meaning a column\n    // literally named `operator`) out of the guard. `field` counts too: a\n    // leaf built with an undefined value loses `value` to JSON but keeps it.\n    if (\n        !keys.includes('operator') ||\n        (!keys.includes('value') && !keys.includes('field')) ||\n        typeof input.operator !== 'string'\n    ) {\n        return false;\n    }\n\n    return (\n        Object.values(FilterFieldOperator).includes(input.operator as FilterFieldOperator) ||\n        Object.values(FilterCompoundOperator).includes(input.operator as FilterCompoundOperator)\n    );\n}\n\nfunction buildConditions(\n    input: unknown,\n    prefix?: string,\n    insideElemMatch = false,\n) : ICondition[] {\n    if (!isObject(input)) {\n        throw BuildError.inputInvalid();\n    }\n\n    const output : ICondition[] = [];\n\n    const keys = Object.keys(input);\n    for (const key of keys) {\n        const value = input[key];\n        if (typeof value === 'undefined') {\n            continue;\n        }\n\n        // a $-prefixed key is never a field name — with one exception:\n        // the ITSELF marker addresses the array element inside an\n        // elemMatch interior.\n        if (key.startsWith('$') && !(key === ITSELF && insideElemMatch && !prefix)) {\n            throw BuildError.keyInvalid(key);\n        }\n\n        output.push(...buildFieldConditions(\n            prefix ? `${prefix}.${key}` : key,\n            value,\n            insideElemMatch,\n        ));\n    }\n\n    return output;\n}\n\nfunction buildFieldConditions(\n    field: string,\n    value: unknown,\n    insideElemMatch = false,\n) : ICondition[] {\n    // the ITSELF marker is only legal as a complete field —\n    // it addresses the element itself and has no dotted form.\n    if (field !== ITSELF && field.split('.').includes(ITSELF)) {\n        throw BuildError.keyInvalid(field);\n    }\n\n    // bare array = IN sugar; null is a legal element,\n    // backend adapters own the `OR IS NULL` rewrite.\n    if (Array.isArray(value)) {\n        return [new Filter(FilterFieldOperator.IN, field, value)];\n    }\n\n    if (value instanceof RegExp) {\n        return [new Filter(FilterFieldOperator.REGEX, field, value)];\n    }\n\n    if (value instanceof Date) {\n        return [new Filter(FilterFieldOperator.EQUAL, field, value)];\n    }\n\n    // a live condition already carries its own semantics. As a field value\n    // it is ambiguous input and must not be expanded like a record.\n    if (isCondition(value) || isParameterNode(value)) {\n        throw BuildError.keyValueInvalid(field);\n    }\n\n    if (isObject(value)) {\n        const keys = Object.keys(value);\n\n        const isOperatorInput = keys.some((key) => key.substring(0, 1) === '$');\n        if (isOperatorInput) {\n            const output : ICondition[] = [];\n            for (const key of keys) {\n                // optional operator keys may be present but undefined\n                // (conditional spreads) — they carry no condition.\n                if (typeof value[key] === 'undefined') {\n                    continue;\n                }\n\n                output.push(buildOperatorCondition(field, key, value[key]));\n            }\n\n            return output;\n        }\n\n        // nested record — relation traversal via dot-path prefixing;\n        // the element itself has no properties to traverse into. Asking the\n        // shared predicate rather than re-testing the marker here is what\n        // keeps lowering and path canonicalization from drifting apart.\n        if (!isNestedRecordValue(field, value)) {\n            throw BuildError.keyValueInvalid(field);\n        }\n\n        return buildConditions(value, field, insideElemMatch);\n    }\n\n    // scalar (incl. null) = EQUAL sugar.\n    return [new Filter(FilterFieldOperator.EQUAL, field, value)];\n}\n\nfunction buildOperatorCondition(\n    field: string,\n    key: string,\n    value: unknown,\n) : ICondition {\n    if (key === `$${FilterFieldOperator.ELEM_MATCH}`) {\n        let condition : ICondition;\n        if (isCondition(value)) {\n            assertConditionFields(value, true);\n\n            condition = value;\n        } else {\n            let conditions : ICondition[];\n            if (\n                isObject(value) &&\n                Object.keys(value).every((child) => child.startsWith('$') && child !== ITSELF)\n            ) {\n                // element-level operator object (mongo's\n                // { $elemMatch: { $gt: 5 } }) — the operators apply\n                // to the element itself.\n                conditions = buildFieldConditions(ITSELF, value, true);\n            } else {\n                conditions = buildConditions(value, undefined, true);\n            }\n\n            const [first] = conditions;\n            condition = first && conditions.length === 1 ?\n                first :\n                new Filters(FilterCompoundOperator.AND, conditions);\n        }\n\n        return new Filter(FilterFieldOperator.ELEM_MATCH, field, condition);\n    }\n\n    if (key.substring(0, 1) !== '$') {\n        throw BuildError.keyInvalid(key);\n    }\n\n    const operator = OPERATORS[key];\n    if (!operator) {\n        throw BuildError.operatorUnsupported(key);\n    }\n\n    if (\n        operator === FilterFieldOperator.IN ||\n        operator === FilterFieldOperator.NOT_IN\n    ) {\n        return new Filter(operator, field, Array.isArray(value) ? value : [value]);\n    }\n\n    return new Filter(operator, field, value);\n}\n\n/**\n * Verify the ITSELF marker contract on a pre-built condition tree:\n * the marker is only legal as the complete field of a condition\n * inside an elemMatch interior.\n */\nfunction assertConditionFields(\n    input: ICondition,\n    insideElemMatch: boolean,\n) : void {\n    if (isFilters(input)) {\n        for (const child of input.value) {\n            if (isCondition(child)) {\n                assertConditionFields(child, insideElemMatch);\n            }\n        }\n\n        return;\n    }\n\n    if (!isFilter(input)) {\n        return;\n    }\n\n    if (input.field === ITSELF) {\n        if (!insideElemMatch) {\n            throw BuildError.keyInvalid(input.field);\n        }\n    } else if (input.field.split('.').includes(ITSELF)) {\n        throw BuildError.keyInvalid(input.field);\n    }\n\n    if (\n        input.operator === FilterFieldOperator.ELEM_MATCH &&\n        isCondition(input.value)\n    ) {\n        assertConditionFields(input.value, true);\n    }\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { BuildError } from '../../../errors';\nimport type { IPagination } from '../../../parameter';\nimport { Pagination } from '../../../parameter';\nimport { isObject } from '../../../utils';\nimport { isParameterNode } from '../../utils';\nimport type { PaginationBuildInput } from './types';\n\nexport function definePagination(\n    input: PaginationBuildInput | IPagination,\n) : IPagination {\n    if (isParameterNode<IPagination>(input)) {\n        return input;\n    }\n\n    if (!isObject(input)) {\n        throw BuildError.inputInvalid();\n    }\n\n    return new Pagination(input.limit, input.offset);\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { BuildError } from '../../../errors';\nimport type { IRelation, IRelations } from '../../../parameter';\nimport { Relation, Relations } from '../../../parameter';\nimport type { ObjectLiteral } from '../../../types';\nimport { isObject } from '../../../utils';\nimport { isParameterNode } from '../../utils';\nimport type { RelationsBuildInput } from './types';\n\n/**\n * The generic-less overload comes first: without an explicit record\n * generic, input is checked against the plain-string grammar instead of\n * letting inference derive RECORD from the argument (a bare string would\n * otherwise become the record type and yield nonsense key types).\n */\nexport function defineRelations(input: RelationsBuildInput<ObjectLiteral> | IRelations) : IRelations;\nexport function defineRelations<\n    RECORD extends ObjectLiteral,\n>(input: RelationsBuildInput<RECORD> | IRelations) : IRelations;\nexport function defineRelations(input: RelationsBuildInput<ObjectLiteral> | IRelations) : IRelations {\n    if (isParameterNode<IRelations>(input)) {\n        return input;\n    }\n\n    const output : IRelation[] = [];\n    buildRelations(output, input);\n\n    return new Relations(output);\n}\n\nfunction buildRelations(\n    output: IRelation[],\n    input: unknown,\n    prefix?: string,\n) : void {\n    if (typeof input === 'string') {\n        for (const part of input.split(',')) {\n            const name = part.trim();\n            if (!name) {\n                continue;\n            }\n\n            output.push(new Relation(prefix ? `${prefix}.${name}` : name));\n        }\n\n        return;\n    }\n\n    if (Array.isArray(input)) {\n        for (const element of input) {\n            if (typeof element !== 'string') {\n                throw BuildError.inputInvalid();\n            }\n\n            output.push(new Relation(prefix ? `${prefix}.${element}` : element));\n        }\n\n        return;\n    }\n\n    if (isObject(input)) {\n        const keys = Object.keys(input);\n        for (const key of keys) {\n            const value = input[key];\n            if (typeof value === 'undefined' || value === false) {\n                continue;\n            }\n\n            const path = prefix ? `${prefix}.${key}` : key;\n\n            if (value === true) {\n                output.push(new Relation(path));\n                continue;\n            }\n\n            buildRelations(output, value, path);\n        }\n\n        return;\n    }\n\n    throw BuildError.inputInvalid();\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { BuildError } from '../../../errors';\nimport type { ISort, ISorts } from '../../../parameter';\nimport { Sort, Sorts } from '../../../parameter';\nimport { SortDirection } from '../../../schema';\nimport type { ObjectLiteral } from '../../../types';\nimport { isObject } from '../../../utils';\nimport { isParameterNode } from '../../utils';\nimport type { SortsBuildInput } from './types';\n\n/**\n * The generic-less overload comes first: without an explicit record\n * generic, input is checked against the plain-string grammar instead of\n * letting inference derive RECORD from the argument (a bare string would\n * otherwise become the record type and yield nonsense key types).\n */\nexport function defineSorts(input: SortsBuildInput<ObjectLiteral> | ISorts) : ISorts;\nexport function defineSorts<\n    RECORD extends ObjectLiteral,\n>(input: SortsBuildInput<RECORD> | ISorts) : ISorts;\nexport function defineSorts(input: SortsBuildInput<ObjectLiteral> | ISorts) : ISorts {\n    if (isParameterNode<ISorts>(input)) {\n        return input;\n    }\n\n    const output : ISort[] = [];\n    buildSorts(output, input);\n\n    return new Sorts(output);\n}\n\nfunction buildSorts(\n    output: ISort[],\n    input: unknown,\n    prefix?: string,\n) : void {\n    if (typeof input === 'string') {\n        for (const part of input.split(',')) {\n            const name = part.trim();\n            if (!name) {\n                continue;\n            }\n\n            pushSort(output, name, prefix);\n        }\n\n        return;\n    }\n\n    if (Array.isArray(input)) {\n        // tuple form: [simple keys, relation record]\n        if (\n            input.length === 2 &&\n            Array.isArray(input[0]) &&\n            isObject(input[1])\n        ) {\n            buildSorts(output, input[0], prefix);\n            buildSorts(output, input[1], prefix);\n\n            return;\n        }\n\n        for (const element of input) {\n            if (typeof element !== 'string') {\n                throw BuildError.inputInvalid();\n            }\n\n            pushSort(output, element, prefix);\n        }\n\n        return;\n    }\n\n    if (isObject(input)) {\n        const keys = Object.keys(input);\n        for (const key of keys) {\n            const value = input[key];\n            if (typeof value === 'undefined') {\n                continue;\n            }\n\n            const path = prefix ? `${prefix}.${key}` : key;\n\n            if (typeof value === 'string') {\n                const lowered = value.toLowerCase();\n                if (lowered !== 'asc' && lowered !== 'desc') {\n                    throw BuildError.keyInvalid(key);\n                }\n\n                output.push(new Sort(\n                    path,\n                    lowered === 'desc' ? SortDirection.DESC : SortDirection.ASC,\n                ));\n\n                continue;\n            }\n\n            buildSorts(output, value, path);\n        }\n\n        return;\n    }\n\n    throw BuildError.inputInvalid();\n}\n\nfunction pushSort(\n    output: ISort[],\n    input: string,\n    prefix?: string,\n) : void {\n    let name = input;\n    let direction : SortDirection = SortDirection.ASC;\n\n    if (name.substring(0, 1) === '-') {\n        direction = SortDirection.DESC;\n        name = name.substring(1);\n    }\n\n    output.push(new Sort(prefix ? `${prefix}.${name}` : name, direction));\n}\n","/*\n * Copyright (c) 2026.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { Parameter } from '../constants';\nimport { BuildError } from '../errors';\nimport type { QueryContext } from '../parameter';\nimport { Query } from '../parameter';\nimport type { ObjectLiteral } from '../types';\nimport { assertKnownInputKeys, resolveAliasedKey } from '../utils';\nimport {\n    defineFields,\n    defineFilters,\n    definePagination,\n    defineRelations,\n    defineSorts,\n} from './parameter';\nimport type { QueryBuildInput } from './types';\n\nconst BUILD_INPUT_KEYS : string[] = [\n    Parameter.FIELDS,\n    Parameter.FILTERS,\n    Parameter.PAGINATION,\n    Parameter.RELATIONS,\n    Parameter.SORTS,\n    Parameter.SORT,\n];\n\n/**\n * Build a {@link Query} (the IR) directly from typed input — no string\n * round-trip, no parsing, no schema. Validation against a schema happens\n * server-side after transport.\n */\nexport function defineQuery(input?: QueryBuildInput<ObjectLiteral>) : Query;\nexport function defineQuery<\n    RECORD extends ObjectLiteral,\n    DEPTH extends number = 5,\n>(input?: QueryBuildInput<RECORD, DEPTH>) : Query;\nexport function defineQuery(input: QueryBuildInput<ObjectLiteral> = {}) : Query {\n    assertKnownInputKeys(\n        input,\n        BUILD_INPUT_KEYS,\n        (key, suggestion) => BuildError.keyUnknown(key, suggestion),\n    );\n\n    const context : QueryContext = {};\n\n    if (typeof input.fields !== 'undefined') {\n        context.fields = defineFields(input.fields);\n    }\n\n    if (typeof input.filters !== 'undefined') {\n        context.filters = defineFilters(input.filters);\n    }\n\n    if (typeof input.pagination !== 'undefined') {\n        context.pagination = definePagination(input.pagination);\n    }\n\n    if (typeof input.relations !== 'undefined') {\n        context.relations = defineRelations(input.relations);\n    }\n\n    const sorts = resolveAliasedKey(\n        input,\n        Parameter.SORTS,\n        Parameter.SORT,\n        (canonical, alias) => BuildError.keyAmbiguous(canonical, alias),\n    );\n\n    if (typeof sorts !== 'undefined') {\n        context.sorts = defineSorts(sorts as NonNullable<QueryBuildInput['sorts']>);\n    }\n\n    return new Query(context);\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport {\n    Filter,\n    Filters,\n    ITSELF,\n    isCondition,\n    isFilter,\n    isFilters,\n    preserve,\n} from '../../../parameter';\nimport type {\n    ICondition,\n    IFilter,\n    IFilters,\n} from '../../../parameter';\nimport { FilterFieldOperator } from '../../../schema';\nimport type { FiltersSchema } from '../../../schema';\nimport { toIssuePath } from '../../../utils';\nimport { Parameter } from '../../../constants';\nimport {\n    ErrorCode,\n    ErrorMessage,\n    SchemaError,\n    buildIssue,\n} from '../../../errors';\nimport type { IssueInput } from '../../../errors';\nimport type { IIssueCollector } from '../../issue';\nimport { FiltersParseError } from './error';\n\nexport type FiltersValidationOptions = {\n    /**\n     * Trace of the enclosing parse.\n     */\n    issueCollector?: IIssueCollector,\n    /**\n     * Call-time failure-policy override, taking precedence over the filters\n     * sub-schema's own setting exactly like everywhere else\n     * (`throwOnFailure ?? schema.throwOnFailure ?? false`). Without it a leaf\n     * rejection would be the one violation a call-time override cannot\n     * govern.\n     *\n     * Deliberately NOT the resolving scope's effective policy: the expression\n     * dialect forces its scope to throw because an expression cannot be\n     * partially reinterpreted, and that says nothing about whether a policy\n     * hook declining a leaf should fail the request.\n     */\n    throwOnFailure?: boolean,\n    /**\n     * Absolute path prefix carried through nested filter values.\n     */\n    path?: string[],\n};\n\nfunction appendFilterPath(path: string[], field: string) : string[] {\n    return field === ITSELF ? path : [...path, ...toIssuePath(field)];\n}\n\n/**\n * The conditions a parser falls back to when the input carries no\n * (surviving) filters — the schema `default`, or nothing.\n */\nexport function buildFiltersDefaults(schema: FiltersSchema) : ICondition[] {\n    if (!schema.default) {\n        return [];\n    }\n\n    if (Array.isArray(schema.default)) {\n        return schema.default;\n    }\n\n    return [schema.default];\n}\n\n/**\n * A leaf the schema validator declined.\n *\n * The hook is the filters counterpart of the fields/sorts/relations key\n * validators, so it fails the same way: nothing under a dropping policy (the\n * leaf is dropped and nothing will be raised), and `KEY_VALIDATE_REJECTED`\n * under `throwOnFailure`, recorded into the trace when the parse collects one\n * and thrown (carrying the same issue) where it does not. A hook that means\n * to drop a leaf silently under a throwing schema returns a replacement\n * condition instead of `undefined`.\n */\nfunction rejectLeaf(\n    leaf: IFilter<string, unknown>,\n    schema: FiltersSchema,\n    options: FiltersValidationOptions,\n) : void {\n    const throwOnFailure = options.throwOnFailure ?? schema.throwOnFailure ?? false;\n    if (!throwOnFailure) {\n        return;\n    }\n\n    const issue : IssueInput = {\n        code: ErrorCode.KEY_VALIDATE_REJECTED,\n        parameter: Parameter.FILTERS,\n        path: appendFilterPath(options.path ?? [], leaf.field),\n        message: ErrorMessage.keyValidateRejected(leaf.field),\n    };\n\n    if (options.issueCollector) {\n        options.issueCollector.add(issue);\n\n        return;\n    }\n\n    throw FiltersParseError.keyValidateRejected(leaf.field, [buildIssue(issue)]);\n}\n\nfunction isPromiseLike(input: unknown) : input is PromiseLike<unknown> {\n    return (\n        input !== null &&\n        (typeof input === 'object' || typeof input === 'function') &&\n        'then' in input &&\n        typeof input.then === 'function'\n    );\n}\n\n/**\n * Apply a filter schema's leaf validator without flattening or otherwise\n * changing the compound tree. Returning `undefined` from the validator drops\n * only that leaf; replacement conditions (a leaf or a whole compound, e.g.\n * `and(<leaf>, <policy residual>)`) are inserted in the same position.\n * A compound whose every child is rejected is dropped entirely (`undefined`),\n * so callers fall back to the schema defaults instead of keeping a vacuous\n * node. An `elemMatch` leaf is validated inside-out: the interior condition\n * tree first (dropping the whole leaf when nothing survives), then the\n * rebuilt leaf itself.\n */\nexport function applyFiltersSchemaValidation(\n    input: IFilters,\n    schema: FiltersSchema,\n    context?: unknown,\n    options?: FiltersValidationOptions,\n) : IFilters | undefined;\nexport function applyFiltersSchemaValidation(\n    input: ICondition,\n    schema: FiltersSchema,\n    context?: unknown,\n    options?: FiltersValidationOptions,\n) : ICondition | undefined;\nexport function applyFiltersSchemaValidation(\n    input: ICondition,\n    schema: FiltersSchema,\n    context?: unknown,\n    options: FiltersValidationOptions = {},\n) : ICondition | undefined {\n    if (!schema.hasValidator()) {\n        return input;\n    }\n\n    if (isFilter(input)) {\n        let leaf = input;\n        if (\n            input.operator === FilterFieldOperator.ELEM_MATCH &&\n            isCondition(input.value)\n        ) {\n            const nestedOptions = {\n                ...options,\n                path: appendFilterPath(options.path ?? [], input.field),\n            };\n            const interior = applyFiltersSchemaValidation(input.value, schema, context, nestedOptions);\n            if (!interior) {\n                return undefined;\n            }\n\n            if (interior !== input.value) {\n                leaf = new Filter(input.operator, input.field, interior, { preserved: input.preserved });\n            }\n        }\n\n        const output = schema.validate(leaf, context);\n        if (isPromiseLike(output)) {\n            void Promise.resolve(output).catch(() => undefined);\n            throw SchemaError.validatorAsyncRequiresAsyncParser();\n        }\n\n        if (!output) {\n            rejectLeaf(leaf, schema, options);\n\n            return undefined;\n        }\n\n        // The replacement stands in for the leaf, so it inherits\n        // relation-pruning preservation.\n        return leaf.preserved ? preserve(output) : output;\n    }\n\n    if (!isFilters(input)) {\n        return input;\n    }\n\n    const conditions : ICondition[] = [];\n    for (const child of input.value) {\n        const validated = applyFiltersSchemaValidation(child, schema, context, options);\n        if (validated) {\n            conditions.push(validated);\n        }\n    }\n\n    if (conditions.length === 0) {\n        return undefined;\n    }\n\n    return new Filters(input.operator, conditions, { preserved: input.preserved });\n}\n\n/**\n * Async counterpart of {@link applyFiltersSchemaValidation}. Validators are\n * awaited sequentially so leaf order and observable execution order remain\n * identical to the synchronous traversal.\n */\nexport function applyFiltersSchemaValidationAsync(\n    input: IFilters,\n    schema: FiltersSchema,\n    context?: unknown,\n    options?: FiltersValidationOptions,\n) : Promise<IFilters | undefined>;\nexport function applyFiltersSchemaValidationAsync(\n    input: ICondition,\n    schema: FiltersSchema,\n    context?: unknown,\n    options?: FiltersValidationOptions,\n) : Promise<ICondition | undefined>;\nexport async function applyFiltersSchemaValidationAsync(\n    input: ICondition,\n    schema: FiltersSchema,\n    context?: unknown,\n    options: FiltersValidationOptions = {},\n) : Promise<ICondition | undefined> {\n    if (!schema.hasValidator()) {\n        return input;\n    }\n\n    if (isFilter(input)) {\n        let leaf = input;\n        if (\n            input.operator === FilterFieldOperator.ELEM_MATCH &&\n            isCondition(input.value)\n        ) {\n            const nestedOptions = {\n                ...options,\n                path: appendFilterPath(options.path ?? [], input.field),\n            };\n            const interior = await applyFiltersSchemaValidationAsync(input.value, schema, context, nestedOptions);\n            if (!interior) {\n                return undefined;\n            }\n\n            if (interior !== input.value) {\n                leaf = new Filter(input.operator, input.field, interior, { preserved: input.preserved });\n            }\n        }\n\n        const output = await schema.validate(leaf, context);\n        if (!output) {\n            rejectLeaf(leaf, schema, options);\n\n            return undefined;\n        }\n\n        return leaf.preserved ? preserve(output) : output;\n    }\n\n    if (!isFilters(input)) {\n        return input;\n    }\n\n    const conditions : ICondition[] = [];\n    for (const child of input.value) {\n        const validated = await applyFiltersSchemaValidationAsync(child, schema, context, options);\n        if (validated) {\n            conditions.push(validated);\n        }\n    }\n\n    if (conditions.length === 0) {\n        return undefined;\n    }\n\n    return new Filters(input.operator, conditions, { preserved: input.preserved });\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { toIssuePath } from '../../utils';\nimport { Parameter } from '../../constants';\nimport {\n    ErrorCode,\n    ErrorMessage,\n    SchemaError,\n    buildIssue,\n} from '../../errors';\nimport type { IssueInput, ParseError } from '../../errors';\nimport type { ICondition } from '../../parameter';\nimport { isCondition } from '../../parameter';\nimport type { IIssueCollector } from '../issue';\nimport type {\n    KeyValidationVerdict,\n    KeyValidationVerdictRecord,\n} from '../../schema';\nimport type { MaybeAsync } from '../../types';\n\n/**\n * The slice of a parameter schema the key-validation pass consumes —\n * implemented by RelationsSchema, FieldsSchema and SortsSchema. The\n * batched members are optional, so an external implementation without\n * them stays source compatible and is simply driven per key.\n */\nexport type KeyValidatableSchema = {\n    readonly name?: string,\n    /**\n     * The parameter this schema governs. Declared once by the schema\n     * (the sub-schema classes set it in their constructors); the\n     * driver derives the condition rules from it per entry, so mixed\n     * obligation pools (a relation ledger fed by every parameter) need\n     * no caller-side annotation.\n     */\n    readonly parameter: `${Parameter}`,\n    hasValidator() : boolean,\n    hasManyValidator?() : boolean,\n    /**\n     * The caller supplies only the dotted relation path of the position\n     * being validated (`''` at the query root); the schema completes the\n     * {@link KeyValidationScope} its hook receives from what it already\n     * knows about itself. The path is REQUIRED on this driver contract:\n     * an omitted path would silently claim the root position, which\n     * fails open for an allow-at-root hook. (The schema classes default\n     * it for direct human calls; a defaulted method still satisfies the\n     * required signature.)\n     */\n    validate(\n        name: string,\n        context: any,\n        path: string,\n    ) : MaybeAsync<KeyValidationVerdict>,\n    validateMany?(\n        names: string[],\n        context: any,\n        path: string,\n    ) : MaybeAsync<KeyValidationVerdictRecord>,\n};\n\n/**\n * A client-requested key whose governing schema may carry a validate\n * hook. Parsers record one entry per resolved key during resolution\n * and evaluate them once the parameter is assembled, so the sync and\n * async entry points share a single resolution pass.\n */\nexport type PendingKeyValidation = {\n    /**\n     * The hook argument — the canonical key relative to the schema\n     * that governs it (the target schema for dotted input).\n     */\n    key: string,\n    /**\n     * Final dotted output name; parsers prefix it with the relation\n     * segment while their recursion unwinds. Used for pruning.\n     */\n    path: string,\n    schema: KeyValidatableSchema,\n    /**\n     * The failure policy of the scope that resolved this key, recorded\n     * at push time so a child schema's own `throwOnFailure` governs its\n     * rejections even inside a pooled pending list. Falls back to the\n     * pass-wide {@link KeyValidationOptions.throwOnFailure} when absent\n     * (the relation ledger, whose policy is the root relations schema's\n     * by contract).\n     */\n    throwOnFailure?: boolean,\n};\n\nexport type KeyValidationOptions = {\n    throwOnFailure: boolean,\n    errors: typeof ParseError,\n    /**\n     * Trace of the enclosing parse. A rejection records an issue there and\n     * lets the parse continue on the drop path; the owning call raises it.\n     */\n    issueCollector?: IIssueCollector,\n    /**\n     * Sink for the conditions of condition-gated keys, keyed by output\n     * path. Supplied by callers that can carry a condition onward (the\n     * fields parsers, onto the `Field` node). Absent means a condition\n     * verdict has nowhere to go and counts as a rejection.\n     */\n    conditions?: Map<string, ICondition>,\n};\n\n/**\n * Evaluate the recorded validate-hook obligations. Returns the output\n * names (paths) of rejected keys for the caller to prune — or throws\n * the parameter's ParseError (`ErrorCode.KEY_VALIDATE_REJECTED`) under\n * `throwOnFailure`, naming the full client-facing path. Duplicate\n * obligations (the same key recorded twice, e.g. from duplicated\n * client input) invoke the hook once. A hook returning a Promise here\n * means the caller sits behind a synchronous `parse()`; that is\n * refused the same way as an async filters validator.\n */\nexport function applyKeySchemaValidation(\n    pending: PendingKeyValidation[],\n    context: unknown,\n    options: KeyValidationOptions,\n) : string[] {\n    const rejected : string[] = [];\n    const entries = dedupe(pending);\n    const batches = new BatchCache();\n\n    for (const entry of entries) {\n        if (!entry.schema.hasValidator()) {\n            continue;\n        }\n\n        let verdict : KeyValidationVerdict;\n\n        if (entry.schema.hasManyValidator?.()) {\n            const record = batches.resolve(\n                entry,\n                entries,\n                (schema, names, path) => refuseAsync(schema.validateMany!(names, context, path)),\n            );\n\n            verdict = refuseAsync(readVerdict(record, entry.key));\n        } else {\n            verdict = refuseAsync(\n                entry.schema.validate(entry.key, context, scopePathOf(entry)),\n            );\n        }\n\n        if (!settle(verdict, entry, options)) {\n            reject(entry, options);\n\n            rejected.push(entry.path);\n        }\n    }\n\n    return rejected;\n}\n\n/**\n * Async counterpart of {@link applyKeySchemaValidation}. Hooks are\n * awaited sequentially so observable execution order matches the\n * synchronous pass.\n */\nexport async function applyKeySchemaValidationAsync(\n    pending: PendingKeyValidation[],\n    context: unknown,\n    options: KeyValidationOptions,\n) : Promise<string[]> {\n    const rejected : string[] = [];\n    const entries = dedupe(pending);\n    const batches = new BatchCache();\n\n    for (const entry of entries) {\n        if (!entry.schema.hasValidator()) {\n            continue;\n        }\n\n        let verdict : KeyValidationVerdict;\n\n        if (entry.schema.hasManyValidator?.()) {\n            const record = await batches.resolveAsync(\n                entry,\n                entries,\n                (schema, names, path) => schema.validateMany!(names, context, path),\n            );\n\n            verdict = await readVerdict(record, entry.key);\n        } else {\n            verdict = await entry.schema.validate(entry.key, context, scopePathOf(entry));\n        }\n\n        if (!settle(verdict, entry, options)) {\n            reject(entry, options);\n\n            rejected.push(entry.path);\n        }\n    }\n\n    return rejected;\n}\n\n/**\n * Memoizes one `validateMany` result per batch. The batch unit is\n * (governing schema instance, scope path): a single registered schema\n * can govern two relation positions of the same query (`items.realm`\n * and `other.realm`), and each is a distinct authorization question.\n * Batches resolve lazily, at the first deduped entry belonging to one,\n * so the hook fires in recorded order like the per-key hook does.\n */\nclass BatchCache {\n    protected records : Map<KeyValidatableSchema, Map<string, KeyValidationVerdictRecord>>;\n\n    constructor() {\n        this.records = new Map();\n    }\n\n    resolve(\n        entry: PendingKeyValidation,\n        entries: PendingKeyValidation[],\n        run: (\n            schema: KeyValidatableSchema,\n            names: string[],\n            path: string,\n        ) => KeyValidationVerdictRecord,\n    ) : KeyValidationVerdictRecord {\n        const path = scopePathOf(entry);\n        const cached = this.read(entry.schema, path);\n        if (cached) {\n            return cached;\n        }\n\n        const record = run(\n            entry.schema,\n            batchKeys(entries, entry.schema, path),\n            path,\n        );\n\n        return this.write(entry.schema, path, record);\n    }\n\n    async resolveAsync(\n        entry: PendingKeyValidation,\n        entries: PendingKeyValidation[],\n        run: (\n            schema: KeyValidatableSchema,\n            names: string[],\n            path: string,\n        ) => MaybeAsync<KeyValidationVerdictRecord>,\n    ) : Promise<KeyValidationVerdictRecord> {\n        const path = scopePathOf(entry);\n        const cached = this.read(entry.schema, path);\n        if (cached) {\n            return cached;\n        }\n\n        const record = await run(\n            entry.schema,\n            batchKeys(entries, entry.schema, path),\n            path,\n        );\n\n        return this.write(entry.schema, path, record);\n    }\n\n    protected read(\n        schema: KeyValidatableSchema,\n        path: string,\n    ) : KeyValidationVerdictRecord | undefined {\n        return this.records.get(schema)?.get(path);\n    }\n\n    protected write(\n        schema: KeyValidatableSchema,\n        path: string,\n        record: KeyValidationVerdictRecord,\n    ) : KeyValidationVerdictRecord {\n        let paths = this.records.get(schema);\n        if (!paths) {\n            paths = new Map();\n            this.records.set(schema, paths);\n        }\n\n        paths.set(path, record);\n\n        return record;\n    }\n}\n\n/**\n * The dotted relation path of the schema governing an obligation.\n * Every recorded `path` ends with its `key`: root entries record\n * `path === key`, and parsers prefix a relation segment while their\n * recursion unwinds, so the remaining prefix is the governing scope.\n */\nfunction scopePathOf(entry: PendingKeyValidation) : string {\n    const offset = entry.path.length - entry.key.length - 1;\n    if (offset < 0) {\n        return '';\n    }\n\n    // the key must sit on a segment boundary, not merely be a suffix of the\n    // path: without this, an obligation like { key: 'me', path: 'awesome' }\n    // would report the governing scope as 'awes'. That path is handed to the\n    // hook as an authorization input and partitions the batches, so a recorder\n    // that breaks the invariant must fall back to the root rather than invent\n    // a relation path that does not exist.\n    if (\n        entry.path.charAt(offset) !== '.' ||\n        entry.path.slice(offset + 1) !== entry.key\n    ) {\n        return '';\n    }\n\n    return entry.path.slice(0, offset);\n}\n\n/**\n * Keys of one batch: every deduped obligation governed by `schema` at\n * `path`, in recorded order, without repeats.\n */\nfunction batchKeys(\n    entries: PendingKeyValidation[],\n    schema: KeyValidatableSchema,\n    path: string,\n) : string[] {\n    const output : string[] = [];\n\n    for (const entry of entries) {\n        if (entry.schema !== schema || scopePathOf(entry) !== path) {\n            continue;\n        }\n\n        if (!output.includes(entry.key)) {\n            output.push(entry.key);\n        }\n    }\n\n    return output;\n}\n\n/**\n * A key absent from a batch record is rejected, mirroring the\n * `undefined`-rejects rule of the per-key hook. Read through\n * `hasOwnProperty` so inherited prototype members (`constructor`,\n * `toString`, …) cannot forge an acceptance.\n *\n * The declared record maps to plain verdicts, but a hook may hand back\n * a promise per key regardless of the type. That is settled like a\n * per-key verdict, refused by the sync driver and awaited by the async\n * one, because a thenable is truthy and would otherwise turn a hook\n * meaning \"reject\" into an acceptance.\n */\nfunction readVerdict(\n    record: KeyValidationVerdictRecord,\n    name: string,\n) : MaybeAsync<KeyValidationVerdict> {\n    if (!Object.prototype.hasOwnProperty.call(record, name)) {\n        return false;\n    }\n\n    return record[name];\n}\n\n/**\n * Accept, reject, or record the condition of one verdict. Returns\n * whether the key survives. A condition gates the VALUE of a projected\n * column, so it is honoured for the fields parameter only, and only\n * when the caller supplied a sink to carry it onward; a sort key or a\n * relation has no column to gate, and a condition there is refused\n * rather than silently dropped.\n */\nfunction settle(\n    verdict: KeyValidationVerdict,\n    entry: PendingKeyValidation,\n    options: KeyValidationOptions,\n) : boolean {\n    if (isCondition(verdict)) {\n        if (\n            options.conditions &&\n            entry.schema.parameter === Parameter.FIELDS\n        ) {\n            options.conditions.set(entry.path, verdict);\n\n            return true;\n        }\n\n        return false;\n    }\n\n    return !!verdict;\n}\n\n/**\n * A hook rejection: recorded into the trace when the parse collects one, and\n * thrown where it is found otherwise (a standalone pass outside a parse). The\n * thrown error carries the same issue, so a catching driver can merge the\n * position rather than synthesize a path-less one.\n */\nfunction reject(\n    entry: PendingKeyValidation,\n    options: KeyValidationOptions,\n) : void {\n    const throwOnFailure = entry.throwOnFailure ?? options.throwOnFailure;\n    if (!throwOnFailure) {\n        return;\n    }\n\n    const issue : IssueInput = {\n        code: ErrorCode.KEY_VALIDATE_REJECTED,\n        parameter: entry.schema.parameter,\n        path: toIssuePath(entry.path),\n        message: ErrorMessage.keyValidateRejected(entry.path),\n    };\n\n    if (options.issueCollector) {\n        options.issueCollector.add(issue);\n\n        return;\n    }\n\n    throw options.errors.keyValidateRejected(entry.path, [buildIssue(issue)]);\n}\n\nfunction dedupe(pending: PendingKeyValidation[]) : PendingKeyValidation[] {\n    const seen = new Map<KeyValidatableSchema, Set<string>>();\n\n    return pending.filter((entry) => {\n        let paths = seen.get(entry.schema);\n        if (!paths) {\n            paths = new Set();\n            seen.set(entry.schema, paths);\n        }\n\n        const id = `${entry.key} ${entry.path}`;\n        if (paths.has(id)) {\n            return false;\n        }\n\n        paths.add(id);\n\n        return true;\n    });\n}\n\n/**\n * Refuse a hook that answered asynchronously while the caller sits behind\n * a synchronous `parse()`. The pending promise is settled defensively so\n * a rejecting hook cannot surface as an unhandled rejection.\n */\nfunction refuseAsync<T>(input: MaybeAsync<T>) : T {\n    if (isPromiseLike(input)) {\n        void Promise.resolve(input).catch(() => undefined);\n        throw SchemaError.validatorAsyncRequiresAsyncParser();\n    }\n\n    return input;\n}\n\nfunction isPromiseLike(input: unknown) : input is PromiseLike<unknown> {\n    return (\n        input !== null &&\n        (typeof input === 'object' || typeof input === 'function') &&\n        'then' in input &&\n        typeof input.then === 'function'\n    );\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport {\n    flattenIssueItems,\n    isIssueGroup,\n    prefixIssuePath,\n} from 'blemish';\nimport type { Issue, IssueItem } from 'blemish';\nimport type { Parameter } from '../../constants';\nimport { MAX_ISSUES, buildIssue } from '../../errors';\nimport type { IParseError, IssueInput } from '../../errors';\nimport type { IIssueCollector } from './types';\n\ntype IssueBudget = {\n    remaining: number;\n};\n\nfunction trimIssueToLeafBudget(input: Issue, budget: IssueBudget) : Issue | undefined {\n    if (budget.remaining <= 0) {\n        return undefined;\n    }\n\n    if (!isIssueGroup(input)) {\n        budget.remaining--;\n\n        return input;\n    }\n\n    const issues : Issue[] = [];\n    for (const child of input.issues) {\n        if (budget.remaining === 0) {\n            break;\n        }\n\n        const retained = trimIssueToLeafBudget(child, budget);\n        if (retained) {\n            issues.push(retained);\n        }\n    }\n\n    return issues.length > 0 ? { ...input, issues } : undefined;\n}\n\nfunction removeLastIssueItem(\n    issues: Issue[],\n    terminalItems?: WeakSet<IssueItem>,\n) : boolean {\n    for (let index = issues.length - 1; index >= 0; index--) {\n        const issue = issues[index]!;\n        if (!isIssueGroup(issue)) {\n            if (terminalItems?.has(issue)) {\n                continue;\n            }\n\n            issues.splice(index, 1);\n\n            return true;\n        }\n\n        if (removeLastIssueItem(issue.issues, terminalItems)) {\n            if (issue.issues.length === 0) {\n                issues.splice(index, 1);\n            }\n\n            return true;\n        }\n    }\n\n    return false;\n}\n\n/**\n * The trace of one parse call: every issue its sites recorded, and which of\n * them the parse failed on.\n *\n * A collector inverts the failure policy. Instead of throwing where a\n * violation is found, a site records it and takes the drop path, so a request\n * with several bad keys reports all of them. What to do about that is not its\n * decision: it collects and serves, and the call that owns the parse raises\n * the failure (`BaseParser.finishIssues`).\n *\n * Every issue is a failure. Under a dropping policy nothing is recorded at\n * all: the key is dropped, nothing will be raised, and a trace nobody can read\n * is a trace nobody should pay for.\n *\n * The trace is not observable anywhere else: a parse that raises nothing\n * discards it. `error.issues` is the single channel.\n *\n * A site without a collector keeps throwing immediately: `ResolutionScope` is\n * public API and usable outside a parse, where nobody would ever raise the\n * trace.\n */\nexport class IssueCollector implements IIssueCollector {\n    protected items : Issue[] = [];\n\n    private terminalItems = new WeakSet<IssueItem>();\n\n    private get leafCount() : number {\n        return flattenIssueItems(this.items).length;\n    }\n\n    // -----------------------------------------------------\n\n    /**\n     * Add a rejection.\n     *\n     * Whether one is added at all is the caller's decision, made where the\n     * failure policy is known: a dropping policy adds nothing, because there\n     * is no failure to raise and so nobody to read it. The trace does not\n     * second-guess that: it would mean building an issue in order to bin it,\n     * and a collector that filters is a collector with an opinion.\n     */\n    add(input: IssueInput) : void {\n        this.record(buildIssue(input));\n    }\n\n    /**\n     * Record a thrown parse error as the issue it never got to be: the\n     * structural failures (a malformed expression, an input of the wrong\n     * shape) abort their parameter instead of dropping one key, so the\n     * caller catches them here. The error OBJECT is not kept: only branded\n     * parse errors are ever recorded (a server bug propagates untouched), and\n     * everything a client-input failure knows is in the issue it becomes.\n     *\n     * A throw that already carries a trace hands over that trace rather than\n     * a summary of it: the positions its sites recorded are the ones no\n     * enclosing site could reconstruct.\n     */\n    addError(input: IParseError, parameter?: `${Parameter}`, path: string[] = []) : void {\n        const issues = input.issues ?? [];\n        if (issues.length > 0) {\n            const before = this.leafCount;\n            for (const issue of issues) {\n                this.record(prefixIssuePath(issue, path), { terminal: true });\n            }\n            if (this.leafCount > before) {\n                return;\n            }\n\n            const first = flattenIssueItems([...issues])[0];\n            if (first && this.record(prefixIssuePath(first, path), {\n                ensure: true,\n                terminal: true,\n            })) {\n                return;\n            }\n        }\n\n        this.record(buildIssue({\n            code: input.code,\n            parameter,\n            path,\n            message: input.message,\n        }), { ensure: true, terminal: true });\n    }\n\n    /**\n     * Take over the issues of a nested trace, rebased onto the position it\n     * was merged at.\n     */\n    merge(issues: readonly Issue[], path: string[] = []) : void {\n        for (const issue of issues) {\n            this.record(prefixIssuePath(issue, path));\n        }\n    }\n\n    protected record(\n        input: Issue,\n        options: { ensure?: boolean, terminal?: boolean } = {},\n    ) : boolean {\n        // The tail of a hostile request changes nothing about the outcome: the\n        // trace is a diagnostic, and what the parse raises does not depend on\n        // which issue came first.\n        if (options.ensure && this.leafCount >= MAX_ISSUES) {\n            if (!removeLastIssueItem(this.items, this.terminalItems)) {\n                // When only structural aborts remain, retain the first issue\n                // and replace the newest abort to make room deterministically.\n                removeLastIssueItem(this.items);\n            }\n        }\n\n        const budget = { remaining: MAX_ISSUES - this.leafCount };\n        const retained = trimIssueToLeafBudget(input, budget);\n        if (!retained) {\n            return false;\n        }\n\n        this.items.push(retained);\n\n        if (options.terminal) {\n            const items = flattenIssueItems([retained]);\n            for (const item of items) {\n                this.terminalItems.add(item);\n            }\n        }\n\n        return true;\n    }\n\n    // -----------------------------------------------------\n\n    get issues() : Issue[] {\n        return this.items;\n    }\n\n    get failed() : boolean {\n        return this.items.length > 0;\n    }\n}\n","/*\n * Copyright (c) 2025.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { setPathValue } from 'pathtrace';\nimport { DEFAULT_ID, MAX_TRAVERSAL_DEPTH } from '../constants';\nimport type { Parameter } from '../constants';\nimport { ParseError, isParseError } from '../errors';\nimport type { Schema } from '../schema';\nimport { SchemaRegistry, defineSchema } from '../schema';\nimport type { ObjectLiteral } from '../types';\nimport {\n    isObject, \n    isUnsafeKey, \n    parseKey, \n    stringifyKey,\n} from '../utils';\nimport { IssueCollector } from './issue';\nimport { PARAMETER_ERROR_CLASSES } from './issue/constants';\nimport type { IIssueCollector } from './issue';\nimport type { IParser, ParseTrace, ParseTraceContext } from './types';\n\nexport type TempType = {\n    attributes: Record<string, any>,\n    relations: Record<string, TempType>\n};\n\nexport abstract class BaseParser<\n    OPTIONS extends ObjectLiteral = ObjectLiteral,\n    OUTPUT = any,\n> implements IParser<unknown, OUTPUT, OPTIONS> {\n    protected registry: SchemaRegistry;\n\n    // -----------------------------------------------------\n\n    constructor(input?: SchemaRegistry) {\n        let registry: SchemaRegistry;\n        if (input instanceof SchemaRegistry) {\n            registry = input;\n        } else {\n            registry = new SchemaRegistry();\n        }\n\n        this.registry = registry;\n    }\n\n    // --------------------------------------------------\n\n    abstract parse(input: unknown, options?: OPTIONS): OUTPUT;\n\n    async parseAsync(input: unknown, options?: OPTIONS) : Promise<OUTPUT> {\n        return this.parse(input, options);\n    }\n\n    // --------------------------------------------------\n\n    /**\n     * Open the trace this parse call records into: the enclosing call's when a\n     * driver handed one down (a query parse driving its five parameters), a\n     * fresh one otherwise.\n     *\n     * The handle carries whether this call OWNS the trace, because that is the\n     * one thing every later step needs and the one thing a collector cannot\n     * answer about itself. It used to be re-derived by comparing a driver\n     * against the collector at each step, which meant passing both everywhere\n     * and made an inverted comparison (a rejection silently degrading into a\n     * drop) a plain argument-order mistake.\n     *\n     * It also carries the parameter the call parses, which decides what a\n     * failure is raised AS: see {@link raise}. A query parse opens its trace\n     * without one, because it speaks for all five.\n     */\n    protected beginIssues(\n        driver?: IIssueCollector,\n        parameter?: `${Parameter}`,\n    ) : ParseTrace {\n        if (driver) {\n            return {\n                collector: driver, \n                owned: false, \n                parameter, \n            };\n        }\n\n        return {\n            collector: new IssueCollector(),\n            owned: true,\n            parameter,\n        };\n    }\n\n    /**\n     * The failure a trace stands for, raised as the parse that owns it.\n     *\n     * A single-parameter parse names its parameter (`parseFields` fails with\n     * `FieldsParseError`): the caller asked about one parameter, so saying\n     * which one is the whole truth, and it is the class that parameter has\n     * always thrown. A query parse names none, because a request can violate\n     * policies in four parameters at once and an error advertising one of them\n     * describes a SUBSET: a consumer branching on the class would act on the\n     * part it happened to be handed. Either way the code is `INPUT_REJECTED`\n     * and `error.issues` is what actually went wrong; the sub-parser failures\n     * a query parse catches are merged into its trace rather than raised.\n     */\n    protected raise(trace: ParseTrace) : ParseError {\n        const ErrorClass = trace.parameter ?\n            PARAMETER_ERROR_CLASSES[trace.parameter] :\n            ParseError;\n\n        return ErrorClass.inputRejected(trace.collector.issues);\n    }\n\n    /**\n     * Raise what the trace collected, but only in the call that started it: a\n     * sub-parser driven by a query parse records across all five parameters and\n     * lets the orchestrator decide, so a single bad key no longer hides what the\n     * other four would have reported. Every other call raises its own, so a\n     * rejection can never end up recorded into a trace nobody reads.\n     *\n     * A trace nothing raises is discarded: the error a parse throws is the only\n     * way it is ever read.\n     */\n    protected finishIssues(trace: ParseTrace) : void {\n        if (!trace.owned || !trace.collector.failed) {\n            return;\n        }\n\n        throw this.raise(trace);\n    }\n\n    /**\n     * Run one parse call end to end: open a trace, record what the body\n     * rejects into it, and raise it on the way out.\n     *\n     * Every entry point has this shape, so it is one call rather than three:\n     * a body that forgets to finish turns every rejection it recorded into a\n     * silent drop, which is the failure this whole mechanism exists to prevent.\n     */\n    protected withTrace<T>(\n        context: ParseTraceContext,\n        fn: (collector: IIssueCollector) => T,\n    ) : T {\n        const trace = this.beginIssues(context.driver, context.parameter);\n\n        const output = this.recordFailure(trace, () => fn(trace.collector));\n        this.finishIssues(trace);\n\n        return output;\n    }\n\n    protected async withTraceAsync<T>(\n        context: ParseTraceContext,\n        fn: (collector: IIssueCollector) => Promise<T>,\n    ) : Promise<T> {\n        const trace = this.beginIssues(context.driver, context.parameter);\n\n        const output = await this.recordFailureAsync(trace, () => fn(trace.collector));\n        this.finishIssues(trace);\n\n        return output;\n    }\n\n    /**\n     * Run a parse body whose failures belong in `trace`.\n     *\n     * A structural failure (a malformed expression, an input of the wrong\n     * shape, a hostile key) aborts by throwing rather than by dropping one\n     * key, so without this it would escape the call before anything recorded\n     * it: the caller would catch an error with an empty trace, and\n     * `formatErrors(error.issues)`, the documented way to render a\n     * failure, would answer with nothing at all.\n     *\n     * Recorded, the throw is re-raised through the trace, so the error that\n     * leaves is the FIRST violation with the whole trace attached (an earlier\n     * recorded rejection still wins over a structural abort that follows it).\n     * A call driven by an enclosing parse records nothing here and simply\n     * propagates: that parse catches the abort per parameter, keeps the other\n     * four parsing, and decides.\n     */\n    protected recordFailure<T>(trace: ParseTrace, fn: () => T) : T {\n        try {\n            return fn();\n        } catch (e) {\n            throw this.failure(e, trace);\n        }\n    }\n\n    protected async recordFailureAsync<T>(trace: ParseTrace, fn: () => Promise<T>) : Promise<T> {\n        try {\n            return await fn();\n        } catch (e) {\n            throw this.failure(e, trace);\n        }\n    }\n\n    /**\n     * The error a caught throw should leave the call as.\n     */\n    protected failure(input: unknown, trace: ParseTrace) : unknown {\n        if (!isParseError(input) || !trace.owned) {\n            return input;\n        }\n\n        trace.collector.addError(input, trace.parameter);\n        return this.raise(trace);\n    }\n\n    protected getBaseSchema<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input?: string | Schema<RECORD>,\n    ) : Schema<RECORD> {\n        let schema : Schema<RECORD> | undefined;\n        if (input) {\n            schema = this.registry.getOrFail(input);\n        } else {\n            schema = defineSchema();\n        }\n\n        return schema;\n    }\n\n    /**\n     * Expand dotted keys and nested objects into one canonical tree.\n     * Every leaf is written via its full dotted path, so a dotted key\n     * and a nested object sharing a prefix (`{'realm.id': 1, realm:\n     * {name: 'x'}}`) merge instead of the later key replacing the\n     * earlier subtree. Paths are capped at the shared traversal depth:\n     * a crafted deeply nested (or cyclic) input must fail typed instead\n     * of overflowing the call stack — no valid path exceeds the cap,\n     * since relation traversal is bounded by the same constant.\n     */\n    protected expandObject(\n        input: Record<string, any>,\n        output: Record<string, any> = {},\n        prefix?: string,\n    ) {\n        const depth = prefix ? prefix.split('.').length : 0;\n\n        const keys = Object.keys(input);\n        for (const key of keys) {\n            if (depth + key.split('.').length > MAX_TRAVERSAL_DEPTH) {\n                throw ParseError.inputInvalid();\n            }\n\n            if (isUnsafeKey(key)) {\n                throw ParseError.inputInvalid();\n            }\n\n            const path = prefix ? `${prefix}.${key}` : key;\n            if (isObject(input[key])) {\n                this.expandObject(input[key], output, path);\n            } else {\n                setPathValue(output, path, input[key]);\n            }\n        }\n\n        return output;\n    }\n\n    /**\n     * Reject an input object carrying a key whose path addresses an\n     * inherited prototype member. A parameter parser that never expands\n     * or groups its keys (pagination) does not run the hardened helpers\n     * above, but must not accept such keys silently either — the guard\n     * contract is uniform across every parameter. Nesting is bounded by\n     * the shared traversal depth for the same reason as `expandObject`.\n     */\n    protected assertSafeObjectKeys(\n        input: Record<string, any>,\n        depth = 0,\n    ) {\n        const keys = Object.keys(input);\n        for (const key of keys) {\n            if (depth + key.split('.').length > MAX_TRAVERSAL_DEPTH) {\n                throw ParseError.inputInvalid();\n            }\n\n            if (isUnsafeKey(key)) {\n                throw ParseError.inputInvalid();\n            }\n\n            if (isObject(input[key])) {\n                this.assertSafeObjectKeys(input[key], depth + key.split('.').length);\n            }\n        }\n    }\n\n    protected groupObject(input: Record<string, any>) {\n        const output : TempType = {\n            attributes: Object.create(null),\n            relations: Object.create(null),\n        };\n\n        const keys = Object.keys(input);\n        for (const key of keys) {\n            if (isUnsafeKey(key)) {\n                throw ParseError.inputInvalid();\n            }\n\n            if (isObject(input[key])) {\n                output.relations[key] = this.groupObject(input[key]);\n            } else {\n                output.attributes[key] = input[key];\n            }\n        }\n\n        return output;\n    }\n\n    protected groupObjectByBasePath<T extends Record<string, any>>(\n        input: T,\n    ) : Record<string, T> {\n        const output : Record<string, T> = Object.create(null);\n\n        const keys = Object.keys(input);\n\n        this.groupByFieldPathWithFn(\n            keys,\n            (prefix, key, index) => {\n                if (!output[prefix]) {\n                    output[prefix] = Object.create(null) as T;\n                }\n\n                const sourceKey = keys[index];\n                if (sourceKey !== undefined) {\n                    output[prefix][key as keyof T] = input[sourceKey] as T[keyof T];\n                }\n            },\n        );\n\n        return output;\n    }\n\n    protected groupArrayByBasePath(\n        input: string[],\n    ) : Record<string, string[]> {\n        const output : Record<string, string[]> = Object.create(null);\n\n        this.groupByFieldPathWithFn(\n            input,\n            (prefix, key) => {\n                if (!output[prefix]) {\n                    output[prefix] = [];\n                }\n\n                output[prefix].push(key);\n            },\n        );\n\n        return output;\n    }\n\n    /**\n     * Group keys by everything before their last path segment\n     * (e.g. \"items.realm.id\" -> { 'items.realm': ['id'] }).\n     */\n    protected groupArrayByKeyPath(\n        input: string[],\n    ) : Record<string, string[]> {\n        const output : Record<string, string[]> = Object.create(null);\n\n        for (const element of input) {\n            let key : string;\n            let name : string;\n\n            if (isUnsafeKey(element)) {\n                throw ParseError.inputInvalid();\n            }\n\n            const lastIndex = element.lastIndexOf('.');\n            if (lastIndex === -1) {\n                key = DEFAULT_ID;\n                name = element;\n            } else {\n                key = element.substring(0, lastIndex);\n                name = element.substring(lastIndex + 1);\n            }\n\n            const list = output[key] ?? [];\n            output[key] = list;\n            list.push(name);\n        }\n\n        return output;\n    }\n\n    protected groupByFieldPathWithFn(\n        items: string[],\n        cb: (\n            prefix: string,\n            key: string,\n            index: number,\n        ) => void,\n    ) : void {\n        for (const [i, item] of items.entries()) {\n            if (isUnsafeKey(item)) {\n                throw ParseError.inputInvalid();\n            }\n\n            const key = parseKey(item);\n\n            let prefix : string;\n            if (key.path) {\n                const dotIndex = key.path.indexOf('.');\n                if (dotIndex === -1) {\n                    prefix = key.path;\n                    key.path = undefined;\n                } else {\n                    prefix = key.path.substring(0, dotIndex);\n                    key.path = key.path.substring(dotIndex + 1);\n                }\n            } else {\n                prefix = DEFAULT_ID;\n            }\n\n            cb(prefix, stringifyKey(key), i);\n        }\n    }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SchemaError } from '../errors';\nimport {\n    Field,\n    Fields,\n    Filter,\n    Filters,\n    Relation,\n    Relations,\n    Sort,\n    Sorts,\n    isCondition,\n    isFilter,\n    isFilters,\n} from '../parameter';\nimport type {\n    ICondition,\n    IFields,\n    IFilters,\n    IRelations,\n    ISorts,\n} from '../parameter';\nimport { FilterCompoundOperator, FilterFieldOperator } from '../schema';\nimport type { FiltersSchema, SortsSchema } from '../schema';\nimport { parseKey } from '../utils';\nimport type { IIssueCollector } from './issue';\nimport { buildFiltersDefaults } from './parameter/filters/validate';\n\n/**\n * Every pass below always yields the tree that would execute, whether or not\n * the trace has already failed (`issueCollector.failed`): the index policies\n * judge that tree afterwards, and judging an unpruned one would report the\n * keys a rejected relation dragged along as violations of their own.\n *\n * What a failed trace does switch off is the one refusal pruning can raise. A\n * preserved condition over a rejected relation is a contradiction between two\n * validators and throws `SCHEMA_PRESERVED_CONDITION_PRUNED`; but a parse that\n * recorded a rejection is over and raises that rejection, so the tree it ends\n * with is never observed, and a structural conflict found while cleaning up\n * after a rejection must not displace the rejection itself. The contradiction\n * surfaces unchanged on the next request that violates nothing else.\n */\n\n/**\n * The rejected relation governing a canonical relation/field path: the path\n * is the relation itself or lives underneath it.\n */\nfunction matchRelationRejected(path: string, rejected: string[]) : string | undefined {\n    return rejected.find(\n        (name) => path === name || path.startsWith(`${name}.`),\n    );\n}\n\n/**\n * Whether a canonical relation/field path is governed by a rejected relation —\n * the path is the relation itself or lives underneath it.\n */\nexport function isRelationRejected(path: string, rejected: string[]) : boolean {\n    return typeof matchRelationRejected(path, rejected) !== 'undefined';\n}\n\nfunction joinPath(prefix: string, segment: string) : string {\n    return prefix ? `${prefix}.${segment}` : segment;\n}\n\n/**\n * Drop every field whose canonical name traverses a rejected relation.\n */\nexport function pruneFieldsByRelations(\n    fields: IFields,\n    rejected: string[],\n) : IFields {\n    if (rejected.length === 0) {\n        return fields;\n    }\n\n    return new Fields(\n        fields.value\n            .filter((field) => !isRelationRejected(field.name, rejected))\n            // the visibility condition must survive the rebuild: dropping it\n            // would turn a gated field into an ungated one.\n            .map((field) => new Field(field.name, field.operator, field.condition)),\n    );\n}\n\n/**\n * Drop every sort whose canonical name traverses a rejected relation. Falls back\n * to the schema `default` when pruning empties the parameter — mirroring the\n * parser, which re-applies defaults once relation gating removes every key.\n */\nexport function pruneSortsByRelations(\n    sorts: ISorts,\n    rejected: string[],\n    schema?: SortsSchema,\n) : ISorts {\n    if (rejected.length === 0) {\n        return sorts;\n    }\n\n    const value = sorts.value\n        .filter((sort) => !isRelationRejected(sort.name, rejected))\n        .map((sort) => new Sort(sort.name, sort.operator));\n\n    if (value.length === 0 && schema) {\n        return buildSortsDefaults(schema);\n    }\n\n    return new Sorts(value);\n}\n\n/**\n * Drop every relation at or below a rejected relation.\n */\nexport function pruneRelationsByRelations(\n    relations: IRelations,\n    rejected: string[],\n) : IRelations {\n    if (rejected.length === 0) {\n        return relations;\n    }\n\n    return new Relations(\n        relations.value\n            .filter((relation) => !isRelationRejected(relation.name, rejected))\n            .map((relation) => new Relation(relation.name)),\n    );\n}\n\n/**\n * Prune a filter tree of every leaf traversing a rejected relation, collapsing\n * empty compounds (mirrors {@link applyFiltersSchemaValidation}). Interior\n * `elemMatch` conditions are addressed relative to the array element, so a\n * running `prefix` reconstructs their absolute path before matching. Falls back\n * to the schema `default` when pruning empties the parameter.\n *\n * A preserved condition is exempt from the drop, not from the gate: pruning\n * anything out of a preserved subtree returns a query the preserved condition\n * does not describe (wider under the `and(<leaf>, <scope>)` shape a filters\n * validator produces, narrower under an `or`), while keeping it would join a\n * relation the relations validator rejected. Neither outcome is correct, so the\n * contradiction between the two validators throws {@link SchemaError}\n * (`SCHEMA_PRESERVED_CONDITION_PRUNED`) instead of resolving it silently. The\n * decision is per node, not per operator: preservation says the condition\n * survives composition intact, and pruning is not asked to reason about which shapes\n * happen to fail open.\n */\nexport function pruneFiltersByRelations(\n    filters: IFilters,\n    rejected: string[],\n    schema?: FiltersSchema,\n    issueCollector?: IIssueCollector,\n) : IFilters {\n    if (rejected.length === 0) {\n        return filters;\n    }\n\n    // the refusal is suppressed once the trace has failed: see the note at\n    // the top of this module.\n    const refuse = !issueCollector?.failed;\n\n    const pruned = pruneCondition(filters, rejected, '', false, refuse);\n    if (pruned && isFilters(pruned)) {\n        return pruned;\n    }\n\n    let conditions : ICondition[];\n    if (pruned) {\n        conditions = [pruned];\n    } else {\n        conditions = schema ? buildFiltersDefaults(schema) : [];\n\n        // The default is the server's own baseline and is exempt from the gate:\n        // it is re-applied here un-pruned, even when it names a rejected\n        // relation. A preserved default asserts the same must-survive contract as\n        // a validator residual though, so it is checked: without this, the very\n        // same default would throw or survive depending on whether the client\n        // sent a filter of its own, which is what decides whether it was\n        // materialized before this pass or after it.\n        if (refuse) {\n            for (const condition of conditions) {\n                assertPreservedSurvivesPruning(condition, rejected);\n            }\n        }\n    }\n\n    return new Filters(FilterCompoundOperator.AND, conditions);\n}\n\n/**\n * Raise the preserved-condition contradiction for a condition that is kept rather\n * than pruned. The pruned copy is discarded: only the throw matters here.\n */\nfunction assertPreservedSurvivesPruning(condition: ICondition, rejected: string[]) : void {\n    pruneCondition(condition, rejected, '', false, true);\n}\n\n/**\n * Drop the condition at `field`, unless it is protected: a drop inside a preserved\n * subtree is the one case pruning must refuse rather than resolve. `refuse`\n * false drops it anyway, for a parse that is going to raise regardless.\n */\nfunction dropUnlessPreserved(\n    relation: string,\n    field: string,\n    preserved: boolean,\n    refuse: boolean,\n) : undefined {\n    if (preserved && refuse) {\n        throw SchemaError.preservedConditionPruned(relation, field);\n    }\n\n    return undefined;\n}\n\nfunction pruneCondition(\n    node: ICondition,\n    rejected: string[],\n    prefix: string,\n    preserved: boolean,\n    refuse: boolean,\n) : ICondition | undefined {\n    // The marker protects the whole subtree it heads. `preserve()` sets it on\n    // the built-in nodes and wraps anything else, but the marker itself is\n    // part of ICondition, so a custom condition setting it is honoured too.\n    const preserved2 = preserved || isConditionPreservedAtRoot(node);\n\n    if (isFilter(node)) {\n        const field = joinPath(prefix, node.field);\n        const rejectedBy = matchRelationRejected(field, rejected);\n\n        // Dropping a leaf drops everything addressed below it, so the refusal\n        // is decided over the whole subtree rather than this node alone: an\n        // interior condition (`elemMatch`, or any operator built the same way)\n        // can carry the marker its parent does not.\n        if (typeof rejectedBy === 'string') {\n            return dropUnlessPreserved(\n                rejectedBy,\n                field,\n                preserved2 || isConditionPreserved(node),\n                refuse,\n            );\n        }\n\n        // Descending is gated on the operator, not on the value shape: only\n        // `elemMatch` is known to address its interior relative to the element,\n        // which is what `field` becomes the prefix for.\n        if (\n            node.operator === FilterFieldOperator.ELEM_MATCH &&\n            isCondition(node.value)\n        ) {\n            const interior = pruneCondition(node.value, rejected, field, preserved2, refuse);\n            if (!interior) {\n                return undefined;\n            }\n\n            if (interior !== node.value) {\n                return new Filter(node.operator, node.field, interior, { preserved: node.preserved });\n            }\n        }\n\n        return node;\n    }\n\n    if (!isFilters(node)) {\n        return node;\n    }\n\n    const conditions : ICondition[] = [];\n    for (const child of node.value) {\n        const child2 = pruneCondition(child, rejected, prefix, preserved2, refuse);\n        if (child2) {\n            conditions.push(child2);\n        }\n    }\n\n    if (conditions.length === 0) {\n        return undefined;\n    }\n\n    return new Filters(node.operator, conditions, { preserved: node.preserved });\n}\n\nfunction isConditionPreservedAtRoot(node: ICondition) : boolean {\n    return node.preserved === true;\n}\n\nfunction isConditionPreserved(node: ICondition) : boolean {\n    if (isConditionPreservedAtRoot(node)) {\n        return true;\n    }\n\n    if (isFilters(node)) {\n        return node.value.some((child) => isConditionPreserved(child));\n    }\n\n    // A leaf value can be a condition in its own right, and it goes away with\n    // the leaf. The addressing convention does not matter here: the question\n    // is only whether anything below is marked.\n    if (isFilter(node) && isCondition(node.value)) {\n        return isConditionPreserved(node.value);\n    }\n\n    return false;\n}\n\nexport function buildSortsDefaults(schema: SortsSchema) : Sorts {\n    const output = new Sorts();\n    if (!schema.default) {\n        return output;\n    }\n\n    for (const key of Object.keys(schema.default)) {\n        const details = parseKey(key);\n        const name = details.path ? `${details.path}.${details.name}` : details.name;\n        output.value.push(new Sort(name, schema.default[key]));\n    }\n\n    return output;\n}\n\n/**\n * @deprecated use {@link buildSortsDefaults}. Removed in 3.0.\n */\nexport const buildSortDefaults = buildSortsDefaults;\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { flattenIssueItems } from 'blemish';\nimport { Parameter } from '../constants';\nimport {\n    Filters,\n    isCondition,\n    isFilter,\n    isFilters,\n} from '../parameter';\nimport type { ICondition, IFilters, ISorts } from '../parameter';\nimport {\n    ErrorCode,\n    ErrorMessage,\n    SchemaError,\n    extractIssueParameter,\n} from '../errors';\nimport {\n    FilterCompoundOperator,\n    ResolutionScope,\n    checkConditionIndexed,\n    checkSortKeysIndexed,\n} from '../schema';\nimport type {\n    FiltersSchema,\n    IndexesResolver,\n    Schema,\n    SchemaRegistry,\n    SortsSchema,\n} from '../schema';\nimport type { ObjectLiteral } from '../types';\nimport { parseKey } from '../utils';\nimport type { IIssueCollector } from './issue';\nimport { FiltersParseError } from './parameter/filters/error';\nimport { SortsParseError } from './parameter/sort/error';\nimport { buildFiltersDefaults } from './parameter/filters/validate';\nimport { buildSortsDefaults } from './relation-prune';\n\ntype IndexPolicyContext = {\n    throwOnFailure?: boolean,\n    /**\n     * Trace of the enclosing parse. Present: the violation is recorded and\n     * the parse continues to its own end. Absent: it throws here.\n     */\n    issueCollector?: IIssueCollector,\n};\n\nfunction hasIssueForParameter(\n    collector: IIssueCollector | undefined,\n    parameter: `${Parameter}`,\n) : boolean {\n    return collector ? flattenIssueItems(collector.issues)\n        .some((issue) => extractIssueParameter(issue) === parameter) : false;\n}\n\n/**\n * Indexes are read from the schema governing each relation path, so a\n * dotted leaf checks the target schema's declaration. The scope walk\n * mirrors allow-list resolution (registry + schemaMapping), without\n * relation gating: the tree only carries already-resolved paths.\n */\nfunction indexesResolverFor(scope: ResolutionScope<any, any>) : IndexesResolver {\n    const cache = new Map<string, string[][] | null>();\n\n    return (path) => {\n        const cached = cache.get(path);\n        if (typeof cached !== 'undefined') {\n            return cached;\n        }\n\n        let target = scope;\n        if (path !== '') {\n            const child = scope.descend(path);\n            if (!(child instanceof ResolutionScope)) {\n                cache.set(path, null);\n                return null;\n            }\n\n            target = child;\n        }\n\n        const schema = target.schema as { indexes: string[][], indexesIsUndefined: boolean };\n        const value = schema.indexesIsUndefined ? null : schema.indexes;\n        cache.set(path, value);\n\n        return value;\n    };\n}\n\n/**\n * Semantic equality of two condition trees: field, operator and value,\n * flags excluded (a codec round trip rebuilds fresh instances and never\n * carries preservation). Unknown condition kinds compare by identity.\n */\nfunction conditionEquals(a: ICondition, b: ICondition) : boolean {\n    if (a === b) {\n        return true;\n    }\n\n    if (isFilter(a) && isFilter(b)) {\n        return a.operator === b.operator &&\n            a.field === b.field &&\n            filterValueEquals(a.value, b.value);\n    }\n\n    if (isFilters(a) && isFilters(b)) {\n        return a.operator === b.operator &&\n            a.value.length === b.value.length &&\n            a.value.every(\n                (child, index) => conditionEquals(child, b.value[index] as ICondition),\n            );\n    }\n\n    return false;\n}\n\nfunction filterValueEquals(a: unknown, b: unknown) : boolean {\n    if (isCondition(a) && isCondition(b)) {\n        return conditionEquals(a, b);\n    }\n\n    if (Array.isArray(a) && Array.isArray(b)) {\n        return a.length === b.length &&\n            a.every((element, index) => element === b[index]);\n    }\n\n    return a === b;\n}\n\n/**\n * A preserved condition anywhere in the tree, including elemMatch\n * interiors. Custom kinds enter preservation through the preserve()\n * wrapper, a flagged Filters node, so flag checks on the built-in\n * nodes cover them.\n */\nfunction hasPreservedCondition(node: ICondition) : boolean {\n    if (isFilter(node)) {\n        if (node.preserved) {\n            return true;\n        }\n\n        return isCondition(node.value) ? hasPreservedCondition(node.value) : false;\n    }\n\n    if (isFilters(node)) {\n        if (node.preserved) {\n            return true;\n        }\n\n        return node.value.some(hasPreservedCondition);\n    }\n\n    return false;\n}\n\nfunction isFiltersDefaults(output: IFilters, schema: FiltersSchema) : boolean {\n    const defaults = buildFiltersDefaults(schema);\n    if (defaults.length === 0 || output.value.length !== defaults.length) {\n        return false;\n    }\n\n    return output.value.every((item, index) => {\n        const other = defaults[index];\n\n        return typeof other !== 'undefined' && conditionEquals(item, other);\n    });\n}\n\n/**\n * The client-authored subset of a sort list. Server-authored default\n * entries are exempt from the index check: the root schema's defaults\n * (declared under their full, possibly dotted name), and the\n * per-relation defaults a child schema contributes when a client's\n * relation sort keys all drop. An entry counts as a default when the\n * schema governing its path declares exactly that name and direction.\n */\nfunction collectClientSortKeys(\n    output: ISorts,\n    scope: ResolutionScope<any, any>,\n) : string[] {\n    const rootSchema = scope.schema as SortsSchema;\n    const rootDefaults = rootSchema.defaultIsUndefined ? null : rootSchema.default;\n\n    const cache = new Map<string, Record<string, string> | null>();\n    const names : string[] = [];\n\n    for (const sort of output.value) {\n        if (rootDefaults && rootDefaults[sort.name] === sort.operator) {\n            continue;\n        }\n\n        const details = parseKey(sort.name);\n        const path = details.path ?? '';\n\n        let defaults = cache.get(path);\n        if (typeof defaults === 'undefined') {\n            defaults = null;\n\n            if (path !== '') {\n                const child = scope.descend(path);\n                if (child instanceof ResolutionScope) {\n                    const childSchema = child.schema as SortsSchema;\n                    if (!childSchema.defaultIsUndefined) {\n                        defaults = childSchema.default;\n                    }\n                }\n            }\n\n            cache.set(path, defaults);\n        }\n\n        if (defaults && defaults[details.name] === sort.operator) {\n            continue;\n        }\n\n        names.push(sort.name);\n    }\n\n    return names;\n}\n\n/**\n * Enforce the schema's `indexed` filters policy on a final parsed tree.\n * Runs after validate hooks and relation pruning, so server-authored\n * residuals legitimately anchor the executed query; the schema default\n * tree is server-authored and bypasses. Violations follow the standard\n * failure policy: drop the parameter whole (falling back to the\n * default), or throw typed under `throwOnFailure`.\n */\nexport function applyFiltersIndexPolicy<\n    RECORD extends ObjectLiteral = ObjectLiteral,\n>(\n    output: IFilters,\n    registry: SchemaRegistry,\n    schema?: string | Schema<RECORD> | FiltersSchema<RECORD>,\n    context: IndexPolicyContext = {},\n) : IFilters {\n    const scope = ResolutionScope.for(registry, Parameter.FILTERS, schema, { throwOnFailure: context.throwOnFailure });\n\n    const filtersSchema = scope.schema as FiltersSchema<RECORD>;\n    if (\n        !filtersSchema.indexed ||\n        isFiltersDefaults(output, filtersSchema) ||\n        // A filter failure already explains why this tree cannot execute.\n        // Its index violation is only a consequence (and its preserved-\n        // condition refusal would displace that original failure).\n        hasIssueForParameter(context.issueCollector, Parameter.FILTERS)\n    ) {\n        return output;\n    }\n\n    const result = checkConditionIndexed(\n        output,\n        indexesResolverFor(scope),\n        filtersSchema.indexed,\n    );\n    if (result.ok) {\n        return output;\n    }\n\n    // A preserved (must-survive) condition cannot be dropped with the\n    // tree: mirror relation pruning and refuse loudly.\n    if (!scope.throwOnFailure && hasPreservedCondition(output)) {\n        throw SchemaError.preservedConditionNotIndexed(result.keys);\n    }\n\n    const defaults = scope.throwOnFailure ? [] : buildFiltersDefaults(filtersSchema);\n\n    // Dropping to an empty filter set would execute an unfiltered scan, the\n    // exact outcome the policy exists to prevent: with no fallback to fall\n    // back to, the violation always fails the parse.\n    const fatal = scope.throwOnFailure || defaults.length === 0;\n\n    if (context.issueCollector) {\n        if (fatal) {\n            context.issueCollector.add({\n                code: ErrorCode.KEY_COMBINATION_NOT_INDEXED,\n                parameter: Parameter.FILTERS,\n                path: [],\n                received: result.keys,\n                message: ErrorMessage.keyCombinationNotIndexed(result.keys),\n            });\n\n            // the parse ends on the recorded issue; the tree it ends with is\n            // never observed.\n            return output;\n        }\n\n        return new Filters(FilterCompoundOperator.AND, defaults);\n    }\n\n    if (fatal) {\n        throw FiltersParseError.keyCombinationNotIndexed(result.keys);\n    }\n\n    return new Filters(FilterCompoundOperator.AND, defaults);\n}\n\n/**\n * Sorts counterpart of {@link applyFiltersIndexPolicy}: ordered\n * leftmost-prefix rule applied to the client-authored keys only\n * (server-authored default entries, root or relation-scoped, are\n * exempt), standard failure policy.\n */\nexport function applySortsIndexPolicy<\n    RECORD extends ObjectLiteral = ObjectLiteral,\n>(\n    output: ISorts,\n    registry: SchemaRegistry,\n    schema?: string | Schema<RECORD> | SortsSchema<RECORD>,\n    context: IndexPolicyContext = {},\n) : ISorts {\n    const scope = ResolutionScope.for(registry, Parameter.SORTS, schema, { throwOnFailure: context.throwOnFailure });\n\n    const sortSchema = scope.schema as SortsSchema<RECORD>;\n    if (\n        !sortSchema.indexed ||\n        output.value.length === 0 ||\n        // A sort failure already explains why this list cannot execute; its\n        // index violation is only a consequence of that original failure.\n        hasIssueForParameter(context.issueCollector, Parameter.SORTS)\n    ) {\n        return output;\n    }\n\n    const names = collectClientSortKeys(output, scope);\n    if (names.length === 0) {\n        return output;\n    }\n\n    const result = checkSortKeysIndexed(names, indexesResolverFor(scope));\n    if (result.ok) {\n        return output;\n    }\n\n    if (context.issueCollector) {\n        if (!scope.throwOnFailure) {\n            return buildSortsDefaults(sortSchema);\n        }\n\n        context.issueCollector.add({\n            code: ErrorCode.KEY_COMBINATION_NOT_INDEXED,\n            parameter: Parameter.SORTS,\n            path: [],\n            received: result.keys,\n            message: ErrorMessage.keyCombinationNotIndexed(result.keys),\n        });\n\n        return output;\n    }\n\n    if (scope.throwOnFailure) {\n        throw SortsParseError.keyCombinationNotIndexed(result.keys);\n    }\n\n    return buildSortsDefaults(sortSchema);\n}\n\n/**\n * @deprecated use {@link applySortsIndexPolicy}. Removed in 3.0.\n */\nexport const applySortIndexPolicy = applySortsIndexPolicy;\n","/*\n * Copyright (c) 2025.\n *  Author Peter Placzek (tada5hi)\n *  For the full copyright and license information,\n *  view the LICENSE file that was distributed with this source code.\n */\n\nimport { Parameter } from '../constants';\nimport { ParseError, isParseError } from '../errors';\nimport type {\n    IFields,\n    IFilters,\n    IPagination,\n    IRelations,\n    ISorts,\n    QueryContext,\n} from '../parameter';\nimport {\n    Fields,\n    Filters,\n    Pagination,\n    Query,\n    Relations,\n    Sorts,\n} from '../parameter';\nimport { FilterCompoundOperator } from '../schema';\nimport type { Schema } from '../schema';\nimport type { ObjectLiteral } from '../types';\nimport {\n    isObject,\n    isPropertySet,\n    normalizeParameter,\n    resolveAliasedKey,\n} from '../utils';\nimport { BaseParser } from './base';\nimport { applyFiltersIndexPolicy, applySortsIndexPolicy } from './index-policy';\nimport type { IIssueCollector } from './issue';\nimport { RelationsParseError } from './parameter/relations/error';\nimport {\n    applyKeySchemaValidation,\n    applyKeySchemaValidationAsync,\n} from './parameter/validate';\nimport {\n    pruneFieldsByRelations,\n    pruneFiltersByRelations,\n    pruneRelationsByRelations,\n    pruneSortsByRelations,\n} from './relation-prune';\nimport type {\n    IQueryParameterParser,\n    ParseParameterOptions,\n    ParseQueryOptions,\n    ParseTrace,\n    RelationLedger,\n} from './types';\n\n/**\n * Shared query parse orchestration. Dialect packages supply the\n * per-parameter sub-parsers; this base owns the composition:\n * parameter key lookup, relation gating and the delegation order\n * (relations first, since they gate the rest).\n */\nexport abstract class BaseQueryParser extends BaseParser<ParseQueryOptions, Query> {\n    protected abstract fieldsParser : IQueryParameterParser<IFields>;\n\n    protected abstract filtersParser : IQueryParameterParser<IFilters>;\n\n    protected abstract paginationParser : IQueryParameterParser<IPagination>;\n\n    protected abstract relationsParser : IQueryParameterParser<IRelations>;\n\n    protected abstract sortParser : IQueryParameterParser<ISorts>;\n\n    // -----------------------------------------------------\n\n    parse<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseQueryOptions<RECORD> = {},\n    ): Query {\n        const output : QueryContext = {};\n        const {\n            data, \n            parameterOptions, \n            trace, \n        } = this.prepareQueryContext(input, options);\n        const issueCollector = trace.collector;\n\n        // pooled relation-authorization obligations across every parameter, so\n        // the relations validate hook runs once per distinct relation and prunes\n        // the whole query (see plan 022 / #815). The ledger is an explicit driver\n        // argument, never part of the public parse options.\n        const ledger : RelationLedger = [];\n\n        if (!this.skipParameter(options, Parameter.RELATIONS)) {\n            const relationsInput = this.readParameter(data, Parameter.RELATIONS);\n\n            const relations = this.parseOne(issueCollector, Parameter.RELATIONS, new Relations(), () => this.relationsParser\n                .parseParameter(relationsInput, parameterOptions, ledger, issueCollector));\n            output.relations = relations;\n            this.gateRelations(parameterOptions, relationsInput, relations);\n        }\n\n        if (!this.skipParameter(options, Parameter.FIELDS)) {\n            output.fields = this.parseOne(issueCollector, Parameter.FIELDS, new Fields(), () => this.fieldsParser.parseParameter(\n                this.readParameter(data, Parameter.FIELDS),\n                parameterOptions,\n                ledger,\n                issueCollector,\n            ));\n        }\n\n        if (!this.skipParameter(options, Parameter.FILTERS)) {\n            const empty = new Filters(FilterCompoundOperator.AND, []);\n            output.filters = this.parseOne(issueCollector, Parameter.FILTERS, empty, () => this.filtersParser\n                .parseParameter(\n                    this.readParameter(data, Parameter.FILTERS),\n                    parameterOptions,\n                    ledger,\n                    issueCollector,\n                ));\n        }\n\n        if (!this.skipParameter(options, Parameter.PAGINATION)) {\n            output.pagination = this.parseOne(issueCollector, Parameter.PAGINATION, new Pagination(), () => this.paginationParser\n                .parseParameter(\n                    this.readParameter(data, Parameter.PAGINATION),\n                    parameterOptions,\n                    ledger,\n                    issueCollector,\n                ));\n        }\n\n        if (!this.skipParameter(options, Parameter.SORTS)) {\n            output.sorts = this.parseOne(issueCollector, Parameter.SORTS, new Sorts(), () => this.sortParser.parseParameter(\n                this.readParameter(data, Parameter.SORTS),\n                parameterOptions,\n                ledger,\n                issueCollector,\n            ));\n        }\n\n        // the cross-parameter passes belong to the trace like the parameters\n        // do: a rejection they throw (rather than record) must not leave with\n        // an empty trace.\n        this.recordFailure(trace, () => {\n            const rejected = this.applyRelationValidations(ledger, options, issueCollector);\n            this.pruneByRelations(output, rejected, options, issueCollector);\n            this.applyIndexPolicies(output, options, issueCollector);\n        });\n\n        this.finishIssues(trace);\n\n        return new Query(output);\n    }\n\n    override async parseAsync<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseQueryOptions<RECORD> = {},\n    ) : Promise<Query> {\n        const output : QueryContext = {};\n        const {\n            data, \n            parameterOptions, \n            trace, \n        } = this.prepareQueryContext(input, options);\n        const issueCollector = trace.collector;\n\n        const ledger : RelationLedger = [];\n\n        if (!this.skipParameter(options, Parameter.RELATIONS)) {\n            const relationsInput = this.readParameter(data, Parameter.RELATIONS);\n\n            const relations = await this.parseOneAsync(issueCollector, Parameter.RELATIONS, new Relations(), () => this\n                .relationsParser.parseParameterAsync(relationsInput, parameterOptions, ledger, issueCollector));\n            output.relations = relations;\n            this.gateRelations(parameterOptions, relationsInput, relations);\n        }\n\n        if (!this.skipParameter(options, Parameter.FIELDS)) {\n            output.fields = await this.parseOneAsync(issueCollector, Parameter.FIELDS, new Fields(), () => this.fieldsParser\n                .parseParameterAsync(\n                    this.readParameter(data, Parameter.FIELDS),\n                    parameterOptions,\n                    ledger,\n                    issueCollector,\n                ));\n        }\n\n        if (!this.skipParameter(options, Parameter.FILTERS)) {\n            const empty = new Filters(FilterCompoundOperator.AND, []);\n            output.filters = await this.parseOneAsync(issueCollector, Parameter.FILTERS, empty, () => this.filtersParser\n                .parseParameterAsync(\n                    this.readParameter(data, Parameter.FILTERS),\n                    parameterOptions,\n                    ledger,\n                    issueCollector,\n                ));\n        }\n\n        if (!this.skipParameter(options, Parameter.PAGINATION)) {\n            output.pagination = await this.parseOneAsync(\n                issueCollector,\n                Parameter.PAGINATION,\n                new Pagination(),\n                () => this.paginationParser.parseParameterAsync(\n                    this.readParameter(data, Parameter.PAGINATION),\n                    parameterOptions,\n                    ledger,\n                    issueCollector,\n                ),\n            );\n        }\n\n        if (!this.skipParameter(options, Parameter.SORTS)) {\n            output.sorts = await this.parseOneAsync(issueCollector, Parameter.SORTS, new Sorts(), () => this.sortParser\n                .parseParameterAsync(\n                    this.readParameter(data, Parameter.SORTS),\n                    parameterOptions,\n                    ledger,\n                    issueCollector,\n                ));\n        }\n\n        await this.recordFailureAsync(trace, async () => {\n            const rejected = await this.applyRelationValidationsAsync(ledger, options, issueCollector);\n            this.pruneByRelations(output, rejected, options, issueCollector);\n            this.applyIndexPolicies(output, options, issueCollector);\n        });\n\n        this.finishIssues(trace);\n\n        return new Query(output);\n    }\n\n    // -----------------------------------------------------\n\n    /**\n     * Run one parameter, keeping a structural failure inside it.\n     *\n     * A malformed expression or an input of the wrong shape aborts the\n     * parameter it was found in (there is no next key to move on to), but the\n     * other four parameters are independent and still parse. The failure is\n     * recorded as an error issue, so the query parse ends on it (or on an\n     * earlier one) exactly as it would have ended on the immediate throw.\n     */\n    protected parseOne<T>(\n        issueCollector: IIssueCollector,\n        parameter: `${Parameter}`,\n        fallback: T,\n        fn: () => T,\n    ) : T {\n        try {\n            return fn();\n        } catch (e) {\n            if (isParseError(e)) {\n                issueCollector.addError(e, parameter);\n\n                return fallback;\n            }\n\n            throw e;\n        }\n    }\n\n    protected async parseOneAsync<T>(\n        issueCollector: IIssueCollector,\n        parameter: `${Parameter}`,\n        fallback: T,\n        fn: () => Promise<T>,\n    ) : Promise<T> {\n        try {\n            return await fn();\n        } catch (e) {\n            if (isParseError(e)) {\n                issueCollector.addError(e, parameter);\n\n                return fallback;\n            }\n\n            throw e;\n        }\n    }\n\n    // -----------------------------------------------------\n\n    /**\n     * The option plumbing shared by {@link parse} and {@link parseAsync}.\n     * Forwards the ORIGINAL schema input — a manufactured empty schema\n     * would wrongly bind the parameter scopes.\n     */\n    protected prepareQueryContext<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseQueryOptions<RECORD>,\n    ) : {\n        data: ObjectLiteral,\n        parameterOptions: ParseParameterOptions<RECORD>,\n        trace: ParseTrace,\n    } {\n        const data : ObjectLiteral = isObject(input) ? input : {};\n\n        // one trace for the whole query: the sub-parsers record into it and\n        // defer throwing, so a violation in the first parameter no longer\n        // hides what the other four would have reported. This call owns it,\n        // and raises it once every parameter has been seen.\n        const trace = this.beginIssues();\n\n        // the trace reaches the sub-parsers as a driver argument, never as an\n        // option: a consumer able to supply one would take over the decision\n        // to raise, and a rejection nobody raises is a rejection that became\n        // a silent drop.\n        const parameterOptions : ParseParameterOptions<RECORD> = {};\n        if (options.schema) {\n            parameterOptions.schema = options.schema;\n        }\n\n        if (typeof options.strict !== 'undefined') {\n            parameterOptions.strict = options.strict;\n        }\n\n        if (typeof options.throwOnFailure !== 'undefined') {\n            parameterOptions.throwOnFailure = options.throwOnFailure;\n        }\n\n        if (typeof options.context !== 'undefined') {\n            parameterOptions.context = options.context;\n        }\n\n        return {\n            data, \n            parameterOptions, \n            trace, \n        };\n    }\n\n    /**\n     * Relation paths of the other parameters are only gated by the\n     * relations parameter when the client actually supplied one.\n     */\n    protected gateRelations<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        parameterOptions: ParseParameterOptions<RECORD>,\n        relationsInput: unknown,\n        relations: IRelations,\n    ) : void {\n        if (typeof relationsInput !== 'undefined') {\n            parameterOptions.relations = relations;\n        }\n    }\n\n    /**\n     * Evaluate the pooled relation-authorization obligations once — deduped\n     * across every parameter — under the relations schema's failure policy.\n     * Returns the canonical relation paths the hook rejected, for\n     * {@link pruneByRelations}. A rejection under `throwOnFailure` throws\n     * `RelationsParseError`, regardless of which parameter forced the join.\n     */\n    protected applyRelationValidations<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        ledger: RelationLedger,\n        options: ParseQueryOptions<RECORD>,\n        issueCollector?: IIssueCollector,\n    ) : string[] {\n        if (ledger.length === 0 || !options.schema) {\n            return [];\n        }\n\n        const schema = this.registry.getOrFail(options.schema);\n\n        return applyKeySchemaValidation(ledger, options.context, {\n            throwOnFailure: options.throwOnFailure ?? schema.relations.throwOnFailure ?? false,\n            errors: RelationsParseError,\n            issueCollector,\n        });\n    }\n\n    protected async applyRelationValidationsAsync<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        ledger: RelationLedger,\n        options: ParseQueryOptions<RECORD>,\n        issueCollector?: IIssueCollector,\n    ) : Promise<string[]> {\n        if (ledger.length === 0 || !options.schema) {\n            return [];\n        }\n\n        const schema = this.registry.getOrFail(options.schema);\n\n        return applyKeySchemaValidationAsync(ledger, options.context, {\n            throwOnFailure: options.throwOnFailure ?? schema.relations.throwOnFailure ?? false,\n            errors: RelationsParseError,\n            issueCollector,\n        });\n    }\n\n    /**\n     * Drop every field/filter/sort/relation traversing a rejected relation from\n     * the assembled query. Filters and sorts fall back to their schema defaults\n     * when pruning empties them, matching the parser's own default fallback.\n     */\n    protected pruneByRelations<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        output: QueryContext,\n        rejected: string[],\n        options: ParseQueryOptions<RECORD>,\n        issueCollector?: IIssueCollector,\n    ) : void {\n        if (rejected.length === 0) {\n            return;\n        }\n\n        const schema : Schema<RECORD> | undefined = options.schema ?\n            this.registry.getOrFail(options.schema) :\n            undefined;\n\n        if (output.relations) {\n            output.relations = pruneRelationsByRelations(output.relations, rejected);\n        }\n\n        if (output.fields) {\n            output.fields = pruneFieldsByRelations(output.fields, rejected);\n        }\n\n        if (output.sorts) {\n            output.sorts = pruneSortsByRelations(output.sorts, rejected, schema?.sort);\n        }\n\n        if (output.filters) {\n            output.filters = pruneFiltersByRelations(output.filters, rejected, schema?.filters, issueCollector);\n        }\n    }\n\n    /**\n     * Enforce the schema's `indexed` policies on the final composed\n     * query, after relation pruning: the check governs the tree that\n     * will actually execute. Per-parameter throw policy comes from the\n     * sub-schemas themselves.\n     */\n    protected applyIndexPolicies<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        output: QueryContext,\n        options: ParseQueryOptions<RECORD>,\n        issueCollector?: IIssueCollector,\n    ) : void {\n        const context = { throwOnFailure: options.throwOnFailure, issueCollector };\n\n        if (output.filters) {\n            output.filters = applyFiltersIndexPolicy(output.filters, this.registry, options.schema, context);\n        }\n\n        if (output.sorts) {\n            output.sorts = applySortsIndexPolicy(output.sorts, this.registry, options.schema, context);\n        }\n    }\n\n    // -----------------------------------------------------\n\n    /**\n     * Parse relations input parameter.\n     *\n     * @param input\n     * @param options\n     */\n    parseRelations<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseParameterOptions<RECORD> = {},\n    ): IRelations {\n        return this.relationsParser.parse(input, options);\n    }\n\n    parseRelationsAsync<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseParameterOptions<RECORD> = {},\n    ) : Promise<IRelations> {\n        return this.relationsParser.parseAsync(input, options);\n    }\n\n    /**\n     * Parse fields input parameter.\n     *\n     * @param input\n     * @param options\n     */\n    parseFields<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseParameterOptions<RECORD> = {},\n    ) : IFields {\n        return this.fieldsParser.parse(input, options);\n    }\n\n    parseFieldsAsync<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseParameterOptions<RECORD> = {},\n    ) : Promise<IFields> {\n        return this.fieldsParser.parseAsync(input, options);\n    }\n\n    /**\n     * Parse filter(s) input parameter.\n     *\n     * @param input\n     * @param options\n     */\n    parseFilters<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseParameterOptions<RECORD> = {},\n    ) : IFilters {\n        return this.filtersParser.parse(input, options);\n    }\n\n    parseFiltersAsync<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseParameterOptions<RECORD> = {},\n    ) : Promise<IFilters> {\n        return this.filtersParser.parseAsync(input, options);\n    }\n\n    /**\n     * Parse pagination input parameter.\n     *\n     * @param input\n     * @param options\n     */\n    parsePagination<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseParameterOptions<RECORD> = {},\n    ) : IPagination {\n        return this.paginationParser.parse(input, options);\n    }\n\n    parsePaginationAsync<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseParameterOptions<RECORD> = {},\n    ) : Promise<IPagination> {\n        return this.paginationParser.parseAsync(input, options);\n    }\n\n    /**\n     * Parse sorts input parameter.\n     *\n     * @param input\n     * @param options\n     */\n    parseSorts<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseParameterOptions<RECORD> = {},\n    ) : ISorts {\n        return this.sortParser.parse(input, options);\n    }\n\n    parseSortsAsync<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseParameterOptions<RECORD> = {},\n    ) : Promise<ISorts> {\n        return this.sortParser.parseAsync(input, options);\n    }\n\n    /**\n     * @deprecated use {@link BaseQueryParser.parseSorts}. Removed in 3.0.\n     */\n    parseSort<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseParameterOptions<RECORD> = {},\n    ) : ISorts {\n        return this.parseSorts(input, options);\n    }\n\n    /**\n     * @deprecated use {@link BaseQueryParser.parseSortsAsync}. Removed in 3.0.\n     */\n    parseSortAsync<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        input: unknown,\n        options: ParseParameterOptions<RECORD> = {},\n    ) : Promise<ISorts> {\n        return this.parseSortsAsync(input, options);\n    }\n\n    // --------------------------------------------------\n\n    /**\n     * Read a parameter from the input object by its\n     * canonical {@link Parameter} key.\n     */\n    protected readParameter(\n        input: ObjectLiteral,\n        key: `${Parameter}`,\n    ) : unknown {\n        if (key === Parameter.SORTS) {\n            return resolveAliasedKey(\n                input,\n                Parameter.SORTS,\n                Parameter.SORT,\n                (canonical, alias) => ParseError.keyAmbiguous(canonical, alias),\n            );\n        }\n\n        if (isPropertySet(input, key)) {\n            return input[key];\n        }\n\n        return undefined;\n    }\n\n    /**\n     * A parameter is skipped when the `parameters` allow-list\n     * excludes it or its per-parameter option is `false`. A skipped\n     * parameter is neither parsed nor defaulted — the query leaves\n     * it empty, as if input and schema said nothing about it.\n     */\n    protected skipParameter<\n        RECORD extends ObjectLiteral = ObjectLiteral,\n    >(\n        options: ParseQueryOptions<RECORD>,\n        parameter: `${Parameter}`,\n    ) : boolean {\n        if (\n            typeof options.parameters !== 'undefined' &&\n            !options.parameters\n                .map((item) => normalizeParameter(item))\n                .includes(normalizeParameter(parameter))\n        ) {\n            return true;\n        }\n\n        const flag = parameter === Parameter.SORTS ?\n            resolveAliasedKey(\n                options,\n                Parameter.SORTS,\n                Parameter.SORT,\n                (canonical, alias) => ParseError.keyAmbiguous(canonical, alias),\n            ) :\n            options[parameter];\n\n        return typeof flag === 'boolean' && !flag;\n    }\n}\n"],"mappings":";;;;;;;AAUA,SAAgB,SAAS,MAA6C;CAClE,OACI,CAAC,CAAC,QACF,OAAO,SAAS,YAChB,CAAC,MAAM,QAAQ,IAAI;AAE3B;AAEA,SAAgB,eAGd,KAAQ,MAAwC;CAC9C,OAAO,OAAO,UAAU,eAAe,KAAK,KAAK,IAAI;A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