@ballistix.digital/odata-query-builder 0.3.0 → 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/dist/index.d.ts +2 -2
- package/dist/module/query/domain/chain/{projectChain.model.d.ts → expandChain.model.d.ts} +4 -4
- package/dist/module/query/domain/chain/{projectChain.model.js → expandChain.model.js} +1 -1
- package/dist/module/query/domain/chain/expandChain.model.js.map +1 -0
- package/dist/module/query/domain/chain/expandNamespace.model.d.ts +19 -3
- package/dist/module/query/service/queryChain.service.d.ts +2 -2
- package/dist/module/query/service/queryChain.service.js +2 -2
- package/dist/module/query/service/queryChain.service.js.map +1 -1
- package/package.json +1 -1
- package/dist/module/query/domain/chain/projectChain.model.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,9 +11,9 @@ import type { ExceptionDetail } from './module/common/domain/exceptionDetail.mod
|
|
|
11
11
|
import type { Scalar, Unwrap } from './module/common/domain/scalar.model';
|
|
12
12
|
import { QueryBuilderException } from './module/common/exception/queryBuilder.exception';
|
|
13
13
|
import type { Chain, QueryParams } from './module/query/domain/chain/chain.model';
|
|
14
|
+
import type { ExpandChain } from './module/query/domain/chain/expandChain.model';
|
|
14
15
|
import type { EmbeddedPathKeys, ExpandKey, ExpandNamespace, FieldKey, OrderKey } from './module/query/domain/chain/expandNamespace.model';
|
|
15
16
|
import type { ItemChain } from './module/query/domain/chain/itemChain.model';
|
|
16
|
-
import type { ProjectChain } from './module/query/domain/chain/projectChain.model';
|
|
17
17
|
import type { BooleanExpr } from './module/query/domain/filter/booleanExpr.model';
|
|
18
18
|
import type { Castable, CastResult, EdmTarget } from './module/query/domain/filter/castable.model';
|
|
19
19
|
import type { Comparable } from './module/query/domain/filter/comparable.model';
|
|
@@ -28,4 +28,4 @@ import { ReservedNameError } from './module/query/exception/reservedName.excepti
|
|
|
28
28
|
import { and, maxdatetime, mindatetime, not, now, or, raw } from './module/query/service/filter/filter.facade';
|
|
29
29
|
import { odataItem, odataQuery } from './module/query/service/queryChain.service';
|
|
30
30
|
export { InvalidFilterError, QueryBuilderException, QueryBuilderExceptionCode, ReservedNameError, and, maxdatetime, mindatetime, not, now, odataItem, odataQuery, or, raw, };
|
|
31
|
-
export type { BooleanExpr, CastResult, Castable, Chain, Comparable, DateExpr, DateInput, EdmTarget, EmbeddedObjectKeys, EmbeddedOf, EmbeddedPathKeys, ExceptionDetail, ExpandKey, ExpandNamespace, ExprFor, FieldKey, ItemChain, LambdaNamespace, Node, NumberExpr, Operators, OrderKey, OwnKeys, Predicate, PrimitiveArrayKeys, PrimitiveLambdaNamespace,
|
|
31
|
+
export type { BooleanExpr, CastResult, Castable, Chain, Comparable, DateExpr, DateInput, EdmTarget, EmbeddedObjectKeys, EmbeddedOf, EmbeddedPathKeys, ExceptionDetail, ExpandChain, ExpandKey, ExpandNamespace, ExprFor, FieldKey, ItemChain, LambdaNamespace, Node, NumberExpr, Operators, OrderKey, OwnKeys, Predicate, PrimitiveArrayKeys, PrimitiveLambdaNamespace, QueryParams, Relation, Scalar, ScalarFieldKeys, Scope, StringExpr, ToManyKeys, ToOneKeys, Unwrap, };
|
|
@@ -17,12 +17,12 @@ import type { Predicate } from '../filter/node.model';
|
|
|
17
17
|
import type { Operators } from '../filter/operators.model';
|
|
18
18
|
import type { Scope } from '../filter/scope.model';
|
|
19
19
|
import type { ExpandNamespace, FieldKey } from './expandNamespace.model';
|
|
20
|
-
export interface
|
|
21
|
-
readonly expand: ExpandNamespace<T,
|
|
22
|
-
select(...keys: FieldKey<T>[]):
|
|
20
|
+
export interface ExpandChain<T> {
|
|
21
|
+
readonly expand: ExpandNamespace<T, ExpandChain<T>>;
|
|
22
|
+
select(...keys: FieldKey<T>[]): ExpandChain<T>;
|
|
23
23
|
/**
|
|
24
24
|
* `$expand=rel($filter=…)`. The scope is the EXPANDED entity, so paths are
|
|
25
25
|
* written relative to it, not to the root. Repeated calls AND together.
|
|
26
26
|
*/
|
|
27
|
-
filter(build: (scope: Scope<T>, operators: Operators) => Predicate):
|
|
27
|
+
filter(build: (scope: Scope<T>, operators: Operators) => Predicate): ExpandChain<T>;
|
|
28
28
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expandChain.model.js","sourceRoot":"","sources":["../../../../../src/module/query/domain/chain/expandChain.model.ts"],"names":[],"mappings":""}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* relation reaches, with no build step and no `$metadata` document.
|
|
7
7
|
*/
|
|
8
8
|
import type { EmbeddedObjectKeys, Relation, ScalarFieldKeys, ToManyKeys, ToOneKeys } from '../filter/scope.model';
|
|
9
|
-
import type {
|
|
9
|
+
import type { ExpandChain } from './expandChain.model';
|
|
10
10
|
/** Every expandable relation name of a DTO. A real allowlist. */
|
|
11
11
|
export type ExpandKey<T> = ToOneKeys<T> | ToManyKeys<T>;
|
|
12
12
|
/**
|
|
@@ -15,7 +15,23 @@ export type ExpandKey<T> = ToOneKeys<T> | ToManyKeys<T>;
|
|
|
15
15
|
* A DTO graph is cyclic — `ProjectDto` reaches itself through `parent` — so a
|
|
16
16
|
* path type that recursed freely would never terminate and TypeScript would
|
|
17
17
|
* answer TS2589. Indexing `Down` with the remaining budget yields the budget
|
|
18
|
-
* one segment deeper;
|
|
18
|
+
* one segment deeper; `[D] extends [0]` stops the descent.
|
|
19
|
+
*
|
|
20
|
+
* The budget also sets what a caller can write. `OrderKey` (default 3) admits
|
|
21
|
+
* up to three to-one hops; `EmbeddedPathKeys` (default 2) admits three object
|
|
22
|
+
* segments before the leaf. A deeper path is a compile error, which
|
|
23
|
+
* `test/types/err/orderBy.err.ts` pins.
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* orderBy('owner/organisation/code') // 2 to-one hops: compiles
|
|
27
|
+
* orderBy('parent/parent/parent/name') // 3 to-one hops: compiles, the default budget
|
|
28
|
+
* orderBy('parent/parent/parent/parent/name') // 4 to-one hops: TS2345, past the budget
|
|
29
|
+
* // Down[3] is 2, Down[1] is 0, and at 0 the path stops.
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* To allow a deeper path, raise the default `D` and move the pinned case to
|
|
33
|
+
* `test/types/ok/`. Each extra unit multiplies the key strings TypeScript
|
|
34
|
+
* builds, so compile time grows.
|
|
19
35
|
*/
|
|
20
36
|
type Budget = 0 | 1 | 2 | 3;
|
|
21
37
|
type Down = [never, 0, 1, 2, 3];
|
|
@@ -51,6 +67,6 @@ export type OrderKey<T, D extends Budget = 3> = FieldKey<T> | ([D] extends [0] ?
|
|
|
51
67
|
* chains at whatever level it is written.
|
|
52
68
|
*/
|
|
53
69
|
export type ExpandNamespace<T, Self> = {
|
|
54
|
-
readonly [K in ExpandKey<T>]: (
|
|
70
|
+
readonly [K in ExpandKey<T>]: (build?: (chain: ExpandChain<Relation<T, K>>) => unknown) => Self;
|
|
55
71
|
};
|
|
56
72
|
export {};
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* query therefore does not change this class, and a change to this class does
|
|
11
11
|
* not change how the query is printed.
|
|
12
12
|
*
|
|
13
|
-
* `Chain<T>`, `ItemChain<T>` and `
|
|
13
|
+
* `Chain<T>`, `ItemChain<T>` and `ExpandChain<T>` are three interfaces over
|
|
14
14
|
* this one class. Only the type that a factory returns differs. `Chain<T>`
|
|
15
15
|
* has every member. `ItemChain<T>` has `select`, `expand`, `toQueryString()`
|
|
16
|
-
* and `toParams()`. `
|
|
16
|
+
* and `toParams()`. `ExpandChain<T>` has `select`, `expand` and `filter`, the
|
|
17
17
|
* three options that the server accepts inside `$expand`. At runtime, every
|
|
18
18
|
* instance has every member.
|
|
19
19
|
*/
|
|
@@ -33,9 +33,9 @@ class QueryChainService {
|
|
|
33
33
|
throw new reservedName_exception_1.ReservedNameError(property);
|
|
34
34
|
if (property === 'constructor')
|
|
35
35
|
return undefined;
|
|
36
|
-
return (
|
|
36
|
+
return (build) => {
|
|
37
37
|
const child = new QueryChainService();
|
|
38
|
-
|
|
38
|
+
build?.(child);
|
|
39
39
|
this.queryState.expand.push({
|
|
40
40
|
name: property,
|
|
41
41
|
queryState: child.queryState,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryChain.service.js","sourceRoot":"","sources":["../../../../src/module/query/service/queryChain.service.ts"],"names":[],"mappings":";;;AAwBA,kFAA0E;AAC1E,gFAAwE;AACxE,oDAAsE;AACtE,0DAGgC;AAEhC,MAAa,iBAAiB;IACpB,UAAU,GAAe;QACjC,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE;KACX,CAAC;IAEF;;;;;;;;;;;OAWG;IACH,IAAI,MAAM;QACT,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAA4B,EAAE;YAChE,GAAG,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;gBAC1B,IAAI,OAAO,QAAQ,KAAK,QAAQ;oBAAE,OAAO,SAAS,CAAC;gBACnD,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,QAAQ;oBAC/C,MAAM,IAAI,0CAAiB,CAAC,QAAQ,CAAC,CAAC;gBACvC,IAAI,QAAQ,KAAK,aAAa;oBAAE,OAAO,SAAS,CAAC;gBACjD,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"queryChain.service.js","sourceRoot":"","sources":["../../../../src/module/query/service/queryChain.service.ts"],"names":[],"mappings":";;;AAwBA,kFAA0E;AAC1E,gFAAwE;AACxE,oDAAsE;AACtE,0DAGgC;AAEhC,MAAa,iBAAiB;IACpB,UAAU,GAAe;QACjC,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE;KACX,CAAC;IAEF;;;;;;;;;;;OAWG;IACH,IAAI,MAAM;QACT,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAA4B,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vC,QAAA,SAAS,aAC8B"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projectChain.model.js","sourceRoot":"","sources":["../../../../../src/module/query/domain/chain/projectChain.model.ts"],"names":[],"mappings":""}
|