velocious 1.0.461 → 1.0.463

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 (374) hide show
  1. package/build/application.js +1 -3
  2. package/build/background-jobs/cron-expression.js +1 -3
  3. package/build/background-jobs/forked-runner-child.js +1 -3
  4. package/build/background-jobs/job.js +1 -3
  5. package/build/background-jobs/scheduler.js +2 -6
  6. package/build/background-jobs/store.js +2 -6
  7. package/build/background-jobs/web/controller.js +1 -3
  8. package/build/background-jobs/worker.js +1 -3
  9. package/build/beacon/client.js +2 -6
  10. package/build/cli/tenant-database-command-helper.js +1 -3
  11. package/build/configuration.js +62 -40
  12. package/build/controller.js +4 -14
  13. package/build/database/drivers/mssql/index.js +1 -3
  14. package/build/database/drivers/mysql/index.js +2 -6
  15. package/build/database/drivers/pgsql/index.js +1 -3
  16. package/build/database/drivers/sqlite/base.js +3 -9
  17. package/build/database/drivers/sqlite/index.js +3 -9
  18. package/build/database/drivers/sqlite/table.js +1 -3
  19. package/build/database/migrator.js +1 -3
  20. package/build/database/pool/async-tracked-multi-connection.js +86 -46
  21. package/build/database/pool/base-methods-forward.js +2 -10
  22. package/build/database/pool/base.js +13 -15
  23. package/build/database/query/index.js +4 -12
  24. package/build/database/query/join-object.js +3 -9
  25. package/build/database/query/model-class-query.js +21 -63
  26. package/build/database/query/preloader/belongs-to.js +9 -27
  27. package/build/database/query/preloader/has-many.js +7 -21
  28. package/build/database/query/preloader/has-one.js +3 -9
  29. package/build/database/query/preloader.js +6 -18
  30. package/build/database/query/query-data.js +5 -15
  31. package/build/database/query/where-model-class-hash.js +5 -15
  32. package/build/database/query/with-count.js +5 -15
  33. package/build/database/record/acts-as-list.js +10 -38
  34. package/build/database/record/attachments/normalize-input.js +7 -25
  35. package/build/database/record/attachments/storage-drivers/s3.js +4 -12
  36. package/build/database/record/attachments/store.js +2 -6
  37. package/build/database/record/index.js +55 -171
  38. package/build/database/record/instance-relationships/base.js +6 -20
  39. package/build/database/record/instance-relationships/belongs-to.js +2 -6
  40. package/build/database/record/instance-relationships/has-many.js +4 -12
  41. package/build/database/record/instance-relationships/has-one.js +4 -12
  42. package/build/database/record/relationships/base.js +1 -5
  43. package/build/database/record/validators/presence.js +1 -3
  44. package/build/database/record/validators/uniqueness.js +4 -12
  45. package/build/environment-handlers/browser.js +1 -3
  46. package/build/environment-handlers/node/cli/commands/console.js +2 -6
  47. package/build/environment-handlers/node/cli/commands/db/schema/load.js +1 -3
  48. package/build/environment-handlers/node/cli/commands/generate/frontend-models.js +67 -11
  49. package/build/environment-handlers/node.js +15 -6
  50. package/build/frontend-model-controller.js +34 -110
  51. package/build/frontend-models/base.js +45 -151
  52. package/build/frontend-models/clear-pending-debounced-callback.js +1 -3
  53. package/build/frontend-models/preloader.js +3 -9
  54. package/build/frontend-models/query.js +11 -33
  55. package/build/frontend-models/resource-definition.js +2 -6
  56. package/build/frontend-models/transport-serialization.js +7 -21
  57. package/build/frontend-models/use-destroyed-event.js +2 -6
  58. package/build/frontend-models/use-model-class-event.js +2 -6
  59. package/build/frontend-models/use-updated-event.js +3 -9
  60. package/build/frontend-models/websocket-channel.js +9 -27
  61. package/build/frontend-models/websocket-publishers.js +12 -23
  62. package/build/http-server/client/index.js +7 -19
  63. package/build/http-server/client/params-to-object.js +6 -18
  64. package/build/http-server/client/request-buffer/index.js +1 -3
  65. package/build/http-server/client/request-parser.js +1 -3
  66. package/build/http-server/client/request-runner.js +5 -13
  67. package/build/http-server/client/websocket-session.js +6 -18
  68. package/build/http-server/development-reloader.js +2 -6
  69. package/build/http-server/remote-address.js +1 -5
  70. package/build/http-server/server-client.js +3 -9
  71. package/build/http-server/server-lock.js +2 -6
  72. package/build/http-server/websocket-channel-subscribers.js +2 -6
  73. package/build/http-server/websocket-event-log-store.js +5 -15
  74. package/build/http-server/websocket-events-host.js +1 -3
  75. package/build/http-server/worker-handler/in-process.js +3 -11
  76. package/build/http-server/worker-handler/index.js +3 -2
  77. package/build/http-server/worker-handler/worker-thread.js +1 -3
  78. package/build/logger.js +2 -6
  79. package/build/mailer/backends/smtp.js +1 -5
  80. package/build/mailer/base.js +4 -16
  81. package/build/plugins/sqljs-wasm-route-controller.js +1 -3
  82. package/build/routes/basic-route.js +1 -3
  83. package/build/routes/resolver.js +5 -15
  84. package/build/src/application.d.ts.map +1 -1
  85. package/build/src/application.js +2 -4
  86. package/build/src/background-jobs/cron-expression.d.ts.map +1 -1
  87. package/build/src/background-jobs/cron-expression.js +2 -4
  88. package/build/src/background-jobs/forked-runner-child.js +2 -4
  89. package/build/src/background-jobs/job.d.ts.map +1 -1
  90. package/build/src/background-jobs/job.js +2 -4
  91. package/build/src/background-jobs/scheduler.d.ts.map +1 -1
  92. package/build/src/background-jobs/scheduler.js +3 -7
  93. package/build/src/background-jobs/store.d.ts.map +1 -1
  94. package/build/src/background-jobs/store.js +3 -7
  95. package/build/src/background-jobs/web/controller.d.ts.map +1 -1
  96. package/build/src/background-jobs/web/controller.js +2 -5
  97. package/build/src/background-jobs/worker.d.ts.map +1 -1
  98. package/build/src/background-jobs/worker.js +2 -4
  99. package/build/src/beacon/client.d.ts.map +1 -1
  100. package/build/src/beacon/client.js +3 -7
  101. package/build/src/cli/tenant-database-command-helper.d.ts.map +1 -1
  102. package/build/src/cli/tenant-database-command-helper.js +2 -4
  103. package/build/src/configuration.d.ts +13 -0
  104. package/build/src/configuration.d.ts.map +1 -1
  105. package/build/src/configuration.js +58 -44
  106. package/build/src/controller.d.ts.map +1 -1
  107. package/build/src/controller.js +5 -15
  108. package/build/src/database/drivers/mssql/index.d.ts.map +1 -1
  109. package/build/src/database/drivers/mssql/index.js +2 -4
  110. package/build/src/database/drivers/mysql/index.d.ts.map +1 -1
  111. package/build/src/database/drivers/mysql/index.js +3 -7
  112. package/build/src/database/drivers/pgsql/index.d.ts.map +1 -1
  113. package/build/src/database/drivers/pgsql/index.js +2 -4
  114. package/build/src/database/drivers/sqlite/base.d.ts.map +1 -1
  115. package/build/src/database/drivers/sqlite/base.js +4 -10
  116. package/build/src/database/drivers/sqlite/index.d.ts.map +1 -1
  117. package/build/src/database/drivers/sqlite/index.js +4 -10
  118. package/build/src/database/drivers/sqlite/table.d.ts.map +1 -1
  119. package/build/src/database/drivers/sqlite/table.js +2 -4
  120. package/build/src/database/migrator.d.ts.map +1 -1
  121. package/build/src/database/migrator.js +2 -4
  122. package/build/src/database/pool/async-tracked-multi-connection.d.ts +18 -0
  123. package/build/src/database/pool/async-tracked-multi-connection.d.ts.map +1 -1
  124. package/build/src/database/pool/async-tracked-multi-connection.js +82 -48
  125. package/build/src/database/pool/base-methods-forward.d.ts.map +1 -1
  126. package/build/src/database/pool/base-methods-forward.js +3 -11
  127. package/build/src/database/pool/base.d.ts +5 -0
  128. package/build/src/database/pool/base.d.ts.map +1 -1
  129. package/build/src/database/pool/base.js +13 -16
  130. package/build/src/database/query/index.d.ts.map +1 -1
  131. package/build/src/database/query/index.js +5 -13
  132. package/build/src/database/query/join-object.d.ts.map +1 -1
  133. package/build/src/database/query/join-object.js +4 -10
  134. package/build/src/database/query/model-class-query.d.ts.map +1 -1
  135. package/build/src/database/query/model-class-query.js +22 -64
  136. package/build/src/database/query/preloader/belongs-to.d.ts.map +1 -1
  137. package/build/src/database/query/preloader/belongs-to.js +10 -28
  138. package/build/src/database/query/preloader/has-many.d.ts.map +1 -1
  139. package/build/src/database/query/preloader/has-many.js +8 -22
  140. package/build/src/database/query/preloader/has-one.d.ts.map +1 -1
  141. package/build/src/database/query/preloader/has-one.js +4 -10
  142. package/build/src/database/query/preloader.d.ts.map +1 -1
  143. package/build/src/database/query/preloader.js +7 -20
  144. package/build/src/database/query/query-data.d.ts.map +1 -1
  145. package/build/src/database/query/query-data.js +6 -16
  146. package/build/src/database/query/where-model-class-hash.d.ts.map +1 -1
  147. package/build/src/database/query/where-model-class-hash.js +6 -16
  148. package/build/src/database/query/with-count.d.ts.map +1 -1
  149. package/build/src/database/query/with-count.js +6 -17
  150. package/build/src/database/record/acts-as-list.d.ts.map +1 -1
  151. package/build/src/database/record/acts-as-list.js +11 -47
  152. package/build/src/database/record/attachments/normalize-input.d.ts.map +1 -1
  153. package/build/src/database/record/attachments/normalize-input.js +8 -30
  154. package/build/src/database/record/attachments/storage-drivers/s3.d.ts.map +1 -1
  155. package/build/src/database/record/attachments/storage-drivers/s3.js +5 -13
  156. package/build/src/database/record/attachments/store.d.ts.map +1 -1
  157. package/build/src/database/record/attachments/store.js +3 -7
  158. package/build/src/database/record/index.d.ts +4 -9
  159. package/build/src/database/record/index.d.ts.map +1 -1
  160. package/build/src/database/record/index.js +53 -173
  161. package/build/src/database/record/instance-relationships/base.d.ts.map +1 -1
  162. package/build/src/database/record/instance-relationships/base.js +7 -21
  163. package/build/src/database/record/instance-relationships/belongs-to.d.ts.map +1 -1
  164. package/build/src/database/record/instance-relationships/belongs-to.js +3 -7
  165. package/build/src/database/record/instance-relationships/has-many.d.ts.map +1 -1
  166. package/build/src/database/record/instance-relationships/has-many.js +5 -13
  167. package/build/src/database/record/instance-relationships/has-one.d.ts.map +1 -1
  168. package/build/src/database/record/instance-relationships/has-one.js +5 -13
  169. package/build/src/database/record/relationships/base.d.ts.map +1 -1
  170. package/build/src/database/record/relationships/base.js +2 -6
  171. package/build/src/database/record/validators/presence.d.ts.map +1 -1
  172. package/build/src/database/record/validators/presence.js +2 -4
  173. package/build/src/database/record/validators/uniqueness.d.ts.map +1 -1
  174. package/build/src/database/record/validators/uniqueness.js +5 -14
  175. package/build/src/environment-handlers/browser.d.ts.map +1 -1
  176. package/build/src/environment-handlers/browser.js +2 -4
  177. package/build/src/environment-handlers/node/cli/commands/console.d.ts.map +1 -1
  178. package/build/src/environment-handlers/node/cli/commands/console.js +3 -7
  179. package/build/src/environment-handlers/node/cli/commands/db/schema/load.d.ts.map +1 -1
  180. package/build/src/environment-handlers/node/cli/commands/db/schema/load.js +2 -4
  181. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +38 -0
  182. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts.map +1 -1
  183. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.js +58 -12
  184. package/build/src/environment-handlers/node.d.ts.map +1 -1
  185. package/build/src/environment-handlers/node.js +16 -7
  186. package/build/src/frontend-model-controller.d.ts.map +1 -1
  187. package/build/src/frontend-model-controller.js +35 -114
  188. package/build/src/frontend-models/base.d.ts.map +1 -1
  189. package/build/src/frontend-models/base.js +46 -158
  190. package/build/src/frontend-models/clear-pending-debounced-callback.d.ts.map +1 -1
  191. package/build/src/frontend-models/clear-pending-debounced-callback.js +2 -4
  192. package/build/src/frontend-models/preloader.d.ts.map +1 -1
  193. package/build/src/frontend-models/preloader.js +4 -11
  194. package/build/src/frontend-models/query.d.ts.map +1 -1
  195. package/build/src/frontend-models/query.js +12 -34
  196. package/build/src/frontend-models/resource-definition.d.ts.map +1 -1
  197. package/build/src/frontend-models/resource-definition.js +3 -7
  198. package/build/src/frontend-models/transport-serialization.d.ts.map +1 -1
  199. package/build/src/frontend-models/transport-serialization.js +8 -23
  200. package/build/src/frontend-models/use-destroyed-event.js +3 -7
  201. package/build/src/frontend-models/use-model-class-event.d.ts.map +1 -1
  202. package/build/src/frontend-models/use-model-class-event.js +3 -7
  203. package/build/src/frontend-models/use-updated-event.d.ts.map +1 -1
  204. package/build/src/frontend-models/use-updated-event.js +4 -10
  205. package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
  206. package/build/src/frontend-models/websocket-channel.js +10 -32
  207. package/build/src/frontend-models/websocket-publishers.d.ts.map +1 -1
  208. package/build/src/frontend-models/websocket-publishers.js +14 -25
  209. package/build/src/http-server/client/index.d.ts.map +1 -1
  210. package/build/src/http-server/client/index.js +8 -22
  211. package/build/src/http-server/client/params-to-object.d.ts.map +1 -1
  212. package/build/src/http-server/client/params-to-object.js +7 -21
  213. package/build/src/http-server/client/request-buffer/index.d.ts.map +1 -1
  214. package/build/src/http-server/client/request-buffer/index.js +2 -4
  215. package/build/src/http-server/client/request-parser.d.ts.map +1 -1
  216. package/build/src/http-server/client/request-parser.js +2 -4
  217. package/build/src/http-server/client/request-runner.d.ts.map +1 -1
  218. package/build/src/http-server/client/request-runner.js +6 -15
  219. package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
  220. package/build/src/http-server/client/websocket-session.js +7 -20
  221. package/build/src/http-server/development-reloader.d.ts.map +1 -1
  222. package/build/src/http-server/development-reloader.js +3 -7
  223. package/build/src/http-server/remote-address.d.ts.map +1 -1
  224. package/build/src/http-server/remote-address.js +2 -6
  225. package/build/src/http-server/server-client.d.ts.map +1 -1
  226. package/build/src/http-server/server-client.js +4 -10
  227. package/build/src/http-server/server-lock.d.ts.map +1 -1
  228. package/build/src/http-server/server-lock.js +3 -7
  229. package/build/src/http-server/websocket-channel-subscribers.d.ts.map +1 -1
  230. package/build/src/http-server/websocket-channel-subscribers.js +3 -7
  231. package/build/src/http-server/websocket-event-log-store.d.ts.map +1 -1
  232. package/build/src/http-server/websocket-event-log-store.js +6 -16
  233. package/build/src/http-server/websocket-events-host.d.ts.map +1 -1
  234. package/build/src/http-server/websocket-events-host.js +2 -5
  235. package/build/src/http-server/worker-handler/in-process.d.ts.map +1 -1
  236. package/build/src/http-server/worker-handler/in-process.js +4 -12
  237. package/build/src/http-server/worker-handler/index.d.ts.map +1 -1
  238. package/build/src/http-server/worker-handler/index.js +4 -3
  239. package/build/src/http-server/worker-handler/worker-thread.d.ts.map +1 -1
  240. package/build/src/http-server/worker-handler/worker-thread.js +2 -4
  241. package/build/src/logger.d.ts.map +1 -1
  242. package/build/src/logger.js +3 -7
  243. package/build/src/mailer/backends/smtp.d.ts.map +1 -1
  244. package/build/src/mailer/backends/smtp.js +2 -6
  245. package/build/src/mailer/base.d.ts.map +1 -1
  246. package/build/src/mailer/base.js +5 -17
  247. package/build/src/plugins/sqljs-wasm-route-controller.d.ts.map +1 -1
  248. package/build/src/plugins/sqljs-wasm-route-controller.js +2 -4
  249. package/build/src/routes/basic-route.d.ts.map +1 -1
  250. package/build/src/routes/basic-route.js +2 -4
  251. package/build/src/routes/resolver.d.ts.map +1 -1
  252. package/build/src/routes/resolver.js +6 -16
  253. package/build/src/testing/expect-utils.d.ts.map +1 -1
  254. package/build/src/testing/expect-utils.js +9 -27
  255. package/build/src/testing/expect.d.ts.map +1 -1
  256. package/build/src/testing/expect.js +5 -15
  257. package/build/src/testing/test-runner.d.ts.map +1 -1
  258. package/build/src/testing/test-runner.js +4 -10
  259. package/build/src/testing/test.d.ts.map +1 -1
  260. package/build/src/testing/test.js +5 -17
  261. package/build/src/utils/model-scope.d.ts.map +1 -1
  262. package/build/src/utils/model-scope.js +2 -5
  263. package/build/src/utils/ransack.d.ts.map +1 -1
  264. package/build/src/utils/ransack.js +15 -42
  265. package/build/src/utils/with-tracked-stack-async-hooks.d.ts.map +1 -1
  266. package/build/src/utils/with-tracked-stack-async-hooks.js +4 -12
  267. package/build/src/utils/with-tracked-stack.d.ts.map +1 -1
  268. package/build/src/utils/with-tracked-stack.js +3 -8
  269. package/build/testing/expect-utils.js +8 -26
  270. package/build/testing/expect.js +4 -14
  271. package/build/testing/test-runner.js +3 -9
  272. package/build/testing/test.js +4 -12
  273. package/build/tsconfig.tsbuildinfo +1 -1
  274. package/build/utils/model-scope.js +1 -3
  275. package/build/utils/ransack.js +15 -41
  276. package/build/utils/with-tracked-stack-async-hooks.js +3 -9
  277. package/build/utils/with-tracked-stack.js +2 -6
  278. package/package.json +5 -3
  279. package/src/application.js +1 -3
  280. package/src/background-jobs/cron-expression.js +1 -3
  281. package/src/background-jobs/forked-runner-child.js +1 -3
  282. package/src/background-jobs/job.js +1 -3
  283. package/src/background-jobs/scheduler.js +2 -6
  284. package/src/background-jobs/store.js +2 -6
  285. package/src/background-jobs/web/controller.js +1 -3
  286. package/src/background-jobs/worker.js +1 -3
  287. package/src/beacon/client.js +2 -6
  288. package/src/cli/tenant-database-command-helper.js +1 -3
  289. package/src/configuration.js +62 -40
  290. package/src/controller.js +4 -14
  291. package/src/database/drivers/mssql/index.js +1 -3
  292. package/src/database/drivers/mysql/index.js +2 -6
  293. package/src/database/drivers/pgsql/index.js +1 -3
  294. package/src/database/drivers/sqlite/base.js +3 -9
  295. package/src/database/drivers/sqlite/index.js +3 -9
  296. package/src/database/drivers/sqlite/table.js +1 -3
  297. package/src/database/migrator.js +1 -3
  298. package/src/database/pool/async-tracked-multi-connection.js +86 -46
  299. package/src/database/pool/base-methods-forward.js +2 -10
  300. package/src/database/pool/base.js +13 -15
  301. package/src/database/query/index.js +4 -12
  302. package/src/database/query/join-object.js +3 -9
  303. package/src/database/query/model-class-query.js +21 -63
  304. package/src/database/query/preloader/belongs-to.js +9 -27
  305. package/src/database/query/preloader/has-many.js +7 -21
  306. package/src/database/query/preloader/has-one.js +3 -9
  307. package/src/database/query/preloader.js +6 -18
  308. package/src/database/query/query-data.js +5 -15
  309. package/src/database/query/where-model-class-hash.js +5 -15
  310. package/src/database/query/with-count.js +5 -15
  311. package/src/database/record/acts-as-list.js +10 -38
  312. package/src/database/record/attachments/normalize-input.js +7 -25
  313. package/src/database/record/attachments/storage-drivers/s3.js +4 -12
  314. package/src/database/record/attachments/store.js +2 -6
  315. package/src/database/record/index.js +55 -171
  316. package/src/database/record/instance-relationships/base.js +6 -20
  317. package/src/database/record/instance-relationships/belongs-to.js +2 -6
  318. package/src/database/record/instance-relationships/has-many.js +4 -12
  319. package/src/database/record/instance-relationships/has-one.js +4 -12
  320. package/src/database/record/relationships/base.js +1 -5
  321. package/src/database/record/validators/presence.js +1 -3
  322. package/src/database/record/validators/uniqueness.js +4 -12
  323. package/src/environment-handlers/browser.js +1 -3
  324. package/src/environment-handlers/node/cli/commands/console.js +2 -6
  325. package/src/environment-handlers/node/cli/commands/db/schema/load.js +1 -3
  326. package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +67 -11
  327. package/src/environment-handlers/node.js +15 -6
  328. package/src/frontend-model-controller.js +34 -110
  329. package/src/frontend-models/base.js +45 -151
  330. package/src/frontend-models/clear-pending-debounced-callback.js +1 -3
  331. package/src/frontend-models/preloader.js +3 -9
  332. package/src/frontend-models/query.js +11 -33
  333. package/src/frontend-models/resource-definition.js +2 -6
  334. package/src/frontend-models/transport-serialization.js +7 -21
  335. package/src/frontend-models/use-destroyed-event.js +2 -6
  336. package/src/frontend-models/use-model-class-event.js +2 -6
  337. package/src/frontend-models/use-updated-event.js +3 -9
  338. package/src/frontend-models/websocket-channel.js +9 -27
  339. package/src/frontend-models/websocket-publishers.js +12 -23
  340. package/src/http-server/client/index.js +7 -19
  341. package/src/http-server/client/params-to-object.js +6 -18
  342. package/src/http-server/client/request-buffer/index.js +1 -3
  343. package/src/http-server/client/request-parser.js +1 -3
  344. package/src/http-server/client/request-runner.js +5 -13
  345. package/src/http-server/client/websocket-session.js +6 -18
  346. package/src/http-server/development-reloader.js +2 -6
  347. package/src/http-server/remote-address.js +1 -5
  348. package/src/http-server/server-client.js +3 -9
  349. package/src/http-server/server-lock.js +2 -6
  350. package/src/http-server/websocket-channel-subscribers.js +2 -6
  351. package/src/http-server/websocket-event-log-store.js +5 -15
  352. package/src/http-server/websocket-events-host.js +1 -3
  353. package/src/http-server/worker-handler/in-process.js +3 -11
  354. package/src/http-server/worker-handler/index.js +3 -2
  355. package/src/http-server/worker-handler/worker-thread.js +1 -3
  356. package/src/logger.js +2 -6
  357. package/src/mailer/backends/smtp.js +1 -5
  358. package/src/mailer/base.js +4 -16
  359. package/src/plugins/sqljs-wasm-route-controller.js +1 -3
  360. package/src/routes/basic-route.js +1 -3
  361. package/src/routes/resolver.js +5 -15
  362. package/src/testing/expect-utils.js +8 -26
  363. package/src/testing/expect.js +4 -14
  364. package/src/testing/test-runner.js +3 -9
  365. package/src/testing/test.js +4 -12
  366. package/src/utils/model-scope.js +1 -3
  367. package/src/utils/ransack.js +15 -41
  368. package/src/utils/with-tracked-stack-async-hooks.js +3 -9
  369. package/src/utils/with-tracked-stack.js +2 -6
  370. package/build/src/utils/ensure-error.d.ts +0 -7
  371. package/build/src/utils/ensure-error.d.ts.map +0 -1
  372. package/build/src/utils/ensure-error.js +0 -15
  373. package/build/utils/ensure-error.js +0 -15
  374. package/src/utils/ensure-error.js +0 -15
