@rapiq/parser-expression 2.4.0 → 2.5.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/dist/index.d.mts +7 -21
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +20 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { BaseParser, BaseQueryParser, FiltersParseOptions, ICondition, IFilters, IIssueCollector, ObjectLiteral, PaginationParseOptions, Parameter, RelationLedger, ResolutionScope, Scalar, SchemaRegistry } from "@rapiq/core";
|
|
2
2
|
import { SimpleFieldsParser, SimplePaginationParser, SimpleRelationsParser, SimpleSortsParser } from "@rapiq/parser-simple";
|
|
3
|
-
//#region src/parameter/fields/module.d.ts
|
|
4
3
|
export declare class ExpressionFieldsParser extends SimpleFieldsParser {}
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/parameter/filters/constants.d.ts
|
|
7
4
|
export declare enum FilterTokenType {
|
|
8
5
|
NOT = "NOT",
|
|
9
6
|
AND = "AND",
|
|
@@ -60,8 +57,6 @@ export declare const FILTER_EXPRESSION_KEYWORDS: {
|
|
|
60
57
|
* it as needed).
|
|
61
58
|
*/
|
|
62
59
|
export declare const FILTER_FIELD_SEGMENT_PATTERN = "[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?";
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/parameter/filters/module.d.ts
|
|
65
60
|
type FiltersScope = ResolutionScope<`${Parameter.FILTERS}`>;
|
|
66
61
|
/**
|
|
67
62
|
* @see https://www.jsonapi.net/usage/reading/filtering.html
|
|
@@ -144,38 +139,29 @@ export declare class ExpressionFiltersParser extends BaseParser<FiltersParseOpti
|
|
|
144
139
|
private parseElemMatchTarget;
|
|
145
140
|
private buildUnboundScope;
|
|
146
141
|
private parseExpressionValue;
|
|
142
|
+
/**
|
|
143
|
+
* `relationTarget` marks the field of an array operator (`size`): a leaf
|
|
144
|
+
* that is itself a relation is then gated by the relation policy too.
|
|
145
|
+
* A scalar comparison never asks, so a column sharing a registered
|
|
146
|
+
* schema's name is not mistaken for a relation.
|
|
147
|
+
*/
|
|
147
148
|
private parseExpressionFieldChain;
|
|
148
149
|
protected normalizeValue(input: unknown): Scalar;
|
|
149
150
|
}
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/parameter/filters/types.d.ts
|
|
152
151
|
export type FilterToken = {
|
|
153
152
|
type: `${FilterTokenType}`;
|
|
154
153
|
value?: string;
|
|
155
154
|
};
|
|
156
155
|
export type FilterExpressionParseOptions<RECORD extends ObjectLiteral = ObjectLiteral> = FiltersParseOptions<RECORD>;
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region src/parameter/pagination/types.d.ts
|
|
159
156
|
type ExpressionPaginationParseOptions = PaginationParseOptions;
|
|
160
|
-
//#endregion
|
|
161
|
-
//#region src/parameter/pagination/module.d.ts
|
|
162
157
|
export declare class ExpressionPaginationParser extends SimplePaginationParser<ExpressionPaginationParseOptions> {}
|
|
163
|
-
//#endregion
|
|
164
|
-
//#region src/parameter/relations/module.d.ts
|
|
165
158
|
export declare class ExpressionRelationsParser extends SimpleRelationsParser {}
|
|
166
|
-
//#endregion
|
|
167
|
-
//#region src/parameter/sorts/module.d.ts
|
|
168
159
|
export declare class ExpressionSortsParser extends SimpleSortsParser {}
|
|
169
160
|
/**
|
|
170
161
|
* @deprecated use {@link ExpressionSortsParser}. Removed in 3.0.
|
|
171
162
|
*/
|
|
172
163
|
export declare const ExpressionSortParser: typeof ExpressionSortsParser;
|
|
173
|
-
/**
|
|
174
|
-
* @deprecated use {@link ExpressionSortsParser}. Removed in 3.0.
|
|
175
|
-
*/
|
|
176
164
|
export type ExpressionSortParser = ExpressionSortsParser;
|
|
177
|
-
//#endregion
|
|
178
|
-
//#region src/module.d.ts
|
|
179
165
|
export declare class ExpressionParser extends BaseQueryParser {
|
|
180
166
|
protected fieldsParser: ExpressionFieldsParser;
|
|
181
167
|
protected filtersParser: ExpressionFiltersParser;
|
|
@@ -184,5 +170,5 @@ export declare class ExpressionParser extends BaseQueryParser {
|
|
|
184
170
|
protected sortParser: ExpressionSortsParser;
|
|
185
171
|
constructor(input?: SchemaRegistry);
|
|
186
172
|
}
|
|
187
|
-
|
|
173
|
+
export {};
|
|
188
174
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/parameter/fields/module.ts","../src/parameter/filters/constants.ts","../src/parameter/filters/module.ts","../src/parameter/filters/types.ts","../src/parameter/pagination/types.ts","../src/parameter/pagination/module.ts","../src/parameter/relations/module.ts","../src/parameter/sorts/module.ts","../src/module.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/parameter/fields/module.ts","../src/parameter/filters/constants.ts","../src/parameter/filters/module.ts","../src/parameter/filters/types.ts","../src/parameter/pagination/types.ts","../src/parameter/pagination/module.ts","../src/parameter/relations/module.ts","../src/parameter/sorts/module.ts","../src/module.ts"],"mappings":";;qBASa,+BAA+B;oBCFhC;EACR;EAEA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;qBASS;;;;;;;;;;;;;;;;;;;;;;;qBAwBA;KClBR,eAAe,mBAAmB,UAAU;;;;qBA4BpC,gCAAgC,WACzC,qBACA;UAEQ;UAEA;;;;;UAMA;EAIR,MAAM,eAAe,gBAAgB,eACjC,gBACA,UAAS,oBAAoB,UAC7B;EAuBW,WAAW,eAAe,gBAAgB,eACrD,gBACA,UAAS,oBAAoB,UAC7B,QAAQ;EAuBZ,eAAe,eAAe,gBAAgB,eAC1C,gBACA,SAAS,oBAAoB,SAC7B,QAAQ,gBACR,iBAAiB,kBACjB;EAUE,oBAAoB,eAAe,gBAAgB,eACrD,gBACA,SAAS,oBAAoB,SAC7B,QAAQ,gBACR,iBAAiB,kBACjB,QAAQ;EAKZ,WAAW,eAAe,gBAAgB,eACtC,gBACA,UAAS,oBAAoB,UAC7B;EAOE,gBAAgB,eAAe,gBAAgB,eACjD,gBACA,UAAS,oBAAoB,UAC7B,QAAQ;;;;;;;YAaF,MAAM,eAAe,gBAAgB,eAC3C,gBACA,SAAS,oBAAoB,SAC7B,QAAQ,gBACR,iBAAiB;IACf,QAAQ;IAAU,QAAQ;;YAUhB,WAAW,eAAe,gBAAgB,eACtD,gBACA,SAAS,oBAAoB,SAC7B,QAAQ,gBACR,iBAAiB,kBACjB;IAAU,QAAQ;IAAU,QAAQ;;;;;;;UAehC;UA0BM;;;;;;UAmCN;UAyCA;UAWA;UAaA;UAIA;UAYA;UAwEA;;;;;;;UA4CA;UA6BA;UA+BA;UAwDA;UAkDA;;;;;;UA6CA;;;;;;UA+BA;;;;;;UA+BA;UAgEA;UAOA;;;;;;;UAmBA;YAwDE,eAAe,iBAAkB;;YCl4BnC;EACR,SAAS;EACT;;YAGQ,6BACR,eAAe,gBAAgB,iBAC/B,oBAAoB;KCRZ,mCAAmC;qBCClC,mCAAmC,uBAAuB;qBCD1D,kCAAkC;qBCAlC,8BAA8B;;;;qBAO9B,6BAAoB;YAGrB,uBAAuB;qBCDtB,yBAAyB;YACxB,cAAe;YAEf,eAAgB;YAEhB,kBAAmB;YAEnB,iBAAkB;YAElB,YAAa;EAIX,YAAA,QAAQ"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { BaseParser, BaseQueryParser, DEFAULT_ID,
|
|
1
|
+
import { BaseParser, BaseQueryParser, DEFAULT_ID, FILTER_OPERATOR_SEMANTICS, Filter, FilterCompoundOperator, FilterFieldOperator, Filters, FiltersParseError, ITSELF, MAX_TRAVERSAL_DEPTH, Parameter, RelationsParseError, ResolutionScope, applyFiltersIndexPolicy, applyFiltersSchemaValidation, applyFiltersSchemaValidationAsync, applyKeySchemaValidation, applyKeySchemaValidationAsync, buildFiltersDefaults, isFilter, isFilters, pruneFiltersByRelations } from "@rapiq/core";
|
|
2
2
|
import { SimpleAggregatesParser, SimpleFieldsParser, SimpleGroupsParser, SimplePaginationParser, SimpleRelationsParser, SimpleSortsParser, parseFilterScalar } from "@rapiq/parser-simple";
|
|
3
|
-
|
|
3
|
+
// src/parameter/fields/module.ts
|
|
4
4
|
var ExpressionFieldsParser = class extends SimpleFieldsParser {};
|
|
5
|
-
|
|
6
|
-
//#region src/parameter/filters/constants.ts
|
|
5
|
+
// src/parameter/filters/constants.ts
|
|
7
6
|
let FilterTokenType = /* @__PURE__ */ function(FilterTokenType) {
|
|
8
7
|
FilterTokenType["NOT"] = "NOT";
|
|
9
8
|
FilterTokenType["AND"] = "AND";
|
|
@@ -61,8 +60,7 @@ const FILTER_EXPRESSION_KEYWORDS = {
|
|
|
61
60
|
* it as needed).
|
|
62
61
|
*/
|
|
63
62
|
const FILTER_FIELD_SEGMENT_PATTERN = "[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?";
|
|
64
|
-
|
|
65
|
-
//#region src/parameter/filters/module.ts
|
|
63
|
+
// src/parameter/filters/module.ts
|
|
66
64
|
/**
|
|
67
65
|
* Keep recursive expression parsing below the JavaScript call-stack limit and
|
|
68
66
|
* aligned with the schema resolver and Mongo parser traversal caps.
|
|
@@ -382,7 +380,7 @@ var ExpressionFiltersParser = class extends BaseParser {
|
|
|
382
380
|
parseSizeExpression(scope) {
|
|
383
381
|
this.consume("size");
|
|
384
382
|
this.consume("LPAREN");
|
|
385
|
-
const field = this.parseExpressionFieldChain(scope);
|
|
383
|
+
const field = this.parseExpressionFieldChain(scope, true);
|
|
386
384
|
this.consume("COMMA");
|
|
387
385
|
const value = this.parseExpressionValue();
|
|
388
386
|
this.consume("RPAREN");
|
|
@@ -431,12 +429,8 @@ var ExpressionFiltersParser = class extends BaseParser {
|
|
|
431
429
|
if (!resolved.success) throw FiltersParseError.keyInvalid(resolved.input);
|
|
432
430
|
const field = [...resolved.path, resolved.name].join(".");
|
|
433
431
|
let interior;
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
if (verdict instanceof ResolutionScope) interior = verdict;
|
|
437
|
-
} catch (e) {
|
|
438
|
-
if (!isParseError(e) || e.code !== ErrorCode.KEY_PATH_INVALID) throw e;
|
|
439
|
-
}
|
|
432
|
+
const verdict = resolved.scope.descend(resolved.name, { optional: true });
|
|
433
|
+
if (verdict instanceof ResolutionScope) interior = verdict;
|
|
440
434
|
return {
|
|
441
435
|
field,
|
|
442
436
|
scope: interior ?? this.buildUnboundScope(scope)
|
|
@@ -453,7 +447,13 @@ var ExpressionFiltersParser = class extends BaseParser {
|
|
|
453
447
|
if (token.type !== "ESCAPED_TEXT" && token.type !== "NULL") throw FiltersParseError.syntaxInvalid(`Unexpected token in value: ${token.type}`);
|
|
454
448
|
return this.normalizeValue(token.value ?? "null");
|
|
455
449
|
}
|
|
456
|
-
|
|
450
|
+
/**
|
|
451
|
+
* `relationTarget` marks the field of an array operator (`size`): a leaf
|
|
452
|
+
* that is itself a relation is then gated by the relation policy too.
|
|
453
|
+
* A scalar comparison never asks, so a column sharing a registered
|
|
454
|
+
* schema's name is not mistaken for a relation.
|
|
455
|
+
*/
|
|
456
|
+
parseExpressionFieldChain(scope, relationTarget = false) {
|
|
457
457
|
if (this.peek().type === "ITSELF") {
|
|
458
458
|
this.consume("ITSELF");
|
|
459
459
|
if (this.elemMatchDepth === 0) throw FiltersParseError.keyInvalid(ITSELF);
|
|
@@ -468,7 +468,8 @@ var ExpressionFiltersParser = class extends BaseParser {
|
|
|
468
468
|
}
|
|
469
469
|
if (scope) {
|
|
470
470
|
if (parts.length > 1 && (parts[0] === DEFAULT_ID || parts[0] === scope.schema.name)) parts.shift();
|
|
471
|
-
const
|
|
471
|
+
const key = parts.join(".");
|
|
472
|
+
const resolved = scope.resolveKey(key, key, { relationTarget });
|
|
472
473
|
/* istanbul ignore next -- the scope always throws */
|
|
473
474
|
if (!resolved.success) throw FiltersParseError.keyInvalid(resolved.input);
|
|
474
475
|
return [...resolved.path, resolved.name].join(".");
|
|
@@ -487,21 +488,17 @@ var ExpressionFiltersParser = class extends BaseParser {
|
|
|
487
488
|
throw FiltersParseError.syntaxInvalid("the value could not be normalized");
|
|
488
489
|
}
|
|
489
490
|
};
|
|
490
|
-
|
|
491
|
-
//#region src/parameter/pagination/module.ts
|
|
491
|
+
// src/parameter/pagination/module.ts
|
|
492
492
|
var ExpressionPaginationParser = class extends SimplePaginationParser {};
|
|
493
|
-
|
|
494
|
-
//#region src/parameter/relations/module.ts
|
|
493
|
+
// src/parameter/relations/module.ts
|
|
495
494
|
var ExpressionRelationsParser = class extends SimpleRelationsParser {};
|
|
496
|
-
|
|
497
|
-
//#region src/parameter/sorts/module.ts
|
|
495
|
+
// src/parameter/sorts/module.ts
|
|
498
496
|
var ExpressionSortsParser = class extends SimpleSortsParser {};
|
|
499
497
|
/**
|
|
500
498
|
* @deprecated use {@link ExpressionSortsParser}. Removed in 3.0.
|
|
501
499
|
*/
|
|
502
500
|
const ExpressionSortParser = ExpressionSortsParser;
|
|
503
|
-
|
|
504
|
-
//#region src/module.ts
|
|
501
|
+
// src/module.ts
|
|
505
502
|
var ExpressionParser = class extends BaseQueryParser {
|
|
506
503
|
fieldsParser;
|
|
507
504
|
filtersParser;
|
|
@@ -519,7 +516,6 @@ var ExpressionParser = class extends BaseQueryParser {
|
|
|
519
516
|
this.aggregatesParser = new SimpleAggregatesParser(this.registry);
|
|
520
517
|
}
|
|
521
518
|
};
|
|
522
|
-
//#endregion
|
|
523
519
|
export { ExpressionFieldsParser, ExpressionFiltersParser, ExpressionPaginationParser, ExpressionParser, ExpressionRelationsParser, ExpressionSortParser, ExpressionSortsParser, FILTER_EXPRESSION_KEYWORDS, FILTER_FIELD_SEGMENT_PATTERN, FilterTokenType };
|
|
524
520
|
|
|
525
521
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/parameter/fields/module.ts","../src/parameter/filters/constants.ts","../src/parameter/filters/module.ts","../src/parameter/pagination/module.ts","../src/parameter/relations/module.ts","../src/parameter/sorts/module.ts","../src/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2025-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SimpleFieldsParser } from '@rapiq/parser-simple';\n\nexport class ExpressionFieldsParser extends SimpleFieldsParser {\n\n}\n","/*\n * Copyright (c) 2025-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum FilterTokenType {\n NOT = 'NOT',\n\n AND = 'AND',\n OR = 'OR',\n\n EQUAL = 'eq',\n GREATER_THAN = 'gt',\n GREATER_OR_EQUAL = 'gte',\n LESS_THAN = 'lt',\n LESS_OR_EQUAL = 'lte',\n CONTAINS = 'like',\n STARTS_WITH = 'startsWith',\n ENDS_WITH = 'endsWith',\n IN = 'in',\n NIN = 'nin',\n ELEM_MATCH = 'elemMatch',\n SIZE = 'size',\n\n FIELD = 'FIELD',\n ITSELF = 'ITSELF',\n ESCAPED_TEXT = 'ESCAPED_TEXT',\n NULL = 'NULL',\n LPAREN = 'LPAREN',\n RPAREN = 'RPAREN',\n COMMA = 'COMMA',\n DOT = 'DOT',\n EOF = 'EOF',\n}\n\n/**\n * Grammar keywords of the expression dialect mapped to the token\n * they classify as. The tokenizer classifies whole identifiers\n * against this map; encoders consume its keys to reject field\n * segments that would tokenize as an operator on decode.\n */\nexport const FILTER_EXPRESSION_KEYWORDS = {\n not: FilterTokenType.NOT,\n and: FilterTokenType.AND,\n or: FilterTokenType.OR,\n eq: FilterTokenType.EQUAL,\n gt: FilterTokenType.GREATER_THAN,\n gte: FilterTokenType.GREATER_OR_EQUAL,\n lt: FilterTokenType.LESS_THAN,\n lte: FilterTokenType.LESS_OR_EQUAL,\n contains: FilterTokenType.CONTAINS,\n startsWith: FilterTokenType.STARTS_WITH,\n endsWith: FilterTokenType.ENDS_WITH,\n in: FilterTokenType.IN,\n nin: FilterTokenType.NIN,\n elemMatch: FilterTokenType.ELEM_MATCH,\n size: FilterTokenType.SIZE,\n null: FilterTokenType.NULL,\n} as const satisfies Record<string, FilterTokenType>;\n\n/**\n * Identifier grammar of a single field segment as accepted by the\n * expression tokenizer (unanchored regex source; consumers anchor\n * it as needed).\n */\nexport const FILTER_FIELD_SEGMENT_PATTERN = '[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?';\n","/*\n * Copyright (c) 2021-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type {\n FiltersParseOptions,\n FiltersSchema,\n ICondition,\n IFilters,\n IIssueCollector,\n ObjectLiteral,\n RelationLedger,\n Scalar,\n} from '@rapiq/core';\nimport {\n BaseParser,\n DEFAULT_ID,\n ErrorCode,\n FILTER_OPERATOR_SEMANTICS,\n Filter,\n FilterCompoundOperator,\n FilterFieldOperator,\n Filters,\n FiltersParseError,\n ITSELF,\n MAX_TRAVERSAL_DEPTH,\n Parameter,\n RelationsParseError,\n ResolutionScope,\n applyFiltersIndexPolicy,\n applyFiltersSchemaValidation,\n applyFiltersSchemaValidationAsync,\n applyKeySchemaValidation,\n applyKeySchemaValidationAsync,\n buildFiltersDefaults,\n isFilter,\n isFilters,\n isParseError,\n pruneFiltersByRelations,\n} from '@rapiq/core';\nimport { parseFilterScalar } from '@rapiq/parser-simple';\nimport {\n FILTER_EXPRESSION_KEYWORDS,\n FILTER_FIELD_SEGMENT_PATTERN,\n FilterTokenType,\n} from './constants';\nimport type { FilterToken } from './types';\n\ntype FiltersScope = ResolutionScope<`${Parameter.FILTERS}`>;\n\n/**\n * Keep recursive expression parsing below the JavaScript call-stack limit and\n * aligned with the schema resolver and Mongo parser traversal caps.\n */\nconst MAX_DEPTH = MAX_TRAVERSAL_DEPTH;\n\n/**\n * Bidirectional complement twins derived from the semantics table:\n * a not(…) around a single leaf normalizes to the leaf's twin\n * (not(eq) → ne, not(nin) → in) instead of a symbolic NOT node —\n * both lower to the identical plan, the twin is the canonical form.\n */\nconst COMPLEMENT_TWINS : Record<string, string> = {};\nfor (const [operator, semantics] of Object.entries(FILTER_OPERATOR_SEMANTICS)) {\n const twin = (semantics as { complementOf?: string }).complementOf;\n if (twin) {\n COMPLEMENT_TWINS[operator] = twin;\n COMPLEMENT_TWINS[twin] = operator;\n }\n}\n\n/**\n * @see https://www.jsonapi.net/usage/reading/filtering.html\n */\nexport class ExpressionFiltersParser extends BaseParser<\n FiltersParseOptions,\n IFilters\n> {\n private tokens: FilterToken[] = [];\n\n private pos = 0;\n\n /**\n * How many elemMatch interiors the parser is currently inside —\n * the ITSELF marker is only legal at depth > 0.\n */\n private elemMatchDepth = 0;\n\n // ---------------------------------------------------------\n\n parse<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD> = {},\n ) : IFilters {\n const ledger : RelationLedger = [];\n\n return this.withTrace({ parameter: Parameter.FILTERS }, (issueCollector) => {\n const { output, scope } = this.build(input, options, ledger, issueCollector);\n if (!scope) {\n return output;\n }\n\n return applyFiltersIndexPolicy(\n pruneFiltersByRelations(output, applyKeySchemaValidation(ledger, options.context, {\n throwOnFailure: scope.relationsThrowOnFailure,\n errors: RelationsParseError,\n issueCollector,\n }), scope.schema as FiltersSchema<RECORD>, issueCollector),\n this.registry,\n options.schema,\n { throwOnFailure: options.throwOnFailure, issueCollector },\n );\n });\n }\n\n override async parseAsync<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD> = {},\n ) : Promise<IFilters> {\n const ledger : RelationLedger = [];\n\n return this.withTraceAsync({ parameter: Parameter.FILTERS }, async (issueCollector) => {\n const { output, scope } = await this.buildAsync(input, options, ledger, issueCollector);\n if (!scope) {\n return output;\n }\n\n return applyFiltersIndexPolicy(\n pruneFiltersByRelations(output, await applyKeySchemaValidationAsync(ledger, options.context, {\n throwOnFailure: scope.relationsThrowOnFailure,\n errors: RelationsParseError,\n issueCollector,\n }), scope.schema as FiltersSchema<RECORD>, issueCollector),\n this.registry,\n options.schema,\n { throwOnFailure: options.throwOnFailure, issueCollector },\n );\n });\n }\n\n parseParameter<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n issueCollector?: IIssueCollector,\n ) : IFilters {\n // whoever opens a trace raises it: driven by the query orchestrator\n // this records into the enclosing one and decides nothing, driven\n // directly it raises its own. The dialect resolves keys under an\n // always-throwing scope, so the abort route is the usual one here.\n return this.withTrace({ parameter: Parameter.FILTERS, driver: issueCollector }, (trace) =>\n this.build(input, options, ledger, trace).output);\n }\n\n\n async parseParameterAsync<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n issueCollector?: IIssueCollector,\n ) : Promise<IFilters> {\n return this.withTraceAsync({ parameter: Parameter.FILTERS, driver: issueCollector }, async (trace) =>\n (await this.buildAsync(input, options, ledger, trace)).output);\n }\n\n parseExact<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD> = {},\n ) : ICondition {\n // raw exact tree; a standalone caller wanting relation authorization\n // uses parse(). Obligations are discarded, not pooled.\n return this.withTrace({ parameter: Parameter.FILTERS }, (issueCollector) =>\n this.parseValidated(input, options, [], issueCollector).result);\n }\n\n async parseExactAsync<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD> = {},\n ) : Promise<ICondition> {\n return this.withTraceAsync({ parameter: Parameter.FILTERS }, async (issueCollector) =>\n (await this.parseValidatedAsync(input, options, [], issueCollector)).result);\n }\n\n // ---------------------------------------------------------\n\n /**\n * Resolve + leaf-validate + wrap into the root filters node, recording the\n * relation obligations it traverses into `ledger` (the scope's sink). Relation\n * authorization stays with the caller. `scope` is undefined for a schemaless\n * parse (nothing to authorize).\n */\n protected build<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n issueCollector?: IIssueCollector,\n ) : { output: IFilters, scope?: FiltersScope } {\n if (input === undefined || input === null) {\n return { output: this.buildAbsentOutput(options) };\n }\n\n const { result, scope } = this.parseValidated(input, options, ledger, issueCollector);\n\n return { output: this.wrapRoot(result), scope };\n }\n\n protected async buildAsync<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n issueCollector?: IIssueCollector,\n ) : Promise<{ output: IFilters, scope?: FiltersScope }> {\n if (input === undefined || input === null) {\n return { output: this.buildAbsentOutput(options) };\n }\n\n const { result, scope } = await this.parseValidatedAsync(input, options, ledger, issueCollector);\n\n return { output: this.wrapRoot(result), scope };\n }\n\n /**\n * The shared validated-parse of {@link parse} and {@link parseExact}:\n * tokenize + resolve + apply the filters leaf validator, returning the\n * bound scope so the caller can additionally authorize traversed relations.\n */\n private parseValidated<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n issueCollector?: IIssueCollector,\n ) : { result: ICondition, scope?: FiltersScope } {\n const { expr, scope } = this.parseSource(input, options, ledger);\n if (!scope) {\n return { result: expr };\n }\n\n const validated = applyFiltersSchemaValidation(expr, scope.schema, options.context, {\n issueCollector,\n throwOnFailure: options.throwOnFailure,\n });\n\n return {\n result: validated ?? new Filters(\n FilterCompoundOperator.AND,\n buildFiltersDefaults(scope.schema),\n ),\n scope,\n };\n }\n\n private async parseValidatedAsync<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n issueCollector?: IIssueCollector,\n ) : Promise<{ result: ICondition, scope?: FiltersScope }> {\n const { expr, scope } = this.parseSource(input, options, ledger);\n if (!scope) {\n return { result: expr };\n }\n\n const validated = await applyFiltersSchemaValidationAsync(\n expr,\n scope.schema,\n options.context,\n { issueCollector, throwOnFailure: options.throwOnFailure },\n );\n\n return {\n result: validated ?? new Filters(\n FilterCompoundOperator.AND,\n buildFiltersDefaults(scope.schema),\n ),\n scope,\n };\n }\n\n // ---------------------------------------------------------\n\n /**\n * The shared front-end of {@link parseValidated}: tokenize, bind the\n * resolution scope (recording relation obligations into `ledger`) and run\n * the grammar — everything up to (but excluding) validation.\n */\n private parseSource<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n ) : { expr: Filters | Filter, scope?: FiltersScope } {\n if (typeof input !== 'string') {\n throw FiltersParseError.inputInvalid();\n }\n\n this.pos = 0;\n this.elemMatchDepth = 0;\n this.tokens = this.tokenize(input);\n\n // expressions are precise — invalid keys always throw,\n // but only when a schema (or the strict override,\n // which rejects undeclared keys) constrains the parse.\n let scope : FiltersScope | undefined;\n if (options.schema || options.strict) {\n scope = ResolutionScope.for(this.registry, Parameter.FILTERS, options.schema, {\n relations: options.relations,\n throwOnFailure: options.throwOnFailure,\n // the forcing is about KEYS: an expression cannot be partially\n // reinterpreted. Whether a relations validator declining a\n // relation fails the request stays the caller's call, as\n // everywhere else.\n resolutionThrowOnFailure: true,\n strict: options.strict,\n obligationSink: ledger,\n }) as FiltersScope;\n }\n\n const expr = this.parseFilterExpression(scope);\n if (this.peek().type !== FilterTokenType.EOF) {\n throw FiltersParseError.syntaxInvalid(`Unexpected token: ${this.peek().type}`);\n }\n\n return { expr, scope };\n }\n\n private buildAbsentOutput<RECORD extends ObjectLiteral = ObjectLiteral>(\n options: FiltersParseOptions<RECORD>,\n ) : IFilters {\n const scope = ResolutionScope.for(this.registry, Parameter.FILTERS, options.schema, { relations: options.relations }) as FiltersScope;\n\n return new Filters(\n FilterCompoundOperator.AND,\n buildFiltersDefaults(scope.schema),\n );\n }\n\n private wrapRoot(expr: ICondition) : IFilters {\n if (\n isFilters(expr, FilterCompoundOperator.AND) ||\n isFilters(expr, FilterCompoundOperator.OR)\n ) {\n return expr;\n }\n\n return new Filters(FilterCompoundOperator.AND, [expr]);\n }\n\n // ---------------------------------------------------------\n\n private peek(): FilterToken {\n return this.tokens[this.pos] || { type: FilterTokenType.EOF };\n }\n\n private consume(expected?: `${FilterTokenType}`): FilterToken {\n const token = this.peek();\n if (expected && token.type !== expected) {\n throw FiltersParseError.syntaxInvalid(`Expected ${expected}, got ${token.type}`);\n }\n this.pos++;\n return token;\n }\n\n private tokenize(input: string): FilterToken[] {\n const tokens: FilterToken[] = [];\n // keywords are classified from whole identifiers (lookup below) —\n // matching them in the regex would split identifiers that merely\n // start with a keyword (e.g. \"order\" -> \"or\" + \"der\").\n // $-words are reserved markers, never field segments.\n const regex = new RegExp(`\\\\s+|\\\\(|\\\\)|,|\\\\.|'(?:''|[^'])*'|\\\\$[A-Za-z0-9_]*|${FILTER_FIELD_SEGMENT_PATTERN}`, 'g');\n\n let match: RegExpExecArray | null;\n let cursor = 0;\n\n while ((match = regex.exec(input))) {\n if (match.index !== cursor) {\n throw FiltersParseError.syntaxInvalid(`Unexpected character at position ${cursor}.`);\n }\n\n const value = match[0];\n cursor = regex.lastIndex;\n if (/^\\s+$/.test(value)) continue;\n\n switch (value) {\n case '(': tokens.push({ type: FilterTokenType.LPAREN }); break;\n case ')': tokens.push({ type: FilterTokenType.RPAREN }); break;\n case ',': tokens.push({ type: FilterTokenType.COMMA }); break;\n case '.': tokens.push({ type: FilterTokenType.DOT }); break;\n default:\n if (value.startsWith('$')) {\n if (value !== ITSELF) {\n throw FiltersParseError.syntaxInvalid(`The marker ${value} is unknown.`);\n }\n\n tokens.push({ type: FilterTokenType.ITSELF });\n break;\n }\n\n // own-property check: exotic field names inherited from\n // Object.prototype (toString, constructor, ...) stay fields.\n if (Object.prototype.hasOwnProperty.call(FILTER_EXPRESSION_KEYWORDS, value)) {\n tokens.push({ type: FILTER_EXPRESSION_KEYWORDS[value as keyof typeof FILTER_EXPRESSION_KEYWORDS] });\n } else if (\n value.startsWith('\\'') &&\n value.endsWith('\\'')\n ) {\n tokens.push({ type: FilterTokenType.ESCAPED_TEXT, value });\n } else {\n tokens.push({ type: FilterTokenType.FIELD, value });\n }\n }\n }\n\n if (cursor !== input.length) {\n throw FiltersParseError.syntaxInvalid(`Unexpected character at position ${cursor}.`);\n }\n\n tokens.push({ type: FilterTokenType.EOF });\n return tokens;\n }\n\n private parseFilterExpression(\n scope?: FiltersScope,\n depth: number = 0,\n ) : Filters | Filter {\n if (depth > MAX_DEPTH) {\n throw FiltersParseError.syntaxInvalid('The maximum nesting depth was exceeded.');\n }\n\n const token = this.peek();\n switch (token.type) {\n case FilterTokenType.NOT:\n return this.parseNotExpression(scope, depth);\n case FilterTokenType.AND:\n case FilterTokenType.OR:\n return this.parseLogicalExpression(scope, depth);\n case FilterTokenType.EQUAL:\n case FilterTokenType.GREATER_THAN:\n case FilterTokenType.GREATER_OR_EQUAL:\n case FilterTokenType.LESS_THAN:\n case FilterTokenType.LESS_OR_EQUAL:\n return this.parseComparisonExpression(scope);\n case FilterTokenType.CONTAINS:\n case FilterTokenType.STARTS_WITH:\n case FilterTokenType.ENDS_WITH:\n return this.parseMatchExpression(scope);\n case FilterTokenType.IN:\n case FilterTokenType.NIN:\n return this.parseInExpression(scope);\n case FilterTokenType.ELEM_MATCH:\n return this.parseElemMatchExpression(scope, depth);\n case FilterTokenType.SIZE:\n return this.parseSizeExpression(scope);\n default:\n throw FiltersParseError.syntaxInvalid(`Unexpected token in filter expression: ${token.type}`);\n }\n }\n\n /**\n * not(expr): the exact complement of the interior (null-inclusive\n * complement law). A single leaf with a complement twin normalizes\n * to the twin, a double negation cancels; everything else stays a\n * first-class NOT node.\n */\n private parseNotExpression(\n scope?: FiltersScope,\n depth: number = 0,\n ): Filters | Filter {\n this.consume(FilterTokenType.NOT);\n this.consume(FilterTokenType.LPAREN);\n const expr = this.parseFilterExpression(scope, depth + 1);\n this.consume(FilterTokenType.RPAREN);\n\n if (isFilter(expr)) {\n const twin = COMPLEMENT_TWINS[expr.operator];\n if (twin) {\n return new Filter(twin as FilterFieldOperator, expr.field, expr.value);\n }\n }\n\n if (\n isFilters(expr, FilterCompoundOperator.NOT) &&\n expr.value.length === 1\n ) {\n return expr.value[0] as Filters | Filter;\n }\n\n return new Filters(FilterCompoundOperator.NOT, [expr]);\n }\n\n private parseLogicalExpression(\n scope?: FiltersScope,\n depth: number = 0,\n ): Filters | Filter {\n const op = this.consume().type; // AND / OR\n if (op !== FilterTokenType.AND && op !== FilterTokenType.OR) {\n throw FiltersParseError.syntaxInvalid('Expected AND or OR token type.');\n }\n\n this.consume(FilterTokenType.LPAREN);\n const expressions: (Filter | Filters)[] = [this.parseFilterExpression(scope, depth + 1)];\n while (this.peek().type === FilterTokenType.COMMA) {\n this.consume(FilterTokenType.COMMA);\n expressions.push(this.parseFilterExpression(scope, depth + 1));\n }\n this.consume(FilterTokenType.RPAREN);\n\n if (op === FilterTokenType.AND) {\n return new Filters(\n FilterCompoundOperator.AND,\n expressions,\n );\n }\n\n return new Filters(FilterCompoundOperator.OR, expressions);\n }\n\n private parseComparisonExpression(\n scope?: FiltersScope,\n ): Filters | Filter {\n const op = this.consume().type;\n this.consume(FilterTokenType.LPAREN);\n const left = this.parseExpressionFieldChain(scope);\n this.consume(FilterTokenType.COMMA);\n const right = this.parseExpressionValue();\n this.consume(FilterTokenType.RPAREN);\n\n switch (op) {\n case FilterTokenType.EQUAL: {\n return new Filter(\n FilterFieldOperator.EQUAL,\n left as string,\n right as string,\n );\n }\n case FilterTokenType.GREATER_THAN: {\n return new Filter(\n FilterFieldOperator.GREATER_THAN,\n left as string,\n right as string,\n );\n }\n case FilterTokenType.GREATER_OR_EQUAL: {\n return new Filter(\n FilterFieldOperator.GREATER_THAN_EQUAL,\n left as string,\n right as string,\n );\n }\n case FilterTokenType.LESS_THAN: {\n return new Filter(\n FilterFieldOperator.LESS_THAN,\n left as string,\n right as string,\n );\n }\n case FilterTokenType.LESS_OR_EQUAL: {\n return new Filter(\n FilterFieldOperator.LESS_THAN_EQUAL,\n left as string,\n right as string,\n );\n }\n }\n\n throw FiltersParseError.syntaxInvalid(`Token type ${op} not supported as comparison operator.`);\n }\n\n private parseMatchExpression(\n scope?: FiltersScope,\n ): Filters | Filter {\n const op = this.consume().type;\n this.consume(FilterTokenType.LPAREN);\n const field = this.parseExpressionFieldChain(scope);\n this.consume(FilterTokenType.COMMA);\n const text = this.consume(FilterTokenType.ESCAPED_TEXT).value!;\n this.consume(FilterTokenType.RPAREN);\n\n // the anchored operators match a literal substring, so the pattern\n // is transport text and is kept verbatim — never run through the\n // scalar grammar. Coercing it would reject a numeric pattern\n // (contains(title, '2024')) and silently trim a whitespace one into\n // a match-everything predicate. Mirrors the simple dialect, which\n // tags exactly these three operators `value: 'raw'`.\n const normalized = text.length >= 2 ?\n text.slice(1, -1).replace(/''/g, '\\'') :\n text;\n\n switch (op) {\n case FilterTokenType.CONTAINS: {\n return new Filter(\n FilterFieldOperator.CONTAINS,\n field,\n normalized,\n );\n }\n case FilterTokenType.ENDS_WITH: {\n return new Filter(\n FilterFieldOperator.ENDS_WITH,\n field,\n normalized,\n );\n }\n default: {\n return new Filter(\n FilterFieldOperator.STARTS_WITH,\n field,\n normalized,\n );\n }\n }\n }\n\n private parseInExpression(\n scope?: FiltersScope,\n ): Filters | Filter {\n const token = this.peek();\n if (token.type === FilterTokenType.NIN) {\n this.consume(FilterTokenType.NIN);\n } else {\n this.consume(FilterTokenType.IN);\n }\n\n this.consume(FilterTokenType.LPAREN);\n\n const field = this.parseExpressionFieldChain(scope);\n\n const values: unknown[] = [];\n while (this.peek().type === FilterTokenType.COMMA) {\n this.consume(FilterTokenType.COMMA);\n\n values.push(this.parseExpressionValue());\n }\n this.consume(FilterTokenType.RPAREN);\n\n if (token.type === FilterTokenType.NIN) {\n return new Filter(\n FilterFieldOperator.NOT_IN,\n field,\n values,\n );\n }\n\n return new Filter(\n FilterFieldOperator.IN,\n field,\n values,\n );\n }\n\n /**\n * size(field, n): the field holds an array of exactly n elements\n * (a non-negative integer — the wire is untyped, so the quoted\n * value coerces back to a number).\n */\n private parseSizeExpression(\n scope?: FiltersScope,\n ): Filter {\n this.consume(FilterTokenType.SIZE);\n this.consume(FilterTokenType.LPAREN);\n const field = this.parseExpressionFieldChain(scope);\n this.consume(FilterTokenType.COMMA);\n const value = this.parseExpressionValue();\n this.consume(FilterTokenType.RPAREN);\n\n if (\n typeof value !== 'number' ||\n !Number.isSafeInteger(value) ||\n value < 0\n ) {\n throw FiltersParseError.keyValueInvalid(field);\n }\n\n return new Filter(FilterFieldOperator.SIZE, field, value);\n }\n\n /**\n * elemMatch(field, expr): field paths inside the interior are\n * relative to the array element; the ITSELF marker addresses the\n * element itself.\n */\n private parseElemMatchExpression(\n scope?: FiltersScope,\n depth: number = 0,\n ): Filter {\n this.consume(FilterTokenType.ELEM_MATCH);\n this.consume(FilterTokenType.LPAREN);\n\n const target = this.parseElemMatchTarget(scope);\n\n this.consume(FilterTokenType.COMMA);\n\n this.elemMatchDepth += 1;\n\n let condition : Filters | Filter;\n try {\n condition = this.parseFilterExpression(target.scope, depth + 1);\n } finally {\n this.elemMatchDepth -= 1;\n }\n\n this.consume(FilterTokenType.RPAREN);\n\n return new Filter(FilterFieldOperator.ELEM_MATCH, target.field, condition);\n }\n\n /**\n * The field an elemMatch binds plus the interior resolution scope:\n * the related schema when resolvable, otherwise an unbound scope\n * inheriting the current policy (e.g. a JSON array column).\n */\n private parseElemMatchTarget(\n scope?: FiltersScope,\n ): { field: string, scope?: FiltersScope } {\n if (this.peek().type === FilterTokenType.ITSELF) {\n // an elemMatch on the element itself (arrays of arrays);\n // the chain parser enforces the interior-only contract.\n const field = this.parseExpressionFieldChain(scope);\n\n return {\n field,\n scope: scope ? this.buildUnboundScope(scope) : undefined,\n };\n }\n\n const token = this.consume(FilterTokenType.FIELD);\n\n const parts = [token.value!];\n while (this.peek().type === FilterTokenType.DOT) {\n this.consume(FilterTokenType.DOT);\n parts.push(this.consume(FilterTokenType.FIELD).value!);\n }\n\n if (!scope) {\n return { field: parts.join('.') };\n }\n\n // a leading segment matching the schema name addresses the\n // schema itself (mirrors parseExpressionFieldChain).\n if (\n parts.length > 1 &&\n (parts[0] === DEFAULT_ID || parts[0] === scope.schema.name)\n ) {\n parts.shift();\n }\n\n const resolved = scope.resolveKey(parts.join('.'));\n\n /* istanbul ignore next -- the scope always throws */\n if (!resolved.success) {\n throw FiltersParseError.keyInvalid(resolved.input);\n }\n\n const field = [...resolved.path, resolved.name].join('.');\n\n let interior : FiltersScope | undefined;\n try {\n const verdict = resolved.scope.descend(resolved.name);\n if (verdict instanceof ResolutionScope) {\n interior = verdict as FiltersScope;\n }\n } catch (e) {\n // elemMatch on a non-relation field is legal — a missing\n // related schema (thrown as keyPathInvalid, the scope is\n // always throwing) falls back to the unbound scope; every\n // other failure (e.g. relations gating) propagates.\n if (\n !isParseError(e) ||\n e.code !== ErrorCode.KEY_PATH_INVALID\n ) {\n throw e;\n }\n }\n\n return {\n field,\n scope: interior ?? this.buildUnboundScope(scope),\n };\n }\n\n private buildUnboundScope(current: FiltersScope) : FiltersScope {\n return ResolutionScope.for(this.registry, Parameter.FILTERS, undefined, {\n throwOnFailure: true,\n strict: current.strict,\n }) as FiltersScope;\n }\n\n private parseExpressionValue(): Scalar {\n const token = this.consume();\n\n if (\n token.type !== FilterTokenType.ESCAPED_TEXT &&\n token.type !== FilterTokenType.NULL\n ) {\n throw FiltersParseError.syntaxInvalid(`Unexpected token in value: ${token.type}`);\n }\n\n return this.normalizeValue(token.value ?? 'null');\n }\n\n private parseExpressionFieldChain(\n scope?: FiltersScope,\n ): string {\n if (this.peek().type === FilterTokenType.ITSELF) {\n this.consume(FilterTokenType.ITSELF);\n\n // the marker addresses the element bound by the enclosing\n // elemMatch interior and never resolves against the schema.\n if (this.elemMatchDepth === 0) {\n throw FiltersParseError.keyInvalid(ITSELF);\n }\n\n return ITSELF;\n }\n\n const token = this.consume(FilterTokenType.FIELD);\n if (token.type !== FilterTokenType.FIELD) {\n throw FiltersParseError.syntaxInvalid(`Unexpected token in field chain: ${token.type}`);\n }\n\n const parts = [token.value!];\n\n while (this.peek().type === FilterTokenType.DOT) {\n this.consume(FilterTokenType.DOT);\n parts.push(this.consume(FilterTokenType.FIELD).value!);\n }\n\n if (scope) {\n // a leading segment matching the schema name addresses the\n // schema itself (mirrors the named-group hoisting of the\n // simple filters parser) and is stripped.\n if (\n parts.length > 1 &&\n (parts[0] === DEFAULT_ID || parts[0] === scope.schema.name)\n ) {\n parts.shift();\n }\n\n const resolved = scope.resolveKey(parts.join('.'));\n\n /* istanbul ignore next -- the scope always throws */\n if (!resolved.success) {\n throw FiltersParseError.keyInvalid(resolved.input);\n }\n\n return [...resolved.path, resolved.name].join('.');\n }\n\n return parts.join('.');\n }\n\n // ---------------------------------------------------------\n\n protected normalizeValue(input: unknown) : Scalar {\n if (typeof input === 'string') {\n const trimmed = input.trim();\n if (trimmed.length === 0) {\n return trimmed;\n }\n\n // quoted content is coerced but never comma-split —\n // the expression dialect passes lists as separate args.\n if (\n trimmed.startsWith('\\'') &&\n trimmed.endsWith('\\'') &&\n trimmed.length >= 2\n ) {\n return parseFilterScalar(trimmed.slice(1, -1).replace(/''/g, '\\''));\n }\n\n return parseFilterScalar(trimmed);\n }\n\n if (typeof input === 'number') {\n return input;\n }\n\n if (typeof input === 'undefined' || input === null) {\n return null;\n }\n\n throw FiltersParseError.syntaxInvalid('the value could not be normalized');\n }\n}\n","/*\n * Copyright (c) 2022-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SimplePaginationParser } from '@rapiq/parser-simple';\nimport type { ExpressionPaginationParseOptions } from './types';\n\nexport class ExpressionPaginationParser extends SimplePaginationParser<ExpressionPaginationParseOptions> {\n\n}\n","/*\n * Copyright (c) 2021-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SimpleRelationsParser } from '@rapiq/parser-simple';\n\nexport class ExpressionRelationsParser extends SimpleRelationsParser {\n\n}\n","/*\n * Copyright (c) 2021-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SimpleSortsParser } from '@rapiq/parser-simple';\n\nexport class ExpressionSortsParser extends SimpleSortsParser {\n\n}\n\n/**\n * @deprecated use {@link ExpressionSortsParser}. Removed in 3.0.\n */\nexport const ExpressionSortParser = ExpressionSortsParser;\n\n/**\n * @deprecated use {@link ExpressionSortsParser}. Removed in 3.0.\n */\nexport type ExpressionSortParser = ExpressionSortsParser;\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { SchemaRegistry } from '@rapiq/core';\nimport { BaseQueryParser } from '@rapiq/core';\nimport { SimpleAggregatesParser, SimpleGroupsParser } from '@rapiq/parser-simple';\nimport {\n ExpressionFieldsParser,\n ExpressionFiltersParser,\n ExpressionPaginationParser,\n ExpressionRelationsParser,\n ExpressionSortsParser,\n} from './parameter';\n\nexport class ExpressionParser extends BaseQueryParser {\n protected fieldsParser : ExpressionFieldsParser;\n\n protected filtersParser : ExpressionFiltersParser;\n\n protected paginationParser : ExpressionPaginationParser;\n\n protected relationsParser : ExpressionRelationsParser;\n\n protected sortParser : ExpressionSortsParser;\n\n // -----------------------------------------------------\n\n constructor(input?: SchemaRegistry) {\n super(input);\n\n this.fieldsParser = new ExpressionFieldsParser(this.registry);\n this.filtersParser = new ExpressionFiltersParser(this.registry);\n this.paginationParser = new ExpressionPaginationParser(this.registry);\n this.relationsParser = new ExpressionRelationsParser(this.registry);\n this.sortParser = new ExpressionSortsParser(this.registry);\n // one call-term grammar serves every dialect.\n this.groupsParser = new SimpleGroupsParser(this.registry);\n this.aggregatesParser = new SimpleAggregatesParser(this.registry);\n }\n}\n"],"mappings":";;;AASA,IAAa,yBAAb,cAA4C,mBAAmB,CAE/D;;;ACJA,IAAY,kBAAL,yBAAA,iBAAA;CACH,gBAAA,SAAA;CAEA,gBAAA,SAAA;CACA,gBAAA,QAAA;CAEA,gBAAA,WAAA;CACA,gBAAA,kBAAA;CACA,gBAAA,sBAAA;CACA,gBAAA,eAAA;CACA,gBAAA,mBAAA;CACA,gBAAA,cAAA;CACA,gBAAA,iBAAA;CACA,gBAAA,eAAA;CACA,gBAAA,QAAA;CACA,gBAAA,SAAA;CACA,gBAAA,gBAAA;CACA,gBAAA,UAAA;CAEA,gBAAA,WAAA;CACA,gBAAA,YAAA;CACA,gBAAA,kBAAA;CACA,gBAAA,UAAA;CACA,gBAAA,YAAA;CACA,gBAAA,YAAA;CACA,gBAAA,WAAA;CACA,gBAAA,SAAA;CACA,gBAAA,SAAA;;AACJ,EAAA,CAAA,CAAA;;;;;;;AAQA,MAAa,6BAA6B;CACtC,KAAA;CACA,KAAA;CACA,IAAA;CACA,IAAA;CACA,IAAA;CACA,KAAA;CACA,IAAA;CACA,KAAA;CACA,UAAA;CACA,YAAA;CACA,UAAA;CACA,IAAA;CACA,KAAA;CACA,WAAA;CACA,MAAA;CACA,MAAA;AACJ;;;;;;AAOA,MAAa,+BAA+B;;;;;;;ACV5C,MAAM,YAAY;;;;;;;AAQlB,MAAM,mBAA4C,CAAC;AACnD,KAAK,MAAM,CAAC,UAAU,cAAc,OAAO,QAAQ,yBAAyB,GAAG;CAC3E,MAAM,OAAQ,UAAwC;CACtD,IAAI,MAAM;EACN,iBAAiB,YAAY;EAC7B,iBAAiB,QAAQ;CAC7B;AACJ;;;;AAKA,IAAa,0BAAb,cAA6C,WAG3C;CACE,SAAgC,CAAC;CAEjC,MAA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parameter/filters/constants.ts","../src/parameter/filters/module.ts","../src/parameter/pagination/module.ts","../src/parameter/relations/module.ts","../src/parameter/sorts/module.ts","../src/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2025-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SimpleFieldsParser } from '@rapiq/parser-simple';\n\nexport class ExpressionFieldsParser extends SimpleFieldsParser {\n\n}\n","/*\n * Copyright (c) 2025-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum FilterTokenType {\n NOT = 'NOT',\n\n AND = 'AND',\n OR = 'OR',\n\n EQUAL = 'eq',\n GREATER_THAN = 'gt',\n GREATER_OR_EQUAL = 'gte',\n LESS_THAN = 'lt',\n LESS_OR_EQUAL = 'lte',\n CONTAINS = 'like',\n STARTS_WITH = 'startsWith',\n ENDS_WITH = 'endsWith',\n IN = 'in',\n NIN = 'nin',\n ELEM_MATCH = 'elemMatch',\n SIZE = 'size',\n\n FIELD = 'FIELD',\n ITSELF = 'ITSELF',\n ESCAPED_TEXT = 'ESCAPED_TEXT',\n NULL = 'NULL',\n LPAREN = 'LPAREN',\n RPAREN = 'RPAREN',\n COMMA = 'COMMA',\n DOT = 'DOT',\n EOF = 'EOF',\n}\n\n/**\n * Grammar keywords of the expression dialect mapped to the token\n * they classify as. The tokenizer classifies whole identifiers\n * against this map; encoders consume its keys to reject field\n * segments that would tokenize as an operator on decode.\n */\nexport const FILTER_EXPRESSION_KEYWORDS = {\n not: FilterTokenType.NOT,\n and: FilterTokenType.AND,\n or: FilterTokenType.OR,\n eq: FilterTokenType.EQUAL,\n gt: FilterTokenType.GREATER_THAN,\n gte: FilterTokenType.GREATER_OR_EQUAL,\n lt: FilterTokenType.LESS_THAN,\n lte: FilterTokenType.LESS_OR_EQUAL,\n contains: FilterTokenType.CONTAINS,\n startsWith: FilterTokenType.STARTS_WITH,\n endsWith: FilterTokenType.ENDS_WITH,\n in: FilterTokenType.IN,\n nin: FilterTokenType.NIN,\n elemMatch: FilterTokenType.ELEM_MATCH,\n size: FilterTokenType.SIZE,\n null: FilterTokenType.NULL,\n} as const satisfies Record<string, FilterTokenType>;\n\n/**\n * Identifier grammar of a single field segment as accepted by the\n * expression tokenizer (unanchored regex source; consumers anchor\n * it as needed).\n */\nexport const FILTER_FIELD_SEGMENT_PATTERN = '[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?';\n","/*\n * Copyright (c) 2021-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type {\n FiltersParseOptions,\n FiltersSchema,\n ICondition,\n IFilters,\n IIssueCollector,\n ObjectLiteral,\n RelationLedger,\n Scalar,\n} from '@rapiq/core';\nimport {\n BaseParser,\n DEFAULT_ID,\n FILTER_OPERATOR_SEMANTICS,\n Filter,\n FilterCompoundOperator,\n FilterFieldOperator,\n Filters,\n FiltersParseError,\n ITSELF,\n MAX_TRAVERSAL_DEPTH,\n Parameter,\n RelationsParseError,\n ResolutionScope,\n applyFiltersIndexPolicy,\n applyFiltersSchemaValidation,\n applyFiltersSchemaValidationAsync,\n applyKeySchemaValidation,\n applyKeySchemaValidationAsync,\n buildFiltersDefaults,\n isFilter,\n isFilters,\n pruneFiltersByRelations,\n} from '@rapiq/core';\nimport { parseFilterScalar } from '@rapiq/parser-simple';\nimport {\n FILTER_EXPRESSION_KEYWORDS,\n FILTER_FIELD_SEGMENT_PATTERN,\n FilterTokenType,\n} from './constants';\nimport type { FilterToken } from './types';\n\ntype FiltersScope = ResolutionScope<`${Parameter.FILTERS}`>;\n\n/**\n * Keep recursive expression parsing below the JavaScript call-stack limit and\n * aligned with the schema resolver and Mongo parser traversal caps.\n */\nconst MAX_DEPTH = MAX_TRAVERSAL_DEPTH;\n\n/**\n * Bidirectional complement twins derived from the semantics table:\n * a not(…) around a single leaf normalizes to the leaf's twin\n * (not(eq) → ne, not(nin) → in) instead of a symbolic NOT node —\n * both lower to the identical plan, the twin is the canonical form.\n */\nconst COMPLEMENT_TWINS : Record<string, string> = {};\n\nfor (const [operator, semantics] of Object.entries(FILTER_OPERATOR_SEMANTICS)) {\n const twin = (semantics as { complementOf?: string }).complementOf;\n\n if (twin) {\n COMPLEMENT_TWINS[operator] = twin;\n COMPLEMENT_TWINS[twin] = operator;\n }\n}\n\n/**\n * @see https://www.jsonapi.net/usage/reading/filtering.html\n */\nexport class ExpressionFiltersParser extends BaseParser<\n FiltersParseOptions,\n IFilters\n> {\n private tokens: FilterToken[] = [];\n\n private pos = 0;\n\n /**\n * How many elemMatch interiors the parser is currently inside —\n * the ITSELF marker is only legal at depth > 0.\n */\n private elemMatchDepth = 0;\n\n // ---------------------------------------------------------\n\n parse<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD> = {},\n ) : IFilters {\n const ledger : RelationLedger = [];\n\n return this.withTrace({ parameter: Parameter.FILTERS }, (issueCollector) => {\n const { output, scope } = this.build(input, options, ledger, issueCollector);\n\n if (!scope) {\n return output;\n }\n\n return applyFiltersIndexPolicy(\n pruneFiltersByRelations(output, applyKeySchemaValidation(ledger, options.context, {\n throwOnFailure: scope.relationsThrowOnFailure,\n errors: RelationsParseError,\n issueCollector,\n }), scope.schema as FiltersSchema<RECORD>, issueCollector),\n this.registry,\n options.schema,\n { throwOnFailure: options.throwOnFailure, issueCollector },\n );\n });\n }\n\n override async parseAsync<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD> = {},\n ) : Promise<IFilters> {\n const ledger : RelationLedger = [];\n\n return this.withTraceAsync({ parameter: Parameter.FILTERS }, async (issueCollector) => {\n const { output, scope } = await this.buildAsync(input, options, ledger, issueCollector);\n\n if (!scope) {\n return output;\n }\n\n return applyFiltersIndexPolicy(\n pruneFiltersByRelations(output, await applyKeySchemaValidationAsync(ledger, options.context, {\n throwOnFailure: scope.relationsThrowOnFailure,\n errors: RelationsParseError,\n issueCollector,\n }), scope.schema as FiltersSchema<RECORD>, issueCollector),\n this.registry,\n options.schema,\n { throwOnFailure: options.throwOnFailure, issueCollector },\n );\n });\n }\n\n parseParameter<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n issueCollector?: IIssueCollector,\n ) : IFilters {\n // whoever opens a trace raises it: driven by the query orchestrator\n // this records into the enclosing one and decides nothing, driven\n // directly it raises its own. The dialect resolves keys under an\n // always-throwing scope, so the abort route is the usual one here.\n return this.withTrace({ parameter: Parameter.FILTERS, driver: issueCollector }, (trace) =>\n this.build(input, options, ledger, trace).output);\n }\n\n\n async parseParameterAsync<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n issueCollector?: IIssueCollector,\n ) : Promise<IFilters> {\n return this.withTraceAsync({ parameter: Parameter.FILTERS, driver: issueCollector }, async (trace) =>\n (await this.buildAsync(input, options, ledger, trace)).output);\n }\n\n parseExact<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD> = {},\n ) : ICondition {\n // raw exact tree; a standalone caller wanting relation authorization\n // uses parse(). Obligations are discarded, not pooled.\n return this.withTrace({ parameter: Parameter.FILTERS }, (issueCollector) =>\n this.parseValidated(input, options, [], issueCollector).result);\n }\n\n async parseExactAsync<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD> = {},\n ) : Promise<ICondition> {\n return this.withTraceAsync({ parameter: Parameter.FILTERS }, async (issueCollector) =>\n (await this.parseValidatedAsync(input, options, [], issueCollector)).result);\n }\n\n // ---------------------------------------------------------\n\n /**\n * Resolve + leaf-validate + wrap into the root filters node, recording the\n * relation obligations it traverses into `ledger` (the scope's sink). Relation\n * authorization stays with the caller. `scope` is undefined for a schemaless\n * parse (nothing to authorize).\n */\n protected build<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n issueCollector?: IIssueCollector,\n ) : { output: IFilters, scope?: FiltersScope } {\n if (input === undefined || input === null) {\n return { output: this.buildAbsentOutput(options) };\n }\n\n const { result, scope } = this.parseValidated(input, options, ledger, issueCollector);\n\n return { output: this.wrapRoot(result), scope };\n }\n\n protected async buildAsync<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n issueCollector?: IIssueCollector,\n ) : Promise<{ output: IFilters, scope?: FiltersScope }> {\n if (input === undefined || input === null) {\n return { output: this.buildAbsentOutput(options) };\n }\n\n const { result, scope } = await this.parseValidatedAsync(input, options, ledger, issueCollector);\n\n return { output: this.wrapRoot(result), scope };\n }\n\n /**\n * The shared validated-parse of {@link parse} and {@link parseExact}:\n * tokenize + resolve + apply the filters leaf validator, returning the\n * bound scope so the caller can additionally authorize traversed relations.\n */\n private parseValidated<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n issueCollector?: IIssueCollector,\n ) : { result: ICondition, scope?: FiltersScope } {\n const { expr, scope } = this.parseSource(input, options, ledger);\n\n if (!scope) {\n return { result: expr };\n }\n\n const validated = applyFiltersSchemaValidation(expr, scope.schema, options.context, {\n issueCollector,\n throwOnFailure: options.throwOnFailure,\n });\n\n return {\n result: validated ?? new Filters(\n FilterCompoundOperator.AND,\n buildFiltersDefaults(scope.schema),\n ),\n scope,\n };\n }\n\n private async parseValidatedAsync<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n issueCollector?: IIssueCollector,\n ) : Promise<{ result: ICondition, scope?: FiltersScope }> {\n const { expr, scope } = this.parseSource(input, options, ledger);\n\n if (!scope) {\n return { result: expr };\n }\n\n const validated = await applyFiltersSchemaValidationAsync(\n expr,\n scope.schema,\n options.context,\n { issueCollector, throwOnFailure: options.throwOnFailure },\n );\n\n return {\n result: validated ?? new Filters(\n FilterCompoundOperator.AND,\n buildFiltersDefaults(scope.schema),\n ),\n scope,\n };\n }\n\n // ---------------------------------------------------------\n\n /**\n * The shared front-end of {@link parseValidated}: tokenize, bind the\n * resolution scope (recording relation obligations into `ledger`) and run\n * the grammar — everything up to (but excluding) validation.\n */\n private parseSource<RECORD extends ObjectLiteral = ObjectLiteral>(\n input: unknown,\n options: FiltersParseOptions<RECORD>,\n ledger: RelationLedger,\n ) : { expr: Filters | Filter, scope?: FiltersScope } {\n if (typeof input !== 'string') {\n throw FiltersParseError.inputInvalid();\n }\n\n this.pos = 0;\n this.elemMatchDepth = 0;\n this.tokens = this.tokenize(input);\n\n // expressions are precise — invalid keys always throw,\n // but only when a schema (or the strict override,\n // which rejects undeclared keys) constrains the parse.\n let scope : FiltersScope | undefined;\n\n if (options.schema || options.strict) {\n scope = ResolutionScope.for(this.registry, Parameter.FILTERS, options.schema, {\n relations: options.relations,\n throwOnFailure: options.throwOnFailure,\n // the forcing is about KEYS: an expression cannot be partially\n // reinterpreted. Whether a relations validator declining a\n // relation fails the request stays the caller's call, as\n // everywhere else.\n resolutionThrowOnFailure: true,\n strict: options.strict,\n obligationSink: ledger,\n }) as FiltersScope;\n }\n\n const expr = this.parseFilterExpression(scope);\n\n if (this.peek().type !== FilterTokenType.EOF) {\n throw FiltersParseError.syntaxInvalid(`Unexpected token: ${this.peek().type}`);\n }\n\n return { expr, scope };\n }\n\n private buildAbsentOutput<RECORD extends ObjectLiteral = ObjectLiteral>(\n options: FiltersParseOptions<RECORD>,\n ) : IFilters {\n const scope = ResolutionScope.for(this.registry, Parameter.FILTERS, options.schema, { relations: options.relations }) as FiltersScope;\n\n return new Filters(\n FilterCompoundOperator.AND,\n buildFiltersDefaults(scope.schema),\n );\n }\n\n private wrapRoot(expr: ICondition) : IFilters {\n if (\n isFilters(expr, FilterCompoundOperator.AND) ||\n isFilters(expr, FilterCompoundOperator.OR)\n ) {\n return expr;\n }\n\n return new Filters(FilterCompoundOperator.AND, [expr]);\n }\n\n // ---------------------------------------------------------\n\n private peek(): FilterToken {\n return this.tokens[this.pos] || { type: FilterTokenType.EOF };\n }\n\n private consume(expected?: `${FilterTokenType}`): FilterToken {\n const token = this.peek();\n\n if (expected && token.type !== expected) {\n throw FiltersParseError.syntaxInvalid(`Expected ${expected}, got ${token.type}`);\n }\n\n this.pos++;\n\n return token;\n }\n\n private tokenize(input: string): FilterToken[] {\n const tokens: FilterToken[] = [];\n // keywords are classified from whole identifiers (lookup below) —\n // matching them in the regex would split identifiers that merely\n // start with a keyword (e.g. \"order\" -> \"or\" + \"der\").\n // $-words are reserved markers, never field segments.\n const regex = new RegExp(`\\\\s+|\\\\(|\\\\)|,|\\\\.|'(?:''|[^'])*'|\\\\$[A-Za-z0-9_]*|${FILTER_FIELD_SEGMENT_PATTERN}`, 'g');\n\n let match: RegExpExecArray | null;\n let cursor = 0;\n\n while ((match = regex.exec(input))) {\n if (match.index !== cursor) {\n throw FiltersParseError.syntaxInvalid(`Unexpected character at position ${cursor}.`);\n }\n\n const value = match[0];\n\n cursor = regex.lastIndex;\n\n if (/^\\s+$/.test(value)) {\n continue;\n }\n\n switch (value) {\n case '(': tokens.push({ type: FilterTokenType.LPAREN });\n\n break;\n case ')': tokens.push({ type: FilterTokenType.RPAREN });\n\n break;\n case ',': tokens.push({ type: FilterTokenType.COMMA });\n\n break;\n case '.': tokens.push({ type: FilterTokenType.DOT });\n\n break;\n default:\n if (value.startsWith('$')) {\n if (value !== ITSELF) {\n throw FiltersParseError.syntaxInvalid(`The marker ${value} is unknown.`);\n }\n\n tokens.push({ type: FilterTokenType.ITSELF });\n\n break;\n }\n\n // own-property check: exotic field names inherited from\n // Object.prototype (toString, constructor, ...) stay fields.\n if (Object.prototype.hasOwnProperty.call(FILTER_EXPRESSION_KEYWORDS, value)) {\n tokens.push({ type: FILTER_EXPRESSION_KEYWORDS[value as keyof typeof FILTER_EXPRESSION_KEYWORDS] });\n } else if (\n value.startsWith('\\'') &&\n value.endsWith('\\'')\n ) {\n tokens.push({ type: FilterTokenType.ESCAPED_TEXT, value });\n } else {\n tokens.push({ type: FilterTokenType.FIELD, value });\n }\n }\n }\n\n if (cursor !== input.length) {\n throw FiltersParseError.syntaxInvalid(`Unexpected character at position ${cursor}.`);\n }\n\n tokens.push({ type: FilterTokenType.EOF });\n\n return tokens;\n }\n\n private parseFilterExpression(\n scope?: FiltersScope,\n depth: number = 0,\n ) : Filters | Filter {\n if (depth > MAX_DEPTH) {\n throw FiltersParseError.syntaxInvalid('The maximum nesting depth was exceeded.');\n }\n\n const token = this.peek();\n\n switch (token.type) {\n case FilterTokenType.NOT:\n return this.parseNotExpression(scope, depth);\n case FilterTokenType.AND:\n case FilterTokenType.OR:\n return this.parseLogicalExpression(scope, depth);\n case FilterTokenType.EQUAL:\n case FilterTokenType.GREATER_THAN:\n case FilterTokenType.GREATER_OR_EQUAL:\n case FilterTokenType.LESS_THAN:\n case FilterTokenType.LESS_OR_EQUAL:\n return this.parseComparisonExpression(scope);\n case FilterTokenType.CONTAINS:\n case FilterTokenType.STARTS_WITH:\n case FilterTokenType.ENDS_WITH:\n return this.parseMatchExpression(scope);\n case FilterTokenType.IN:\n case FilterTokenType.NIN:\n return this.parseInExpression(scope);\n case FilterTokenType.ELEM_MATCH:\n return this.parseElemMatchExpression(scope, depth);\n case FilterTokenType.SIZE:\n return this.parseSizeExpression(scope);\n default:\n throw FiltersParseError.syntaxInvalid(`Unexpected token in filter expression: ${token.type}`);\n }\n }\n\n /**\n * not(expr): the exact complement of the interior (null-inclusive\n * complement law). A single leaf with a complement twin normalizes\n * to the twin, a double negation cancels; everything else stays a\n * first-class NOT node.\n */\n private parseNotExpression(\n scope?: FiltersScope,\n depth: number = 0,\n ): Filters | Filter {\n this.consume(FilterTokenType.NOT);\n this.consume(FilterTokenType.LPAREN);\n\n const expr = this.parseFilterExpression(scope, depth + 1);\n\n this.consume(FilterTokenType.RPAREN);\n\n if (isFilter(expr)) {\n const twin = COMPLEMENT_TWINS[expr.operator];\n\n if (twin) {\n return new Filter(twin as FilterFieldOperator, expr.field, expr.value);\n }\n }\n\n if (\n isFilters(expr, FilterCompoundOperator.NOT) &&\n expr.value.length === 1\n ) {\n return expr.value[0] as Filters | Filter;\n }\n\n return new Filters(FilterCompoundOperator.NOT, [expr]);\n }\n\n private parseLogicalExpression(\n scope?: FiltersScope,\n depth: number = 0,\n ): Filters | Filter {\n const op = this.consume().type; // AND / OR\n\n if (op !== FilterTokenType.AND && op !== FilterTokenType.OR) {\n throw FiltersParseError.syntaxInvalid('Expected AND or OR token type.');\n }\n\n this.consume(FilterTokenType.LPAREN);\n\n const expressions: (Filter | Filters)[] = [this.parseFilterExpression(scope, depth + 1)];\n\n while (this.peek().type === FilterTokenType.COMMA) {\n this.consume(FilterTokenType.COMMA);\n expressions.push(this.parseFilterExpression(scope, depth + 1));\n }\n\n this.consume(FilterTokenType.RPAREN);\n\n if (op === FilterTokenType.AND) {\n return new Filters(\n FilterCompoundOperator.AND,\n expressions,\n );\n }\n\n return new Filters(FilterCompoundOperator.OR, expressions);\n }\n\n private parseComparisonExpression(\n scope?: FiltersScope,\n ): Filters | Filter {\n const op = this.consume().type;\n\n this.consume(FilterTokenType.LPAREN);\n\n const left = this.parseExpressionFieldChain(scope);\n\n this.consume(FilterTokenType.COMMA);\n\n const right = this.parseExpressionValue();\n\n this.consume(FilterTokenType.RPAREN);\n\n switch (op) {\n case FilterTokenType.EQUAL: {\n return new Filter(\n FilterFieldOperator.EQUAL,\n left as string,\n right as string,\n );\n }\n case FilterTokenType.GREATER_THAN: {\n return new Filter(\n FilterFieldOperator.GREATER_THAN,\n left as string,\n right as string,\n );\n }\n case FilterTokenType.GREATER_OR_EQUAL: {\n return new Filter(\n FilterFieldOperator.GREATER_THAN_EQUAL,\n left as string,\n right as string,\n );\n }\n case FilterTokenType.LESS_THAN: {\n return new Filter(\n FilterFieldOperator.LESS_THAN,\n left as string,\n right as string,\n );\n }\n case FilterTokenType.LESS_OR_EQUAL: {\n return new Filter(\n FilterFieldOperator.LESS_THAN_EQUAL,\n left as string,\n right as string,\n );\n }\n }\n\n throw FiltersParseError.syntaxInvalid(`Token type ${op} not supported as comparison operator.`);\n }\n\n private parseMatchExpression(\n scope?: FiltersScope,\n ): Filters | Filter {\n const op = this.consume().type;\n\n this.consume(FilterTokenType.LPAREN);\n\n const field = this.parseExpressionFieldChain(scope);\n\n this.consume(FilterTokenType.COMMA);\n\n const text = this.consume(FilterTokenType.ESCAPED_TEXT).value!;\n\n this.consume(FilterTokenType.RPAREN);\n\n // the anchored operators match a literal substring, so the pattern\n // is transport text and is kept verbatim — never run through the\n // scalar grammar. Coercing it would reject a numeric pattern\n // (contains(title, '2024')) and silently trim a whitespace one into\n // a match-everything predicate. Mirrors the simple dialect, which\n // tags exactly these three operators `value: 'raw'`.\n const normalized = text.length >= 2 ?\n text.slice(1, -1).replace(/''/g, '\\'') :\n text;\n\n switch (op) {\n case FilterTokenType.CONTAINS: {\n return new Filter(\n FilterFieldOperator.CONTAINS,\n field,\n normalized,\n );\n }\n case FilterTokenType.ENDS_WITH: {\n return new Filter(\n FilterFieldOperator.ENDS_WITH,\n field,\n normalized,\n );\n }\n default: {\n return new Filter(\n FilterFieldOperator.STARTS_WITH,\n field,\n normalized,\n );\n }\n }\n }\n\n private parseInExpression(\n scope?: FiltersScope,\n ): Filters | Filter {\n const token = this.peek();\n\n if (token.type === FilterTokenType.NIN) {\n this.consume(FilterTokenType.NIN);\n } else {\n this.consume(FilterTokenType.IN);\n }\n\n this.consume(FilterTokenType.LPAREN);\n\n const field = this.parseExpressionFieldChain(scope);\n\n const values: unknown[] = [];\n\n while (this.peek().type === FilterTokenType.COMMA) {\n this.consume(FilterTokenType.COMMA);\n\n values.push(this.parseExpressionValue());\n }\n\n this.consume(FilterTokenType.RPAREN);\n\n if (token.type === FilterTokenType.NIN) {\n return new Filter(\n FilterFieldOperator.NOT_IN,\n field,\n values,\n );\n }\n\n return new Filter(\n FilterFieldOperator.IN,\n field,\n values,\n );\n }\n\n /**\n * size(field, n): the field holds an array of exactly n elements\n * (a non-negative integer — the wire is untyped, so the quoted\n * value coerces back to a number).\n */\n private parseSizeExpression(\n scope?: FiltersScope,\n ): Filter {\n this.consume(FilterTokenType.SIZE);\n this.consume(FilterTokenType.LPAREN);\n\n // size() may target a relation array directly: gate it (#1001).\n const field = this.parseExpressionFieldChain(scope, true);\n\n this.consume(FilterTokenType.COMMA);\n\n const value = this.parseExpressionValue();\n\n this.consume(FilterTokenType.RPAREN);\n\n if (\n typeof value !== 'number' ||\n !Number.isSafeInteger(value) ||\n value < 0\n ) {\n throw FiltersParseError.keyValueInvalid(field);\n }\n\n return new Filter(FilterFieldOperator.SIZE, field, value);\n }\n\n /**\n * elemMatch(field, expr): field paths inside the interior are\n * relative to the array element; the ITSELF marker addresses the\n * element itself.\n */\n private parseElemMatchExpression(\n scope?: FiltersScope,\n depth: number = 0,\n ): Filter {\n this.consume(FilterTokenType.ELEM_MATCH);\n this.consume(FilterTokenType.LPAREN);\n\n const target = this.parseElemMatchTarget(scope);\n\n this.consume(FilterTokenType.COMMA);\n\n this.elemMatchDepth += 1;\n\n let condition : Filters | Filter;\n\n try {\n condition = this.parseFilterExpression(target.scope, depth + 1);\n } finally {\n this.elemMatchDepth -= 1;\n }\n\n this.consume(FilterTokenType.RPAREN);\n\n return new Filter(FilterFieldOperator.ELEM_MATCH, target.field, condition);\n }\n\n /**\n * The field an elemMatch binds plus the interior resolution scope:\n * the related schema when resolvable, otherwise an unbound scope\n * inheriting the current policy (e.g. a JSON array column).\n */\n private parseElemMatchTarget(\n scope?: FiltersScope,\n ): { field: string, scope?: FiltersScope } {\n if (this.peek().type === FilterTokenType.ITSELF) {\n // an elemMatch on the element itself (arrays of arrays);\n // the chain parser enforces the interior-only contract.\n const field = this.parseExpressionFieldChain(scope);\n\n return {\n field,\n scope: scope ? this.buildUnboundScope(scope) : undefined,\n };\n }\n\n const token = this.consume(FilterTokenType.FIELD);\n\n const parts = [token.value!];\n\n while (this.peek().type === FilterTokenType.DOT) {\n this.consume(FilterTokenType.DOT);\n parts.push(this.consume(FilterTokenType.FIELD).value!);\n }\n\n if (!scope) {\n return { field: parts.join('.') };\n }\n\n // a leading segment matching the schema name addresses the\n // schema itself (mirrors parseExpressionFieldChain).\n if (\n parts.length > 1 &&\n (parts[0] === DEFAULT_ID || parts[0] === scope.schema.name)\n ) {\n parts.shift();\n }\n\n const resolved = scope.resolveKey(parts.join('.'));\n\n /* istanbul ignore next -- the scope always throws */\n if (!resolved.success) {\n throw FiltersParseError.keyInvalid(resolved.input);\n }\n\n const field = [...resolved.path, resolved.name].join('.');\n\n let interior : FiltersScope | undefined;\n\n // elemMatch on a non-relation field is legal: a missing related\n // schema comes back as a bare verdict and falls back to the unbound\n // scope. Every other failure (e.g. relations gating, including a\n // declared relation whose schema is not registered) is thrown by\n // the descent itself, the scope is always throwing.\n const verdict = resolved.scope.descend(resolved.name, { optional: true });\n\n if (verdict instanceof ResolutionScope) {\n interior = verdict as FiltersScope;\n }\n\n return {\n field,\n scope: interior ?? this.buildUnboundScope(scope),\n };\n }\n\n private buildUnboundScope(current: FiltersScope) : FiltersScope {\n return ResolutionScope.for(this.registry, Parameter.FILTERS, undefined, {\n throwOnFailure: true,\n strict: current.strict,\n }) as FiltersScope;\n }\n\n private parseExpressionValue(): Scalar {\n const token = this.consume();\n\n if (\n token.type !== FilterTokenType.ESCAPED_TEXT &&\n token.type !== FilterTokenType.NULL\n ) {\n throw FiltersParseError.syntaxInvalid(`Unexpected token in value: ${token.type}`);\n }\n\n return this.normalizeValue(token.value ?? 'null');\n }\n\n /**\n * `relationTarget` marks the field of an array operator (`size`): a leaf\n * that is itself a relation is then gated by the relation policy too.\n * A scalar comparison never asks, so a column sharing a registered\n * schema's name is not mistaken for a relation.\n */\n private parseExpressionFieldChain(\n scope?: FiltersScope,\n relationTarget: boolean = false,\n ): string {\n if (this.peek().type === FilterTokenType.ITSELF) {\n this.consume(FilterTokenType.ITSELF);\n\n // the marker addresses the element bound by the enclosing\n // elemMatch interior and never resolves against the schema.\n if (this.elemMatchDepth === 0) {\n throw FiltersParseError.keyInvalid(ITSELF);\n }\n\n return ITSELF;\n }\n\n const token = this.consume(FilterTokenType.FIELD);\n\n if (token.type !== FilterTokenType.FIELD) {\n throw FiltersParseError.syntaxInvalid(`Unexpected token in field chain: ${token.type}`);\n }\n\n const parts = [token.value!];\n\n while (this.peek().type === FilterTokenType.DOT) {\n this.consume(FilterTokenType.DOT);\n parts.push(this.consume(FilterTokenType.FIELD).value!);\n }\n\n if (scope) {\n // a leading segment matching the schema name addresses the\n // schema itself (mirrors the named-group hoisting of the\n // simple filters parser) and is stripped.\n if (\n parts.length > 1 &&\n (parts[0] === DEFAULT_ID || parts[0] === scope.schema.name)\n ) {\n parts.shift();\n }\n\n const key = parts.join('.');\n const resolved = scope.resolveKey(key, key, { relationTarget });\n\n /* istanbul ignore next -- the scope always throws */\n if (!resolved.success) {\n throw FiltersParseError.keyInvalid(resolved.input);\n }\n\n return [...resolved.path, resolved.name].join('.');\n }\n\n return parts.join('.');\n }\n\n // ---------------------------------------------------------\n\n protected normalizeValue(input: unknown) : Scalar {\n if (typeof input === 'string') {\n const trimmed = input.trim();\n\n if (trimmed.length === 0) {\n return trimmed;\n }\n\n // quoted content is coerced but never comma-split —\n // the expression dialect passes lists as separate args.\n if (\n trimmed.startsWith('\\'') &&\n trimmed.endsWith('\\'') &&\n trimmed.length >= 2\n ) {\n return parseFilterScalar(trimmed.slice(1, -1).replace(/''/g, '\\''));\n }\n\n return parseFilterScalar(trimmed);\n }\n\n if (typeof input === 'number') {\n return input;\n }\n\n if (typeof input === 'undefined' || input === null) {\n return null;\n }\n\n throw FiltersParseError.syntaxInvalid('the value could not be normalized');\n }\n}\n","/*\n * Copyright (c) 2022-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SimplePaginationParser } from '@rapiq/parser-simple';\nimport type { ExpressionPaginationParseOptions } from './types';\n\nexport class ExpressionPaginationParser extends SimplePaginationParser<ExpressionPaginationParseOptions> {\n\n}\n","/*\n * Copyright (c) 2021-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SimpleRelationsParser } from '@rapiq/parser-simple';\n\nexport class ExpressionRelationsParser extends SimpleRelationsParser {\n\n}\n","/*\n * Copyright (c) 2021-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SimpleSortsParser } from '@rapiq/parser-simple';\n\nexport class ExpressionSortsParser extends SimpleSortsParser {\n\n}\n\n/**\n * @deprecated use {@link ExpressionSortsParser}. Removed in 3.0.\n */\nexport const ExpressionSortParser = ExpressionSortsParser;\n\n// eslint-disable-next-line @tada5hi/type-declaration-location -- Preserve the merged public value and type.\nexport type ExpressionSortParser = ExpressionSortsParser;\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { SchemaRegistry } from '@rapiq/core';\nimport { BaseQueryParser } from '@rapiq/core';\nimport { SimpleAggregatesParser, SimpleGroupsParser } from '@rapiq/parser-simple';\nimport {\n ExpressionFieldsParser,\n ExpressionFiltersParser,\n ExpressionPaginationParser,\n ExpressionRelationsParser,\n ExpressionSortsParser,\n} from './parameter';\n\nexport class ExpressionParser extends BaseQueryParser {\n protected fieldsParser : ExpressionFieldsParser;\n\n protected filtersParser : ExpressionFiltersParser;\n\n protected paginationParser : ExpressionPaginationParser;\n\n protected relationsParser : ExpressionRelationsParser;\n\n protected sortParser : ExpressionSortsParser;\n\n // -----------------------------------------------------\n\n constructor(input?: SchemaRegistry) {\n super(input);\n\n this.fieldsParser = new ExpressionFieldsParser(this.registry);\n this.filtersParser = new ExpressionFiltersParser(this.registry);\n this.paginationParser = new ExpressionPaginationParser(this.registry);\n this.relationsParser = new ExpressionRelationsParser(this.registry);\n this.sortParser = new ExpressionSortsParser(this.registry);\n // one call-term grammar serves every dialect.\n this.groupsParser = new SimpleGroupsParser(this.registry);\n this.aggregatesParser = new SimpleAggregatesParser(this.registry);\n }\n}\n"],"mappings":";;;AASA,IAAa,yBAAb,cAA4C,mBAAmB,CAE/D;;ACJA,IAAY,kBAAL,yBAAA,iBAAA;CACH,gBAAA,SAAA;CAEA,gBAAA,SAAA;CACA,gBAAA,QAAA;CAEA,gBAAA,WAAA;CACA,gBAAA,kBAAA;CACA,gBAAA,sBAAA;CACA,gBAAA,eAAA;CACA,gBAAA,mBAAA;CACA,gBAAA,cAAA;CACA,gBAAA,iBAAA;CACA,gBAAA,eAAA;CACA,gBAAA,QAAA;CACA,gBAAA,SAAA;CACA,gBAAA,gBAAA;CACA,gBAAA,UAAA;CAEA,gBAAA,WAAA;CACA,gBAAA,YAAA;CACA,gBAAA,kBAAA;CACA,gBAAA,UAAA;CACA,gBAAA,YAAA;CACA,gBAAA,YAAA;CACA,gBAAA,WAAA;CACA,gBAAA,SAAA;CACA,gBAAA,SAAA;;AACJ,EAAA,CAAA,CAAA;;;;;;;AAQA,MAAa,6BAA6B;CACtC,KAAA;CACA,KAAA;CACA,IAAA;CACA,IAAA;CACA,IAAA;CACA,KAAA;CACA,IAAA;CACA,KAAA;CACA,UAAA;CACA,YAAA;CACA,UAAA;CACA,IAAA;CACA,KAAA;CACA,WAAA;CACA,MAAA;CACA,MAAA;AACJ;;;;;;AAOA,MAAa,+BAA+B;;;;;;ACZ5C,MAAM,YAAY;;;;;;;AAQlB,MAAM,mBAA4C,CAAC;AAEnD,KAAK,MAAM,CAAC,UAAU,cAAc,OAAO,QAAQ,yBAAyB,GAAG;CAC3E,MAAM,OAAQ,UAAwC;CAEtD,IAAI,MAAM;EACN,iB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Q;EACxD,KAAK,mBAAmB,IAAI,uBAAuB,KAAK,QAAQ;CACpE;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rapiq/parser-expression",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Parse a function-call filter language (e.g. and(eq(name,'John'), gte(age,'18'))) into a rapiq query AST.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
],
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@ebec/core": "^1.3.2",
|
|
20
|
-
"@rapiq/core": "^2.
|
|
21
|
-
"@rapiq/parser-simple": "^2.
|
|
20
|
+
"@rapiq/core": "^2.5.0",
|
|
21
|
+
"@rapiq/parser-simple": "^2.5.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@rapiq/core": "^2.
|
|
25
|
-
"@rapiq/parser-simple": "^2.
|
|
24
|
+
"@rapiq/core": "^2.5.0",
|
|
25
|
+
"@rapiq/parser-simple": "^2.5.0"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build:types": "tsc --noEmit -p tsconfig.build.json",
|