@routier/core 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/assertions/index.cjs +19 -8
- package/dist/assertions/index.cjs.map +1 -1
- package/dist/assertions/index.d.ts +5 -1
- package/dist/assertions/index.js +21 -9
- package/dist/assertions/index.js.map +1 -1
- package/dist/collections/MemoryDataCollection.d.ts +10 -0
- package/dist/collections/index.cjs +29 -4
- package/dist/collections/index.cjs.map +1 -1
- package/dist/collections/index.js +29 -4
- package/dist/collections/index.js.map +1 -1
- package/dist/expressions/callSource.d.ts +41 -0
- package/dist/expressions/evaluate.d.ts +3 -0
- package/dist/expressions/fold.d.ts +7 -0
- package/dist/expressions/index.cjs +1754 -233
- package/dist/expressions/index.cjs.map +1 -1
- package/dist/expressions/index.d.ts +2 -0
- package/dist/expressions/index.js +1765 -234
- package/dist/expressions/index.js.map +1 -1
- package/dist/expressions/types.d.ts +45 -26
- package/dist/expressions/utils.d.ts +19 -1
- package/dist/index.cjs +2429 -363
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2769 -682
- package/dist/index.js.map +1 -1
- package/dist/performance/index.cjs +6 -4
- package/dist/performance/index.cjs.map +1 -1
- package/dist/performance/index.js +6 -4
- package/dist/performance/index.js.map +1 -1
- package/dist/pipeline/index.cjs +6 -4
- package/dist/pipeline/index.cjs.map +1 -1
- package/dist/pipeline/index.js +6 -4
- package/dist/pipeline/index.js.map +1 -1
- package/dist/plugins/index.cjs +2323 -316
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +2328 -311
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/query/QueryOptionsCollection.d.ts +38 -10
- package/dist/plugins/query/describeFilter.d.ts +83 -0
- package/dist/plugins/query/explain.d.ts +71 -9
- package/dist/plugins/query/index.d.ts +1 -0
- package/dist/plugins/query/join.d.ts +4 -1
- package/dist/plugins/query/types.d.ts +36 -4
- package/dist/plugins/resultShape.d.ts +35 -0
- package/dist/schema/PropertyInfo.d.ts +0 -1
- package/dist/schema/index.cjs +7 -14
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.js +7 -14
- package/dist/schema/index.js.map +1 -1
- package/dist/transfer/ChunkEncoder.d.ts +60 -0
- package/dist/transfer/decoder.d.ts +29 -0
- package/dist/transfer/fillers.d.ts +36 -0
- package/dist/transfer/index.cjs +873 -0
- package/dist/transfer/index.cjs.map +1 -0
- package/dist/transfer/index.d.ts +47 -0
- package/dist/transfer/index.js +872 -0
- package/dist/transfer/index.js.map +1 -0
- package/dist/transfer/plan.d.ts +94 -0
- package/dist/transfer/types.d.ts +138 -0
- package/dist/utilities/index.cjs +242 -49
- package/dist/utilities/index.cjs.map +1 -1
- package/dist/utilities/index.js +242 -49
- package/dist/utilities/index.js.map +1 -1
- package/package.json +9 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expressions/index.cjs","sources":["webpack://@routier/core/./src/assertions/index.ts","webpack://@routier/core/./src/expressions/constants.ts","webpack://@routier/core/./src/expressions/evaluate.ts","webpack://@routier/core/./src/expressions/parser.ts","webpack://@routier/core/./src/expressions/types.ts","webpack://@routier/core/./src/expressions/utils.ts","webpack://@routier/core/./src/schema/types.ts","webpack://@routier/core/./src/utilities/logger.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/expressions/index.ts"],"sourcesContent":["import { EXPRESSION_TYPES } from \"../expressions/constants\";\nimport { ComparatorExpression, EmptyExpression, Expression, ExpressionType, NotParsableExpression, OperatorExpression, PropertyExpression, ValueExpression } from \"../expressions/types\";\nimport { isDate } from \"../utilities\";\n\nexport function assertDate(data: unknown): asserts data is Date {\n if (isDate(data) === false) {\n throw new TypeError('Value is not a Date');\n }\n}\n\nexport function assertIsNotNull<T>(data: T | null | undefined, message?: string | (() => string)): asserts data is NonNullable<T> {\n if (data == null) {\n if (message == null) {\n throw new TypeError('Assertion failed, data is null');\n }\n\n if (typeof message === \"string\") {\n throw new TypeError(message);\n }\n\n throw new TypeError(message());\n }\n}\n\nexport function assertIsArray<T>(data: unknown, message?: string): asserts data is T[] {\n if (!Array.isArray(data)) {\n throw new TypeError(message ?? 'Assertion failed, data is not of type Array');\n }\n}\n\nexport function assertString(data: unknown, message?: string): asserts data is string {\n if (typeof data !== \"string\") {\n throw new TypeError(message ?? 'Assertion failed, data is not of type String');\n }\n}\n\nexport function assertInstanceOf<T extends new (...args: any[]) => any>(value: unknown, Instance: T): asserts value is T {\n if (value instanceof Instance) {\n return;\n }\n\n if (value != null && typeof value === \"object\" && \"constructor\" in value) {\n throw new TypeError(`value is not instance of type. Type: ${value.constructor.name}`);\n }\n\n throw new TypeError(`value is not instance of type`);\n}\n\nexport function assertIsNumber(value: unknown): asserts value is number {\n if (typeof value !== \"number\") {\n throw new TypeError(\"value is not of type `number`\");\n }\n}\n\n\nfunction isObjectWithType(value: unknown): value is Record<\"type\", unknown> {\n return typeof value === \"object\" && value !== null && \"type\" in value;\n}\n\n/**\n * Type guard: narrows `value` to `Expression` when it is an object with a valid `type` property.\n */\nexport function isExpression(value: unknown): value is Expression {\n return isObjectWithType(value) && EXPRESSION_TYPES.includes(value.type as ExpressionType);\n}\n\n/**\n * Type guard: narrows `value` to `OperatorExpression` when it is an object with `type === \"operator\"`.\n */\nexport function isOperatorExpression(value: unknown): value is OperatorExpression {\n return isObjectWithType(value) && value.type === \"operator\";\n}\n\n/**\n * Type guard: narrows `value` to `ComparatorExpression` when it is an object with `type === \"comparator\"`.\n */\nexport function isComparatorExpression(value: unknown): value is ComparatorExpression {\n return isObjectWithType(value) && value.type === \"comparator\";\n}\n\n/**\n * Type guard: narrows `value` to `PropertyExpression` when it is an object with `type === \"property\"`.\n */\nexport function isPropertyExpression(value: unknown): value is PropertyExpression {\n return isObjectWithType(value) && value.type === \"property\";\n}\n\n/**\n * Type guard: narrows `value` to `ValueExpression` when it is an object with `type === \"value\"`.\n */\nexport function isValueExpression(value: unknown): value is ValueExpression {\n return isObjectWithType(value) && value.type === \"value\";\n}\n\n/**\n * Type guard: narrows `value` to `EmptyExpression` when it is an object with `type === \"empty\"`.\n */\nexport function isEmptyExpression(value: unknown): value is EmptyExpression {\n return isObjectWithType(value) && value.type === \"empty\";\n}\n\n/**\n * Type guard: narrows `value` to `NotParsableExpression` when it is an object with `type === \"not-parsable\"`.\n */\nexport function isNotParsableExpression(value: unknown): value is NotParsableExpression {\n return isObjectWithType(value) && value.type === \"not-parsable\";\n}","import { ExpressionType } from \"./types\";\n\nexport const EXPRESSION_TYPES: ExpressionType[] = [\n \"operator\",\n \"comparator\",\n \"property\",\n \"value\",\n \"empty\",\n \"not-parsable\",\n];\n","import { isComparatorExpression, isOperatorExpression, isPropertyExpression, isValueExpression } from \"../assertions\";\nimport { UnknownRecord } from \"../utilities\";\nimport { Comparator, Expression, Transformer } from \"./types\";\n\n/**\n * Runs a parsed expression against a row.\n *\n * The counterpart to `toSql` and `toMql`: those turn a tree into a backend's language, and this\n * turns it into an answer. Needed wherever a tree exists but the closure that produced it does\n * not — a filter split out of a larger predicate, an option rebuilt from a serialized query.\n *\n * ## It fails OPEN, and that is the whole safety argument\n *\n * `undefined` means \"this tree cannot be evaluated here\" — an unknown node, a transformer with no\n * implementation, a comparison between shapes that do not compare. Callers must read that as KEEP\n * THE ROW, never as exclude it.\n *\n * The reason is asymmetric cost. Every caller today uses this to NARROW something that a\n * subsequent, authoritative predicate will check again: a semi-join prefilter, a split conjunct.\n * Keeping a row this cannot judge costs one wasted comparison downstream. Dropping one loses data\n * from a query result and nothing anywhere reports it. So every uncertain path returns `undefined`,\n * and no path guesses `false`.\n *\n * ## Why not just reuse the caller's closure\n *\n * Because there often isn't one. A conjunct pulled out of `([p, m]) => p.a === 1 && m.b === 2` is\n * source TEXT; turning it back into a callable needs `new Function`, which a\n * Content-Security-Policy blocks — the same constraint that makes `softDeleteScope` build its tree\n * by hand. The tree is the only representation that survives.\n */\nexport type EvaluationResult = boolean | undefined;\n\n/** Reads a property or literal operand, or `UNRESOLVED` when the node is not one. */\nconst UNRESOLVED = Symbol(\"unresolved\");\n\nconst applyTransformer = (value: unknown, transformer: Transformer | null): unknown | typeof UNRESOLVED => {\n if (transformer == null) {\n return value;\n }\n\n // A transformer applied to an absent value has no answer, and inventing one (\"\" for a missing\n // string) is how a filter starts matching rows it should not.\n if (value == null) {\n return UNRESOLVED;\n }\n\n if (transformer === \"to-lower-case\") {\n return typeof value === \"string\" ? value.toLowerCase() : UNRESOLVED;\n }\n\n if (transformer === \"to-upper-case\") {\n return typeof value === \"string\" ? value.toUpperCase() : UNRESOLVED;\n }\n\n if (transformer === \"length\") {\n return typeof value === \"string\" || Array.isArray(value) ? value.length : UNRESOLVED;\n }\n\n return UNRESOLVED;\n};\n\nconst operand = (expression: Expression | undefined, row: UnknownRecord): unknown | typeof UNRESOLVED => {\n if (expression == null) {\n return UNRESOLVED;\n }\n\n if (isValueExpression(expression)) {\n return applyTransformer(expression.value, expression.transformer);\n }\n\n if (isPropertyExpression(expression)) {\n // Through the PropertyInfo, so a nested path and a `from`-renamed segment resolve the same\n // way every other consumer of the tree resolves them.\n return applyTransformer(expression.property.getValue(row), expression.transformer);\n }\n\n return UNRESOLVED;\n};\n\n/**\n * `a === b` for the comparators, with Dates compared by VALUE.\n *\n * A Date compares by reference under `===`, so two Dates holding the same instant would be\n * unequal — which is not what a filter on a date means, and not what any backend does.\n */\nconst equals = (left: unknown, right: unknown, strict: boolean): boolean => {\n if (left instanceof Date && right instanceof Date) {\n return left.getTime() === right.getTime();\n }\n\n // oxlint-disable-next-line eqeqeq\n return strict ? left === right : left == right;\n};\n\n/** Ordered comparison, only for shapes that have an order. */\nconst compare = (left: unknown, right: unknown, comparator: Comparator): EvaluationResult => {\n const asComparable = (value: unknown) => value instanceof Date ? value.getTime() : value;\n\n const a = asComparable(left);\n const b = asComparable(right);\n\n const comparable = (typeof a === \"number\" && typeof b === \"number\")\n || (typeof a === \"string\" && typeof b === \"string\");\n\n if (comparable === false) {\n return undefined;\n }\n\n if (comparator === \"greater-than\") {\n return a > b;\n }\n\n if (comparator === \"greater-than-equals\") {\n return a >= b;\n }\n\n if (comparator === \"less-than\") {\n return a < b;\n }\n\n return a <= b;\n};\n\nconst evaluateComparator = (comparator: Comparator, left: unknown, right: unknown, strict: boolean): EvaluationResult => {\n\n if (comparator === \"equals\") {\n return equals(left, right, strict);\n }\n\n if (comparator === \"includes\") {\n // Two shapes, and the tree does not distinguish them: `array.includes(value)` and\n // `string.includes(substring)`. Whichever side is the container decides.\n if (Array.isArray(left)) {\n return left.some(item => equals(item, right, strict));\n }\n\n if (Array.isArray(right)) {\n return right.some(item => equals(item, left, strict));\n }\n\n return typeof left === \"string\" && typeof right === \"string\" ? left.includes(right) : undefined;\n }\n\n if (comparator === \"starts-with\") {\n return typeof left === \"string\" && typeof right === \"string\" ? left.startsWith(right) : undefined;\n }\n\n if (comparator === \"ends-with\") {\n return typeof left === \"string\" && typeof right === \"string\" ? left.endsWith(right) : undefined;\n }\n\n return compare(left, right, comparator);\n};\n\n/**\n * Evaluates `expression` against `row`, or returns `undefined` when it cannot.\n *\n * See the note at the top of this file: `undefined` means KEEP the row.\n */\nexport const evaluate = (expression: Expression, row: UnknownRecord): EvaluationResult => {\n\n if (isOperatorExpression(expression)) {\n const left = expression.left == null ? undefined : evaluate(expression.left, row);\n const right = expression.right == null ? undefined : evaluate(expression.right, row);\n\n /**\n * One unevaluable side does not have to sink the whole tree.\n *\n * `a && b` where `a` is definitely false is false whatever `b` is, and `a || b` where `a`\n * is definitely true is true. That short-circuiting is what lets a mostly-understood\n * predicate still narrow anything at all — without it, one unfamiliar sub-expression makes\n * the entire filter a no-op.\n */\n if (expression.operator === \"&&\") {\n if (left === false || right === false) {\n return false;\n }\n\n return left === true && right === true ? true : undefined;\n }\n\n if (left === true || right === true) {\n return true;\n }\n\n return left === false && right === false ? false : undefined;\n }\n\n if (isComparatorExpression(expression)) {\n const left = operand(expression.left, row);\n const right = operand(expression.right, row);\n\n if (left === UNRESOLVED || right === UNRESOLVED) {\n return undefined;\n }\n\n const result = evaluateComparator(expression.comparator, left, right, expression.strict);\n\n if (result === undefined) {\n return undefined;\n }\n\n return expression.negated ? result === false : result;\n }\n\n // A tautology excludes nothing, which is exactly `true`. Anything else — a bare property, a\n // literal, `not-parsable` — is not a predicate this can judge.\n return expression.type === \"empty\" ? true : undefined;\n};\n\n/**\n * `evaluate`, as a predicate that keeps whatever it cannot judge.\n *\n * The form every narrowing caller wants, with the fail-open rule applied once here rather than\n * remembered at each call site.\n */\nexport const toPredicate = (expression: Expression) => (row: UnknownRecord): boolean =>\n evaluate(expression, row) !== false;\n\n/**\n * `evaluate`, as a predicate that THROWS on anything it cannot judge.\n *\n * The opposite default to `toPredicate`, and the right one when the predicate is the only thing\n * standing between a caller and rows they asked to exclude — a filter that arrived over a wire and\n * is being applied by the receiver. Failing open there does not cost a wasted comparison; it returns\n * data the requester filtered out, and reports nothing.\n *\n * Use `toPredicate` when something authoritative re-checks the result, and this when nothing does.\n */\nexport const toStrictPredicate = (expression: Expression) => (row: UnknownRecord): boolean => {\n const result = evaluate(expression, row);\n\n if (result === undefined) {\n throw new Error(\n \"Cannot apply this filter: its expression cannot be evaluated in memory, and applying it partially would \" +\n \"return rows the filter excludes. This happens when a filter arrives without a runnable predicate — over a \" +\n \"wire, or rebuilt from a serialized query — and names something the evaluator does not understand.\"\n );\n }\n\n return result;\n};\n","import { logger } from \"../utilities\";\nimport { assertString } from \"../assertions\";\nimport { CompiledSchema, PropertyInfo, SchemaTypes } from \"../schema\";\nimport { Expression, OperatorExpression, ComparatorExpression, ValueExpression, PropertyExpression, Filter, ParamsFilter, Comparator, Transformer } from \"./types\";\n\n// Error message constants\nconst ERROR_MESSAGES = {\n PROPERTY_NOT_FOUND: (path: string) => `Error parsing query, could not find PropertyInfo for path: ${path}`,\n PARAM_PATH_NOT_FOUND: (value: string, params: unknown) => `Cannot find path in params for .where(). Make sure parameters are not used inline.\\r\\nPath: ${value}, Params: ${JSON.stringify(params)}`,\n VARIABLE_VALUE: (value: string) => `Cannot derive value from variable, please pass parameters into the expression.\n\nExample: .where(([x, params]) => x.id === params.id, { id: someVar.id })\nIssue At: ${value}`,\n UNSUPPORTED: (value: string) => `Unsupported expression format: ${value}`\n};\n\nconst parseUnknown = (value: unknown) => {\n assertString(value);\n return JSON.parse(value);\n}\n\n/**\n * A parse failure caused by the params VALUES rather than the filter source.\n * These must never poison the template cache — the same source can succeed\n * with different params.\n */\nclass ParamDependentParseError extends Error { }\n\nconst converters: Record<SchemaTypes, (value: unknown) => unknown> = {\n Array: v => v,\n Boolean: v => v == null ? v : Boolean(v),\n // Stryker disable next-line ArrowFunction: filters on computed properties route to\n // in-memory execution, so this entry cannot be reached through a parsable filter.\n Computed: v => v,\n Date: v => v,\n // A file is a reference, and a filter can legitimately compare its fields — content type\n // and size are ordinary columns. The value passes through unconverted like an object.\n File: v => v,\n // Stryker disable next-line ArrowFunction: SchemaTypes.Definition is handled as a\n // generic primitive everywhere (specs/known-defects.md) and never pairs in a filter.\n Definition: v => v,\n // Stryker disable next-line ArrowFunction: filters on function properties route to\n // in-memory execution, so this entry cannot be reached through a parsable filter.\n Function: v => v,\n Number: v => v == null ? v : Number(v),\n Object: v => v,\n String: v => v == null ? v : String(v),\n // A vector is a list of numbers and passes through like any other array. Nothing\n // converts it because nothing compares it: similarity is `.nearest()`, not a filter.\n Vector: v => v\n};\n\n// #region Tokenizer\n\ntype TokenKind = \"identifier\" | \"string\" | \"number\" | \"punctuation\";\n\ntype Token = {\n kind: TokenKind;\n value: string;\n}\n\n// Longest first so multi-character punctuation wins over its prefixes\nconst MULTI_CHARACTER_PUNCTUATION = [\"===\", \"!==\", \"?.\", \"&&\", \"||\", \"==\", \"!=\", \">=\", \"<=\", \"=>\"] as const;\n// Stryker disable next-line all: documented equivalent cluster (see\n// docs/mutation-backlog.md) — dropping an entry only affects source the parser rejects\n// either way, and the rejection message names the character from the source rather than\n// from this set, so no observable boundary distinguishes the mutant. Established\n// experimentally: 30 message-asserting tests killed 1 of 12.\nconst SINGLE_CHARACTER_PUNCTUATION = new Set([\"(\", \")\", \"[\", \"]\", \"{\", \"}\", \".\", \",\", \";\", \"!\", \">\", \"<\", \"-\", \"+\", \"*\", \"/\", \"%\", \"=\", \"?\", \":\", \"&\", \"|\"]);\n\nconst STRING_ESCAPES: Record<string, string> = {\n \"n\": \"\\n\",\n \"r\": \"\\r\",\n \"t\": \"\\t\",\n \"b\": \"\\b\",\n \"f\": \"\\f\",\n \"v\": \"\\v\",\n \"0\": \"\\0\"\n};\n\nconst isIdentifierStart = (char: string) => /[a-zA-Z_$]/.test(char);\nconst isIdentifierPart = (char: string) => /[a-zA-Z0-9_$]/.test(char);\nconst isDigit = (char: string) => char >= \"0\" && char <= \"9\";\nconst isHexDigit = (char: string) => isDigit(char) || (char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\");\n\n/**\n * Decodes a `\\uXXXX`, `\\u{...}` or `\\xXX` escape starting at the backslash.\n * Returns the decoded character and the index just past the escape. These\n * escapes carry a computed character, so mapping them through STRING_ESCAPES\n * (which would yield the literal \"u\"/\"x\") silently corrupts the value.\n */\nconst decodeCodeEscape = (source: string, backslashIndex: number): { value: string, nextIndex: number } => {\n const kind = source[backslashIndex + 1];\n let start = backslashIndex + 2;\n\n if (kind === \"u\" && source[start] === \"{\") {\n const end = source.indexOf(\"}\", start + 1);\n\n if (end === -1) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unterminated unicode escape\"));\n }\n\n return { value: String.fromCodePoint(parseInt(source.slice(start + 1, end), 16)), nextIndex: end + 1 };\n }\n\n const length = kind === \"u\" ? 4 : 2;\n const digits = source.slice(start, start + length);\n\n if (digits.length < length || [...digits].some(d => !isHexDigit(d))) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`'\\\\${kind}' escape`));\n }\n\n return { value: String.fromCharCode(parseInt(digits, 16)), nextIndex: start + length };\n}\n\n/**\n * Converts filter source text into a flat token stream. Strings and comments are\n * consumed here so operator characters inside literals can never be mistaken for\n * real operators.\n */\nconst tokenize = (source: string): Token[] => {\n\n const tokens: Token[] = [];\n let i = 0;\n\n while (i < source.length) {\n const char = source[i];\n\n // Whitespace\n if (char === \" \" || char === \"\\t\" || char === \"\\r\" || char === \"\\n\") {\n i++;\n continue;\n }\n\n // Comments\n if (char === \"/\" && source[i + 1] === \"/\") {\n while (i < source.length && source[i] !== \"\\n\") {\n i++;\n }\n continue;\n }\n\n if (char === \"/\" && source[i + 1] === \"*\") {\n i += 2;\n while (i < source.length && !(source[i] === \"*\" && source[i + 1] === \"/\")) {\n i++;\n }\n i += 2;\n continue;\n }\n\n // String literals\n if (char === \"'\" || char === \"\\\"\" || char === \"`\") {\n const quote = char;\n let value = \"\";\n i++;\n\n while (i < source.length && source[i] !== quote) {\n if (source[i] === \"\\\\\") {\n const escaped = source[i + 1];\n\n if (escaped === \"u\" || escaped === \"x\") {\n const decoded = decodeCodeEscape(source, i);\n value += decoded.value;\n i = decoded.nextIndex;\n continue;\n }\n\n value += STRING_ESCAPES[escaped] ?? escaped;\n i += 2;\n continue;\n }\n\n if (quote === \"`\" && source[i] === \"$\" && source[i + 1] === \"{\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"template literal interpolation\"));\n }\n\n value += source[i];\n i++;\n }\n\n if (i >= source.length) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unterminated string literal\"));\n }\n\n i++; // consume closing quote\n tokens.push({ kind: \"string\", value });\n continue;\n }\n\n // Numbers — covers decimals, exponents (1e6), hex/octal/binary (0xFF),\n // and numeric separators (1_000_000). Values are normalized here (the\n // separator stripped) so the parser can hand them straight to Number()\n if (isDigit(char)) {\n let value = \"\";\n\n const nextChar = source[i + 1];\n const radixPrefix = char === \"0\" && nextChar != null && \"xXoObB\".includes(nextChar);\n\n if (radixPrefix) {\n value = source[i] + source[i + 1];\n i += 2;\n\n while (i < source.length && (isHexDigit(source[i]) || source[i] === \"_\")) {\n value += source[i];\n i++;\n }\n } else {\n while (i < source.length && (isDigit(source[i]) || source[i] === \".\" || source[i] === \"_\")) {\n value += source[i];\n i++;\n }\n\n // Exponent part: e/E, optional sign, then digits. Only consumed when\n // digits follow, so a stray identifier after a number still errors\n if ((source[i] === \"e\" || source[i] === \"E\")) {\n const signLength = source[i + 1] === \"+\" || source[i + 1] === \"-\" ? 1 : 0;\n\n if (isDigit(source[i + 1 + signLength])) {\n value += source[i];\n i++;\n\n if (signLength === 1) {\n value += source[i];\n i++;\n }\n\n while (i < source.length && isDigit(source[i])) {\n value += source[i];\n i++;\n }\n }\n }\n }\n\n tokens.push({ kind: \"number\", value: value.replace(/_/g, \"\") });\n continue;\n }\n\n // Identifiers / keywords\n if (isIdentifierStart(char)) {\n let value = \"\";\n\n while (i < source.length && isIdentifierPart(source[i])) {\n value += source[i];\n i++;\n }\n\n tokens.push({ kind: \"identifier\", value });\n continue;\n }\n\n // Multi-character punctuation (longest match first)\n const multi = MULTI_CHARACTER_PUNCTUATION.find(w => source.startsWith(w, i));\n\n if (multi != null) {\n tokens.push({ kind: \"punctuation\", value: multi });\n i += multi.length;\n continue;\n }\n\n if (SINGLE_CHARACTER_PUNCTUATION.has(char)) {\n tokens.push({ kind: \"punctuation\", value: char });\n i++;\n continue;\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`unexpected character '${char}'`));\n }\n\n return tokens;\n}\n\n/**\n * Cursor over the token stream with the small set of lookahead operations the\n * parser needs.\n */\nclass TokenStream {\n\n private readonly tokens: Token[];\n private index: number = 0;\n\n constructor(tokens: Token[]) {\n this.tokens = tokens;\n }\n\n get isAtEnd() {\n return this.index >= this.tokens.length;\n }\n\n peek(offset: number = 0): Token | null {\n return this.tokens[this.index + offset] ?? null;\n }\n\n next(): Token {\n const token = this.tokens[this.index];\n\n if (token == null) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unexpected end of expression\"));\n }\n\n this.index++;\n return token;\n }\n\n isPunctuation(value: string, offset: number = 0): boolean {\n const token = this.peek(offset);\n return token != null && token.kind === \"punctuation\" && token.value === value;\n }\n\n matchPunctuation(value: string): boolean {\n if (this.isPunctuation(value)) {\n this.index++;\n return true;\n }\n\n return false;\n }\n\n expectPunctuation(value: string) {\n if (!this.matchPunctuation(value)) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`expected '${value}'`));\n }\n }\n}\n\n// #endregion\n\n// #region Operands\n\n// Discriminated union so a condition builder can only ever see the operand\n// shapes the grammar allows\ntype PropertyOperand = {\n kind: \"property\";\n property: PropertyInfo<any>;\n transformer: Transformer | null;\n locale: string | null;\n}\n\ntype ValueOperand = {\n kind: \"value\";\n value: unknown;\n transformer: Transformer | null;\n locale: string | null;\n}\n\ntype ParamOperand = {\n kind: \"param\";\n path: string[];\n transformer: Transformer | null;\n locale: string | null;\n}\n\ntype MethodCallOperand = {\n kind: \"method-call\";\n target: PropertyOperand | ParamOperand | ValueOperand;\n method: \"startsWith\" | \"endsWith\" | \"includes\";\n argument: PropertyOperand | ValueOperand | ParamOperand;\n}\n\ntype Operand = PropertyOperand | ValueOperand | ParamOperand | MethodCallOperand;\n\nconst COMPARATOR_METHODS: Record<string, Comparator> = {\n startsWith: \"starts-with\",\n endsWith: \"ends-with\",\n includes: \"includes\"\n};\n\nconst TRANSFORM_METHODS: Record<string, { transformer: Transformer, locale: string | null }> = {\n toLowerCase: { transformer: \"to-lower-case\", locale: null },\n toUpperCase: { transformer: \"to-upper-case\", locale: null },\n toLocaleLowerCase: { transformer: \"to-lower-case\", locale: \"en-US\" },\n toLocaleUpperCase: { transformer: \"to-upper-case\", locale: \"en-US\" }\n};\n\nconst COMPARISON_OPERATORS: Record<string, { comparator: Comparator, negated: boolean, strict: boolean }> = {\n \"==\": { comparator: \"equals\", negated: false, strict: false },\n \"===\": { comparator: \"equals\", negated: false, strict: true },\n \"!=\": { comparator: \"equals\", negated: true, strict: false },\n \"!==\": { comparator: \"equals\", negated: true, strict: true },\n \">\": { comparator: \"greater-than\", negated: false, strict: false },\n \">=\": { comparator: \"greater-than-equals\", negated: false, strict: false },\n \"<\": { comparator: \"less-than\", negated: false, strict: false },\n \"<=\": { comparator: \"less-than-equals\", negated: false, strict: false }\n};\n\nconst SWAPPED_COMPARATORS: Record<Comparator, Comparator> = {\n \"equals\": \"equals\",\n \"greater-than\": \"less-than\",\n \"greater-than-equals\": \"less-than-equals\",\n \"less-than\": \"greater-than\",\n \"less-than-equals\": \"greater-than-equals\",\n \"starts-with\": \"starts-with\",\n \"ends-with\": \"ends-with\",\n \"includes\": \"includes\"\n};\n\n// #endregion\n\n// #region Param references\n\n/**\n * Placeholder for a parameter value inside a cached expression template. Never\n * escapes this module — binding replaces it with a plain ValueExpression that\n * holds the resolved value.\n */\nclass ParamReferenceExpression extends ValueExpression {\n\n /** Path into the params object, excluding the params root name. */\n readonly paramPath: string[];\n /** The property this value is compared against; drives serialization/conversion at bind time. */\n readonly pairedProperty: PropertyInfo<any> | null;\n /** Whether the paired property's type converter applies (equality/relational comparisons only). */\n readonly applyConverter: boolean;\n\n constructor(options: {\n paramPath: string[],\n pairedProperty: PropertyInfo<any> | null,\n applyConverter: boolean\n }) {\n super({ value: undefined });\n this.paramPath = options.paramPath;\n this.pairedProperty = options.pairedProperty;\n this.applyConverter = options.applyConverter;\n }\n}\n\nconst resolveParamPath = (paramsName: string, path: string[], data: unknown) => {\n\n let result = data as Record<string, unknown>;\n\n for (let i = 0; i < path.length; i++) {\n const name = path[i];\n\n if (result != null && typeof result === \"object\" && name in result) {\n result = result[name] as Record<string, unknown>;\n continue;\n }\n\n throw new ParamDependentParseError(ERROR_MESSAGES.PARAM_PATH_NOT_FOUND([paramsName, ...path].join(\".\"), data));\n }\n\n return result as unknown;\n}\n\n/**\n * Applies the paired property's value serializer and (optionally) its schema\n * type converter, matching how literal values are treated at parse time.\n */\nconst resolvePairedValue = (value: unknown, pairedProperty: PropertyInfo<any> | null, applyConverter: boolean) => {\n\n if (pairedProperty == null) {\n return value;\n }\n\n let result = value;\n\n if (pairedProperty.valueSerializer != null) {\n result = String(pairedProperty.valueSerializer(parseUnknown(result)));\n }\n\n if (applyConverter) {\n result = converters[pairedProperty.type](result);\n }\n\n return result;\n}\n\n// #endregion\n\n// #region Parser\n\n/**\n * Recursive descent parser over the token stream. Produces an expression\n * template: literal values are fully resolved, parameter values are represented\n * as ParamReferenceExpression placeholders so the template can be cached and\n * re-bound with different params.\n */\nclass ExpressionParser {\n\n private readonly schema: CompiledSchema<any>;\n private readonly stream: TokenStream;\n private readonly entityName: string;\n private readonly paramsName: string | null;\n private readonly params: unknown;\n\n /** Set when a param value shaped the tree itself (e.g. x[p.name]) — such templates cannot be cached. */\n structurallyDependsOnParams: boolean = false;\n\n constructor(schema: CompiledSchema<any>, stream: TokenStream, entityName: string, paramsName: string | null, params: unknown) {\n this.schema = schema;\n this.stream = stream;\n this.entityName = entityName;\n this.paramsName = paramsName;\n this.params = params;\n }\n\n parse(): Expression {\n const expression = this.parseOr();\n\n if (!this.stream.isAtEnd) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`unexpected token '${this.stream.peek()?.value}'`));\n }\n\n return expression;\n }\n\n // || binds loosest, so it sits at the root of the parse\n private parseOr(): Expression {\n let left = this.parseAnd();\n\n while (this.stream.matchPunctuation(\"||\")) {\n const right = this.parseAnd();\n\n // A tautology (`true`) absorbs the whole disjunction\n if (Expression.isEmpty(left) || Expression.isEmpty(right)) {\n left = Expression.EMPTY;\n continue;\n }\n\n left = new OperatorExpression({ operator: \"||\", left, right });\n }\n\n return left;\n }\n\n private parseAnd(): Expression {\n let left = this.parseUnary();\n\n while (this.stream.matchPunctuation(\"&&\")) {\n const right = this.parseUnary();\n\n // A tautology (`true`) is the identity of a conjunction\n if (Expression.isEmpty(left)) {\n left = right;\n continue;\n }\n\n if (Expression.isEmpty(right)) {\n continue;\n }\n\n left = new OperatorExpression({ operator: \"&&\", left, right });\n }\n\n return left;\n }\n\n private parseUnary(): Expression {\n if (this.stream.matchPunctuation(\"!\")) {\n return this.negateExpression(this.parseUnary());\n }\n\n return this.parseComparison();\n }\n\n /**\n * Applies `!` to an already-parsed expression: comparators flip their\n * negated flag, compound expressions distribute via De Morgan's laws.\n */\n private negateExpression(expression: Expression): Expression {\n if (expression instanceof ComparatorExpression) {\n expression.negated = !expression.negated;\n return expression;\n }\n\n if (expression instanceof OperatorExpression && expression.left != null && expression.right != null) {\n return new OperatorExpression({\n operator: expression.operator === \"&&\" ? \"||\" : \"&&\",\n left: this.negateExpression(expression.left),\n right: this.negateExpression(expression.right)\n });\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"'!' on this expression\"));\n }\n\n private parseComparison(): Expression {\n\n // Parenthesized group\n if (this.stream.matchPunctuation(\"(\")) {\n const expression = this.parseOr();\n this.stream.expectPunctuation(\")\");\n\n const trailing = this.stream.peek();\n if (trailing != null && trailing.kind === \"punctuation\" && COMPARISON_OPERATORS[trailing.value] != null) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"comparison against a parenthesized expression\"));\n }\n\n return expression;\n }\n\n const left = this.parseOperand();\n const operatorToken = this.stream.peek();\n\n if (operatorToken != null && operatorToken.kind === \"punctuation\" && COMPARISON_OPERATORS[operatorToken.value] != null) {\n this.stream.next();\n const right = this.parseOperand();\n return this.buildComparison(left, COMPARISON_OPERATORS[operatorToken.value], right);\n }\n\n return this.buildStandalone(left);\n }\n\n private parseOperand(): Operand {\n const token = this.stream.peek();\n\n if (token == null) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unexpected end of expression\"));\n }\n\n if (token.kind === \"string\") {\n this.stream.next();\n return this.withValueTransformer({ kind: \"value\", value: token.value, transformer: null, locale: null });\n }\n\n if (token.kind === \"number\") {\n this.stream.next();\n return { kind: \"value\", value: Number(token.value), transformer: null, locale: null };\n }\n\n if (token.kind === \"punctuation\" && token.value === \"-\") {\n this.stream.next();\n const numberToken = this.stream.next();\n\n if (numberToken.kind !== \"number\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unary '-' on a non-number\"));\n }\n\n return { kind: \"value\", value: -Number(numberToken.value), transformer: null, locale: null };\n }\n\n if (token.kind === \"punctuation\" && token.value === \"[\") {\n return this.parseArrayLiteralOperand();\n }\n\n if (token.kind === \"identifier\") {\n return this.parseIdentifierOperand();\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(String(token.value)));\n }\n\n /**\n * Parses an inline array of literals, e.g. `[\"active\", \"pending\"]`, and the\n * membership test that follows it: `[...].includes(entity.property)`.\n */\n private parseArrayLiteralOperand(): Operand {\n this.stream.expectPunctuation(\"[\");\n const elements: unknown[] = [];\n\n while (!this.stream.isPunctuation(\"]\")) {\n const element = this.parseOperand();\n\n if (element.kind !== \"value\" || element.transformer != null) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"a non-literal element in an array literal\"));\n }\n\n elements.push(element.value);\n\n if (!this.stream.matchPunctuation(\",\")) {\n break;\n }\n }\n\n this.stream.expectPunctuation(\"]\");\n\n const array: ValueOperand = { kind: \"value\", value: elements, transformer: null, locale: null };\n\n // The only supported use is a membership test on a schema property\n if (this.stream.isPunctuation(\".\") || this.stream.isPunctuation(\"?.\")) {\n this.stream.next();\n const method = this.stream.next();\n\n if (method.kind !== \"identifier\" || method.value !== \"includes\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`'.${method.value}' on an array literal`));\n }\n\n this.stream.expectPunctuation(\"(\");\n const argument = this.parseOperand();\n this.stream.expectPunctuation(\")\");\n\n if (argument.kind === \"method-call\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"nested method call inside .includes()\"));\n }\n\n return { kind: \"method-call\", target: array, method: \"includes\", argument };\n }\n\n return array;\n }\n\n private parseIdentifierOperand(): Operand {\n const root = this.stream.next().value;\n\n // Keyword literals\n if (root === \"true\" || root === \"false\") {\n return { kind: \"value\", value: root === \"true\", transformer: null, locale: null };\n }\n\n if (root === \"null\") {\n return { kind: \"value\", value: null, transformer: null, locale: null };\n }\n\n if (root === \"undefined\") {\n return { kind: \"value\", value: undefined, transformer: null, locale: null };\n }\n\n if (root === \"void\") {\n this.stream.next(); // the '0'\n return { kind: \"value\", value: undefined, transformer: null, locale: null };\n }\n\n if (root === this.entityName) {\n return this.parseChain({ kind: \"property\", root });\n }\n\n if (this.paramsName != null && root === this.paramsName) {\n return this.parseChain({ kind: \"param\", root });\n }\n\n // A bare variable from the outer scope — its value cannot be derived from source text\n throw new Error(ERROR_MESSAGES.VARIABLE_VALUE(root));\n }\n\n /**\n * Parses the segments after an entity/params root: dot access, bracket\n * access, transform methods and comparator methods.\n */\n private parseChain(options: { kind: \"property\" | \"param\", root: string }): Operand {\n const path: string[] = [];\n let transformer: Transformer | null = null;\n let locale: string | null = null;\n\n while (true) {\n if (this.stream.matchPunctuation(\".\") || this.stream.matchPunctuation(\"?.\")) {\n const segment = this.stream.next();\n\n if (segment.kind !== \"identifier\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`'.${segment.value}'`));\n }\n\n // Method call\n if (this.stream.isPunctuation(\"(\")) {\n const method = segment.value;\n\n if (TRANSFORM_METHODS[method] != null) {\n this.stream.expectPunctuation(\"(\");\n this.stream.expectPunctuation(\")\");\n transformer = TRANSFORM_METHODS[method].transformer;\n locale = TRANSFORM_METHODS[method].locale;\n continue;\n }\n\n if (COMPARATOR_METHODS[method] != null) {\n this.stream.expectPunctuation(\"(\");\n const argument = this.parseOperand();\n this.stream.expectPunctuation(\")\");\n\n if (argument.kind === \"method-call\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`nested method call inside .${method}()`));\n }\n\n return {\n kind: \"method-call\",\n target: this.resolveChain(options.kind, path, transformer, locale),\n method: method as MethodCallOperand[\"method\"],\n argument\n };\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`method '.${method}()'`));\n }\n\n if (transformer != null) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"property access after a transform method\"));\n }\n\n path.push(segment.value);\n continue;\n }\n\n if (this.stream.matchPunctuation(\"[\")) {\n path.push(this.parseBracketSegment(options.kind));\n this.stream.expectPunctuation(\"]\");\n continue;\n }\n\n break;\n }\n\n return this.resolveChain(options.kind, path, transformer, locale);\n }\n\n private parseBracketSegment(kind: \"property\" | \"param\"): string {\n const token = this.stream.next();\n\n // Literal segment: entity[\"name\"]\n if (token.kind === \"string\") {\n return token.value;\n }\n\n // Param-driven segment: entity[p.name] — the property depends on the\n // param VALUE, so the resulting template is tied to these params.\n // Stryker disable next-line all: documented equivalent cluster (see\n // docs/mutation-backlog.md) — every mutation of this four-conjunct guard reroutes\n // bracket access between two paths that both collapse to NOT_PARSABLE; the\n // experiment recorded there aimed 30 tests at this line and killed none.\n if (kind === \"property\" && token.kind === \"identifier\" && this.paramsName != null && token.value === this.paramsName) {\n const paramPath: string[] = [];\n\n while (this.stream.matchPunctuation(\".\") || this.stream.matchPunctuation(\"?.\")) {\n paramPath.push(this.stream.next().value);\n }\n\n const resolved = resolveParamPath(this.paramsName, paramPath, this.params);\n\n if (typeof resolved !== \"string\") {\n throw new ParamDependentParseError(ERROR_MESSAGES.PROPERTY_NOT_FOUND(paramPath.join(\".\")));\n }\n\n this.structurallyDependsOnParams = true;\n return resolved;\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`bracket access '[${token.value}]'`));\n }\n\n private resolveChain(kind: \"property\" | \"param\", path: string[], transformer: Transformer | null, locale: string | null): PropertyOperand | ParamOperand {\n\n if (kind === \"param\") {\n if (path.length === 0) {\n // `params` alone is a variable, not a value we can resolve\n throw new Error(ERROR_MESSAGES.PARAM_PATH_NOT_FOUND(this.paramsName ?? \"params\", this.params));\n }\n\n return { kind: \"param\", path, transformer, locale };\n }\n\n const pathString = path.join(\".\");\n const property = this.schema.properties.find(w => w.getAssignmentPath() == pathString);\n\n if (property == null) {\n // `.length` on a string/array property — a real schema property named\n // `length` wins (checked above); otherwise treat it as a transformer\n if (path.length > 1 && path[path.length - 1] === \"length\" && transformer == null) {\n const parentPath = path.slice(0, -1).join(\".\");\n const parent = this.schema.properties.find(w => w.getAssignmentPath() == parentPath);\n\n // Vector is deliberately absent. Its length is the dimension count declared\n // in the schema — a constant, not data — so a filter on it answers a question\n // nobody asks, and pushing it down would need `json_array_length` on a\n // backend storing JSON and something else entirely on one with a native\n // vector column. Not parsing it leaves a clear error instead of a dialect gap.\n if (parent != null && (parent.type === SchemaTypes.String || parent.type === SchemaTypes.Array)) {\n return { kind: \"property\", property: parent, transformer: \"length\", locale: null };\n }\n }\n\n throw new Error(ERROR_MESSAGES.PROPERTY_NOT_FOUND(pathString));\n }\n\n return { kind: \"property\", property, transformer, locale };\n }\n\n private withValueTransformer(operand: ValueOperand): ValueOperand {\n if (this.stream.isPunctuation(\".\")) {\n const method = this.stream.peek(1);\n\n // Stryker disable next-line all: documented equivalent cluster (see\n // docs/mutation-backlog.md) — the guard's conjuncts each route to a rejection that\n // collapses to NOT_PARSABLE with an indistinguishable message; 18 targeted tests\n // killed none of these.\n if (method != null && method.kind === \"identifier\" && TRANSFORM_METHODS[method.value] != null) {\n this.stream.next(); // .\n this.stream.next(); // method name\n this.stream.expectPunctuation(\"(\");\n this.stream.expectPunctuation(\")\");\n\n operand.transformer = TRANSFORM_METHODS[method.value].transformer;\n operand.locale = TRANSFORM_METHODS[method.value].locale;\n }\n }\n\n return operand;\n }\n\n // #region Condition building\n\n private buildComparison(left: Operand, operator: { comparator: Comparator, negated: boolean, strict: boolean }, right: Operand): Expression {\n\n // methodCall == true/false — fold the boolean into negation\n if (left.kind === \"method-call\") {\n if (operator.comparator === \"equals\" && right.kind === \"value\" && typeof right.value === \"boolean\") {\n const comparator = this.buildMethodComparator(left);\n const comparedToFalse = right.value === false;\n comparator.negated = comparator.negated !== (operator.negated !== comparedToFalse);\n return comparator;\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"comparing a method call to a non-boolean\"));\n }\n\n if (right.kind === \"method-call\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"method call on the right side of a comparison\"));\n }\n\n if (left.kind === \"property\" && right.kind === \"property\") {\n // Casing transformers are only valid with string-matching comparators,\n // which cannot produce a property-to-property comparison\n if (left.transformer === \"to-lower-case\" || left.transformer === \"to-upper-case\" ||\n right.transformer === \"to-lower-case\" || right.transformer === \"to-upper-case\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"transform method outside of startsWith/endsWith/includes\"));\n }\n\n return new ComparatorExpression({\n comparator: operator.comparator,\n negated: operator.negated,\n strict: operator.strict,\n left: this.createPropertyExpression(left),\n right: this.createPropertyExpression(right)\n });\n }\n\n if (left.kind === \"property\" && right.kind !== \"property\") {\n return this.buildPropertyComparator(left, operator, right, /* applyConverter */ true);\n }\n\n if (right.kind === \"property\" && left.kind !== \"property\") {\n const swapped = { ...operator, comparator: SWAPPED_COMPARATORS[operator.comparator] };\n return this.buildPropertyComparator(right, swapped, left, /* applyConverter */ true);\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"comparison requires a schema property on at least one side\"));\n }\n\n private buildStandalone(operand: Operand): Expression {\n\n if (operand.kind === \"method-call\") {\n return this.buildMethodComparator(operand);\n }\n\n if (operand.kind === \"property\") {\n // Truthy shorthand on `.length`: a length is truthy exactly when > 0\n if (operand.transformer === \"length\") {\n return this.buildPropertyComparator(operand, COMPARISON_OPERATORS[\">\"], { kind: \"value\", value: 0, transformer: null, locale: null }, /* applyConverter */ true);\n }\n\n // Truthy shorthand: `w.isActive` → isActive === true\n return this.buildPropertyComparator(operand, COMPARISON_OPERATORS[\"===\"], { kind: \"value\", value: true, transformer: null, locale: null }, /* applyConverter */ true);\n }\n\n // Constant `true` — a tautology, which parseAnd/parseOr simplify away\n if (operand.kind === \"value\" && operand.value === true && operand.transformer == null) {\n return Expression.EMPTY;\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"a filter condition must reference a schema property\"));\n }\n\n private buildMethodComparator(operand: MethodCallOperand): ComparatorExpression {\n const { target, method, argument } = operand;\n\n if (target.kind === \"property\") {\n if (argument.kind === \"property\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`.${method}() comparing two schema properties`));\n }\n\n // Method arguments skip type conversion — only the value serializer applies\n return this.buildPropertyComparator(target, { comparator: COMPARATOR_METHODS[method], negated: false, strict: false }, argument, /* applyConverter */ false);\n }\n\n // [\"a\", \"b\"].includes(x.prop) / params.list.includes(x.prop) —\n // membership test with the collection on the left\n if (method === \"includes\" && argument.kind === \"property\") {\n if (target.transformer != null) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"transform method on a collection used with .includes()\"));\n }\n\n return new ComparatorExpression({\n comparator: \"includes\",\n negated: false,\n strict: false,\n left: this.createValueExpression(target, argument.property, /* applyConverter */ false),\n right: this.createPropertyExpression(argument)\n });\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`.${method}() on a non-property target`));\n }\n\n private buildPropertyComparator(property: PropertyOperand, operator: { comparator: Comparator, negated: boolean, strict: boolean }, value: ValueOperand | ParamOperand, applyConverter: boolean): ComparatorExpression {\n\n const isStringMatch = operator.comparator === \"starts-with\" || operator.comparator === \"ends-with\" || operator.comparator === \"includes\";\n\n // `.length` compares a NUMBER, so the paired property's serializer and\n // type converter must not touch the value; and a length has no meaning\n // inside a string-matching comparator\n if (property.transformer === \"length\") {\n if (isStringMatch) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"'.length' with startsWith/endsWith/includes\"));\n }\n\n return new ComparatorExpression({\n comparator: operator.comparator,\n negated: operator.negated,\n strict: operator.strict,\n left: this.createPropertyExpression(property),\n right: this.createValueExpression(value, null, /* applyConverter */ false)\n });\n }\n\n // Casing transformers on a property are only meaningful with string-matching\n // comparators; on relational comparators the plugins would silently\n // ignore them and return wrong data\n if (property.transformer != null && !isStringMatch) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"transform method outside of startsWith/endsWith/includes\"));\n }\n\n return new ComparatorExpression({\n comparator: operator.comparator,\n negated: operator.negated,\n strict: operator.strict,\n left: this.createPropertyExpression(property),\n right: this.createValueExpression(value, property.property, applyConverter)\n });\n }\n\n private createPropertyExpression(operand: PropertyOperand): PropertyExpression {\n const expression = new PropertyExpression({ property: operand.property });\n expression.transformer = operand.transformer;\n expression.locale = operand.locale;\n return expression;\n }\n\n private createValueExpression(operand: ValueOperand | ParamOperand, pairedProperty: PropertyInfo<any> | null, applyConverter: boolean): ValueExpression {\n\n if (operand.kind === \"param\") {\n const expression = new ParamReferenceExpression({ paramPath: operand.path, pairedProperty, applyConverter });\n expression.transformer = operand.transformer;\n expression.locale = operand.locale;\n return expression;\n }\n\n const expression = new ValueExpression({ value: resolvePairedValue(operand.value, pairedProperty, applyConverter) });\n expression.transformer = operand.transformer;\n expression.locale = operand.locale;\n return expression;\n }\n\n // #endregion\n}\n\n// #endregion\n\n// #region Template binding\n\n/**\n * Deep-clones a template into a consumer-facing tree, resolving parameter\n * placeholders against the supplied params. Always clones so cached templates\n * can never be mutated by consumers.\n */\nconst bindExpression = (expression: Expression, paramsName: string | null, params: unknown): Expression => {\n\n if (expression instanceof ParamReferenceExpression) {\n const raw = resolveParamPath(paramsName ?? \"params\", expression.paramPath, params);\n const bound = new ValueExpression({ value: resolvePairedValue(raw, expression.pairedProperty, expression.applyConverter) });\n bound.transformer = expression.transformer;\n bound.locale = expression.locale;\n return bound;\n }\n\n if (expression instanceof ValueExpression) {\n const clone = new ValueExpression({ value: expression.value });\n clone.transformer = expression.transformer;\n clone.locale = expression.locale;\n return clone;\n }\n\n if (expression instanceof PropertyExpression) {\n const clone = new PropertyExpression({ property: expression.property });\n clone.transformer = expression.transformer;\n clone.locale = expression.locale;\n return clone;\n }\n\n if (expression instanceof ComparatorExpression) {\n return new ComparatorExpression({\n comparator: expression.comparator,\n negated: expression.negated,\n strict: expression.strict,\n left: expression.left ? bindExpression(expression.left, paramsName, params) : undefined,\n right: expression.right ? bindExpression(expression.right, paramsName, params) : undefined\n });\n }\n\n if (expression instanceof OperatorExpression) {\n return new OperatorExpression({\n operator: expression.operator,\n left: expression.left ? bindExpression(expression.left, paramsName, params) : undefined,\n right: expression.right ? bindExpression(expression.right, paramsName, params) : undefined\n });\n }\n\n return expression;\n}\n\n// #endregion\n\n// #region Function source handling\n\ntype FunctionShape = {\n entityName: string;\n paramsName: string | null;\n body: string;\n}\n\n/**\n * Splits stringified filter source into parameter names and the expression\n * body, unwrapping single-return block bodies.\n */\nconst resolveFunctionShape = (stringifiedFunction: string, hasParams: boolean): FunctionShape => {\n\n const source = stringifiedFunction.trim();\n\n let parameterNames: string;\n let body: string;\n\n // `function (x) { ... }` / `function name(x) { ... }` — what ES5-targeting\n // transpilers rewrite every arrow filter into\n const functionHead = /^function\\b[^(]*\\(/.exec(source);\n\n if (functionHead != null) {\n const parametersEnd = source.indexOf(\")\", functionHead[0].length);\n\n if (parametersEnd === -1) {\n throw new Error(\"Invalid Function\");\n }\n\n parameterNames = source.slice(functionHead[0].length, parametersEnd).trim();\n body = source.slice(parametersEnd + 1).trim();\n } else {\n const arrowIndex = source.indexOf(\"=>\");\n\n if (arrowIndex === -1) {\n throw new Error(\"Invalid Function\");\n }\n\n parameterNames = source.substring(0, arrowIndex).trim();\n body = source.substring(arrowIndex + 2).trim();\n\n // Strip wrapping parens: (entity) or ([x, p])\n if (parameterNames.startsWith(\"(\") && parameterNames.endsWith(\")\")) {\n parameterNames = parameterNames.slice(1, -1).trim();\n }\n }\n\n let entityName: string;\n let paramsName: string | null = null;\n\n if (parameterNames.startsWith(\"[\") && parameterNames.endsWith(\"]\")) {\n const destructured = parameterNames.slice(1, -1).split(\",\").map(w => w.trim());\n entityName = destructured[0];\n\n if (hasParams) {\n paramsName = destructured[1] ?? null;\n }\n } else {\n entityName = parameterNames;\n }\n\n if (entityName == null || entityName.length === 0) {\n throw new Error(\"Invalid Function\");\n }\n\n // Unwrap a single-return block body: { return <expression>; }\n if (body.startsWith(\"{\")) {\n const inner = body.slice(1, body.lastIndexOf(\"}\")).trim();\n\n if (!inner.startsWith(\"return\")) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"block body without a single return statement\"));\n }\n\n body = inner.slice(\"return\".length).trim();\n\n if (body.endsWith(\";\")) {\n body = body.slice(0, -1).trim();\n }\n }\n\n return { entityName, paramsName, body };\n}\n\n// #endregion\n\n// #region Cache\n\ntype ParsedTemplate = {\n template: Expression;\n paramsName: string | null;\n}\n\n// Keyed by schema instance so identical filter source on different schemas can\n// never collide; entries live only as long as the schema does\nconst templateCache = new WeakMap<CompiledSchema<any>, Map<string, ParsedTemplate>>();\nconst MAX_CACHED_TEMPLATES_PER_SCHEMA = 1024;\n\nconst getCachedTemplate = (schema: CompiledSchema<any>, source: string): ParsedTemplate | null => {\n return templateCache.get(schema)?.get(source) ?? null;\n}\n\nconst setCachedTemplate = (schema: CompiledSchema<any>, source: string, entry: ParsedTemplate) => {\n let bySource = templateCache.get(schema);\n\n if (bySource == null) {\n bySource = new Map<string, ParsedTemplate>();\n templateCache.set(schema, bySource);\n }\n\n // Filter source strings come from static code, so this cap should never be\n // hit in practice — it only guards against unbounded dynamic generation.\n // Stryker disable next-line all: the cap is a pure resource bound — every mutation of\n // it (never clear, always clear, off-by-one) parses identically and differs only in\n // memory growth, which no observable boundary can assert.\n if (bySource.size >= MAX_CACHED_TEMPLATES_PER_SCHEMA) {\n bySource.clear();\n }\n\n bySource.set(source, entry);\n}\n\n// #endregion\n\nexport const combineExpressions = (...expressions: Expression[]): Expression => {\n\n if (expressions.length === 0) {\n throw new Error(\"combineExpressions requires at least 1 expression\");\n }\n\n\n if (expressions.length === 1) {\n return expressions[0];\n }\n\n // Start with the first expression\n let result = expressions[0];\n\n // Loop through remaining expressions and combine them\n for (let i = 1; i < expressions.length; i++) {\n result = new OperatorExpression({\n operator: \"&&\",\n left: result,\n right: expressions[i]\n });\n }\n\n return result;\n};\n\n/**\n * Parses an expression SOURCE FRAGMENT against one schema and one root name.\n *\n * `toExpression` starts from a function and works out its own roots. This starts from text, which\n * is what a caller has when it has split a larger predicate apart — `p.rank > 10` lifted out of\n * `([p, m]) => p.rank > 10 && m.won === true`.\n *\n * **A fragment naming anything other than `rootName` returns `NOT_PARSABLE`, and that is the\n * point.** It is how a caller discovers which side of a join a conjunct belongs to: parse it\n * against each side in turn, and exactly one succeeds for a single-side condition. A condition\n * spanning both fails against both, which is the correct answer — it cannot be pushed to either.\n *\n * No params: a fragment carrying a params reference has no bag to resolve it against here, so it\n * fails rather than binding to nothing.\n *\n * Deliberately NOT cached. The cache is keyed by function source, and a fragment is not a function\n * — two different lambdas can contain the same fragment text against different schemas.\n */\nexport const parseFragment = (schema: CompiledSchema<any>, body: string, rootName: string): Expression => {\n try {\n const stream = new TokenStream(tokenize(body));\n const parser = new ExpressionParser(schema, stream, rootName, null, undefined);\n\n return parser.parse();\n } catch {\n // The failure is expected and informative — see above — so it is not logged. A caller that\n // parses one conjunct against two schemas would otherwise warn on every successful split.\n return Expression.NOT_PARSABLE;\n }\n};\n\nexport const toExpression = <T extends any, P extends any>(schema: CompiledSchema<any>, fn: Filter<T> | ParamsFilter<T, P>, params?: P) => {\n const stringifiedFunction = fn.toString();\n\n const warn = (error: unknown) => logger.warn(\"Error parsing expression\", {\n error,\n collectionName: schema.collectionName,\n params,\n selector: stringifiedFunction\n });\n\n const cached = getCachedTemplate(schema, stringifiedFunction);\n\n if (cached != null) {\n // A cached failure — the warning was already logged when it was discovered\n if (Expression.isNotParsable(cached.template)) {\n return Expression.NOT_PARSABLE;\n }\n\n try {\n return bindExpression(cached.template, cached.paramsName, params);\n } catch (error) {\n // Binding failures are param-dependent by nature — never cached\n warn(error);\n return Expression.NOT_PARSABLE;\n }\n }\n\n let paramsName: string | null = null;\n let template: Expression;\n let structurallyDependsOnParams: boolean;\n\n try {\n const shape = resolveFunctionShape(stringifiedFunction, params != null);\n const stream = new TokenStream(tokenize(shape.body));\n const parser = new ExpressionParser(schema, stream, shape.entityName, shape.paramsName, params);\n paramsName = shape.paramsName;\n template = parser.parse();\n structurallyDependsOnParams = parser.structurallyDependsOnParams;\n } catch (error) {\n // Cache the failure so a hot query on an unsupported filter doesn't\n // re-parse and re-warn on every execution. Param-dependent failures are\n // exempt: the same source can succeed with different params.\n if (!(error instanceof ParamDependentParseError)) {\n setCachedTemplate(schema, stringifiedFunction, { template: Expression.NOT_PARSABLE, paramsName: null });\n }\n\n warn(error);\n return Expression.NOT_PARSABLE;\n }\n\n // Templates whose structure was resolved from param values are only\n // valid for this exact params object — parse those fresh every time\n if (!structurallyDependsOnParams) {\n setCachedTemplate(schema, stringifiedFunction, { template, paramsName });\n }\n\n try {\n return bindExpression(template, paramsName, params);\n } catch (error) {\n warn(error);\n return Expression.NOT_PARSABLE;\n }\n}\n","import { QueryOptionExecutionTarget } from \"../plugins\";\nimport { CompiledSchemaCore, PropertyInfo } from \"../schema\";\n\n/**\n * JSON-safe form of a literal. Tagged only where JSON cannot carry the value as it is.\n *\n * See `Expression.toJson`.\n */\nexport type SerializedValue =\n | { k: \"raw\"; v: string | number | boolean | null }\n | { k: \"date\"; v: string }\n | { k: \"undefined\" }\n | { k: \"number\"; v: \"NaN\" | \"Infinity\" | \"-Infinity\" }\n | { k: \"array\"; v: SerializedValue[] };\n\n/** JSON-safe form of an expression tree. See `Expression.toJson`. */\nexport type SerializedExpression =\n | { t: \"empty\" }\n | { t: \"not-parsable\" }\n | { t: \"operator\"; operator: Operator; left?: SerializedExpression; right?: SerializedExpression }\n | {\n t: \"comparator\";\n comparator: Comparator;\n negated: boolean;\n strict: boolean;\n left?: SerializedExpression;\n right?: SerializedExpression;\n }\n | { t: \"property\"; path: string; transformer: Transformer | null; locale: string | null }\n | { t: \"value\"; value: SerializedValue; transformer: Transformer | null; locale: string | null };\n\nconst valueToJson = (value: unknown): SerializedValue => {\n if (value === undefined) {\n return { k: \"undefined\" };\n }\n\n if (value === null) {\n return { k: \"raw\", v: null };\n }\n\n if (value instanceof Date) {\n // ISO rather than epoch millis: it survives a human reading the payload, and an invalid\n // Date has no ISO form — so it is caught here rather than becoming a silent `null`.\n return { k: \"date\", v: value.toISOString() };\n }\n\n if (Array.isArray(value)) {\n return { k: \"array\", v: value.map(valueToJson) };\n }\n\n if (typeof value === \"number\" && Number.isFinite(value) === false) {\n // `JSON.stringify` turns all three of these into `null`, which would compare as a different\n // value entirely rather than failing.\n return { k: \"number\", v: Number.isNaN(value) ? \"NaN\" : value > 0 ? \"Infinity\" : \"-Infinity\" };\n }\n\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n return { k: \"raw\", v: value };\n }\n\n throw new Error(\n `Cannot serialize this filter value: only strings, numbers, booleans, null, undefined, Dates and arrays of those can cross a wire. ` +\n `Received: ${Object.prototype.toString.call(value)}`\n );\n};\n\nconst valueFromJson = (value: SerializedValue): unknown => {\n if (value.k === \"undefined\") {\n return undefined;\n }\n\n if (value.k === \"date\") {\n return new Date(value.v);\n }\n\n if (value.k === \"array\") {\n return value.v.map(valueFromJson);\n }\n\n if (value.k === \"number\") {\n return value.v === \"NaN\" ? Number.NaN : value.v === \"Infinity\" ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;\n }\n\n return value.v;\n};\n\nexport type ParsedExpression = {\n expression: Expression;\n // Will be memory when trying to query on an untracked computed property or on a function\n executionTarget: QueryOptionExecutionTarget;\n}\n\n/**\n * The base class for all expression types.\n */\nexport abstract class Expression {\n /** The type of the expression. */\n abstract readonly type: ExpressionType;\n /** The left-hand side of the expression (if applicable). */\n left?: Expression;\n /** The right-hand side of the expression (if applicable). */\n right?: Expression;\n\n constructor(left?: Expression, right?: Expression) {\n this.left = left;\n this.right = right;\n }\n\n static get EMPTY() {\n return new EmptyExpression();\n }\n\n static get NOT_PARSABLE() {\n return new NotParsableExpression();\n }\n\n static isEmpty(expression: Expression) {\n return expression.type === \"empty\" || expression instanceof EmptyExpression;\n }\n\n static isNotParsable(expression: Expression) {\n return expression.type === \"not-parsable\" || expression instanceof NotParsableExpression;\n }\n\n /**\n * Turns a tree into plain JSON, so a whole query can cross a wire.\n *\n * On the class rather than beside it, because this is the type's own REPRESENTATION — there is one\n * right answer and it belongs with the thing being represented, next to `EMPTY` and `isEmpty`.\n * Rendering a tree into some other language (`toSql`, `toMql`, `evaluate`) is a different kind of\n * thing: there are many, each belongs to its consumer, and none of them is canonical.\n *\n * ## Why it is this small\n *\n * Of the six node types a bound tree can contain, exactly one holds anything JSON cannot carry:\n * `PropertyExpression`, whose live `PropertyInfo` has functions, a parent chain and caches. It\n * reduces to a property PATH — `PropertyInfo.id` IS the dotted path, and `getProperty` is keyed by\n * exactly that — so rebinding is one lookup.\n *\n * `ParamReferenceExpression` never appears: it is a parse-time placeholder that binding replaces\n * with a plain `ValueExpression` holding the resolved value. A serialized tree is always already\n * bound, so there is no params object to send alongside it.\n *\n * Switches on `type` rather than using the `isXExpression` guards, which live in `../assertions`\n * and import this module — the guards test the same discriminant, so nothing is lost.\n */\n static toJson(expression: Expression): SerializedExpression {\n\n if (expression.type === \"operator\") {\n const operator = expression as OperatorExpression;\n\n return {\n t: \"operator\",\n operator: operator.operator,\n ...(operator.left != null && { left: Expression.toJson(operator.left) }),\n ...(operator.right != null && { right: Expression.toJson(operator.right) }),\n };\n }\n\n if (expression.type === \"comparator\") {\n const comparator = expression as ComparatorExpression;\n\n return {\n t: \"comparator\",\n comparator: comparator.comparator,\n negated: comparator.negated,\n strict: comparator.strict,\n ...(comparator.left != null && { left: Expression.toJson(comparator.left) }),\n ...(comparator.right != null && { right: Expression.toJson(comparator.right) }),\n };\n }\n\n if (expression.type === \"property\") {\n const property = expression as PropertyExpression;\n\n return {\n t: \"property\",\n // The dotted path, which is exactly the key `getProperty` is looking up\n path: property.property.id,\n transformer: property.transformer,\n locale: property.locale,\n };\n }\n\n if (expression.type === \"value\") {\n const value = expression as ValueExpression;\n\n return {\n t: \"value\",\n value: valueToJson(value.value),\n transformer: value.transformer,\n locale: value.locale,\n };\n }\n\n return expression.type === \"empty\" ? { t: \"empty\" } : { t: \"not-parsable\" };\n }\n\n /**\n * Rebuilds a tree from JSON, rebinding every property against `schema`.\n *\n * The schema is SUPPLIED rather than read out of the payload. A filter always belongs to a known\n * collection, and the RECEIVER's schema is the authority on what its properties are — taking an\n * id from the payload would mean rebinding against a schema the sender chose, which is backwards\n * for anything crossing a trust boundary.\n *\n * @throws when a property path is not declared by `schema`. Not `NOT_PARSABLE`: on a receiver, a\n * filter that silently stops filtering returns rows the requester excluded, which is the one\n * failure here worse than an error.\n */\n static fromJson(json: SerializedExpression, schema: CompiledSchemaCore<any>): Expression {\n\n const child = (node: SerializedExpression | undefined) => node == null ? undefined : Expression.fromJson(node, schema);\n\n if (json.t === \"operator\") {\n return new OperatorExpression({ operator: json.operator, left: child(json.left), right: child(json.right) });\n }\n\n if (json.t === \"comparator\") {\n return new ComparatorExpression({\n comparator: json.comparator,\n negated: json.negated,\n strict: json.strict,\n left: child(json.left),\n right: child(json.right),\n });\n }\n\n if (json.t === \"property\") {\n const property = schema.getProperty(json.path);\n\n if (property == null) {\n throw new Error(\n `Cannot deserialize a filter: this schema does not declare the property it names. ` +\n `Property: ${json.path}, Collection: ${schema.collectionName}. ` +\n `The two sides disagree about the shape of the data, so the filter cannot be applied.`\n );\n }\n\n const rebuilt = new PropertyExpression({ property });\n rebuilt.transformer = json.transformer;\n rebuilt.locale = json.locale;\n\n return rebuilt;\n }\n\n if (json.t === \"value\") {\n const rebuilt = new ValueExpression({ value: valueFromJson(json.value) });\n rebuilt.transformer = json.transformer;\n rebuilt.locale = json.locale;\n\n return rebuilt;\n }\n\n return json.t === \"empty\" ? Expression.EMPTY : Expression.NOT_PARSABLE;\n }\n}\n\nexport class EmptyExpression extends Expression {\n readonly type = \"empty\" as const;\n}\n\nexport class NotParsableExpression extends Expression {\n readonly type = \"not-parsable\" as const;\n}\n\n/**\n * A class representing a comparison operation (e.g., equals, greater-than).\n */\nexport class ComparatorExpression extends Expression {\n /** The type of the expression (always 'comparator'). */\n readonly type = \"comparator\" as const;\n /** The comparator operation (e.g., equals, greater-than). */\n comparator: Comparator;\n /** Whether the comparison is negated (e.g., not equals). */\n negated: boolean;\n /** Whether the comparison is strict (type-sensitive). */\n strict: boolean;\n\n constructor(\n options: {\n comparator: Comparator,\n negated: boolean,\n strict: boolean,\n left?: Expression,\n right?: Expression\n }\n ) {\n super(options.left, options.right);\n this.comparator = options.comparator;\n this.negated = options.negated;\n this.strict = options.strict;\n }\n}\n\n/**\n * A class representing a logical operator (e.g., &&, ||).\n */\nexport class OperatorExpression extends Expression {\n /** The type of the expression (always 'operator'). */\n readonly type = \"operator\" as const;\n /** The logical operator. */\n operator: Operator;\n\n constructor(options: { operator: Operator, left?: Expression, right?: Expression }) {\n super(options.left, options.right);\n this.operator = options.operator;\n }\n}\n\n/**\n * A class representing a property path.\n */\nexport class PropertyExpression extends Expression {\n /** The type of the expression (always 'property'). */\n readonly type = \"property\" as const;\n /** The property info for the path. */\n property: PropertyInfo<any>;\n transformer: Transformer | null = null;\n locale: string | null = null;\n\n constructor(options: { property: PropertyInfo<any> }) {\n super();\n this.property = options.property;\n }\n}\n\n/**\n * A class representing a literal value.\n */\nexport class ValueExpression extends Expression {\n /** The type of the expression (always 'value'). */\n readonly type = \"value\" as const;\n /** The literal value. */\n value: unknown;\n\n transformer: Transformer | null = null;\n locale: string | null = null;\n\n constructor(options: {\n value: unknown\n }) {\n super();\n this.value = options.value;\n }\n}\n\n\n/**\n * The set of possible expression types.\n */\nexport type ExpressionType = \"operator\" | \"comparator\" | \"property\" | \"value\" | \"empty\" | \"not-parsable\";\n\n/**\n * Supported value transformations that can be applied to values.\n * `length` reads the length of a string or array property.\n */\nexport type Transformer = \"to-lower-case\" | \"to-upper-case\" | \"length\";\n\n/**\n * Supported comparator operations for expressions.\n */\nexport type Comparator =\n | \"equals\"\n | \"starts-with\"\n | \"includes\"\n | \"ends-with\"\n | \"greater-than\"\n | \"greater-than-equals\"\n | \"less-than\"\n | \"less-than-equals\";\n\n/**\n * Supported logical operators for expressions.\n */\nexport type Operator = \"&&\" | \"||\";\n\n/**\n * A function that filters a value of type T and returns a boolean.\n */\nexport type Filter<T extends any> = (value: T) => boolean;\n\n/**\n * A function that filters a value of type T with additional parameters P.\n */\nexport type ParamsFilter<T extends any, P> = (payload: [T, P]) => boolean;\n\n/**\n * A filter that can be either a simple filter or a parameterized filter.\n */\nexport type CompositeFilter<T extends any, P = never> = Filter<T> | ParamsFilter<T, P>;\n\n/**\n * An object that can be filtered using a composite filter and optional parameters.\n */\nexport type Filterable<T extends any, P = any> = {\n /** The filter function. */\n filter: CompositeFilter<T, P>;\n /** Optional parameters for the filter. */\n params?: P;\n};","import { PropertyInfo } from \"../schema\";\nimport { Expression, PropertyExpression } from \"./types\";\n\n/**\n * Extracts all properties referenced in an expression\n * @param expression The expression to analyze\n * @returns Array of PropertyInfo objects referenced in the expression\n */\nexport function getProperties(expression: Expression): PropertyInfo<any>[] {\n const properties: PropertyInfo<any>[] = [];\n\n function traverse(expr: Expression) {\n // If this is a property expression, add it to our collection\n if (expr.type === \"property\") {\n properties.push((expr as PropertyExpression).property);\n }\n\n // Traverse left and right expressions if they exist\n if (expr.left) {\n traverse(expr.left);\n }\n if (expr.right) {\n traverse(expr.right);\n }\n }\n\n traverse(expression);\n return properties;\n}\n\nexport function forEach(expression: Expression, callback: (expression: Expression) => boolean) {\n function traverse(expr: Expression): boolean {\n // Call the callback for this expression\n // If callback returns false, stop traversing\n if (!callback(expr)) {\n return false;\n }\n\n // Traverse left and right expressions if they exist\n if (expr.left) {\n if (!traverse(expr.left)) {\n return false;\n }\n }\n if (expr.right) {\n if (!traverse(expr.right)) {\n return false;\n }\n }\n\n return true;\n }\n\n traverse(expression);\n}","import type { SchemaDefinition } from \"./SchemaDefinition\";\nimport type { SchemaBase } from \"./property/base/SchemaBase\";\nimport type { SchemaArray } from \"./property/types/SchemaArray\";\nimport type { SchemaVector } from \"./property/types/SchemaVector\";\nimport type { SchemaObject } from \"./property/types/SchemaObject\";\nimport type { PropertyInfo } from \"./PropertyInfo\";\nimport type { DeepPartial } from \"../types\";\nimport type { SchemaFunction } from \"./table\";\nimport type { SchemaOptional, SchemaTag } from \"./property/modifiers\";\nimport type { Branded } from \"../utilities/types\";\nimport type { SchemaSubscriptionOptions } from \"./communication/broadcast\";\n\nexport type DefaultValue<T, I = never> = T | ((injected: I) => T);\nexport type FunctionBody<TEntity, TResult> = (entity: TEntity, collectionName: CollectionName) => TResult;\nexport type IdType = string | number;\nexport type ForeignKey<T extends {}> = { \n schema: CompiledSchema<T>, \n property: PropertyInfo<T> \n};\n\nexport enum SchemaTypes {\n Array = \"Array\",\n Boolean = \"Boolean\",\n Date = \"Date\",\n Number = \"Number\",\n Object = \"Object\",\n String = \"String\",\n Definition = \"Definition\",\n Function = \"Function\",\n Computed = \"Computed\",\n /**\n * Content in, reference out. The only type whose write shape differs from its stored\n * shape, and a leaf on purpose — see `SchemaFile`.\n */\n File = \"File\",\n /**\n * A fixed-length list of numbers, carrying its dimension count — see `SchemaVector`.\n *\n * Value-shaped exactly like `s.array(s.number())`, which is why every array codegen\n * handler accepts it. It is a distinct type only so a backend can recognise it and store\n * it natively; nothing else needs to tell the two apart.\n */\n Vector = \"Vector\"\n}\n\nexport type ArrayShape = string | number | Date | {};\n\n\n/**\n * What a file property gives back: where the bytes are and what they are.\n *\n * Declared in core so `InferType` can name it. Core never reads or writes the bytes — it only\n * carries this shape — and `@routier/blob-plugin` is what puts one here.\n */\nexport type FileReferenceValue = {\n /** Where the bytes live, content-addressed by the blob plugin. */\n key: string;\n /** Byte length. */\n size: number;\n /** Media type as supplied at upload. */\n contentType: string;\n /** SHA-256 of the bytes, lowercase hex. */\n checksum: string;\n /** The name to show a user. Not part of the key. */\n fileName: string;\n};\n\n/**\n * What a file property ACCEPTS: content, or a reference you already have.\n *\n * `Blob` covers `File`, which is what an `<input type=\"file\">` yields. A reference is accepted\n * too, so re-saving an entity that was read from the database does not have to re-upload it.\n */\nexport type FileContentValue =\n | FileReferenceValue\n | Uint8Array\n | ArrayBuffer\n | Blob\n | string;\n\n/**\n * What a vector property holds, in and out: a plain list of numbers.\n *\n * Named rather than written inline because the inference rules have to recognise it after a\n * modifier has erased which class produced it — the same problem `FileReferenceValue` solves\n * above, and for the same reason.\n */\nexport type VectorValue = number[];\n\n/**\n * What `s.string({ ... })` accepts.\n *\n * Declarations only. Core stores them and never acts on them; a backend that can use one does.\n */\nexport type StringOptions = {\n /**\n * The longest value the property is declared to hold.\n *\n * MySQL uses it for `VARCHAR(maxLength)`; without it every string column is\n * `VARCHAR(255)`, which silently truncates longer values. Other backends ignore it. Core\n * never validates a value against it — see `SchemaBase.maxLength`.\n */\n maxLength?: number;\n};\n\nexport type ExpandedProperty = ExpandedChildProperty & {\n assignmentPath: string;\n selectorPath: string;\n properties: Map<string, ExpandedChildProperty>;\n childDegree: number;\n};\n\nexport type ExpandedChildProperty = {\n propertyName: string;\n type: SchemaTypes;\n isNullableOrOptional: boolean;\n isReadonly: boolean;\n isIdentity: boolean;\n isUnmapped: boolean;\n}\n\nexport enum HashType {\n Ids = \"Ids\",\n Object = \"Object\"\n}\n\nexport type HashFunction<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>, type: HashType.Object): string;\n (entity: InferType<TEntity>, type: HashType.Ids): string;\n}\n\nexport type GetHashTypeFunction<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): HashType.Object;\n (entity: InferType<TEntity>): HashType.Ids;\n}\n\nexport type ChangeTrackingType = \"proxy\" | \"diff\" | \"immutable\";\n\nexport type IndexType = \"single\" | \"compound\" | \"unique\" | \"primary-key\"\nexport type Index = {\n properties: PropertyInfo<any>[],\n type: IndexType;\n name: string;\n}\n\n/**\n * Represents changes to subscriptions, categorizing them by modifications to\n * entities (additions, updates, removals) or query-driven removals.\n * @template T - The type of the entities in the subscription.\n */\nexport type SubscriptionChanges<T extends {}> = {\n /**\n * Entities that have been added to the subscription.\n */\n adds: InferType<T>[];\n /**\n * Entities that have been updated within the subscription.\n */\n updates: InferType<T>[];\n /**\n * Entities that have been removed from the subscription.\n */\n removals: InferType<T>[];\n /**\n * Entities that have been added/updated/removed from the subscription and it is unknown \n * if the entities have been added/updated/removed.\n */\n unknown: InferType<T>[];\n}\n\nexport interface ISchemaSubscription<T extends {}> extends Disposable {\n send(changes: SubscriptionChanges<T>): void;\n onMessage(callback: (changes: SubscriptionChanges<T>) => void): void;\n}\n\nexport type Enrich<TEntity extends {}> = {\n (entity: InferType<TEntity>, changeTrackingType: ChangeTrackingType): InferType<TEntity>;\n (entity: InferCreateType<TEntity>, changeTrackingType: ChangeTrackingType): InferCreateType<TEntity>;\n}\nexport type Prepare<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): InferCreateType<TEntity>;\n (entity: InferType<TEntity>): InferType<TEntity>;\n}\nexport type Preprocess<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): InferType<TEntity>;\n (entity: InferType<TEntity>): InferType<TEntity>;\n}\n\nexport type SetProperties<TEntity extends {}> = (destination: DeepPartial<InferType<TEntity> | InferCreateType<TEntity>>, source: DeepPartial<InferType<TEntity> | InferCreateType<TEntity>>) => void;\n\nexport type CompiledSchemaCore<TEntity extends {}> = Omit<CompiledSchema<TEntity>, \"createSubscription\">;\n\nexport type CompiledSchemaWithMetadata<TEntity extends {}, TMetadata> = {\n readonly metadata: TMetadata;\n} & CompiledSchema<TEntity>;\n\n/**\n * Represents a fully compiled schema with all utilities and metadata for an entity type.\n */\nexport type CompiledSchema<TEntity extends {}> = {\n\n deserializePartial: (item: Record<string, unknown>, properties: PropertyInfo<TEntity>[]) => DeepPartial<InferType<TEntity>>;\n\n createSubscription: (abortSignal?: AbortSignal, scope?: string, options?: SchemaSubscriptionOptions) => ISchemaSubscription<TEntity>;\n /** Returns the property info for a given id (full path) */\n getProperty: (id: string) => PropertyInfo<TEntity>;\n /** Returns the ID of the given entity. */\n getId: (entity: InferType<TEntity>) => IdType;\n /** Returns a deep clone of the given entity. */\n clone: (entity: InferType<TEntity>) => InferType<TEntity>;\n /**\n * Returns a deep clone of a record that is still in the STORAGE shape — renamed properties\n * under their `from` names rather than their in-memory names.\n *\n * `clone` reads in-memory names, so it returns `undefined` for every renamed property of a\n * stored record. Use this when copying rows a store holds before they have been deserialized.\n * Generated on first call; schemas that are never cloned in storage shape never build it.\n */\n cloneStorage: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Removes unmapped or extraneous properties from the entity. */\n strip: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Prepares a new entity for creation, applying defaults and transformations. */\n prepare: Prepare<TEntity>;\n /** Merges the source entity into the destination entity. */\n merge: (destination: InferType<TEntity> | InferCreateType<TEntity>, source: InferType<TEntity>) => InferType<TEntity>;\n /** Indicates if the schema has identity properties. */\n hasIdentities: boolean;\n /** List of properties that are identity keys. */\n idProperties: PropertyInfo<TEntity>[];\n /** All property metadata for the schema. */\n properties: PropertyInfo<TEntity>[],\n /** The hash type used for this schema. */\n hashType: HashType;\n /** Computes a hash for the given entity. */\n hash: HashFunction<TEntity>;\n /** Returns the hash type for the given entity. */\n getHashType: GetHashTypeFunction<TEntity>;\n /** Compares two entities for equality. */\n compare: (a: InferType<TEntity>, fromDb: InferType<TEntity>) => boolean;\n /** Deserializes an entity from storage format. */\n deserialize: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Sets 1 or many properties from the source object onto the destination object with change tracking. */\n set: SetProperties<TEntity>;\n /** Combines serializing and preparing an entity for saving. */\n preprocess: Preprocess<TEntity>;\n /** Combines deserializing and enriching an entity for selection. */\n postprocess: Enrich<TEntity>;\n\n /** Serializes an entity to storage format. */\n serialize: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Unique id for the schema. */\n id: SchemaId,\n /** The name of the collection for this schema. */\n collectionName: CollectionName;\n /** Returns all IDs for the given entity (usually a single-element tuple). */\n getIds: (entity: InferType<TEntity>) => [IdType];\n /** Enriches the entity with change tracking or other metadata. */\n enrich: Enrich<TEntity>;\n /** Indicates if the schema has identity keys. */\n hasIdentityKeys: boolean;\n /** Returns a deeply frozen (immutable) version of the entity. */\n freeze: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Enables change tracking on the entity. */\n enableChangeTracking: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** The schema definition object. */\n definition: SchemaDefinition<TEntity>;\n /** Returns all indexes defined for this schema. */\n getIndexes: () => Index[];\n /** Compares two entities for Id equality. */\n compareIds: (a: InferType<TEntity>, b: InferType<TEntity>) => boolean;\n}\n\nexport type PropertySerializer<T extends any> = (value: T) => string | number;\nexport type PropertyDeserializer<T extends any> = (value: string | number) => T;\n\n/**\n * A two-way transform between the application value and the stored value.\n *\n * Both directions may be async. Held as a live reference rather than stringified, so a\n * closure works and `injected` is a convenience rather than the only way in.\n */\nexport type PropertyTransform<T extends any> = {\n /**\n * Application value to stored value. Runs before the plugin sees it. May be async.\n *\n * `entity` is there for the one-way case: a transform with no `from` derives a value\n * rather than converting one, which is what `computed` does.\n */\n to: (value: T, entity: Record<string, unknown>) => unknown | Promise<unknown>;\n\n /**\n * Stored value back to application value. Runs after the plugin returns it.\n *\n * Optional. Leave it out and the transform is one-way: the stored value is the value.\n */\n from?: (value: unknown) => T | Promise<T>;\n\n /**\n * What the column becomes, when the stored form is not the property's own type.\n *\n * Defaults to the property's own type, so nothing changes unless you say it does. A\n * library that always produces text — a cipher, a compressor — sets this once, and the\n * caller who uses that library never writes it.\n */\n stores?: SchemaTypes;\n\n /**\n * Whether a filter on this property can still run in the database.\n *\n * Defaults to `none`, which rejects the filter rather than returning wrong rows. Set\n * `equality` only when `to` is deterministic.\n */\n comparable?: 'equality' | 'none';\n};\n\nexport type SchemaId = Branded<number, \"SchemaId\">;\nexport type CollectionName = Branded<string, \"CollectionName\">;\n\nexport type SchemaModifiers = \"default\" | \"deserialize\" |\n \"identity\" | \"key\" |\n \"nullable\" | \"optional\" |\n \"readonly\" | \"serialize\" |\n \"unmapped\" | \"computed\" |\n \"distinct\" | \"searchable\";\n\n/**\n * What a tagged property infers to.\n *\n * `tag()` is metadata and must not change a type, but `SchemaTag<T>` carries the same `T` as\n * whatever it wrapped without carrying which class that was. For a string `T` is already\n * `string`; for an object `T` is the map of child schemas, which only the `SchemaObject`\n * branch below knows how to unwrap. Falling through to the generic `SchemaBase` branch\n * therefore handed the raw map back, so `s.object({ key: s.string() }).tag('x')` typed\n * `key` as `SchemaString` instead of `string` — everything ran, and only the types lied.\n *\n * An array is distinguishable because `SchemaArray`'s parameter is the ELEMENT schema, so a\n * tagged array arrives here as a `SchemaBase` rather than a plain map.\n */\ntype InferTagged<C> = ResolveWrapped<C>;\n\n/**\n * What a wrapping modifier's inner type resolves to.\n *\n * `SchemaOptional`, `SchemaNullable` and `SchemaTag` all carry the same `C` as whatever they\n * wrapped, without carrying which class that was, so each has to work out what it is holding.\n * Three shapes are possible:\n *\n * - an already-resolved value (`string` from `s.string()`, a file reference from `s.file()`)\n * - an ELEMENT schema, which is what `SchemaArray` parameterises on\n * - a map of child schemas, which is what `SchemaObject` parameterises on\n *\n * Getting this wrong is silent. The map branch applied to an already-resolved object walks\n * its keys and infers `never` for each, so `s.file().optional()` typed as\n * `{ key: never, size: never, ... }` — which no value can satisfy and no test would catch at\n * runtime.\n */\ntype ResolveWrapped<C> =\n C extends string | number | boolean | Date | FileReferenceValue ? C :\n C extends VectorValue ? C :\n C extends SchemaBase<any, any> ? InferPrimitive<C>[] :\n { [K in keyof C]: InferPrimitive<C[K]> };\n\ntype InferPrimitive<T> =\n T extends SchemaOptional<infer C, infer __> ? ResolveWrapped<C> :\n T extends SchemaTag<infer C, infer __> ? InferTagged<C> :\n // Before the generic `SchemaBase` branch below, which would see `X = number[]` and map\n // the element through `InferPrimitive<number>` — no branch matches a bare `number`, so a\n // vector would type as `never[]`: assignable from nothing, and invisible at runtime.\n T extends SchemaVector<infer __, infer ___> ? VectorValue :\n T extends SchemaArray<infer Y, infer __> ? InferPrimitive<Y>[]\n : T extends SchemaObject<infer Obj, infer _> ?\n { [K in keyof Obj]: InferPrimitive<Obj[K]> } : // Process nested objects\n T extends SchemaFunction<infer F, infer __> ? F : T extends SchemaBase<infer X, infer _> ?\n X extends Array<infer A> ? InferPrimitive<A>[] : X : // Extract the primitive type\n never;\n\nexport type InferType<T> = T extends CompiledSchema<infer R> ? InferCompiledSchema<R> : T extends {} ? InferCompiledSchema<T> : T;\nexport type InferCreateType<T> = T extends CompiledSchema<infer R> ? InferCompiledCreateSchema<R> : T extends {} ? InferCompiledCreateSchema<T> : unknown;\nexport type InferMappedType<T> = T extends SchemaBase<infer K, infer __> ? InferType<K> : InferCompiledSchema<T>;\nexport type InferRoot<T> = T extends CompiledSchema<infer R> ? R : never;\n\ntype HasModifier<T, K extends keyof T, M extends SchemaModifiers> =\n T[K] extends SchemaBase<any, infer Mods> ?\n M extends Mods ? true : false :\n false;\n\ntype IsPlainProperty<T, K extends keyof T> =\n [\n HasModifier<T, K, \"readonly\">,\n HasModifier<T, K, \"optional\">,\n HasModifier<T, K, \"nullable\">\n ] extends [\n false,\n false,\n false\n ] ? true : false;\n\ntype IsCreateExcluded<T, K extends keyof T> =\n [\n HasModifier<T, K, \"identity\">,\n HasModifier<T, K, \"computed\">,\n HasModifier<T, K, \"unmapped\">\n ] extends [\n false,\n false,\n false\n ] ? false : true;\n\ntype IsCreateOptional<T, K extends keyof T> =\n [\n HasModifier<T, K, \"optional\">,\n HasModifier<T, K, \"default\">\n ] extends [\n false,\n false\n ] ? false : true;\n\ntype IsCreateNullable<T, K extends keyof T> =\n HasModifier<T, K, \"nullable\"> extends true ? true : false;\n\n/**\n * What a property ACCEPTS on the way in, which is not always what it gives back.\n *\n * Only a file differs today: you assign content and read a reference. Matching on the read\n * type rather than on `SchemaFile` itself is deliberate — it keeps working through every\n * modifier. `s.file().optional()` is a `SchemaOptional`, `s.file().tag('x')` is a\n * `SchemaTag`, and neither carries the original class, so a check against the class alone\n * would silently stop accepting content the moment anyone added a modifier.\n *\n * Assignability is required in BOTH directions, and the tuple wrappers are load-bearing.\n * One-way `extends` matches `never` — which is assignable to everything — so a generic\n * property over `Record<string, unknown>` resolved to file content and broke the Dexie\n * plugin's types. It also matched any object that merely happens to have these five fields\n * plus more. Mutual assignability admits the reference shape and nothing else, and the\n * tuples stop the conditional distributing over a union.\n */\ntype InferWritePrimitive<T> =\n [InferPrimitive<T>] extends [FileReferenceValue]\n ? [FileReferenceValue] extends [InferPrimitive<T>] ? FileContentValue : InferPrimitive<T>\n : InferPrimitive<T>;\n\ntype InferCreateProperty<T, K extends keyof T> =\n IsCreateNullable<T, K> extends true ? null | InferWritePrimitive<T[K]> : InferWritePrimitive<T[K]>;\n\ntype InferCompiledSchema<T> = CoalesceEmpty<{\n [K in keyof T as IsPlainProperty<T, K> extends true ? K : never]: InferPrimitive<T[K]>\n}, {\n readonly [K in keyof T as HasModifier<T, K, \"readonly\"> extends true ? K : never]: InferPrimitive<T[K]>\n }, {\n [K in keyof T as HasModifier<T, K, \"optional\"> extends true ? K : never]?: InferPrimitive<T[K]>\n }, {\n [K in keyof T as HasModifier<T, K, \"nullable\"> extends true ? K : never]: null | InferPrimitive<T[K]>\n}>;\n\ntype InferCompiledCreateSchema<T> = {\n [K in keyof T as IsCreateExcluded<T, K> extends true ? never\n : IsCreateOptional<T, K> extends true ? K : never]?: InferCreateProperty<T, K>\n} & {\n [K in keyof T as IsCreateExcluded<T, K> extends true ? never\n : IsCreateOptional<T, K> extends true ? never : K]: InferCreateProperty<T, K>\n};\n\ntype IsEmptyObject<T> = keyof T extends never ? true : false;\ntype CoalesceEmpty<T1 extends {}, T2 extends {}, T3 extends {}, T4 extends {}> = (IsEmptyObject<T1> extends true ? {} : T1) & (IsEmptyObject<T2> extends true ? {} : T2) & (IsEmptyObject<T3> extends true ? {} : T3) & (IsEmptyObject<T4> extends true ? {} : T4);\n","/**\n * Levelled logging, resolved once.\n *\n * Three things about the previous implementation drove this shape:\n *\n * - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever\n * compared against `true`, so setting it to `false` did nothing — while\n * `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.\n * A documented switch that silently does nothing is worse than no switch.\n * - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always\n * sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through\n * a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also\n * capture console output by snapshotting a stack trace per call, so the cost is far above what\n * writing to a terminal would suggest — and the output buries whatever the failure was.\n * - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug\n * was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.\n *\n * Levels are compared numerically against a value cached at module load. Measured against a\n * no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.\n * Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why\n * this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —\n * a lazy API would recover 0.3% of an enabled call's cost and would have to change every call\n * site to do it.\n */\n\n/** Ordered from most severe to most verbose. `silent` discards everything. */\nexport const LOG_LEVELS = ['silent', 'error', 'warn', 'info', 'debug'] as const;\n\nexport type LogLevel = (typeof LOG_LEVELS)[number];\n\n/** Numeric rank, so a gate is one integer comparison. */\nconst RANK: Record<LogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n};\n\nconst isLogLevel = (value: unknown): value is LogLevel =>\n typeof value === 'string' && (LOG_LEVELS as readonly string[]).includes(value);\n\n/**\n * Resolves the configured level, in precedence order.\n *\n * Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an\n * environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything\n * unrecognised is ignored rather than treated as an error — a typo'd level should not take down\n * an application, and `silent` is the safe direction to fall back to.\n */\nconst resolveLevel = (): LogLevel => {\n if (typeof globalThis !== 'undefined') {\n const g = globalThis as { __ROUTIER_LOG_LEVEL__?: unknown; __ROUTIER_DEBUG__?: unknown };\n\n if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {\n return g.__ROUTIER_LOG_LEVEL__;\n }\n\n // Both directions honoured. `=== false` used to fall through to the NODE_ENV checks\n // below and re-enable the logging it was asked to suppress.\n if (g.__ROUTIER_DEBUG__ === true) return 'debug';\n if (g.__ROUTIER_DEBUG__ === false) return 'silent';\n }\n\n // There is deliberately no `import.meta.env` branch, although the documentation used to\n // promise one. It could never work: this package is bundled with rspack, which replaces\n // `import.meta` with `undefined`, so the check would read the *library's* build-time\n // environment rather than the application's — and referencing `import.meta` at all is a parse\n // error under a CommonJS build target, which is how the test suite loads this file. Vite and\n // similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own\n // `import.meta.env`, which is what the docs now describe.\n if (typeof process !== 'undefined' && process.env != null) {\n if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {\n return process.env.ROUTIER_LOG_LEVEL as LogLevel;\n }\n\n const debug = process.env.DEBUG;\n if (debug === 'routier' || debug === '*') return 'debug';\n\n const env = process.env.NODE_ENV?.toLowerCase();\n\n // `test` is deliberately absent. It used to be here, which meant no test suite anywhere\n // could run Routier quietly. Opt in with DEBUG=routier or ROUTIER_LOG_LEVEL when a test\n // needs the output.\n if (env === 'dev' || env === 'development') return 'debug';\n }\n\n return 'silent';\n};\n\nlet level: LogLevel = resolveLevel();\nlet rank = RANK[level];\n\n/**\n * Overrides the level for the rest of the process.\n *\n * The configuration above is read once, at import, which is what makes the gate cheap — but it\n * also means an application that decides its verbosity after startup, or a test that wants to\n * assert on output, has no way in. This is that way in.\n */\nexport const setLogLevel = (next: LogLevel): void => {\n if (isLogLevel(next) === false) {\n throw new Error(`Unknown log level \"${next}\". Expected one of: ${LOG_LEVELS.join(', ')}`);\n }\n\n level = next;\n rank = RANK[next];\n};\n\nexport const getLogLevel = (): LogLevel => level;\n\n/** Re-reads the environment. For tests that change it after this module was imported. */\nexport const resetLogLevel = (): void => {\n level = resolveLevel();\n rank = RANK[level];\n};\n\n/**\n * Whether a message at this level would be emitted.\n *\n * For the rare call site whose *arguments* are expensive to build — a serialization, a deep\n * clone, a join over a large collection. An ordinary payload object is not worth guarding; see\n * the measurement in the header.\n */\nexport const isLogLevelEnabled = (at: LogLevel): boolean => rank >= RANK[at];\n\ntype ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'debug' | 'table';\n\nconst emit = (at: LogLevel, method: ConsoleMethod, args: unknown[]) => {\n if (rank < RANK[at]) {\n return;\n }\n\n // Resolved at call time rather than captured once: test harnesses and browser devtools both\n // replace console methods after modules have loaded, and a captured reference would keep\n // writing past the replacement.\n (console[method] as (...a: unknown[]) => void)(...args);\n};\n\nexport const logger = {\n /** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */\n log: (...args: unknown[]): void => emit('info', 'log', args),\n info: (...args: unknown[]): void => emit('info', 'info', args),\n warn: (...args: unknown[]): void => emit('warn', 'warn', args),\n error: (...args: unknown[]): void => emit('error', 'error', args),\n debug: (...args: unknown[]): void => emit('debug', 'debug', args),\n /** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */\n table: (...args: unknown[]): void => emit('debug', 'table', args),\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './evaluate';\nexport * from './parser';\nexport * from './types';\nexport * from './utils';\nexport * from './constants';"],"names":["EXPRESSION_TYPES","isDate","assertDate","data","TypeError","assertIsNotNull","message","assertIsArray","Array","assertString","assertInstanceOf","value","Instance","assertIsNumber","isObjectWithType","isExpression","isOperatorExpression","isComparatorExpression","isPropertyExpression","isValueExpression","isEmptyExpression","isNotParsableExpression","UNRESOLVED","Symbol","applyTransformer","transformer","operand","expression","row","equals","left","right","strict","Date","compare","comparator","asComparable","a","b","comparable","undefined","evaluateComparator","item","evaluate","result","toPredicate","toStrictPredicate","Error","logger","SchemaTypes","Expression","OperatorExpression","ComparatorExpression","ValueExpression","PropertyExpression","ERROR_MESSAGES","path","params","JSON","parseUnknown","ParamDependentParseError","converters","v","Boolean","Number","String","MULTI_CHARACTER_PUNCTUATION","SINGLE_CHARACTER_PUNCTUATION","Set","STRING_ESCAPES","isIdentifierStart","char","isIdentifierPart","isDigit","isHexDigit","decodeCodeEscape","source","backslashIndex","kind","start","end","parseInt","length","digits","d","tokenize","tokens","i","quote","escaped","decoded","nextChar","radixPrefix","signLength","multi","w","TokenStream","offset","token","COMPARATOR_METHODS","TRANSFORM_METHODS","COMPARISON_OPERATORS","SWAPPED_COMPARATORS","ParamReferenceExpression","options","resolveParamPath","paramsName","name","resolvePairedValue","pairedProperty","applyConverter","ExpressionParser","schema","stream","entityName","trailing","operatorToken","numberToken","elements","element","array","method","argument","root","locale","segment","paramPath","resolved","pathString","property","parentPath","parent","operator","comparedToFalse","swapped","target","isStringMatch","bindExpression","raw","bound","clone","resolveFunctionShape","stringifiedFunction","hasParams","parameterNames","body","functionHead","parametersEnd","arrowIndex","destructured","inner","templateCache","WeakMap","MAX_CACHED_TEMPLATES_PER_SCHEMA","getCachedTemplate","setCachedTemplate","entry","bySource","Map","combineExpressions","expressions","parseFragment","rootName","parser","toExpression","fn","warn","error","cached","template","structurallyDependsOnParams","shape","valueToJson","Object","valueFromJson","EmptyExpression","NotParsableExpression","json","child","node","rebuilt","getProperties","properties","traverse","expr","forEach","callback","HashType","LOG_LEVELS","RANK","isLogLevel","resolveLevel","globalThis","g","process","debug","env","level","rank","setLogLevel","next","getLogLevel","resetLogLevel","isLogLevelEnabled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J;IAEA,4FAA4F;IAC5F,yFAAyF;IACzF,gCAAgC;IAC/BG,OAAO,CAACtF,OAAO,IAAkCqF;AACtD;AAEO,MAAM9J,SAAS;IAClB,gGAAgG,GAChG,KAAK,CAAC,GAAG8J,OAA0BD,KAAK,QAAQ,OAAOC;IACvD,MAAM,CAAC,GAAGA,OAA0BD,KAAK,QAAQ,QAAQC;IACzD,MAAM,CAAC,GAAGA,OAA0BD,KAAK,QAAQ,QAAQC;IACzD,OAAO,CAAC,GAAGA,OAA0BD,KAAK,SAAS,SAASC;IAC5D,OAAO,CAAC,GAAGA,OAA0BD,KAAK,SAAS,SAASC;IAC5D,yEAAyE,GACzE,OAAO,CAAC,GAAGA,OAA0BD,KAAK,SAAS,SAASC;AAChE,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACpJF;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D,E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACN2B;AACF;AACD;AACA;AACI"}
|
|
1
|
+
{"version":3,"file":"expressions/index.cjs","sources":["webpack://@routier/core/./src/assertions/index.ts","webpack://@routier/core/./src/expressions/callSource.ts","webpack://@routier/core/./src/expressions/constants.ts","webpack://@routier/core/./src/expressions/evaluate.ts","webpack://@routier/core/./src/expressions/fold.ts","webpack://@routier/core/./src/expressions/parser.ts","webpack://@routier/core/./src/expressions/types.ts","webpack://@routier/core/./src/expressions/utils.ts","webpack://@routier/core/./src/schema/types.ts","webpack://@routier/core/./src/utilities/logger.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/expressions/index.ts"],"sourcesContent":["import { EXPRESSION_TYPES } from \"../expressions/constants\";\nimport { CallExpression, ComparatorExpression, EmptyExpression, Expression, ExpressionType, NotParsableExpression, OperatorExpression, PropertyExpression, ValueExpression } from \"../expressions/types\";\nimport { isDate } from \"../utilities\";\n\nexport function assertDate(data: unknown): asserts data is Date {\n if (isDate(data) === false) {\n throw new TypeError('Value is not a Date');\n }\n}\n\nexport function assertIsNotNull<T>(data: T | null | undefined, message?: string | (() => string)): asserts data is NonNullable<T> {\n if (data == null) {\n if (message == null) {\n throw new TypeError('Assertion failed, data is null');\n }\n\n if (typeof message === \"string\") {\n throw new TypeError(message);\n }\n\n throw new TypeError(message());\n }\n}\n\nexport function assertIsArray<T>(data: unknown, message?: string): asserts data is T[] {\n if (!Array.isArray(data)) {\n throw new TypeError(message ?? 'Assertion failed, data is not of type Array');\n }\n}\n\nexport function assertString(data: unknown, message?: string): asserts data is string {\n if (typeof data !== \"string\") {\n throw new TypeError(message ?? 'Assertion failed, data is not of type String');\n }\n}\n\nexport function assertInstanceOf<T extends new (...args: any[]) => any>(value: unknown, Instance: T): asserts value is T {\n if (value instanceof Instance) {\n return;\n }\n\n if (value != null && typeof value === \"object\" && \"constructor\" in value) {\n throw new TypeError(`value is not instance of type. Type: ${value.constructor.name}`);\n }\n\n throw new TypeError(`value is not instance of type`);\n}\n\nexport function assertIsNumber(value: unknown): asserts value is number {\n if (typeof value !== \"number\") {\n throw new TypeError(\"value is not of type `number`\");\n }\n}\n\n\nfunction isObjectWithType(value: unknown): value is Record<\"type\", unknown> {\n return typeof value === \"object\" && value !== null && \"type\" in value;\n}\n\n/**\n * Type guard: narrows `value` to `Expression` when it is an object with a valid `type` property.\n */\nexport function isExpression(value: unknown): value is Expression {\n return isObjectWithType(value) && EXPRESSION_TYPES.includes(value.type as ExpressionType);\n}\n\n/**\n * Type guard: narrows `value` to `OperatorExpression` when it is an object with `type === \"operator\"`.\n */\nexport function isOperatorExpression(value: unknown): value is OperatorExpression {\n return isObjectWithType(value) && value.type === \"operator\";\n}\n\n/**\n * Type guard: narrows `value` to `ComparatorExpression` when it is an object with `type === \"comparator\"`.\n */\nexport function isComparatorExpression(value: unknown): value is ComparatorExpression {\n return isObjectWithType(value) && value.type === \"comparator\";\n}\n\n/**\n * Type guard: narrows `value` to `PropertyExpression` when it is an object with `type === \"property\"`.\n */\nexport function isPropertyExpression(value: unknown): value is PropertyExpression {\n return isObjectWithType(value) && value.type === \"property\";\n}\n\n/**\n * Type guard: narrows `value` to `ValueExpression` when it is an object with `type === \"value\"`.\n */\nexport function isValueExpression(value: unknown): value is ValueExpression {\n return isObjectWithType(value) && value.type === \"value\";\n}\n\n/**\n * Type guard: narrows `value` to `CallExpression` when it is an object with `type === \"call\"`.\n */\nexport function isCallExpression(value: unknown): value is CallExpression {\n return isObjectWithType(value) && value.type === \"call\";\n}\n\n/**\n * Type guard: narrows `value` to `EmptyExpression` when it is an object with `type === \"empty\"`.\n */\nexport function isEmptyExpression(value: unknown): value is EmptyExpression {\n return isObjectWithType(value) && value.type === \"empty\";\n}\n\n/**\n * Type guard: narrows `value` to `NotParsableExpression` when it is an object with `type === \"not-parsable\"`.\n */\nexport function isNotParsableExpression(value: unknown): value is NotParsableExpression {\n return isObjectWithType(value) && value.type === \"not-parsable\";\n}","import { Call } from \"./types\";\n\n/**\n * How a {@link Call} is spelled in JavaScript, and where its operand goes.\n *\n * `length` is a property, `Math.abs` is a function, `+` is an operator and `typeof` is a prefix — so\n * a name alone is not enough to render one.\n */\nexport type CallSource =\n | { form: \"method\", name: string }\n | { form: \"property\", name: string }\n | { form: \"function\", name: string }\n | { form: \"operator\", symbol: string }\n | { form: \"prefix\", keyword: string }\n | { form: \"conditional\" }\n /** The argument is the receiver in source: `/^a/.test(x.name)`, not `x.name.test(/^a/)`. */\n | { form: \"regex-test\" };\n\nexport const CALL_SOURCE: Record<Call, CallSource> = {\n \"to-lower-case\": { form: \"method\", name: \"toLowerCase\" },\n \"to-upper-case\": { form: \"method\", name: \"toUpperCase\" },\n \"length\": { form: \"property\", name: \"length\" },\n \"trim\": { form: \"method\", name: \"trim\" },\n \"trim-start\": { form: \"method\", name: \"trimStart\" },\n \"trim-end\": { form: \"method\", name: \"trimEnd\" },\n \"index-of\": { form: \"method\", name: \"indexOf\" },\n \"substring\": { form: \"method\", name: \"substring\" },\n \"concat\": { form: \"method\", name: \"concat\" },\n \"replace\": { form: \"method\", name: \"replace\" },\n \"replace-all\": { form: \"method\", name: \"replaceAll\" },\n\n \"absolute\": { form: \"function\", name: \"Math.abs\" },\n \"floor\": { form: \"function\", name: \"Math.floor\" },\n \"ceiling\": { form: \"function\", name: \"Math.ceil\" },\n \"round\": { form: \"function\", name: \"Math.round\" },\n \"sign\": { form: \"function\", name: \"Math.sign\" },\n \"square-root\": { form: \"function\", name: \"Math.sqrt\" },\n\n \"add\": { form: \"operator\", symbol: \"+\" },\n \"subtract\": { form: \"operator\", symbol: \"-\" },\n \"multiply\": { form: \"operator\", symbol: \"*\" },\n \"divide\": { form: \"operator\", symbol: \"/\" },\n \"modulo\": { form: \"operator\", symbol: \"%\" },\n\n \"utc-year\": { form: \"method\", name: \"getUTCFullYear\" },\n \"utc-month\": { form: \"method\", name: \"getUTCMonth\" },\n \"utc-day-of-month\": { form: \"method\", name: \"getUTCDate\" },\n \"utc-day-of-week\": { form: \"method\", name: \"getUTCDay\" },\n \"utc-hour\": { form: \"method\", name: \"getUTCHours\" },\n \"utc-minute\": { form: \"method\", name: \"getUTCMinutes\" },\n \"utc-second\": { form: \"method\", name: \"getUTCSeconds\" },\n \"utc-millisecond\": { form: \"method\", name: \"getUTCMilliseconds\" },\n \"epoch-ms\": { form: \"method\", name: \"getTime\" },\n\n \"to-string\": { form: \"function\", name: \"String\" },\n \"to-number\": { form: \"function\", name: \"Number\" },\n \"to-boolean\": { form: \"function\", name: \"Boolean\" },\n \"type-of\": { form: \"prefix\", keyword: \"typeof\" },\n\n \"some\": { form: \"method\", name: \"some\" },\n \"every\": { form: \"method\", name: \"every\" },\n\n // `Math.pow(a, b)` parses to the same call; `**` is the shorter of the two spellings\n \"power\": { form: \"operator\", symbol: \"**\" },\n \"bit-and\": { form: \"operator\", symbol: \"&\" },\n \"bit-or\": { form: \"operator\", symbol: \"|\" },\n \"bit-xor\": { form: \"operator\", symbol: \"^\" },\n \"shift-left\": { form: \"operator\", symbol: \"<<\" },\n \"shift-right\": { form: \"operator\", symbol: \">>\" },\n \"shift-right-unsigned\": { form: \"operator\", symbol: \">>>\" },\n \"bit-not\": { form: \"prefix\", keyword: \"~\" },\n \"coalesce\": { form: \"operator\", symbol: \"??\" },\n \"conditional\": { form: \"conditional\" },\n \"matches\": { form: \"regex-test\" },\n};\n\n/**\n * A call rendered as the JavaScript that produced it, from operand and argument text already\n * rendered by the caller.\n *\n * Takes strings so one implementation serves a live tree and a serialized one.\n */\n/**\n * Thunked because rendering a side can record a parameter, and `regex-test` emits its argument\n * before its operand — so the two orders have to agree.\n */\nexport const renderCallAsJs = (call: Call, renderOperand: () => string, renderArgs: () => string[]): string => {\n const source = CALL_SOURCE[call];\n\n if (source == null) {\n const operand = renderOperand();\n\n return `${operand}.${call}(${renderArgs().join(\", \")})`;\n }\n\n if (source.form === \"property\") {\n return `${renderOperand()}.${source.name}`;\n }\n\n if (source.form === \"regex-test\") {\n const pattern = renderArgs()[0] ?? \"?\";\n\n return `${pattern}.test(${renderOperand()})`;\n }\n\n if (source.form === \"method\") {\n const operand = renderOperand();\n\n return `${operand}.${source.name}(${renderArgs().join(\", \")})`;\n }\n\n if (source.form === \"function\") {\n const operand = renderOperand();\n\n return `${source.name}(${[operand, ...renderArgs()].join(\", \")})`;\n }\n\n if (source.form === \"prefix\") {\n // `~x`, not `~ x` — a bitwise complement is written tight, unlike `typeof`\n const operand = renderOperand();\n\n return source.keyword === \"~\" ? `${source.keyword}${operand}` : `${source.keyword} ${operand}`;\n }\n\n if (source.form === \"conditional\") {\n const operand = renderOperand();\n const args = renderArgs();\n\n return `${operand} ? ${args[0] ?? \"?\"} : ${args[1] ?? \"?\"}`;\n }\n\n const operand = renderOperand();\n\n return `${[operand, ...renderArgs()].join(` ${source.symbol} `)}`;\n};\n","import { ExpressionType } from \"./types\";\n\n/**\n * A `Record` rather than a list, so adding to `ExpressionType` without adding it here is a compile\n * error. As a list it was not exhaustive, and `call` was silently missing from `isExpression`.\n */\nconst EXPRESSION_TYPE_SET: Record<ExpressionType, true> = {\n \"operator\": true,\n \"comparator\": true,\n \"property\": true,\n \"value\": true,\n \"call\": true,\n \"empty\": true,\n \"not-parsable\": true,\n};\n\nexport const EXPRESSION_TYPES = Object.keys(EXPRESSION_TYPE_SET) as ExpressionType[];\n","import { isCallExpression, isComparatorExpression, isOperatorExpression, isPropertyExpression, isValueExpression } from \"../assertions\";\nimport { UnknownRecord } from \"../utilities\";\nimport { Call, Comparator, Expression } from \"./types\";\n\n/**\n * Runs a parsed expression against a row.\n *\n * The counterpart to `toSql` and `toMql`: those turn a tree into a backend's language, and this\n * turns it into an answer. Needed wherever a tree exists but the closure that produced it does\n * not — a filter split out of a larger predicate, an option rebuilt from a serialized query.\n *\n * ## It fails OPEN, and that is the whole safety argument\n *\n * `undefined` means \"this tree cannot be evaluated here\" — an unknown node, a transformer with no\n * implementation, a comparison between shapes that do not compare. Callers must read that as KEEP\n * THE ROW, never as exclude it.\n *\n * The reason is asymmetric cost. Every caller today uses this to NARROW something that a\n * subsequent, authoritative predicate will check again: a semi-join prefilter, a split conjunct.\n * Keeping a row this cannot judge costs one wasted comparison downstream. Dropping one loses data\n * from a query result and nothing anywhere reports it. So every uncertain path returns `undefined`,\n * and no path guesses `false`.\n *\n * ## Why not just reuse the caller's closure\n *\n * Because there often isn't one. A conjunct pulled out of `([p, m]) => p.a === 1 && m.b === 2` is\n * source TEXT; turning it back into a callable needs `new Function`, which a\n * Content-Security-Policy blocks — the same constraint that makes `softDeleteScope` build its tree\n * by hand. The tree is the only representation that survives.\n */\nexport type EvaluationResult = boolean | undefined;\n\n/** Reads a property or literal operand, or `UNRESOLVED` when the node is not one. */\nexport const UNRESOLVED = Symbol(\"unresolved\");\n\nconst ARITHMETIC: Partial<Record<Call, (left: number, right: number) => number>> = {\n \"add\": (left, right) => left + right,\n \"subtract\": (left, right) => left - right,\n \"multiply\": (left, right) => left * right,\n \"divide\": (left, right) => left / right,\n \"modulo\": (left, right) => left % right,\n \"power\": (left, right) => left ** right,\n \"bit-and\": (left, right) => left & right,\n \"bit-or\": (left, right) => left | right,\n \"bit-xor\": (left, right) => left ^ right,\n \"shift-left\": (left, right) => left << right,\n \"shift-right\": (left, right) => left >> right,\n \"shift-right-unsigned\": (left, right) => left >>> right,\n};\n\nconst applyCall = (call: Call, value: unknown, args: unknown[]): unknown | typeof UNRESOLVED => {\n // Above the guard: a template renders null as \"null\" in JavaScript, so these two are total.\n if (call === \"to-string\") {\n return String(value);\n }\n\n if (call === \"concat\") {\n return [value, ...args].map(String).join(\"\");\n }\n\n // A call applied to an absent value has no answer, and inventing one (\"\" for a missing string)\n // is how a filter starts matching rows it should not.\n if (value == null) {\n return UNRESOLVED;\n }\n\n if (call === \"to-lower-case\" || call === \"to-upper-case\") {\n if (typeof value !== \"string\") {\n return UNRESOLVED;\n }\n\n const lower = call === \"to-lower-case\";\n\n if (args.length === 0 || args[0] == null) {\n return lower ? value.toLowerCase() : value.toUpperCase();\n }\n\n if (typeof args[0] !== \"string\") {\n return UNRESOLVED;\n }\n\n try {\n // An explicit locale is deterministic; dropping it answers a different question in Turkish.\n return lower ? value.toLocaleLowerCase(args[0]) : value.toLocaleUpperCase(args[0]);\n } catch {\n // An invalid language tag throws RangeError; no answer beats the host's default.\n return UNRESOLVED;\n }\n }\n\n if (call === \"length\") {\n return typeof value === \"string\" || Array.isArray(value) ? value.length : UNRESOLVED;\n }\n\n if (call === \"bit-not\") {\n return typeof value === \"number\" ? ~value : UNRESOLVED;\n }\n\n if (call === \"matches\") {\n if (typeof value !== \"string\" || !(args[0] instanceof RegExp)) {\n return UNRESOLVED;\n }\n\n // `test` advances `lastIndex` on a global or sticky pattern, and the pattern is shared with\n // the cached template, where a source evaluates fresh in JavaScript.\n return args[0].global || args[0].sticky\n ? new RegExp(args[0].source, args[0].flags).test(value)\n : args[0].test(value);\n }\n\n const arithmetic = ARITHMETIC[call];\n\n if (arithmetic != null) {\n return typeof value === \"number\" && typeof args[0] === \"number\"\n ? arithmetic(value, args[0])\n : UNRESOLVED;\n }\n\n return UNRESOLVED;\n};\n\nexport const operandValue = (expression: Expression | undefined, row: UnknownRecord): unknown | typeof UNRESOLVED => {\n if (expression == null) {\n return UNRESOLVED;\n }\n\n if (isValueExpression(expression)) {\n return expression.value;\n }\n\n if (isPropertyExpression(expression)) {\n // Through the PropertyInfo, so a nested path and a `from`-renamed segment resolve the same\n // way every other consumer of the tree resolves them.\n return expression.property.getValue(row);\n }\n\n if (isCallExpression(expression)) {\n\n /**\n * `??` and `? :` are the two calls whose whole job is to answer when something is absent, so\n * they run before the guard that refuses an absent operand.\n */\n if (expression.call === \"coalesce\") {\n const left = operandValue(expression.expression, row);\n\n return left === UNRESOLVED || left == null ? operandValue(expression.arguments[0], row) : left;\n }\n\n if (expression.call === \"conditional\") {\n const condition = evaluate(expression.expression, row);\n\n if (condition === undefined) {\n return UNRESOLVED;\n }\n\n return operandValue(expression.arguments[condition === true ? 0 : 1], row);\n }\n\n const inner = operandValue(expression.expression, row);\n\n if (inner === UNRESOLVED) {\n return UNRESOLVED;\n }\n\n const args: unknown[] = [];\n\n for (const argument of expression.arguments) {\n const resolved = operandValue(argument, row);\n\n if (resolved === UNRESOLVED) {\n return UNRESOLVED;\n }\n\n args.push(resolved);\n }\n\n return applyCall(expression.call, inner, args);\n }\n\n return UNRESOLVED;\n};\n\n/**\n * `a === b` for the comparators, with Dates compared by VALUE.\n *\n * A Date compares by reference under `===`, so two Dates holding the same instant would be\n * unequal — which is not what a filter on a date means, and not what any backend does.\n */\nconst equals = (left: unknown, right: unknown, strict: boolean): boolean => {\n if (left instanceof Date && right instanceof Date) {\n return left.getTime() === right.getTime();\n }\n\n // oxlint-disable-next-line eqeqeq\n return strict ? left === right : left == right;\n};\n\n/** Ordered comparison, only for shapes that have an order. */\nconst compare = (left: unknown, right: unknown, comparator: Comparator): EvaluationResult => {\n const asComparable = (value: unknown) => value instanceof Date ? value.getTime() : value;\n\n const a = asComparable(left);\n const b = asComparable(right);\n\n const comparable = (typeof a === \"number\" && typeof b === \"number\")\n || (typeof a === \"string\" && typeof b === \"string\");\n\n if (comparable === false) {\n return undefined;\n }\n\n if (comparator === \"greater-than\") {\n return a > b;\n }\n\n if (comparator === \"greater-than-equals\") {\n return a >= b;\n }\n\n if (comparator === \"less-than\") {\n return a < b;\n }\n\n return a <= b;\n};\n\nconst evaluateComparator = (comparator: Comparator, left: unknown, right: unknown, strict: boolean): EvaluationResult => {\n\n if (comparator === \"equals\") {\n return equals(left, right, strict);\n }\n\n if (comparator === \"includes\") {\n // Two shapes, and the tree does not distinguish them: `array.includes(value)` and\n // `string.includes(substring)`. Whichever side is the container decides.\n if (Array.isArray(left)) {\n return left.some(item => equals(item, right, strict));\n }\n\n if (Array.isArray(right)) {\n return right.some(item => equals(item, left, strict));\n }\n\n return typeof left === \"string\" && typeof right === \"string\" ? left.includes(right) : undefined;\n }\n\n if (comparator === \"starts-with\") {\n return typeof left === \"string\" && typeof right === \"string\" ? left.startsWith(right) : undefined;\n }\n\n if (comparator === \"ends-with\") {\n return typeof left === \"string\" && typeof right === \"string\" ? left.endsWith(right) : undefined;\n }\n\n return compare(left, right, comparator);\n};\n\n/**\n * Evaluates `expression` against `row`, or returns `undefined` when it cannot.\n *\n * See the note at the top of this file: `undefined` means KEEP the row.\n */\nexport const evaluate = (expression: Expression, row: UnknownRecord): EvaluationResult => {\n\n if (isOperatorExpression(expression)) {\n const left = expression.left == null ? undefined : evaluate(expression.left, row);\n const right = expression.right == null ? undefined : evaluate(expression.right, row);\n\n /**\n * One unevaluable side does not have to sink the whole tree.\n *\n * `a && b` where `a` is definitely false is false whatever `b` is, and `a || b` where `a`\n * is definitely true is true. That short-circuiting is what lets a mostly-understood\n * predicate still narrow anything at all — without it, one unfamiliar sub-expression makes\n * the entire filter a no-op.\n */\n if (expression.operator === \"&&\") {\n if (left === false || right === false) {\n return false;\n }\n\n return left === true && right === true ? true : undefined;\n }\n\n if (left === true || right === true) {\n return true;\n }\n\n return left === false && right === false ? false : undefined;\n }\n\n if (isComparatorExpression(expression)) {\n const left = operandValue(expression.left, row);\n const right = operandValue(expression.right, row);\n\n if (left === UNRESOLVED || right === UNRESOLVED) {\n return undefined;\n }\n\n const result = evaluateComparator(expression.comparator, left, right, expression.strict);\n\n if (result === undefined) {\n return undefined;\n }\n\n return expression.negated ? result === false : result;\n }\n\n // A tautology excludes nothing, which is exactly `true`. Anything else — a bare property, a\n // literal, `not-parsable` — is not a predicate this can judge.\n return expression.type === \"empty\" ? true : undefined;\n};\n\n/**\n * `evaluate`, as a predicate that keeps whatever it cannot judge.\n *\n * The form every narrowing caller wants, with the fail-open rule applied once here rather than\n * remembered at each call site.\n */\nexport const toPredicate = (expression: Expression) => (row: UnknownRecord): boolean =>\n evaluate(expression, row) !== false;\n\n/**\n * `evaluate`, as a predicate that THROWS on anything it cannot judge.\n *\n * The opposite default to `toPredicate`, and the right one when the predicate is the only thing\n * standing between a caller and rows they asked to exclude — a filter that arrived over a wire and\n * is being applied by the receiver. Failing open there does not cost a wasted comparison; it returns\n * data the requester filtered out, and reports nothing.\n *\n * Use `toPredicate` when something authoritative re-checks the result, and this when nothing does.\n */\nexport const toStrictPredicate = (expression: Expression) => (row: UnknownRecord): boolean => {\n const result = evaluate(expression, row);\n\n if (result === undefined) {\n throw new Error(\n \"Cannot apply this filter: its expression cannot be evaluated in memory, and applying it partially would \" +\n \"return rows the filter excludes. This happens when a filter arrives without a runnable predicate — over a \" +\n \"wire, or rebuilt from a serialized query — and names something the evaluator does not understand.\"\n );\n }\n\n return result;\n};\n","import { isCallExpression, isComparatorExpression, isOperatorExpression, isPropertyExpression, isValueExpression } from \"../assertions\";\nimport { operandValue, UNRESOLVED } from \"./evaluate\";\nimport { Call, CallExpression, ComparatorExpression, Expression, OperatorExpression, ValueExpression } from \"./types\";\nimport { childrenOf } from \"./utils\";\n\n/** Calls fold may compute. Absent means a plugin declines it, so a new call is opt-in. */\nexport const FOLDABLE: ReadonlySet<Call> = new Set([\n \"to-lower-case\", \"to-upper-case\", \"length\", \"bit-not\", \"matches\", \"to-string\", \"concat\",\n \"add\", \"subtract\", \"multiply\", \"divide\", \"modulo\", \"power\",\n \"bit-and\", \"bit-or\", \"bit-xor\", \"shift-left\", \"shift-right\", \"shift-right-unsigned\",\n \"coalesce\", \"conditional\",\n]);\n\n/** `String(value)` on an object is the host's rendering — a Date carries its timezone. */\nconst COERCES_TO_TEXT: ReadonlySet<Call> = new Set([\"to-string\", \"concat\"]);\n\nconst isFrozenPrimitive = (value: unknown): boolean => value == null || typeof value !== \"object\";\n\nconst readsAProperty = (expression: Expression): boolean => {\n if (isPropertyExpression(expression)) {\n return true;\n }\n\n return childrenOf(expression).some(readsAProperty);\n};\n\n/** A `conditional` holds a condition where every other call holds a value. */\nconst isConstant = (call: CallExpression): boolean => {\n if (!FOLDABLE.has(call.call) || !call.arguments.every(isValueExpression)) {\n return false;\n }\n\n if (COERCES_TO_TEXT.has(call.call)\n && [call.expression, ...call.arguments].some(operand =>\n isValueExpression(operand) && !isFrozenPrimitive(operand.value))) {\n return false;\n }\n\n return call.call === \"conditional\"\n ? !readsAProperty(call.expression)\n : isValueExpression(call.expression);\n};\n\n/** Computes every call whose operand and arguments are all literals. Runs after `bindExpression`. */\nexport const foldConstantCalls = (expression: Expression): Expression => {\n\n if (isCallExpression(expression)) {\n const folded = new CallExpression({\n call: expression.call,\n expression: foldConstantCalls(expression.expression),\n arguments: expression.arguments.map(foldConstantCalls)\n });\n\n if (!isConstant(folded)) {\n return folded;\n }\n\n const value = operandValue(folded, {});\n\n return value === UNRESOLVED ? folded : new ValueExpression({ value });\n }\n\n if (isComparatorExpression(expression)) {\n return new ComparatorExpression({\n comparator: expression.comparator,\n negated: expression.negated,\n strict: expression.strict,\n left: expression.left == null ? undefined : foldConstantCalls(expression.left),\n right: expression.right == null ? undefined : foldConstantCalls(expression.right)\n });\n }\n\n if (isOperatorExpression(expression)) {\n return new OperatorExpression({\n operator: expression.operator,\n left: expression.left == null ? undefined : foldConstantCalls(expression.left),\n right: expression.right == null ? undefined : foldConstantCalls(expression.right)\n });\n }\n\n return expression;\n};\n\n/** The value a literal operand binds as once the calls on it are computed. Throws if it cannot. */\nexport const foldedOperandValue = (operand: ValueExpression, calls: CallExpression[]): unknown => {\n if (calls.length === 0) {\n return operand.value;\n }\n\n // `peelCalls` returns calls innermost first, so the last one evaluates the whole chain.\n const outermost = calls[calls.length - 1];\n const value = readsAProperty(outermost) ? UNRESOLVED : operandValue(outermost, {});\n\n if (value === UNRESOLVED) {\n throw new Error(\n `'${calls.map(call => call.call).join(\"', '\")}' cannot be computed on the literal ` +\n `'${String(operand.value)}'.`\n );\n }\n\n return value;\n};\n","import { logger } from \"../utilities\";\nimport { assertString } from \"../assertions\";\nimport { CompiledSchema, PropertyInfo, SchemaTypes } from \"../schema\";\nimport { evaluate } from \"./evaluate\";\nimport { foldConstantCalls } from \"./fold\";\nimport { Expression, OperatorExpression, ComparatorExpression, ValueExpression, PropertyExpression, CallExpression, Filter, ParamsFilter, Call, Comparator, Transformer } from \"./types\";\n\n// Error message constants\nconst ERROR_MESSAGES = {\n PROPERTY_NOT_FOUND: (path: string) => `Error parsing query, could not find PropertyInfo for path: ${path}`,\n PARAM_PATH_NOT_FOUND: (value: string, params: unknown) => `Cannot find path in params for .where(). Make sure parameters are not used inline.\\r\\nPath: ${value}, Params: ${JSON.stringify(params)}`,\n VARIABLE_VALUE: (value: string) => `Cannot derive value from variable, please pass parameters into the expression.\n\nExample: .where(([x, params]) => x.id === params.id, { id: someVar.id })\nIssue At: ${value}`,\n UNSUPPORTED: (value: string) => `Unsupported expression format: ${value}`\n};\n\nconst parseUnknown = (value: unknown) => {\n assertString(value);\n return JSON.parse(value);\n}\n\n/**\n * A parse failure caused by the params VALUES rather than the filter source.\n * These must never poison the template cache — the same source can succeed\n * with different params.\n */\nclass ParamDependentParseError extends Error { }\n\nconst converters: Record<SchemaTypes, (value: unknown) => unknown> = {\n Array: v => v,\n Boolean: v => v == null ? v : Boolean(v),\n // Stryker disable next-line ArrowFunction: filters on computed properties route to\n // in-memory execution, so this entry cannot be reached through a parsable filter.\n Computed: v => v,\n Date: v => v,\n // A file is a reference, and a filter can legitimately compare its fields — content type\n // and size are ordinary columns. The value passes through unconverted like an object.\n File: v => v,\n // Stryker disable next-line ArrowFunction: SchemaTypes.Definition is handled as a\n // generic primitive everywhere (specs/known-defects.md) and never pairs in a filter.\n Definition: v => v,\n // Stryker disable next-line ArrowFunction: filters on function properties route to\n // in-memory execution, so this entry cannot be reached through a parsable filter.\n Function: v => v,\n Number: v => v == null ? v : Number(v),\n Object: v => v,\n String: v => v == null ? v : String(v),\n // A vector is a list of numbers and passes through like any other array. Nothing\n // converts it because nothing compares it: similarity is `.nearest()`, not a filter.\n Vector: v => v\n};\n\n// #region Tokenizer\n\ntype TokenKind = \"identifier\" | \"string\" | \"number\" | \"bigint\" | \"regex\" | \"template\" | \"punctuation\";\n\ntype Token = {\n kind: TokenKind;\n value: string;\n}\n\n// Longest first so multi-character punctuation wins over its prefixes\nconst MULTI_CHARACTER_PUNCTUATION = [\">>>\", \"===\", \"!==\", \"**\", \"<<\", \">>\", \"??\", \"?.\", \"&&\", \"||\", \"==\", \"!=\", \">=\", \"<=\", \"=>\"] as const;\n// Stryker disable next-line all: documented equivalent cluster (see\n// docs/mutation-backlog.md) — dropping an entry only affects source the parser rejects\n// either way, and the rejection message names the character from the source rather than\n// from this set, so no observable boundary distinguishes the mutant. Established\n// experimentally: 30 message-asserting tests killed 1 of 12.\nconst SINGLE_CHARACTER_PUNCTUATION = new Set([\"(\", \")\", \"[\", \"]\", \"{\", \"}\", \".\", \",\", \";\", \"!\", \">\", \"<\", \"-\", \"+\", \"*\", \"/\", \"%\", \"=\", \"?\", \":\", \"&\", \"|\", \"^\", \"~\"]);\n\n/**\n * A lookup table keyed by source text.\n *\n * Null-prototype: `TRANSFORM_METHODS[\"toString\"]` otherwise returns `Object.prototype.toString`,\n * which is truthy, and the parser reads a method it does not support as one it does.\n */\nconst sourceKeyed = <T>(entries: Record<string, T>): Record<string, T> =>\n Object.assign(Object.create(null) as Record<string, T>, entries);\n\nconst STRING_ESCAPES: Record<string, string> = sourceKeyed({\n \"n\": \"\\n\",\n \"r\": \"\\r\",\n \"t\": \"\\t\",\n \"b\": \"\\b\",\n \"f\": \"\\f\",\n \"v\": \"\\v\",\n \"0\": \"\\0\"\n});\n\n/**\n * Whether a `/` here opens a regex rather than dividing.\n *\n * A regex cannot follow a value. Everything else — the start of the source, an operator, an opening\n * bracket, a comma — is a position where only a regex makes sense.\n */\nconst regexCanStartHere = (tokens: Token[]): boolean => {\n const previous = tokens[tokens.length - 1];\n\n if (previous == null) {\n return true;\n }\n\n if (previous.kind === \"number\" || previous.kind === \"string\" || previous.kind === \"bigint\" || previous.kind === \"regex\") {\n return false;\n }\n\n if (previous.kind === \"identifier\") {\n return false;\n }\n\n return previous.value !== \")\" && previous.value !== \"]\";\n};\n\nconst isIdentifierStart = (char: string) => /[a-zA-Z_$]/.test(char);\nconst isIdentifierPart = (char: string) => /[a-zA-Z0-9_$]/.test(char);\nconst isDigit = (char: string) => char >= \"0\" && char <= \"9\";\nconst isHexDigit = (char: string) => isDigit(char) || (char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\");\n\n/**\n * Decodes a `\\uXXXX`, `\\u{...}` or `\\xXX` escape starting at the backslash.\n * Returns the decoded character and the index just past the escape. These\n * escapes carry a computed character, so mapping them through STRING_ESCAPES\n * (which would yield the literal \"u\"/\"x\") silently corrupts the value.\n */\nconst decodeCodeEscape = (source: string, backslashIndex: number): { value: string, nextIndex: number } => {\n const kind = source[backslashIndex + 1];\n let start = backslashIndex + 2;\n\n if (kind === \"u\" && source[start] === \"{\") {\n const end = source.indexOf(\"}\", start + 1);\n\n if (end === -1) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unterminated unicode escape\"));\n }\n\n return { value: String.fromCodePoint(parseInt(source.slice(start + 1, end), 16)), nextIndex: end + 1 };\n }\n\n const length = kind === \"u\" ? 4 : 2;\n const digits = source.slice(start, start + length);\n\n if (digits.length < length || [...digits].some(d => !isHexDigit(d))) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`'\\\\${kind}' escape`));\n }\n\n return { value: String.fromCharCode(parseInt(digits, 16)), nextIndex: start + length };\n}\n\n/**\n * Converts filter source text into a flat token stream. Strings and comments are\n * consumed here so operator characters inside literals can never be mistaken for\n * real operators.\n */\nconst tokenize = (source: string): Token[] => {\n\n const tokens: Token[] = [];\n let i = 0;\n\n while (i < source.length) {\n const char = source[i];\n\n // Whitespace\n if (char === \" \" || char === \"\\t\" || char === \"\\r\" || char === \"\\n\") {\n i++;\n continue;\n }\n\n /**\n * A regex literal, told from division by what came before it.\n *\n * `/` after a value — a number, string, identifier, `)` or `]` — is division. Anywhere else\n * it opens a regex. That is the same rule a JavaScript lexer uses, and it is why `x.a / 2`\n * and `/^a/.test(x.a)` can share a character.\n */\n if (char === \"/\" && source[i + 1] !== \"/\" && source[i + 1] !== \"*\" && regexCanStartHere(tokens)) {\n let value = \"\";\n let inClass = false;\n let j = i + 1;\n\n while (j < source.length) {\n const current = source[j];\n\n if (current === \"\\\\\") {\n value += current + (source[j + 1] ?? \"\");\n j += 2;\n continue;\n }\n\n if (current === \"[\") {\n inClass = true;\n } else if (current === \"]\") {\n inClass = false;\n } else if (current === \"/\" && inClass === false) {\n break;\n } else if (current === \"\\n\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unterminated regular expression\"));\n }\n\n value += current;\n j++;\n }\n\n if (j >= source.length) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unterminated regular expression\"));\n }\n\n j++;\n let flags = \"\";\n\n while (j < source.length && isIdentifierPart(source[j])) {\n flags += source[j];\n j++;\n }\n\n i = j;\n tokens.push({ kind: \"regex\", value: `${value}\\u0000${flags}` });\n continue;\n }\n\n // Comments\n if (char === \"/\" && source[i + 1] === \"/\") {\n while (i < source.length && source[i] !== \"\\n\") {\n i++;\n }\n continue;\n }\n\n if (char === \"/\" && source[i + 1] === \"*\") {\n i += 2;\n while (i < source.length && !(source[i] === \"*\" && source[i + 1] === \"/\")) {\n i++;\n }\n i += 2;\n continue;\n }\n\n // String literals\n if (char === \"'\" || char === \"\\\"\" || char === \"`\") {\n const quote = char;\n let value = \"\";\n const chunks: string[] = [];\n const expressions: string[] = [];\n i++;\n\n while (i < source.length && source[i] !== quote) {\n if (source[i] === \"\\\\\") {\n const escaped = source[i + 1];\n\n if (escaped === \"u\" || escaped === \"x\") {\n const decoded = decodeCodeEscape(source, i);\n value += decoded.value;\n i = decoded.nextIndex;\n continue;\n }\n\n value += STRING_ESCAPES[escaped] ?? escaped;\n i += 2;\n continue;\n }\n\n /**\n * An interpolation. The literal so far becomes a chunk and the expression source is\n * kept whole, to be parsed by its own stream — nesting means the inner source can\n * hold anything, including another template.\n */\n if (quote === \"`\" && source[i] === \"$\" && source[i + 1] === \"{\") {\n let depth = 1;\n let expression = \"\";\n let at = i + 2;\n\n while (at < source.length && depth > 0) {\n const current = source[at];\n\n if (current === \"{\") {\n depth++;\n } else if (current === \"}\") {\n depth--;\n\n if (depth === 0) {\n break;\n }\n } else if (current === \"'\" || current === '\"' || current === \"`\") {\n const closing = current;\n expression += current;\n at++;\n\n while (at < source.length && source[at] !== closing) {\n expression += source[at] === \"\\\\\" ? source[at] + (source[at + 1] ?? \"\") : source[at];\n at += source[at] === \"\\\\\" ? 2 : 1;\n }\n }\n\n expression += source[at];\n at++;\n }\n\n if (depth > 0) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unterminated template interpolation\"));\n }\n\n chunks.push(value);\n expressions.push(expression);\n value = \"\";\n i = at + 1;\n continue;\n }\n\n value += source[i];\n i++;\n }\n\n if (i >= source.length) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unterminated string literal\"));\n }\n\n i++; // consume closing quote\n\n if (expressions.length > 0) {\n chunks.push(value);\n tokens.push({ kind: \"template\", value: JSON.stringify({ chunks, expressions }) });\n continue;\n }\n\n tokens.push({ kind: \"string\", value });\n continue;\n }\n\n // Numbers — covers decimals, exponents (1e6), hex/octal/binary (0xFF),\n // and numeric separators (1_000_000). Values are normalized here (the\n // separator stripped) so the parser can hand them straight to Number()\n if (isDigit(char)) {\n let value = \"\";\n\n const nextChar = source[i + 1];\n const radixPrefix = char === \"0\" && nextChar != null && \"xXoObB\".includes(nextChar);\n\n if (radixPrefix) {\n value = source[i] + source[i + 1];\n i += 2;\n\n while (i < source.length && (isHexDigit(source[i]) || source[i] === \"_\")) {\n value += source[i];\n i++;\n }\n } else {\n while (i < source.length && (isDigit(source[i]) || source[i] === \".\" || source[i] === \"_\")) {\n value += source[i];\n i++;\n }\n\n // Exponent part: e/E, optional sign, then digits. Only consumed when\n // digits follow, so a stray identifier after a number still errors\n if ((source[i] === \"e\" || source[i] === \"E\")) {\n const signLength = source[i + 1] === \"+\" || source[i + 1] === \"-\" ? 1 : 0;\n\n if (isDigit(source[i + 1 + signLength])) {\n value += source[i];\n i++;\n\n if (signLength === 1) {\n value += source[i];\n i++;\n }\n\n while (i < source.length && isDigit(source[i])) {\n value += source[i];\n i++;\n }\n }\n }\n }\n\n if (source[i] === \"n\") {\n i++;\n tokens.push({ kind: \"bigint\", value: value.replace(/_/g, \"\") });\n continue;\n }\n\n tokens.push({ kind: \"number\", value: value.replace(/_/g, \"\") });\n continue;\n }\n\n // Identifiers / keywords\n if (isIdentifierStart(char)) {\n let value = \"\";\n\n while (i < source.length && isIdentifierPart(source[i])) {\n value += source[i];\n i++;\n }\n\n tokens.push({ kind: \"identifier\", value });\n continue;\n }\n\n // Multi-character punctuation (longest match first)\n const multi = MULTI_CHARACTER_PUNCTUATION.find(w => source.startsWith(w, i));\n\n if (multi != null) {\n tokens.push({ kind: \"punctuation\", value: multi });\n i += multi.length;\n continue;\n }\n\n if (SINGLE_CHARACTER_PUNCTUATION.has(char)) {\n tokens.push({ kind: \"punctuation\", value: char });\n i++;\n continue;\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`unexpected character '${char}'`));\n }\n\n return tokens;\n}\n\n/**\n * Cursor over the token stream with the small set of lookahead operations the\n * parser needs.\n */\nclass TokenStream {\n\n private tokens: Token[];\n private index: number = 0;\n\n constructor(tokens: Token[]) {\n this.tokens = tokens;\n }\n\n /** Inserts tokens at the cursor, bracketed so they keep their own precedence. */\n splice(tokens: Token[]) {\n const bracketed: Token[] = [\n { kind: \"punctuation\", value: \"(\" },\n ...tokens,\n { kind: \"punctuation\", value: \")\" }\n ];\n\n this.tokens = [...this.tokens.slice(0, this.index), ...bracketed, ...this.tokens.slice(this.index)];\n }\n\n get isAtEnd() {\n return this.index >= this.tokens.length;\n }\n\n peek(offset: number = 0): Token | null {\n return this.tokens[this.index + offset] ?? null;\n }\n\n next(): Token {\n const token = this.tokens[this.index];\n\n if (token == null) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unexpected end of expression\"));\n }\n\n this.index++;\n return token;\n }\n\n /** The tokens of one statement's value, through the `;` or block end that closes it. */\n takeStatementTokens(): Token[] {\n const tokens: Token[] = [];\n let depth = 0;\n\n while (!this.isAtEnd) {\n const token = this.peek()!;\n\n if (token.kind === \"punctuation\") {\n if (token.value === \"(\" || token.value === \"[\" || token.value === \"{\") {\n depth++;\n } else if (token.value === \")\" || token.value === \"]\" || token.value === \"}\") {\n if (depth === 0) {\n break;\n }\n\n depth--;\n } else if (token.value === \";\" && depth === 0) {\n this.next();\n break;\n }\n }\n\n tokens.push(this.next());\n }\n\n if (tokens.length === 0) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"a declaration with no value\"));\n }\n\n return tokens;\n }\n\n isPunctuation(value: string, offset: number = 0): boolean {\n const token = this.peek(offset);\n return token != null && token.kind === \"punctuation\" && token.value === value;\n }\n\n /**\n * Whether the group starting here holds a value rather than a condition.\n *\n * `(a && b)` is a boolean sub-expression; `(x.name ?? '') === 'ada'` and `(x.name).length` are\n * values. Only the token after the matching bracket tells them apart, so the decision is made by\n * looking ahead rather than by parsing one way and catching the failure — a rewind on exception\n * would swallow a genuine syntax error inside the group and report it as something else.\n */\n groupIsValue(): boolean {\n let depth = 0;\n let at = this.index;\n\n for (; at < this.tokens.length; at++) {\n const token = this.tokens[at];\n\n if (token.kind !== \"punctuation\") {\n continue;\n }\n\n if (token.value === \"(\") {\n depth++;\n continue;\n }\n\n if (token.value === \")\") {\n depth--;\n\n if (depth === 0) {\n break;\n }\n }\n }\n\n const after = this.tokens[at + 1];\n\n if (after == null || after.kind !== \"punctuation\") {\n return false;\n }\n\n return COMPARISON_OPERATORS[after.value] != null || after.value === \".\" || after.value === \"?.\";\n }\n\n /** Whether a `?` sits at the top level of what is left, so this is a conditional. */\n holdsConditional(): boolean {\n let depth = 0;\n\n for (let at = this.index; at < this.tokens.length; at++) {\n const token = this.tokens[at];\n\n if (token.kind !== \"punctuation\") {\n continue;\n }\n\n if (token.value === \"(\" || token.value === \"[\") {\n depth++;\n } else if (token.value === \")\" || token.value === \"]\") {\n depth--;\n } else if (token.value === \"?\" && depth === 0) {\n return true;\n }\n }\n\n return false;\n }\n\n /** Whether the group starting here is `( … ? … : … )` rather than a plain value. */\n groupHoldsConditional(): boolean {\n let depth = 0;\n\n for (let at = this.index; at < this.tokens.length; at++) {\n const token = this.tokens[at];\n\n if (token.kind !== \"punctuation\") {\n continue;\n }\n\n if (token.value === \"(\") {\n depth++;\n continue;\n }\n\n if (token.value === \")\") {\n depth--;\n\n if (depth === 0) {\n return false;\n }\n\n continue;\n }\n\n if (token.value === \"?\" && depth === 1) {\n return true;\n }\n }\n\n return false;\n }\n\n matchPunctuation(value: string): boolean {\n if (this.isPunctuation(value)) {\n this.index++;\n return true;\n }\n\n return false;\n }\n\n expectPunctuation(value: string) {\n if (!this.matchPunctuation(value)) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`expected '${value}'`));\n }\n }\n}\n\n// #endregion\n\n// #region Operands\n\n// Discriminated union so a condition builder can only ever see the operand\n// shapes the grammar allows\ntype PropertyOperand = {\n kind: \"property\";\n property: PropertyInfo<any>;\n transformer: Transformer | null;\n locale: string | null;\n}\n\ntype ValueOperand = {\n kind: \"value\";\n value: unknown;\n transformer: Transformer | null;\n locale: string | null;\n}\n\ntype ParamOperand = {\n kind: \"param\";\n path: string[];\n transformer: Transformer | null;\n locale: string | null;\n}\n\ntype MethodCallOperand = {\n kind: \"method-call\";\n target: PropertyOperand | ParamOperand | ValueOperand;\n method: \"startsWith\" | \"endsWith\" | \"includes\";\n argument: PropertyOperand | ValueOperand | ParamOperand;\n}\n\n/**\n * Arithmetic, which the tree carries as a binary `CallExpression`.\n *\n * A parse-time shape rather than an expression because the comparator builders orient on operand\n * KIND, and they have to be able to see that the property is in here.\n */\ntype ArithmeticOperand = {\n kind: \"arithmetic\";\n call: Call;\n left: Operand;\n right: Operand;\n /** The third operand, which only `conditional` has. */\n extra?: Operand;\n /** Set when brackets around it settled the precedence. See {@link LOOSER_THAN_COMPARISON}. */\n grouped?: true;\n}\n\n/**\n * Calls JavaScript binds LOOSER than a comparison.\n *\n * This grammar reads a comparison's operands as values, which puts these tighter than they belong:\n * `x.flags & 6 === 2` is `x.flags & (6 === 2)` in JavaScript and would be read here as\n * `(x.flags & 6) === 2`. The two answer differently, so an ungrouped one is refused rather than\n * reinterpreted — the filter then runs in memory against the caller's own function, which is right by\n * construction. Brackets say which was meant, and JavaScript itself makes an unbracketed `??` mix a\n * syntax error for the same reason.\n */\nconst LOOSER_THAN_COMPARISON: readonly Call[] = [\"bit-and\", \"bit-or\", \"bit-xor\", \"coalesce\"];\n\nconst needsBrackets = (operand: Operand): boolean =>\n operand.kind === \"arithmetic\" && operand.grouped !== true && LOOSER_THAN_COMPARISON.includes(operand.call);\n\n/**\n * `a ? b : c`, where the condition is a BOOLEAN and the branches are values.\n *\n * Its own kind rather than an arithmetic operand with three slots, because the condition is an\n * Expression already — a comparison — while the branches are operands still being built.\n */\ntype ConditionalOperand = {\n kind: \"conditional\";\n condition: Expression;\n whenTrue: Operand;\n whenFalse: Operand;\n}\n\ntype Operand = PropertyOperand | ValueOperand | ParamOperand | MethodCallOperand | ArithmeticOperand | ConditionalOperand;\n\n/** JavaScript precedence: `*`, `/`, `%` bind tighter than `+` and `-`. */\nconst MULTIPLICATIVE_OPERATORS: Record<string, Call> = sourceKeyed({\n \"*\": \"multiply\",\n \"/\": \"divide\",\n \"%\": \"modulo\",\n});\n\nconst ADDITIVE_OPERATORS: Record<string, Call> = sourceKeyed({\n \"+\": \"add\",\n \"-\": \"subtract\",\n});\n\nconst SHIFT_OPERATORS: Record<string, Call> = sourceKeyed({\n \"<<\": \"shift-left\",\n \">>\": \"shift-right\",\n \">>>\": \"shift-right-unsigned\",\n});\n\nconst BITWISE_AND_OPERATORS: Record<string, Call> = sourceKeyed({ \"&\": \"bit-and\" });\nconst BITWISE_XOR_OPERATORS: Record<string, Call> = sourceKeyed({ \"^\": \"bit-xor\" });\nconst BITWISE_OR_OPERATORS: Record<string, Call> = sourceKeyed({ \"|\": \"bit-or\" });\nconst COALESCE_OPERATORS: Record<string, Call> = sourceKeyed({ \"??\": \"coalesce\" });\n\n/** Whether a schema property is reachable in here, which decides which side of a comparison it is. */\nconst containsProperty = (operand: Operand): boolean => {\n if (operand.kind === \"property\") {\n return true;\n }\n\n if (operand.kind === \"conditional\") {\n // A comparison always names a schema property, so the condition alone settles it\n return true;\n }\n\n return operand.kind === \"arithmetic\"\n && (containsProperty(operand.left) || containsProperty(operand.right) || (operand.extra != null && containsProperty(operand.extra)));\n};\n\nconst DECLARATION_KEYWORDS = new Set([\"const\", \"let\", \"var\"]);\n\n/** An operand whose value only a row can supply. */\nconst UNKNOWN_UNTIL_ROW = Symbol(\"unknown until row\");\n\n/** The empty argument slot of a unary call. Compared by identity, so a real `undefined` still counts. */\nconst NO_ARGUMENT: ValueOperand = Object.freeze({ kind: \"value\", value: undefined, transformer: null, locale: null }) as ValueOperand;\n\nconst noArgument = (): ValueOperand => NO_ARGUMENT;\n\n/** A predicate no row satisfies. Never reaches a tree: no expression node means \"match nothing\". */\nconst NEVER = \"never\";\n\ntype Answer = Expression | typeof NEVER;\n\nconst and = (left: Expression, right: Expression): Expression => {\n if (Expression.isEmpty(left)) {\n return right;\n }\n\n if (Expression.isEmpty(right)) {\n return left;\n }\n\n return new OperatorExpression({ operator: \"&&\", left, right });\n}\n\nconst or = (left: Expression, right: Expression): Expression => {\n if (Expression.isEmpty(left) || Expression.isEmpty(right)) {\n return Expression.EMPTY;\n }\n\n return new OperatorExpression({ operator: \"||\", left, right });\n}\n\nconst COMPARATOR_METHODS: Record<string, Comparator> = sourceKeyed({\n startsWith: \"starts-with\",\n endsWith: \"ends-with\",\n includes: \"includes\"\n});\n\nconst TRANSFORM_METHODS: Record<string, { transformer: Transformer, locale: string | null }> = sourceKeyed({\n toLowerCase: { transformer: \"to-lower-case\", locale: null },\n toUpperCase: { transformer: \"to-upper-case\", locale: null },\n toLocaleLowerCase: { transformer: \"to-lower-case\", locale: \"en-US\" },\n toLocaleUpperCase: { transformer: \"to-upper-case\", locale: \"en-US\" }\n});\n\nconst COMPARISON_OPERATORS: Record<string, { comparator: Comparator, negated: boolean, strict: boolean }> = sourceKeyed({\n \"==\": { comparator: \"equals\", negated: false, strict: false },\n \"===\": { comparator: \"equals\", negated: false, strict: true },\n \"!=\": { comparator: \"equals\", negated: true, strict: false },\n \"!==\": { comparator: \"equals\", negated: true, strict: true },\n \">\": { comparator: \"greater-than\", negated: false, strict: false },\n \">=\": { comparator: \"greater-than-equals\", negated: false, strict: false },\n \"<\": { comparator: \"less-than\", negated: false, strict: false },\n \"<=\": { comparator: \"less-than-equals\", negated: false, strict: false }\n});\n\nconst SWAPPED_COMPARATORS: Record<Comparator, Comparator> = {\n \"equals\": \"equals\",\n \"greater-than\": \"less-than\",\n \"greater-than-equals\": \"less-than-equals\",\n \"less-than\": \"greater-than\",\n \"less-than-equals\": \"greater-than-equals\",\n \"starts-with\": \"starts-with\",\n \"ends-with\": \"ends-with\",\n \"includes\": \"includes\"\n};\n\n// #endregion\n\n// #region Param references\n\n/**\n * Placeholder for a parameter value inside a cached expression template. Never\n * escapes this module — binding replaces it with a plain ValueExpression that\n * holds the resolved value.\n */\nclass ParamReferenceExpression extends ValueExpression {\n\n /** Path into the params object, excluding the params root name. */\n readonly paramPath: string[];\n /** The property this value is compared against; drives serialization/conversion at bind time. */\n readonly pairedProperty: PropertyInfo<any> | null;\n /** Whether the paired property's type converter applies (equality/relational comparisons only). */\n readonly applyConverter: boolean;\n\n constructor(options: {\n paramPath: string[],\n pairedProperty: PropertyInfo<any> | null,\n applyConverter: boolean\n }) {\n super({ value: undefined });\n this.paramPath = options.paramPath;\n this.pairedProperty = options.pairedProperty;\n this.applyConverter = options.applyConverter;\n }\n}\n\nconst resolveParamPath = (paramsName: string, path: string[], data: unknown) => {\n\n let result = data as Record<string, unknown>;\n\n for (let i = 0; i < path.length; i++) {\n const name = path[i];\n\n if (result != null && typeof result === \"object\" && name in result) {\n result = result[name] as Record<string, unknown>;\n continue;\n }\n\n throw new ParamDependentParseError(ERROR_MESSAGES.PARAM_PATH_NOT_FOUND([paramsName, ...path].join(\".\"), data));\n }\n\n return result as unknown;\n}\n\n/**\n * Applies the paired property's value serializer and (optionally) its schema\n * type converter, matching how literal values are treated at parse time.\n */\nconst resolvePairedValue = (value: unknown, pairedProperty: PropertyInfo<any> | null, applyConverter: boolean) => {\n\n if (pairedProperty == null) {\n return value;\n }\n\n let result = value;\n\n if (pairedProperty.valueSerializer != null) {\n result = String(pairedProperty.valueSerializer(parseUnknown(result)));\n }\n\n if (applyConverter) {\n result = converters[pairedProperty.type](result);\n }\n\n return result;\n}\n\n// #endregion\n\n// #region Parser\n\n/**\n * Recursive descent parser over the token stream. Produces an expression\n * template: literal values are fully resolved, parameter values are represented\n * as ParamReferenceExpression placeholders so the template can be cached and\n * re-bound with different params.\n */\nclass ExpressionParser {\n\n private readonly schema: CompiledSchema<any>;\n private readonly stream: TokenStream;\n private readonly scope: Scope;\n private readonly paramsName: string | null;\n private readonly params: unknown;\n\n /** Set when a param value shaped the tree itself (e.g. x[p.name]) — such templates cannot be cached. */\n structurallyDependsOnParams: boolean = false;\n\n constructor(schema: CompiledSchema<any>, stream: TokenStream, scope: Scope, paramsName: string | null, params: unknown) {\n this.schema = schema;\n this.stream = stream;\n this.scope = scope;\n this.paramsName = paramsName;\n this.params = params;\n }\n\n parse(): Expression {\n const expression = this.parseOr();\n\n if (!this.stream.isAtEnd) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`unexpected token '${this.stream.peek()?.value}'`));\n }\n\n return expression;\n }\n\n parseBody(): Expression {\n\n if (!this.stream.isPunctuation(\"{\")) {\n return this.parse();\n }\n\n const answer = this.parseBlock();\n\n if (!this.stream.isAtEnd) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`unexpected token '${this.stream.peek()?.value}'`));\n }\n\n if (answer === NEVER) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"a predicate no row can satisfy\"));\n }\n\n return answer;\n }\n\n /** The expression a `{ … }` block answers with. */\n private parseBlock(): Answer {\n this.stream.expectPunctuation(\"{\");\n const answer = this.parseStatements();\n this.stream.expectPunctuation(\"}\");\n\n return answer;\n }\n\n /** Statements up to the one that returns. What follows a `return` is never read, as in JavaScript. */\n private parseStatements(): Answer {\n if (this.stream.isPunctuation(\"}\") || this.stream.isAtEnd) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"a block body that returns nothing\"));\n }\n\n const keyword = this.stream.peek();\n\n if (keyword == null || keyword.kind !== \"identifier\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`a statement starting '${keyword?.value}'`));\n }\n\n if (DECLARATION_KEYWORDS.has(keyword.value)) {\n this.declare();\n return this.parseStatements();\n }\n\n if (keyword.value === \"return\") {\n this.stream.next();\n const answer = this.parseReturnedCondition();\n this.stream.matchPunctuation(\";\");\n\n return answer;\n }\n\n if (keyword.value === \"if\") {\n return this.parseIfStatement();\n }\n\n if (keyword.value === \"switch\") {\n return this.parseSwitchStatement();\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`the statement '${keyword.value}'`));\n }\n\n /**\n * Binds a `const`/`let`/`var` name to the tokens of its initializer — tokens rather than a parsed\n * expression, so the name works as an operand, an argument, or a call receiver alike.\n */\n private declare() {\n this.stream.next();\n\n const name = this.stream.next();\n\n if (name.kind !== \"identifier\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`the declaration '${name.value}'`));\n }\n\n this.stream.expectPunctuation(\"=\");\n\n this.scope.set(name.value, { kind: \"inlined\", tokens: this.stream.takeStatementTokens() });\n }\n\n /** `return false` on its own, which no row satisfies, and every other returned condition. */\n private parseReturnedCondition(): Answer {\n const next = this.stream.peek();\n const after = this.stream.peek(1);\n const endsHere = after == null || (after.kind === \"punctuation\" && (after.value === \";\" || after.value === \"}\"));\n\n if (next != null && next.kind === \"identifier\" && next.value === \"false\" && endsHere) {\n this.stream.next();\n return NEVER;\n }\n\n return this.parseOr();\n }\n\n private parseIfStatement(): Answer {\n this.stream.next();\n\n this.stream.expectPunctuation(\"(\");\n const condition = this.parseOr();\n this.stream.expectPunctuation(\")\");\n\n const whenTrue = this.parseBranch();\n\n if (this.stream.peek()?.value === \"else\") {\n this.stream.next();\n return this.either(condition, whenTrue, this.parseBranch());\n }\n\n // Without an `else`, the statements after the `if` are the other branch\n return this.either(condition, whenTrue, this.parseStatements());\n }\n\n /** One arm of an `if`: a block, or a single statement. */\n private parseBranch(): Answer {\n return this.stream.isPunctuation(\"{\") ? this.parseBlock() : this.parseStatements();\n }\n\n /** A `switch` over one subject, as the disjunction of its cases. */\n private parseSwitchStatement(): Answer {\n this.stream.next();\n\n this.stream.expectPunctuation(\"(\");\n const subject = this.parseValue();\n this.stream.expectPunctuation(\")\");\n this.stream.expectPunctuation(\"{\");\n\n let matching: Expression | null = null;\n let pending: Expression[] = [];\n let everyLabel: Expression[] = [];\n let byDefault: Expression | null = null;\n let anyCaseBroke = false;\n\n while (!this.stream.matchPunctuation(\"}\")) {\n const label = this.stream.next();\n\n if (label.kind !== \"identifier\" || (label.value !== \"case\" && label.value !== \"default\")) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`'${label.value}' inside a switch`));\n }\n\n if (label.value === \"case\") {\n const test = this.buildComparison(subject, COMPARISON_OPERATORS[\"===\"], this.parseValue());\n pending.push(test);\n everyLabel.push(test);\n }\n\n this.stream.expectPunctuation(\":\");\n\n // `case 'a':` with no body of its own runs the next case's body\n if (this.stream.peek()?.value === \"case\" || this.stream.peek()?.value === \"default\") {\n continue;\n }\n\n if (this.stream.peek()?.value === \"break\") {\n this.stream.next();\n this.stream.matchPunctuation(\";\");\n anyCaseBroke = true;\n pending = [];\n continue;\n }\n\n const body = this.parseCaseBody();\n\n if (label.value === \"default\") {\n byDefault = body === NEVER ? null : body;\n continue;\n }\n\n if (body !== NEVER && pending.length > 0) {\n const reached = pending.reduce((left, right) => or(left, right));\n const term = Expression.isEmpty(body) ? reached : and(reached, body);\n\n matching = matching == null ? term : or(matching, term);\n }\n\n pending = [];\n }\n\n // Falling out of the switch continues after it, so the statements there are the default too\n const afterSwitch = byDefault == null && !this.stream.isPunctuation(\"}\") && !this.stream.isAtEnd\n ? this.parseStatements()\n : NEVER;\n\n if (afterSwitch !== NEVER) {\n // A `break` also continues after the switch, so its case would take that answer rather\n // than none — a distinction this rewrite cannot carry\n if (anyCaseBroke) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"a switch that breaks and then falls into more statements\"));\n }\n\n byDefault = afterSwitch;\n }\n\n // A `default` runs only when every case failed, wherever it was written\n if (byDefault != null) {\n const noCaseMatched = everyLabel.length === 0\n ? byDefault\n : and(this.negateExpression(everyLabel.reduce((left, right) => or(left, right))), byDefault);\n\n matching = matching == null ? noCaseMatched : or(matching, noCaseMatched);\n }\n\n return matching ?? NEVER;\n }\n\n /** One case body, and the `break` that may follow its `return`. */\n private parseCaseBody(): Answer {\n const answer = this.parseStatements();\n\n if (this.stream.peek()?.value === \"break\") {\n this.stream.next();\n this.stream.matchPunctuation(\";\");\n }\n\n return answer;\n }\n\n /**\n * The predicate an `if`/`else` answers: `(condition && whenTrue) || (!condition && whenFalse)`,\n * with each case below that form after a constant branch cancels out.\n */\n private either(condition: Expression, whenTrue: Answer, whenFalse: Answer): Answer {\n\n if (whenTrue === NEVER) {\n return whenFalse === NEVER ? NEVER : and(this.negateExpression(condition), whenFalse);\n }\n\n if (whenFalse === NEVER) {\n return and(condition, whenTrue);\n }\n\n if (Expression.isEmpty(whenTrue)) {\n return or(condition, whenFalse);\n }\n\n if (Expression.isEmpty(whenFalse)) {\n return or(this.negateExpression(condition), whenTrue);\n }\n\n return or(and(condition, whenTrue), and(this.negateExpression(condition), whenFalse));\n }\n\n // || binds loosest, so it sits at the root of the parse\n private parseOr(): Expression {\n let left = this.parseAnd();\n\n while (this.stream.matchPunctuation(\"||\")) {\n const right = this.parseAnd();\n\n // A tautology (`true`) absorbs the whole disjunction\n if (Expression.isEmpty(left) || Expression.isEmpty(right)) {\n left = Expression.EMPTY;\n continue;\n }\n\n left = new OperatorExpression({ operator: \"||\", left, right });\n }\n\n return left;\n }\n\n private parseAnd(): Expression {\n let left = this.parseUnary();\n\n while (this.stream.matchPunctuation(\"&&\")) {\n const right = this.parseUnary();\n\n // A tautology (`true`) is the identity of a conjunction\n if (Expression.isEmpty(left)) {\n left = right;\n continue;\n }\n\n if (Expression.isEmpty(right)) {\n continue;\n }\n\n left = new OperatorExpression({ operator: \"&&\", left, right });\n }\n\n return left;\n }\n\n private parseUnary(): Expression {\n if (this.stream.matchPunctuation(\"!\")) {\n return this.negateExpression(this.parseUnary());\n }\n\n return this.parseComparison();\n }\n\n /**\n * Applies `!` to an already-parsed expression: comparators flip their\n * negated flag, compound expressions distribute via De Morgan's laws.\n *\n * Builds a new tree rather than flipping the flag in place, because an `if` uses its condition\n * twice — once negated — and a shared node would carry the flip into both branches.\n */\n private negateExpression(expression: Expression): Expression {\n if (expression instanceof ComparatorExpression) {\n return new ComparatorExpression({\n comparator: expression.comparator,\n negated: !expression.negated,\n strict: expression.strict,\n left: expression.left,\n right: expression.right\n });\n }\n\n if (expression instanceof OperatorExpression && expression.left != null && expression.right != null) {\n return new OperatorExpression({\n operator: expression.operator === \"&&\" ? \"||\" : \"&&\",\n left: this.negateExpression(expression.left),\n right: this.negateExpression(expression.right)\n });\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"'!' on this expression\"));\n }\n\n private parseComparison(): Expression {\n\n /**\n * A parenthesised group is either a boolean sub-expression or a VALUE — `(a && b)` against\n * `(x.name ?? '') === 'ada'` — and which one it is is only known at the closing bracket, by\n * what follows. So the boolean reading is tried first and rewound if a comparator turns up.\n */\n if (this.stream.isPunctuation(\"(\") && this.stream.groupIsValue() === false) {\n this.stream.next();\n\n const expression = this.parseOr();\n this.stream.expectPunctuation(\")\");\n\n return expression;\n }\n\n const left = this.parseValue();\n const operatorToken = this.stream.peek();\n\n if (operatorToken != null && operatorToken.kind === \"punctuation\" && COMPARISON_OPERATORS[operatorToken.value] != null) {\n this.stream.next();\n const right = this.parseValue();\n return this.buildComparison(left, COMPARISON_OPERATORS[operatorToken.value], right);\n }\n\n return this.buildStandalone(left);\n }\n\n /**\n * A value, at JavaScript's precedence.\n *\n * Lowest first: the conditional operator, then nullish coalescing, then the bitwise levels, then\n * the shifts, then the arithmetic. Comparison sits between the shifts and the bitwise levels in\n * JavaScript, but a comparison is a boolean and is handled by `parseComparison` above, so this\n * chain skips it — a bitwise operand here is always a value.\n */\n /**\n * An operand from its own source, sharing this parser's schema and parameter names.\n *\n * A structural dependence found inside propagates outward: the template it belongs to cannot be\n * cached either.\n */\n private parseNested(source: string): Operand {\n const nested = new ExpressionParser(this.schema, new TokenStream(tokenize(source)), this.scope, this.paramsName, this.params);\n const operand = nested.parseInterpolation();\n\n // Leftover tokens mean the interpolation held something this reads only part of. Silently\n // keeping the part it understood is the worst outcome available: `${x.age > 5 ? \"a\" : \"b\"}`\n // would become `x.age`, and the filter would answer a question nobody asked.\n if (nested.stream.isAtEnd === false) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"an interpolation this parser reads only part of\"));\n }\n\n if (nested.structurallyDependsOnParams === true) {\n this.structurallyDependsOnParams = true;\n }\n\n return operand;\n }\n\n /**\n * The whole of one `${…}`.\n *\n * A conditional is read here rather than in `parseValue`, because an interpolation is the one\n * place a conditional appears without brackets around it.\n */\n parseInterpolation(): Operand {\n\n if (this.stream.holdsConditional()) {\n const condition = this.parseOr();\n\n this.stream.expectPunctuation(\"?\");\n const whenTrue = this.parseValue();\n this.stream.expectPunctuation(\":\");\n const whenFalse = this.parseValue();\n\n return { kind: \"conditional\", condition, whenTrue, whenFalse };\n }\n\n return this.parseValue();\n }\n\n parseValue(): Operand {\n return this.parseCoalesce();\n }\n\n private parseCoalesce(): Operand {\n return this.parseBinary(COALESCE_OPERATORS, () => this.parseBitwiseOr());\n }\n\n private parseBitwiseOr(): Operand {\n return this.parseBinary(BITWISE_OR_OPERATORS, () => this.parseBitwiseXor());\n }\n\n private parseBitwiseXor(): Operand {\n return this.parseBinary(BITWISE_XOR_OPERATORS, () => this.parseBitwiseAnd());\n }\n\n private parseBitwiseAnd(): Operand {\n return this.parseBinary(BITWISE_AND_OPERATORS, () => this.parseShift());\n }\n\n private parseShift(): Operand {\n return this.parseBinary(SHIFT_OPERATORS, () => this.parseAdditive());\n }\n\n private parseAdditive(): Operand {\n return this.parseBinary(ADDITIVE_OPERATORS, () => this.parseMultiplicative());\n }\n\n private parseMultiplicative(): Operand {\n return this.parseBinary(MULTIPLICATIVE_OPERATORS, () => this.parseExponent());\n }\n\n /** `**` is RIGHT-associative: `2 ** 3 ** 2` is 2 ** 9, not 8 ** 2. */\n private parseExponent(): Operand {\n const left = this.parseOperand();\n\n if (this.stream.isPunctuation(\"**\") === false) {\n return left;\n }\n\n this.stream.next();\n\n return { kind: \"arithmetic\", call: \"power\", left, right: this.parseExponent() };\n }\n\n /** Left-associative, so `a - b - c` is `(a - b) - c` rather than `a - (b - c)`. */\n private parseBinary(operators: Record<string, Call>, next: () => Operand): Operand {\n let left = next();\n\n for (;;) {\n const token = this.stream.peek();\n\n if (token == null || token.kind !== \"punctuation\" || operators[token.value] == null) {\n return left;\n }\n\n this.stream.next();\n left = { kind: \"arithmetic\", call: operators[token.value], left, right: next() };\n }\n }\n\n private parseOperand(): Operand {\n const token = this.stream.peek();\n\n if (token == null) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unexpected end of expression\"));\n }\n\n if (token.kind === \"string\") {\n this.stream.next();\n return this.withValueTransformer({ kind: \"value\", value: token.value, transformer: null, locale: null });\n }\n\n if (token.kind === \"number\") {\n this.stream.next();\n return { kind: \"value\", value: Number(token.value), transformer: null, locale: null };\n }\n\n // A parenthesised VALUE — `(x.price & 1)`, `(x.name ?? '')`. The boolean reading of a group\n // is handled in parseComparison; by the time an operand sees one it is arithmetic.\n if (token.kind === \"punctuation\" && token.value === \"(\") {\n const conditional = this.stream.groupHoldsConditional();\n\n this.stream.next();\n\n if (conditional === true) {\n const condition = this.parseOr();\n\n this.stream.expectPunctuation(\"?\");\n const whenTrue = this.parseValue();\n this.stream.expectPunctuation(\":\");\n const whenFalse = this.parseValue();\n this.stream.expectPunctuation(\")\");\n\n return { kind: \"conditional\", condition, whenTrue, whenFalse };\n }\n\n const inner = this.parseValue();\n this.stream.expectPunctuation(\")\");\n\n const grouped = inner.kind === \"arithmetic\" ? { ...inner, grouped: true } as Operand : inner;\n\n return this.withGroupCall(grouped);\n }\n\n /**\n * A template with interpolation, folded into `concat`.\n *\n * Each `${…}` was kept as source by the tokenizer and is parsed by its own stream, so it can\n * hold anything an operand can — a property, a param, arithmetic, another template. Empty\n * chunks are dropped: `${a}${b}` is two operands, not two operands and three empty strings.\n */\n if (token.kind === \"template\") {\n this.stream.next();\n\n const { chunks, expressions } = JSON.parse(token.value) as { chunks: string[], expressions: string[] };\n const pieces: Operand[] = [];\n\n for (let at = 0; at < chunks.length; at++) {\n if (chunks[at].length > 0) {\n pieces.push({ kind: \"value\", value: chunks[at], transformer: null, locale: null });\n }\n\n if (at < expressions.length) {\n pieces.push(this.parseNested(expressions[at]));\n }\n }\n\n if (pieces.length === 0) {\n return { kind: \"value\", value: \"\", transformer: null, locale: null };\n }\n\n // One piece and no chunk means no concat to do the coercion, so the conversion has to be\n // explicit: `` `${x.age}` `` is the STRING \"9\", not the number 9.\n if (pieces.length === 1) {\n const only = pieces[0];\n const alreadyText = only.kind === \"value\" && typeof only.value === \"string\";\n\n return alreadyText ? only : { kind: \"arithmetic\", call: \"to-string\", left: only, right: noArgument() };\n }\n\n return pieces.reduce((left, right) => ({ kind: \"arithmetic\", call: \"concat\", left, right }));\n }\n\n if (token.kind === \"bigint\") {\n this.stream.next();\n return { kind: \"value\", value: BigInt(token.value), transformer: null, locale: null };\n }\n\n if (token.kind === \"regex\") {\n this.stream.next();\n\n const [source, flags] = token.value.split(\"\\u0000\");\n const pattern: ValueOperand = { kind: \"value\", value: new RegExp(source, flags), transformer: null, locale: null };\n\n // `/^a/.test(x.name)` — the pattern is the literal, the subject is the argument, and the\n // tree puts them the other way round: the property is what the call applies to.\n if (this.stream.isPunctuation(\".\")) {\n const method = this.stream.peek(1);\n\n if (method != null && method.kind === \"identifier\" && method.value === \"test\") {\n this.stream.next();\n this.stream.next();\n this.stream.expectPunctuation(\"(\");\n\n const subject = this.parseValue();\n this.stream.expectPunctuation(\")\");\n\n return { kind: \"arithmetic\", call: \"matches\", left: subject, right: pattern };\n }\n }\n\n return pattern;\n }\n\n if (token.kind === \"punctuation\" && token.value === \"~\") {\n this.stream.next();\n\n // Unary, so the tree carries the operand and no argument\n return { kind: \"arithmetic\", call: \"bit-not\", left: this.parseOperand(), right: noArgument() };\n }\n\n if (token.kind === \"punctuation\" && token.value === \"-\") {\n this.stream.next();\n const numberToken = this.stream.next();\n\n if (numberToken.kind !== \"number\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"unary '-' on a non-number\"));\n }\n\n return { kind: \"value\", value: -Number(numberToken.value), transformer: null, locale: null };\n }\n\n if (token.kind === \"punctuation\" && token.value === \"[\") {\n return this.parseArrayLiteralOperand();\n }\n\n if (token.kind === \"identifier\") {\n return this.parseIdentifierOperand();\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(String(token.value)));\n }\n\n /**\n * Parses an inline array of literals, e.g. `[\"active\", \"pending\"]`, and the\n * membership test that follows it: `[...].includes(entity.property)`.\n */\n private parseArrayLiteralOperand(): Operand {\n this.stream.expectPunctuation(\"[\");\n const elements: unknown[] = [];\n\n while (!this.stream.isPunctuation(\"]\")) {\n const element = this.parseOperand();\n\n if (element.kind !== \"value\" || element.transformer != null) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"a non-literal element in an array literal\"));\n }\n\n elements.push(element.value);\n\n if (!this.stream.matchPunctuation(\",\")) {\n break;\n }\n }\n\n this.stream.expectPunctuation(\"]\");\n\n const array: ValueOperand = { kind: \"value\", value: elements, transformer: null, locale: null };\n\n // The only supported use is a membership test on a schema property\n if (this.stream.isPunctuation(\".\") || this.stream.isPunctuation(\"?.\")) {\n this.stream.next();\n const method = this.stream.next();\n\n if (method.kind !== \"identifier\" || method.value !== \"includes\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`'.${method.value}' on an array literal`));\n }\n\n this.stream.expectPunctuation(\"(\");\n const argument = this.parseOperand();\n this.stream.expectPunctuation(\")\");\n\n if (argument.kind === \"method-call\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"nested method call inside .includes()\"));\n }\n\n if (argument.kind === \"arithmetic\" || argument.kind === \"conditional\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"arithmetic inside .includes()\"));\n }\n\n return { kind: \"method-call\", target: array, method: \"includes\", argument };\n }\n\n return array;\n }\n\n private parseIdentifierOperand(): Operand {\n const root = this.stream.next().value;\n\n // Keyword literals\n if (root === \"true\" || root === \"false\") {\n return { kind: \"value\", value: root === \"true\", transformer: null, locale: null };\n }\n\n if (root === \"null\") {\n return { kind: \"value\", value: null, transformer: null, locale: null };\n }\n\n if (root === \"undefined\") {\n return { kind: \"value\", value: undefined, transformer: null, locale: null };\n }\n\n if (root === \"void\") {\n this.stream.next(); // the '0'\n return { kind: \"value\", value: undefined, transformer: null, locale: null };\n }\n\n const binding = this.scope.get(root);\n\n if (binding != null) {\n if (binding.kind === \"inlined\") {\n this.stream.splice(binding.tokens);\n return this.parseOperand();\n }\n\n return this.parseChain({ kind: binding.kind, path: [...binding.path] });\n }\n\n // A bare variable from the outer scope — its value cannot be derived from source text\n throw new Error(ERROR_MESSAGES.VARIABLE_VALUE(root));\n }\n\n /**\n * Parses the segments after an entity/params root: dot access, bracket\n * access, transform methods and comparator methods.\n */\n private parseChain(options: { kind: \"property\" | \"param\", path: string[] }): Operand {\n const path = options.path;\n let transformer: Transformer | null = null;\n let locale: string | null = null;\n\n while (true) {\n if (this.stream.matchPunctuation(\".\") || this.stream.matchPunctuation(\"?.\")) {\n const segment = this.stream.next();\n\n if (segment.kind !== \"identifier\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`'.${segment.value}'`));\n }\n\n // Method call\n if (this.stream.isPunctuation(\"(\")) {\n const method = segment.value;\n\n if (TRANSFORM_METHODS[method] != null) {\n this.stream.expectPunctuation(\"(\");\n this.stream.expectPunctuation(\")\");\n transformer = TRANSFORM_METHODS[method].transformer;\n locale = TRANSFORM_METHODS[method].locale;\n continue;\n }\n\n if (COMPARATOR_METHODS[method] != null) {\n this.stream.expectPunctuation(\"(\");\n const argument = this.parseOperand();\n this.stream.expectPunctuation(\")\");\n\n if (argument.kind === \"method-call\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`nested method call inside .${method}()`));\n }\n\n if (argument.kind === \"arithmetic\" || argument.kind === \"conditional\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`arithmetic inside .${method}()`));\n }\n\n return {\n kind: \"method-call\",\n target: this.resolveChain(options.kind, path, transformer, locale),\n method: method as MethodCallOperand[\"method\"],\n argument\n };\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`method '.${method}()'`));\n }\n\n if (transformer != null) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"property access after a transform method\"));\n }\n\n path.push(segment.value);\n continue;\n }\n\n if (this.stream.matchPunctuation(\"[\")) {\n path.push(this.parseBracketSegment(options.kind));\n this.stream.expectPunctuation(\"]\");\n continue;\n }\n\n break;\n }\n\n return this.resolveChain(options.kind, path, transformer, locale);\n }\n\n private parseBracketSegment(kind: \"property\" | \"param\"): string {\n const token = this.stream.next();\n\n // Literal segment: entity[\"name\"]\n if (token.kind === \"string\") {\n return token.value;\n }\n\n // Param-driven segment: entity[p.name] — the property depends on the\n // param VALUE, so the resulting template is tied to these params.\n // Stryker disable next-line all: documented equivalent cluster (see\n // docs/mutation-backlog.md) — every mutation of this four-conjunct guard reroutes\n // bracket access between two paths that both collapse to NOT_PARSABLE; the\n // experiment recorded there aimed 30 tests at this line and killed none.\n const binding = token.kind === \"identifier\" ? this.scope.get(token.value) : undefined;\n\n if (kind === \"property\" && binding != null && binding.kind === \"param\") {\n const paramPath: string[] = [...binding.path];\n\n while (this.stream.matchPunctuation(\".\") || this.stream.matchPunctuation(\"?.\")) {\n paramPath.push(this.stream.next().value);\n }\n\n const resolved = resolveParamPath(this.paramsName ?? token.value, paramPath, this.params);\n\n if (typeof resolved !== \"string\") {\n throw new ParamDependentParseError(ERROR_MESSAGES.PROPERTY_NOT_FOUND(paramPath.join(\".\")));\n }\n\n this.structurallyDependsOnParams = true;\n return resolved;\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`bracket access '[${token.value}]'`));\n }\n\n private resolveChain(kind: \"property\" | \"param\", path: string[], transformer: Transformer | null, locale: string | null): PropertyOperand | ParamOperand {\n\n if (kind === \"param\") {\n if (path.length === 0) {\n // `params` alone is a variable, not a value we can resolve\n throw new Error(ERROR_MESSAGES.PARAM_PATH_NOT_FOUND(this.paramsName ?? \"params\", this.params));\n }\n\n return { kind: \"param\", path, transformer, locale };\n }\n\n const pathString = path.join(\".\");\n const property = this.schema.properties.find(w => w.getAssignmentPath() == pathString);\n\n if (property == null) {\n // `.length` on a string/array property — a real schema property named\n // `length` wins (checked above); otherwise treat it as a transformer\n if (path.length > 1 && path[path.length - 1] === \"length\" && transformer == null) {\n const parentPath = path.slice(0, -1).join(\".\");\n const parent = this.schema.properties.find(w => w.getAssignmentPath() == parentPath);\n\n // Vector is deliberately absent. Its length is the dimension count declared\n // in the schema — a constant, not data — so a filter on it answers a question\n // nobody asks, and pushing it down would need `json_array_length` on a\n // backend storing JSON and something else entirely on one with a native\n // vector column. Not parsing it leaves a clear error instead of a dialect gap.\n if (parent != null && (parent.type === SchemaTypes.String || parent.type === SchemaTypes.Array)) {\n return { kind: \"property\", property: parent, transformer: \"length\", locale: null };\n }\n }\n\n throw new Error(ERROR_MESSAGES.PROPERTY_NOT_FOUND(pathString));\n }\n\n return { kind: \"property\", property, transformer, locale };\n }\n\n /**\n * A call on a parenthesised value: `(x.name).toLowerCase()`, `(x.age + 1).length`. Any operand can\n * receive one here, unlike a property chain, which carries at most one transform.\n */\n private withGroupCall(operand: Operand): Operand {\n let receiver = operand;\n\n while (this.stream.isPunctuation(\".\") || this.stream.isPunctuation(\"?.\")) {\n const segment = this.stream.peek(1);\n\n if (segment == null || segment.kind !== \"identifier\") {\n break;\n }\n\n if (segment.value === \"length\" && !this.stream.isPunctuation(\"(\", 2)) {\n this.stream.next();\n this.stream.next();\n\n receiver = { kind: \"arithmetic\", call: \"length\", left: receiver, right: noArgument() };\n continue;\n }\n\n const transform = TRANSFORM_METHODS[segment.value];\n\n if (transform != null) {\n this.stream.next();\n this.stream.next();\n this.stream.expectPunctuation(\"(\");\n this.stream.expectPunctuation(\")\");\n\n receiver = {\n kind: \"arithmetic\",\n call: transform.transformer,\n left: receiver,\n right: transform.locale == null ? noArgument() : { kind: \"value\", value: transform.locale, transformer: null, locale: null }\n };\n continue;\n }\n\n // A comparator method needs a property target, which only an ungrouped chain produces\n if (COMPARATOR_METHODS[segment.value] != null && receiver.kind === \"property\") {\n this.stream.next();\n this.stream.next();\n this.stream.expectPunctuation(\"(\");\n const argument = this.parseOperand();\n this.stream.expectPunctuation(\")\");\n\n if (argument.kind !== \"property\" && argument.kind !== \"value\" && argument.kind !== \"param\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`'.${segment.value}()' on that argument`));\n }\n\n return { kind: \"method-call\", target: receiver, method: segment.value as MethodCallOperand[\"method\"], argument };\n }\n\n break;\n }\n\n return receiver;\n }\n\n private withValueTransformer(operand: ValueOperand): ValueOperand {\n if (this.stream.isPunctuation(\".\")) {\n const method = this.stream.peek(1);\n\n // Stryker disable next-line all: documented equivalent cluster (see\n // docs/mutation-backlog.md) — the guard's conjuncts each route to a rejection that\n // collapses to NOT_PARSABLE with an indistinguishable message; 18 targeted tests\n // killed none of these.\n if (method != null && method.kind === \"identifier\" && TRANSFORM_METHODS[method.value] != null) {\n this.stream.next(); // .\n this.stream.next(); // method name\n this.stream.expectPunctuation(\"(\");\n this.stream.expectPunctuation(\")\");\n\n operand.transformer = TRANSFORM_METHODS[method.value].transformer;\n operand.locale = TRANSFORM_METHODS[method.value].locale;\n }\n }\n\n return operand;\n }\n\n // #region Condition building\n\n private buildComparison(left: Operand, operator: { comparator: Comparator, negated: boolean, strict: boolean }, right: Operand): Expression {\n\n // methodCall == true/false — fold the boolean into negation\n if (left.kind === \"method-call\") {\n if (operator.comparator === \"equals\" && right.kind === \"value\" && typeof right.value === \"boolean\") {\n const comparator = this.buildMethodComparator(left);\n const comparedToFalse = right.value === false;\n comparator.negated = comparator.negated !== (operator.negated !== comparedToFalse);\n return comparator;\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"comparing a method call to a non-boolean\"));\n }\n\n if (right.kind === \"method-call\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"method call on the right side of a comparison\"));\n }\n\n if (needsBrackets(left) || needsBrackets(right)) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\n \"a bitwise or nullish operator compared without brackets, which JavaScript reads the other way round\"\n ));\n }\n\n if (left.kind === \"arithmetic\" || right.kind === \"arithmetic\" || left.kind === \"conditional\" || right.kind === \"conditional\") {\n if (containsProperty(left) === false && containsProperty(right) === false) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"arithmetic that references no schema property\"));\n }\n\n return new ComparatorExpression({\n comparator: operator.comparator,\n negated: operator.negated,\n strict: operator.strict,\n left: this.createOperandExpression(left),\n right: this.createOperandExpression(right)\n });\n }\n\n if (left.kind === \"property\" && right.kind === \"property\") {\n return new ComparatorExpression({\n comparator: operator.comparator,\n negated: operator.negated,\n strict: operator.strict,\n left: this.createPropertyExpression(left),\n right: this.createPropertyExpression(right)\n });\n }\n\n // Only a loose comparison coerces. `===` records `strict` and honouring it is the point.\n if (left.kind === \"property\" && right.kind !== \"property\") {\n return this.buildPropertyComparator(left, operator, right, /* applyConverter */ !operator.strict);\n }\n\n if (right.kind === \"property\" && left.kind !== \"property\") {\n const swapped = { ...operator, comparator: SWAPPED_COMPARATORS[operator.comparator] };\n return this.buildPropertyComparator(right, swapped, left, /* applyConverter */ !operator.strict);\n }\n\n const settled = this.settleConstantComparison(left, operator, right);\n\n if (settled != null) {\n return settled;\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"comparison requires a schema property on at least one side\"));\n }\n\n /**\n * The answer a comparison of two constants gives, when that answer is `true`. The other answer\n * excludes every row, which has no expression node.\n */\n private settleConstantComparison(left: Operand, operator: { comparator: Comparator, negated: boolean, strict: boolean }, right: Operand): Expression | null {\n const leftValue = this.constantOf(left);\n const rightValue = this.constantOf(right);\n\n if (leftValue === UNKNOWN_UNTIL_ROW || rightValue === UNKNOWN_UNTIL_ROW) {\n return null;\n }\n\n const answer = evaluate(new ComparatorExpression({\n comparator: operator.comparator,\n negated: operator.negated,\n strict: operator.strict,\n left: new ValueExpression({ value: leftValue }),\n right: new ValueExpression({ value: rightValue })\n }), {});\n\n if (answer === true) {\n return Expression.EMPTY;\n }\n\n // Params decided this, so the refusal must not be cached against the source: the same filter\n // with other params can be a tautology.\n if (left.kind === \"param\" || right.kind === \"param\") {\n throw new ParamDependentParseError(ERROR_MESSAGES.UNSUPPORTED(\"a params comparison no row satisfies\"));\n }\n\n return null;\n }\n\n /** The value an operand holds already, for the operands that do not depend on a row. */\n private constantOf(operand: Operand): unknown {\n if (operand.kind === \"value\" && operand.transformer == null) {\n return operand.value;\n }\n\n if (operand.kind === \"param\" && operand.transformer == null) {\n this.structurallyDependsOnParams = true;\n return resolveParamPath(this.paramsName ?? \"params\", operand.path, this.params);\n }\n\n return UNKNOWN_UNTIL_ROW;\n }\n\n private buildStandalone(operand: Operand): Expression {\n\n if (operand.kind === \"method-call\") {\n return this.buildMethodComparator(operand);\n }\n\n if (operand.kind === \"property\") {\n // Truthy shorthand on `.length`: a length is truthy exactly when > 0\n if (operand.transformer === \"length\") {\n return this.buildPropertyComparator(operand, COMPARISON_OPERATORS[\">\"], { kind: \"value\", value: 0, transformer: null, locale: null }, /* applyConverter */ true);\n }\n\n // Truthy shorthand: `w.isActive` → isActive === true\n return this.buildPropertyComparator(operand, COMPARISON_OPERATORS[\"===\"], { kind: \"value\", value: true, transformer: null, locale: null }, /* applyConverter */ true);\n }\n\n // A boolean-valued call standing alone IS the predicate\n if (operand.kind === \"arithmetic\" && operand.call === \"matches\") {\n return new ComparatorExpression({\n comparator: \"equals\",\n negated: false,\n strict: false,\n left: this.createOperandExpression(operand),\n right: new ValueExpression({ value: true })\n });\n }\n\n if (operand.kind === \"arithmetic\" || operand.kind === \"conditional\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"arithmetic used as a condition rather than compared\"));\n }\n\n // Constant `true` — a tautology, which parseAnd/parseOr simplify away\n if (operand.kind === \"value\" && operand.value === true && operand.transformer == null) {\n return Expression.EMPTY;\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"a filter condition must reference a schema property\"));\n }\n\n private buildMethodComparator(operand: MethodCallOperand): ComparatorExpression {\n const { target, method, argument } = operand;\n\n if (target.kind === \"property\") {\n if (argument.kind === \"property\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`.${method}() comparing two schema properties`));\n }\n\n // Method arguments skip type conversion — only the value serializer applies\n return this.buildPropertyComparator(target, { comparator: COMPARATOR_METHODS[method], negated: false, strict: false }, argument, /* applyConverter */ false);\n }\n\n // [\"a\", \"b\"].includes(x.prop) / params.list.includes(x.prop) —\n // membership test with the collection on the left\n if (method === \"includes\" && argument.kind === \"property\") {\n if (target.transformer != null) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"transform method on a collection used with .includes()\"));\n }\n\n return new ComparatorExpression({\n comparator: \"includes\",\n negated: false,\n strict: false,\n left: this.createValueExpression(target, argument.property, /* applyConverter */ false),\n right: this.createPropertyExpression(argument)\n });\n }\n\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`.${method}() on a non-property target`));\n }\n\n private buildPropertyComparator(property: PropertyOperand, operator: { comparator: Comparator, negated: boolean, strict: boolean }, value: ValueOperand | ParamOperand, applyConverter: boolean): ComparatorExpression {\n\n const isStringMatch = operator.comparator === \"starts-with\" || operator.comparator === \"ends-with\" || operator.comparator === \"includes\";\n\n // `.length` compares a NUMBER, so the paired property's serializer and\n // type converter must not touch the value; and a length has no meaning\n // inside a string-matching comparator\n if (property.transformer === \"length\") {\n if (isStringMatch) {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"'.length' with startsWith/endsWith/includes\"));\n }\n\n return new ComparatorExpression({\n comparator: operator.comparator,\n negated: operator.negated,\n strict: operator.strict,\n left: this.createPropertyExpression(property),\n right: this.createValueExpression(value, null, /* applyConverter */ false)\n });\n }\n\n return new ComparatorExpression({\n comparator: operator.comparator,\n negated: operator.negated,\n strict: operator.strict,\n left: this.createPropertyExpression(property),\n right: this.createValueExpression(value, property.property, applyConverter)\n });\n }\n\n /**\n * Any operand as an expression.\n *\n * Values inside arithmetic take no paired property: the result is a computed number, so the\n * property's serializer and type converter do not describe it — the same reason `.length` skips\n * them.\n */\n private createOperandExpression(operand: Operand): Expression {\n\n if (operand.kind === \"conditional\") {\n return new CallExpression({\n call: \"conditional\",\n expression: operand.condition,\n arguments: [this.createOperandExpression(operand.whenTrue), this.createOperandExpression(operand.whenFalse)]\n });\n }\n\n if (operand.kind === \"arithmetic\") {\n return new CallExpression({\n call: operand.call,\n expression: this.createOperandExpression(operand.left),\n arguments: operand.right === NO_ARGUMENT\n ? []\n : operand.extra == null\n ? [this.createOperandExpression(operand.right)]\n : [this.createOperandExpression(operand.right), this.createOperandExpression(operand.extra)]\n });\n }\n\n if (operand.kind === \"property\") {\n return this.createPropertyExpression(operand);\n }\n\n if (operand.kind === \"method-call\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(\"a method call inside arithmetic\"));\n }\n\n return this.createValueExpression(operand, null, /* applyConverter */ false);\n }\n\n private createPropertyExpression(operand: PropertyOperand): Expression {\n return asCall(new PropertyExpression({ property: operand.property }), operand.transformer, operand.locale);\n }\n\n private createValueExpression(operand: ValueOperand | ParamOperand, pairedProperty: PropertyInfo<any> | null, applyConverter: boolean): Expression {\n\n if (operand.kind === \"param\") {\n return asCall(\n new ParamReferenceExpression({ paramPath: operand.path, pairedProperty, applyConverter }),\n operand.transformer,\n operand.locale\n );\n }\n\n const expression = new ValueExpression({ value: resolvePairedValue(operand.value, pairedProperty, applyConverter) });\n\n return asCall(expression, operand.transformer, operand.locale);\n }\n\n // #endregion\n}\n\n// #endregion\n\n// #region Template binding\n\n/**\n * Deep-clones a template into a consumer-facing tree, resolving parameter\n * placeholders against the supplied params. Always clones so cached templates\n * can never be mutated by consumers.\n */\nconst bindExpression = (expression: Expression, paramsName: string | null, params: unknown): Expression => {\n\n if (expression instanceof ParamReferenceExpression) {\n const raw = resolveParamPath(paramsName ?? \"params\", expression.paramPath, params);\n\n return new ValueExpression({ value: resolvePairedValue(raw, expression.pairedProperty, expression.applyConverter) });\n }\n\n if (expression instanceof ValueExpression) {\n return new ValueExpression({ value: expression.value });\n }\n\n if (expression instanceof PropertyExpression) {\n return new PropertyExpression({ property: expression.property });\n }\n\n if (expression instanceof ComparatorExpression) {\n return new ComparatorExpression({\n comparator: expression.comparator,\n negated: expression.negated,\n strict: expression.strict,\n left: expression.left ? bindExpression(expression.left, paramsName, params) : undefined,\n right: expression.right ? bindExpression(expression.right, paramsName, params) : undefined\n });\n }\n\n if (expression instanceof OperatorExpression) {\n return new OperatorExpression({\n operator: expression.operator,\n left: expression.left ? bindExpression(expression.left, paramsName, params) : undefined,\n right: expression.right ? bindExpression(expression.right, paramsName, params) : undefined\n });\n }\n\n if (expression instanceof CallExpression) {\n return new CallExpression({\n call: expression.call,\n expression: bindExpression(expression.expression, paramsName, params),\n arguments: expression.arguments.map(argument => bindExpression(argument, paramsName, params)),\n });\n }\n\n return expression;\n}\n\n/**\n * Wraps an operand in the call a transform method named, if there was one.\n *\n * `Transformer` and `Call` share these three names, so the transform IS the call name. A locale\n * becomes the call's first argument, which is where it belongs — it qualifies the casing, not the\n * property.\n */\nconst asCall = (inner: Expression, transformer: Transformer | null, locale: string | null): Expression => {\n\n if (transformer == null) {\n return inner;\n }\n\n return new CallExpression({\n call: transformer,\n expression: inner,\n arguments: locale == null ? [] : [new ValueExpression({ value: locale })],\n });\n};\n\n// #endregion\n\n// #region Function source handling\n\n/** What an identifier in a filter body stands for. */\ntype Binding =\n | { kind: \"property\", path: string[] }\n | { kind: \"param\", path: string[] }\n | { kind: \"inlined\", tokens: Token[] };\n\ntype Scope = Map<string, Binding>;\n\ntype FunctionShape = {\n scope: Scope;\n paramsName: string | null;\n body: string;\n}\n\n/** Binds every name a destructuring pattern introduces to the path it reads. */\nconst bindPattern = (stream: TokenStream, kind: \"property\" | \"param\", path: string[], scope: Scope): void => {\n\n if (!stream.matchPunctuation(\"{\")) {\n const name = stream.next();\n\n if (name.kind !== \"identifier\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`parameter '${name.value}'`));\n }\n\n scope.set(name.value, { kind, path });\n return;\n }\n\n while (!stream.matchPunctuation(\"}\")) {\n const key = stream.next();\n\n if (key.kind !== \"identifier\") {\n throw new Error(ERROR_MESSAGES.UNSUPPORTED(`destructured key '${key.value}'`));\n }\n\n if (stream.matchPunctuation(\":\")) {\n bindPattern(stream, kind, [...path, key.value], scope);\n } else {\n scope.set(key.value, { kind, path: [...path, key.value] });\n }\n\n if (!stream.matchPunctuation(\",\")) {\n stream.expectPunctuation(\"}\");\n return;\n }\n }\n}\n\n/** Reads a filter's parameter list — the entity alone, or the `[entity, params]` pair — into a scope. */\nconst buildScope = (parameterNames: string, hasParams: boolean): { scope: Scope, paramsName: string | null } => {\n\n const stream = new TokenStream(tokenize(parameterNames));\n const scope: Scope = new Map();\n\n if (!stream.matchPunctuation(\"[\")) {\n bindPattern(stream, \"property\", [], scope);\n return { scope, paramsName: null };\n }\n\n bindPattern(stream, \"property\", [], scope);\n\n if (hasParams && stream.matchPunctuation(\",\") && !stream.isPunctuation(\"]\")) {\n bindPattern(stream, \"param\", [], scope);\n }\n\n return { scope, paramsName: wholeParamsName(scope) };\n}\n\n/** The name the whole params object was given, when it was not destructured. Error messages only. */\nconst wholeParamsName = (scope: Scope): string | null => {\n for (const [name, binding] of scope) {\n if (binding.kind === \"param\" && binding.path.length === 0) {\n return name;\n }\n }\n\n return null;\n}\n\n/**\n * Splits stringified filter source into parameter names and the expression\n * body, unwrapping single-return block bodies.\n */\nconst resolveFunctionShape = (stringifiedFunction: string, hasParams: boolean): FunctionShape => {\n\n const source = stringifiedFunction.trim();\n\n let parameterNames: string;\n let body: string;\n\n // `function (x) { ... }` / `function name(x) { ... }` — what ES5-targeting\n // transpilers rewrite every arrow filter into\n const functionHead = /^function\\b[^(]*\\(/.exec(source);\n\n if (functionHead != null) {\n const parametersEnd = source.indexOf(\")\", functionHead[0].length);\n\n if (parametersEnd === -1) {\n throw new Error(\"Invalid Function\");\n }\n\n parameterNames = source.slice(functionHead[0].length, parametersEnd).trim();\n body = source.slice(parametersEnd + 1).trim();\n } else {\n const arrowIndex = source.indexOf(\"=>\");\n\n if (arrowIndex === -1) {\n throw new Error(\"Invalid Function\");\n }\n\n parameterNames = source.substring(0, arrowIndex).trim();\n body = source.substring(arrowIndex + 2).trim();\n\n // Strip wrapping parens: (entity) or ([x, p])\n if (parameterNames.startsWith(\"(\") && parameterNames.endsWith(\")\")) {\n parameterNames = parameterNames.slice(1, -1).trim();\n }\n }\n\n if (parameterNames.length === 0) {\n throw new Error(\"Invalid Function\");\n }\n\n const { scope, paramsName } = buildScope(parameterNames, hasParams);\n\n return { scope, paramsName, body };\n}\n\n// #endregion\n\n// #region Cache\n\ntype ParsedTemplate = {\n template: Expression;\n paramsName: string | null;\n}\n\n// Keyed by schema instance so identical filter source on different schemas can\n// never collide; entries live only as long as the schema does\nconst templateCache = new WeakMap<CompiledSchema<any>, Map<string, ParsedTemplate>>();\nconst MAX_CACHED_TEMPLATES_PER_SCHEMA = 1024;\n\nconst getCachedTemplate = (schema: CompiledSchema<any>, source: string): ParsedTemplate | null => {\n return templateCache.get(schema)?.get(source) ?? null;\n}\n\nconst setCachedTemplate = (schema: CompiledSchema<any>, source: string, entry: ParsedTemplate) => {\n let bySource = templateCache.get(schema);\n\n if (bySource == null) {\n bySource = new Map<string, ParsedTemplate>();\n templateCache.set(schema, bySource);\n }\n\n // Filter source strings come from static code, so this cap should never be\n // hit in practice — it only guards against unbounded dynamic generation.\n // Stryker disable next-line all: the cap is a pure resource bound — every mutation of\n // it (never clear, always clear, off-by-one) parses identically and differs only in\n // memory growth, which no observable boundary can assert.\n if (bySource.size >= MAX_CACHED_TEMPLATES_PER_SCHEMA) {\n bySource.clear();\n }\n\n bySource.set(source, entry);\n}\n\n// #endregion\n\nexport const combineExpressions = (...expressions: Expression[]): Expression => {\n\n if (expressions.length === 0) {\n throw new Error(\"combineExpressions requires at least 1 expression\");\n }\n\n\n if (expressions.length === 1) {\n return expressions[0];\n }\n\n // Start with the first expression\n let result = expressions[0];\n\n // Loop through remaining expressions and combine them\n for (let i = 1; i < expressions.length; i++) {\n result = new OperatorExpression({\n operator: \"&&\",\n left: result,\n right: expressions[i]\n });\n }\n\n return result;\n};\n\n/**\n * Parses an expression SOURCE FRAGMENT against one schema and one root name.\n *\n * `toExpression` starts from a function and works out its own roots. This starts from text, which\n * is what a caller has when it has split a larger predicate apart — `p.rank > 10` lifted out of\n * `([p, m]) => p.rank > 10 && m.won === true`.\n *\n * **A fragment naming anything other than `rootName` returns `NOT_PARSABLE`, and that is the\n * point.** It is how a caller discovers which side of a join a conjunct belongs to: parse it\n * against each side in turn, and exactly one succeeds for a single-side condition. A condition\n * spanning both fails against both, which is the correct answer — it cannot be pushed to either.\n *\n * No params: a fragment carrying a params reference has no bag to resolve it against here, so it\n * fails rather than binding to nothing.\n *\n * Deliberately NOT cached. The cache is keyed by function source, and a fragment is not a function\n * — two different lambdas can contain the same fragment text against different schemas.\n */\nexport const parseFragment = (schema: CompiledSchema<any>, body: string, rootName: string): Expression => {\n try {\n const stream = new TokenStream(tokenize(body));\n const scope: Scope = new Map([[rootName, { kind: \"property\", path: [] }]]);\n const parser = new ExpressionParser(schema, stream, scope, null, undefined);\n\n return foldConstantCalls(parser.parse());\n } catch {\n // The failure is expected and informative — see above — so it is not logged. A caller that\n // parses one conjunct against two schemas would otherwise warn on every successful split.\n return Expression.NOT_PARSABLE;\n }\n};\n\n/** What the parser refused, from a throw that may not be an `Error`. */\nconst refusalOf = (error: unknown): string =>\n error instanceof Error ? error.message : String(error);\n\nexport const toExpression = <T extends any, P extends any>(schema: CompiledSchema<any>, fn: Filter<T> | ParamsFilter<T, P>, params?: P) => {\n const stringifiedFunction = fn.toString();\n\n const warn = (error: unknown) => logger.warn(\"Error parsing expression\", {\n error,\n collectionName: schema.collectionName,\n params,\n selector: stringifiedFunction\n });\n\n const cached = getCachedTemplate(schema, stringifiedFunction);\n\n if (cached != null) {\n // A cached failure — the warning was already logged when it was discovered. The template\n // carries what was refused, and `.explain()` is usually called once the cache is warm.\n if (Expression.isNotParsable(cached.template)) {\n return cached.template;\n }\n\n try {\n return foldConstantCalls(bindExpression(cached.template, cached.paramsName, params));\n } catch (error) {\n // Binding failures are param-dependent by nature — never cached\n warn(error);\n return Expression.notParsable(refusalOf(error));\n }\n }\n\n let paramsName: string | null = null;\n let template: Expression;\n let structurallyDependsOnParams: boolean;\n\n try {\n const shape = resolveFunctionShape(stringifiedFunction, params != null);\n const stream = new TokenStream(tokenize(shape.body));\n const parser = new ExpressionParser(schema, stream, shape.scope, shape.paramsName, params);\n paramsName = shape.paramsName;\n template = parser.parseBody();\n structurallyDependsOnParams = parser.structurallyDependsOnParams;\n } catch (error) {\n // Cache the failure so a hot query on an unsupported filter doesn't\n // re-parse and re-warn on every execution. Param-dependent failures are\n // exempt: the same source can succeed with different params.\n const refused = Expression.notParsable(refusalOf(error));\n\n if (!(error instanceof ParamDependentParseError)) {\n setCachedTemplate(schema, stringifiedFunction, { template: refused, paramsName: null });\n }\n\n warn(error);\n return refused;\n }\n\n // Templates whose structure was resolved from param values are only\n // valid for this exact params object — parse those fresh every time\n if (!structurallyDependsOnParams) {\n setCachedTemplate(schema, stringifiedFunction, { template, paramsName });\n }\n\n try {\n return foldConstantCalls(bindExpression(template, paramsName, params));\n } catch (error) {\n warn(error);\n return Expression.notParsable(refusalOf(error));\n }\n}\n","import { QueryOptionExecutionTarget } from \"../plugins\";\nimport { CompiledSchemaCore, PropertyInfo } from \"../schema\";\n\n/**\n * JSON-safe form of a literal. Tagged only where JSON cannot carry the value as it is.\n *\n * See `Expression.toJson`.\n */\nexport type SerializedValue =\n | string | number | boolean | null\n | SerializedValue[]\n | { date: string }\n | { undefined: true }\n | { number: \"NaN\" | \"Infinity\" | \"-Infinity\" }\n | { regex: { source: string, flags: string } }\n | { bigint: string };\n\n/** JSON-safe form of an expression tree. See `Expression.toJson`. */\nexport type SerializedExpression =\n | { type: \"empty\" }\n | { type: \"not-parsable\"; reason?: string }\n | { type: \"operator\"; operator: Operator; left?: SerializedExpression; right?: SerializedExpression }\n | {\n type: \"comparator\";\n comparator: Comparator;\n negated: boolean;\n strict: boolean;\n left?: SerializedExpression;\n right?: SerializedExpression;\n }\n | { type: \"call\"; call: Call; expression: SerializedExpression; arguments: SerializedExpression[] }\n | { type: \"property\"; path: string }\n | { type: \"value\"; value: SerializedValue };\n\nconst valueToJson = (value: unknown): SerializedValue => {\n if (value === undefined) {\n return { undefined: true };\n }\n\n if (value === null) {\n return null;\n }\n\n if (value instanceof Date) {\n // ISO rather than epoch millis: it survives a human reading the payload, and an invalid\n // Date has no ISO form — so it is caught here rather than becoming a silent `null`.\n return { date: value.toISOString() };\n }\n\n if (Array.isArray(value)) {\n return value.map(valueToJson);\n }\n\n if (typeof value === \"number\" && Number.isFinite(value) === false) {\n // `JSON.stringify` turns all three of these into `null`, which would compare as a different\n // value entirely rather than failing.\n return { number: Number.isNaN(value) ? \"NaN\" : value > 0 ? \"Infinity\" : \"-Infinity\" };\n }\n\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n return value;\n }\n\n if (value instanceof RegExp) {\n return { regex: { source: value.source, flags: value.flags } };\n }\n\n // `JSON.stringify` throws outright on a bigint rather than losing it quietly, so this is the one\n // tag that turns a crash into a value\n if (typeof value === \"bigint\") {\n return { bigint: value.toString() };\n }\n\n throw new Error(\n `Cannot serialize this filter value: only strings, numbers, booleans, null, undefined, Dates and arrays of those can cross a wire. ` +\n `Received: ${Object.prototype.toString.call(value)}`\n );\n};\n\nconst valueFromJson = (value: SerializedValue): unknown => {\n if (value === null || typeof value !== \"object\") {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map(valueFromJson);\n }\n\n if (\"date\" in value) {\n return new Date(value.date);\n }\n\n if (\"undefined\" in value) {\n return undefined;\n }\n\n if (\"regex\" in value) {\n return new RegExp(value.regex.source, value.regex.flags);\n }\n\n if (\"bigint\" in value) {\n return BigInt(value.bigint);\n }\n\n return value.number === \"NaN\"\n ? Number.NaN\n : value.number === \"Infinity\" ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;\n};\n\nexport type ParsedExpression = {\n expression: Expression;\n // Will be memory when trying to query on an untracked computed property or on a function\n executionTarget: QueryOptionExecutionTarget;\n}\n\n/**\n * The base class for all expression types.\n */\nexport abstract class Expression {\n /** The type of the expression. */\n abstract readonly type: ExpressionType;\n /** The left-hand side of the expression (if applicable). */\n left?: Expression;\n /** The right-hand side of the expression (if applicable). */\n right?: Expression;\n\n constructor(left?: Expression, right?: Expression) {\n this.left = left;\n this.right = right;\n }\n\n static get EMPTY() {\n return new EmptyExpression();\n }\n\n static get NOT_PARSABLE() {\n return new NotParsableExpression();\n }\n\n /** `NOT_PARSABLE`, carrying what the parser refused. */\n static notParsable(reason: string) {\n return new NotParsableExpression(reason);\n }\n\n static isEmpty(expression: Expression) {\n return expression.type === \"empty\" || expression instanceof EmptyExpression;\n }\n\n static isNotParsable(expression: Expression) {\n return expression.type === \"not-parsable\" || expression instanceof NotParsableExpression;\n }\n\n /**\n * Turns a tree into plain JSON, so a whole query can cross a wire.\n *\n * On the class rather than beside it, because this is the type's own REPRESENTATION — there is one\n * right answer and it belongs with the thing being represented, next to `EMPTY` and `isEmpty`.\n * Rendering a tree into some other language (`toSql`, `toMql`, `evaluate`) is a different kind of\n * thing: there are many, each belongs to its consumer, and none of them is canonical.\n *\n * ## Why it is this small\n *\n * Of the seven node types a bound tree can contain, exactly one holds anything JSON cannot carry:\n * `PropertyExpression`, whose live `PropertyInfo` has functions, a parent chain and caches. It\n * reduces to a property PATH — `PropertyInfo.id` IS the dotted path, and `getProperty` is keyed by\n * exactly that — so rebinding is one lookup.\n *\n * `ParamReferenceExpression` never appears: it is a parse-time placeholder that binding replaces\n * with a plain `ValueExpression` holding the resolved value. A serialized tree is always already\n * bound, so there is no params object to send alongside it.\n *\n * Switches on `type` rather than using the `isXExpression` guards, which live in `../assertions`\n * and import this module — the guards test the same discriminant, so nothing is lost.\n */\n static toJson(expression: Expression): SerializedExpression {\n\n if (expression.type === \"operator\") {\n const operator = expression as OperatorExpression;\n\n return {\n type: \"operator\",\n operator: operator.operator,\n ...(operator.left != null && { left: Expression.toJson(operator.left) }),\n ...(operator.right != null && { right: Expression.toJson(operator.right) }),\n };\n }\n\n if (expression.type === \"comparator\") {\n const comparator = expression as ComparatorExpression;\n\n return {\n type: \"comparator\",\n comparator: comparator.comparator,\n negated: comparator.negated,\n strict: comparator.strict,\n ...(comparator.left != null && { left: Expression.toJson(comparator.left) }),\n ...(comparator.right != null && { right: Expression.toJson(comparator.right) }),\n };\n }\n\n if (expression.type === \"call\") {\n const call = expression as CallExpression;\n\n return {\n type: \"call\",\n call: call.call,\n expression: Expression.toJson(call.expression),\n arguments: call.arguments.map(Expression.toJson),\n };\n }\n\n if (expression.type === \"property\") {\n const property = expression as PropertyExpression;\n\n return {\n type: \"property\",\n // The dotted path, which is exactly the key `getProperty` is looking up\n path: property.property.id,\n };\n }\n\n if (expression.type === \"value\") {\n const value = expression as ValueExpression;\n\n return {\n type: \"value\",\n value: valueToJson(value.value),\n };\n }\n\n if (expression.type === \"empty\") {\n return { type: \"empty\" };\n }\n\n const reason = (expression as NotParsableExpression).reason;\n\n return reason == null ? { type: \"not-parsable\" } : { type: \"not-parsable\", reason };\n }\n\n /**\n * Rebuilds a tree from JSON, rebinding every property against `schema`.\n *\n * The schema is SUPPLIED rather than read out of the payload. A filter always belongs to a known\n * collection, and the RECEIVER's schema is the authority on what its properties are — taking an\n * id from the payload would mean rebinding against a schema the sender chose, which is backwards\n * for anything crossing a trust boundary.\n *\n * @throws when a property path is not declared by `schema`. Not `NOT_PARSABLE`: on a receiver, a\n * filter that silently stops filtering returns rows the requester excluded, which is the one\n * failure here worse than an error.\n */\n static fromJson(json: SerializedExpression, schema: CompiledSchemaCore<any>): Expression {\n\n const child = (node: SerializedExpression | undefined) => node == null ? undefined : Expression.fromJson(node, schema);\n\n if (json.type === \"operator\") {\n return new OperatorExpression({ operator: json.operator, left: child(json.left), right: child(json.right) });\n }\n\n if (json.type === \"comparator\") {\n return new ComparatorExpression({\n comparator: json.comparator,\n negated: json.negated,\n strict: json.strict,\n left: child(json.left),\n right: child(json.right),\n });\n }\n\n if (json.type === \"call\") {\n if (json.expression == null) {\n throw new Error(\n `Cannot deserialize a filter: a '${json.call}' call carries no operand. ` +\n `Collection: ${schema.collectionName}.`\n );\n }\n\n return new CallExpression({\n call: json.call,\n expression: Expression.fromJson(json.expression, schema),\n arguments: (json.arguments ?? []).map(argument => Expression.fromJson(argument, schema)),\n });\n }\n\n if (json.type === \"property\") {\n const property = schema.getProperty(json.path);\n\n if (property == null) {\n throw new Error(\n `Cannot deserialize a filter: this schema does not declare the property it names. ` +\n `Property: ${json.path}, Collection: ${schema.collectionName}. ` +\n `The two sides disagree about the shape of the data, so the filter cannot be applied.`\n );\n }\n\n return new PropertyExpression({ property });\n }\n\n if (json.type === \"value\") {\n return new ValueExpression({ value: valueFromJson(json.value) });\n }\n\n if (json.type === \"empty\") {\n return Expression.EMPTY;\n }\n\n return json.reason == null ? Expression.NOT_PARSABLE : Expression.notParsable(json.reason);\n }\n}\n\nexport class EmptyExpression extends Expression {\n readonly type = \"empty\" as const;\n}\n\nexport class NotParsableExpression extends Expression {\n readonly type = \"not-parsable\" as const;\n\n /** What the parser refused, when it knows. `.explain()` prints it beside the source. */\n readonly reason?: string;\n\n constructor(reason?: string) {\n super();\n this.reason = reason;\n }\n}\n\n/**\n * A class representing a comparison operation (e.g., equals, greater-than).\n */\nexport class ComparatorExpression extends Expression {\n /** The type of the expression (always 'comparator'). */\n readonly type = \"comparator\" as const;\n /** The comparator operation (e.g., equals, greater-than). */\n comparator: Comparator;\n /** Whether the comparison is negated (e.g., not equals). */\n negated: boolean;\n /** Whether the comparison is strict (type-sensitive). */\n strict: boolean;\n\n constructor(\n options: {\n comparator: Comparator,\n negated: boolean,\n strict: boolean,\n left?: Expression,\n right?: Expression\n }\n ) {\n super(options.left, options.right);\n this.comparator = options.comparator;\n this.negated = options.negated;\n this.strict = options.strict;\n }\n}\n\n/**\n * A class representing a logical operator (e.g., &&, ||).\n */\nexport class OperatorExpression extends Expression {\n /** The type of the expression (always 'operator'). */\n readonly type = \"operator\" as const;\n /** The logical operator. */\n operator: Operator;\n\n constructor(options: { operator: Operator, left?: Expression, right?: Expression }) {\n super(options.left, options.right);\n this.operator = options.operator;\n }\n}\n\n/**\n * A class representing a property path.\n */\nexport class PropertyExpression extends Expression {\n /** The type of the expression (always 'property'). */\n readonly type = \"property\" as const;\n /** The property info for the path. */\n property: PropertyInfo<any>;\n\n constructor(options: { property: PropertyInfo<any> }) {\n super();\n this.property = options.property;\n }\n}\n\nexport class CallExpression extends Expression {\n readonly type = \"call\" as const;\n call: Call;\n expression: Expression;\n /** Empty for a unary call. */\n arguments: Expression[];\n\n constructor(options: { call: Call, expression: Expression, arguments?: Expression[] }) {\n super();\n this.call = options.call;\n this.expression = options.expression;\n this.arguments = options.arguments ?? [];\n }\n\n}\n\n/**\n * A class representing a literal value.\n */\nexport class ValueExpression extends Expression {\n /** The type of the expression (always 'value'). */\n readonly type = \"value\" as const;\n /** The literal value. */\n value: unknown;\n\n constructor(options: {\n value: unknown\n }) {\n super();\n this.value = options.value;\n }\n}\n\n\n/**\n * The set of possible expression types.\n */\nexport type ExpressionType = \"operator\" | \"comparator\" | \"property\" | \"value\" | \"call\" | \"empty\" | \"not-parsable\";\n\n/**\n * Supported value transformations that can be applied to values.\n * `length` reads the length of a string or array property.\n */\nexport type Transformer = \"to-lower-case\" | \"to-upper-case\" | \"length\";\n\n/**\n * The names claimed so far. A name absent here is not refused — `specs/filter-expressions.md` lists\n * both the refusals and their reasons, and is longer than this union.\n */\nexport type Call =\n | \"to-lower-case\" | \"to-upper-case\" | \"length\" | \"trim\" | \"trim-start\" | \"trim-end\"\n | \"index-of\" | \"substring\" | \"concat\" | \"replace\" | \"replace-all\"\n | \"absolute\" | \"floor\" | \"ceiling\" | \"round\" | \"sign\" | \"square-root\" | \"power\"\n | \"add\" | \"subtract\" | \"multiply\" | \"divide\" | \"modulo\"\n | \"utc-year\" | \"utc-month\" | \"utc-day-of-month\" | \"utc-day-of-week\"\n | \"utc-hour\" | \"utc-minute\" | \"utc-second\" | \"utc-millisecond\" | \"epoch-ms\"\n | \"to-string\" | \"to-number\" | \"to-boolean\" | \"type-of\"\n | \"some\" | \"every\"\n | \"power\"\n | \"bit-and\" | \"bit-or\" | \"bit-xor\" | \"bit-not\" | \"shift-left\" | \"shift-right\" | \"shift-right-unsigned\"\n | \"conditional\" | \"coalesce\" | \"matches\";\n\n/**\n * Supported comparator operations for expressions.\n */\nexport type Comparator =\n | \"equals\"\n | \"starts-with\"\n | \"includes\"\n | \"ends-with\"\n | \"greater-than\"\n | \"greater-than-equals\"\n | \"less-than\"\n | \"less-than-equals\";\n\n/**\n * Supported logical operators for expressions.\n */\nexport type Operator = \"&&\" | \"||\";\n\n/**\n * A function that filters a value of type T and returns a boolean.\n */\nexport type Filter<T extends any> = (value: T) => boolean;\n\n/**\n * A function that filters a value of type T with additional parameters P.\n */\nexport type ParamsFilter<T extends any, P> = (payload: [T, P]) => boolean;\n\n/**\n * A filter that can be either a simple filter or a parameterized filter.\n */\nexport type CompositeFilter<T extends any, P = never> = Filter<T> | ParamsFilter<T, P>;\n\n/**\n * An object that can be filtered using a composite filter and optional parameters.\n */\nexport type Filterable<T extends any, P = any> = {\n /** The filter function. */\n filter: CompositeFilter<T, P>;\n /** Optional parameters for the filter. */\n params?: P;\n};","import { PropertyInfo } from \"../schema\";\nimport { CallExpression, Expression, PropertyExpression } from \"./types\";\n\n/**\n * An operand with the calls wrapping it, innermost first — the order they are applied in.\n *\n * The nodes rather than their names: a binary call carries arguments, and a consumer that only knows\n * the name renders `LOWER(col)` correctly and `col + ?` not at all.\n */\nexport type PeeledOperand = { operand: Expression, calls: CallExpression[] };\n\n/**\n * Separates an operand from the calls applied to it.\n *\n * `null` when there is no operand beneath the calls. Every consumer needs this to decide whether a\n * comparator side is a property or a value, so it lives here rather than in each translator.\n */\nexport function peelCalls(expression: Expression | undefined): PeeledOperand | null {\n const calls: CallExpression[] = [];\n let current = expression;\n\n while (current != null && current.type === \"call\") {\n calls.unshift(current as CallExpression);\n current = (current as CallExpression).expression;\n }\n\n return current == null ? null : { operand: current, calls };\n}\n\nexport function childrenOf(expression: Expression): Expression[] {\n\n if (expression.type === \"call\") {\n const call = expression as CallExpression;\n\n return [call.expression, ...(call.arguments ?? [])].filter(child => child != null);\n }\n\n const children: Expression[] = [];\n\n if (expression.left != null) {\n children.push(expression.left);\n }\n\n if (expression.right != null) {\n children.push(expression.right);\n }\n\n return children;\n}\n\n/**\n * Extracts all properties referenced in an expression\n * @param expression The expression to analyze\n * @returns Array of PropertyInfo objects referenced in the expression\n */\nexport function getProperties(expression: Expression): PropertyInfo<any>[] {\n const properties: PropertyInfo<any>[] = [];\n\n function traverse(expr: Expression) {\n // If this is a property expression, add it to our collection\n if (expr.type === \"property\") {\n properties.push((expr as PropertyExpression).property);\n }\n\n for (const child of childrenOf(expr)) {\n traverse(child);\n }\n }\n\n traverse(expression);\n return properties;\n}\n\nexport function forEach(expression: Expression, callback: (expression: Expression) => boolean) {\n function traverse(expr: Expression): boolean {\n // Call the callback for this expression\n // If callback returns false, stop traversing\n if (!callback(expr)) {\n return false;\n }\n\n for (const child of childrenOf(expr)) {\n if (!traverse(child)) {\n return false;\n }\n }\n\n return true;\n }\n\n traverse(expression);\n}","import type { SchemaDefinition } from \"./SchemaDefinition\";\nimport type { SchemaBase } from \"./property/base/SchemaBase\";\nimport type { SchemaArray } from \"./property/types/SchemaArray\";\nimport type { SchemaVector } from \"./property/types/SchemaVector\";\nimport type { SchemaObject } from \"./property/types/SchemaObject\";\nimport type { PropertyInfo } from \"./PropertyInfo\";\nimport type { DeepPartial } from \"../types\";\nimport type { SchemaFunction } from \"./table\";\nimport type { SchemaOptional, SchemaTag } from \"./property/modifiers\";\nimport type { Branded } from \"../utilities/types\";\nimport type { SchemaSubscriptionOptions } from \"./communication/broadcast\";\n\nexport type DefaultValue<T, I = never> = T | ((injected: I) => T);\nexport type FunctionBody<TEntity, TResult> = (entity: TEntity, collectionName: CollectionName) => TResult;\nexport type IdType = string | number;\nexport type ForeignKey<T extends {}> = { \n schema: CompiledSchema<T>, \n property: PropertyInfo<T> \n};\n\nexport enum SchemaTypes {\n Array = \"Array\",\n Boolean = \"Boolean\",\n Date = \"Date\",\n Number = \"Number\",\n Object = \"Object\",\n String = \"String\",\n Definition = \"Definition\",\n Function = \"Function\",\n Computed = \"Computed\",\n /**\n * Content in, reference out. The only type whose write shape differs from its stored\n * shape, and a leaf on purpose — see `SchemaFile`.\n */\n File = \"File\",\n /**\n * A fixed-length list of numbers, carrying its dimension count — see `SchemaVector`.\n *\n * Value-shaped exactly like `s.array(s.number())`, which is why every array codegen\n * handler accepts it. It is a distinct type only so a backend can recognise it and store\n * it natively; nothing else needs to tell the two apart.\n */\n Vector = \"Vector\"\n}\n\nexport type ArrayShape = string | number | Date | {};\n\n\n/**\n * What a file property gives back: where the bytes are and what they are.\n *\n * Declared in core so `InferType` can name it. Core never reads or writes the bytes — it only\n * carries this shape — and `@routier/blob-plugin` is what puts one here.\n */\nexport type FileReferenceValue = {\n /** Where the bytes live, content-addressed by the blob plugin. */\n key: string;\n /** Byte length. */\n size: number;\n /** Media type as supplied at upload. */\n contentType: string;\n /** SHA-256 of the bytes, lowercase hex. */\n checksum: string;\n /** The name to show a user. Not part of the key. */\n fileName: string;\n};\n\n/**\n * What a file property ACCEPTS: content, or a reference you already have.\n *\n * `Blob` covers `File`, which is what an `<input type=\"file\">` yields. A reference is accepted\n * too, so re-saving an entity that was read from the database does not have to re-upload it.\n */\nexport type FileContentValue =\n | FileReferenceValue\n | Uint8Array\n | ArrayBuffer\n | Blob\n | string;\n\n/**\n * What a vector property holds, in and out: a plain list of numbers.\n *\n * Named rather than written inline because the inference rules have to recognise it after a\n * modifier has erased which class produced it — the same problem `FileReferenceValue` solves\n * above, and for the same reason.\n */\nexport type VectorValue = number[];\n\n/**\n * What `s.string({ ... })` accepts.\n *\n * Declarations only. Core stores them and never acts on them; a backend that can use one does.\n */\nexport type StringOptions = {\n /**\n * The longest value the property is declared to hold.\n *\n * MySQL uses it for `VARCHAR(maxLength)`; without it every string column is\n * `VARCHAR(255)`, which silently truncates longer values. Other backends ignore it. Core\n * never validates a value against it — see `SchemaBase.maxLength`.\n */\n maxLength?: number;\n};\n\nexport type ExpandedProperty = ExpandedChildProperty & {\n assignmentPath: string;\n selectorPath: string;\n properties: Map<string, ExpandedChildProperty>;\n childDegree: number;\n};\n\nexport type ExpandedChildProperty = {\n propertyName: string;\n type: SchemaTypes;\n isNullableOrOptional: boolean;\n isReadonly: boolean;\n isIdentity: boolean;\n isUnmapped: boolean;\n}\n\nexport enum HashType {\n Ids = \"Ids\",\n Object = \"Object\"\n}\n\nexport type HashFunction<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>, type: HashType.Object): string;\n (entity: InferType<TEntity>, type: HashType.Ids): string;\n}\n\nexport type GetHashTypeFunction<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): HashType.Object;\n (entity: InferType<TEntity>): HashType.Ids;\n}\n\nexport type ChangeTrackingType = \"proxy\" | \"diff\" | \"immutable\";\n\nexport type IndexType = \"single\" | \"compound\" | \"unique\" | \"primary-key\"\nexport type Index = {\n properties: PropertyInfo<any>[],\n type: IndexType;\n name: string;\n}\n\n/**\n * Represents changes to subscriptions, categorizing them by modifications to\n * entities (additions, updates, removals) or query-driven removals.\n * @template T - The type of the entities in the subscription.\n */\nexport type SubscriptionChanges<T extends {}> = {\n /**\n * Entities that have been added to the subscription.\n */\n adds: InferType<T>[];\n /**\n * Entities that have been updated within the subscription.\n */\n updates: InferType<T>[];\n /**\n * Entities that have been removed from the subscription.\n */\n removals: InferType<T>[];\n /**\n * Entities that have been added/updated/removed from the subscription and it is unknown \n * if the entities have been added/updated/removed.\n */\n unknown: InferType<T>[];\n}\n\nexport interface ISchemaSubscription<T extends {}> extends Disposable {\n send(changes: SubscriptionChanges<T>): void;\n onMessage(callback: (changes: SubscriptionChanges<T>) => void): void;\n}\n\nexport type Enrich<TEntity extends {}> = {\n (entity: InferType<TEntity>, changeTrackingType: ChangeTrackingType): InferType<TEntity>;\n (entity: InferCreateType<TEntity>, changeTrackingType: ChangeTrackingType): InferCreateType<TEntity>;\n}\nexport type Prepare<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): InferCreateType<TEntity>;\n (entity: InferType<TEntity>): InferType<TEntity>;\n}\nexport type Preprocess<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): InferType<TEntity>;\n (entity: InferType<TEntity>): InferType<TEntity>;\n}\n\nexport type SetProperties<TEntity extends {}> = (destination: DeepPartial<InferType<TEntity> | InferCreateType<TEntity>>, source: DeepPartial<InferType<TEntity> | InferCreateType<TEntity>>) => void;\n\nexport type CompiledSchemaCore<TEntity extends {}> = Omit<CompiledSchema<TEntity>, \"createSubscription\">;\n\nexport type CompiledSchemaWithMetadata<TEntity extends {}, TMetadata> = {\n readonly metadata: TMetadata;\n} & CompiledSchema<TEntity>;\n\n/**\n * Represents a fully compiled schema with all utilities and metadata for an entity type.\n */\nexport type CompiledSchema<TEntity extends {}> = {\n\n deserializePartial: (item: Record<string, unknown>, properties: PropertyInfo<TEntity>[]) => DeepPartial<InferType<TEntity>>;\n\n createSubscription: (abortSignal?: AbortSignal, scope?: string, options?: SchemaSubscriptionOptions) => ISchemaSubscription<TEntity>;\n /** Returns the property info for a given id (full path) */\n getProperty: (id: string) => PropertyInfo<TEntity>;\n /** Returns the ID of the given entity. */\n getId: (entity: InferType<TEntity>) => IdType;\n /** Returns a deep clone of the given entity. */\n clone: (entity: InferType<TEntity>) => InferType<TEntity>;\n /**\n * Returns a deep clone of a record that is still in the STORAGE shape — renamed properties\n * under their `from` names rather than their in-memory names.\n *\n * `clone` reads in-memory names, so it returns `undefined` for every renamed property of a\n * stored record. Use this when copying rows a store holds before they have been deserialized.\n * Generated on first call; schemas that are never cloned in storage shape never build it.\n */\n cloneStorage: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Removes unmapped or extraneous properties from the entity. */\n strip: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Prepares a new entity for creation, applying defaults and transformations. */\n prepare: Prepare<TEntity>;\n /** Merges the source entity into the destination entity. */\n merge: (destination: InferType<TEntity> | InferCreateType<TEntity>, source: InferType<TEntity>) => InferType<TEntity>;\n /** Indicates if the schema has identity properties. */\n hasIdentities: boolean;\n /** List of properties that are identity keys. */\n idProperties: PropertyInfo<TEntity>[];\n /** All property metadata for the schema. */\n properties: PropertyInfo<TEntity>[],\n /** The hash type used for this schema. */\n hashType: HashType;\n /** Computes a hash for the given entity. */\n hash: HashFunction<TEntity>;\n /** Returns the hash type for the given entity. */\n getHashType: GetHashTypeFunction<TEntity>;\n /** Compares two entities for equality. */\n compare: (a: InferType<TEntity>, fromDb: InferType<TEntity>) => boolean;\n /** Deserializes an entity from storage format. */\n deserialize: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Sets 1 or many properties from the source object onto the destination object with change tracking. */\n set: SetProperties<TEntity>;\n /** Combines serializing and preparing an entity for saving. */\n preprocess: Preprocess<TEntity>;\n /** Combines deserializing and enriching an entity for selection. */\n postprocess: Enrich<TEntity>;\n\n /** Serializes an entity to storage format. */\n serialize: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Unique id for the schema. */\n id: SchemaId,\n /** The name of the collection for this schema. */\n collectionName: CollectionName;\n /** Returns all IDs for the given entity (usually a single-element tuple). */\n getIds: (entity: InferType<TEntity>) => [IdType];\n /** Enriches the entity with change tracking or other metadata. */\n enrich: Enrich<TEntity>;\n /** Indicates if the schema has identity keys. */\n hasIdentityKeys: boolean;\n /** Returns a deeply frozen (immutable) version of the entity. */\n freeze: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Enables change tracking on the entity. */\n enableChangeTracking: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** The schema definition object. */\n definition: SchemaDefinition<TEntity>;\n /** Returns all indexes defined for this schema. */\n getIndexes: () => Index[];\n /** Compares two entities for Id equality. */\n compareIds: (a: InferType<TEntity>, b: InferType<TEntity>) => boolean;\n}\n\nexport type PropertySerializer<T extends any> = (value: T) => string | number;\nexport type PropertyDeserializer<T extends any> = (value: string | number) => T;\n\n/**\n * A two-way transform between the application value and the stored value.\n *\n * Both directions may be async. Held as a live reference rather than stringified, so a\n * closure works and `injected` is a convenience rather than the only way in.\n */\nexport type PropertyTransform<T extends any> = {\n /**\n * Application value to stored value. Runs before the plugin sees it. May be async.\n *\n * `entity` is there for the one-way case: a transform with no `from` derives a value\n * rather than converting one, which is what `computed` does.\n */\n to: (value: T, entity: Record<string, unknown>) => unknown | Promise<unknown>;\n\n /**\n * Stored value back to application value. Runs after the plugin returns it.\n *\n * Optional. Leave it out and the transform is one-way: the stored value is the value.\n */\n from?: (value: unknown) => T | Promise<T>;\n\n /**\n * What the column becomes, when the stored form is not the property's own type.\n *\n * Defaults to the property's own type, so nothing changes unless you say it does. A\n * library that always produces text — a cipher, a compressor — sets this once, and the\n * caller who uses that library never writes it.\n */\n stores?: SchemaTypes;\n\n /**\n * Whether a filter on this property can still run in the database.\n *\n * Defaults to `none`, which rejects the filter rather than returning wrong rows. Set\n * `equality` only when `to` is deterministic.\n */\n comparable?: 'equality' | 'none';\n};\n\nexport type SchemaId = Branded<number, \"SchemaId\">;\nexport type CollectionName = Branded<string, \"CollectionName\">;\n\nexport type SchemaModifiers = \"default\" | \"deserialize\" |\n \"identity\" | \"key\" |\n \"nullable\" | \"optional\" |\n \"readonly\" | \"serialize\" |\n \"unmapped\" | \"computed\" |\n \"distinct\" | \"searchable\";\n\n/**\n * What a tagged property infers to.\n *\n * `tag()` is metadata and must not change a type, but `SchemaTag<T>` carries the same `T` as\n * whatever it wrapped without carrying which class that was. For a string `T` is already\n * `string`; for an object `T` is the map of child schemas, which only the `SchemaObject`\n * branch below knows how to unwrap. Falling through to the generic `SchemaBase` branch\n * therefore handed the raw map back, so `s.object({ key: s.string() }).tag('x')` typed\n * `key` as `SchemaString` instead of `string` — everything ran, and only the types lied.\n *\n * An array is distinguishable because `SchemaArray`'s parameter is the ELEMENT schema, so a\n * tagged array arrives here as a `SchemaBase` rather than a plain map.\n */\ntype InferTagged<C> = ResolveWrapped<C>;\n\n/**\n * What a wrapping modifier's inner type resolves to.\n *\n * `SchemaOptional`, `SchemaNullable` and `SchemaTag` all carry the same `C` as whatever they\n * wrapped, without carrying which class that was, so each has to work out what it is holding.\n * Three shapes are possible:\n *\n * - an already-resolved value (`string` from `s.string()`, a file reference from `s.file()`)\n * - an ELEMENT schema, which is what `SchemaArray` parameterises on\n * - a map of child schemas, which is what `SchemaObject` parameterises on\n *\n * Getting this wrong is silent. The map branch applied to an already-resolved object walks\n * its keys and infers `never` for each, so `s.file().optional()` typed as\n * `{ key: never, size: never, ... }` — which no value can satisfy and no test would catch at\n * runtime.\n */\ntype ResolveWrapped<C> =\n C extends string | number | boolean | Date | FileReferenceValue ? C :\n C extends VectorValue ? C :\n C extends SchemaBase<any, any> ? InferPrimitive<C>[] :\n { [K in keyof C]: InferPrimitive<C[K]> };\n\ntype InferPrimitive<T> =\n T extends SchemaOptional<infer C, infer __> ? ResolveWrapped<C> :\n T extends SchemaTag<infer C, infer __> ? InferTagged<C> :\n // Before the generic `SchemaBase` branch below, which would see `X = number[]` and map\n // the element through `InferPrimitive<number>` — no branch matches a bare `number`, so a\n // vector would type as `never[]`: assignable from nothing, and invisible at runtime.\n T extends SchemaVector<infer __, infer ___> ? VectorValue :\n T extends SchemaArray<infer Y, infer __> ? InferPrimitive<Y>[]\n : T extends SchemaObject<infer Obj, infer _> ?\n { [K in keyof Obj]: InferPrimitive<Obj[K]> } : // Process nested objects\n T extends SchemaFunction<infer F, infer __> ? F : T extends SchemaBase<infer X, infer _> ?\n X extends Array<infer A> ? InferPrimitive<A>[] : X : // Extract the primitive type\n never;\n\nexport type InferType<T> = T extends CompiledSchema<infer R> ? InferCompiledSchema<R> : T extends {} ? InferCompiledSchema<T> : T;\nexport type InferCreateType<T> = T extends CompiledSchema<infer R> ? InferCompiledCreateSchema<R> : T extends {} ? InferCompiledCreateSchema<T> : unknown;\nexport type InferMappedType<T> = T extends SchemaBase<infer K, infer __> ? InferType<K> : InferCompiledSchema<T>;\nexport type InferRoot<T> = T extends CompiledSchema<infer R> ? R : never;\n\ntype HasModifier<T, K extends keyof T, M extends SchemaModifiers> =\n T[K] extends SchemaBase<any, infer Mods> ?\n M extends Mods ? true : false :\n false;\n\ntype IsPlainProperty<T, K extends keyof T> =\n [\n HasModifier<T, K, \"readonly\">,\n HasModifier<T, K, \"optional\">,\n HasModifier<T, K, \"nullable\">\n ] extends [\n false,\n false,\n false\n ] ? true : false;\n\ntype IsCreateExcluded<T, K extends keyof T> =\n [\n HasModifier<T, K, \"identity\">,\n HasModifier<T, K, \"computed\">,\n HasModifier<T, K, \"unmapped\">\n ] extends [\n false,\n false,\n false\n ] ? false : true;\n\ntype IsCreateOptional<T, K extends keyof T> =\n [\n HasModifier<T, K, \"optional\">,\n HasModifier<T, K, \"default\">\n ] extends [\n false,\n false\n ] ? false : true;\n\ntype IsCreateNullable<T, K extends keyof T> =\n HasModifier<T, K, \"nullable\"> extends true ? true : false;\n\n/**\n * What a property ACCEPTS on the way in, which is not always what it gives back.\n *\n * Only a file differs today: you assign content and read a reference. Matching on the read\n * type rather than on `SchemaFile` itself is deliberate — it keeps working through every\n * modifier. `s.file().optional()` is a `SchemaOptional`, `s.file().tag('x')` is a\n * `SchemaTag`, and neither carries the original class, so a check against the class alone\n * would silently stop accepting content the moment anyone added a modifier.\n *\n * Assignability is required in BOTH directions, and the tuple wrappers are load-bearing.\n * One-way `extends` matches `never` — which is assignable to everything — so a generic\n * property over `Record<string, unknown>` resolved to file content and broke the Dexie\n * plugin's types. It also matched any object that merely happens to have these five fields\n * plus more. Mutual assignability admits the reference shape and nothing else, and the\n * tuples stop the conditional distributing over a union.\n */\ntype InferWritePrimitive<T> =\n [InferPrimitive<T>] extends [FileReferenceValue]\n ? [FileReferenceValue] extends [InferPrimitive<T>] ? FileContentValue : InferPrimitive<T>\n : InferPrimitive<T>;\n\ntype InferCreateProperty<T, K extends keyof T> =\n IsCreateNullable<T, K> extends true ? null | InferWritePrimitive<T[K]> : InferWritePrimitive<T[K]>;\n\ntype InferCompiledSchema<T> = CoalesceEmpty<{\n [K in keyof T as IsPlainProperty<T, K> extends true ? K : never]: InferPrimitive<T[K]>\n}, {\n readonly [K in keyof T as HasModifier<T, K, \"readonly\"> extends true ? K : never]: InferPrimitive<T[K]>\n }, {\n [K in keyof T as HasModifier<T, K, \"optional\"> extends true ? K : never]?: InferPrimitive<T[K]>\n }, {\n [K in keyof T as HasModifier<T, K, \"nullable\"> extends true ? K : never]: null | InferPrimitive<T[K]>\n}>;\n\ntype InferCompiledCreateSchema<T> = {\n [K in keyof T as IsCreateExcluded<T, K> extends true ? never\n : IsCreateOptional<T, K> extends true ? K : never]?: InferCreateProperty<T, K>\n} & {\n [K in keyof T as IsCreateExcluded<T, K> extends true ? never\n : IsCreateOptional<T, K> extends true ? never : K]: InferCreateProperty<T, K>\n};\n\ntype IsEmptyObject<T> = keyof T extends never ? true : false;\ntype CoalesceEmpty<T1 extends {}, T2 extends {}, T3 extends {}, T4 extends {}> = (IsEmptyObject<T1> extends true ? {} : T1) & (IsEmptyObject<T2> extends true ? {} : T2) & (IsEmptyObject<T3> extends true ? {} : T3) & (IsEmptyObject<T4> extends true ? {} : T4);\n","/**\n * Levelled logging, resolved once.\n *\n * Three things about the previous implementation drove this shape:\n *\n * - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever\n * compared against `true`, so setting it to `false` did nothing — while\n * `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.\n * A documented switch that silently does nothing is worse than no switch.\n * - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always\n * sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through\n * a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also\n * capture console output by snapshotting a stack trace per call, so the cost is far above what\n * writing to a terminal would suggest — and the output buries whatever the failure was.\n * - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug\n * was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.\n *\n * Levels are compared numerically against a value cached at module load. Measured against a\n * no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.\n * Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why\n * this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —\n * a lazy API would recover 0.3% of an enabled call's cost and would have to change every call\n * site to do it.\n */\n\n/** Ordered from most severe to most verbose. `silent` discards everything. */\nexport const LOG_LEVELS = ['silent', 'error', 'warn', 'info', 'debug'] as const;\n\nexport type LogLevel = (typeof LOG_LEVELS)[number];\n\n/** Numeric rank, so a gate is one integer comparison. */\nconst RANK: Record<LogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n};\n\nconst isLogLevel = (value: unknown): value is LogLevel =>\n typeof value === 'string' && (LOG_LEVELS as readonly string[]).includes(value);\n\n/**\n * Resolves the configured level, in precedence order.\n *\n * Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an\n * environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything\n * unrecognised is ignored rather than treated as an error — a typo'd level should not take down\n * an application, and `silent` is the safe direction to fall back to.\n */\nconst resolveLevel = (): LogLevel => {\n if (typeof globalThis !== 'undefined') {\n const g = globalThis as { __ROUTIER_LOG_LEVEL__?: unknown; __ROUTIER_DEBUG__?: unknown };\n\n if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {\n return g.__ROUTIER_LOG_LEVEL__;\n }\n\n // Both directions honoured. `=== false` used to fall through to the NODE_ENV checks\n // below and re-enable the logging it was asked to suppress.\n if (g.__ROUTIER_DEBUG__ === true) return 'debug';\n if (g.__ROUTIER_DEBUG__ === false) return 'silent';\n }\n\n // There is deliberately no `import.meta.env` branch, although the documentation used to\n // promise one. It could never work: this package is bundled with rspack, which replaces\n // `import.meta` with `undefined`, so the check would read the *library's* build-time\n // environment rather than the application's — and referencing `import.meta` at all is a parse\n // error under a CommonJS build target, which is how the test suite loads this file. Vite and\n // similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own\n // `import.meta.env`, which is what the docs now describe.\n if (typeof process !== 'undefined' && process.env != null) {\n if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {\n return process.env.ROUTIER_LOG_LEVEL as LogLevel;\n }\n\n const debug = process.env.DEBUG;\n if (debug === 'routier' || debug === '*') return 'debug';\n\n const env = process.env.NODE_ENV?.toLowerCase();\n\n if (env === 'dev' || env === 'development') return 'debug';\n }\n\n // Warnings are on unless something turns them off.\n //\n // Routier warns when a query returns correct rows a slower way than it could, or when a filter\n // compares types that can never match. Both are the caller's to act on, and a default of\n // `silent` meant the only people who ever saw them were the ones who already knew to look.\n return 'warn';\n};\n\nlet level: LogLevel = resolveLevel();\nlet rank = RANK[level];\n\n/**\n * Overrides the level for the rest of the process.\n *\n * The configuration above is read once, at import, which is what makes the gate cheap — but it\n * also means an application that decides its verbosity after startup, or a test that wants to\n * assert on output, has no way in. This is that way in.\n */\nexport const setLogLevel = (next: LogLevel): void => {\n if (isLogLevel(next) === false) {\n throw new Error(`Unknown log level \"${next}\". Expected one of: ${LOG_LEVELS.join(', ')}`);\n }\n\n level = next;\n rank = RANK[next];\n};\n\nexport const getLogLevel = (): LogLevel => level;\n\n/** Re-reads the environment. For tests that change it after this module was imported. */\nexport const resetLogLevel = (): void => {\n level = resolveLevel();\n rank = RANK[level];\n};\n\n/**\n * Whether a message at this level would be emitted.\n *\n * For the rare call site whose *arguments* are expensive to build — a serialization, a deep\n * clone, a join over a large collection. An ordinary payload object is not worth guarding; see\n * the measurement in the header.\n */\nexport const isLogLevelEnabled = (at: LogLevel): boolean => rank >= RANK[at];\n\ntype ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'debug' | 'table';\n\nconst emit = (at: LogLevel, method: ConsoleMethod, args: unknown[]) => {\n if (rank < RANK[at]) {\n return;\n }\n\n // Resolved at call time rather than captured once: test harnesses and browser devtools both\n // replace console methods after modules have loaded, and a captured reference would keep\n // writing past the replacement.\n (console[method] as (...a: unknown[]) => void)(...args);\n};\n\nexport const logger = {\n /** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */\n log: (...args: unknown[]): void => emit('info', 'log', args),\n info: (...args: unknown[]): void => emit('info', 'info', args),\n warn: (...args: unknown[]): void => emit('warn', 'warn', args),\n error: (...args: unknown[]): void => emit('error', 'error', args),\n debug: (...args: unknown[]): void => emit('debug', 'debug', args),\n /** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */\n table: (...args: unknown[]): void => emit('debug', 'table', args),\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './callSource';\nexport * from './evaluate';\nexport * from './fold';\nexport * from './parser';\nexport * from './types';\nexport * from './utils';\nexport * from './constants';"],"names":["EXPRESSION_TYPES","isDate","assertDate","data","TypeError","assertIsNotNull","message","assertIsArray","Array","assertString","assertInstanceOf","value","Instance","assertIsNumber","isObjectWithType","isExpression","isOperatorExpression","isComparatorExpression","isPropertyExpression","isValueExpression","isCallExpression","isEmptyExpression","isNotParsableExpression","CALL_SOURCE","renderCallAsJs","call","renderOperand","renderArgs","source","operand","pattern","args","EXPRESSION_TYPE_SET","Object","UNRESOLVED","Symbol","ARITHMETIC","left","right","applyCall","String","lower","RegExp","arithmetic","operandValue","expression","row","condition","evaluate","undefined","inner","argument","resolved","equals","strict","Date","compare","comparator","asComparable","a","b","comparable","evaluateComparator","item","result","toPredicate","toStrictPredicate","Error","CallExpression","ComparatorExpression","OperatorExpression","ValueExpression","childrenOf","FOLDABLE","Set","COERCES_TO_TEXT","isFrozenPrimitive","readsAProperty","isConstant","foldConstantCalls","folded","foldedOperandValue","calls","outermost","logger","SchemaTypes","Expression","PropertyExpression","ERROR_MESSAGES","path","params","JSON","parseUnknown","ParamDependentParseError","converters","v","Boolean","Number","MULTI_CHARACTER_PUNCTUATION","SINGLE_CHARACTER_PUNCTUATION","sourceKeyed","entries","STRING_ESCAPES","regexCanStartHere","tokens","previous","isIdentifierStart","char","isIdentifierPart","isDigit","isHexDigit","decodeCodeEscape","backslashIndex","kind","start","end","parseInt","length","digits","d","tokenize","i","inClass","j","current","flags","quote","chunks","expressions","escaped","decoded","depth","at","closing","nextChar","radixPrefix","signLength","multi","w","TokenStream","bracketed","offset","token","after","COMPARISON_OPERATORS","LOOSER_THAN_COMPARISON","needsBrackets","MULTIPLICATIVE_OPERATORS","ADDITIVE_OPERATORS","SHIFT_OPERATORS","BITWISE_AND_OPERATORS","BITWISE_XOR_OPERATORS","BITWISE_OR_OPERATORS","COALESCE_OPERATORS","containsProperty","DECLARATION_KEYWORDS","UNKNOWN_UNTIL_ROW","NO_ARGUMENT","noArgument","NEVER","and","or","COMPARATOR_METHODS","TRANSFORM_METHODS","SWAPPED_COMPARATORS","ParamReferenceExpression","options","resolveParamPath","paramsName","name","resolvePairedValue","pairedProperty","applyConverter","ExpressionParser","schema","stream","scope","answer","keyword","next","endsHere","whenTrue","subject","matching","pending","everyLabel","byDefault","anyCaseBroke","label","test","body","reached","term","afterSwitch","noCaseMatched","whenFalse","operatorToken","nested","operators","conditional","grouped","pieces","only","alreadyText","BigInt","method","numberToken","elements","element","array","root","binding","transformer","locale","segment","paramPath","pathString","property","parentPath","parent","receiver","transform","operator","comparedToFalse","swapped","settled","leftValue","rightValue","target","isStringMatch","asCall","bindExpression","raw","bindPattern","key","buildScope","parameterNames","hasParams","Map","wholeParamsName","resolveFunctionShape","stringifiedFunction","functionHead","parametersEnd","arrowIndex","templateCache","WeakMap","MAX_CACHED_TEMPLATES_PER_SCHEMA","getCachedTemplate","setCachedTemplate","entry","bySource","combineExpressions","parseFragment","rootName","parser","refusalOf","error","toExpression","fn","warn","cached","template","structurallyDependsOnParams","shape","refused","valueToJson","valueFromJson","EmptyExpression","NotParsableExpression","reason","json","child","node","peelCalls","children","getProperties","properties","traverse","expr","forEach","callback","HashType","LOG_LEVELS","RANK","isLogLevel","resolveLevel","globalThis","g","process","debug","env","level","rank","setLogLevel","getLogLevel","resetLogLevel","isLogLevelEnabled","emit","console"],"mappings":";;;;;;;;;;;;AAA4D;AAEtB;AAE/B,SAASE,WAAWC,IAAa;IACpC,IAAIF,OAAOE,UAAU,OAAO;QACxB,MAAM,IAAIC,UAAU;IACxB;AACJ;AAEO,SAASC,gBAAmBF,IAA0B,EAAEG,OAAiC;IAC5F,IAAIH,QAAQ,MAAM;QACd,IAAIG,WAAW,MAAM;YACjB,MAAM,IAAIF,UAAU;QACxB;QAEA,IAAI,OAAOE,YAAY,UAAU;YAC7B,MAAM,IAAIF,UAAUE;QACxB;QAEA,MAAM,IAAIF,UAAUE;IACxB;AACJ;AAEO,SAASC,cAAiBJ,IAAa,EAAEG,OAAgB;IAC5D,IAAI,CAACE,MAAM,OAAO,CAACL,OAAO;QACtB,MAAM,IAAIC,UAAUE,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