@allgemein/expressions 1.2.1 → 1.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/README.md +66 -0
- package/browser.d.ts +18 -18
- package/browser.js +17 -47
- package/browser.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -17
- package/index.js.map +1 -1
- package/libs/descriptors/AndDesc.d.ts +2 -2
- package/libs/descriptors/AndDesc.js +4 -9
- package/libs/descriptors/AndDesc.js.map +1 -1
- package/libs/descriptors/EqDesc.d.ts +3 -3
- package/libs/descriptors/EqDesc.js +7 -12
- package/libs/descriptors/EqDesc.js.map +1 -1
- package/libs/descriptors/ExprDesc.d.ts +1 -1
- package/libs/descriptors/ExprDesc.js +36 -40
- package/libs/descriptors/ExprDesc.js.map +1 -1
- package/libs/descriptors/GeDesc.d.ts +3 -3
- package/libs/descriptors/GeDesc.js +6 -11
- package/libs/descriptors/GeDesc.js.map +1 -1
- package/libs/descriptors/GroupDesc.d.ts +1 -1
- package/libs/descriptors/GroupDesc.js +2 -6
- package/libs/descriptors/GroupDesc.js.map +1 -1
- package/libs/descriptors/GtDesc.d.ts +3 -3
- package/libs/descriptors/GtDesc.js +6 -11
- package/libs/descriptors/GtDesc.js.map +1 -1
- package/libs/descriptors/IExpr.js +1 -2
- package/libs/descriptors/InDesc.d.ts +3 -3
- package/libs/descriptors/InDesc.js +6 -11
- package/libs/descriptors/InDesc.js.map +1 -1
- package/libs/descriptors/KeyDesc.d.ts +1 -1
- package/libs/descriptors/KeyDesc.js +3 -8
- package/libs/descriptors/KeyDesc.js.map +1 -1
- package/libs/descriptors/LeDesc.d.ts +3 -3
- package/libs/descriptors/LeDesc.js +6 -11
- package/libs/descriptors/LeDesc.js.map +1 -1
- package/libs/descriptors/LikeDesc.d.ts +3 -3
- package/libs/descriptors/LikeDesc.js +7 -12
- package/libs/descriptors/LikeDesc.js.map +1 -1
- package/libs/descriptors/LtDesc.d.ts +3 -3
- package/libs/descriptors/LtDesc.js +6 -11
- package/libs/descriptors/LtDesc.js.map +1 -1
- package/libs/descriptors/NeqDesc.d.ts +3 -3
- package/libs/descriptors/NeqDesc.js +6 -11
- package/libs/descriptors/NeqDesc.js.map +1 -1
- package/libs/descriptors/OpDesc.d.ts +3 -3
- package/libs/descriptors/OpDesc.js +4 -8
- package/libs/descriptors/OpDesc.js.map +1 -1
- package/libs/descriptors/OrDesc.d.ts +2 -2
- package/libs/descriptors/OrDesc.js +4 -9
- package/libs/descriptors/OrDesc.js.map +1 -1
- package/libs/descriptors/Selector.d.ts +1 -1
- package/libs/descriptors/Selector.js +1 -5
- package/libs/descriptors/Selector.js.map +1 -1
- package/libs/descriptors/ValueDesc.d.ts +1 -1
- package/libs/descriptors/ValueDesc.js +3 -8
- package/libs/descriptors/ValueDesc.js.map +1 -1
- package/libs/exceptions/ExpressionValidationError.js +1 -5
- package/libs/exceptions/ExpressionValidationError.js.map +1 -1
- package/libs/expressions/ExpressionInterpreter.d.ts +1 -1
- package/libs/expressions/ExpressionInterpreter.js +64 -50
- package/libs/expressions/ExpressionInterpreter.js.map +1 -1
- package/libs/expressions/Expressions.d.ts +11 -11
- package/libs/expressions/Expressions.js +57 -61
- package/libs/expressions/Expressions.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -4,3 +4,69 @@
|
|
|
4
4
|
[](https://app.circleci.com/pipelines/github/allgemein-node/expressions)
|
|
5
5
|
[](https://codecov.io/gh/allgemein-node/expressions)
|
|
6
6
|
[](https://david-dm.org/allgemein-node/expressions)
|
|
7
|
+
|
|
8
|
+
@allgemein/expressions is a library for building, parsing and evaluating
|
|
9
|
+
mango-like (MongoDB-style) query expressions. Expressions can be constructed
|
|
10
|
+
programmatically, parsed from a SQL-like condition string or from/to a plain
|
|
11
|
+
JSON representation, which makes it useful for building generic, storage
|
|
12
|
+
agnostic query conditions.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm i @allgemein/expressions
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Building expressions programmatically
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import {And, Eq, Key, Value} from "@allgemein/expressions";
|
|
26
|
+
|
|
27
|
+
const condition = And(
|
|
28
|
+
Eq('tableName', Value('condition_keeper')),
|
|
29
|
+
Eq('tableId', Key('id'))
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
console.log(condition.toJson());
|
|
33
|
+
// => {$and: [{tableName: {$eq: 'condition_keeper'}}, {tableId: {$eq: 'id'}}]}
|
|
34
|
+
|
|
35
|
+
console.log(condition.getSourceKeys()); // => ['tableName', 'tableId']
|
|
36
|
+
console.log(condition.getTargetKeys()); // => ['id']
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Parsing JSON conditions
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import {Expressions} from "@allgemein/expressions";
|
|
43
|
+
|
|
44
|
+
const condition = Expressions.fromJson({
|
|
45
|
+
$and: [
|
|
46
|
+
{test: {$eq: 'hallo'}},
|
|
47
|
+
{test2: {$eq: 2}}
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
console.log(condition.toJson());
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Parsing string conditions
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import {ExpressionInterpreter} from "@allgemein/expressions";
|
|
58
|
+
|
|
59
|
+
const interpreter = new ExpressionInterpreter();
|
|
60
|
+
const condition = interpreter.interprete('\'testnr\' = 1 AND \'test\' = \'searchfor\'');
|
|
61
|
+
|
|
62
|
+
console.log(condition.toJson());
|
|
63
|
+
// => {$and: [{testnr: {$eq: 1}}, {test: {$eq: 'searchfor'}}]}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Features
|
|
67
|
+
|
|
68
|
+
* Fluent condition builders: `And`, `Or`, `Eq`, `Neq`, `Ge`, `Le`, `Like`, `In`, `Key`, `Value`
|
|
69
|
+
* Serialize/deserialize conditions to and from a plain JSON (mango-like) representation via `Expressions`
|
|
70
|
+
* Parse SQL-like condition strings into expression trees with `ExpressionInterpreter`
|
|
71
|
+
* Extract source and target keys referenced by a condition (`getSourceKeys`, `getTargetKeys`)
|
|
72
|
+
* Written in TypeScript, usable both in Node.js and the browser
|
package/browser.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { IExpr } from './libs/descriptors/IExpr';
|
|
2
|
-
export { ExprDesc } from './libs/descriptors/ExprDesc';
|
|
3
|
-
export { OpDesc } from './libs/descriptors/OpDesc';
|
|
4
|
-
export { In, InDesc } from './libs/descriptors/InDesc';
|
|
5
|
-
export { And, AndDesc } from './libs/descriptors/AndDesc';
|
|
6
|
-
export { Or, OrDesc } from './libs/descriptors/OrDesc';
|
|
7
|
-
export { Eq, EqDesc } from './libs/descriptors/EqDesc';
|
|
8
|
-
export { Ge, GeDesc } from './libs/descriptors/GeDesc';
|
|
9
|
-
export { GroupDesc } from './libs/descriptors/GroupDesc';
|
|
10
|
-
export { Key, KeyDesc } from './libs/descriptors/KeyDesc';
|
|
11
|
-
export { Le, LeDesc } from './libs/descriptors/LeDesc';
|
|
12
|
-
export { Like, LikeDesc } from './libs/descriptors/LikeDesc';
|
|
13
|
-
export { Neq, NeqDesc } from './libs/descriptors/NeqDesc';
|
|
14
|
-
export { Selector } from './libs/descriptors/Selector';
|
|
15
|
-
export { Value, ValueDesc } from './libs/descriptors/ValueDesc';
|
|
16
|
-
export { ExpressionInterpreter } from './libs/expressions/ExpressionInterpreter';
|
|
17
|
-
export { Expressions } from './libs/expressions/Expressions';
|
|
18
|
-
export { ExpressionValidationError } from './libs/exceptions/ExpressionValidationError';
|
|
1
|
+
export { IExpr } from './libs/descriptors/IExpr.js';
|
|
2
|
+
export { ExprDesc } from './libs/descriptors/ExprDesc.js';
|
|
3
|
+
export { OpDesc } from './libs/descriptors/OpDesc.js';
|
|
4
|
+
export { In, InDesc } from './libs/descriptors/InDesc.js';
|
|
5
|
+
export { And, AndDesc } from './libs/descriptors/AndDesc.js';
|
|
6
|
+
export { Or, OrDesc } from './libs/descriptors/OrDesc.js';
|
|
7
|
+
export { Eq, EqDesc } from './libs/descriptors/EqDesc.js';
|
|
8
|
+
export { Ge, GeDesc } from './libs/descriptors/GeDesc.js';
|
|
9
|
+
export { GroupDesc } from './libs/descriptors/GroupDesc.js';
|
|
10
|
+
export { Key, KeyDesc } from './libs/descriptors/KeyDesc.js';
|
|
11
|
+
export { Le, LeDesc } from './libs/descriptors/LeDesc.js';
|
|
12
|
+
export { Like, LikeDesc } from './libs/descriptors/LikeDesc.js';
|
|
13
|
+
export { Neq, NeqDesc } from './libs/descriptors/NeqDesc.js';
|
|
14
|
+
export { Selector } from './libs/descriptors/Selector.js';
|
|
15
|
+
export { Value, ValueDesc } from './libs/descriptors/ValueDesc.js';
|
|
16
|
+
export { ExpressionInterpreter } from './libs/expressions/ExpressionInterpreter.js';
|
|
17
|
+
export { Expressions } from './libs/expressions/Expressions.js';
|
|
18
|
+
export { ExpressionValidationError } from './libs/exceptions/ExpressionValidationError.js';
|
package/browser.js
CHANGED
|
@@ -1,48 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(exports, "Eq", { enumerable: true, get: function () { return EqDesc_1.Eq; } });
|
|
19
|
-
Object.defineProperty(exports, "EqDesc", { enumerable: true, get: function () { return EqDesc_1.EqDesc; } });
|
|
20
|
-
var GeDesc_1 = require("./libs/descriptors/GeDesc");
|
|
21
|
-
Object.defineProperty(exports, "Ge", { enumerable: true, get: function () { return GeDesc_1.Ge; } });
|
|
22
|
-
Object.defineProperty(exports, "GeDesc", { enumerable: true, get: function () { return GeDesc_1.GeDesc; } });
|
|
23
|
-
var GroupDesc_1 = require("./libs/descriptors/GroupDesc");
|
|
24
|
-
Object.defineProperty(exports, "GroupDesc", { enumerable: true, get: function () { return GroupDesc_1.GroupDesc; } });
|
|
25
|
-
var KeyDesc_1 = require("./libs/descriptors/KeyDesc");
|
|
26
|
-
Object.defineProperty(exports, "Key", { enumerable: true, get: function () { return KeyDesc_1.Key; } });
|
|
27
|
-
Object.defineProperty(exports, "KeyDesc", { enumerable: true, get: function () { return KeyDesc_1.KeyDesc; } });
|
|
28
|
-
var LeDesc_1 = require("./libs/descriptors/LeDesc");
|
|
29
|
-
Object.defineProperty(exports, "Le", { enumerable: true, get: function () { return LeDesc_1.Le; } });
|
|
30
|
-
Object.defineProperty(exports, "LeDesc", { enumerable: true, get: function () { return LeDesc_1.LeDesc; } });
|
|
31
|
-
var LikeDesc_1 = require("./libs/descriptors/LikeDesc");
|
|
32
|
-
Object.defineProperty(exports, "Like", { enumerable: true, get: function () { return LikeDesc_1.Like; } });
|
|
33
|
-
Object.defineProperty(exports, "LikeDesc", { enumerable: true, get: function () { return LikeDesc_1.LikeDesc; } });
|
|
34
|
-
var NeqDesc_1 = require("./libs/descriptors/NeqDesc");
|
|
35
|
-
Object.defineProperty(exports, "Neq", { enumerable: true, get: function () { return NeqDesc_1.Neq; } });
|
|
36
|
-
Object.defineProperty(exports, "NeqDesc", { enumerable: true, get: function () { return NeqDesc_1.NeqDesc; } });
|
|
37
|
-
var Selector_1 = require("./libs/descriptors/Selector");
|
|
38
|
-
Object.defineProperty(exports, "Selector", { enumerable: true, get: function () { return Selector_1.Selector; } });
|
|
39
|
-
var ValueDesc_1 = require("./libs/descriptors/ValueDesc");
|
|
40
|
-
Object.defineProperty(exports, "Value", { enumerable: true, get: function () { return ValueDesc_1.Value; } });
|
|
41
|
-
Object.defineProperty(exports, "ValueDesc", { enumerable: true, get: function () { return ValueDesc_1.ValueDesc; } });
|
|
42
|
-
var ExpressionInterpreter_1 = require("./libs/expressions/ExpressionInterpreter");
|
|
43
|
-
Object.defineProperty(exports, "ExpressionInterpreter", { enumerable: true, get: function () { return ExpressionInterpreter_1.ExpressionInterpreter; } });
|
|
44
|
-
var Expressions_1 = require("./libs/expressions/Expressions");
|
|
45
|
-
Object.defineProperty(exports, "Expressions", { enumerable: true, get: function () { return Expressions_1.Expressions; } });
|
|
46
|
-
var ExpressionValidationError_1 = require("./libs/exceptions/ExpressionValidationError");
|
|
47
|
-
Object.defineProperty(exports, "ExpressionValidationError", { enumerable: true, get: function () { return ExpressionValidationError_1.ExpressionValidationError; } });
|
|
1
|
+
export { ExprDesc } from './libs/descriptors/ExprDesc.js';
|
|
2
|
+
export { OpDesc } from './libs/descriptors/OpDesc.js';
|
|
3
|
+
export { In, InDesc } from './libs/descriptors/InDesc.js';
|
|
4
|
+
export { And, AndDesc } from './libs/descriptors/AndDesc.js';
|
|
5
|
+
export { Or, OrDesc } from './libs/descriptors/OrDesc.js';
|
|
6
|
+
export { Eq, EqDesc } from './libs/descriptors/EqDesc.js';
|
|
7
|
+
export { Ge, GeDesc } from './libs/descriptors/GeDesc.js';
|
|
8
|
+
export { GroupDesc } from './libs/descriptors/GroupDesc.js';
|
|
9
|
+
export { Key, KeyDesc } from './libs/descriptors/KeyDesc.js';
|
|
10
|
+
export { Le, LeDesc } from './libs/descriptors/LeDesc.js';
|
|
11
|
+
export { Like, LikeDesc } from './libs/descriptors/LikeDesc.js';
|
|
12
|
+
export { Neq, NeqDesc } from './libs/descriptors/NeqDesc.js';
|
|
13
|
+
export { Selector } from './libs/descriptors/Selector.js';
|
|
14
|
+
export { Value, ValueDesc } from './libs/descriptors/ValueDesc.js';
|
|
15
|
+
export { ExpressionInterpreter } from './libs/expressions/ExpressionInterpreter.js';
|
|
16
|
+
export { Expressions } from './libs/expressions/Expressions.js';
|
|
17
|
+
export { ExpressionValidationError } from './libs/exceptions/ExpressionValidationError.js';
|
|
48
18
|
//# sourceMappingURL=browser.js.map
|
package/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAC,EAAE,EAAE,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,GAAG,EAAE,OAAO,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,EAAE,EAAE,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,EAAE,EAAE,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,EAAE,EAAE,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,SAAS,EAAC,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAC,GAAG,EAAE,OAAO,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,EAAE,EAAE,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAC,GAAG,EAAE,OAAO,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAC,qBAAqB,EAAC,MAAM,6CAA6C,CAAC;AAClF,OAAO,EAAC,WAAW,EAAC,MAAM,mCAAmC,CAAC;AAE9D,OAAO,EAAC,yBAAyB,EAAC,MAAM,gDAAgD,CAAC"}
|
package/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './browser';
|
|
1
|
+
export * from './browser.js';
|
package/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./browser"), exports);
|
|
1
|
+
export * from './browser.js';
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GroupDesc } from "./GroupDesc";
|
|
2
|
-
import { ExprDesc } from "./ExprDesc";
|
|
1
|
+
import { GroupDesc } from "./GroupDesc.js";
|
|
2
|
+
import { ExprDesc } from "./ExprDesc.js";
|
|
3
3
|
export declare class AndDesc extends GroupDesc {
|
|
4
4
|
readonly type: string;
|
|
5
5
|
constructor(...values: ExprDesc[]);
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.And = And;
|
|
5
|
-
const _ = require("lodash");
|
|
6
|
-
const GroupDesc_1 = require("./GroupDesc");
|
|
7
|
-
class AndDesc extends GroupDesc_1.GroupDesc {
|
|
1
|
+
import * as _ from "@allgemein/base";
|
|
2
|
+
import { GroupDesc } from "./GroupDesc.js";
|
|
3
|
+
export class AndDesc extends GroupDesc {
|
|
8
4
|
constructor(...values) {
|
|
9
5
|
super(...values);
|
|
10
6
|
this.type = 'and';
|
|
@@ -27,8 +23,7 @@ class AndDesc extends GroupDesc_1.GroupDesc {
|
|
|
27
23
|
return c;
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
|
-
|
|
31
|
-
function And(...values) {
|
|
26
|
+
export function And(...values) {
|
|
32
27
|
return new AndDesc(...values);
|
|
33
28
|
}
|
|
34
29
|
//# sourceMappingURL=AndDesc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AndDesc.js","sourceRoot":"","sources":["../../../../src/libs/descriptors/AndDesc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AndDesc.js","sourceRoot":"","sources":["../../../../src/libs/descriptors/AndDesc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAKzC,MAAM,OAAO,OAAQ,SAAQ,SAAS;IAKpC,YAAY,GAAG,MAAkB;QAC/B,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC;QAJV,SAAI,GAAU,KAAK,CAAC;IAK7B,CAAC;IAED,MAAM,CAAC,MAAW;QAChB,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACzD,OAAO,UAAU,MAAW;YAC1B,KAAK,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC;gBACtB,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;oBAChB,OAAO,KAAK,CAAC;gBACf,CAAC;YACH,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAA;IACH,CAAC;IAED,GAAG,CAAC,MAAW,EAAE,SAAc,EAAE;QAC/B,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC,GAAQ,EAAE,CAAC;QAChB,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;QACnB,OAAO,CAAC,CAAC;IACX,CAAC;CAEF;AAID,MAAM,UAAU,GAAG,CAAC,GAAG,MAAkB;IACvC,OAAO,IAAI,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Selector } from "./Selector";
|
|
2
|
-
import { KeyDesc } from "./KeyDesc";
|
|
3
|
-
import { OpDesc } from "./OpDesc";
|
|
1
|
+
import { Selector } from "./Selector.js";
|
|
2
|
+
import { KeyDesc } from "./KeyDesc.js";
|
|
3
|
+
import { OpDesc } from "./OpDesc.js";
|
|
4
4
|
export declare class EqDesc extends OpDesc {
|
|
5
5
|
readonly type: string;
|
|
6
6
|
constructor(key: string | KeyDesc, value: Selector);
|
|
@@ -1,32 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const _ = require("lodash");
|
|
6
|
-
const KeyDesc_1 = require("./KeyDesc");
|
|
7
|
-
const OpDesc_1 = require("./OpDesc");
|
|
8
|
-
class EqDesc extends OpDesc_1.OpDesc {
|
|
1
|
+
import * as _ from "@allgemein/base";
|
|
2
|
+
import { KeyDesc } from "./KeyDesc.js";
|
|
3
|
+
import { OpDesc } from "./OpDesc.js";
|
|
4
|
+
export class EqDesc extends OpDesc {
|
|
9
5
|
constructor(key, value) {
|
|
10
6
|
super(key, value);
|
|
11
7
|
this.type = 'eq';
|
|
12
8
|
}
|
|
13
9
|
lookup(source) {
|
|
14
|
-
const value = this.value instanceof
|
|
10
|
+
const value = this.value instanceof KeyDesc ? source[this.value.key] : _.clone(this.value.value);
|
|
15
11
|
const key = this.key;
|
|
16
12
|
return function (target) {
|
|
17
13
|
return target[key] === value;
|
|
18
14
|
};
|
|
19
15
|
}
|
|
20
16
|
for(source, keyMap = {}) {
|
|
21
|
-
const value = this.value instanceof
|
|
17
|
+
const value = this.value instanceof KeyDesc ? source[this.value.key] : _.clone(this.value.value);
|
|
22
18
|
const key = _.get(keyMap, this.key, this.key);
|
|
23
19
|
let c = {};
|
|
24
20
|
c[key] = value;
|
|
25
21
|
return c;
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
|
-
|
|
29
|
-
function Eq(key, value) {
|
|
24
|
+
export function Eq(key, value) {
|
|
30
25
|
return new EqDesc(key, value);
|
|
31
26
|
}
|
|
32
27
|
//# sourceMappingURL=EqDesc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EqDesc.js","sourceRoot":"","sources":["../../../../src/libs/descriptors/EqDesc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EqDesc.js","sourceRoot":"","sources":["../../../../src/libs/descriptors/EqDesc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,iBAAiB,CAAC;AAIrC,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAErC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAGnC,MAAM,OAAO,MAAO,SAAQ,MAAM;IAEhC,YAAY,GAAqB,EAAE,KAAe;QAChD,KAAK,CAAC,GAAG,EA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 = require("lodash");
|
|
9
|
-
class ExprDesc {
|
|
1
|
+
import { KeyDesc } from './KeyDesc.js';
|
|
2
|
+
import { NotSupportedError, NotYetImplementedError } from '@allgemein/base';
|
|
3
|
+
import { ValueDesc } from './ValueDesc.js';
|
|
4
|
+
import { ExpressionValidationError } from '../exceptions/ExpressionValidationError.js';
|
|
5
|
+
import { concat, has, map, merge, uniq } from "@allgemein/base";
|
|
6
|
+
export class ExprDesc {
|
|
10
7
|
constructor() {
|
|
11
8
|
this.type = 'cond';
|
|
12
9
|
}
|
|
@@ -33,68 +30,68 @@ class ExprDesc {
|
|
|
33
30
|
}*/
|
|
34
31
|
}
|
|
35
32
|
else if (this.isGroup()) {
|
|
36
|
-
keys =
|
|
33
|
+
keys = concat(keys, ...map(this.values, v => v.getSourceKeys()));
|
|
37
34
|
}
|
|
38
|
-
return
|
|
35
|
+
return uniq(keys);
|
|
39
36
|
}
|
|
40
37
|
getTargetKeys() {
|
|
41
38
|
let keys = [];
|
|
42
39
|
if (this.isOp()) {
|
|
43
|
-
if (this.value instanceof
|
|
40
|
+
if (this.value instanceof KeyDesc) {
|
|
44
41
|
keys.push(this.value.key);
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
else if (this.isGroup()) {
|
|
48
|
-
keys =
|
|
45
|
+
keys = concat(keys, ...map(this.values, v => v.getTargetKeys()));
|
|
49
46
|
}
|
|
50
|
-
return
|
|
47
|
+
return uniq(keys);
|
|
51
48
|
}
|
|
52
49
|
applyOn(target, source, force = false) {
|
|
53
50
|
if (this.type == 'eq') {
|
|
54
|
-
if (!
|
|
55
|
-
if (this.value instanceof
|
|
51
|
+
if (!has(target, this.key) || false) {
|
|
52
|
+
if (this.value instanceof ValueDesc) {
|
|
56
53
|
// @ts-ignore
|
|
57
54
|
target[this.key] = this.value.value;
|
|
58
55
|
}
|
|
59
|
-
else if (this.value instanceof
|
|
56
|
+
else if (this.value instanceof KeyDesc) {
|
|
60
57
|
// @ts-ignore
|
|
61
58
|
target[this.key] = source[this.value.key];
|
|
62
59
|
}
|
|
63
60
|
else {
|
|
64
|
-
throw new
|
|
61
|
+
throw new NotYetImplementedError();
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
65
|
else if (this.type == 'and') {
|
|
69
|
-
|
|
66
|
+
map(this.values, v => v.applyOn(target, source, force));
|
|
70
67
|
}
|
|
71
68
|
else if (this.type == 'or') {
|
|
72
|
-
|
|
69
|
+
map(this.values, v => v.applyOn(target, source, force));
|
|
73
70
|
}
|
|
74
71
|
else {
|
|
75
|
-
throw new
|
|
72
|
+
throw new NotYetImplementedError();
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
75
|
applyReverseOn(target, source, force = false) {
|
|
79
76
|
if (this.type == 'eq') {
|
|
80
|
-
if (!
|
|
81
|
-
if (this.value instanceof
|
|
77
|
+
if (!has(target, this.key) || false) {
|
|
78
|
+
if (this.value instanceof KeyDesc) {
|
|
82
79
|
// @ts-ignore
|
|
83
80
|
target[this.value.key] = source[this.key];
|
|
84
81
|
}
|
|
85
82
|
else {
|
|
86
|
-
throw new
|
|
83
|
+
throw new NotYetImplementedError();
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
87
|
else if (this.type == 'and') {
|
|
91
|
-
|
|
88
|
+
map(this.values, v => v.applyReverseOn(target, source, force));
|
|
92
89
|
}
|
|
93
90
|
else if (this.type == 'or') {
|
|
94
|
-
|
|
91
|
+
map(this.values, v => v.applyReverseOn(target, source, force));
|
|
95
92
|
}
|
|
96
93
|
else {
|
|
97
|
-
throw new
|
|
94
|
+
throw new NotYetImplementedError();
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
97
|
/**
|
|
@@ -104,32 +101,32 @@ class ExprDesc {
|
|
|
104
101
|
getMap() {
|
|
105
102
|
let map = {};
|
|
106
103
|
if (this.type == 'eq') {
|
|
107
|
-
if (this.value instanceof
|
|
104
|
+
if (this.value instanceof KeyDesc) {
|
|
108
105
|
map[this.key] = this.value.key;
|
|
109
106
|
}
|
|
110
|
-
else if (this.value instanceof
|
|
107
|
+
else if (this.value instanceof ValueDesc) {
|
|
111
108
|
map[this.key] = '\'' + this.value.value + '\'';
|
|
112
109
|
}
|
|
113
110
|
else {
|
|
114
|
-
throw new
|
|
111
|
+
throw new NotYetImplementedError();
|
|
115
112
|
}
|
|
116
113
|
}
|
|
117
114
|
else if (this.type == 'and') {
|
|
118
|
-
|
|
115
|
+
merge(map, ...this.values.map((v) => v.getMap()));
|
|
119
116
|
}
|
|
120
117
|
else if (this.type == 'or') {
|
|
121
|
-
|
|
118
|
+
merge(map, ...this.values.map((v) => v.getMap()));
|
|
122
119
|
}
|
|
123
120
|
else {
|
|
124
|
-
throw new
|
|
121
|
+
throw new NotYetImplementedError();
|
|
125
122
|
}
|
|
126
123
|
return map;
|
|
127
124
|
}
|
|
128
125
|
lookup(source) {
|
|
129
|
-
throw new
|
|
126
|
+
throw new NotYetImplementedError();
|
|
130
127
|
}
|
|
131
128
|
for(target, keyMap = {}) {
|
|
132
|
-
throw new
|
|
129
|
+
throw new NotYetImplementedError();
|
|
133
130
|
}
|
|
134
131
|
/**
|
|
135
132
|
* Test if conditions matching class properties and references
|
|
@@ -166,13 +163,13 @@ class ExprDesc {
|
|
|
166
163
|
let sourceProps = sourceRef ? sourceRef.getPropertyRefs().map(p => p.name).filter(pn => targetKeys.indexOf(pn) !== -1) : [];
|
|
167
164
|
if (sourceKeys.length != targetProps.length) {
|
|
168
165
|
if (throwing) {
|
|
169
|
-
throw new
|
|
166
|
+
throw new ExpressionValidationError('referred key(s) ' + sourceKeys.filter(k => targetProps.indexOf(k) === -1).join(',') + ' not in sourceRef');
|
|
170
167
|
}
|
|
171
168
|
return false;
|
|
172
169
|
}
|
|
173
170
|
if (targetKeys.length != sourceProps.length) {
|
|
174
171
|
if (throwing) {
|
|
175
|
-
throw new
|
|
172
|
+
throw new ExpressionValidationError('referrer key(s) ' + targetKeys.filter(k => sourceProps.indexOf(k) === -1).join(',') + ' not in targetRef');
|
|
176
173
|
}
|
|
177
174
|
return false;
|
|
178
175
|
}
|
|
@@ -181,7 +178,7 @@ class ExprDesc {
|
|
|
181
178
|
toJson() {
|
|
182
179
|
if (this.isGroup()) {
|
|
183
180
|
let res = {};
|
|
184
|
-
res['$' + this.type] =
|
|
181
|
+
res['$' + this.type] = map(this.values, x => x.toJson());
|
|
185
182
|
return res;
|
|
186
183
|
}
|
|
187
184
|
else if (this.isOp()) {
|
|
@@ -191,9 +188,8 @@ class ExprDesc {
|
|
|
191
188
|
return res;
|
|
192
189
|
}
|
|
193
190
|
else {
|
|
194
|
-
throw new
|
|
191
|
+
throw new NotSupportedError('toJson to this condition not supported');
|
|
195
192
|
}
|
|
196
193
|
}
|
|
197
194
|
}
|
|
198
|
-
exports.ExprDesc = ExprDesc;
|
|
199
195
|
//# sourceMappingURL=ExprDesc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExprDesc.js","sourceRoot":"","sources":["../../../../src/libs/descriptors/ExprDesc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExprDesc.js","sourceRoot":"","sources":["../../../../src/libs/descriptors/ExprDesc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,iBAAiB,EAAE,sBAAsB,EAAC,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAC,yBAAyB,EAAC,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAG9D,MAAM,OAAO,QAAQ;IAArB;QAEW,SAAI,GAAW,MAAM,CAAC;IAoMjC,CAAC;IAhMC,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAW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AAC,CAAC;QACxE,CAAC;IAEH,CAAC;CAEF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Selector } from "./Selector";
|
|
2
|
-
import { KeyDesc } from "./KeyDesc";
|
|
3
|
-
import { OpDesc } from "./OpDesc";
|
|
1
|
+
import { Selector } from "./Selector.js";
|
|
2
|
+
import { KeyDesc } from "./KeyDesc.js";
|
|
3
|
+
import { OpDesc } from "./OpDesc.js";
|
|
4
4
|
export declare class GeDesc extends OpDesc {
|
|
5
5
|
readonly type: string;
|
|
6
6
|
constructor(key: string | KeyDesc, value: Selector);
|
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const _ = require("lodash");
|
|
6
|
-
const KeyDesc_1 = require("./KeyDesc");
|
|
7
|
-
const OpDesc_1 = require("./OpDesc");
|
|
8
|
-
class GeDesc extends OpDesc_1.OpDesc {
|
|
1
|
+
import * as _ from "@allgemein/base";
|
|
2
|
+
import { KeyDesc } from "./KeyDesc.js";
|
|
3
|
+
import { OpDesc } from "./OpDesc.js";
|
|
4
|
+
export class GeDesc extends OpDesc {
|
|
9
5
|
constructor(key, value) {
|
|
10
6
|
super(key, value);
|
|
11
7
|
this.type = 'ge';
|
|
12
8
|
}
|
|
13
9
|
lookup(source) {
|
|
14
|
-
const value = this.value instanceof
|
|
10
|
+
const value = this.value instanceof KeyDesc ? source[this.value.key] : _.clone(this.value.value);
|
|
15
11
|
const key = this.key;
|
|
16
12
|
return function (target) {
|
|
17
13
|
return target[key] >= value;
|
|
18
14
|
};
|
|
19
15
|
}
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
function Ge(key, value) {
|
|
17
|
+
export function Ge(key, value) {
|
|
23
18
|
return new GeDesc(key, value);
|
|
24
19
|
}
|
|
25
20
|
//# sourceMappingURL=GeDesc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeDesc.js","sourceRoot":"","sources":["../../../../src/libs/descriptors/GeDesc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GeDesc.js","sourceRoot":"","sources":["../../../../src/libs/descriptors/GeDesc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,iBAAiB,CAAC;AAGrC,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAErC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAGnC,MAAM,OAAO,MAAO,SAAQ,MAAM;IAGhC,YAAY,GAAqB,EAAE,KAAe;QAChD,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAHX,SAAI,GAAW,IAAI,CAAC;IAI7B,CAAC;IAED,MAAM,CAAC,MAAW;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,YAAY,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAa,IAAI,CAAC,KAAM,CAAC,KAAK,CAAC,CAAC;QAC9G,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACrB,OAAO,UAAU,MAAW;YAC1B,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC;QAC9B,CAAC,CAAA;IACH,CAAC;CACF;AAGD,MAAM,UAAU,EAAE,CAAC,GAAqB,EAAE,KAAe;IACvD,OAAO,IAAI,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAChC,CAAC"}
|