@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.
Files changed (330) hide show
  1. package/LICENSE.md +21 -157
  2. package/README.md +652 -15
  3. package/dist/core.cjs +2638 -1085
  4. package/dist/core.esm.cjs +2636 -1070
  5. package/lib/esm/identity/decorators.d.ts +52 -14
  6. package/lib/esm/identity/decorators.js +54 -16
  7. package/lib/esm/identity/utils.d.ts +20 -1
  8. package/lib/esm/identity/utils.js +22 -2
  9. package/lib/esm/index.d.ts +11 -15
  10. package/lib/esm/index.js +17 -19
  11. package/lib/esm/interfaces/ErrorParser.d.ts +12 -0
  12. package/lib/esm/interfaces/ErrorParser.js +1 -1
  13. package/lib/esm/interfaces/Executor.d.ts +10 -13
  14. package/lib/esm/interfaces/Executor.js +1 -1
  15. package/lib/esm/interfaces/Observable.d.ts +20 -18
  16. package/lib/esm/interfaces/Observable.js +1 -1
  17. package/lib/esm/interfaces/Observer.d.ts +7 -8
  18. package/lib/esm/interfaces/Observer.js +1 -1
  19. package/lib/esm/interfaces/Paginatable.d.ts +18 -2
  20. package/lib/esm/interfaces/Paginatable.js +1 -1
  21. package/lib/esm/interfaces/Queriable.d.ts +44 -3
  22. package/lib/esm/interfaces/Queriable.js +1 -1
  23. package/lib/esm/interfaces/RawExecutor.d.ts +10 -13
  24. package/lib/esm/interfaces/RawExecutor.js +1 -1
  25. package/lib/esm/interfaces/SequenceOptions.d.ts +50 -5
  26. package/lib/esm/interfaces/SequenceOptions.js +19 -1
  27. package/lib/esm/interfaces/index.d.ts +0 -1
  28. package/lib/esm/interfaces/index.js +1 -2
  29. package/lib/esm/model/BaseModel.d.ts +31 -0
  30. package/lib/esm/model/BaseModel.js +24 -1
  31. package/lib/esm/model/construction.d.ts +442 -9
  32. package/lib/esm/model/construction.js +441 -2
  33. package/lib/esm/model/decorators.d.ts +166 -42
  34. package/lib/esm/model/decorators.js +161 -37
  35. package/lib/esm/model/index.js +1 -2
  36. package/lib/esm/model/types.d.ts +9 -0
  37. package/lib/esm/model/types.js +1 -1
  38. package/lib/esm/persistence/Adapter.d.ts +384 -40
  39. package/lib/esm/persistence/Adapter.js +415 -59
  40. package/lib/esm/persistence/Dispatch.d.ts +131 -0
  41. package/lib/esm/persistence/Dispatch.js +187 -0
  42. package/lib/esm/persistence/ObserverHandler.d.ts +109 -0
  43. package/lib/esm/persistence/ObserverHandler.js +137 -0
  44. package/lib/esm/persistence/Sequence.d.ts +89 -8
  45. package/lib/esm/persistence/Sequence.js +91 -1
  46. package/lib/esm/persistence/constants.d.ts +22 -5
  47. package/lib/esm/persistence/constants.js +23 -7
  48. package/lib/esm/persistence/decorators.d.ts +10 -0
  49. package/lib/esm/persistence/decorators.js +11 -1
  50. package/lib/esm/persistence/errors.d.ts +23 -3
  51. package/lib/esm/persistence/errors.js +25 -7
  52. package/lib/esm/persistence/index.d.ts +3 -0
  53. package/lib/esm/persistence/index.js +4 -1
  54. package/lib/esm/persistence/types.d.ts +21 -0
  55. package/lib/esm/persistence/types.js +2 -0
  56. package/lib/esm/query/Condition.d.ts +88 -44
  57. package/lib/esm/query/Condition.js +144 -62
  58. package/lib/esm/query/Paginator.d.ts +67 -10
  59. package/lib/esm/query/Paginator.js +64 -10
  60. package/lib/esm/query/Statement.d.ts +82 -47
  61. package/lib/esm/query/Statement.js +175 -122
  62. package/lib/esm/query/constants.d.ts +25 -64
  63. package/lib/esm/query/constants.js +26 -68
  64. package/lib/esm/query/errors.d.ts +14 -0
  65. package/lib/esm/query/errors.js +15 -1
  66. package/lib/esm/query/index.d.ts +0 -5
  67. package/lib/esm/query/index.js +1 -6
  68. package/lib/esm/query/options.d.ts +69 -178
  69. package/lib/esm/query/options.js +1 -1
  70. package/lib/esm/query/selectors.d.ts +20 -24
  71. package/lib/esm/query/selectors.js +1 -1
  72. package/lib/esm/ram/RamAdapter.d.ts +322 -20
  73. package/lib/esm/ram/RamAdapter.js +360 -140
  74. package/lib/esm/ram/RamContext.d.ts +16 -1
  75. package/lib/esm/ram/RamContext.js +18 -3
  76. package/lib/esm/ram/RamPaginator.d.ts +51 -6
  77. package/lib/esm/ram/RamPaginator.js +58 -6
  78. package/lib/esm/ram/RamSequence.d.ts +49 -24
  79. package/lib/esm/ram/RamSequence.js +52 -40
  80. package/lib/esm/ram/RamStatement.d.ts +84 -6
  81. package/lib/esm/ram/RamStatement.js +175 -6
  82. package/lib/esm/ram/constants.d.ts +9 -0
  83. package/lib/esm/ram/constants.js +10 -0
  84. package/lib/esm/ram/handlers.d.ts +25 -0
  85. package/lib/esm/ram/handlers.js +27 -0
  86. package/lib/esm/ram/index.d.ts +4 -4
  87. package/lib/esm/ram/index.js +9 -5
  88. package/lib/esm/ram/model/RamSequence.d.ts +21 -9
  89. package/lib/esm/ram/model/RamSequence.js +19 -1
  90. package/lib/esm/ram/types.d.ts +47 -5
  91. package/lib/esm/ram/types.js +1 -1
  92. package/lib/esm/repository/Repository.d.ts +381 -22
  93. package/lib/esm/repository/Repository.js +446 -43
  94. package/lib/esm/repository/constants.d.ts +23 -13
  95. package/lib/esm/repository/constants.js +24 -14
  96. package/lib/esm/repository/decorators.d.ts +27 -0
  97. package/lib/esm/repository/decorators.js +28 -1
  98. package/lib/esm/repository/errors.d.ts +12 -11
  99. package/lib/esm/repository/errors.js +13 -16
  100. package/lib/esm/repository/injectables.d.ts +18 -0
  101. package/lib/esm/repository/injectables.js +19 -1
  102. package/lib/esm/repository/types.d.ts +13 -1
  103. package/lib/esm/repository/types.js +1 -1
  104. package/lib/esm/repository/utils.d.ts +11 -0
  105. package/lib/esm/repository/utils.js +12 -1
  106. package/lib/esm/utils/decorators.d.ts +9 -0
  107. package/lib/esm/utils/decorators.js +19 -0
  108. package/lib/esm/utils/errors.d.ts +56 -0
  109. package/lib/esm/utils/errors.js +63 -0
  110. package/lib/esm/utils/index.d.ts +2 -0
  111. package/lib/esm/utils/index.js +3 -0
  112. package/lib/identity/decorators.cjs +54 -16
  113. package/lib/identity/decorators.d.ts +52 -14
  114. package/lib/identity/utils.cjs +22 -2
  115. package/lib/identity/utils.d.ts +20 -1
  116. package/lib/index.cjs +17 -19
  117. package/lib/index.d.ts +11 -15
  118. package/lib/interfaces/ErrorParser.cjs +1 -1
  119. package/lib/interfaces/ErrorParser.d.ts +12 -0
  120. package/lib/interfaces/Executor.cjs +1 -1
  121. package/lib/interfaces/Executor.d.ts +10 -13
  122. package/lib/interfaces/Observable.cjs +1 -1
  123. package/lib/interfaces/Observable.d.ts +20 -18
  124. package/lib/interfaces/Observer.cjs +1 -1
  125. package/lib/interfaces/Observer.d.ts +7 -8
  126. package/lib/interfaces/Paginatable.cjs +1 -1
  127. package/lib/interfaces/Paginatable.d.ts +18 -2
  128. package/lib/interfaces/Queriable.cjs +1 -1
  129. package/lib/interfaces/Queriable.d.ts +44 -3
  130. package/lib/interfaces/RawExecutor.cjs +1 -1
  131. package/lib/interfaces/RawExecutor.d.ts +10 -13
  132. package/lib/interfaces/SequenceOptions.cjs +19 -1
  133. package/lib/interfaces/SequenceOptions.d.ts +50 -5
  134. package/lib/interfaces/index.cjs +1 -2
  135. package/lib/interfaces/index.d.ts +0 -1
  136. package/lib/model/BaseModel.cjs +24 -1
  137. package/lib/model/BaseModel.d.ts +31 -0
  138. package/lib/model/construction.cjs +441 -2
  139. package/lib/model/construction.d.ts +442 -9
  140. package/lib/model/decorators.cjs +161 -37
  141. package/lib/model/decorators.d.ts +166 -42
  142. package/lib/model/index.cjs +1 -2
  143. package/lib/model/types.cjs +1 -1
  144. package/lib/model/types.d.ts +9 -0
  145. package/lib/persistence/Adapter.cjs +414 -58
  146. package/lib/persistence/Adapter.d.ts +384 -40
  147. package/lib/persistence/Dispatch.cjs +191 -0
  148. package/lib/persistence/Dispatch.d.ts +131 -0
  149. package/lib/persistence/ObserverHandler.cjs +141 -0
  150. package/lib/persistence/ObserverHandler.d.ts +109 -0
  151. package/lib/persistence/Sequence.cjs +91 -1
  152. package/lib/persistence/Sequence.d.ts +89 -8
  153. package/lib/persistence/constants.cjs +24 -8
  154. package/lib/persistence/constants.d.ts +22 -5
  155. package/lib/persistence/decorators.cjs +11 -1
  156. package/lib/persistence/decorators.d.ts +10 -0
  157. package/lib/persistence/errors.cjs +26 -9
  158. package/lib/persistence/errors.d.ts +23 -3
  159. package/lib/persistence/index.cjs +4 -1
  160. package/lib/persistence/index.d.ts +3 -0
  161. package/lib/persistence/types.cjs +3 -0
  162. package/lib/persistence/types.d.ts +21 -0
  163. package/lib/query/Condition.cjs +143 -61
  164. package/lib/query/Condition.d.ts +88 -44
  165. package/lib/query/Paginator.cjs +64 -10
  166. package/lib/query/Paginator.d.ts +67 -10
  167. package/lib/query/Statement.cjs +174 -121
  168. package/lib/query/Statement.d.ts +82 -47
  169. package/lib/query/constants.cjs +27 -69
  170. package/lib/query/constants.d.ts +25 -64
  171. package/lib/query/errors.cjs +15 -1
  172. package/lib/query/errors.d.ts +14 -0
  173. package/lib/query/index.cjs +1 -6
  174. package/lib/query/index.d.ts +0 -5
  175. package/lib/query/options.cjs +1 -1
  176. package/lib/query/options.d.ts +69 -178
  177. package/lib/query/selectors.cjs +1 -1
  178. package/lib/query/selectors.d.ts +20 -24
  179. package/lib/ram/RamAdapter.cjs +358 -172
  180. package/lib/ram/RamAdapter.d.ts +322 -20
  181. package/lib/ram/RamContext.cjs +18 -3
  182. package/lib/ram/RamContext.d.ts +16 -1
  183. package/lib/ram/RamPaginator.cjs +58 -6
  184. package/lib/ram/RamPaginator.d.ts +51 -6
  185. package/lib/ram/RamSequence.cjs +52 -41
  186. package/lib/ram/RamSequence.d.ts +49 -24
  187. package/lib/ram/RamStatement.cjs +175 -6
  188. package/lib/ram/RamStatement.d.ts +84 -6
  189. package/lib/ram/constants.cjs +13 -0
  190. package/lib/ram/constants.d.ts +9 -0
  191. package/lib/ram/handlers.cjs +30 -0
  192. package/lib/ram/handlers.d.ts +25 -0
  193. package/lib/ram/index.cjs +9 -5
  194. package/lib/ram/index.d.ts +4 -4
  195. package/lib/ram/model/RamSequence.cjs +19 -1
  196. package/lib/ram/model/RamSequence.d.ts +21 -9
  197. package/lib/ram/types.cjs +1 -1
  198. package/lib/ram/types.d.ts +47 -5
  199. package/lib/repository/Repository.cjs +445 -42
  200. package/lib/repository/Repository.d.ts +381 -22
  201. package/lib/repository/constants.cjs +24 -14
  202. package/lib/repository/constants.d.ts +23 -13
  203. package/lib/repository/decorators.cjs +28 -1
  204. package/lib/repository/decorators.d.ts +27 -0
  205. package/lib/repository/errors.cjs +14 -19
  206. package/lib/repository/errors.d.ts +12 -11
  207. package/lib/repository/injectables.cjs +19 -1
  208. package/lib/repository/injectables.d.ts +18 -0
  209. package/lib/repository/types.cjs +1 -1
  210. package/lib/repository/types.d.ts +13 -1
  211. package/lib/repository/utils.cjs +12 -1
  212. package/lib/repository/utils.d.ts +11 -0
  213. package/lib/utils/decorators.cjs +22 -0
  214. package/lib/utils/decorators.d.ts +9 -0
  215. package/lib/utils/errors.cjs +69 -0
  216. package/lib/utils/errors.d.ts +56 -0
  217. package/lib/{validators → utils}/index.cjs +2 -2
  218. package/lib/utils/index.d.ts +2 -0
  219. package/package.json +5 -5
  220. package/lib/esm/interfaces/Builder.d.ts +0 -16
  221. package/lib/esm/interfaces/Builder.js +0 -2
  222. package/lib/esm/model/IdentifiedBaseModel.d.ts +0 -7
  223. package/lib/esm/model/IdentifiedBaseModel.js +0 -25
  224. package/lib/esm/query/Clause.d.ts +0 -50
  225. package/lib/esm/query/Clause.js +0 -82
  226. package/lib/esm/query/ClauseFactory.d.ts +0 -71
  227. package/lib/esm/query/ClauseFactory.js +0 -6
  228. package/lib/esm/query/Query.d.ts +0 -43
  229. package/lib/esm/query/Query.js +0 -54
  230. package/lib/esm/query/clauses/FromClause.d.ts +0 -45
  231. package/lib/esm/query/clauses/FromClause.js +0 -59
  232. package/lib/esm/query/clauses/GroupByClause.d.ts +0 -21
  233. package/lib/esm/query/clauses/GroupByClause.js +0 -19
  234. package/lib/esm/query/clauses/InsertClause.d.ts +0 -37
  235. package/lib/esm/query/clauses/InsertClause.js +0 -55
  236. package/lib/esm/query/clauses/LimitClause.d.ts +0 -29
  237. package/lib/esm/query/clauses/LimitClause.js +0 -27
  238. package/lib/esm/query/clauses/OffsetClause.d.ts +0 -21
  239. package/lib/esm/query/clauses/OffsetClause.js +0 -19
  240. package/lib/esm/query/clauses/OrderByClause.d.ts +0 -37
  241. package/lib/esm/query/clauses/OrderByClause.js +0 -39
  242. package/lib/esm/query/clauses/SelectClause.d.ts +0 -47
  243. package/lib/esm/query/clauses/SelectClause.js +0 -62
  244. package/lib/esm/query/clauses/SelectorBasedClause.d.ts +0 -25
  245. package/lib/esm/query/clauses/SelectorBasedClause.js +0 -44
  246. package/lib/esm/query/clauses/ValuesClause.d.ts +0 -21
  247. package/lib/esm/query/clauses/ValuesClause.js +0 -36
  248. package/lib/esm/query/clauses/WhereClause.d.ts +0 -46
  249. package/lib/esm/query/clauses/WhereClause.js +0 -71
  250. package/lib/esm/query/clauses/index.d.ts +0 -10
  251. package/lib/esm/query/clauses/index.js +0 -11
  252. package/lib/esm/query/types.d.ts +0 -2
  253. package/lib/esm/query/types.js +0 -2
  254. package/lib/esm/ram/RamClauseFactory.d.ts +0 -17
  255. package/lib/esm/ram/RamClauseFactory.js +0 -92
  256. package/lib/esm/ram/clauses/FromClause.d.ts +0 -7
  257. package/lib/esm/ram/clauses/FromClause.js +0 -11
  258. package/lib/esm/ram/clauses/InsertClause.d.ts +0 -7
  259. package/lib/esm/ram/clauses/InsertClause.js +0 -13
  260. package/lib/esm/ram/clauses/OrderByClause.d.ts +0 -7
  261. package/lib/esm/ram/clauses/OrderByClause.js +0 -39
  262. package/lib/esm/ram/clauses/SelectClause.d.ts +0 -7
  263. package/lib/esm/ram/clauses/SelectClause.js +0 -16
  264. package/lib/esm/ram/clauses/ValuesClause.d.ts +0 -7
  265. package/lib/esm/ram/clauses/ValuesClause.js +0 -12
  266. package/lib/esm/ram/clauses/WhereClause.d.ts +0 -7
  267. package/lib/esm/ram/clauses/WhereClause.js +0 -11
  268. package/lib/esm/ram/clauses/index.d.ts +0 -6
  269. package/lib/esm/ram/clauses/index.js +0 -7
  270. package/lib/esm/validators/ClauseSequenceValidator.d.ts +0 -28
  271. package/lib/esm/validators/ClauseSequenceValidator.js +0 -95
  272. package/lib/esm/validators/decorators.d.ts +0 -10
  273. package/lib/esm/validators/decorators.js +0 -24
  274. package/lib/esm/validators/index.d.ts +0 -2
  275. package/lib/esm/validators/index.js +0 -3
  276. package/lib/interfaces/Builder.cjs +0 -3
  277. package/lib/interfaces/Builder.d.ts +0 -16
  278. package/lib/model/IdentifiedBaseModel.cjs +0 -29
  279. package/lib/model/IdentifiedBaseModel.d.ts +0 -7
  280. package/lib/query/Clause.cjs +0 -86
  281. package/lib/query/Clause.d.ts +0 -50
  282. package/lib/query/ClauseFactory.cjs +0 -10
  283. package/lib/query/ClauseFactory.d.ts +0 -71
  284. package/lib/query/Query.cjs +0 -58
  285. package/lib/query/Query.d.ts +0 -43
  286. package/lib/query/clauses/FromClause.cjs +0 -63
  287. package/lib/query/clauses/FromClause.d.ts +0 -45
  288. package/lib/query/clauses/GroupByClause.cjs +0 -23
  289. package/lib/query/clauses/GroupByClause.d.ts +0 -21
  290. package/lib/query/clauses/InsertClause.cjs +0 -59
  291. package/lib/query/clauses/InsertClause.d.ts +0 -37
  292. package/lib/query/clauses/LimitClause.cjs +0 -31
  293. package/lib/query/clauses/LimitClause.d.ts +0 -29
  294. package/lib/query/clauses/OffsetClause.cjs +0 -23
  295. package/lib/query/clauses/OffsetClause.d.ts +0 -21
  296. package/lib/query/clauses/OrderByClause.cjs +0 -43
  297. package/lib/query/clauses/OrderByClause.d.ts +0 -37
  298. package/lib/query/clauses/SelectClause.cjs +0 -66
  299. package/lib/query/clauses/SelectClause.d.ts +0 -47
  300. package/lib/query/clauses/SelectorBasedClause.cjs +0 -48
  301. package/lib/query/clauses/SelectorBasedClause.d.ts +0 -25
  302. package/lib/query/clauses/ValuesClause.cjs +0 -40
  303. package/lib/query/clauses/ValuesClause.d.ts +0 -21
  304. package/lib/query/clauses/WhereClause.cjs +0 -75
  305. package/lib/query/clauses/WhereClause.d.ts +0 -46
  306. package/lib/query/clauses/index.cjs +0 -27
  307. package/lib/query/clauses/index.d.ts +0 -10
  308. package/lib/query/types.cjs +0 -3
  309. package/lib/query/types.d.ts +0 -2
  310. package/lib/ram/RamClauseFactory.cjs +0 -96
  311. package/lib/ram/RamClauseFactory.d.ts +0 -17
  312. package/lib/ram/clauses/FromClause.cjs +0 -15
  313. package/lib/ram/clauses/FromClause.d.ts +0 -7
  314. package/lib/ram/clauses/InsertClause.cjs +0 -17
  315. package/lib/ram/clauses/InsertClause.d.ts +0 -7
  316. package/lib/ram/clauses/OrderByClause.cjs +0 -43
  317. package/lib/ram/clauses/OrderByClause.d.ts +0 -7
  318. package/lib/ram/clauses/SelectClause.cjs +0 -20
  319. package/lib/ram/clauses/SelectClause.d.ts +0 -7
  320. package/lib/ram/clauses/ValuesClause.cjs +0 -16
  321. package/lib/ram/clauses/ValuesClause.d.ts +0 -7
  322. package/lib/ram/clauses/WhereClause.cjs +0 -15
  323. package/lib/ram/clauses/WhereClause.d.ts +0 -7
  324. package/lib/ram/clauses/index.cjs +0 -23
  325. package/lib/ram/clauses/index.d.ts +0 -6
  326. package/lib/validators/ClauseSequenceValidator.cjs +0 -98
  327. package/lib/validators/ClauseSequenceValidator.d.ts +0 -28
  328. package/lib/validators/decorators.cjs +0 -27
  329. package/lib/validators/decorators.d.ts +0 -10
  330. package/lib/validators/index.d.ts +0 -2
