velocious 1.0.460 → 1.0.462

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 (367) hide show
  1. package/README.md +1 -1
  2. package/build/application.js +1 -3
  3. package/build/background-jobs/cron-expression.js +1 -3
  4. package/build/background-jobs/forked-runner-child.js +1 -3
  5. package/build/background-jobs/job.js +1 -3
  6. package/build/background-jobs/scheduler.js +2 -6
  7. package/build/background-jobs/store.js +2 -6
  8. package/build/background-jobs/web/controller.js +1 -3
  9. package/build/background-jobs/worker.js +1 -3
  10. package/build/beacon/client.js +2 -6
  11. package/build/cli/tenant-database-command-helper.js +1 -3
  12. package/build/configuration.js +29 -32
  13. package/build/controller.js +4 -14
  14. package/build/current.js +2 -2
  15. package/build/database/drivers/mssql/index.js +1 -3
  16. package/build/database/drivers/mysql/index.js +2 -6
  17. package/build/database/drivers/pgsql/index.js +1 -3
  18. package/build/database/drivers/sqlite/base.js +3 -9
  19. package/build/database/drivers/sqlite/index.js +3 -9
  20. package/build/database/drivers/sqlite/table.js +1 -3
  21. package/build/database/migrator.js +1 -3
  22. package/build/database/pool/async-tracked-multi-connection.js +20 -45
  23. package/build/database/pool/base-methods-forward.js +2 -10
  24. package/build/database/pool/base.js +5 -15
  25. package/build/database/query/index.js +4 -12
  26. package/build/database/query/join-object.js +3 -9
  27. package/build/database/query/model-class-query.js +21 -63
  28. package/build/database/query/preloader/belongs-to.js +9 -27
  29. package/build/database/query/preloader/has-many.js +7 -21
  30. package/build/database/query/preloader/has-one.js +3 -9
  31. package/build/database/query/preloader.js +6 -18
  32. package/build/database/query/query-data.js +5 -15
  33. package/build/database/query/where-model-class-hash.js +5 -15
  34. package/build/database/query/with-count.js +5 -15
  35. package/build/database/record/acts-as-list.js +10 -38
  36. package/build/database/record/attachments/normalize-input.js +7 -25
  37. package/build/database/record/attachments/storage-drivers/s3.js +4 -12
  38. package/build/database/record/attachments/store.js +2 -6
  39. package/build/database/record/index.js +56 -172
  40. package/build/database/record/instance-relationships/base.js +6 -20
  41. package/build/database/record/instance-relationships/belongs-to.js +2 -6
  42. package/build/database/record/instance-relationships/has-many.js +4 -12
  43. package/build/database/record/instance-relationships/has-one.js +4 -12
  44. package/build/database/record/relationships/base.js +1 -5
  45. package/build/database/record/validators/presence.js +1 -3
  46. package/build/database/record/validators/uniqueness.js +4 -12
  47. package/build/environment-handlers/browser.js +1 -3
  48. package/build/environment-handlers/node/cli/commands/console.js +2 -6
  49. package/build/environment-handlers/node/cli/commands/db/schema/load.js +1 -3
  50. package/build/environment-handlers/node/cli/commands/generate/frontend-models.js +67 -11
  51. package/build/environment-handlers/node.js +15 -6
  52. package/build/frontend-model-controller.js +34 -110
  53. package/build/frontend-models/base.js +45 -151
  54. package/build/frontend-models/clear-pending-debounced-callback.js +1 -3
  55. package/build/frontend-models/preloader.js +3 -9
  56. package/build/frontend-models/query.js +11 -33
  57. package/build/frontend-models/resource-definition.js +2 -6
  58. package/build/frontend-models/transport-serialization.js +7 -21
  59. package/build/frontend-models/use-destroyed-event.js +2 -6
  60. package/build/frontend-models/use-model-class-event.js +2 -6
  61. package/build/frontend-models/use-updated-event.js +3 -9
  62. package/build/frontend-models/websocket-channel.js +9 -27
  63. package/build/frontend-models/websocket-publishers.js +12 -23
  64. package/build/http-server/client/index.js +6 -18
  65. package/build/http-server/client/params-to-object.js +6 -18
  66. package/build/http-server/client/request-buffer/index.js +1 -3
  67. package/build/http-server/client/request-parser.js +1 -3
  68. package/build/http-server/client/request-runner.js +4 -12
  69. package/build/http-server/client/websocket-session.js +6 -18
  70. package/build/http-server/development-reloader.js +2 -6
  71. package/build/http-server/remote-address.js +1 -5
  72. package/build/http-server/server-client.js +3 -9
  73. package/build/http-server/server-lock.js +2 -6
  74. package/build/http-server/websocket-channel-subscribers.js +2 -6
  75. package/build/http-server/websocket-event-log-store.js +5 -15
  76. package/build/http-server/websocket-events-host.js +1 -3
  77. package/build/http-server/worker-handler/in-process.js +3 -11
  78. package/build/http-server/worker-handler/worker-thread.js +1 -3
  79. package/build/logger.js +2 -6
  80. package/build/mailer/backends/smtp.js +1 -5
  81. package/build/mailer/base.js +4 -16
  82. package/build/plugins/sqljs-wasm-route-controller.js +1 -3
  83. package/build/routes/basic-route.js +1 -3
  84. package/build/routes/resolver.js +4 -14
  85. package/build/src/application.d.ts.map +1 -1
  86. package/build/src/application.js +2 -4
  87. package/build/src/background-jobs/cron-expression.d.ts.map +1 -1
  88. package/build/src/background-jobs/cron-expression.js +2 -4
  89. package/build/src/background-jobs/forked-runner-child.js +2 -4
  90. package/build/src/background-jobs/job.d.ts.map +1 -1
  91. package/build/src/background-jobs/job.js +2 -4
  92. package/build/src/background-jobs/scheduler.d.ts.map +1 -1
  93. package/build/src/background-jobs/scheduler.js +3 -7
  94. package/build/src/background-jobs/store.d.ts.map +1 -1
  95. package/build/src/background-jobs/store.js +3 -7
  96. package/build/src/background-jobs/web/controller.d.ts.map +1 -1
  97. package/build/src/background-jobs/web/controller.js +2 -5
  98. package/build/src/background-jobs/worker.d.ts.map +1 -1
  99. package/build/src/background-jobs/worker.js +2 -4
  100. package/build/src/beacon/client.d.ts.map +1 -1
  101. package/build/src/beacon/client.js +3 -7
  102. package/build/src/cli/tenant-database-command-helper.d.ts.map +1 -1
  103. package/build/src/cli/tenant-database-command-helper.js +2 -4
  104. package/build/src/configuration.d.ts.map +1 -1
  105. package/build/src/configuration.js +27 -35
  106. package/build/src/controller.d.ts.map +1 -1
  107. package/build/src/controller.js +5 -15
  108. package/build/src/current.d.ts +4 -4
  109. package/build/src/current.d.ts.map +1 -1
  110. package/build/src/current.js +3 -3
  111. package/build/src/database/drivers/mssql/index.d.ts.map +1 -1
  112. package/build/src/database/drivers/mssql/index.js +2 -4
  113. package/build/src/database/drivers/mysql/index.d.ts.map +1 -1
  114. package/build/src/database/drivers/mysql/index.js +3 -7
  115. package/build/src/database/drivers/pgsql/index.d.ts.map +1 -1
  116. package/build/src/database/drivers/pgsql/index.js +2 -4
  117. package/build/src/database/drivers/sqlite/base.d.ts.map +1 -1
  118. package/build/src/database/drivers/sqlite/base.js +4 -10
  119. package/build/src/database/drivers/sqlite/index.d.ts.map +1 -1
  120. package/build/src/database/drivers/sqlite/index.js +4 -10
  121. package/build/src/database/drivers/sqlite/table.d.ts.map +1 -1
  122. package/build/src/database/drivers/sqlite/table.js +2 -4
  123. package/build/src/database/migrator.d.ts.map +1 -1
  124. package/build/src/database/migrator.js +2 -4
  125. package/build/src/database/pool/async-tracked-multi-connection.d.ts.map +1 -1
  126. package/build/src/database/pool/async-tracked-multi-connection.js +21 -47
  127. package/build/src/database/pool/base-methods-forward.d.ts.map +1 -1
  128. package/build/src/database/pool/base-methods-forward.js +3 -11
  129. package/build/src/database/pool/base.d.ts.map +1 -1
  130. package/build/src/database/pool/base.js +6 -16
  131. package/build/src/database/query/index.d.ts.map +1 -1
  132. package/build/src/database/query/index.js +5 -13
  133. package/build/src/database/query/join-object.d.ts.map +1 -1
  134. package/build/src/database/query/join-object.js +4 -10
  135. package/build/src/database/query/model-class-query.d.ts.map +1 -1
  136. package/build/src/database/query/model-class-query.js +22 -64
  137. package/build/src/database/query/preloader/belongs-to.d.ts.map +1 -1
  138. package/build/src/database/query/preloader/belongs-to.js +10 -28
  139. package/build/src/database/query/preloader/has-many.d.ts.map +1 -1
  140. package/build/src/database/query/preloader/has-many.js +8 -22
  141. package/build/src/database/query/preloader/has-one.d.ts.map +1 -1
  142. package/build/src/database/query/preloader/has-one.js +4 -10
  143. package/build/src/database/query/preloader.d.ts.map +1 -1
  144. package/build/src/database/query/preloader.js +7 -20
  145. package/build/src/database/query/query-data.d.ts.map +1 -1
  146. package/build/src/database/query/query-data.js +6 -16
  147. package/build/src/database/query/where-model-class-hash.d.ts.map +1 -1
  148. package/build/src/database/query/where-model-class-hash.js +6 -16
  149. package/build/src/database/query/with-count.d.ts.map +1 -1
  150. package/build/src/database/query/with-count.js +6 -17
  151. package/build/src/database/record/acts-as-list.d.ts.map +1 -1
  152. package/build/src/database/record/acts-as-list.js +11 -47
  153. package/build/src/database/record/attachments/normalize-input.d.ts.map +1 -1
  154. package/build/src/database/record/attachments/normalize-input.js +8 -30
  155. package/build/src/database/record/attachments/storage-drivers/s3.d.ts.map +1 -1
  156. package/build/src/database/record/attachments/storage-drivers/s3.js +5 -13
  157. package/build/src/database/record/attachments/store.d.ts.map +1 -1
  158. package/build/src/database/record/attachments/store.js +3 -7
  159. package/build/src/database/record/index.d.ts +6 -11
  160. package/build/src/database/record/index.d.ts.map +1 -1
  161. package/build/src/database/record/index.js +54 -174
  162. package/build/src/database/record/instance-relationships/base.d.ts.map +1 -1
  163. package/build/src/database/record/instance-relationships/base.js +7 -21
  164. package/build/src/database/record/instance-relationships/belongs-to.d.ts.map +1 -1
  165. package/build/src/database/record/instance-relationships/belongs-to.js +3 -7
  166. package/build/src/database/record/instance-relationships/has-many.d.ts.map +1 -1
  167. package/build/src/database/record/instance-relationships/has-many.js +5 -13
  168. package/build/src/database/record/instance-relationships/has-one.d.ts.map +1 -1
  169. package/build/src/database/record/instance-relationships/has-one.js +5 -13
  170. package/build/src/database/record/relationships/base.d.ts.map +1 -1
  171. package/build/src/database/record/relationships/base.js +2 -6
  172. package/build/src/database/record/validators/presence.d.ts.map +1 -1
  173. package/build/src/database/record/validators/presence.js +2 -4
  174. package/build/src/database/record/validators/uniqueness.d.ts.map +1 -1
  175. package/build/src/database/record/validators/uniqueness.js +5 -14
  176. package/build/src/environment-handlers/browser.d.ts.map +1 -1
  177. package/build/src/environment-handlers/browser.js +2 -4
  178. package/build/src/environment-handlers/node/cli/commands/console.d.ts.map +1 -1
  179. package/build/src/environment-handlers/node/cli/commands/console.js +3 -7
  180. package/build/src/environment-handlers/node/cli/commands/db/schema/load.d.ts.map +1 -1
  181. package/build/src/environment-handlers/node/cli/commands/db/schema/load.js +2 -4
  182. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +38 -0
  183. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts.map +1 -1
  184. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.js +58 -12
  185. package/build/src/environment-handlers/node.d.ts.map +1 -1
  186. package/build/src/environment-handlers/node.js +16 -7
  187. package/build/src/frontend-model-controller.d.ts.map +1 -1
  188. package/build/src/frontend-model-controller.js +35 -114
  189. package/build/src/frontend-models/base.d.ts.map +1 -1
  190. package/build/src/frontend-models/base.js +46 -158
  191. package/build/src/frontend-models/clear-pending-debounced-callback.d.ts.map +1 -1
  192. package/build/src/frontend-models/clear-pending-debounced-callback.js +2 -4
  193. package/build/src/frontend-models/preloader.d.ts.map +1 -1
  194. package/build/src/frontend-models/preloader.js +4 -11
  195. package/build/src/frontend-models/query.d.ts.map +1 -1
  196. package/build/src/frontend-models/query.js +12 -34
  197. package/build/src/frontend-models/resource-definition.d.ts.map +1 -1
  198. package/build/src/frontend-models/resource-definition.js +3 -7
  199. package/build/src/frontend-models/transport-serialization.d.ts.map +1 -1
  200. package/build/src/frontend-models/transport-serialization.js +8 -23
  201. package/build/src/frontend-models/use-destroyed-event.js +3 -7
  202. package/build/src/frontend-models/use-model-class-event.d.ts.map +1 -1
  203. package/build/src/frontend-models/use-model-class-event.js +3 -7
  204. package/build/src/frontend-models/use-updated-event.d.ts.map +1 -1
  205. package/build/src/frontend-models/use-updated-event.js +4 -10
  206. package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
  207. package/build/src/frontend-models/websocket-channel.js +10 -32
  208. package/build/src/frontend-models/websocket-publishers.d.ts.map +1 -1
  209. package/build/src/frontend-models/websocket-publishers.js +14 -25
  210. package/build/src/http-server/client/index.d.ts.map +1 -1
  211. package/build/src/http-server/client/index.js +7 -21
  212. package/build/src/http-server/client/params-to-object.d.ts.map +1 -1
  213. package/build/src/http-server/client/params-to-object.js +7 -21
  214. package/build/src/http-server/client/request-buffer/index.d.ts.map +1 -1
  215. package/build/src/http-server/client/request-buffer/index.js +2 -4
  216. package/build/src/http-server/client/request-parser.d.ts.map +1 -1
  217. package/build/src/http-server/client/request-parser.js +2 -4
  218. package/build/src/http-server/client/request-runner.d.ts.map +1 -1
  219. package/build/src/http-server/client/request-runner.js +5 -14
  220. package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
  221. package/build/src/http-server/client/websocket-session.js +7 -20
  222. package/build/src/http-server/development-reloader.d.ts.map +1 -1
  223. package/build/src/http-server/development-reloader.js +3 -7
  224. package/build/src/http-server/remote-address.d.ts.map +1 -1
  225. package/build/src/http-server/remote-address.js +2 -6
  226. package/build/src/http-server/server-client.d.ts.map +1 -1
  227. package/build/src/http-server/server-client.js +4 -10
  228. package/build/src/http-server/server-lock.d.ts.map +1 -1
  229. package/build/src/http-server/server-lock.js +3 -7
  230. package/build/src/http-server/websocket-channel-subscribers.d.ts.map +1 -1
  231. package/build/src/http-server/websocket-channel-subscribers.js +3 -7
  232. package/build/src/http-server/websocket-event-log-store.d.ts.map +1 -1
  233. package/build/src/http-server/websocket-event-log-store.js +6 -16
  234. package/build/src/http-server/websocket-events-host.d.ts.map +1 -1
  235. package/build/src/http-server/websocket-events-host.js +2 -5
  236. package/build/src/http-server/worker-handler/in-process.d.ts.map +1 -1
  237. package/build/src/http-server/worker-handler/in-process.js +4 -12
  238. package/build/src/http-server/worker-handler/worker-thread.d.ts.map +1 -1
  239. package/build/src/http-server/worker-handler/worker-thread.js +2 -4
  240. package/build/src/logger.d.ts.map +1 -1
  241. package/build/src/logger.js +3 -7
  242. package/build/src/mailer/backends/smtp.d.ts.map +1 -1
  243. package/build/src/mailer/backends/smtp.js +2 -6
  244. package/build/src/mailer/base.d.ts.map +1 -1
  245. package/build/src/mailer/base.js +5 -17
  246. package/build/src/plugins/sqljs-wasm-route-controller.d.ts.map +1 -1
  247. package/build/src/plugins/sqljs-wasm-route-controller.js +2 -4
  248. package/build/src/routes/basic-route.d.ts.map +1 -1
  249. package/build/src/routes/basic-route.js +2 -4
  250. package/build/src/routes/resolver.d.ts.map +1 -1
  251. package/build/src/routes/resolver.js +5 -15
  252. package/build/src/testing/expect-utils.d.ts.map +1 -1
  253. package/build/src/testing/expect-utils.js +9 -27
  254. package/build/src/testing/expect.d.ts.map +1 -1
  255. package/build/src/testing/expect.js +5 -15
  256. package/build/src/testing/test-runner.d.ts.map +1 -1
  257. package/build/src/testing/test-runner.js +4 -10
  258. package/build/src/testing/test.d.ts.map +1 -1
  259. package/build/src/testing/test.js +5 -17
  260. package/build/src/utils/model-scope.d.ts.map +1 -1
  261. package/build/src/utils/model-scope.js +2 -5
  262. package/build/src/utils/ransack.d.ts.map +1 -1
  263. package/build/src/utils/ransack.js +15 -42
  264. package/build/src/utils/with-tracked-stack-async-hooks.d.ts.map +1 -1
  265. package/build/src/utils/with-tracked-stack-async-hooks.js +4 -12
  266. package/build/src/utils/with-tracked-stack.d.ts.map +1 -1
  267. package/build/src/utils/with-tracked-stack.js +3 -8
  268. package/build/testing/expect-utils.js +8 -26
  269. package/build/testing/expect.js +4 -14
  270. package/build/testing/test-runner.js +3 -9
  271. package/build/testing/test.js +4 -12
  272. package/build/utils/model-scope.js +1 -3
  273. package/build/utils/ransack.js +15 -41
  274. package/build/utils/with-tracked-stack-async-hooks.js +3 -9
  275. package/build/utils/with-tracked-stack.js +2 -6
  276. package/package.json +3 -2
  277. package/src/application.js +1 -3
  278. package/src/background-jobs/cron-expression.js +1 -3
  279. package/src/background-jobs/forked-runner-child.js +1 -3
  280. package/src/background-jobs/job.js +1 -3
  281. package/src/background-jobs/scheduler.js +2 -6
  282. package/src/background-jobs/store.js +2 -6
  283. package/src/background-jobs/web/controller.js +1 -3
  284. package/src/background-jobs/worker.js +1 -3
  285. package/src/beacon/client.js +2 -6
  286. package/src/cli/tenant-database-command-helper.js +1 -3
  287. package/src/configuration.js +29 -32
  288. package/src/controller.js +4 -14
  289. package/src/current.js +2 -2
  290. package/src/database/drivers/mssql/index.js +1 -3
  291. package/src/database/drivers/mysql/index.js +2 -6
  292. package/src/database/drivers/pgsql/index.js +1 -3
  293. package/src/database/drivers/sqlite/base.js +3 -9
  294. package/src/database/drivers/sqlite/index.js +3 -9
  295. package/src/database/drivers/sqlite/table.js +1 -3
  296. package/src/database/migrator.js +1 -3
  297. package/src/database/pool/async-tracked-multi-connection.js +20 -45
  298. package/src/database/pool/base-methods-forward.js +2 -10
  299. package/src/database/pool/base.js +5 -15
  300. package/src/database/query/index.js +4 -12
  301. package/src/database/query/join-object.js +3 -9
  302. package/src/database/query/model-class-query.js +21 -63
  303. package/src/database/query/preloader/belongs-to.js +9 -27
  304. package/src/database/query/preloader/has-many.js +7 -21
  305. package/src/database/query/preloader/has-one.js +3 -9
  306. package/src/database/query/preloader.js +6 -18
  307. package/src/database/query/query-data.js +5 -15
  308. package/src/database/query/where-model-class-hash.js +5 -15
  309. package/src/database/query/with-count.js +5 -15
  310. package/src/database/record/acts-as-list.js +10 -38
  311. package/src/database/record/attachments/normalize-input.js +7 -25
  312. package/src/database/record/attachments/storage-drivers/s3.js +4 -12
  313. package/src/database/record/attachments/store.js +2 -6
  314. package/src/database/record/index.js +56 -172
  315. package/src/database/record/instance-relationships/base.js +6 -20
  316. package/src/database/record/instance-relationships/belongs-to.js +2 -6
  317. package/src/database/record/instance-relationships/has-many.js +4 -12
  318. package/src/database/record/instance-relationships/has-one.js +4 -12
  319. package/src/database/record/relationships/base.js +1 -5
  320. package/src/database/record/validators/presence.js +1 -3
  321. package/src/database/record/validators/uniqueness.js +4 -12
  322. package/src/environment-handlers/browser.js +1 -3
  323. package/src/environment-handlers/node/cli/commands/console.js +2 -6
  324. package/src/environment-handlers/node/cli/commands/db/schema/load.js +1 -3
  325. package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +67 -11
  326. package/src/environment-handlers/node.js +15 -6
  327. package/src/frontend-model-controller.js +34 -110
  328. package/src/frontend-models/base.js +45 -151
  329. package/src/frontend-models/clear-pending-debounced-callback.js +1 -3
  330. package/src/frontend-models/preloader.js +3 -9
  331. package/src/frontend-models/query.js +11 -33
  332. package/src/frontend-models/resource-definition.js +2 -6
  333. package/src/frontend-models/transport-serialization.js +7 -21
  334. package/src/frontend-models/use-destroyed-event.js +2 -6
  335. package/src/frontend-models/use-model-class-event.js +2 -6
  336. package/src/frontend-models/use-updated-event.js +3 -9
  337. package/src/frontend-models/websocket-channel.js +9 -27
  338. package/src/frontend-models/websocket-publishers.js +12 -23
  339. package/src/http-server/client/index.js +6 -18
  340. package/src/http-server/client/params-to-object.js +6 -18
  341. package/src/http-server/client/request-buffer/index.js +1 -3
  342. package/src/http-server/client/request-parser.js +1 -3
  343. package/src/http-server/client/request-runner.js +4 -12
  344. package/src/http-server/client/websocket-session.js +6 -18
  345. package/src/http-server/development-reloader.js +2 -6
  346. package/src/http-server/remote-address.js +1 -5
  347. package/src/http-server/server-client.js +3 -9
  348. package/src/http-server/server-lock.js +2 -6
  349. package/src/http-server/websocket-channel-subscribers.js +2 -6
  350. package/src/http-server/websocket-event-log-store.js +5 -15
  351. package/src/http-server/websocket-events-host.js +1 -3
  352. package/src/http-server/worker-handler/in-process.js +3 -11
  353. package/src/http-server/worker-handler/worker-thread.js +1 -3
  354. package/src/logger.js +2 -6
  355. package/src/mailer/backends/smtp.js +1 -5
  356. package/src/mailer/base.js +4 -16
  357. package/src/plugins/sqljs-wasm-route-controller.js +1 -3
  358. package/src/routes/basic-route.js +1 -3
  359. package/src/routes/resolver.js +4 -14
  360. package/src/testing/expect-utils.js +8 -26
  361. package/src/testing/expect.js +4 -14
  362. package/src/testing/test-runner.js +3 -9
  363. package/src/testing/test.js +4 -12
  364. package/src/utils/model-scope.js +1 -3
  365. package/src/utils/ransack.js +15 -41
  366. package/src/utils/with-tracked-stack-async-hooks.js +3 -9
  367. package/src/utils/with-tracked-stack.js +2 -6
