@ballistix.digital/odata-query-builder 0.7.0 → 0.8.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/module/query/domain/filter/node.model.d.ts +3 -2
- package/dist/module/query/domain/filter/node.model.js +3 -2
- package/dist/module/query/domain/filter/node.model.js.map +1 -1
- package/dist/module/query/service/emit/emit.facade.d.ts +2 -8
- package/dist/module/query/service/emit/emit.facade.js +3 -17
- package/dist/module/query/service/emit/emit.facade.js.map +1 -1
- package/dist/module/query/service/emit/emit.service.d.ts +38 -0
- package/dist/module/query/service/emit/emit.service.js +89 -0
- package/dist/module/query/service/emit/emit.service.js.map +1 -0
- package/dist/module/query/service/filter/filter.facade.d.ts +4 -17
- package/dist/module/query/service/filter/filter.facade.js +12 -61
- package/dist/module/query/service/filter/filter.facade.js.map +1 -1
- package/dist/module/query/service/filter/filter.service.d.ts +51 -0
- package/dist/module/query/service/filter/filter.service.js +88 -0
- package/dist/module/query/service/filter/filter.service.js.map +1 -0
- package/dist/module/query/service/filter/scope.service.d.ts +70 -0
- package/dist/module/query/service/filter/scope.service.js +260 -0
- package/dist/module/query/service/filter/scope.service.js.map +1 -0
- package/package.json +1 -1
- package/dist/module/query/util/emit/queryParts.util.d.ts +0 -16
- package/dist/module/query/util/emit/queryParts.util.js +0 -60
- package/dist/module/query/util/emit/queryParts.util.js.map +0 -1
- package/dist/module/query/util/filter/filterFunction.util.d.ts +0 -9
- package/dist/module/query/util/filter/filterFunction.util.js +0 -111
- package/dist/module/query/util/filter/filterFunction.util.js.map +0 -1
- package/dist/module/query/util/filter/literal.util.d.ts +0 -23
- package/dist/module/query/util/filter/literal.util.js +0 -81
- package/dist/module/query/util/filter/literal.util.js.map +0 -1
- package/dist/module/query/util/filter/scopeProxy.util.d.ts +0 -22
- package/dist/module/query/util/filter/scopeProxy.util.js +0 -93
- package/dist/module/query/util/filter/scopeProxy.util.js.map +0 -1
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rootScope = exports.createMember = exports.nodeOf = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The JavaScript built-in class `Proxy` behind a filter scope: `createMember`, `rootScope`, and
|
|
6
|
-
* `nodeOf` — the one place a node comes back out of a proxy.
|
|
7
|
-
*
|
|
8
|
-
* THE COLLISION PROBLEM AND ITS FIX
|
|
9
|
-
* ---------------------------------
|
|
10
|
-
* At runtime a property name carries no type, so `a.year` is ambiguous: the
|
|
11
|
-
* `year()` date function, or a column actually called `year`. A single
|
|
12
|
-
* "methods first, path second" Proxy has to guess, and guesses wrong on every
|
|
13
|
-
* entity with a column named `year`, `name`, `length` or `date`.
|
|
14
|
-
*
|
|
15
|
-
* The fix: a property read NEVER resolves a function. Reading `x.foo` always
|
|
16
|
-
* returns a *member* — a callable proxy that remembers (parent node, "foo").
|
|
17
|
-
* - Read further from it -> "foo" was a path segment: `parent/foo`.
|
|
18
|
-
* - CALL it -> "foo" was a function: `foo(parent)`.
|
|
19
|
-
* A path segment is never called and a function is never left uncalled, so the
|
|
20
|
-
* two roles are told apart by syntax the caller already writes. A column named
|
|
21
|
-
* `year` therefore works, and so does `year()` over a sibling column, in the
|
|
22
|
-
* same expression.
|
|
23
|
-
*
|
|
24
|
-
* The node itself is reachable only through a Symbol, which no DTO key can be.
|
|
25
|
-
*
|
|
26
|
-
* The import back into `filterFunction.util.ts` is a real (not type-only)
|
|
27
|
-
* cycle, and so is `literal.util.ts`'s import back into this file. Both are
|
|
28
|
-
* safe because nothing here runs at module load: a trap body is entered when a
|
|
29
|
-
* caller builds a filter, long after every module has finished loading.
|
|
30
|
-
*/
|
|
31
|
-
const invalidFilter_exception_1 = require("../../exception/invalidFilter.exception");
|
|
32
|
-
const reservedName_exception_1 = require("../../exception/reservedName.exception");
|
|
33
|
-
const filterFunction_util_1 = require("./filterFunction.util");
|
|
34
|
-
const literal_util_1 = require("./literal.util");
|
|
35
|
-
/** The only key that reads a node. A DTO key can never be a symbol. */
|
|
36
|
-
const NODE = Symbol('odata.node');
|
|
37
|
-
/** The node behind a scope proxy, or `undefined` for a plain value. */
|
|
38
|
-
const nodeOf = (value) => typeof value === 'function' || (typeof value === 'object' && value !== null)
|
|
39
|
-
? value[NODE]
|
|
40
|
-
: undefined;
|
|
41
|
-
exports.nodeOf = nodeOf;
|
|
42
|
-
/**
|
|
43
|
-
* `createMember(node)` is a value; `createMember(node, parent, name)` is a
|
|
44
|
-
* member of `parent` that has not yet decided whether it is a path segment or
|
|
45
|
-
* a function call.
|
|
46
|
-
*
|
|
47
|
-
* The target is an arrow function so the proxy is callable. An arrow function
|
|
48
|
-
* has no `prototype`, and its `name`/`length` are configurable, so no Proxy
|
|
49
|
-
* invariant forces a value through — a DTO column called `name` or `length`
|
|
50
|
-
* still reaches the trap.
|
|
51
|
-
*
|
|
52
|
-
* `v.name.eq('x')` on `rootScope()` gives `name eq 'x'`. See
|
|
53
|
-
* docs/maintainer/architecture.md, How `Proxy` works here.
|
|
54
|
-
*/
|
|
55
|
-
const createMember = (node, parent, name) =>
|
|
56
|
-
// The target is never invoked: the `apply` trap owns every call. It only
|
|
57
|
-
// has to BE callable, so the Proxy accepts an `apply` trap at all.
|
|
58
|
-
new Proxy(/* istanbul ignore next */ (() => undefined), {
|
|
59
|
-
get(_target, property) {
|
|
60
|
-
if (property === NODE)
|
|
61
|
-
return node;
|
|
62
|
-
if (typeof property !== 'string')
|
|
63
|
-
return undefined;
|
|
64
|
-
// Reserved names THROW rather than return undefined, so `await q`,
|
|
65
|
-
// `JSON.stringify(q)` and an implicit `${q}`/arithmetic coercion fail
|
|
66
|
-
// loudly instead of silently — the last two would otherwise reach
|
|
67
|
-
// `apply` as a call to a function named `toString`/`valueOf` that the
|
|
68
|
-
// OData function table does not know, a confusing error to land on.
|
|
69
|
-
if (property === 'then' ||
|
|
70
|
-
property === 'toJSON' ||
|
|
71
|
-
property === 'toString' ||
|
|
72
|
-
property === 'valueOf')
|
|
73
|
-
throw new reservedName_exception_1.ReservedNameError(property);
|
|
74
|
-
return (0, exports.createMember)(new literal_util_1.ExpressionNode(node.text ? `${node.text}/${property}` : property, node.depth), node, property);
|
|
75
|
-
},
|
|
76
|
-
apply(_target, _thisArgument, callArguments) {
|
|
77
|
-
if (parent === undefined || name === undefined)
|
|
78
|
-
throw new invalidFilter_exception_1.InvalidFilterError(`"${node.text}" is a property path, not a function`, node.text);
|
|
79
|
-
const method = (0, filterFunction_util_1.filterFunction)(name);
|
|
80
|
-
if (method === undefined)
|
|
81
|
-
throw new invalidFilter_exception_1.InvalidFilterError(`${name}() is not an OData filter function served by this API`, name);
|
|
82
|
-
return method(parent, callArguments);
|
|
83
|
-
},
|
|
84
|
-
has: (_target, property) => typeof property === 'string',
|
|
85
|
-
});
|
|
86
|
-
exports.createMember = createMember;
|
|
87
|
-
/**
|
|
88
|
-
* The filter scope of an entity: an empty path at lambda depth 0. An expanded
|
|
89
|
-
* entity is filtered relative to itself, so it takes the same empty root.
|
|
90
|
-
*/
|
|
91
|
-
const rootScope = () => (0, exports.createMember)(new literal_util_1.ExpressionNode('', 0));
|
|
92
|
-
exports.rootScope = rootScope;
|
|
93
|
-
//# sourceMappingURL=scopeProxy.util.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scopeProxy.util.js","sourceRoot":"","sources":["../../../../../src/module/query/util/filter/scopeProxy.util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qFAA6E;AAC7E,mFAA2E;AAC3E,+DAAuD;AACvD,iDAAgD;AAEhD,uEAAuE;AACvE,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAElC,uEAAuE;AAChE,MAAM,MAAM,GAAG,CAAC,KAAc,EAA8B,EAAE,CACpE,OAAO,KAAK,KAAK,UAAU,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,K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