@@ -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
- * @extends QueryBuilder
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
- * @extends QueryBuilder
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
- * @extends QueryBuilder
70
- *
71
- * @category Query
72
- * @subcategory Options
31
+ * @memberOf module:core
73
32
  */
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;
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 OrderpBy Option interface
37
+ * @summary OrderBy Option interface
85
38
  * @description Exposes the ORDER BY method and remaining options
86
39
  *
87
40
  * @interface OrderByOption
88
- * @extends QueryBuilder
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
- * @category Query
91
- * @subcategory Options
50
+ * @interface ThenByOption
51
+ * @memberOf module:core
92
52
  */
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;
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
- * @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>;
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
- * @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;
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
- * @extends QueryBuilder
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
- * @summary The starting point for creating Conditions
363
- * @description Exposes the available operations for a {@link Condition}
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: string): AttributeOption;
261
+ export interface ConditionBuilderOption<M extends Model> {
262
+ attribute(attr: keyof M): AttributeOption<M>;
372
263
  }
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsZWN0b3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3F1ZXJ5L3NlbGVjdG9ycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgT3JkZXJEaXJlY3Rpb24gfSBmcm9tIFwiLi4vcmVwb3NpdG9yeVwiO1xuaW1wb3J0IHsgQ29uc3RydWN0b3IsIE1vZGVsIH0gZnJvbSBcIkBkZWNhZi10cy9kZWNvcmF0b3ItdmFsaWRhdGlvblwiO1xuXG4vKipcbiAqIEB0eXBlZGVmIEZyb21TZWxlY3RvclxuICpcbiAqIEBjYXRlZ29yeSBDbGF1c2VzXG4gKi9cbmV4cG9ydCB0eXBlIEZyb21TZWxlY3RvcjxNIGV4dGVuZHMgTW9kZWw+ID0gQ29uc3RydWN0b3I8TT4gfCBzdHJpbmc7XG4vKipcbiAqIEB0eXBlZGVmIEdyb3VwQnlTZWxlY3RvclxuICpcbiAqIEBjYXRlZ29yeSBDbGF1c2VzXG4gKi9cbmV4cG9ydCB0eXBlIEdyb3VwQnlTZWxlY3RvciA9IHN0cmluZztcbi8qKlxuICogQHR5cGVkZWYgT3JkZXJCeVNlbGVjdG9yXG4gKlxuICogQGNhdGVnb3J5IENsYXVzZXNcbiAqL1xuZXhwb3J0IHR5cGUgT3JkZXJCeVNlbGVjdG9yID0gW3N0cmluZywgT3JkZXJEaXJlY3Rpb25dO1xuLyoqXG4gKiBAdHlwZWRlZiBMaW1pdFNlbGVjdG9yXG4gKlxuICogQGNhdGVnb3J5IENsYXVzZXNcbiAqL1xuZXh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ICogQGRlc2NyaXB0aW9uIFR5cGUgZm9yIHNlbGVjdGluZyBmaWVsZHMgaW4gYSBxdWVyeVxuICogQHN1bW1hcnkgRGVmaW5lcyB0aGUgdHlwZSBmb3Igc3BlY2lmeWluZyB3aGljaCBmaWVsZHMgdG8gc2VsZWN0IGZyb20gYSBtb2RlbFxuICogQHRlbXBsYXRlIE0gLSBUaGUgbW9kZWwgdHlwZSB0aGlzIHNlbGVjdG9yIG9wZXJhdGVzIG9uXG4gKiBAdHlwZWRlZiBTZWxlY3RTZWxlY3RvclxuICogQG1lbWJlck9mIG1vZHVsZTpjb3JlXG4gKi9cbmV4cG9ydCB0eXBlIFNlbGVjdFNlbGVjdG9yPE0gZXh0ZW5kcyBNb2RlbD4gPSBrZXlvZiBNO1xuIl19
@@ -1,38 +1,34 @@
1
1
  import { OrderDirection } from "../repository";
2
2
  import { Constructor, Model } from "@decaf-ts/decorator-validation";
3
3
  /**
4
- * @typedef FromSelector
5
- *
6
- * @category Clauses
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
- * @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
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
- * @typedef OffsetSelector
29
- *
30
- * @category Clauses
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 = string | string[];
34
+ export type SelectSelector<M extends Model> = keyof M;