@@ -99,9 +99,12 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
99
99
  */
100
100
  constructor({configuration, identifier}) {
101
101
  super({configuration, identifier})
102
- this._withoutCurrentConnectionContext = /**
103
- * Narrows the runtime value to the documented type.
104
- * @type {(callback: () => ?) => ?} */ ((callback) => this.asyncLocalStorage.run(undefined, callback))
102
+ /**
103
+ * Runs a callback without the inherited current connection context.
104
+ * @type {(callback: () => ?) => ?}
105
+ */
106
+ const withoutCurrentConnectionContext = (callback) => this.asyncLocalStorage.run(undefined, callback)
107
+ this._withoutCurrentConnectionContext = withoutCurrentConnectionContext
105
108
  }
106
109
 
107
110
  /**
@@ -111,9 +114,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
111
114
  */
112
115
  async checkin(connection) {
113
116
  const id = connection.getIdSeq()
114
- const trackedConnection = /**
115
- * Narrows the runtime value to the documented type.
116
- * @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean, [CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
117
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean, [CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
117
118
 
118
119
  if (trackedConnection[CLOSED_CONNECTION]) {
119
120
  this.untrackConnectionInUse(connection, id)
@@ -243,9 +244,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
243
244
  * @returns {boolean} - Whether the connection matches the reuse key.
244
245
  */
245
246
  connectionMatchesReuseKey(connection, reuseKey) {
246
- const connectionWithPoolKey = /**
247
- * Narrows the runtime value to the documented type.
248
- * @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
247
+ const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
249
248
 
250
249
  return connectionWithPoolKey[POOL_CONFIGURATION_KEY] === reuseKey
251
250
  }
@@ -261,9 +260,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
261
260
 
262
261
  const id = this.idSeq++
263
262
 
264
- const trackedConnection = /**
265
- * Narrows the runtime value to the documented type.
266
- * @type {import("../drivers/base.js").default & {[CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
263
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
267
264
  delete trackedConnection[IDLE_CONNECTION_CHECKED_IN_AT]
268
265
  trackedConnection[CONNECTION_CHECKED_OUT_AT] = Date.now()
269
266
 
@@ -362,9 +359,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
362
359
 
363
360
  try {
364
361
  const connection = await this.spawnConnectionWithConfiguration(databaseConfig)
365
- const connectionWithPoolKey = /**
366
- * Narrows the runtime value to the documented type.
367
- * @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
362
+ const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
368
363
 
369
364
  connectionWithPoolKey[POOL_CONFIGURATION_KEY] = reuseKey
370
365
  connection.setSchemaCacheInvalidator(() => {
@@ -709,9 +704,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
709
704
  * @returns {void} - No return value.
710
705
  */
711
706
  setGlobalConnection(connection) {
712
- const klass = /**
713
- * Narrows the runtime value to the documented type.
714
- * @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
707
+ const klass = /** @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
715
708
  let mapForConfiguration = klass.globalConnections.get(this.configuration)
716
709
 
717
710
  if (!mapForConfiguration) {
@@ -816,9 +809,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
816
809
  */
817
810
  addInUseDebugConnectionSnapshots({connections, now, seenConnections}) {
818
811
  for (const [id, connection] of Object.entries(this.connectionsInUse)) {
819
- const trackedConnection = /**
820
- * Narrows the runtime value to the documented type.
821
- * @type {import("../drivers/base.js").default & {[CONNECTION_CHECKED_OUT_AT]?: number}} */ (connection)
812
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[CONNECTION_CHECKED_OUT_AT]?: number}} */ (connection)
822
813
  const checkedOutAt = trackedConnection[CONNECTION_CHECKED_OUT_AT]
823
814
  const checkedOutForMs = typeof checkedOutAt === "number" ? Math.max(0, now - checkedOutAt) : undefined
824
815
 
@@ -838,9 +829,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
838
829
 
839
830
  seenConnections.add(connection)
840
831
 
841
- const trackedConnection = /**
842
- * Narrows the runtime value to the documented type.
843
- * @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
832
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
844
833
  const checkedInAt = trackedConnection[IDLE_CONNECTION_CHECKED_IN_AT]
845
834
  const idleForMs = typeof checkedInAt === "number" ? Math.max(0, now - checkedInAt) : undefined
846
835
 
@@ -906,9 +895,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
906
895
  * @returns {import("../drivers/base.js").default | undefined} - The global connection for this pool identifier.
907
896
  */
908
897
  getGlobalConnectionForIdentifier() {
909
- const klass = /**
910
- * Narrows the runtime value to the documented type.
911
- * @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
898
+ const klass = /** @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
912
899
  const mapForConfiguration = klass.globalConnections.get(this.configuration)
913
900
 
914
901
  return mapForConfiguration?.[this.identifier]
@@ -919,9 +906,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
919
906
  * @returns {void} - No return value.
920
907
  */
921
908
  clearGlobalConnectionForIdentifier() {
922
- const klass = /**
923
- * Narrows the runtime value to the documented type.
924
- * @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
909
+ const klass = /** @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
925
910
  const mapForConfiguration = klass.globalConnections.get(this.configuration)
926
911
 
927
912
  if (!mapForConfiguration) return
@@ -975,9 +960,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
975
960
  if (this.idleConnectionReaperTimer) return
976
961
  if (!this.hasIdleConnectionsToReap()) return
977
962
 
978
- const delay = this.nextIdleConnectionReapDelay(/**
979
- * Narrows the runtime value to the documented type.
980
- * @type {number} */ (this.idleTimeoutMillis()))
963
+ const delay = this.nextIdleConnectionReapDelay(/** @type {number} */ (this.idleTimeoutMillis()))
981
964
 
982
965
  this.idleConnectionReaperTimer = setTimeout(() => {
983
966
  this.idleConnectionReaperTimer = undefined
@@ -1011,9 +994,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
1011
994
  for (const connection of this.connections) {
1012
995
  if (this.connectionHasOpenTransaction(connection)) continue
1013
996
 
1014
- const trackedConnection = /**
1015
- * Narrows the runtime value to the documented type.
1016
- * @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
997
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
1017
998
  const checkedInAt = trackedConnection[IDLE_CONNECTION_CHECKED_IN_AT]
1018
999
 
1019
1000
  if (typeof checkedInAt !== "number") continue
@@ -1109,9 +1090,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
1109
1090
  * @returns {boolean} - Whether the connection is marked closed.
1110
1091
  */
1111
1092
  connectionIsClosed(connection) {
1112
- const trackedConnection = /**
1113
- * Narrows the runtime value to the documented type.
1114
- * @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean}} */ (connection)
1093
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean}} */ (connection)
1115
1094
 
1116
1095
  return Boolean(trackedConnection[CLOSED_CONNECTION])
1117
1096
  }
@@ -1122,9 +1101,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
1122
1101
  * @returns {boolean} - Whether the idle connection expired.
1123
1102
  */
1124
1103
  idleConnectionExpired({connection, idleTimeoutMillis, now}) {
1125
- const trackedConnection = /**
1126
- * Narrows the runtime value to the documented type.
1127
- * @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
1104
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
1128
1105
  const checkedInAt = trackedConnection[IDLE_CONNECTION_CHECKED_IN_AT]
1129
1106
 
1130
1107
  return typeof checkedInAt === "number" && now - checkedInAt >= idleTimeoutMillis
@@ -1174,9 +1151,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
1174
1151
  return await existingClose
1175
1152
  }
1176
1153
 
1177
- const trackedConnection = /**
1178
- * Narrows the runtime value to the documented type.
1179
- * @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean, [CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
1154
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean, [CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
1180
1155
 
1181
1156
  trackedConnection[CLOSED_CONNECTION] = true
1182
1157
  delete trackedConnection[CONNECTION_CHECKED_OUT_AT]
@@ -28,20 +28,12 @@ export default function baseMethodsForward(PoolBase) {
28
28
  "updateSql"
29
29
  ]
30
30
 
31
- const prototype = /**
32
- * Narrows the runtime value to the documented type.
33
- * @type {Record<string, (...args: Array<?>) => ?>} */ (/**
34
- * Narrows the runtime value to the documented type.
35
- * @type {?} */ (PoolBase.prototype))
31
+ const prototype = /** @type {Record<string, (...args: Array<?>) => ?>} */ (/** @type {?} */ (PoolBase.prototype))
36
32
 
37
33
  for (const forwardMethod of forwardMethods) {
38
34
  prototype[forwardMethod] = function(...args) {
39
35
  const connection = this.getCurrentConnection()
40
- const connectionRecord = /**
41
- * Narrows the runtime value to the documented type.
42
- * @type {Record<string, (...args: Array<?>) => ?>} */ (/**
43
- * Narrows the runtime value to the documented type.
44
- * @type {?} */ (connection))
36
+ const connectionRecord = /** @type {Record<string, (...args: Array<?>) => ?>} */ (/** @type {?} */ (connection))
45
37
  const connectionMethod = connectionRecord[forwardMethod]
46
38
 
47
39
  if (!connectionMethod) throw new Error(`${forwardMethod} isn't defined on driver`)
@@ -58,13 +58,9 @@ function stableStringify(value) {
58
58
 
59
59
  if (value && typeof value === "object") {
60
60
  const entries = Object
61
- .keys(/**
62
- * Narrows the runtime value to the documented type.
63
- * @type {Record<string, ?>} */ (value))
61
+ .keys(/** @type {Record<string, ?>} */ (value))
64
62
  .sort()
65
- .map((key) => `${JSON.stringify(key)}:${stableStringify(/**
66
- * Narrows the runtime value to the documented type.
67
- * @type {Record<string, ?>} */ (value)[key])}`)
63
+ .map((key) => `${JSON.stringify(key)}:${stableStringify(/** @type {Record<string, ?>} */ (value)[key])}`)
68
64
 
69
65
  return `{${entries.join(",")}}`
70
66
  }
@@ -195,9 +191,7 @@ class VelociousDatabasePoolBase {
195
191
  * @returns {boolean} - Whether connection matches current resolved configuration.
196
192
  */
197
193
  connectionMatchesCurrentConfiguration(connection) {
198
- const connectionWithPoolKey = /**
199
- * Narrows the runtime value to the documented type.
200
- * @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
194
+ const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
201
195
 
202
196
  return connectionWithPoolKey[POOL_CONFIGURATION_KEY] === this.getConfigurationReuseKey()
203
197
  }
@@ -256,9 +250,7 @@ class VelociousDatabasePoolBase {
256
250
 
257
251
  const connection = await this.spawnConnectionWithConfiguration(databaseConfig)
258
252
 
259
- const connectionWithPoolKey = /**
260
- * Narrows the runtime value to the documented type.
261
- * @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
253
+ const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
262
254
  connectionWithPoolKey[POOL_CONFIGURATION_KEY] = this.getConfigurationReuseKey()
263
255
  connection.setSchemaCacheInvalidator(() => {
264
256
  this.clearSchemaCache()
@@ -371,9 +363,7 @@ class VelociousDatabasePoolBase {
371
363
  * @returns {Record<string, ?>} - Connection diagnostic snapshot.
372
364
  */
373
365
  debugConnectionSnapshot(connection, details = {}) {
374
- const connectionWithPoolKey = /**
375
- * Narrows the runtime value to the documented type.
376
- * @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
366
+ const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
377
367
 
378
368
  return {
379
369
  ...connection.getDebugSnapshot(),
@@ -188,9 +188,7 @@ export default class VelociousDatabaseQuery {
188
188
  * @type {import("./where-base.js").default[]} */
189
189
  this._wheres = wheres
190
190
 
191
- const boundWhere = /**
192
- * Narrows the runtime value to the documented type.
193
- * @type {?} */ (this.where.bind(this))
191
+ const boundWhere = /** @type {?} */ (this.where.bind(this))
194
192
  boundWhere.not = this.whereNot.bind(this)
195
193
  this.where = boundWhere
196
194
  }
@@ -200,9 +198,7 @@ export default class VelociousDatabaseQuery {
200
198
  * @returns {this} - The clone.
201
199
  */
202
200
  clone() {
203
- const QueryClass = /**
204
- * Narrows the runtime value to the documented type.
205
- * @type {new (args: QueryArgsType) => this} */ (this.constructor)
201
+ const QueryClass = /** @type {new (args: QueryArgsType) => this} */ (this.constructor)
206
202
  const newQuery = new QueryClass({
207
203
  driver: this._driverFn,
208
204
  froms: [...this._froms],
@@ -494,9 +490,7 @@ export default class VelociousDatabaseQuery {
494
490
  if (typeof where == "string") {
495
491
  this._wheres.push(new WherePlain(this, where))
496
492
  } else if (typeof where == "object" && (where.constructor.name == "object" || where.constructor.name == "Object")) {
497
- this._wheres.push(new WhereHash(this, /**
498
- * Narrows the runtime value to the documented type.
499
- * @type {import("./where-hash.js").WhereHash} */ (where)))
493
+ this._wheres.push(new WhereHash(this, /** @type {import("./where-hash.js").WhereHash} */ (where)))
500
494
  } else {
501
495
  throw new Error(`Invalid type of where: ${typeof where} (${where.constructor.name})`)
502
496
  }
@@ -513,9 +507,7 @@ export default class VelociousDatabaseQuery {
513
507
  if (typeof where == "string") {
514
508
  this._wheres.push(new WhereNot(new WherePlain(this, where)))
515
509
  } else if (typeof where == "object" && (where.constructor.name == "object" || where.constructor.name == "Object")) {
516
- this._wheres.push(new WhereNot(new WhereHash(this, /**
517
- * Narrows the runtime value to the documented type.
518
- * @type {import("./where-hash.js").WhereHash} */ (where))))
510
+ this._wheres.push(new WhereNot(new WhereHash(this, /** @type {import("./where-hash.js").WhereHash} */ (where))))
519
511
  } else {
520
512
  throw new Error(`Invalid type of where: ${typeof where} (${where.constructor.name})`)
521
513
  }
@@ -29,12 +29,8 @@ export default class VelociousDatabaseQueryJoinObject extends JoinBase {
29
29
  throw new Error(`Query has to be a ModelClassQuery but was a ${query.constructor.name}`)
30
30
  }
31
31
 
32
- const modelQuery = /**
33
- * Narrows the runtime value to the documented type.
34
- * @type {import("./model-class-query.js").default} */ (query)
35
- const ModelClass = /**
36
- * Narrows the runtime value to the documented type.
37
- * @type {typeof import("../record/index.js").default} */ (
32
+ const modelQuery = /** @type {import("./model-class-query.js").default} */ (query)
33
+ const ModelClass = /** @type {typeof import("../record/index.js").default} */ (
38
34
  this.basePath.length > 0 ? modelQuery._resolveModelClassForJoinPath(this.basePath) : modelQuery.modelClass
39
35
  )
40
36
 
@@ -53,9 +49,7 @@ export default class VelociousDatabaseQueryJoinObject extends JoinBase {
53
49
  joinObject(join, modelClass, sql, joinsCount, path) {
54
50
  const pretty = this.pretty
55
51
  const conn = this.getQuery().driver
56
- const query = /**
57
- * Narrows the runtime value to the documented type.
58
- * @type {import("./model-class-query.js").default} */ (this.getQuery())
52
+ const query = /** @type {import("./model-class-query.js").default} */ (this.getQuery())
59
53
 
60
54
  for (const joinKey in join) {
61
55
  const joinValue = join[joinKey]
@@ -216,9 +216,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
216
216
  * @returns {this} - The clone.
217
217
  */
218
218
  clone() {
219
- const newQuery = /**
220
- * Narrows the runtime value to the documented type.
221
- * @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (new VelociousDatabaseQueryModelClassQuery({
219
+ const newQuery = /** @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (new VelociousDatabaseQueryModelClassQuery({
222
220
  driver: this._driverFn,
223
221
  froms: [...this._froms],
224
222
  handler: this.handler.clone(),
@@ -338,9 +336,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
338
336
  countQuery._selects = []
339
337
  countQuery.select(sql)
340
338
 
341
- const results = /**
342
- * Narrows the runtime value to the documented type.
343
- * @type {{count: number}[]} */ (await countQuery._executeQuery({
339
+ const results = /** @type {{count: number}[]} */ (await countQuery._executeQuery({
344
340
  logName: countQuery.queryLogName("Count")
345
341
  }))
346
342
 
@@ -374,9 +370,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
374
370
  `SELECT ${countSql} AS ${this.driver.quoteColumn("count")}`,
375
371
  `FROM (${countQuery.toSql()}) AS ${this.driver.quoteTable("paginated_count_rows")}`
376
372
  ].join(" ")
377
- const results = /**
378
- * Narrows the runtime value to the documented type.
379
- * @type {{count: number}[]} */ (await this.driver.query(
373
+ const results = /** @type {{count: number}[]} */ (await this.driver.query(
380
374
  sql,
381
375
  {logName: this.queryLogName("Count")}
382
376
  ))
@@ -470,18 +464,12 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
470
464
  const froms = this.getFroms()
471
465
  const lastFrom = froms[froms.length - 1]
472
466
 
473
- if (lastFrom && typeof /**
474
- * Narrows the runtime value to the documented type.
475
- * @type {?} */ (lastFrom).tableName === "string") {
467
+ if (lastFrom && typeof /** @type {?} */ (lastFrom).tableName === "string") {
476
468
  return /** @type {?} */ (lastFrom).tableName
477
469
  }
478
470
 
479
- if (lastFrom && typeof /**
480
- * Narrows the runtime value to the documented type.
481
- * @type {?} */ (lastFrom).plain === "string") {
482
- const parsedReference = parseFromPlainTableReference(/**
483
- * Narrows the runtime value to the documented type.
484
- * @type {?} */ (lastFrom).plain)
471
+ if (lastFrom && typeof /** @type {?} */ (lastFrom).plain === "string") {
472
+ const parsedReference = parseFromPlainTableReference(/** @type {?} */ (lastFrom).plain)
485
473
 
486
474
  if (parsedReference) return parsedReference
487
475
  }
@@ -539,9 +527,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
539
527
  * @returns {VelociousDatabaseQueryModelClassQuery<MC>} - The scoped query.
540
528
  */
541
529
  withJoinPath(joinBasePath) {
542
- const scopedQuery = /**
543
- * Narrows the runtime value to the documented type.
544
- * @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
530
+ const scopedQuery = /** @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
545
531
 
546
532
  scopedQuery._joinBasePath = joinBasePath
547
533
  scopedQuery._joinTracker = this._joinTracker
@@ -638,9 +624,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
638
624
  }
639
625
 
640
626
  return this._applyJoinPathScope({
641
- joinPath: normalizeScopePath(/**
642
- * Narrows the runtime value to the documented type.
643
- * @type {string | string[]} */ (pathOrScopeDescriptor)),
627
+ joinPath: normalizeScopePath(/** @type {string | string[]} */ (pathOrScopeDescriptor)),
644
628
  scopeDescriptor: maybeScopeDescriptor
645
629
  })
646
630
  }
@@ -659,9 +643,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
659
643
  throw new Error(`Cannot apply ${scopeDescriptor.modelClass.name} scope to ${this.getModelClass().name} query`)
660
644
  }
661
645
 
662
- const scopedQuery = /**
663
- * Narrows the runtime value to the documented type.
664
- * @type {this | void} */ (scopeDescriptor.callback({
646
+ const scopedQuery = /** @type {this | void} */ (scopeDescriptor.callback({
665
647
  driver: this.driver,
666
648
  modelClass: this.getModelClass(),
667
649
  query: this,
@@ -693,9 +675,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
693
675
  const scopedQuery = this.buildJoinScopeQuery(targetModelClass, fullJoinPath)
694
676
  const originalJoinCount = scopedQuery._joins.length
695
677
  const originalWhereCount = scopedQuery._wheres.length
696
- const appliedQuery = /**
697
- * Narrows the runtime value to the documented type.
698
- * @type {typeof scopedQuery | void} */ (scopeDescriptor.callback({
678
+ const appliedQuery = /** @type {typeof scopedQuery | void} */ (scopeDescriptor.callback({
699
679
  driver: scopedQuery.driver,
700
680
  modelClass: targetModelClass,
701
681
  path: [...fullJoinPath],
@@ -742,9 +722,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
742
722
  * @returns {VelociousDatabaseQueryModelClassQuery<MC>} - The scoped join query.
743
723
  */
744
724
  buildJoinScopeQuery(targetModelClass, joinPath) {
745
- const scopedQuery = /**
746
- * Narrows the runtime value to the documented type.
747
- * @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (targetModelClass._newQuery())
725
+ const scopedQuery = /** @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (targetModelClass._newQuery())
748
726
 
749
727
  scopedQuery._joinTracker = this._joinTracker
750
728
  scopedQuery._joinBasePath = joinPath
@@ -817,9 +795,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
817
795
 
818
796
  conditions[this.getModelClass().primaryKey()] = recordId
819
797
 
820
- const newQuery = /**
821
- * Narrows the runtime value to the documented type.
822
- * @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
798
+ const newQuery = /** @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
823
799
 
824
800
  newQuery.where(conditions)
825
801
 
@@ -838,9 +814,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
838
814
  * @returns {Promise<InstanceType<MC> | null>} - Resolves with the by.
839
815
  */
840
816
  async findBy(conditions) {
841
- const newQuery = /**
842
- * Narrows the runtime value to the documented type.
843
- * @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
817
+ const newQuery = /** @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
844
818
 
845
819
  newQuery.where(conditions)
846
820
 
@@ -890,9 +864,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
890
864
  if (record) return record
891
865
 
892
866
  const ModelClass = this.getModelClass()
893
- const newRecord = /**
894
- * Narrows the runtime value to the documented type.
895
- * @type {InstanceType<MC>} */ (new ModelClass(conditions))
867
+ const newRecord = /** @type {InstanceType<MC>} */ (new ModelClass(conditions))
896
868
 
897
869
  if (callback) {
898
870
  callback(newRecord)
@@ -945,9 +917,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
945
917
 
946
918
  for (const result of results) {
947
919
  const ModelClass = this.getModelClass()
948
- const model = /**
949
- * Narrows the runtime value to the documented type.
950
- * @type {InstanceType<MC>} */ (new ModelClass())
920
+ const model = /** @type {InstanceType<MC>} */ (new ModelClass())
951
921
 
952
922
  model.loadExistingRecord(result)
953
923
  models.push(model)
@@ -1013,9 +983,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
1013
983
  const attributeMap = modelClass.getAttributeNameToColumnNameMap()
1014
984
  const columnNames = flatColumns.map((column) => attributeMap[column] || column)
1015
985
 
1016
- const query = /**
1017
- * Narrows the runtime value to the documented type.
1018
- * @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
986
+ const query = /** @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
1019
987
 
1020
988
  query._preload = {}
1021
989
  query._selects = []
@@ -1030,15 +998,11 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
1030
998
 
1031
999
  if (columnNames.length === 1) {
1032
1000
  const [columnName] = columnNames
1033
- return rows.map((row) => /**
1034
- * Narrows the runtime value to the documented type.
1035
- * @type {Record<string, ?>} */ (row)[columnName])
1001
+ return rows.map((row) => /** @type {Record<string, ?>} */ (row)[columnName])
1036
1002
  }
1037
1003
 
1038
1004
  return rows.map((row) => {
1039
- const rowHash = /**
1040
- * Narrows the runtime value to the documented type.
1041
- * @type {Record<string, ?>} */ (row)
1005
+ const rowHash = /** @type {Record<string, ?>} */ (row)
1042
1006
 
1043
1007
  return columnNames.map((columnName) => rowHash[columnName])
1044
1008
  })
@@ -1496,9 +1460,7 @@ function normalizeRelationshipWhereOperator(operator) {
1496
1460
  }
1497
1461
 
1498
1462
  return /** @type {"eq" | "notEq" | "gt" | "gteq" | "lt" | "lteq" | "like"} */ (
1499
- operatorAliases[/**
1500
- * Narrows the runtime value to the documented type.
1501
- * @type {"<" | "<=" | ">" | ">="} */ (operator)] || operator
1463
+ operatorAliases[/** @type {"<" | "<=" | ">" | ">="} */ (operator)] || operator
1502
1464
  )
1503
1465
  }
1504
1466
 
@@ -1537,9 +1499,7 @@ function normalizeRelationshipWhereOperatorTuples(value) {
1537
1499
  */
1538
1500
  const addCondition = (conditionValue) => {
1539
1501
  if (isRelationshipWhereOperatorTuple(conditionValue)) {
1540
- const tuple = /**
1541
- * Narrows the runtime value to the documented type.
1542
- * @type {[string, "eq" | "notEq" | "gt" | "gteq" | "lt" | "lteq" | "like" | ">" | ">=" | "<" | "<=", unknown, ...Array<unknown>]} */ (conditionValue)
1502
+ const tuple = /** @type {[string, "eq" | "notEq" | "gt" | "gteq" | "lt" | "lteq" | "like" | ">" | ">=" | "<" | "<=", unknown, ...Array<unknown>]} */ (conditionValue)
1543
1503
  const normalizedOperator = normalizeRelationshipWhereOperator(tuple[1])
1544
1504
 
1545
1505
  normalized.push([
@@ -1561,9 +1521,7 @@ function normalizeRelationshipWhereOperatorTuples(value) {
1561
1521
  throw new Error("Relationship where conditions must be tuples")
1562
1522
  }
1563
1523
 
1564
- /**
1565
- * Narrows the runtime value to the documented type.
1566
- * @type {Array<?>} */ (conditionValue).forEach((nestedConditionValue) => {
1524
+ /** @type {Array<?>} */ (conditionValue).forEach((nestedConditionValue) => {
1567
1525
  addCondition(nestedConditionValue)
1568
1526
  })
1569
1527
  }
@@ -46,9 +46,7 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
46
46
  const instanceRelationship = model.getRelationshipByName(relationshipName)
47
47
 
48
48
  if (this.selection.isSatisfied({instanceRelationship, targetModelClass, mappingColumns: [primaryKey]})) {
49
- const loaded = /**
50
- * Narrows the runtime value to the documented type.
51
- * @type {import("../../record/index.js").default | undefined} */ (instanceRelationship.getLoadedOrUndefined())
49
+ const loaded = /** @type {import("../../record/index.js").default | undefined} */ (instanceRelationship.getLoadedOrUndefined())
52
50
 
53
51
  if (loaded) satisfiedTargets.push(loaded)
54
52
  } else {
@@ -64,9 +62,7 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
64
62
  const foreignKeyValues = []
65
63
 
66
64
  for (const model of modelsToLoad) {
67
- const foreignKeyValue = /**
68
- * Narrows the runtime value to the documented type.
69
- * @type {string | number | null | undefined} */ (model.readColumn(foreignKey))
65
+ const foreignKeyValue = /** @type {string | number | null | undefined} */ (model.readColumn(foreignKey))
70
66
 
71
67
  // Skip null/undefined foreign keys: a belongsTo with no foreign key has no
72
68
  // target, and including them would serialize to e.g. `IN (null)` which
@@ -106,9 +102,7 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
106
102
  targetModels = await query.toArray()
107
103
 
108
104
  for (const targetModel of targetModels) {
109
- const primaryKeyValue = /**
110
- * Narrows the runtime value to the documented type.
111
- * @type {string | number} */ (targetModel.readColumn(primaryKey))
105
+ const primaryKeyValue = /** @type {string | number} */ (targetModel.readColumn(primaryKey))
112
106
 
113
107
  targetModelsById[primaryKeyValue] = targetModel
114
108
  }
@@ -116,9 +110,7 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
116
110
 
117
111
  // Set the target preloaded models on the given models
118
112
  for (const model of modelsToLoad) {
119
- const foreignKeyValue = /**
120
- * Narrows the runtime value to the documented type.
121
- * @type {string | number} */ (model.readColumn(foreignKey))
113
+ const foreignKeyValue = /** @type {string | number} */ (model.readColumn(foreignKey))
122
114
  const targetModel = targetModelsById[foreignKeyValue]
123
115
  const modelRelationship = model.getRelationshipByName(relationshipName)
124
116
 
@@ -158,23 +150,17 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
158
150
  const targetModelsByClassName = {}
159
151
 
160
152
  for (const model of this.models) {
161
- const targetType = /**
162
- * Narrows the runtime value to the documented type.
163
- * @type {string | undefined} */ (model.readColumn(typeColumn))
153
+ const targetType = /** @type {string | undefined} */ (model.readColumn(typeColumn))
164
154
  const instanceRelationship = model.getRelationshipByName(relationshipName)
165
155
  const targetModelClass = targetType ? configuration.getModelClass(targetType) : undefined
166
156
 
167
157
  if (targetModelClass && this.selection.isSatisfied({instanceRelationship, targetModelClass, mappingColumns: [primaryKey]})) {
168
- const loaded = /**
169
- * Narrows the runtime value to the documented type.
170
- * @type {import("../../record/index.js").default | undefined} */ (instanceRelationship.getLoadedOrUndefined())
158
+ const loaded = /** @type {import("../../record/index.js").default | undefined} */ (instanceRelationship.getLoadedOrUndefined())
171
159
 
172
160
  if (loaded) {
173
161
  satisfiedTargets.push(loaded)
174
162
 
175
- const className = /**
176
- * Narrows the runtime value to the documented type.
177
- * @type {typeof import("../../record/index.js").default} */ (loaded.constructor).getModelName()
163
+ const className = /** @type {typeof import("../../record/index.js").default} */ (loaded.constructor).getModelName()
178
164
 
179
165
  if (!targetModelsByClassName[className]) targetModelsByClassName[className] = []
180
166
  targetModelsByClassName[className].push(loaded)
@@ -184,9 +170,7 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
184
170
  }
185
171
 
186
172
  modelMeta.push({
187
- foreignKeyValue: /**
188
- * Narrows the runtime value to the documented type.
189
- * @type {string | number | undefined} */ (model.readColumn(foreignKey)),
173
+ foreignKeyValue: /** @type {string | number | undefined} */ (model.readColumn(foreignKey)),
190
174
  model,
191
175
  targetType
192
176
  })
@@ -244,9 +228,7 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
244
228
  targetModelsByTypeAndId[targetType] = {}
245
229
 
246
230
  for (const targetModel of foundTargetModels) {
247
- const primaryKeyValue = /**
248
- * Narrows the runtime value to the documented type.
249
- * @type {string | number} */ (targetModel.readColumn(primaryKey))
231
+ const primaryKeyValue = /** @type {string | number} */ (targetModel.readColumn(primaryKey))
250
232
 
251
233
  targetModelsByTypeAndId[targetType][primaryKeyValue] = targetModel
252
234
  }