velocious 1.0.461 → 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 (361) 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 +29 -32
  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 +20 -45
  21. package/build/database/pool/base-methods-forward.js +2 -10
  22. package/build/database/pool/base.js +5 -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 +6 -18
  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 +4 -12
  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/worker-thread.js +1 -3
  77. package/build/logger.js +2 -6
  78. package/build/mailer/backends/smtp.js +1 -5
  79. package/build/mailer/base.js +4 -16
  80. package/build/plugins/sqljs-wasm-route-controller.js +1 -3
  81. package/build/routes/basic-route.js +1 -3
  82. package/build/routes/resolver.js +4 -14
  83. package/build/src/application.d.ts.map +1 -1
  84. package/build/src/application.js +2 -4
  85. package/build/src/background-jobs/cron-expression.d.ts.map +1 -1
  86. package/build/src/background-jobs/cron-expression.js +2 -4
  87. package/build/src/background-jobs/forked-runner-child.js +2 -4
  88. package/build/src/background-jobs/job.d.ts.map +1 -1
  89. package/build/src/background-jobs/job.js +2 -4
  90. package/build/src/background-jobs/scheduler.d.ts.map +1 -1
  91. package/build/src/background-jobs/scheduler.js +3 -7
  92. package/build/src/background-jobs/store.d.ts.map +1 -1
  93. package/build/src/background-jobs/store.js +3 -7
  94. package/build/src/background-jobs/web/controller.d.ts.map +1 -1
  95. package/build/src/background-jobs/web/controller.js +2 -5
  96. package/build/src/background-jobs/worker.d.ts.map +1 -1
  97. package/build/src/background-jobs/worker.js +2 -4
  98. package/build/src/beacon/client.d.ts.map +1 -1
  99. package/build/src/beacon/client.js +3 -7
  100. package/build/src/cli/tenant-database-command-helper.d.ts.map +1 -1
  101. package/build/src/cli/tenant-database-command-helper.js +2 -4
  102. package/build/src/configuration.d.ts.map +1 -1
  103. package/build/src/configuration.js +27 -35
  104. package/build/src/controller.d.ts.map +1 -1
  105. package/build/src/controller.js +5 -15
  106. package/build/src/database/drivers/mssql/index.d.ts.map +1 -1
  107. package/build/src/database/drivers/mssql/index.js +2 -4
  108. package/build/src/database/drivers/mysql/index.d.ts.map +1 -1
  109. package/build/src/database/drivers/mysql/index.js +3 -7
  110. package/build/src/database/drivers/pgsql/index.d.ts.map +1 -1
  111. package/build/src/database/drivers/pgsql/index.js +2 -4
  112. package/build/src/database/drivers/sqlite/base.d.ts.map +1 -1
  113. package/build/src/database/drivers/sqlite/base.js +4 -10
  114. package/build/src/database/drivers/sqlite/index.d.ts.map +1 -1
  115. package/build/src/database/drivers/sqlite/index.js +4 -10
  116. package/build/src/database/drivers/sqlite/table.d.ts.map +1 -1
  117. package/build/src/database/drivers/sqlite/table.js +2 -4
  118. package/build/src/database/migrator.d.ts.map +1 -1
  119. package/build/src/database/migrator.js +2 -4
  120. package/build/src/database/pool/async-tracked-multi-connection.d.ts.map +1 -1
  121. package/build/src/database/pool/async-tracked-multi-connection.js +21 -47
  122. package/build/src/database/pool/base-methods-forward.d.ts.map +1 -1
  123. package/build/src/database/pool/base-methods-forward.js +3 -11
  124. package/build/src/database/pool/base.d.ts.map +1 -1
  125. package/build/src/database/pool/base.js +6 -16
  126. package/build/src/database/query/index.d.ts.map +1 -1
  127. package/build/src/database/query/index.js +5 -13
  128. package/build/src/database/query/join-object.d.ts.map +1 -1
  129. package/build/src/database/query/join-object.js +4 -10
  130. package/build/src/database/query/model-class-query.d.ts.map +1 -1
  131. package/build/src/database/query/model-class-query.js +22 -64
  132. package/build/src/database/query/preloader/belongs-to.d.ts.map +1 -1
  133. package/build/src/database/query/preloader/belongs-to.js +10 -28
  134. package/build/src/database/query/preloader/has-many.d.ts.map +1 -1
  135. package/build/src/database/query/preloader/has-many.js +8 -22
  136. package/build/src/database/query/preloader/has-one.d.ts.map +1 -1
  137. package/build/src/database/query/preloader/has-one.js +4 -10
  138. package/build/src/database/query/preloader.d.ts.map +1 -1
  139. package/build/src/database/query/preloader.js +7 -20
  140. package/build/src/database/query/query-data.d.ts.map +1 -1
  141. package/build/src/database/query/query-data.js +6 -16
  142. package/build/src/database/query/where-model-class-hash.d.ts.map +1 -1
  143. package/build/src/database/query/where-model-class-hash.js +6 -16
  144. package/build/src/database/query/with-count.d.ts.map +1 -1
  145. package/build/src/database/query/with-count.js +6 -17
  146. package/build/src/database/record/acts-as-list.d.ts.map +1 -1
  147. package/build/src/database/record/acts-as-list.js +11 -47
  148. package/build/src/database/record/attachments/normalize-input.d.ts.map +1 -1
  149. package/build/src/database/record/attachments/normalize-input.js +8 -30
  150. package/build/src/database/record/attachments/storage-drivers/s3.d.ts.map +1 -1
  151. package/build/src/database/record/attachments/storage-drivers/s3.js +5 -13
  152. package/build/src/database/record/attachments/store.d.ts.map +1 -1
  153. package/build/src/database/record/attachments/store.js +3 -7
  154. package/build/src/database/record/index.d.ts +4 -9
  155. package/build/src/database/record/index.d.ts.map +1 -1
  156. package/build/src/database/record/index.js +53 -173
  157. package/build/src/database/record/instance-relationships/base.d.ts.map +1 -1
  158. package/build/src/database/record/instance-relationships/base.js +7 -21
  159. package/build/src/database/record/instance-relationships/belongs-to.d.ts.map +1 -1
  160. package/build/src/database/record/instance-relationships/belongs-to.js +3 -7
  161. package/build/src/database/record/instance-relationships/has-many.d.ts.map +1 -1
  162. package/build/src/database/record/instance-relationships/has-many.js +5 -13
  163. package/build/src/database/record/instance-relationships/has-one.d.ts.map +1 -1
  164. package/build/src/database/record/instance-relationships/has-one.js +5 -13
  165. package/build/src/database/record/relationships/base.d.ts.map +1 -1
  166. package/build/src/database/record/relationships/base.js +2 -6
  167. package/build/src/database/record/validators/presence.d.ts.map +1 -1
  168. package/build/src/database/record/validators/presence.js +2 -4
  169. package/build/src/database/record/validators/uniqueness.d.ts.map +1 -1
  170. package/build/src/database/record/validators/uniqueness.js +5 -14
  171. package/build/src/environment-handlers/browser.d.ts.map +1 -1
  172. package/build/src/environment-handlers/browser.js +2 -4
  173. package/build/src/environment-handlers/node/cli/commands/console.d.ts.map +1 -1
  174. package/build/src/environment-handlers/node/cli/commands/console.js +3 -7
  175. package/build/src/environment-handlers/node/cli/commands/db/schema/load.d.ts.map +1 -1
  176. package/build/src/environment-handlers/node/cli/commands/db/schema/load.js +2 -4
  177. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +38 -0
  178. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts.map +1 -1
  179. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.js +58 -12
  180. package/build/src/environment-handlers/node.d.ts.map +1 -1
  181. package/build/src/environment-handlers/node.js +16 -7
  182. package/build/src/frontend-model-controller.d.ts.map +1 -1
  183. package/build/src/frontend-model-controller.js +35 -114
  184. package/build/src/frontend-models/base.d.ts.map +1 -1
  185. package/build/src/frontend-models/base.js +46 -158
  186. package/build/src/frontend-models/clear-pending-debounced-callback.d.ts.map +1 -1
  187. package/build/src/frontend-models/clear-pending-debounced-callback.js +2 -4
  188. package/build/src/frontend-models/preloader.d.ts.map +1 -1
  189. package/build/src/frontend-models/preloader.js +4 -11
  190. package/build/src/frontend-models/query.d.ts.map +1 -1
  191. package/build/src/frontend-models/query.js +12 -34
  192. package/build/src/frontend-models/resource-definition.d.ts.map +1 -1
  193. package/build/src/frontend-models/resource-definition.js +3 -7
  194. package/build/src/frontend-models/transport-serialization.d.ts.map +1 -1
  195. package/build/src/frontend-models/transport-serialization.js +8 -23
  196. package/build/src/frontend-models/use-destroyed-event.js +3 -7
  197. package/build/src/frontend-models/use-model-class-event.d.ts.map +1 -1
  198. package/build/src/frontend-models/use-model-class-event.js +3 -7
  199. package/build/src/frontend-models/use-updated-event.d.ts.map +1 -1
  200. package/build/src/frontend-models/use-updated-event.js +4 -10
  201. package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
  202. package/build/src/frontend-models/websocket-channel.js +10 -32
  203. package/build/src/frontend-models/websocket-publishers.d.ts.map +1 -1
  204. package/build/src/frontend-models/websocket-publishers.js +14 -25
  205. package/build/src/http-server/client/index.d.ts.map +1 -1
  206. package/build/src/http-server/client/index.js +7 -21
  207. package/build/src/http-server/client/params-to-object.d.ts.map +1 -1
  208. package/build/src/http-server/client/params-to-object.js +7 -21
  209. package/build/src/http-server/client/request-buffer/index.d.ts.map +1 -1
  210. package/build/src/http-server/client/request-buffer/index.js +2 -4
  211. package/build/src/http-server/client/request-parser.d.ts.map +1 -1
  212. package/build/src/http-server/client/request-parser.js +2 -4
  213. package/build/src/http-server/client/request-runner.d.ts.map +1 -1
  214. package/build/src/http-server/client/request-runner.js +5 -14
  215. package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
  216. package/build/src/http-server/client/websocket-session.js +7 -20
  217. package/build/src/http-server/development-reloader.d.ts.map +1 -1
  218. package/build/src/http-server/development-reloader.js +3 -7
  219. package/build/src/http-server/remote-address.d.ts.map +1 -1
  220. package/build/src/http-server/remote-address.js +2 -6
  221. package/build/src/http-server/server-client.d.ts.map +1 -1
  222. package/build/src/http-server/server-client.js +4 -10
  223. package/build/src/http-server/server-lock.d.ts.map +1 -1
  224. package/build/src/http-server/server-lock.js +3 -7
  225. package/build/src/http-server/websocket-channel-subscribers.d.ts.map +1 -1
  226. package/build/src/http-server/websocket-channel-subscribers.js +3 -7
  227. package/build/src/http-server/websocket-event-log-store.d.ts.map +1 -1
  228. package/build/src/http-server/websocket-event-log-store.js +6 -16
  229. package/build/src/http-server/websocket-events-host.d.ts.map +1 -1
  230. package/build/src/http-server/websocket-events-host.js +2 -5
  231. package/build/src/http-server/worker-handler/in-process.d.ts.map +1 -1
  232. package/build/src/http-server/worker-handler/in-process.js +4 -12
  233. package/build/src/http-server/worker-handler/worker-thread.d.ts.map +1 -1
  234. package/build/src/http-server/worker-handler/worker-thread.js +2 -4
  235. package/build/src/logger.d.ts.map +1 -1
  236. package/build/src/logger.js +3 -7
  237. package/build/src/mailer/backends/smtp.d.ts.map +1 -1
  238. package/build/src/mailer/backends/smtp.js +2 -6
  239. package/build/src/mailer/base.d.ts.map +1 -1
  240. package/build/src/mailer/base.js +5 -17
  241. package/build/src/plugins/sqljs-wasm-route-controller.d.ts.map +1 -1
  242. package/build/src/plugins/sqljs-wasm-route-controller.js +2 -4
  243. package/build/src/routes/basic-route.d.ts.map +1 -1
  244. package/build/src/routes/basic-route.js +2 -4
  245. package/build/src/routes/resolver.d.ts.map +1 -1
  246. package/build/src/routes/resolver.js +5 -15
  247. package/build/src/testing/expect-utils.d.ts.map +1 -1
  248. package/build/src/testing/expect-utils.js +9 -27
  249. package/build/src/testing/expect.d.ts.map +1 -1
  250. package/build/src/testing/expect.js +5 -15
  251. package/build/src/testing/test-runner.d.ts.map +1 -1
  252. package/build/src/testing/test-runner.js +4 -10
  253. package/build/src/testing/test.d.ts.map +1 -1
  254. package/build/src/testing/test.js +5 -17
  255. package/build/src/utils/model-scope.d.ts.map +1 -1
  256. package/build/src/utils/model-scope.js +2 -5
  257. package/build/src/utils/ransack.d.ts.map +1 -1
  258. package/build/src/utils/ransack.js +15 -42
  259. package/build/src/utils/with-tracked-stack-async-hooks.d.ts.map +1 -1
  260. package/build/src/utils/with-tracked-stack-async-hooks.js +4 -12
  261. package/build/src/utils/with-tracked-stack.d.ts.map +1 -1
  262. package/build/src/utils/with-tracked-stack.js +3 -8
  263. package/build/testing/expect-utils.js +8 -26
  264. package/build/testing/expect.js +4 -14
  265. package/build/testing/test-runner.js +3 -9
  266. package/build/testing/test.js +4 -12
  267. package/build/utils/model-scope.js +1 -3
  268. package/build/utils/ransack.js +15 -41
  269. package/build/utils/with-tracked-stack-async-hooks.js +3 -9
  270. package/build/utils/with-tracked-stack.js +2 -6
  271. package/package.json +3 -2
  272. package/src/application.js +1 -3
  273. package/src/background-jobs/cron-expression.js +1 -3
  274. package/src/background-jobs/forked-runner-child.js +1 -3
  275. package/src/background-jobs/job.js +1 -3
  276. package/src/background-jobs/scheduler.js +2 -6
  277. package/src/background-jobs/store.js +2 -6
  278. package/src/background-jobs/web/controller.js +1 -3
  279. package/src/background-jobs/worker.js +1 -3
  280. package/src/beacon/client.js +2 -6
  281. package/src/cli/tenant-database-command-helper.js +1 -3
  282. package/src/configuration.js +29 -32
  283. package/src/controller.js +4 -14
  284. package/src/database/drivers/mssql/index.js +1 -3
  285. package/src/database/drivers/mysql/index.js +2 -6
  286. package/src/database/drivers/pgsql/index.js +1 -3
  287. package/src/database/drivers/sqlite/base.js +3 -9
  288. package/src/database/drivers/sqlite/index.js +3 -9
  289. package/src/database/drivers/sqlite/table.js +1 -3
  290. package/src/database/migrator.js +1 -3
  291. package/src/database/pool/async-tracked-multi-connection.js +20 -45
  292. package/src/database/pool/base-methods-forward.js +2 -10
  293. package/src/database/pool/base.js +5 -15
  294. package/src/database/query/index.js +4 -12
  295. package/src/database/query/join-object.js +3 -9
  296. package/src/database/query/model-class-query.js +21 -63
  297. package/src/database/query/preloader/belongs-to.js +9 -27
  298. package/src/database/query/preloader/has-many.js +7 -21
  299. package/src/database/query/preloader/has-one.js +3 -9
  300. package/src/database/query/preloader.js +6 -18
  301. package/src/database/query/query-data.js +5 -15
  302. package/src/database/query/where-model-class-hash.js +5 -15
  303. package/src/database/query/with-count.js +5 -15
  304. package/src/database/record/acts-as-list.js +10 -38
  305. package/src/database/record/attachments/normalize-input.js +7 -25
  306. package/src/database/record/attachments/storage-drivers/s3.js +4 -12
  307. package/src/database/record/attachments/store.js +2 -6
  308. package/src/database/record/index.js +55 -171
  309. package/src/database/record/instance-relationships/base.js +6 -20
  310. package/src/database/record/instance-relationships/belongs-to.js +2 -6
  311. package/src/database/record/instance-relationships/has-many.js +4 -12
  312. package/src/database/record/instance-relationships/has-one.js +4 -12
  313. package/src/database/record/relationships/base.js +1 -5
  314. package/src/database/record/validators/presence.js +1 -3
  315. package/src/database/record/validators/uniqueness.js +4 -12
  316. package/src/environment-handlers/browser.js +1 -3
  317. package/src/environment-handlers/node/cli/commands/console.js +2 -6
  318. package/src/environment-handlers/node/cli/commands/db/schema/load.js +1 -3
  319. package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +67 -11
  320. package/src/environment-handlers/node.js +15 -6
  321. package/src/frontend-model-controller.js +34 -110
  322. package/src/frontend-models/base.js +45 -151
  323. package/src/frontend-models/clear-pending-debounced-callback.js +1 -3
  324. package/src/frontend-models/preloader.js +3 -9
  325. package/src/frontend-models/query.js +11 -33
  326. package/src/frontend-models/resource-definition.js +2 -6
  327. package/src/frontend-models/transport-serialization.js +7 -21
  328. package/src/frontend-models/use-destroyed-event.js +2 -6
  329. package/src/frontend-models/use-model-class-event.js +2 -6
  330. package/src/frontend-models/use-updated-event.js +3 -9
  331. package/src/frontend-models/websocket-channel.js +9 -27
  332. package/src/frontend-models/websocket-publishers.js +12 -23
  333. package/src/http-server/client/index.js +6 -18
  334. package/src/http-server/client/params-to-object.js +6 -18
  335. package/src/http-server/client/request-buffer/index.js +1 -3
  336. package/src/http-server/client/request-parser.js +1 -3
  337. package/src/http-server/client/request-runner.js +4 -12
  338. package/src/http-server/client/websocket-session.js +6 -18
  339. package/src/http-server/development-reloader.js +2 -6
  340. package/src/http-server/remote-address.js +1 -5
  341. package/src/http-server/server-client.js +3 -9
  342. package/src/http-server/server-lock.js +2 -6
  343. package/src/http-server/websocket-channel-subscribers.js +2 -6
  344. package/src/http-server/websocket-event-log-store.js +5 -15
  345. package/src/http-server/websocket-events-host.js +1 -3
  346. package/src/http-server/worker-handler/in-process.js +3 -11
  347. package/src/http-server/worker-handler/worker-thread.js +1 -3
  348. package/src/logger.js +2 -6
  349. package/src/mailer/backends/smtp.js +1 -5
  350. package/src/mailer/base.js +4 -16
  351. package/src/plugins/sqljs-wasm-route-controller.js +1 -3
  352. package/src/routes/basic-route.js +1 -3
  353. package/src/routes/resolver.js +4 -14
  354. package/src/testing/expect-utils.js +8 -26
  355. package/src/testing/expect.js +4 -14
  356. package/src/testing/test-runner.js +3 -9
  357. package/src/testing/test.js +4 -12
  358. package/src/utils/model-scope.js +1 -3
  359. package/src/utils/ransack.js +15 -41
  360. package/src/utils/with-tracked-stack-async-hooks.js +3 -9
  361. package/src/utils/with-tracked-stack.js +2 -6
