@decaf-ts/core 0.3.38 → 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/core.cjs +2361 -0
- package/dist/core.esm.cjs +2307 -0
- package/lib/esm/identity/decorators.js +1 -2
- package/lib/esm/identity/index.js +1 -2
- package/lib/esm/identity/utils.js +1 -2
- package/{dist/types → lib/esm}/index.d.ts +1 -1
- package/lib/esm/index.js +2 -3
- package/lib/esm/interfaces/Builder.js +1 -2
- package/lib/esm/interfaces/Executor.js +1 -2
- package/lib/esm/interfaces/Observable.js +1 -2
- package/lib/esm/interfaces/Observer.js +1 -2
- package/lib/esm/interfaces/Paginatable.js +1 -2
- package/lib/esm/interfaces/Queriable.js +1 -2
- package/lib/esm/interfaces/RawExecutor.js +1 -2
- package/lib/esm/interfaces/SequenceOptions.js +1 -2
- package/lib/esm/interfaces/index.js +1 -2
- package/lib/esm/model/BaseModel.js +1 -2
- package/lib/esm/model/IdentifiedBaseModel.js +1 -2
- package/{dist/types → lib/esm}/model/User.d.ts +2 -1
- package/lib/esm/model/User.js +1 -2
- package/lib/esm/model/construction.js +1 -2
- package/lib/esm/model/decorators.js +1 -2
- package/lib/esm/model/index.js +1 -2
- package/lib/esm/model/types.js +1 -2
- package/lib/esm/persistence/Adapter.js +1 -2
- package/lib/esm/persistence/Sequence.js +1 -2
- package/lib/esm/persistence/constants.js +1 -2
- package/lib/esm/persistence/decorators.js +1 -2
- package/lib/esm/persistence/errors.js +1 -2
- package/lib/esm/persistence/index.js +1 -2
- package/lib/esm/query/Clause.js +1 -2
- package/lib/esm/query/ClauseFactory.js +1 -2
- package/lib/esm/query/Condition.js +1 -2
- package/lib/esm/query/Paginator.js +1 -2
- package/lib/esm/query/Query.js +1 -2
- package/{dist/types → lib/esm}/query/Statement.d.ts +2 -1
- package/lib/esm/query/Statement.js +1 -2
- package/lib/esm/query/clauses/FromClause.js +1 -2
- package/lib/esm/query/clauses/GroupByClause.js +1 -2
- package/lib/esm/query/clauses/InsertClause.js +1 -2
- package/lib/esm/query/clauses/LimitClause.js +1 -2
- package/lib/esm/query/clauses/OffsetClause.js +1 -2
- package/lib/esm/query/clauses/OrderByClause.js +1 -2
- package/lib/esm/query/clauses/SelectClause.js +1 -2
- package/lib/esm/query/clauses/SelectorBasedClause.js +1 -2
- package/lib/esm/query/clauses/ValuesClause.js +1 -2
- package/lib/esm/query/clauses/WhereClause.js +1 -2
- package/lib/esm/query/clauses/index.js +1 -2
- package/lib/esm/query/constants.js +1 -2
- package/lib/esm/query/errors.js +1 -2
- package/lib/esm/query/index.js +1 -2
- package/lib/esm/query/options.js +1 -2
- package/lib/esm/query/selectors.js +1 -2
- package/lib/esm/query/types.js +1 -2
- package/lib/esm/repository/Context.js +1 -2
- package/lib/esm/repository/Repository.js +1 -2
- package/lib/esm/repository/constants.js +1 -2
- package/lib/esm/repository/decorators.js +1 -2
- package/lib/esm/repository/errors.js +1 -2
- package/lib/esm/repository/index.js +1 -2
- package/lib/esm/repository/injectables.js +1 -2
- package/lib/esm/repository/types.js +1 -2
- package/lib/esm/repository/utils.js +1 -2
- package/lib/esm/validators/ClauseSequenceValidator.js +1 -2
- package/lib/esm/validators/decorators.js +1 -2
- package/lib/esm/validators/index.js +1 -2
- package/lib/identity/decorators.cjs +1 -2
- package/lib/identity/decorators.d.ts +24 -0
- package/lib/identity/index.cjs +1 -2
- package/lib/identity/index.d.ts +2 -0
- package/lib/identity/utils.cjs +1 -2
- package/lib/identity/utils.d.ts +3 -0
- package/lib/index.cjs +2 -3
- package/lib/index.d.ts +25 -0
- package/lib/interfaces/Builder.cjs +1 -2
- package/lib/interfaces/Builder.d.ts +16 -0
- package/lib/interfaces/Executor.cjs +1 -2
- package/lib/interfaces/Executor.d.ts +19 -0
- package/lib/interfaces/Observable.cjs +1 -2
- package/lib/interfaces/Observable.d.ts +31 -0
- package/lib/interfaces/Observer.cjs +1 -2
- package/lib/interfaces/Observer.d.ts +16 -0
- package/lib/interfaces/Paginatable.cjs +1 -2
- package/lib/interfaces/Paginatable.d.ts +4 -0
- package/lib/interfaces/Queriable.cjs +1 -2
- package/lib/interfaces/Queriable.d.ts +6 -0
- package/lib/interfaces/RawExecutor.cjs +1 -2
- package/lib/interfaces/RawExecutor.d.ts +20 -0
- package/lib/interfaces/SequenceOptions.cjs +1 -2
- package/lib/interfaces/SequenceOptions.d.ts +19 -0
- package/lib/interfaces/index.cjs +1 -2
- package/lib/interfaces/index.d.ts +7 -0
- package/lib/model/BaseModel.cjs +1 -2
- package/lib/model/BaseModel.d.ts +6 -0
- package/lib/model/IdentifiedBaseModel.cjs +1 -2
- package/lib/model/IdentifiedBaseModel.d.ts +7 -0
- package/lib/model/User.cjs +1 -2
- package/lib/model/User.d.ts +9 -0
- package/lib/model/construction.cjs +1 -2
- package/lib/model/construction.d.ts +15 -0
- package/lib/model/decorators.cjs +1 -2
- package/lib/model/decorators.d.ts +75 -0
- package/lib/model/index.cjs +1 -2
- package/lib/model/index.d.ts +4 -0
- package/lib/model/types.cjs +1 -2
- package/lib/model/types.d.ts +6 -0
- package/lib/persistence/Adapter.cjs +1 -2
- package/lib/persistence/Adapter.d.ts +86 -0
- package/lib/persistence/Sequence.cjs +1 -2
- package/lib/persistence/Sequence.d.ts +22 -0
- package/lib/persistence/constants.cjs +1 -2
- package/lib/persistence/constants.d.ts +22 -0
- package/lib/persistence/decorators.cjs +1 -2
- package/lib/persistence/decorators.d.ts +1 -0
- package/lib/persistence/errors.cjs +1 -2
- package/lib/persistence/errors.d.ts +7 -0
- package/lib/persistence/index.cjs +1 -2
- package/lib/persistence/index.d.ts +5 -0
- package/lib/query/Clause.cjs +1 -2
- package/lib/query/Clause.d.ts +50 -0
- package/lib/query/ClauseFactory.cjs +1 -2
- package/lib/query/ClauseFactory.d.ts +71 -0
- package/lib/query/Condition.cjs +1 -2
- package/lib/query/Condition.d.ts +75 -0
- package/lib/query/Paginator.cjs +1 -2
- package/lib/query/Paginator.d.ts +22 -0
- package/lib/query/Query.cjs +1 -2
- package/lib/query/Query.d.ts +43 -0
- package/lib/query/Statement.cjs +1 -2
- package/lib/query/Statement.d.ts +56 -0
- package/lib/query/clauses/FromClause.cjs +1 -2
- package/lib/query/clauses/FromClause.d.ts +45 -0
- package/lib/query/clauses/GroupByClause.cjs +1 -2
- package/lib/query/clauses/GroupByClause.d.ts +21 -0
- package/lib/query/clauses/InsertClause.cjs +1 -2
- package/lib/query/clauses/InsertClause.d.ts +37 -0
- package/lib/query/clauses/LimitClause.cjs +1 -2
- package/lib/query/clauses/LimitClause.d.ts +29 -0
- package/lib/query/clauses/OffsetClause.cjs +1 -2
- package/lib/query/clauses/OffsetClause.d.ts +21 -0
- package/lib/query/clauses/OrderByClause.cjs +1 -2
- package/lib/query/clauses/OrderByClause.d.ts +37 -0
- package/lib/query/clauses/SelectClause.cjs +1 -2
- package/lib/query/clauses/SelectClause.d.ts +47 -0
- package/lib/query/clauses/SelectorBasedClause.cjs +1 -2
- package/lib/query/clauses/SelectorBasedClause.d.ts +25 -0
- package/lib/query/clauses/ValuesClause.cjs +1 -2
- package/lib/query/clauses/ValuesClause.d.ts +21 -0
- package/lib/query/clauses/WhereClause.cjs +1 -2
- package/lib/query/clauses/WhereClause.d.ts +46 -0
- package/lib/query/clauses/index.cjs +1 -2
- package/lib/query/clauses/index.d.ts +10 -0
- package/lib/query/constants.cjs +1 -2
- package/lib/query/constants.d.ts +79 -0
- package/lib/query/errors.cjs +1 -2
- package/lib/query/errors.d.ts +7 -0
- package/lib/query/index.cjs +1 -2
- package/lib/query/index.d.ts +12 -0
- package/lib/query/options.cjs +1 -2
- package/lib/query/options.d.ts +372 -0
- package/lib/query/selectors.cjs +1 -2
- package/lib/query/selectors.d.ts +38 -0
- package/lib/query/types.cjs +1 -2
- package/lib/query/types.d.ts +2 -0
- package/lib/repository/Context.cjs +1 -2
- package/lib/repository/Context.d.ts +10 -0
- package/lib/repository/Repository.cjs +1 -2
- package/lib/repository/Repository.d.ts +70 -0
- package/lib/repository/constants.cjs +1 -2
- package/lib/repository/constants.d.ts +25 -0
- package/lib/repository/decorators.cjs +1 -2
- package/lib/repository/decorators.d.ts +2 -0
- package/lib/repository/errors.cjs +1 -2
- package/lib/repository/errors.d.ts +12 -0
- package/lib/repository/index.cjs +1 -2
- package/lib/repository/index.d.ts +8 -0
- package/lib/repository/injectables.cjs +1 -2
- package/lib/repository/injectables.d.ts +5 -0
- package/lib/repository/types.cjs +1 -2
- package/lib/repository/types.d.ts +15 -0
- package/lib/repository/utils.cjs +1 -2
- package/lib/repository/utils.d.ts +3 -0
- package/lib/validators/ClauseSequenceValidator.cjs +1 -2
- package/lib/validators/ClauseSequenceValidator.d.ts +28 -0
- package/lib/validators/decorators.cjs +1 -2
- package/lib/validators/decorators.d.ts +10 -0
- package/lib/validators/index.cjs +1 -2
- package/lib/validators/index.d.ts +2 -0
- package/package.json +23 -36
- package/dist/core.js +0 -2
- package/dist/core.js.LICENSE.txt +0 -14
- package/dist/esm/core.js +0 -2
- package/dist/esm/core.js.LICENSE.txt +0 -14
- /package/{dist/types → lib/esm}/identity/decorators.d.ts +0 -0
- /package/{dist/types → lib/esm}/identity/index.d.ts +0 -0
- /package/{dist/types → lib/esm}/identity/utils.d.ts +0 -0
- /package/{dist/types → lib/esm}/interfaces/Builder.d.ts +0 -0
- /package/{dist/types → lib/esm}/interfaces/Executor.d.ts +0 -0
- /package/{dist/types → lib/esm}/interfaces/Observable.d.ts +0 -0
- /package/{dist/types → lib/esm}/interfaces/Observer.d.ts +0 -0
- /package/{dist/types → lib/esm}/interfaces/Paginatable.d.ts +0 -0
- /package/{dist/types → lib/esm}/interfaces/Queriable.d.ts +0 -0
- /package/{dist/types → lib/esm}/interfaces/RawExecutor.d.ts +0 -0
- /package/{dist/types → lib/esm}/interfaces/SequenceOptions.d.ts +0 -0
- /package/{dist/types → lib/esm}/interfaces/index.d.ts +0 -0
- /package/{dist/types → lib/esm}/model/BaseModel.d.ts +0 -0
- /package/{dist/types → lib/esm}/model/IdentifiedBaseModel.d.ts +0 -0
- /package/{dist/types → lib/esm}/model/construction.d.ts +0 -0
- /package/{dist/types → lib/esm}/model/decorators.d.ts +0 -0
- /package/{dist/types → lib/esm}/model/index.d.ts +0 -0
- /package/{dist/types → lib/esm}/model/types.d.ts +0 -0
- /package/{dist/types → lib/esm}/persistence/Adapter.d.ts +0 -0
- /package/{dist/types → lib/esm}/persistence/Sequence.d.ts +0 -0
- /package/{dist/types → lib/esm}/persistence/constants.d.ts +0 -0
- /package/{dist/types → lib/esm}/persistence/decorators.d.ts +0 -0
- /package/{dist/types → lib/esm}/persistence/errors.d.ts +0 -0
- /package/{dist/types → lib/esm}/persistence/index.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/Clause.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/ClauseFactory.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/Condition.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/Paginator.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/Query.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/clauses/FromClause.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/clauses/GroupByClause.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/clauses/InsertClause.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/clauses/LimitClause.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/clauses/OffsetClause.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/clauses/OrderByClause.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/clauses/SelectClause.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/clauses/SelectorBasedClause.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/clauses/ValuesClause.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/clauses/WhereClause.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/clauses/index.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/constants.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/errors.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/index.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/options.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/selectors.d.ts +0 -0
- /package/{dist/types → lib/esm}/query/types.d.ts +0 -0
- /package/{dist/types → lib/esm}/repository/Context.d.ts +0 -0
- /package/{dist/types → lib/esm}/repository/Repository.d.ts +0 -0
- /package/{dist/types → lib/esm}/repository/constants.d.ts +0 -0
- /package/{dist/types → lib/esm}/repository/decorators.d.ts +0 -0
- /package/{dist/types → lib/esm}/repository/errors.d.ts +0 -0
- /package/{dist/types → lib/esm}/repository/index.d.ts +0 -0
- /package/{dist/types → lib/esm}/repository/injectables.d.ts +0 -0
- /package/{dist/types → lib/esm}/repository/types.d.ts +0 -0
- /package/{dist/types → lib/esm}/repository/utils.d.ts +0 -0
- /package/{dist/types → lib/esm}/validators/ClauseSequenceValidator.d.ts +0 -0
- /package/{dist/types → lib/esm}/validators/decorators.d.ts +0 -0
- /package/{dist/types → lib/esm}/validators/index.d.ts +0 -0
@@ -0,0 +1,372 @@
|
|
1
|
+
import { GroupBySelector, LimitSelector, OffsetSelector, OrderBySelector, SelectSelector } from "./selectors";
|
2
|
+
import { Executor } from "../interfaces";
|
3
|
+
import { Constructor, Model } from "@decaf-ts/decorator-validation";
|
4
|
+
import { Condition } from "./Condition";
|
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
|
+
/**
|
27
|
+
* @summary GroupBy Option interface
|
28
|
+
* @description Exposes the GROUP BY method and remaining options
|
29
|
+
*
|
30
|
+
* @interface GroupByOption
|
31
|
+
* @extends QueryBuilder
|
32
|
+
*
|
33
|
+
* @category Query
|
34
|
+
* @subcategory Options
|
35
|
+
*/
|
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;
|
44
|
+
}
|
45
|
+
/**
|
46
|
+
* @summary Offset Option interface
|
47
|
+
* @description Exposes the OFFSET method and remaining options
|
48
|
+
*
|
49
|
+
* @interface GroupByOption
|
50
|
+
* @extends QueryBuilder
|
51
|
+
*
|
52
|
+
* @category Query
|
53
|
+
* @subcategory Options
|
54
|
+
*/
|
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;
|
63
|
+
}
|
64
|
+
/**
|
65
|
+
* @summary Limit Option interface
|
66
|
+
* @description Exposes the LIMIT method and remaining options
|
67
|
+
*
|
68
|
+
* @interface LimitOption
|
69
|
+
* @extends QueryBuilder
|
70
|
+
*
|
71
|
+
* @category Query
|
72
|
+
* @subcategory Options
|
73
|
+
*/
|
74
|
+
export interface LimitOption extends Executor, Paginatable {
|
75
|
+
/**
|
76
|
+
* @summary Limits the results to the provided number
|
77
|
+
*
|
78
|
+
* @param {LimitSelector} selector
|
79
|
+
* @method
|
80
|
+
*/
|
81
|
+
limit(selector: LimitSelector): OffsetOption;
|
82
|
+
}
|
83
|
+
/**
|
84
|
+
* @summary OrderpBy Option interface
|
85
|
+
* @description Exposes the ORDER BY method and remaining options
|
86
|
+
*
|
87
|
+
* @interface OrderByOption
|
88
|
+
* @extends QueryBuilder
|
89
|
+
*
|
90
|
+
* @category Query
|
91
|
+
* @subcategory Options
|
92
|
+
*/
|
93
|
+
export interface OrderByOption extends Executor, Paginatable {
|
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;
|
101
|
+
}
|
102
|
+
/**
|
103
|
+
* @summary Groups several order and grouping options
|
104
|
+
*
|
105
|
+
* @interface OrderAndGroupOption
|
106
|
+
* @extends OrderByOption
|
107
|
+
* @extends GroupByOption
|
108
|
+
* @extends LimitOption
|
109
|
+
* @extends OffsetOption
|
110
|
+
*
|
111
|
+
* @category Query
|
112
|
+
* @subcategory Options
|
113
|
+
*/
|
114
|
+
export interface OrderAndGroupOption extends OrderByOption, GroupByOption, LimitOption, OffsetOption {
|
115
|
+
}
|
116
|
+
/**
|
117
|
+
* @summary Where Option interface
|
118
|
+
* @description Exposes the WHERE method and remaining options
|
119
|
+
*
|
120
|
+
* @interface WhereOption
|
121
|
+
* @extends OrderAndGroupOption
|
122
|
+
*
|
123
|
+
* @category Query
|
124
|
+
* @subcategory Options
|
125
|
+
*/
|
126
|
+
export interface WhereOption extends OrderAndGroupOption {
|
127
|
+
/**
|
128
|
+
* @summary filter the records by a condition
|
129
|
+
*
|
130
|
+
* @param {Condition} condition
|
131
|
+
* @method
|
132
|
+
*/
|
133
|
+
where(condition: Condition): OrderAndGroupOption;
|
134
|
+
}
|
135
|
+
/**
|
136
|
+
* @summary From Option Interface
|
137
|
+
* @description Exposes the FROM method and remaining options
|
138
|
+
*
|
139
|
+
* @interface FromOption
|
140
|
+
*
|
141
|
+
* @category Query
|
142
|
+
* @subcategory Options
|
143
|
+
*/
|
144
|
+
export interface FromOption<M extends Model> {
|
145
|
+
/**
|
146
|
+
* @summary selects records from a table
|
147
|
+
*
|
148
|
+
* @param {Constructor} tableName
|
149
|
+
* @method
|
150
|
+
*/
|
151
|
+
from(tableName: Constructor<M> | string): WhereOption;
|
152
|
+
}
|
153
|
+
/**
|
154
|
+
* @summary Distinct Option Interface
|
155
|
+
* @description Exposes the remaining options after a DISTINCT
|
156
|
+
*
|
157
|
+
* @interface DistinctOption
|
158
|
+
* @extends FromOption
|
159
|
+
*
|
160
|
+
* @category Query
|
161
|
+
* @subcategory Options
|
162
|
+
*/
|
163
|
+
export interface DistinctOption<M extends Model> extends FromOption<M> {
|
164
|
+
}
|
165
|
+
/**
|
166
|
+
* @summary Max Option Interface
|
167
|
+
* @description Exposes the remaining options after a MAX
|
168
|
+
*
|
169
|
+
* @interface MaxOption
|
170
|
+
* @extends FromOption
|
171
|
+
*
|
172
|
+
* @category Query
|
173
|
+
* @subcategory Options
|
174
|
+
*/
|
175
|
+
export interface MaxOption<M extends Model> extends FromOption<M> {
|
176
|
+
}
|
177
|
+
/**
|
178
|
+
* @summary Min Option Interface
|
179
|
+
* @description Exposes the remaining options after a MIN
|
180
|
+
*
|
181
|
+
* @interface MinOption
|
182
|
+
* @extends FromOption
|
183
|
+
*
|
184
|
+
* @category Query
|
185
|
+
* @subcategory Options
|
186
|
+
*/
|
187
|
+
export interface MinOption<M extends Model> extends FromOption<M> {
|
188
|
+
}
|
189
|
+
/**
|
190
|
+
* @summary Count Option Interface
|
191
|
+
* @description Exposes the remaining options after a COUNT
|
192
|
+
*
|
193
|
+
* @interface CountOption
|
194
|
+
* @extends FromOption
|
195
|
+
*
|
196
|
+
* @category Query
|
197
|
+
* @subcategory Options
|
198
|
+
*/
|
199
|
+
export interface CountOption<M extends Model> extends FromOption<M> {
|
200
|
+
}
|
201
|
+
/**
|
202
|
+
* @summary Select Option Interface
|
203
|
+
* @description Exposes the remaining options after a SELECT
|
204
|
+
*
|
205
|
+
* @interface SelectOption
|
206
|
+
* @extends FromOption
|
207
|
+
*
|
208
|
+
* @category Query
|
209
|
+
* @subcategory Options
|
210
|
+
*/
|
211
|
+
export interface SelectOption<M extends Model> extends FromOption<M> {
|
212
|
+
/**
|
213
|
+
* @summary selects distinct values
|
214
|
+
*
|
215
|
+
* @param {SelectSelector} selector
|
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>;
|
240
|
+
}
|
241
|
+
/**
|
242
|
+
* @summary Into Option Interface
|
243
|
+
* @description Exposes the remaining options after an INTO
|
244
|
+
*
|
245
|
+
* @interface IntoOption
|
246
|
+
*
|
247
|
+
* @category Query
|
248
|
+
* @subcategory Options
|
249
|
+
*/
|
250
|
+
export interface IntoOption<M extends Model> {
|
251
|
+
/**
|
252
|
+
* @summary sets the models to insert
|
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;
|
265
|
+
}
|
266
|
+
/**
|
267
|
+
* @summary Valuest Option Interface
|
268
|
+
* @description Exposes the remaining options after a VALUES
|
269
|
+
*
|
270
|
+
* @interface ValuesOption
|
271
|
+
* @extends QueryBuilder
|
272
|
+
*
|
273
|
+
* @category Query
|
274
|
+
* @subcategory Options
|
275
|
+
*/
|
276
|
+
export interface ValuesOption extends Executor {
|
277
|
+
}
|
278
|
+
/**
|
279
|
+
* @summary Insert Option Interface
|
280
|
+
* @description Exposes the remaining options after an INSERT
|
281
|
+
*
|
282
|
+
* @interface InsertOption
|
283
|
+
*
|
284
|
+
* @category Query
|
285
|
+
* @subcategory Options
|
286
|
+
*/
|
287
|
+
export interface InsertOption<M extends Model> {
|
288
|
+
/**
|
289
|
+
* @summary selects the table to insert records into
|
290
|
+
*
|
291
|
+
* @param {string | Constructor} table
|
292
|
+
* @method
|
293
|
+
*/
|
294
|
+
into(table: Constructor<M>): IntoOption<M>;
|
295
|
+
}
|
296
|
+
/**
|
297
|
+
* @summary {@link Operator} Option Interface
|
298
|
+
* @description Exposes the available operators for a {@link Condition}
|
299
|
+
*
|
300
|
+
* @interface AttributeOption
|
301
|
+
*
|
302
|
+
* @category Query
|
303
|
+
* @subcategory Conditions
|
304
|
+
*/
|
305
|
+
export interface AttributeOption {
|
306
|
+
/**
|
307
|
+
* @summary Test equality
|
308
|
+
*
|
309
|
+
* @param {any} val the value to test
|
310
|
+
* @method
|
311
|
+
*/
|
312
|
+
eq(val: any): Condition;
|
313
|
+
/**
|
314
|
+
* @summary Test difference
|
315
|
+
*
|
316
|
+
* @param {any} val the value to test
|
317
|
+
* @method
|
318
|
+
*/
|
319
|
+
dif(val: any): Condition;
|
320
|
+
/**
|
321
|
+
* @summary Test greater than
|
322
|
+
*
|
323
|
+
* @param {any} val the value to test
|
324
|
+
* @method
|
325
|
+
*/
|
326
|
+
gt(val: any): Condition;
|
327
|
+
/**
|
328
|
+
* @summary Test lower than
|
329
|
+
*
|
330
|
+
* @param {any} val the value to test
|
331
|
+
* @method
|
332
|
+
*/
|
333
|
+
lt(val: any): Condition;
|
334
|
+
/**
|
335
|
+
* @summary Test greater or equal to
|
336
|
+
*
|
337
|
+
* @param {any} val the value to test
|
338
|
+
* @method
|
339
|
+
*/
|
340
|
+
gte(val: any): Condition;
|
341
|
+
/**
|
342
|
+
* @summary Test lower or equal to
|
343
|
+
*
|
344
|
+
* @param {any} val the value to test
|
345
|
+
* @method
|
346
|
+
*/
|
347
|
+
lte(val: any): Condition;
|
348
|
+
/**
|
349
|
+
* @summary Test value in a range of values
|
350
|
+
* @param {any[]} val
|
351
|
+
*/
|
352
|
+
in(val: any[]): Condition;
|
353
|
+
/**
|
354
|
+
* @summary Test matches {@link RegExp}
|
355
|
+
*
|
356
|
+
* @param {any} val the value to test
|
357
|
+
* @method
|
358
|
+
*/
|
359
|
+
regexp(val: string | RegExp): Condition;
|
360
|
+
}
|
361
|
+
/**
|
362
|
+
* @summary The starting point for creating Conditions
|
363
|
+
* @description Exposes the available operations for a {@link Condition}
|
364
|
+
*
|
365
|
+
* @interface ConditionBuilderOption
|
366
|
+
*
|
367
|
+
* @category Query
|
368
|
+
* @subcategory Conditions
|
369
|
+
*/
|
370
|
+
export interface ConditionBuilderOption {
|
371
|
+
attribute(attr: string): AttributeOption;
|
372
|
+
}
|
package/lib/query/selectors.cjs
CHANGED
@@ -1,4 +1,3 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
|
4
|
-
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9xdWVyeS9zZWxlY3RvcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJxdWVyeS9zZWxlY3RvcnMuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBPcmRlckRpcmVjdGlvbiB9IGZyb20gXCIuLi9yZXBvc2l0b3J5XCI7XG5pbXBvcnQgeyBDb25zdHJ1Y3RvciwgTW9kZWwgfSBmcm9tIFwiQGRlY2FmLXRzL2RlY29yYXRvci12YWxpZGF0aW9uXCI7XG5cbi8qKlxuICogQHR5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HR5cGUgU2VsZWN0RnVuY3Rpb248VCA9IGFueT4gPSAob2JqOiBUKSA9PiBUIHwgYW55O1xuLyoqXG4gKiBAdHlwZWRlZiBTZWxlY3RTZWxlY3RvclxuICpcbiAqIEBjYXRlZ29yeSBDbGF1c2VzXG4gKi9cbmV4cG9ydCB0eXBlIFNlbGVjdFNlbGVjdG9yID0gc3RyaW5nIHwgc3RyaW5nW107XG4iXX0=
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { OrderDirection } from "../repository";
|
2
|
+
import { Constructor, Model } from "@decaf-ts/decorator-validation";
|
3
|
+
/**
|
4
|
+
* @typedef FromSelector
|
5
|
+
*
|
6
|
+
* @category Clauses
|
7
|
+
*/
|
8
|
+
export type FromSelector<M extends Model> = Constructor<M> | string;
|
9
|
+
/**
|
10
|
+
* @typedef GroupBySelector
|
11
|
+
*
|
12
|
+
* @category Clauses
|
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
|
25
|
+
*/
|
26
|
+
export type LimitSelector = number;
|
27
|
+
/**
|
28
|
+
* @typedef OffsetSelector
|
29
|
+
*
|
30
|
+
* @category Clauses
|
31
|
+
*/
|
32
|
+
export type OffsetSelector = number;
|
33
|
+
/**
|
34
|
+
* @typedef SelectSelector
|
35
|
+
*
|
36
|
+
* @category Clauses
|
37
|
+
*/
|
38
|
+
export type SelectSelector = string | string[];
|
package/lib/query/types.cjs
CHANGED
@@ -1,4 +1,3 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
|
4
|
-
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9xdWVyeS90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwiZmlsZSI6InF1ZXJ5L3R5cGVzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHR5cGUgQXR0cmlidXRlUmVzdWx0ID0gUmVjb3JkPHN0cmluZywgc3RyaW5nPjtcblxuZXhwb3J0IHR5cGUgT3BlcmF0aW9uUmVzdWx0ID0gUmVjb3JkPHN0cmluZywgQXR0cmlidXRlUmVzdWx0IHwgYW55PjtcbiJdfQ==
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcXVlcnkvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCB0eXBlIEF0dHJpYnV0ZVJlc3VsdCA9IFJlY29yZDxzdHJpbmcsIHN0cmluZz47XG5cbmV4cG9ydCB0eXBlIE9wZXJhdGlvblJlc3VsdCA9IFJlY29yZDxzdHJpbmcsIEF0dHJpYnV0ZVJlc3VsdCB8IGFueT47XG4iXX0=
|
@@ -13,5 +13,4 @@ class Context extends db_decorators_1.Context {
|
|
13
13
|
}
|
14
14
|
}
|
15
15
|
exports.Context = Context;
|
16
|
-
|
17
|
-
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9yZXBvc2l0b3J5L0NvbnRleHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsMkRBQXlEO0FBS3pELE1BQXNCLE9BR3BCLFNBQVEsdUJBQU07SUFHZCxZQUNFLFNBQXdCLEVBQ3hCLEtBQXNCLEVBQ3RCLE1BQTBCO1FBRTFCLEtBQUssQ0FBQyxTQUFTLEVBQUUsS0FBSyxFQUFFLE1BQU0sQ0FB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FwiLi4vbW9kZWxcIjtcblxuZXhwb3J0IGFic3RyYWN0IGNsYXNzIENvbnRleHQ8XG4gIE0gZXh0ZW5kcyBNb2RlbCxcbiAgVSBleHRlbmRzIFVzZXIgPSBVc2VyLFxuPiBleHRlbmRzIEN0eDxNPiB7XG4gIHByb3RlY3RlZCBfdGltZXN0YW1wITogRGF0ZTtcblxuICBwcm90ZWN0ZWQgY29uc3RydWN0b3IoXG4gICAgb3BlcmF0aW9uOiBPcGVyYXRpb25LZXlzLFxuICAgIG1vZGVsPzogQ29uc3RydWN0b3I8TT4sXG4gICAgcGFyZW50PzogQ29udGV4dDxhbnksIGFueT5cbiAgKSB7XG4gICAgc3VwZXIob3BlcmF0aW9uLCBtb2RlbCwgcGFyZW50KTtcbiAgfVxuXG4gIG92ZXJyaWRlIGdldCB0aW1lc3RhbXAoKSB7XG4gICAgaWYgKCF0aGlzLl90aW1lc3RhbXApIHRoaXMuX3RpbWVzdGFtcCA9IG5ldyBEYXRlKCk7XG4gICAgcmV0dXJuIHRoaXMuX3RpbWVzdGFtcDtcbiAgfVxuXG4gIGFic3RyYWN0IGdldCB1c2VyKCk6IFUgfCB1bmRlZmluZWQ7XG59XG4iXX0=
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { Context as Ctx } from "@decaf-ts/db-decorators";
|
2
|
+
import { Constructor, Model } from "@decaf-ts/decorator-validation";
|
3
|
+
import { OperationKeys } from "@decaf-ts/db-decorators";
|
4
|
+
import { User } from "../model";
|
5
|
+
export declare abstract class Context<M extends Model, U extends User = User> extends Ctx<M> {
|
6
|
+
protected _timestamp: Date;
|
7
|
+
protected constructor(operation: OperationKeys, model?: Constructor<M>, parent?: Context<any, any>);
|
8
|
+
get timestamp(): Date;
|
9
|
+
abstract get user(): U | undefined;
|
10
|
+
}
|