@@ -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(() => {
@@ -528,8 +523,65 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
528
523
  */
529
524
  pendingCheckoutTimeoutError(checkout) {
530
525
  const checkoutName = checkout.options.name ? ` Checkout name: ${JSON.stringify(checkout.options.name)}.` : ""
526
+ const diagnostics = this.pendingCheckoutTimeoutDiagnostics(checkout)
527
+
528
+ return new Error(`Timed out after ${checkout.timeoutMillis}ms waiting for database connection checkout from pool "${this.identifier}".${checkoutName} ${diagnostics}`)
529
+ }
530
+
531
+ /**
532
+ * Builds sanitized diagnostics for a checkout timeout.
533
+ * @param {PendingCheckout} checkout - Timed-out checkout.
534
+ * @returns {string} - Pool state summary.
535
+ */
536
+ pendingCheckoutTimeoutDiagnostics(checkout) {
537
+ const snapshot = this.getDebugSnapshot()
538
+ const connectionSummaries = snapshot.connections
539
+ .map((connection) => this.pendingCheckoutTimeoutConnectionSummary(connection))
540
+ .join(", ")
541
+ const pendingSummaries = (snapshot.pendingCheckouts || [])
542
+ .map((pendingCheckout) => this.pendingCheckoutTimeoutPendingSummary(pendingCheckout))
543
+ .join(", ")
544
+ const waitedForMs = Math.max(0, Date.now() - checkout.enqueuedAt)
531
545
 
532
- return new Error(`Timed out after ${checkout.timeoutMillis}ms waiting for database connection checkout from pool "${this.identifier}".${checkoutName}`)
546
+ return `Pool state: max=${this.maxConnections() ?? "unbounded"}, inUse=${snapshot.inUseCount}, idle=${snapshot.idleCount}, pending=${snapshot.pendingCheckoutCount}, spawning=${snapshot.connectionsBeingSpawned}, timedOutWaitingForMs=${waitedForMs}, holders=[${connectionSummaries}], waiting=[${pendingSummaries}].`
547
+ }
548
+
549
+ /**
550
+ * Builds a sanitized connection summary for checkout timeout diagnostics.
551
+ * @param {Record<string, ?>} connection - Connection debug snapshot.
552
+ * @returns {string} - Sanitized connection state.
553
+ */
554
+ pendingCheckoutTimeoutConnectionSummary(connection) {
555
+ const parts = [`state=${connection.state}`]
556
+
557
+ if (connection.checkoutName) parts.push(`checkout=${JSON.stringify(connection.checkoutName)}`)
558
+ if (typeof connection.checkedOutForMs === "number") parts.push(`checkedOutForMs=${connection.checkedOutForMs}`)
559
+ if (typeof connection.idleForMs === "number") parts.push(`idleForMs=${connection.idleForMs}`)
560
+ if (typeof connection.openTransactions === "number") parts.push(`openTransactions=${connection.openTransactions}`)
561
+
562
+ const activeQuery = connection.activeQuery
563
+
564
+ if (activeQuery && typeof activeQuery === "object" && !Array.isArray(activeQuery)) {
565
+ const runningMs = (/** @type {Record<string, ?>} */ (activeQuery)).runningMs
566
+
567
+ if (typeof runningMs === "number") parts.push(`activeQueryMs=${runningMs}`)
568
+ }
569
+
570
+ return `{${parts.join(" ")}}`
571
+ }
572
+
573
+ /**
574
+ * Builds a sanitized pending checkout summary for checkout timeout diagnostics.
575
+ * @param {import("./base.js").DatabasePoolPendingCheckoutDebugSnapshot} pendingCheckout - Waiting checkout snapshot.
576
+ * @returns {string} - Sanitized pending checkout state.
577
+ */
578
+ pendingCheckoutTimeoutPendingSummary(pendingCheckout) {
579
+ const parts = [`index=${pendingCheckout.index}`, `waitingForMs=${pendingCheckout.waitingForMs}`]
580
+
581
+ if (pendingCheckout.checkoutName) parts.push(`checkout=${JSON.stringify(pendingCheckout.checkoutName)}`)
582
+ if (pendingCheckout.remainingTimeoutMs !== null) parts.push(`remainingTimeoutMs=${pendingCheckout.remainingTimeoutMs}`)
583
+
584
+ return `{${parts.join(" ")}}`
533
585
  }
534
586
 
535
587
  /**
@@ -709,9 +761,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
709
761
  * @returns {void} - No return value.
710
762
  */
711
763
  setGlobalConnection(connection) {
712
- const klass = /**
713
- * Narrows the runtime value to the documented type.
714
- * @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
764
+ const klass = /** @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
715
765
  let mapForConfiguration = klass.globalConnections.get(this.configuration)
716
766
 
717
767
  if (!mapForConfiguration) {
@@ -770,6 +820,14 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
770
820
  return this.getCurrentConnection()
771
821
  }
772
822
 
823
+ /**
824
+ * Returns whether this pool has a real async context for the current connection.
825
+ * @returns {boolean} - Whether nested code can reuse the current connection context.
826
+ */
827
+ hasCurrentConnectionContext() {
828
+ return this.asyncLocalStorage.getStore() !== undefined
829
+ }
830
+
773
831
  /**
774
832
  * Runs get debug snapshot.
775
833
  * @returns {import("./base.js").DatabasePoolDebugSnapshot} - Diagnostic snapshot for this pool.
@@ -816,9 +874,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
816
874
  */
817
875
  addInUseDebugConnectionSnapshots({connections, now, seenConnections}) {
818
876
  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)
877
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[CONNECTION_CHECKED_OUT_AT]?: number}} */ (connection)
822
878
  const checkedOutAt = trackedConnection[CONNECTION_CHECKED_OUT_AT]
823
879
  const checkedOutForMs = typeof checkedOutAt === "number" ? Math.max(0, now - checkedOutAt) : undefined
824
880
 
@@ -838,9 +894,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
838
894
 
839
895
  seenConnections.add(connection)
840
896
 
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)
897
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
844
898
  const checkedInAt = trackedConnection[IDLE_CONNECTION_CHECKED_IN_AT]
