@decaf-ts/core 0.5.0 → 0.5.2
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.md +21 -157
- package/README.md +652 -15
- package/dist/core.cjs +2638 -1085
- package/dist/core.esm.cjs +2636 -1070
- package/lib/esm/identity/decorators.d.ts +52 -14
- package/lib/esm/identity/decorators.js +54 -16
- package/lib/esm/identity/utils.d.ts +20 -1
- package/lib/esm/identity/utils.js +22 -2
- package/lib/esm/index.d.ts +11 -15
- package/lib/esm/index.js +17 -19
- package/lib/esm/interfaces/ErrorParser.d.ts +12 -0
- package/lib/esm/interfaces/ErrorParser.js +1 -1
- package/lib/esm/interfaces/Executor.d.ts +10 -13
- package/lib/esm/interfaces/Executor.js +1 -1
- package/lib/esm/interfaces/Observable.d.ts +20 -18
- package/lib/esm/interfaces/Observable.js +1 -1
- package/lib/esm/interfaces/Observer.d.ts +7 -8
- package/lib/esm/interfaces/Observer.js +1 -1
- package/lib/esm/interfaces/Paginatable.d.ts +18 -2
- package/lib/esm/interfaces/Paginatable.js +1 -1
- package/lib/esm/interfaces/Queriable.d.ts +44 -3
- package/lib/esm/interfaces/Queriable.js +1 -1
- package/lib/esm/interfaces/RawExecutor.d.ts +10 -13
- package/lib/esm/interfaces/RawExecutor.js +1 -1
- package/lib/esm/interfaces/SequenceOptions.d.ts +50 -5
- package/lib/esm/interfaces/SequenceOptions.js +19 -1
- package/lib/esm/interfaces/index.d.ts +0 -1
- package/lib/esm/interfaces/index.js +1 -2
- package/lib/esm/model/BaseModel.d.ts +31 -0
- package/lib/esm/model/BaseModel.js +24 -1
- package/lib/esm/model/construction.d.ts +442 -9
- package/lib/esm/model/construction.js +441 -2
- package/lib/esm/model/decorators.d.ts +166 -42
- package/lib/esm/model/decorators.js +161 -37
- package/lib/esm/model/index.js +1 -2
- package/lib/esm/model/types.d.ts +9 -0
- package/lib/esm/model/types.js +1 -1
- package/lib/esm/persistence/Adapter.d.ts +384 -40
- package/lib/esm/persistence/Adapter.js +415 -59
- package/lib/esm/persistence/Dispatch.d.ts +131 -0
- package/lib/esm/persistence/Dispatch.js +187 -0
- package/lib/esm/persistence/ObserverHandler.d.ts +109 -0
- package/lib/esm/persistence/ObserverHandler.js +137 -0
- package/lib/esm/persistence/Sequence.d.ts +89 -8
- package/lib/esm/persistence/Sequence.js +91 -1
- package/lib/esm/persistence/constants.d.ts +22 -5
- package/lib/esm/persistence/constants.js +23 -7
- package/lib/esm/persistence/decorators.d.ts +10 -0
- package/lib/esm/persistence/decorators.js +11 -1
- package/lib/esm/persistence/errors.d.ts +23 -3
- package/lib/esm/persistence/errors.js +25 -7
- package/lib/esm/persistence/index.d.ts +3 -0
- package/lib/esm/persistence/index.js +4 -1
- package/lib/esm/persistence/types.d.ts +21 -0
- package/lib/esm/persistence/types.js +2 -0
- package/lib/esm/query/Condition.d.ts +88 -44
- package/lib/esm/query/Condition.js +144 -62
- package/lib/esm/query/Paginator.d.ts +67 -10
- package/lib/esm/query/Paginator.js +64 -10
- package/lib/esm/query/Statement.d.ts +82 -47
- package/lib/esm/query/Statement.js +175 -122
- package/lib/esm/query/constants.d.ts +25 -64
- package/lib/esm/query/constants.js +26 -68
- package/lib/esm/query/errors.d.ts +14 -0
- package/lib/esm/query/errors.js +15 -1
- package/lib/esm/query/index.d.ts +0 -5
- package/lib/esm/query/index.js +1 -6
- package/lib/esm/query/options.d.ts +69 -178
- package/lib/esm/query/options.js +1 -1
- package/lib/esm/query/selectors.d.ts +20 -24
- package/lib/esm/query/selectors.js +1 -1
- package/lib/esm/ram/RamAdapter.d.ts +322 -20
- package/lib/esm/ram/RamAdapter.js +360 -140
- package/lib/esm/ram/RamContext.d.ts +16 -1
- package/lib/esm/ram/RamContext.js +18 -3
- package/lib/esm/ram/RamPaginator.d.ts +51 -6
- package/lib/esm/ram/RamPaginator.js +58 -6
- package/lib/esm/ram/RamSequence.d.ts +49 -24
- package/lib/esm/ram/RamSequence.js +52 -40
- package/lib/esm/ram/RamStatement.d.ts +84 -6
- package/lib/esm/ram/RamStatement.js +175 -6
- package/lib/esm/ram/constants.d.ts +9 -0
- package/lib/esm/ram/constants.js +10 -0
- package/lib/esm/ram/handlers.d.ts +25 -0
- package/lib/esm/ram/handlers.js +27 -0
- package/lib/esm/ram/index.d.ts +4 -4
- package/lib/esm/ram/index.js +9 -5
- package/lib/esm/ram/model/RamSequence.d.ts +21 -9
- package/lib/esm/ram/model/RamSequence.js +19 -1
- package/lib/esm/ram/types.d.ts +47 -5
- package/lib/esm/ram/types.js +1 -1
- package/lib/esm/repository/Repository.d.ts +381 -22
- package/lib/esm/repository/Repository.js +446 -43
- package/lib/esm/repository/constants.d.ts +23 -13
- package/lib/esm/repository/constants.js +24 -14
- package/lib/esm/repository/decorators.d.ts +27 -0
- package/lib/esm/repository/decorators.js +28 -1
- package/lib/esm/repository/errors.d.ts +12 -11
- package/lib/esm/repository/errors.js +13 -16
- package/lib/esm/repository/injectables.d.ts +18 -0
- package/lib/esm/repository/injectables.js +19 -1
- package/lib/esm/repository/types.d.ts +13 -1
- package/lib/esm/repository/types.js +1 -1
- package/lib/esm/repository/utils.d.ts +11 -0
- package/lib/esm/repository/utils.js +12 -1
- package/lib/esm/utils/decorators.d.ts +9 -0
- package/lib/esm/utils/decorators.js +19 -0
- package/lib/esm/utils/errors.d.ts +56 -0
- package/lib/esm/utils/errors.js +63 -0
- package/lib/esm/utils/index.d.ts +2 -0
- package/lib/esm/utils/index.js +3 -0
- package/lib/identity/decorators.cjs +54 -16
- package/lib/identity/decorators.d.ts +52 -14
- package/lib/identity/utils.cjs +22 -2
- package/lib/identity/utils.d.ts +20 -1
- package/lib/index.cjs +17 -19
- package/lib/index.d.ts +11 -15
- package/lib/interfaces/ErrorParser.cjs +1 -1
- package/lib/interfaces/ErrorParser.d.ts +12 -0
- package/lib/interfaces/Executor.cjs +1 -1
- package/lib/interfaces/Executor.d.ts +10 -13
- package/lib/interfaces/Observable.cjs +1 -1
- package/lib/interfaces/Observable.d.ts +20 -18
- package/lib/interfaces/Observer.cjs +1 -1
- package/lib/interfaces/Observer.d.ts +7 -8
- package/lib/interfaces/Paginatable.cjs +1 -1
- package/lib/interfaces/Paginatable.d.ts +18 -2
- package/lib/interfaces/Queriable.cjs +1 -1
- package/lib/interfaces/Queriable.d.ts +44 -3
- package/lib/interfaces/RawExecutor.cjs +1 -1
- package/lib/interfaces/RawExecutor.d.ts +10 -13
- package/lib/interfaces/SequenceOptions.cjs +19 -1
- package/lib/interfaces/SequenceOptions.d.ts +50 -5
- package/lib/interfaces/index.cjs +1 -2
- package/lib/interfaces/index.d.ts +0 -1
- package/lib/model/BaseModel.cjs +24 -1
- package/lib/model/BaseModel.d.ts +31 -0
- package/lib/model/construction.cjs +441 -2
- package/lib/model/construction.d.ts +442 -9
- package/lib/model/decorators.cjs +161 -37
- package/lib/model/decorators.d.ts +166 -42
- package/lib/model/index.cjs +1 -2
- package/lib/model/types.cjs +1 -1
- package/lib/model/types.d.ts +9 -0
- package/lib/persistence/Adapter.cjs +414 -58
- package/lib/persistence/Adapter.d.ts +384 -40
- package/lib/persistence/Dispatch.cjs +191 -0
- package/lib/persistence/Dispatch.d.ts +131 -0
- package/lib/persistence/ObserverHandler.cjs +141 -0
- package/lib/persistence/ObserverHandler.d.ts +109 -0
- package/lib/persistence/Sequence.cjs +91 -1
- package/lib/persistence/Sequence.d.ts +89 -8
- package/lib/persistence/constants.cjs +24 -8
- package/lib/persistence/constants.d.ts +22 -5
- package/lib/persistence/decorators.cjs +11 -1
- package/lib/persistence/decorators.d.ts +10 -0
- package/lib/persistence/errors.cjs +26 -9
- package/lib/persistence/errors.d.ts +23 -3
- package/lib/persistence/index.cjs +4 -1
- package/lib/persistence/index.d.ts +3 -0
- package/lib/persistence/types.cjs +3 -0
- package/lib/persistence/types.d.ts +21 -0
- package/lib/query/Condition.cjs +143 -61
- package/lib/query/Condition.d.ts +88 -44
- package/lib/query/Paginator.cjs +64 -10
- package/lib/query/Paginator.d.ts +67 -10
- package/lib/query/Statement.cjs +174 -121
- package/lib/query/Statement.d.ts +82 -47
- package/lib/query/constants.cjs +27 -69
- package/lib/query/constants.d.ts +25 -64
- package/lib/query/errors.cjs +15 -1
- package/lib/query/errors.d.ts +14 -0
- package/lib/query/index.cjs +1 -6
- package/lib/query/index.d.ts +0 -5
- package/lib/query/options.cjs +1 -1
- package/lib/query/options.d.ts +69 -178
- package/lib/query/selectors.cjs +1 -1
- package/lib/query/selectors.d.ts +20 -24
- package/lib/ram/RamAdapter.cjs +358 -172
- package/lib/ram/RamAdapter.d.ts +322 -20
- package/lib/ram/RamContext.cjs +18 -3
- package/lib/ram/RamContext.d.ts +16 -1
- package/lib/ram/RamPaginator.cjs +58 -6
- package/lib/ram/RamPaginator.d.ts +51 -6
- package/lib/ram/RamSequence.cjs +52 -41
- package/lib/ram/RamSequence.d.ts +49 -24
- package/lib/ram/RamStatement.cjs +175 -6
- package/lib/ram/RamStatement.d.ts +84 -6
- package/lib/ram/constants.cjs +13 -0
- package/lib/ram/constants.d.ts +9 -0
- package/lib/ram/handlers.cjs +30 -0
- package/lib/ram/handlers.d.ts +25 -0
- package/lib/ram/index.cjs +9 -5
- package/lib/ram/index.d.ts +4 -4
- package/lib/ram/model/RamSequence.cjs +19 -1
- package/lib/ram/model/RamSequence.d.ts +21 -9
- package/lib/ram/types.cjs +1 -1
- package/lib/ram/types.d.ts +47 -5
- package/lib/repository/Repository.cjs +445 -42
- package/lib/repository/Repository.d.ts +381 -22
- package/lib/repository/constants.cjs +24 -14
- package/lib/repository/constants.d.ts +23 -13
- package/lib/repository/decorators.cjs +28 -1
- package/lib/repository/decorators.d.ts +27 -0
- package/lib/repository/errors.cjs +14 -19
- package/lib/repository/errors.d.ts +12 -11
- package/lib/repository/injectables.cjs +19 -1
- package/lib/repository/injectables.d.ts +18 -0
- package/lib/repository/types.cjs +1 -1
- package/lib/repository/types.d.ts +13 -1
- package/lib/repository/utils.cjs +12 -1
- package/lib/repository/utils.d.ts +11 -0
- package/lib/utils/decorators.cjs +22 -0
- package/lib/utils/decorators.d.ts +9 -0
- package/lib/utils/errors.cjs +69 -0
- package/lib/utils/errors.d.ts +56 -0
- package/lib/{validators → utils}/index.cjs +2 -2
- package/lib/utils/index.d.ts +2 -0
- package/package.json +5 -5
- package/lib/esm/interfaces/Builder.d.ts +0 -16
- package/lib/esm/interfaces/Builder.js +0 -2
- package/lib/esm/model/IdentifiedBaseModel.d.ts +0 -7
- package/lib/esm/model/IdentifiedBaseModel.js +0 -25
- package/lib/esm/query/Clause.d.ts +0 -50
- package/lib/esm/query/Clause.js +0 -82
- package/lib/esm/query/ClauseFactory.d.ts +0 -71
- package/lib/esm/query/ClauseFactory.js +0 -6
- package/lib/esm/query/Query.d.ts +0 -43
- package/lib/esm/query/Query.js +0 -54
- package/lib/esm/query/clauses/FromClause.d.ts +0 -45
- package/lib/esm/query/clauses/FromClause.js +0 -59
- package/lib/esm/query/clauses/GroupByClause.d.ts +0 -21
- package/lib/esm/query/clauses/GroupByClause.js +0 -19
- package/lib/esm/query/clauses/InsertClause.d.ts +0 -37
- package/lib/esm/query/clauses/InsertClause.js +0 -55
- package/lib/esm/query/clauses/LimitClause.d.ts +0 -29
- package/lib/esm/query/clauses/LimitClause.js +0 -27
- package/lib/esm/query/clauses/OffsetClause.d.ts +0 -21
- package/lib/esm/query/clauses/OffsetClause.js +0 -19
- package/lib/esm/query/clauses/OrderByClause.d.ts +0 -37
- package/lib/esm/query/clauses/OrderByClause.js +0 -39
- package/lib/esm/query/clauses/SelectClause.d.ts +0 -47
- package/lib/esm/query/clauses/SelectClause.js +0 -62
- package/lib/esm/query/clauses/SelectorBasedClause.d.ts +0 -25
- package/lib/esm/query/clauses/SelectorBasedClause.js +0 -44
- package/lib/esm/query/clauses/ValuesClause.d.ts +0 -21
- package/lib/esm/query/clauses/ValuesClause.js +0 -36
- package/lib/esm/query/clauses/WhereClause.d.ts +0 -46
- package/lib/esm/query/clauses/WhereClause.js +0 -71
- package/lib/esm/query/clauses/index.d.ts +0 -10
- package/lib/esm/query/clauses/index.js +0 -11
- package/lib/esm/query/types.d.ts +0 -2
- package/lib/esm/query/types.js +0 -2
- package/lib/esm/ram/RamClauseFactory.d.ts +0 -17
- package/lib/esm/ram/RamClauseFactory.js +0 -92
- package/lib/esm/ram/clauses/FromClause.d.ts +0 -7
- package/lib/esm/ram/clauses/FromClause.js +0 -11
- package/lib/esm/ram/clauses/InsertClause.d.ts +0 -7
- package/lib/esm/ram/clauses/InsertClause.js +0 -13
- package/lib/esm/ram/clauses/OrderByClause.d.ts +0 -7
- package/lib/esm/ram/clauses/OrderByClause.js +0 -39
- package/lib/esm/ram/clauses/SelectClause.d.ts +0 -7
- package/lib/esm/ram/clauses/SelectClause.js +0 -16
- package/lib/esm/ram/clauses/ValuesClause.d.ts +0 -7
- package/lib/esm/ram/clauses/ValuesClause.js +0 -12
- package/lib/esm/ram/clauses/WhereClause.d.ts +0 -7
- package/lib/esm/ram/clauses/WhereClause.js +0 -11
- package/lib/esm/ram/clauses/index.d.ts +0 -6
- package/lib/esm/ram/clauses/index.js +0 -7
- package/lib/esm/validators/ClauseSequenceValidator.d.ts +0 -28
- package/lib/esm/validators/ClauseSequenceValidator.js +0 -95
- package/lib/esm/validators/decorators.d.ts +0 -10
- package/lib/esm/validators/decorators.js +0 -24
- package/lib/esm/validators/index.d.ts +0 -2
- package/lib/esm/validators/index.js +0 -3
- package/lib/interfaces/Builder.cjs +0 -3
- package/lib/interfaces/Builder.d.ts +0 -16
- package/lib/model/IdentifiedBaseModel.cjs +0 -29
- package/lib/model/IdentifiedBaseModel.d.ts +0 -7
- package/lib/query/Clause.cjs +0 -86
- package/lib/query/Clause.d.ts +0 -50
- package/lib/query/ClauseFactory.cjs +0 -10
- package/lib/query/ClauseFactory.d.ts +0 -71
- package/lib/query/Query.cjs +0 -58
- package/lib/query/Query.d.ts +0 -43
- package/lib/query/clauses/FromClause.cjs +0 -63
- package/lib/query/clauses/FromClause.d.ts +0 -45
- package/lib/query/clauses/GroupByClause.cjs +0 -23
- package/lib/query/clauses/GroupByClause.d.ts +0 -21
- package/lib/query/clauses/InsertClause.cjs +0 -59
- package/lib/query/clauses/InsertClause.d.ts +0 -37
- package/lib/query/clauses/LimitClause.cjs +0 -31
- package/lib/query/clauses/LimitClause.d.ts +0 -29
- package/lib/query/clauses/OffsetClause.cjs +0 -23
- package/lib/query/clauses/OffsetClause.d.ts +0 -21
- package/lib/query/clauses/OrderByClause.cjs +0 -43
- package/lib/query/clauses/OrderByClause.d.ts +0 -37
- package/lib/query/clauses/SelectClause.cjs +0 -66
- package/lib/query/clauses/SelectClause.d.ts +0 -47
- package/lib/query/clauses/SelectorBasedClause.cjs +0 -48
- package/lib/query/clauses/SelectorBasedClause.d.ts +0 -25
- package/lib/query/clauses/ValuesClause.cjs +0 -40
- package/lib/query/clauses/ValuesClause.d.ts +0 -21
- package/lib/query/clauses/WhereClause.cjs +0 -75
- package/lib/query/clauses/WhereClause.d.ts +0 -46
- package/lib/query/clauses/index.cjs +0 -27
- package/lib/query/clauses/index.d.ts +0 -10
- package/lib/query/types.cjs +0 -3
- package/lib/query/types.d.ts +0 -2
- package/lib/ram/RamClauseFactory.cjs +0 -96
- package/lib/ram/RamClauseFactory.d.ts +0 -17
- package/lib/ram/clauses/FromClause.cjs +0 -15
- package/lib/ram/clauses/FromClause.d.ts +0 -7
- package/lib/ram/clauses/InsertClause.cjs +0 -17
- package/lib/ram/clauses/InsertClause.d.ts +0 -7
- package/lib/ram/clauses/OrderByClause.cjs +0 -43
- package/lib/ram/clauses/OrderByClause.d.ts +0 -7
- package/lib/ram/clauses/SelectClause.cjs +0 -20
- package/lib/ram/clauses/SelectClause.d.ts +0 -7
- package/lib/ram/clauses/ValuesClause.cjs +0 -16
- package/lib/ram/clauses/ValuesClause.d.ts +0 -7
- package/lib/ram/clauses/WhereClause.cjs +0 -15
- package/lib/ram/clauses/WhereClause.d.ts +0 -7
- package/lib/ram/clauses/index.cjs +0 -23
- package/lib/ram/clauses/index.d.ts +0 -6
- package/lib/validators/ClauseSequenceValidator.cjs +0 -98
- package/lib/validators/ClauseSequenceValidator.d.ts +0 -28
- package/lib/validators/decorators.cjs +0 -27
- package/lib/validators/decorators.d.ts +0 -10
- package/lib/validators/index.d.ts +0 -2
package/lib/query/options.d.ts
CHANGED
@@ -3,101 +3,55 @@ import { Executor } from "../interfaces";
|
|
3
3
|
import { Constructor, Model } from "@decaf-ts/decorator-validation";
|
4
4
|
import { Condition } from "./Condition";
|
5
5
|
import { Paginatable } from "../interfaces/Paginatable";
|
6
|
-
/**
|
7
|
-
* @summary Statement Builder interface
|
8
|
-
* @description Exposes the final method to build the statement
|
9
|
-
*
|
10
|
-
* @typedef Q The query object type to build
|
11
|
-
* @interface QueryBuilder
|
12
|
-
*
|
13
|
-
* @category Query
|
14
|
-
* @subcategory Options
|
15
|
-
*
|
16
|
-
*/
|
17
|
-
export interface QueryBuilder<Q> extends Executor {
|
18
|
-
/**
|
19
|
-
* Method to build and validate the prepared statement before the execution;
|
20
|
-
*
|
21
|
-
* @throws {QueryError} for invalid statements
|
22
|
-
* @method
|
23
|
-
*/
|
24
|
-
build(previous: Q): Q;
|
25
|
-
}
|
26
6
|
/**
|
27
7
|
* @summary GroupBy Option interface
|
28
8
|
* @description Exposes the GROUP BY method and remaining options
|
29
9
|
*
|
30
10
|
* @interface GroupByOption
|
31
|
-
* @
|
32
|
-
*
|
33
|
-
* @category Query
|
34
|
-
* @subcategory Options
|
11
|
+
* @memberOf module:core
|
35
12
|
*/
|
36
|
-
export interface GroupByOption extends Executor {
|
37
|
-
|
38
|
-
* @summary Groups records by an attribute
|
39
|
-
*
|
40
|
-
* @param {GroupBySelector} selector
|
41
|
-
* @method
|
42
|
-
*/
|
43
|
-
groupBy(selector: GroupBySelector): Executor;
|
13
|
+
export interface GroupByOption<M extends Model, R> extends Executor<R> {
|
14
|
+
groupBy(selector: GroupBySelector<M>): Executor<R>;
|
44
15
|
}
|
45
16
|
/**
|
46
17
|
* @summary Offset Option interface
|
47
18
|
* @description Exposes the OFFSET method and remaining options
|
48
19
|
*
|
49
20
|
* @interface GroupByOption
|
50
|
-
* @
|
51
|
-
*
|
52
|
-
* @category Query
|
53
|
-
* @subcategory Options
|
21
|
+
* @memberOf module:core
|
54
22
|
*/
|
55
|
-
export interface OffsetOption extends Executor {
|
56
|
-
|
57
|
-
* @summary Offsets the results by the provided selector
|
58
|
-
*
|
59
|
-
* @param {OffsetSelector} selector
|
60
|
-
* @method
|
61
|
-
*/
|
62
|
-
offset(selector: OffsetSelector): Executor;
|
23
|
+
export interface OffsetOption<R> extends Executor<R> {
|
24
|
+
offset(selector: OffsetSelector): Executor<R>;
|
63
25
|
}
|
64
26
|
/**
|
65
27
|
* @summary Limit Option interface
|
66
28
|
* @description Exposes the LIMIT method and remaining options
|
67
29
|
*
|
68
30
|
* @interface LimitOption
|
69
|
-
* @
|
70
|
-
*
|
71
|
-
* @category Query
|
72
|
-
* @subcategory Options
|
31
|
+
* @memberOf module:core
|
73
32
|
*/
|
74
|
-
export interface LimitOption extends
|
75
|
-
|
76
|
-
* @summary Limits the results to the provided number
|
77
|
-
*
|
78
|
-
* @param {LimitSelector} selector
|
79
|
-
* @method
|
80
|
-
*/
|
81
|
-
limit(selector: LimitSelector): OffsetOption;
|
33
|
+
export interface LimitOption<M extends Model, R> extends Executor<R>, Paginatable<M, R, any> {
|
34
|
+
limit(selector: LimitSelector): OffsetOption<R>;
|
82
35
|
}
|
83
36
|
/**
|
84
|
-
* @summary
|
37
|
+
* @summary OrderBy Option interface
|
85
38
|
* @description Exposes the ORDER BY method and remaining options
|
86
39
|
*
|
87
40
|
* @interface OrderByOption
|
88
|
-
* @
|
41
|
+
* @memberOf module:core
|
42
|
+
*/
|
43
|
+
export interface OrderByOption<M extends Model, R> extends Executor<R>, Paginatable<M, R, any> {
|
44
|
+
orderBy(selector: OrderBySelector<M>): LimitOption<M, R> & OffsetOption<R>;
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* @summary OrderBy Option interface
|
48
|
+
* @description Exposes the ORDER BY method and remaining options
|
89
49
|
*
|
90
|
-
* @
|
91
|
-
* @
|
50
|
+
* @interface ThenByOption
|
51
|
+
* @memberOf module:core
|
92
52
|
*/
|
93
|
-
export interface
|
94
|
-
|
95
|
-
* @summary Orders the results by the provided attribute and according to the provided direction
|
96
|
-
*
|
97
|
-
* @param {OrderBySelector} selector
|
98
|
-
* @method
|
99
|
-
*/
|
100
|
-
orderBy(...selector: OrderBySelector[]): LimitOption & OffsetOption;
|
53
|
+
export interface ThenByOption<M extends Model, R> extends LimitOption<M, R>, OffsetOption<R>, Executor<R>, Paginatable<M, R, any> {
|
54
|
+
thenBy(selector: OrderBySelector<M>): ThenByOption<M, R>;
|
101
55
|
}
|
102
56
|
/**
|
103
57
|
* @summary Groups several order and grouping options
|
@@ -107,11 +61,9 @@ export interface OrderByOption extends Executor, Paginatable {
|
|
107
61
|
* @extends GroupByOption
|
108
62
|
* @extends LimitOption
|
109
63
|
* @extends OffsetOption
|
110
|
-
*
|
111
|
-
* @category Query
|
112
|
-
* @subcategory Options
|
64
|
+
* @memberOf module:core
|
113
65
|
*/
|
114
|
-
export interface OrderAndGroupOption extends OrderByOption, GroupByOption, LimitOption, OffsetOption {
|
66
|
+
export interface OrderAndGroupOption<M extends Model, R> extends OrderByOption<M, R>, Executor<R>, GroupByOption<M, R>, LimitOption<M, R>, OffsetOption<R> {
|
115
67
|
}
|
116
68
|
/**
|
117
69
|
* @summary Where Option interface
|
@@ -119,36 +71,32 @@ export interface OrderAndGroupOption extends OrderByOption, GroupByOption, Limit
|
|
119
71
|
*
|
120
72
|
* @interface WhereOption
|
121
73
|
* @extends OrderAndGroupOption
|
122
|
-
*
|
123
|
-
* @category Query
|
124
|
-
* @subcategory Options
|
74
|
+
* @memberOf module:core
|
125
75
|
*/
|
126
|
-
export interface WhereOption extends OrderAndGroupOption {
|
76
|
+
export interface WhereOption<M extends Model, R> extends OrderAndGroupOption<M, R> {
|
127
77
|
/**
|
128
78
|
* @summary filter the records by a condition
|
129
79
|
*
|
130
80
|
* @param {Condition} condition
|
131
81
|
* @method
|
132
82
|
*/
|
133
|
-
where(condition: Condition): OrderAndGroupOption
|
83
|
+
where(condition: Condition<M>): OrderAndGroupOption<M, R>;
|
134
84
|
}
|
135
85
|
/**
|
136
86
|
* @summary From Option Interface
|
137
87
|
* @description Exposes the FROM method and remaining options
|
138
88
|
*
|
139
89
|
* @interface FromOption
|
140
|
-
*
|
141
|
-
* @category Query
|
142
|
-
* @subcategory Options
|
90
|
+
* @memberOf module:core
|
143
91
|
*/
|
144
|
-
export interface FromOption<M extends Model> {
|
92
|
+
export interface FromOption<M extends Model, R> {
|
145
93
|
/**
|
146
94
|
* @summary selects records from a table
|
147
95
|
*
|
148
96
|
* @param {Constructor} tableName
|
149
97
|
* @method
|
150
98
|
*/
|
151
|
-
from(tableName: Constructor<M> | string): WhereOption
|
99
|
+
from(tableName: Constructor<M> | string): WhereOption<M, R>;
|
152
100
|
}
|
153
101
|
/**
|
154
102
|
* @summary Distinct Option Interface
|
@@ -156,11 +104,9 @@ export interface FromOption<M extends Model> {
|
|
156
104
|
*
|
157
105
|
* @interface DistinctOption
|
158
106
|
* @extends FromOption
|
159
|
-
*
|
160
|
-
* @category Query
|
161
|
-
* @subcategory Options
|
107
|
+
* @memberOf module:core
|
162
108
|
*/
|
163
|
-
export interface DistinctOption<M extends Model> extends FromOption<M> {
|
109
|
+
export interface DistinctOption<M extends Model, R> extends FromOption<M, R> {
|
164
110
|
}
|
165
111
|
/**
|
166
112
|
* @summary Max Option Interface
|
@@ -168,11 +114,9 @@ export interface DistinctOption<M extends Model> extends FromOption<M> {
|
|
168
114
|
*
|
169
115
|
* @interface MaxOption
|
170
116
|
* @extends FromOption
|
171
|
-
*
|
172
|
-
* @category Query
|
173
|
-
* @subcategory Options
|
117
|
+
* @memberOf module:core
|
174
118
|
*/
|
175
|
-
export interface MaxOption<M extends Model> extends FromOption<M> {
|
119
|
+
export interface MaxOption<M extends Model, R> extends FromOption<M, R> {
|
176
120
|
}
|
177
121
|
/**
|
178
122
|
* @summary Min Option Interface
|
@@ -180,11 +124,9 @@ export interface MaxOption<M extends Model> extends FromOption<M> {
|
|
180
124
|
*
|
181
125
|
* @interface MinOption
|
182
126
|
* @extends FromOption
|
183
|
-
*
|
184
|
-
* @category Query
|
185
|
-
* @subcategory Options
|
127
|
+
* @memberOf module:core
|
186
128
|
*/
|
187
|
-
export interface MinOption<M extends Model> extends FromOption<M> {
|
129
|
+
export interface MinOption<M extends Model, R> extends FromOption<M, R> {
|
188
130
|
}
|
189
131
|
/**
|
190
132
|
* @summary Count Option Interface
|
@@ -192,11 +134,9 @@ export interface MinOption<M extends Model> extends FromOption<M> {
|
|
192
134
|
*
|
193
135
|
* @interface CountOption
|
194
136
|
* @extends FromOption
|
195
|
-
*
|
196
|
-
* @category Query
|
197
|
-
* @subcategory Options
|
137
|
+
* @memberOf module:core
|
198
138
|
*/
|
199
|
-
export interface CountOption<M extends Model> extends FromOption<M> {
|
139
|
+
export interface CountOption<M extends Model, R> extends FromOption<M, R> {
|
200
140
|
}
|
201
141
|
/**
|
202
142
|
* @summary Select Option Interface
|
@@ -204,169 +144,120 @@ export interface CountOption<M extends Model> extends FromOption<M> {
|
|
204
144
|
*
|
205
145
|
* @interface SelectOption
|
206
146
|
* @extends FromOption
|
207
|
-
*
|
208
|
-
* @category Query
|
209
|
-
* @subcategory Options
|
147
|
+
* @memberOf module:core
|
210
148
|
*/
|
211
|
-
export interface SelectOption<M extends Model> extends FromOption<M> {
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
* @method
|
217
|
-
*/
|
218
|
-
distinct(selector: SelectSelector): DistinctOption<M>;
|
219
|
-
/**
|
220
|
-
* @summary the maximum value
|
221
|
-
*
|
222
|
-
* @param {SelectSelector} selector
|
223
|
-
* @method
|
224
|
-
*/
|
225
|
-
max(selector: SelectSelector): MaxOption<M>;
|
226
|
-
/**
|
227
|
-
* @summary selects the minimum value
|
228
|
-
*
|
229
|
-
* @param {SelectSelector} selector
|
230
|
-
* @method
|
231
|
-
*/
|
232
|
-
min(selector: SelectSelector): MinOption<M>;
|
233
|
-
/**
|
234
|
-
* @summary counts the records
|
235
|
-
*
|
236
|
-
* @param {SelectSelector} selector
|
237
|
-
* @method
|
238
|
-
*/
|
239
|
-
count(selector?: SelectSelector): CountOption<M>;
|
149
|
+
export interface SelectOption<M extends Model, R> extends FromOption<M, R> {
|
150
|
+
distinct<S extends SelectSelector<M>>(selector: S): DistinctOption<M, M[S][]>;
|
151
|
+
max<S extends SelectSelector<M>>(selector: S): MaxOption<M, M[S]>;
|
152
|
+
min<S extends SelectSelector<M>>(selector: S): MinOption<M, M[S]>;
|
153
|
+
count<S extends SelectSelector<M>>(selector?: S): CountOption<M, number>;
|
240
154
|
}
|
241
155
|
/**
|
242
156
|
* @summary Into Option Interface
|
243
157
|
* @description Exposes the remaining options after an INTO
|
244
158
|
*
|
245
159
|
* @interface IntoOption
|
246
|
-
*
|
247
|
-
* @category Query
|
248
|
-
* @subcategory Options
|
160
|
+
* @memberOf module:core
|
249
161
|
*/
|
250
|
-
export interface IntoOption<M extends Model> {
|
251
|
-
|
252
|
-
|
253
|
-
*
|
254
|
-
* @param {T[]} models
|
255
|
-
* @method
|
256
|
-
*/
|
257
|
-
values(...models: M[]): Executor;
|
258
|
-
/**
|
259
|
-
* @summary filter records to insert
|
260
|
-
*
|
261
|
-
* @param {Condition} condition
|
262
|
-
* @method
|
263
|
-
*/
|
264
|
-
where(condition: Condition): Executor;
|
162
|
+
export interface IntoOption<M extends Model, R> {
|
163
|
+
values(...models: M[]): Executor<R>;
|
164
|
+
where(condition: Condition<M>): Executor<R>;
|
265
165
|
}
|
266
166
|
/**
|
267
167
|
* @summary Valuest Option Interface
|
268
168
|
* @description Exposes the remaining options after a VALUES
|
269
169
|
*
|
270
170
|
* @interface ValuesOption
|
271
|
-
* @
|
272
|
-
*
|
273
|
-
* @category Query
|
274
|
-
* @subcategory Options
|
171
|
+
* @memberOf module:core
|
275
172
|
*/
|
276
|
-
export interface ValuesOption extends Executor {
|
173
|
+
export interface ValuesOption<M extends Model> extends Executor<M> {
|
277
174
|
}
|
278
175
|
/**
|
279
176
|
* @summary Insert Option Interface
|
280
177
|
* @description Exposes the remaining options after an INSERT
|
281
178
|
*
|
282
179
|
* @interface InsertOption
|
283
|
-
*
|
284
|
-
* @category Query
|
285
|
-
* @subcategory Options
|
180
|
+
* @memberOf module:core
|
286
181
|
*/
|
287
|
-
export interface InsertOption<M extends Model> {
|
182
|
+
export interface InsertOption<M extends Model, R = void> {
|
288
183
|
/**
|
289
184
|
* @summary selects the table to insert records into
|
290
185
|
*
|
291
186
|
* @param {string | Constructor} table
|
292
187
|
* @method
|
293
188
|
*/
|
294
|
-
into(table: Constructor<M>): IntoOption<M>;
|
189
|
+
into(table: Constructor<M>): IntoOption<M, R>;
|
295
190
|
}
|
296
191
|
/**
|
297
192
|
* @summary {@link Operator} Option Interface
|
298
193
|
* @description Exposes the available operators for a {@link Condition}
|
299
194
|
*
|
300
195
|
* @interface AttributeOption
|
301
|
-
*
|
302
|
-
* @category Query
|
303
|
-
* @subcategory Conditions
|
196
|
+
* @memberOf module:core
|
304
197
|
*/
|
305
|
-
export interface AttributeOption {
|
198
|
+
export interface AttributeOption<M extends Model> {
|
306
199
|
/**
|
307
200
|
* @summary Test equality
|
308
201
|
*
|
309
202
|
* @param {any} val the value to test
|
310
203
|
* @method
|
311
204
|
*/
|
312
|
-
eq(val: any): Condition
|
205
|
+
eq(val: any): Condition<M>;
|
313
206
|
/**
|
314
207
|
* @summary Test difference
|
315
208
|
*
|
316
209
|
* @param {any} val the value to test
|
317
210
|
* @method
|
318
211
|
*/
|
319
|
-
dif(val: any): Condition
|
212
|
+
dif(val: any): Condition<M>;
|
320
213
|
/**
|
321
214
|
* @summary Test greater than
|
322
215
|
*
|
323
216
|
* @param {any} val the value to test
|
324
217
|
* @method
|
325
218
|
*/
|
326
|
-
gt(val: any): Condition
|
219
|
+
gt(val: any): Condition<M>;
|
327
220
|
/**
|
328
221
|
* @summary Test lower than
|
329
222
|
*
|
330
223
|
* @param {any} val the value to test
|
331
224
|
* @method
|
332
225
|
*/
|
333
|
-
lt(val: any): Condition
|
226
|
+
lt(val: any): Condition<M>;
|
334
227
|
/**
|
335
228
|
* @summary Test greater or equal to
|
336
229
|
*
|
337
230
|
* @param {any} val the value to test
|
338
231
|
* @method
|
339
232
|
*/
|
340
|
-
gte(val: any): Condition
|
233
|
+
gte(val: any): Condition<M>;
|
341
234
|
/**
|
342
235
|
* @summary Test lower or equal to
|
343
236
|
*
|
344
237
|
* @param {any} val the value to test
|
345
238
|
* @method
|
346
239
|
*/
|
347
|
-
lte(val: any): Condition
|
240
|
+
lte(val: any): Condition<M>;
|
348
241
|
/**
|
349
242
|
* @summary Test value in a range of values
|
350
243
|
* @param {any[]} val
|
351
244
|
*/
|
352
|
-
in(val: any[]): Condition
|
245
|
+
in(val: any[]): Condition<M>;
|
353
246
|
/**
|
354
247
|
* @summary Test matches {@link RegExp}
|
355
248
|
*
|
356
249
|
* @param {any} val the value to test
|
357
250
|
* @method
|
358
251
|
*/
|
359
|
-
regexp(val: string | RegExp): Condition
|
252
|
+
regexp(val: string | RegExp): Condition<M>;
|
360
253
|
}
|
361
254
|
/**
|
362
|
-
* @
|
363
|
-
* @
|
364
|
-
*
|
255
|
+
* @description The starting point for creating query conditions
|
256
|
+
* @summary Exposes the available operations for building database query conditions
|
257
|
+
* @template M - The model type this condition builder operates on
|
365
258
|
* @interface ConditionBuilderOption
|
366
|
-
*
|
367
|
-
* @category Query
|
368
|
-
* @subcategory Conditions
|
259
|
+
* @memberOf module:core
|
369
260
|
*/
|
370
|
-
export interface ConditionBuilderOption {
|
371
|
-
attribute(attr:
|
261
|
+
export interface ConditionBuilderOption<M extends Model> {
|
262
|
+
attribute(attr: keyof M): AttributeOption<M>;
|
372
263
|
}
|
package/lib/query/selectors.cjs
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsZWN0b3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3F1ZXJ5L3NlbGVjdG9ycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgT3JkZXJEaXJlY3Rpb24gfSBmcm9tIFwiLi4vcmVwb3NpdG9yeVwiO1xuaW1wb3J0IHsgQ29uc3RydWN0b3IsIE1vZGVsIH0gZnJvbSBcIkBkZWNhZi10cy9kZWNvcmF0b3ItdmFsaWRhdGlvblwiO1xuXG4vKipcbiAqIEBkZXNjcmlwdGlvbiBUeXBlIGZvciBzZWxlY3RpbmcgdGhlIGRhdGEgc291cmNlIGluIGEgcXVlcnlcbiAqIEBzdW1tYXJ5IERlZmluZXMgdGhlIHR5cGUgZm9yIHNwZWNpZnlpbmcgdGhlIHRhYmxlIG9yIG1vZGVsIHRvIHF1ZXJ5IGZyb21cbiAqIEB0ZW1wbGF0ZSBNIC0gVGhlIG1vZGVsIHR5cGUgdGhpcyBzZWxlY3RvciBvcGVyYXRlcyBvblxuICogQHR5cGVkZWYge0NvbnN0cnVjdG9yPE0+IHwgc3RyaW5nfSBGcm9tU2VsZWN0b3JcbiAqIEBtZW1iZXJPZiBtb2R1bGU6Y29yZVxuICovXG5leHBvcnQgdHlwZSBGcm9tU2VsZWN0b3I8TSBleHRlbmRzIE1vZGVsPiA9IENvbnN0cnVjdG9yPE0+IHwgc3RyaW5nO1xuXG5leHBvcnQgdHlwZSBHcm91cEJ5U2VsZWN0b3I8TSBleHRlbmRzIE1vZGVsPiA9IGtleW9mIE07XG5cbmV4cG9ydCB0eXBlIE9yZGVyQnlTZWxlY3RvcjxNIGV4dGVuZHMgTW9kZWw+ID0gW2tleW9mIE0sIE9yZGVyRGlyZWN0aW9uXTtcblxuLyoqXG4gKiBAZGVzY3JpcHRpb24gVHlwZSBmb3IgbGltaXRpbmcgcXVlcnkgcmVzdWx0c1xuICogQHN1bW1hcnkgRGVmaW5lcyB0aGUgdHlwZSBmb3Igc3BlY2lmeWluZyB0aGUgbWF4aW11bSBudW1iZXIgb2YgcmVzdWx0cyB0byByZXR1cm5cbiAqIEB0eXBlZGVmIHtudW1iZXJ9IExpbWl0U2VsZWN0b3JcbiAqIEBtZW1iZXJPZiBtb2R1bGU6Y29yZVxuICovXG5leHBvcnQgdHlwZSBMaW1pdFNlbGVjdG9yID0gbnVtYmVyO1xuXG4vKipcbiAqIEBkZXNjcmlwdGlvbiBUeXBlIGZvciBvZmZzZXR0aW5nIHF1ZXJ5IHJlc3VsdHNcbiAqIEBzdW1tYXJ5IERlZmluZXMgdGhlIHR5cGUgZm9yIHNwZWNpZnlpbmcgdGhlIG51bWJlciBvZiByZXN1bHRzIHRvIHNraXBcbiAqIEB0eXBlZGVmIHtudW1iZXJ9IE9mZnNldFNlbGVjdG9yXG4gKiBAbWVtYmVyT2YgbW9kdWxlOmNvcmVcbiAqL1xuZXhwb3J0IHR5cGUgT2Zmc2V0U2VsZWN0b3IgPSBudW1iZXI7XG5cbi8qKlxuICogQGRlc2NyaXB0aW9uIFR5cGUgZm9yIHNlbGVjdGluZyBmaWVsZHMgaW4gYSBxdWVyeVxuICogQHN1bW1hcnkgRGVmaW5lcyB0aGUgdHlwZSBmb3Igc3BlY2lmeWluZyB3aGljaCBmaWVsZHMgdG8gc2VsZWN0IGZyb20gYSBtb2RlbFxuICogQHRlbXBsYXRlIE0gLSBUaGUgbW9kZWwgdHlwZSB0aGlzIHNlbGVjdG9yIG9wZXJhdGVzIG9uXG4gKiBAdHlwZWRlZiBTZWxlY3RTZWxlY3RvclxuICogQG1lbWJlck9mIG1vZHVsZTpjb3JlXG4gKi9cbmV4cG9ydCB0eXBlIFNlbGVjdFNlbGVjdG9yPE0gZXh0ZW5kcyBNb2RlbD4gPSBrZXlvZiBNO1xuIl19
|
package/lib/query/selectors.d.ts
CHANGED
@@ -1,38 +1,34 @@
|
|
1
1
|
import { OrderDirection } from "../repository";
|
2
2
|
import { Constructor, Model } from "@decaf-ts/decorator-validation";
|
3
3
|
/**
|
4
|
-
* @
|
5
|
-
*
|
6
|
-
* @
|
4
|
+
* @description Type for selecting the data source in a query
|
5
|
+
* @summary Defines the type for specifying the table or model to query from
|
6
|
+
* @template M - The model type this selector operates on
|
7
|
+
* @typedef {Constructor<M> | string} FromSelector
|
8
|
+
* @memberOf module:core
|
7
9
|
*/
|
8
10
|
export type FromSelector<M extends Model> = Constructor<M> | string;
|
11
|
+
export type GroupBySelector<M extends Model> = keyof M;
|
12
|
+
export type OrderBySelector<M extends Model> = [keyof M, OrderDirection];
|
9
13
|
/**
|
10
|
-
* @
|
11
|
-
*
|
12
|
-
* @
|
13
|
-
|
14
|
-
export type GroupBySelector = string;
|
15
|
-
/**
|
16
|
-
* @typedef OrderBySelector
|
17
|
-
*
|
18
|
-
* @category Clauses
|
19
|
-
*/
|
20
|
-
export type OrderBySelector = [string, OrderDirection];
|
21
|
-
/**
|
22
|
-
* @typedef LimitSelector
|
23
|
-
*
|
24
|
-
* @category Clauses
|
14
|
+
* @description Type for limiting query results
|
15
|
+
* @summary Defines the type for specifying the maximum number of results to return
|
16
|
+
* @typedef {number} LimitSelector
|
17
|
+
* @memberOf module:core
|
25
18
|
*/
|
26
19
|
export type LimitSelector = number;
|
27
20
|
/**
|
28
|
-
* @
|
29
|
-
*
|
30
|
-
* @
|
21
|
+
* @description Type for offsetting query results
|
22
|
+
* @summary Defines the type for specifying the number of results to skip
|
23
|
+
* @typedef {number} OffsetSelector
|
24
|
+
* @memberOf module:core
|
31
25
|
*/
|
32
26
|
export type OffsetSelector = number;
|
33
27
|
/**
|
28
|
+
* @description Type for selecting fields in a query
|
29
|
+
* @summary Defines the type for specifying which fields to select from a model
|
30
|
+
* @template M - The model type this selector operates on
|
34
31
|
* @typedef SelectSelector
|
35
|
-
*
|
36
|
-
* @category Clauses
|
32
|
+
* @memberOf module:core
|
37
33
|
*/
|
38
|
-
export type SelectSelector =
|
34
|
+
export type SelectSelector<M extends Model> = keyof M;
|