@@ -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
  }
@@ -105,9 +105,7 @@ export default class VelociousDatabaseQueryPreloaderHasMany {
105
105
  throw new Error(`${this.relationship.getModelClass().name}#${this.relationship.getRelationshipName()} doesn't have a primary key`)
106
106
  }
107
107
 
108
- const throughRelationshipName = /**
109
- * Narrows the runtime value to the documented type.
110
- * @type {string} */ (this.relationship.through)
108
+ const throughRelationshipName = /** @type {string} */ (this.relationship.through)
111
109
  const parentModelClass = this.relationship.getModelClass()
112
110
  const throughRelationship = parentModelClass.getRelationshipByName(throughRelationshipName)
113
111
  const throughModelClass = throughRelationship.getTargetModelClass()
@@ -146,9 +144,7 @@ export default class VelociousDatabaseQueryPreloaderHasMany {
146
144
  const preloadCollections = {}
147
145
 
148
146
  for (const model of modelsToLoad) {
149
- const primaryKeyValue = /**
150
- * Narrows the runtime value to the documented type.
151
- * @type {string | number} */ (model.readColumn(primaryKey))
147
+ const primaryKeyValue = /** @type {string | number} */ (model.readColumn(primaryKey))
152
148
 
153
149
  preloadCollections[primaryKeyValue] = []
154
150
 
@@ -174,12 +170,8 @@ export default class VelociousDatabaseQueryPreloaderHasMany {
174
170
  const allTargetIds = new Set()
175
171
 
176
172
  for (const throughModel of throughModels) {
177
- const parentId = /**
178
- * Narrows the runtime value to the documented type.
179
- * @type {string | number} */ (throughModel.readColumn(throughForeignKey))
180
- const throughId = /**
181
- * Narrows the runtime value to the documented type.
182
- * @type {string | number} */ (throughModel.readColumn(throughModelClass.primaryKey()))
173
+ const parentId = /** @type {string | number} */ (throughModel.readColumn(throughForeignKey))
174
+ const throughId = /** @type {string | number} */ (throughModel.readColumn(throughModelClass.primaryKey()))
183
175
 
184
176
  if (!(parentId in parentToTargetIds)) parentToTargetIds[parentId] = []
185
177
 
@@ -208,9 +200,7 @@ export default class VelociousDatabaseQueryPreloaderHasMany {
208
200
  const targetModelsByForeignKey = {}
209
201
 
210
202
  for (const targetModel of targetModels) {
211
- const fkValue = /**
212
- * Narrows the runtime value to the documented type.
213
- * @type {string | number} */ (targetModel.readColumn(targetForeignKey))
203
+ const fkValue = /** @type {string | number} */ (targetModel.readColumn(targetForeignKey))
214
204
 
215
205
  if (!(fkValue in targetModelsByForeignKey)) targetModelsByForeignKey[fkValue] = []
216
206
 
@@ -284,9 +274,7 @@ export default class VelociousDatabaseQueryPreloaderHasMany {
284
274
  const preloadCollections = {}
285
275
 
286
276
  for (const model of modelsToLoad) {
287
- const primaryKeyValue = /**
288
- * Narrows the runtime value to the documented type.
289
- * @type {string | number} */ (model.readColumn(primaryKey))
277
+ const primaryKeyValue = /** @type {string | number} */ (model.readColumn(primaryKey))
290
278
 
291
279
  preloadCollections[primaryKeyValue] = []
292
280
 
@@ -319,9 +307,7 @@ export default class VelociousDatabaseQueryPreloaderHasMany {
319
307
  const targetModels = await query.toArray()
320
308
 
321
309
  for (const targetModel of targetModels) {
322
- const foreignKeyValue = /**
323
- * Narrows the runtime value to the documented type.
324
- * @type {string | number} */ (targetModel.readColumn(foreignKey))
310
+ const foreignKeyValue = /** @type {string | number} */ (targetModel.readColumn(foreignKey))
325
311
 
326
312
  preloadCollections[foreignKeyValue].push(targetModel)
327
313
  }
@@ -53,17 +53,13 @@ export default class VelociousDatabaseQueryPreloaderHasOne {
53
53
  const instanceRelationship = model.getRelationshipByName(relationshipName)
54
54
 
55
55
  if (this.selection.isSatisfied({instanceRelationship, targetModelClass, mappingColumns: [foreignKey]})) {
56
- const loaded = /**
57
- * Narrows the runtime value to the documented type.
58
- * @type {import("../../record/index.js").default | undefined} */ (instanceRelationship.getLoadedOrUndefined())
56
+ const loaded = /** @type {import("../../record/index.js").default | undefined} */ (instanceRelationship.getLoadedOrUndefined())
59
57
 
60
58
  if (loaded) satisfiedTargets.push(loaded)
61
59
  continue
62
60
  }
63
61
 
64
- const primaryKeyValue = /**
65
- * Narrows the runtime value to the documented type.
66
- * @type {string | number} */ (model.readColumn(primaryKey))
62
+ const primaryKeyValue = /** @type {string | number} */ (model.readColumn(primaryKey))
67
63
 
68
64
  preloadCollections[primaryKeyValue] = undefined
69
65
 
@@ -99,9 +95,7 @@ export default class VelociousDatabaseQueryPreloaderHasOne {
99
95
  const targetModels = await query.toArray()
100
96
 
101
97
  for (const targetModel of targetModels) {
102
- const foreignKeyValue = /**
103
- * Narrows the runtime value to the documented type.
104
- * @type {string | number} */ (targetModel.readColumn(foreignKey))
98
+ const foreignKeyValue = /** @type {string | number} */ (targetModel.readColumn(foreignKey))
105
99
 
106
100
  preloadCollections[foreignKeyValue] = targetModel
107
101
  }
@@ -88,19 +88,13 @@ export default class VelociousDatabaseQueryPreloader {
88
88
  static async preload(models, queryOrSpec, {force = false} = {}) {
89
89
  if (models.length == 0) return
90
90
 
91
- const modelClass = /**
92
- * Narrows the runtime value to the documented type.
93
- * @type {typeof import("../record/index.js").default} */ (models[0].constructor)
91
+ const modelClass = /** @type {typeof import("../record/index.js").default} */ (models[0].constructor)
94
92
  const isQuery = Boolean(queryOrSpec) && typeof queryOrSpec == "object" && "_preload" in queryOrSpec
95
93
  // Reuse the query builder's preload/select normalization for raw specs
96
94
  // instead of duplicating it here.
97
95
  const query = isQuery
98
- ? /**
99
- * Narrows the runtime value to the documented type.
100
- * @type {import("./model-class-query.js").default} */ (queryOrSpec)
101
- : modelClass.preload(/**
102
- * Narrows the runtime value to the documented type.
103
- * @type {?} */ (queryOrSpec))
96
+ ? /** @type {import("./model-class-query.js").default} */ (queryOrSpec)
97
+ : modelClass.preload(/** @type {?} */ (queryOrSpec))
104
98
 
105
99
  const preloader = new VelociousDatabaseQueryPreloader({
106
100
  modelClass,
@@ -141,23 +135,17 @@ export default class VelociousDatabaseQueryPreloader {
141
135
  let preloadResult
142
136
 
143
137
  if (relationship.getType() == "belongsTo") {
144
- const belongsToRelationship = /**
145
- * Narrows the runtime value to the documented type.
146
- * @type {import("../record/relationships/belongs-to.js").default} */ (relationship)
138
+ const belongsToRelationship = /** @type {import("../record/relationships/belongs-to.js").default} */ (relationship)
147
139
  const hasManyPreloader = new BelongsToPreloader({models: this.models, relationship: belongsToRelationship, selection: this.selection})
148
140
 
149
141
  preloadResult = await hasManyPreloader.run()
150
142
  } else if (relationship.getType() == "hasMany") {
151
- const hasManyRelationship = /**
152
- * Narrows the runtime value to the documented type.
153
- * @type {import("../record/relationships/has-many.js").default} */ (relationship)
143
+ const hasManyRelationship = /** @type {import("../record/relationships/has-many.js").default} */ (relationship)
154
144
  const hasManyPreloader = new HasManyPreloader({models: this.models, relationship: hasManyRelationship, selection: this.selection})
155
145
 
156
146
  preloadResult = await hasManyPreloader.run()
157
147
  } else if (relationship.getType() == "hasOne") {
158
- const hasOneRelationship = /**
159
- * Narrows the runtime value to the documented type.
160
- * @type {import("../record/relationships/has-one.js").default} */ (relationship)
148
+ const hasOneRelationship = /** @type {import("../record/relationships/has-one.js").default} */ (relationship)
161
149
  const hasOnePreloader = new HasOnePreloader({models: this.models, relationship: hasOneRelationship, selection: this.selection})
162
150
 
163
151
  preloadResult = await hasOnePreloader.run()
@@ -69,9 +69,7 @@ export function normalizeQueryDataSpec(spec, chain = []) {
69
69
  }
70
70
 
71
71
  if (isPlainObject(item)) {
72
- for (const nested of normalizeQueryDataSpec(/**
73
- * Narrows the runtime value to the documented type.
74
- * @type {?} */ (item), chain)) {
72
+ for (const nested of normalizeQueryDataSpec(/** @type {?} */ (item), chain)) {
75
73
  entries.push(nested)
76
74
  }
77
75
  continue
@@ -98,9 +96,7 @@ export function normalizeQueryDataSpec(spec, chain = []) {
98
96
  if (value === false) continue
99
97
 
100
98
  if (typeof value === "string" || Array.isArray(value) || isPlainObject(value)) {
101
- for (const nested of normalizeQueryDataSpec(/**
102
- * Narrows the runtime value to the documented type.
103
- * @type {?} */ (value), [...chain, key])) {
99
+ for (const nested of normalizeQueryDataSpec(/** @type {?} */ (value), [...chain, key])) {
104
100
  entries.push(nested)
105
101
  }
106
102
  continue
@@ -193,9 +189,7 @@ export async function runQueryData({rootModelClass, rootModels, entries}) {
193
189
  if (rootModels.length === 0 || entries.length === 0) return
194
190
 
195
191
  const primaryKey = rootModelClass.primaryKey()
196
- const rootIds = rootModels.map((model) => /**
197
- * Narrows the runtime value to the documented type.
198
- * @type {string | number} */ (model.readColumn(primaryKey)))
192
+ const rootIds = rootModels.map((model) => /** @type {string | number} */ (model.readColumn(primaryKey)))
199
193
 
200
194
  for (const entry of entries) {
201
195
  await runEntry({entry, primaryKey, rootIds, rootModelClass, rootModels})
@@ -270,9 +264,7 @@ async function runEntry({entry, primaryKey, rootIds, rootModelClass, rootModels}
270
264
  tableName: targetTableRef
271
265
  })
272
266
 
273
- const rows = /**
274
- * Narrows the runtime value to the documented type.
275
- * @type {Array<Record<string, ?>>} */ (await query._executeQuery())
267
+ const rows = /** @type {Array<Record<string, ?>>} */ (await query._executeQuery())
276
268
  const byParent = new Map()
277
269
 
278
270
  for (const row of rows) {
@@ -284,9 +276,7 @@ async function runEntry({entry, primaryKey, rootIds, rootModelClass, rootModels}
284
276
  }
285
277
 
286
278
  for (const model of rootModels) {
287
- const modelId = /**
288
- * Narrows the runtime value to the documented type.
289
- * @type {string | number} */ (model.readColumn(primaryKey))
279
+ const modelId = /** @type {string | number} */ (model.readColumn(primaryKey))
290
280
  // Driver-type tolerance: MySQL can return PKs as strings even when
291
281
  // the column is numeric. Fall back to a string lookup so results
292
282
  // still land on the right model.