845
899
  const idleForMs = typeof checkedInAt === "number" ? Math.max(0, now - checkedInAt) : undefined
846
900
 
@@ -906,9 +960,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
906
960
  * @returns {import("../drivers/base.js").default | undefined} - The global connection for this pool identifier.
907
961
  */
908
962
  getGlobalConnectionForIdentifier() {
909
- const klass = /**
910
- * Narrows the runtime value to the documented type.
911
- * @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
963
+ const klass = /** @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
912
964
  const mapForConfiguration = klass.globalConnections.get(this.configuration)
913
965
 
914
966
  return mapForConfiguration?.[this.identifier]
@@ -919,9 +971,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
919
971
  * @returns {void} - No return value.
920
972
  */
921
973
  clearGlobalConnectionForIdentifier() {
922
- const klass = /**
923
- * Narrows the runtime value to the documented type.
924
- * @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
974
+ const klass = /** @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
925
975
  const mapForConfiguration = klass.globalConnections.get(this.configuration)
926
976
 
927
977
  if (!mapForConfiguration) return
@@ -975,9 +1025,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
975
1025
  if (this.idleConnectionReaperTimer) return
976
1026
  if (!this.hasIdleConnectionsToReap()) return
977
1027
 
978
- const delay = this.nextIdleConnectionReapDelay(/**
979
- * Narrows the runtime value to the documented type.
980
- * @type {number} */ (this.idleTimeoutMillis()))
1028
+ const delay = this.nextIdleConnectionReapDelay(/** @type {number} */ (this.idleTimeoutMillis()))
981
1029
 
982
1030
  this.idleConnectionReaperTimer = setTimeout(() => {
983
1031
  this.idleConnectionReaperTimer = undefined
@@ -1011,9 +1059,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
1011
1059
  for (const connection of this.connections) {
1012
1060
  if (this.connectionHasOpenTransaction(connection)) continue
1013
1061
 
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)
1062
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
1017
1063
  const checkedInAt = trackedConnection[IDLE_CONNECTION_CHECKED_IN_AT]
1018
1064
 
1019
1065
  if (typeof checkedInAt !== "number") continue
@@ -1109,9 +1155,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
1109
1155
  * @returns {boolean} - Whether the connection is marked closed.
1110
1156
  */
1111
1157
  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)
1158
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean}} */ (connection)
1115
1159
 
