@routier/core 0.6.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/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 +2415 -364
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2755 -684
- 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 +2309 -316
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.js +2313 -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/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/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 +1 -1
|
@@ -5,48 +5,49 @@ import { CompiledSchemaCore, PropertyInfo } from "../schema";
|
|
|
5
5
|
*
|
|
6
6
|
* See `Expression.toJson`.
|
|
7
7
|
*/
|
|
8
|
-
export type SerializedValue = {
|
|
9
|
-
|
|
10
|
-
v: string | number | boolean | null;
|
|
8
|
+
export type SerializedValue = string | number | boolean | null | SerializedValue[] | {
|
|
9
|
+
date: string;
|
|
11
10
|
} | {
|
|
12
|
-
|
|
13
|
-
v: string;
|
|
11
|
+
undefined: true;
|
|
14
12
|
} | {
|
|
15
|
-
|
|
13
|
+
number: "NaN" | "Infinity" | "-Infinity";
|
|
16
14
|
} | {
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
regex: {
|
|
16
|
+
source: string;
|
|
17
|
+
flags: string;
|
|
18
|
+
};
|
|
19
19
|
} | {
|
|
20
|
-
|
|
21
|
-
v: SerializedValue[];
|
|
20
|
+
bigint: string;
|
|
22
21
|
};
|
|
23
22
|
/** JSON-safe form of an expression tree. See `Expression.toJson`. */
|
|
24
23
|
export type SerializedExpression = {
|
|
25
|
-
|
|
24
|
+
type: "empty";
|
|
26
25
|
} | {
|
|
27
|
-
|
|
26
|
+
type: "not-parsable";
|
|
27
|
+
reason?: string;
|
|
28
28
|
} | {
|
|
29
|
-
|
|
29
|
+
type: "operator";
|
|
30
30
|
operator: Operator;
|
|
31
31
|
left?: SerializedExpression;
|
|
32
32
|
right?: SerializedExpression;
|
|
33
33
|
} | {
|
|
34
|
-
|
|
34
|
+
type: "comparator";
|
|
35
35
|
comparator: Comparator;
|
|
36
36
|
negated: boolean;
|
|
37
37
|
strict: boolean;
|
|
38
38
|
left?: SerializedExpression;
|
|
39
39
|
right?: SerializedExpression;
|
|
40
40
|
} | {
|
|
41
|
-
|
|
41
|
+
type: "call";
|
|
42
|
+
call: Call;
|
|
43
|
+
expression: SerializedExpression;
|
|
44
|
+
arguments: SerializedExpression[];
|
|
45
|
+
} | {
|
|
46
|
+
type: "property";
|
|
42
47
|
path: string;
|
|
43
|
-
transformer: Transformer | null;
|
|
44
|
-
locale: string | null;
|
|
45
48
|
} | {
|
|
46
|
-
|
|
49
|
+
type: "value";
|
|
47
50
|
value: SerializedValue;
|
|
48
|
-
transformer: Transformer | null;
|
|
49
|
-
locale: string | null;
|
|
50
51
|
};
|
|
51
52
|
export type ParsedExpression = {
|
|
52
53
|
expression: Expression;
|
|
@@ -65,6 +66,8 @@ export declare abstract class Expression {
|
|
|
65
66
|
constructor(left?: Expression, right?: Expression);
|
|
66
67
|
static get EMPTY(): EmptyExpression;
|
|
67
68
|
static get NOT_PARSABLE(): NotParsableExpression;
|
|
69
|
+
/** `NOT_PARSABLE`, carrying what the parser refused. */
|
|
70
|
+
static notParsable(reason: string): NotParsableExpression;
|
|
68
71
|
static isEmpty(expression: Expression): boolean;
|
|
69
72
|
static isNotParsable(expression: Expression): boolean;
|
|
70
73
|
/**
|
|
@@ -77,7 +80,7 @@ export declare abstract class Expression {
|
|
|
77
80
|
*
|
|
78
81
|
* ## Why it is this small
|
|
79
82
|
*
|
|
80
|
-
* Of the
|
|
83
|
+
* Of the seven node types a bound tree can contain, exactly one holds anything JSON cannot carry:
|
|
81
84
|
* `PropertyExpression`, whose live `PropertyInfo` has functions, a parent chain and caches. It
|
|
82
85
|
* reduces to a property PATH — `PropertyInfo.id` IS the dotted path, and `getProperty` is keyed by
|
|
83
86
|
* exactly that — so rebinding is one lookup.
|
|
@@ -109,6 +112,9 @@ export declare class EmptyExpression extends Expression {
|
|
|
109
112
|
}
|
|
110
113
|
export declare class NotParsableExpression extends Expression {
|
|
111
114
|
readonly type: "not-parsable";
|
|
115
|
+
/** What the parser refused, when it knows. `.explain()` prints it beside the source. */
|
|
116
|
+
readonly reason?: string;
|
|
117
|
+
constructor(reason?: string);
|
|
112
118
|
}
|
|
113
119
|
/**
|
|
114
120
|
* A class representing a comparison operation (e.g., equals, greater-than).
|
|
@@ -152,12 +158,22 @@ export declare class PropertyExpression extends Expression {
|
|
|
152
158
|
readonly type: "property";
|
|
153
159
|
/** The property info for the path. */
|
|
154
160
|
property: PropertyInfo<any>;
|
|
155
|
-
transformer: Transformer | null;
|
|
156
|
-
locale: string | null;
|
|
157
161
|
constructor(options: {
|
|
158
162
|
property: PropertyInfo<any>;
|
|
159
163
|
});
|
|
160
164
|
}
|
|
165
|
+
export declare class CallExpression extends Expression {
|
|
166
|
+
readonly type: "call";
|
|
167
|
+
call: Call;
|
|
168
|
+
expression: Expression;
|
|
169
|
+
/** Empty for a unary call. */
|
|
170
|
+
arguments: Expression[];
|
|
171
|
+
constructor(options: {
|
|
172
|
+
call: Call;
|
|
173
|
+
expression: Expression;
|
|
174
|
+
arguments?: Expression[];
|
|
175
|
+
});
|
|
176
|
+
}
|
|
161
177
|
/**
|
|
162
178
|
* A class representing a literal value.
|
|
163
179
|
*/
|
|
@@ -166,8 +182,6 @@ export declare class ValueExpression extends Expression {
|
|
|
166
182
|
readonly type: "value";
|
|
167
183
|
/** The literal value. */
|
|
168
184
|
value: unknown;
|
|
169
|
-
transformer: Transformer | null;
|
|
170
|
-
locale: string | null;
|
|
171
185
|
constructor(options: {
|
|
172
186
|
value: unknown;
|
|
173
187
|
});
|
|
@@ -175,12 +189,17 @@ export declare class ValueExpression extends Expression {
|
|
|
175
189
|
/**
|
|
176
190
|
* The set of possible expression types.
|
|
177
191
|
*/
|
|
178
|
-
export type ExpressionType = "operator" | "comparator" | "property" | "value" | "empty" | "not-parsable";
|
|
192
|
+
export type ExpressionType = "operator" | "comparator" | "property" | "value" | "call" | "empty" | "not-parsable";
|
|
179
193
|
/**
|
|
180
194
|
* Supported value transformations that can be applied to values.
|
|
181
195
|
* `length` reads the length of a string or array property.
|
|
182
196
|
*/
|
|
183
197
|
export type Transformer = "to-lower-case" | "to-upper-case" | "length";
|
|
198
|
+
/**
|
|
199
|
+
* The names claimed so far. A name absent here is not refused — `specs/filter-expressions.md` lists
|
|
200
|
+
* both the refusals and their reasons, and is longer than this union.
|
|
201
|
+
*/
|
|
202
|
+
export type Call = "to-lower-case" | "to-upper-case" | "length" | "trim" | "trim-start" | "trim-end" | "index-of" | "substring" | "concat" | "replace" | "replace-all" | "absolute" | "floor" | "ceiling" | "round" | "sign" | "square-root" | "power" | "add" | "subtract" | "multiply" | "divide" | "modulo" | "utc-year" | "utc-month" | "utc-day-of-month" | "utc-day-of-week" | "utc-hour" | "utc-minute" | "utc-second" | "utc-millisecond" | "epoch-ms" | "to-string" | "to-number" | "to-boolean" | "type-of" | "some" | "every" | "power" | "bit-and" | "bit-or" | "bit-xor" | "bit-not" | "shift-left" | "shift-right" | "shift-right-unsigned" | "conditional" | "coalesce" | "matches";
|
|
184
203
|
/**
|
|
185
204
|
* Supported comparator operations for expressions.
|
|
186
205
|
*/
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { PropertyInfo } from "../schema";
|
|
2
|
-
import { Expression } from "./types";
|
|
2
|
+
import { CallExpression, Expression } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* An operand with the calls wrapping it, innermost first — the order they are applied in.
|
|
5
|
+
*
|
|
6
|
+
* The nodes rather than their names: a binary call carries arguments, and a consumer that only knows
|
|
7
|
+
* the name renders `LOWER(col)` correctly and `col + ?` not at all.
|
|
8
|
+
*/
|
|
9
|
+
export type PeeledOperand = {
|
|
10
|
+
operand: Expression;
|
|
11
|
+
calls: CallExpression[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Separates an operand from the calls applied to it.
|
|
15
|
+
*
|
|
16
|
+
* `null` when there is no operand beneath the calls. Every consumer needs this to decide whether a
|
|
17
|
+
* comparator side is a property or a value, so it lives here rather than in each translator.
|
|
18
|
+
*/
|
|
19
|
+
export declare function peelCalls(expression: Expression | undefined): PeeledOperand | null;
|
|
20
|
+
export declare function childrenOf(expression: Expression): Expression[];
|
|
3
21
|
/**
|
|
4
22
|
* Extracts all properties referenced in an expression
|
|
5
23
|
* @param expression The expression to analyze
|