@routier/core 0.2.1 → 0.4.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/LICENSE +21 -0
- package/{readme.md → README.md} +3 -3
- package/dist/assertions/index.cjs +191 -0
- package/dist/assertions/index.cjs.map +1 -0
- package/dist/assertions/index.js +43 -63
- package/dist/assertions/index.js.map +1 -1
- package/dist/capabilities/index.cjs +820 -0
- package/dist/capabilities/index.cjs.map +1 -0
- package/dist/capabilities/index.js +584 -558
- package/dist/capabilities/index.js.map +1 -1
- package/dist/codegen/handlers/CloneHandlerBuilder.d.ts +10 -1
- package/dist/codegen/handlers/clone/CloneArrayHandler.d.ts +3 -0
- package/dist/codegen/handlers/clone/CloneDateHandler.d.ts +13 -0
- package/dist/codegen/handlers/clone/CloneValueHandler.d.ts +16 -0
- package/dist/codegen/handlers/compare/CompareComputedHandler.d.ts +10 -0
- package/dist/codegen/handlers/compare/CompareFunctionHandler.d.ts +10 -0
- package/dist/codegen/handlers/deserialize/DeserializeArrayHandler.d.ts +14 -0
- package/dist/codegen/handlers/enableChangeTracking/EnableChangeTrackingArrayHandler.d.ts +11 -0
- package/dist/codegen/handlers/enrichment/EnrichmentArrayHandler.d.ts +11 -0
- package/dist/codegen/handlers/freeze/FreezeArrayHandler.d.ts +6 -0
- package/dist/codegen/handlers/hash/HashArrayHandler.d.ts +10 -0
- package/dist/codegen/handlers/hash/HashFileHandler.d.ts +24 -0
- package/dist/codegen/handlers/hash/HashObjectHandler.d.ts +10 -0
- package/dist/codegen/handlers/hash/HashTransformHandler.d.ts +23 -0
- package/dist/codegen/handlers/merge/MergeArrayHandler.d.ts +20 -0
- package/dist/codegen/handlers/merge/MergeObjectHandler.d.ts +10 -0
- package/dist/codegen/handlers/serialize/SerializeArrayHandler.d.ts +19 -0
- package/dist/codegen/handlers/strip/StripComputedHandler.d.ts +10 -0
- package/dist/codegen/handlers/strip/StripFunctionHandler.d.ts +9 -0
- package/dist/codegen/handlers/types.d.ts +55 -1
- package/dist/codegen/index.cjs +618 -0
- package/dist/codegen/index.cjs.map +1 -0
- package/dist/codegen/index.js +99 -127
- package/dist/codegen/index.js.map +1 -1
- package/dist/collections/MemoryDataCollection.d.ts +15 -1
- package/dist/collections/TagCollection.d.ts +0 -1
- package/dist/collections/index.cjs +702 -0
- package/dist/collections/index.cjs.map +1 -0
- package/dist/collections/index.js +282 -276
- package/dist/collections/index.js.map +1 -1
- package/dist/errors/OptimisticConcurrencyError.d.ts +18 -0
- package/dist/errors/PluginDestroyedError.d.ts +10 -0
- package/dist/errors/index.cjs +132 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +61 -19
- package/dist/errors/index.js.map +1 -1
- package/dist/expressions/evaluate.d.ts +53 -0
- package/dist/expressions/index.cjs +2087 -0
- package/dist/expressions/index.cjs.map +1 -0
- package/dist/expressions/index.d.ts +1 -1
- package/dist/expressions/index.js +1727 -1082
- package/dist/expressions/index.js.map +1 -1
- package/dist/expressions/parser.d.ts +19 -0
- package/dist/expressions/types.d.ts +87 -2
- package/dist/index.cjs +14377 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +12374 -7931
- package/dist/index.js.map +1 -1
- package/dist/performance/index.cjs +217 -0
- package/dist/performance/index.cjs.map +1 -0
- package/dist/performance/index.js +120 -55
- package/dist/performance/index.js.map +1 -1
- package/dist/pipeline/index.cjs +576 -0
- package/dist/pipeline/index.cjs.map +1 -0
- package/dist/pipeline/index.js +223 -161
- package/dist/pipeline/index.js.map +1 -1
- package/dist/plugins/BatchingDbPlugin.d.ts +139 -0
- package/dist/plugins/CacheDbPlugin.d.ts +70 -0
- package/dist/plugins/ConcurrencyDbPlugin.d.ts +78 -0
- package/dist/plugins/EphemeralDataPlugin.d.ts +57 -1
- package/dist/plugins/RetryDbPlugin.d.ts +77 -0
- package/dist/plugins/index.cjs +6551 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +6271 -1170
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/query/QueryOptionsCollection.d.ts +34 -0
- package/dist/plugins/query/explain.d.ts +82 -0
- package/dist/plugins/query/formatExplanation.d.ts +9 -0
- package/dist/plugins/query/index.d.ts +4 -0
- package/dist/plugins/query/join.d.ts +210 -0
- package/dist/plugins/query/similarity.d.ts +38 -0
- package/dist/plugins/query/types.d.ts +75 -1
- package/dist/plugins/translators/DataTranslator.d.ts +28 -0
- package/dist/plugins/translators/JsonTranslator.d.ts +27 -0
- package/dist/plugins/translators/SqlTranslator.d.ts +45 -0
- package/dist/plugins/translators/TupleTranslator.d.ts +45 -0
- package/dist/plugins/translators/index.d.ts +1 -0
- package/dist/plugins/types.d.ts +125 -3
- package/dist/plugins/wire/handler.d.ts +122 -0
- package/dist/plugins/wire/index.d.ts +4 -0
- package/dist/plugins/wire/persist.d.ts +43 -0
- package/dist/plugins/wire/query.d.ts +49 -0
- package/dist/plugins/wire/types.d.ts +139 -0
- package/dist/results/index.cjs +174 -0
- package/dist/results/index.cjs.map +1 -0
- package/dist/results/index.js +29 -44
- package/dist/results/index.js.map +1 -1
- package/dist/schema/PropertyInfo.d.ts +31 -2
- package/dist/schema/SchemaDefinition.d.ts +23 -1
- package/dist/schema/builder.d.ts +35 -1
- package/dist/schema/communication/broadcast.d.ts +17 -1
- package/dist/schema/index.cjs +6911 -0
- package/dist/schema/index.cjs.map +1 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +5330 -4541
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/property/base/SchemaBase.d.ts +48 -2
- package/dist/schema/property/modifiers/SchemaNullable.d.ts +10 -0
- package/dist/schema/property/modifiers/SchemaOptional.d.ts +19 -0
- package/dist/schema/property/modifiers/SchemaSearchable.d.ts +34 -0
- package/dist/schema/property/modifiers/index.d.ts +1 -0
- package/dist/schema/property/types/SchemaFile.d.ts +60 -0
- package/dist/schema/property/types/SchemaString.d.ts +21 -1
- package/dist/schema/property/types/SchemaVector.d.ts +61 -0
- package/dist/schema/property/types/index.d.ts +2 -0
- package/dist/schema/table/SchemaTransform.d.ts +40 -0
- package/dist/schema/table/index.d.ts +1 -0
- package/dist/schema/types.d.ts +166 -8
- package/dist/schema/utils/propertyKind.d.ts +4 -0
- package/dist/types/index.cjs +23 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.js +0 -14
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/index.cjs +1013 -0
- package/dist/utilities/index.cjs.map +1 -0
- package/dist/utilities/index.js +541 -379
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/logger.d.ts +48 -0
- package/package.json +156 -98
- package/dist/codegen/SlotPath.test.d.ts +0 -1
- package/dist/codegen/blocks.test.d.ts +0 -1
- package/dist/codegen/utils.test.d.ts +0 -1
- package/dist/collections/Changes.test.d.ts +0 -1
- package/dist/collections/IdSet.test.d.ts +0 -1
- package/dist/collections/MemoryDataCollection.test.d.ts +0 -1
- package/dist/collections/TagCollection.contract.test.d.ts +0 -1
- package/dist/collections/TagCollection.test.d.ts +0 -1
- package/dist/expressions/parser.test.d.ts +0 -1
- package/dist/expressions/sql.d.ts +0 -28
- package/dist/expressions/sql.test.d.ts +0 -1
- package/dist/expressions/utils.test.d.ts +0 -1
- package/dist/pipeline/SyncronousQueue.test.d.ts +0 -1
- package/dist/plugins/EphemeralDataPlugin.test.d.ts +0 -1
- package/dist/plugins/query/Query.test.d.ts +0 -1
- package/dist/plugins/query/QueryOptionsCollection.test.d.ts +0 -1
- package/dist/plugins/translators/JsonTranslator.test.d.ts +0 -1
- package/dist/plugins/translators/SqlTranslator.test.d.ts +0 -1
- package/dist/plugins/translators/TranslatedValues.test.d.ts +0 -1
- package/dist/results/Result.test.d.ts +0 -1
- package/dist/results/utils.test.d.ts +0 -1
- package/dist/schema/PropertyInfo.test.d.ts +0 -1
- package/dist/schema/communication/broadcast.test.d.ts +0 -1
- package/dist/schema/schemaGeneration.test.d.ts +0 -1
- package/dist/schema/utils/standardJsonSchema.test.d.ts +0 -1
- package/dist/utilities/arrays.test.d.ts +0 -1
- package/dist/utilities/dates.test.d.ts +0 -1
- package/dist/utilities/runtime.test.d.ts +0 -1
- package/dist/utilities/strings.test.d.ts +0 -1
- package/dist/utilities/uuid.test.d.ts +0 -1
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import { CompiledSchema } from "../schema";
|
|
2
2
|
import { Expression, Filter, ParamsFilter } from "./types";
|
|
3
3
|
export declare const combineExpressions: (...expressions: Expression[]) => Expression;
|
|
4
|
+
/**
|
|
5
|
+
* Parses an expression SOURCE FRAGMENT against one schema and one root name.
|
|
6
|
+
*
|
|
7
|
+
* `toExpression` starts from a function and works out its own roots. This starts from text, which
|
|
8
|
+
* is what a caller has when it has split a larger predicate apart — `p.rank > 10` lifted out of
|
|
9
|
+
* `([p, m]) => p.rank > 10 && m.won === true`.
|
|
10
|
+
*
|
|
11
|
+
* **A fragment naming anything other than `rootName` returns `NOT_PARSABLE`, and that is the
|
|
12
|
+
* point.** It is how a caller discovers which side of a join a conjunct belongs to: parse it
|
|
13
|
+
* against each side in turn, and exactly one succeeds for a single-side condition. A condition
|
|
14
|
+
* spanning both fails against both, which is the correct answer — it cannot be pushed to either.
|
|
15
|
+
*
|
|
16
|
+
* No params: a fragment carrying a params reference has no bag to resolve it against here, so it
|
|
17
|
+
* fails rather than binding to nothing.
|
|
18
|
+
*
|
|
19
|
+
* Deliberately NOT cached. The cache is keyed by function source, and a fragment is not a function
|
|
20
|
+
* — two different lambdas can contain the same fragment text against different schemas.
|
|
21
|
+
*/
|
|
22
|
+
export declare const parseFragment: (schema: CompiledSchema<any>, body: string, rootName: string) => Expression;
|
|
4
23
|
export declare const toExpression: <T extends any, P extends any>(schema: CompiledSchema<any>, fn: Filter<T> | ParamsFilter<T, P>, params?: P) => Expression;
|
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
import { QueryOptionExecutionTarget } from "../plugins";
|
|
2
|
-
import { PropertyInfo } from "../schema";
|
|
2
|
+
import { CompiledSchemaCore, PropertyInfo } from "../schema";
|
|
3
|
+
/**
|
|
4
|
+
* JSON-safe form of a literal. Tagged only where JSON cannot carry the value as it is.
|
|
5
|
+
*
|
|
6
|
+
* See `Expression.toJson`.
|
|
7
|
+
*/
|
|
8
|
+
export type SerializedValue = {
|
|
9
|
+
k: "raw";
|
|
10
|
+
v: string | number | boolean | null;
|
|
11
|
+
} | {
|
|
12
|
+
k: "date";
|
|
13
|
+
v: string;
|
|
14
|
+
} | {
|
|
15
|
+
k: "undefined";
|
|
16
|
+
} | {
|
|
17
|
+
k: "number";
|
|
18
|
+
v: "NaN" | "Infinity" | "-Infinity";
|
|
19
|
+
} | {
|
|
20
|
+
k: "array";
|
|
21
|
+
v: SerializedValue[];
|
|
22
|
+
};
|
|
23
|
+
/** JSON-safe form of an expression tree. See `Expression.toJson`. */
|
|
24
|
+
export type SerializedExpression = {
|
|
25
|
+
t: "empty";
|
|
26
|
+
} | {
|
|
27
|
+
t: "not-parsable";
|
|
28
|
+
} | {
|
|
29
|
+
t: "operator";
|
|
30
|
+
operator: Operator;
|
|
31
|
+
left?: SerializedExpression;
|
|
32
|
+
right?: SerializedExpression;
|
|
33
|
+
} | {
|
|
34
|
+
t: "comparator";
|
|
35
|
+
comparator: Comparator;
|
|
36
|
+
negated: boolean;
|
|
37
|
+
strict: boolean;
|
|
38
|
+
left?: SerializedExpression;
|
|
39
|
+
right?: SerializedExpression;
|
|
40
|
+
} | {
|
|
41
|
+
t: "property";
|
|
42
|
+
path: string;
|
|
43
|
+
transformer: Transformer | null;
|
|
44
|
+
locale: string | null;
|
|
45
|
+
} | {
|
|
46
|
+
t: "value";
|
|
47
|
+
value: SerializedValue;
|
|
48
|
+
transformer: Transformer | null;
|
|
49
|
+
locale: string | null;
|
|
50
|
+
};
|
|
3
51
|
export type ParsedExpression = {
|
|
4
52
|
expression: Expression;
|
|
5
53
|
executionTarget: QueryOptionExecutionTarget;
|
|
@@ -19,6 +67,42 @@ export declare abstract class Expression {
|
|
|
19
67
|
static get NOT_PARSABLE(): NotParsableExpression;
|
|
20
68
|
static isEmpty(expression: Expression): boolean;
|
|
21
69
|
static isNotParsable(expression: Expression): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Turns a tree into plain JSON, so a whole query can cross a wire.
|
|
72
|
+
*
|
|
73
|
+
* On the class rather than beside it, because this is the type's own REPRESENTATION — there is one
|
|
74
|
+
* right answer and it belongs with the thing being represented, next to `EMPTY` and `isEmpty`.
|
|
75
|
+
* Rendering a tree into some other language (`toSql`, `toMql`, `evaluate`) is a different kind of
|
|
76
|
+
* thing: there are many, each belongs to its consumer, and none of them is canonical.
|
|
77
|
+
*
|
|
78
|
+
* ## Why it is this small
|
|
79
|
+
*
|
|
80
|
+
* Of the six node types a bound tree can contain, exactly one holds anything JSON cannot carry:
|
|
81
|
+
* `PropertyExpression`, whose live `PropertyInfo` has functions, a parent chain and caches. It
|
|
82
|
+
* reduces to a property PATH — `PropertyInfo.id` IS the dotted path, and `getProperty` is keyed by
|
|
83
|
+
* exactly that — so rebinding is one lookup.
|
|
84
|
+
*
|
|
85
|
+
* `ParamReferenceExpression` never appears: it is a parse-time placeholder that binding replaces
|
|
86
|
+
* with a plain `ValueExpression` holding the resolved value. A serialized tree is always already
|
|
87
|
+
* bound, so there is no params object to send alongside it.
|
|
88
|
+
*
|
|
89
|
+
* Switches on `type` rather than using the `isXExpression` guards, which live in `../assertions`
|
|
90
|
+
* and import this module — the guards test the same discriminant, so nothing is lost.
|
|
91
|
+
*/
|
|
92
|
+
static toJson(expression: Expression): SerializedExpression;
|
|
93
|
+
/**
|
|
94
|
+
* Rebuilds a tree from JSON, rebinding every property against `schema`.
|
|
95
|
+
*
|
|
96
|
+
* The schema is SUPPLIED rather than read out of the payload. A filter always belongs to a known
|
|
97
|
+
* collection, and the RECEIVER's schema is the authority on what its properties are — taking an
|
|
98
|
+
* id from the payload would mean rebinding against a schema the sender chose, which is backwards
|
|
99
|
+
* for anything crossing a trust boundary.
|
|
100
|
+
*
|
|
101
|
+
* @throws when a property path is not declared by `schema`. Not `NOT_PARSABLE`: on a receiver, a
|
|
102
|
+
* filter that silently stops filtering returns rows the requester excluded, which is the one
|
|
103
|
+
* failure here worse than an error.
|
|
104
|
+
*/
|
|
105
|
+
static fromJson(json: SerializedExpression, schema: CompiledSchemaCore<any>): Expression;
|
|
22
106
|
}
|
|
23
107
|
export declare class EmptyExpression extends Expression {
|
|
24
108
|
readonly type: "empty";
|
|
@@ -94,8 +178,9 @@ export declare class ValueExpression extends Expression {
|
|
|
94
178
|
export type ExpressionType = "operator" | "comparator" | "property" | "value" | "empty" | "not-parsable";
|
|
95
179
|
/**
|
|
96
180
|
* Supported value transformations that can be applied to values.
|
|
181
|
+
* `length` reads the length of a string or array property.
|
|
97
182
|
*/
|
|
98
|
-
export type Transformer = "to-lower-case" | "to-upper-case";
|
|
183
|
+
export type Transformer = "to-lower-case" | "to-upper-case" | "length";
|
|
99
184
|
/**
|
|
100
185
|
* Supported comparator operations for expressions.
|
|
101
186
|
*/
|