1116
1160
  return Boolean(trackedConnection[CLOSED_CONNECTION])
1117
1161
  }
@@ -1122,9 +1166,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
1122
1166
  * @returns {boolean} - Whether the idle connection expired.
1123
1167
  */
1124
1168
  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)
1169
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
1128
1170
  const checkedInAt = trackedConnection[IDLE_CONNECTION_CHECKED_IN_AT]
1129
1171
 
1130
1172
  return typeof checkedInAt === "number" && now - checkedInAt >= idleTimeoutMillis
@@ -1174,9 +1216,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
1174
1216
  return await existingClose
1175
1217
  }
1176
1218
 
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)
1219
+ const trackedConnection = /** @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean, [CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
1180
1220
 
1181
1221
  trackedConnection[CLOSED_CONNECTION] = true
1182
1222
  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
  }
@@ -148,6 +144,14 @@ class VelociousDatabasePoolBase {
148
144
  return this.getCurrentConnection()
149
145
  }
150
146
 
147
+ /**
148
+ * Returns whether the current connection is pinned to an execution context.
149
+ * @returns {boolean} - Whether the current connection can be reused by nested code.
150
+ */
151
+ hasCurrentConnectionContext() {
152
+ return true
153
+ }
154
+
151
155
  /**
152
156
  * Runs without current connection context.
153
157
  * @template T
@@ -195,9 +199,7 @@ class VelociousDatabasePoolBase {
195
199
  * @returns {boolean} - Whether connection matches current resolved configuration.
196
200
  */
197
201
  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)
202
+ const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
201
203
 
202
204
  return connectionWithPoolKey[POOL_CONFIGURATION_KEY] === this.getConfigurationReuseKey()
203
205
  }
@@ -256,9 +258,7 @@ class VelociousDatabasePoolBase {
256
258
 
257
259
  const connection = await this.spawnConnectionWithConfiguration(databaseConfig)
258
260
 
259
- const connectionWithPoolKey = /**
260
- * Narrows the runtime value to the documented type.
261
- * @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
261
+ const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
262
262
  connectionWithPoolKey[POOL_CONFIGURATION_KEY] = this.getConfigurationReuseKey()
263
263
  connection.setSchemaCacheInvalidator(() => {
264
264
  this.clearSchemaCache()
@@ -371,9 +371,7 @@ class VelociousDatabasePoolBase {
371
371
  * @returns {Record<string, ?>} - Connection diagnostic snapshot.
372
372
  */
373
373
  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)
374
+ const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
377
375
 
378
376
  return {
379
377
  ...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
  }