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
@@ -147,9 +147,7 @@ function buildRelatedRecordWithInverse(parent, relationshipName, attributes, all
147
147
  allowHasMany,
148
148
  inverseOf,
149
149
  parent,
150
- record: /**
151
- * Narrows the runtime value to the documented type.
152
- * @type {{getRelationshipByName: VelociousDatabaseRecord["getRelationshipByName"]}} */ (record)
150
+ record: /** @type {{getRelationshipByName: VelociousDatabaseRecord["getRelationshipByName"]}} */ (record)
153
151
  })
154
152
 
155
153
  return record
@@ -669,11 +667,7 @@ class VelociousDatabaseRecord {
669
667
  }
670
668
 
671
669
  let relationship
672
- const prototype = /**
673
- * Narrows the runtime value to the documented type.
674
- * @type {Record<string, ?>} */ (/**
675
- * Narrows the runtime value to the documented type.
676
- * @type {?} */ (this.prototype))
670
+ const prototype = /** @type {Record<string, ?>} */ (/** @type {?} */ (this.prototype))
677
671
 
678
672
  if (actualData.type == "belongsTo") {
679
673
  relationship = new BelongsToRelationship(actualData)
@@ -684,12 +678,8 @@ class VelociousDatabaseRecord {
684
678
  return relationship.loaded()
685
679
  }
686
680
 
687
- prototype[`build${inflection.camelize(relationshipName)}`] = function(/**
688
- * Narrows the runtime value to the documented type.
689
- * @type {Record<string, ?>} */ attributes) {
690
- return buildRelatedRecordWithInverse(/**
691
- * Narrows the runtime value to the documented type.
692
- * @type {VelociousDatabaseRecord} */ (this), relationshipName, attributes, true)
681
+ prototype[`build${inflection.camelize(relationshipName)}`] = function(/** @type {Record<string, ?>} */ attributes) {
682
+ return buildRelatedRecordWithInverse(/** @type {VelociousDatabaseRecord} */ (this), relationshipName, attributes, true)
693
683
  }
694
684
 
695
685
  prototype[`load${inflection.camelize(relationshipName)}`] = async function() {
@@ -700,9 +690,7 @@ class VelociousDatabaseRecord {
700
690
  return await this.relationshipOrLoad(relationshipName, {preloadTranslations: true})
701
691
  }
702
692
 
703
- prototype[`set${inflection.camelize(relationshipName)}`] = function(/**
704
- * Narrows the runtime value to the documented type.
705
- * @type {?} */ model) {
693
+ prototype[`set${inflection.camelize(relationshipName)}`] = function(/** @type {?} */ model) {
706
694
  const relationship = this.getRelationshipByName(relationshipName)
707
695
 
708
696
  relationship.setLoaded(model)
@@ -733,12 +721,8 @@ class VelociousDatabaseRecord {
733
721
  return this.getRelationshipByName(relationshipName).loaded()
734
722
  }
735
723
 
736
- prototype[`build${inflection.camelize(relationshipName)}`] = function(/**
737
- * Narrows the runtime value to the documented type.
738
- * @type {Record<string, ?>} */ attributes) {
739
- return buildRelatedRecordWithInverse(/**
740
- * Narrows the runtime value to the documented type.
741
- * @type {VelociousDatabaseRecord} */ (this), relationshipName, attributes, false)
724
+ prototype[`build${inflection.camelize(relationshipName)}`] = function(/** @type {Record<string, ?>} */ attributes) {
725
+ return buildRelatedRecordWithInverse(/** @type {VelociousDatabaseRecord} */ (this), relationshipName, attributes, false)
742
726
  }
743
727
 
744
728
  prototype[`load${inflection.camelize(relationshipName)}`] = async function() {
@@ -764,9 +748,7 @@ class VelociousDatabaseRecord {
764
748
  static _normalizeRelationshipArgs(scopeOrOptions, options) {
765
749
  if (typeof scopeOrOptions == "function") {
766
750
  return {
767
- scope: /**
768
- * Narrows the runtime value to the documented type.
769
- * @type {RelationshipScopeCallback} */ (scopeOrOptions),
751
+ scope: /** @type {RelationshipScopeCallback} */ (scopeOrOptions),
770
752
  relationshipOptions: options || {}
771
753
  }
772
754
  }
@@ -837,9 +819,7 @@ class VelociousDatabaseRecord {
837
819
  })
838
820
 
839
821
  ChildModel.beforeSave(async (record) => {
840
- const model = /**
841
- * Narrows the runtime value to the documented type.
842
- * @type {?} */ (record)
822
+ const model = /** @type {?} */ (record)
843
823
 
844
824
  if (model.isNewRecord()) return
845
825
 
@@ -856,9 +836,7 @@ class VelociousDatabaseRecord {
856
836
  })
857
837
 
858
838
  ChildModel.afterSave(async (record) => {
859
- const model = /**
860
- * Narrows the runtime value to the documented type.
861
- * @type {?} */ (record)
839
+ const model = /** @type {?} */ (record)
862
840
  const prevKey = `_counterCachePrev_${relationshipName}`
863
841
  const previousParentId = model[prevKey]
864
842
 
@@ -1128,9 +1106,7 @@ class VelociousDatabaseRecord {
1128
1106
 
1129
1107
  this._defineRelationship(relationshipName, Object.assign({type: "belongsTo", scope}, relationshipOptions))
1130
1108
 
1131
- if (/**
1132
- * Narrows the runtime value to the documented type.
1133
- * @type {?} */ (relationshipOptions)?.counterCache) {
1109
+ if (/** @type {?} */ (relationshipOptions)?.counterCache) {
1134
1110
  this._registerCounterCacheCallbacks(relationshipName)
1135
1111
  }
1136
1112
  }
@@ -1163,9 +1139,7 @@ class VelociousDatabaseRecord {
1163
1139
  static async create(attributes) {
1164
1140
  await this.ensureInitialized()
1165
1141
 
1166
- const record = /**
1167
- * Narrows the runtime value to the documented type.
1168
- * @type {Model} */ (new this(attributes))
1142
+ const record = /** @type {Model} */ (new this(attributes))
1169
1143
 
1170
1144
  await record.save()
1171
1145
 
@@ -1240,9 +1214,7 @@ class VelociousDatabaseRecord {
1240
1214
  this._acceptedNestedAttributes = {}
1241
1215
  }
1242
1216
 
1243
- /**
1244
- * Narrows the runtime value to the documented type.
1245
- * @type {Record<string, {allowDestroy?: boolean, limit?: number, rejectIf?: (attributes: Record<string, ?>) => boolean}>} */ (this._acceptedNestedAttributes)[relationshipName] = {...options}
1217
+ /** @type {Record<string, {allowDestroy?: boolean, limit?: number, rejectIf?: (attributes: Record<string, ?>) => boolean}>} */ (this._acceptedNestedAttributes)[relationshipName] = {...options}
1246
1218
  }
1247
1219
 
1248
1220
  /**
@@ -1281,19 +1253,13 @@ class VelociousDatabaseRecord {
1281
1253
 
1282
1254
  this.getAttachmentsMap()[attachmentName] = {driver, type}
1283
1255
 
1284
- const prototype = /**
1285
- * Narrows the runtime value to the documented type.
1286
- * @type {Record<string, ?>} */ (/**
1287
- * Narrows the runtime value to the documented type.
1288
- * @type {?} */ (this.prototype))
1256
+ const prototype = /** @type {Record<string, ?>} */ (/** @type {?} */ (this.prototype))
1289
1257
 
1290
1258
  prototype[attachmentName] = function() {
1291
1259
  return this.getAttachmentByName(attachmentName)
1292
1260
  }
1293
1261
 
1294
- prototype[`set${inflection.camelize(attachmentName)}`] = function(/**
1295
- * Narrows the runtime value to the documented type.
1296
- * @type {?} */ newValue) {
1262
+ prototype[`set${inflection.camelize(attachmentName)}`] = function(/** @type {?} */ newValue) {
1297
1263
  this.getAttachmentByName(attachmentName).queueAttach(newValue)
1298
1264
  return newValue
1299
1265
  }
@@ -1418,11 +1384,7 @@ class VelociousDatabaseRecord {
1418
1384
 
1419
1385
  const columnNameToAttributeName = this.getColumnNameToAttributeNameMap()
1420
1386
  const attributeNameToColumnName = this.getAttributeNameToColumnNameMap()
1421
- const prototype = /**
1422
- * Narrows the runtime value to the documented type.
1423
- * @type {Record<string, ?>} */ (/**
1424
- * Narrows the runtime value to the documented type.
1425
- * @type {?} */ (this.prototype))
1387
+ const prototype = /** @type {Record<string, ?>} */ (/** @type {?} */ (this.prototype))
1426
1388
 
1427
1389
  for (const column of this._columns) {
1428
1390
  this._columnsAsHash[column.getName()] = column
@@ -1441,20 +1403,14 @@ class VelociousDatabaseRecord {
1441
1403
  }
1442
1404
 
1443
1405
  if (!(`set${camelizedColumnNameBigFirst}` in prototype)) {
1444
- prototype[`set${camelizedColumnNameBigFirst}`] = function(/**
1445
- * Narrows the runtime value to the documented type.
1446
- * @type {?} */ newValue) {
1406
+ prototype[`set${camelizedColumnNameBigFirst}`] = function(/** @type {?} */ newValue) {
1447
1407
  return this._setColumnAttribute(camelizedColumnName, newValue)
1448
1408
  }
1449
1409
  }
1450
1410
 
1451
1411
  if (!(`has${camelizedColumnNameBigFirst}` in prototype)) {
1452
1412
  prototype[`has${camelizedColumnNameBigFirst}`] = function() {
1453
- const dynamicThis = /**
1454
- * Narrows the runtime value to the documented type.
1455
- * @type {Record<string, (...args: Array<?>) => ?>} */ (/**
1456
- * Narrows the runtime value to the documented type.
1457
- * @type {?} */ (this))
1413
+ const dynamicThis = /** @type {Record<string, (...args: Array<?>) => ?>} */ (/** @type {?} */ (this))
1458
1414
  const value = dynamicThis[camelizedColumnName]()
1459
1415
 
1460
1416
  return this._hasAttribute(value)
@@ -1548,11 +1504,7 @@ class VelociousDatabaseRecord {
1548
1504
  for (const name in this._translations) {
1549
1505
  const nameCamelized = inflection.camelize(name)
1550
1506
  const setterMethodName = `set${nameCamelized}`
1551
- const prototype = /**
1552
- * Narrows the runtime value to the documented type.
1553
- * @type {Record<string, ?>} */ (/**
1554
- * Narrows the runtime value to the documented type.
1555
- * @type {?} */ (this.prototype))
1507
+ const prototype = /** @type {Record<string, ?>} */ (/** @type {?} */ (this.prototype))
1556
1508
 
1557
1509
  prototype[name] = function getTranslatedAttribute() {
1558
1510
  const locale = this._getConfiguration().getLocale()
@@ -1561,11 +1513,7 @@ class VelociousDatabaseRecord {
1561
1513
  }
1562
1514
 
1563
1515
  prototype[`has${nameCamelized}`] = function hasTranslatedAttribute() {
1564
- const dynamicThis = /**
1565
- * Narrows the runtime value to the documented type.
1566
- * @type {Record<string, ?>} */ (/**
1567
- * Narrows the runtime value to the documented type.
1568
- * @type {?} */ (this))
1516
+ const dynamicThis = /** @type {Record<string, ?>} */ (/** @type {?} */ (this))
1569
1517
  const candidate = dynamicThis[name]
1570
1518
 
1571
1519
  if (typeof candidate == "function") {
@@ -1577,9 +1525,7 @@ class VelociousDatabaseRecord {
1577
1525
  }
1578
1526
  }
1579
1527
 
1580
- prototype[setterMethodName] = function setTranslatedAttribute(/**
1581
- * Narrows the runtime value to the documented type.
1582
- * @type {?} */ newValue) {
1528
+ prototype[setterMethodName] = function setTranslatedAttribute(/** @type {?} */ newValue) {
1583
1529
  const locale = this._getConfiguration().getLocale()
1584
1530
 
1585
1531
  return this._setTranslatedAttribute(name, locale, newValue)
@@ -1595,18 +1541,12 @@ class VelociousDatabaseRecord {
1595
1541
  return this._getTranslatedAttribute(name, locale)
1596
1542
  }
1597
1543
 
1598
- prototype[setterMethodNameLocalized] = function setTranslatedAttributeWithLocale(/**
1599
- * Narrows the runtime value to the documented type.
1600
- * @type {?} */ newValue) {
1544
+ prototype[setterMethodNameLocalized] = function setTranslatedAttributeWithLocale(/** @type {?} */ newValue) {
1601
1545
  return this._setTranslatedAttribute(name, locale, newValue)
1602
1546
  }
1603
1547
 
1604
1548
  prototype[hasMethodNameLocalized] = function hasTranslatedAttribute() {
1605
- const dynamicThis = /**
1606
- * Narrows the runtime value to the documented type.
1607
- * @type {Record<string, ?>} */ (/**
1608
- * Narrows the runtime value to the documented type.
1609
- * @type {?} */ (this))
1549
+ const dynamicThis = /** @type {Record<string, ?>} */ (/** @type {?} */ (this))
1610
1550
  const candidate = dynamicThis[getterMethodNameLocalized]
1611
1551
 
1612
1552
  if (typeof candidate == "function") {
@@ -1728,9 +1668,7 @@ class VelociousDatabaseRecord {
1728
1668
  * @returns {typeof VelociousDatabaseRecord} - The model class.
1729
1669
  */
1730
1670
  getModelClass() {
1731
- const modelClass = /**
1732
- * Narrows the runtime value to the documented type.
1733
- * @type {typeof VelociousDatabaseRecord} */ (this.constructor)
1671
+ const modelClass = /** @type {typeof VelociousDatabaseRecord} */ (this.constructor)
1734
1672
 
1735
1673
  return modelClass
1736
1674
  }
@@ -1747,11 +1685,7 @@ class VelociousDatabaseRecord {
1747
1685
  const canonicalName = this.getModelClass().resolveAttributeName(name) ?? name
1748
1686
  const requestedSetterName = `set${inflection.camelize(canonicalName)}`
1749
1687
  const setterName = this.getModelClass().findMemberNameInsensitive(this, requestedSetterName)
1750
- const dynamicThis = /**
1751
- * Narrows the runtime value to the documented type.
1752
- * @type {Record<string, (value: ?) => void>} */ (/**
1753
- * Narrows the runtime value to the documented type.
1754
- * @type {?} */ (this))
1688
+ const dynamicThis = /** @type {Record<string, (value: ?) => void>} */ (/** @type {?} */ (this))
1755
1689
 
1756
1690
  this.getModelClass()._assertHasBeenInitialized()
1757
1691
  if (!this.getModelClass().isInitialized()) throw new Error(`${this.constructor.name} model isn't initialized yet`)
@@ -2910,9 +2844,7 @@ class VelociousDatabaseRecord {
2910
2844
  * @type {Record<string, ?>} */
2911
2845
  const dict = translation
2912
2846
 
2913
- const attributeMethod = /**
2914
- * Narrows the runtime value to the documented type.
2915
- * @type {function() : string | undefined} */ (dict[name])
2847
+ const attributeMethod = /** @type {function() : string | undefined} */ (dict[name])
2916
2848
 
2917
2849
  if (typeof attributeMethod == "function") {
2918
2850
  return attributeMethod.bind(translation)()
@@ -3260,9 +3192,7 @@ class VelociousDatabaseRecord {
3260
3192
  * @returns {ModelClassQuery<MC>} - The preload.
3261
3193
  */
3262
3194
  static preload(preload) {
3263
- const query = /**
3264
- * Narrows the runtime value to the documented type.
3265
- * @type {ModelClassQuery<MC>} */ (this._newQuery().preload(preload))
3195
+ const query = /** @type {ModelClassQuery<MC>} */ (this._newQuery().preload(preload))
3266
3196
 
3267
3197
  return query
3268
3198
  }
@@ -3410,9 +3340,7 @@ class VelociousDatabaseRecord {
3410
3340
 
3411
3341
  for (const relationship of this.getModelClass().getRelationships()) {
3412
3342
  if (relationship.getDependent() == "restrict") {
3413
- const instanceRelationship = /**
3414
- * Narrows the runtime value to the documented type.
3415
- * @type {?} */ (this.getRelationshipByName(relationship.getRelationshipName()))
3343
+ const instanceRelationship = /** @type {?} */ (this.getRelationshipByName(relationship.getRelationshipName()))
3416
3344
  const count = await instanceRelationship.query().count()
3417
3345
 
3418
3346
  if (count > 0) {
@@ -3498,11 +3426,7 @@ class VelociousDatabaseRecord {
3498
3426
  if (callback == callbackName) {
3499
3427
  callbackNameRegisteredAsString = true
3500
3428
  }
3501
- const dynamicThis = /**
3502
- * Narrows the runtime value to the documented type.
3503
- * @type {Record<string, ?>} */ (/**
3504
- * Narrows the runtime value to the documented type.
3505
- * @type {?} */ (this))
3429
+ const dynamicThis = /** @type {Record<string, ?>} */ (/** @type {?} */ (this))
3506
3430
  const methodCallback = dynamicThis[callback]
3507
3431
 
3508
3432
  if (typeof methodCallback != "function") {
@@ -3515,11 +3439,7 @@ class VelociousDatabaseRecord {
3515
3439
  }
3516
3440
  }
3517
3441
 
3518
- const dynamicThis = /**
3519
- * Narrows the runtime value to the documented type.
3520
- * @type {Record<string, ?>} */ (/**
3521
- * Narrows the runtime value to the documented type.
3522
- * @type {?} */ (this))
3442
+ const dynamicThis = /** @type {Record<string, ?>} */ (/** @type {?} */ (this))
3523
3443
  const instanceCallback = dynamicThis[callbackName]
3524
3444
 
3525
3445
  if (!callbackNameRegisteredAsString && typeof instanceCallback === "function") {
@@ -3623,11 +3543,7 @@ class VelociousDatabaseRecord {
3623
3543
  * @returns {number}
3624
3544
  */
3625
3545
  readCount(attributeName) {
3626
- return readPayloadAssociationCount(/**
3627
- * Narrows the runtime value to the documented type.
3628
- * @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
3629
- * Narrows the runtime value to the documented type.
3630
- * @type {?} */ (this)), attributeName)
3546
+ return readPayloadAssociationCount(/** @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/** @type {?} */ (this)), attributeName)
3631
3547
  }
3632
3548
 
3633
3549
  /**
@@ -3638,11 +3554,7 @@ class VelociousDatabaseRecord {
3638
3554
  * @returns {void}
3639
3555
  */
3640
3556
  _setAssociationCount(attributeName, value) {
3641
- setPayloadAssociationCount(/**
3642
- * Narrows the runtime value to the documented type.
3643
- * @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
3644
- * Narrows the runtime value to the documented type.
3645
- * @type {?} */ (this)), attributeName, value)
3557
+ setPayloadAssociationCount(/** @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/** @type {?} */ (this)), attributeName, value)
3646
3558
  }
3647
3559
 
3648
3560
  /**
@@ -3657,11 +3569,7 @@ class VelociousDatabaseRecord {
3657
3569
  * @type {Record<string, number>} */
3658
3570
  const result = {}
3659
3571
 
3660
- const target = /**
3661
- * Narrows the runtime value to the documented type.
3662
- * @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
3663
- * Narrows the runtime value to the documented type.
3664
- * @type {?} */ (this))
3572
+ const target = /** @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/** @type {?} */ (this))
3665
3573
 
3666
3574
  if (!target._associationCounts) return result
3667
3575
 
@@ -3683,11 +3591,7 @@ class VelociousDatabaseRecord {
3683
3591
  * @returns {?}
3684
3592
  */
3685
3593
  queryData(name) {
3686
- return readPayloadQueryData(/**
3687
- * Narrows the runtime value to the documented type.
3688
- * @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
3689
- * Narrows the runtime value to the documented type.
3690
- * @type {?} */ (this)), name)
3594
+ return readPayloadQueryData(/** @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/** @type {?} */ (this)), name)
3691
3595
  }
3692
3596
 
3693
3597
  /**
@@ -3699,11 +3603,7 @@ class VelociousDatabaseRecord {
3699
3603
  * @returns {void}
3700
3604
  */
3701
3605
  _setQueryData(name, value) {
3702
- setPayloadQueryData(/**
3703
- * Narrows the runtime value to the documented type.
3704
- * @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
3705
- * Narrows the runtime value to the documented type.
3706
- * @type {?} */ (this)), name, value)
3606
+ setPayloadQueryData(/** @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/** @type {?} */ (this)), name, value)
3707
3607
  }
3708
3608
 
3709
3609
  /**
@@ -3718,11 +3618,7 @@ class VelociousDatabaseRecord {
3718
3618
  * @type {Record<string, ?>} */
3719
3619
  const result = {}
3720
3620
 
3721
- const target = /**
3722
- * Narrows the runtime value to the documented type.
3723
- * @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
3724
- * Narrows the runtime value to the documented type.
3725
- * @type {?} */ (this))
3621
+ const target = /** @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/** @type {?} */ (this))
3726
3622
 
3727
3623
  if (!target._queryDataValues) return result
3728
3624
 
@@ -3745,11 +3641,7 @@ class VelociousDatabaseRecord {
3745
3641
  * @returns {boolean}
3746
3642
  */
3747
3643
  can(action) {
3748
- return readPayloadComputedAbility(/**
3749
- * Narrows the runtime value to the documented type.
3750
- * @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
3751
- * Narrows the runtime value to the documented type.
3752
- * @type {?} */ (this)), action)
3644
+ return readPayloadComputedAbility(/** @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/** @type {?} */ (this)), action)
3753
3645
  }
3754
3646
 
3755
3647
  /**
@@ -3761,11 +3653,7 @@ class VelociousDatabaseRecord {
3761
3653
  * @returns {void}
3762
3654
  */
3763
3655
  _setComputedAbility(action, value) {
3764
- setPayloadComputedAbility(/**
3765
- * Narrows the runtime value to the documented type.
3766
- * @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
3767
- * Narrows the runtime value to the documented type.
3768
- * @type {?} */ (this)), action, value)
3656
+ setPayloadComputedAbility(/** @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/** @type {?} */ (this)), action, value)
3769
3657
  }
3770
3658
 
3771
3659
  /**
@@ -3780,11 +3668,7 @@ class VelociousDatabaseRecord {
3780
3668
  * @type {Record<string, boolean>} */
3781
3669
  const result = {}
3782
3670
 
3783
- const target = /**
3784
- * Narrows the runtime value to the documented type.
3785
- * @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
3786
- * Narrows the runtime value to the documented type.
3787
- * @type {?} */ (this))
3671
+ const target = /** @type {import("../../record-payload-values.js").RecordPayloadValuesTarget} */ (/** @type {?} */ (this))
3788
3672
 
3789
3673
  if (!target._computedAbilities) return result
3790
3674
 
@@ -3957,7 +3841,7 @@ class VelociousDatabaseRecord {
3957
3841
  })
3958
3842
  const insertResult = await this._connection().query(sql, {logName: `${this.getModelClass().name} Create`})
3959
3843
 
3960
- await this._applyInsertResult({data, insertResult, primaryKey, primaryKeyType})
3844
+ await this._applyInsertResult({data, insertResult, primaryKey})
3961
3845
  this.setIsNewRecord(false)
3962
3846
 
3963
3847
  this._markLoadedRelationshipsPreloadedAfterCreate()
@@ -3983,21 +3867,25 @@ class VelociousDatabaseRecord {
3983
3867
 
3984
3868
  /**
3985
3869
  * Applies the database insert response to this record.
3986
- * @param {object} options - Insert result options.
3987
- * @param {Record<string, ?>} options.data - Inserted data.
3988
- * @param {?} options.insertResult - Result returned from the connection.
3989
- * @param {string} options.primaryKey - Primary key column name.
3990
- * @param {string | undefined} options.primaryKeyType - Primary key column type.
3870
+ * @param {{data: Record<string, string | number | boolean | Date | null | undefined>, insertResult: Array<Record<string, string | number | boolean | Date | null | undefined>> | null | undefined, primaryKey: string}} options - Inserted data, connection result, and primary key column name.
3991
3871
  * @returns {Promise<void>} - Resolves when complete.
3992
3872
  */
3993
- async _applyInsertResult({data, insertResult, primaryKey, primaryKeyType}) {
3873
+ async _applyInsertResult({data, insertResult, primaryKey}) {
3994
3874
  if (Array.isArray(insertResult) && insertResult[0] && insertResult[0][primaryKey]) {
3995
3875
  this._attributes = insertResult[0]
3996
3876
  this._changes = {}
3997
- } else if (primaryKeyType == "uuid" && data[primaryKey] !== undefined) {
3998
- this._attributes = Object.assign({}, data)
3999
- this._changes = {}
4000
3877
  } else {
3878
+ const primaryKeyValue = data[primaryKey]
3879
+
3880
+ if (primaryKeyValue !== undefined && primaryKeyValue !== null && primaryKeyValue !== "") {
3881
+ if (typeof primaryKeyValue != "string" && typeof primaryKeyValue != "number") {
3882
+ throw new Error(`Inserted primary key ${primaryKey} must be a string or number, got ${typeof primaryKeyValue}`)
3883
+ }
3884
+
3885
+ await this._reloadWithId(primaryKeyValue)
3886
+ return
3887
+ }
3888
+
4001
3889
  const id = await this._connection().lastInsertID()
4002
3890
 
4003
3891
  await this._reloadWithId(id)
@@ -4127,9 +4015,7 @@ class VelociousDatabaseRecord {
4127
4015
 
4128
4016
  whereObject[primaryKey] = id
4129
4017
 
4130
- const query = /**
4131
- * Narrows the runtime value to the documented type.
4132
- * @type {import("../query/model-class-query.js").default<MC>} */ (this.getModelClass().where(whereObject))
4018
+ const query = /** @type {import("../query/model-class-query.js").default<MC>} */ (this.getModelClass().where(whereObject))
4133
4019
  const reloadedModel = await query.first()
4134
4020
 
4135
4021
  if (!reloadedModel) throw new Error(`${this.constructor.name}#${id} couldn't be reloaded - record didn't exist`)
@@ -4144,9 +4030,7 @@ class VelociousDatabaseRecord {
4144
4030
  * @returns {Promise<void>} - Resolves when complete.
4145
4031
  */
4146
4032
  async reload() {
4147
- const recordId = /**
4148
- * Narrows the runtime value to the documented type.
4149
- * @type {string | number} */ (this.readAttribute("id"))
4033
+ const recordId = /** @type {string | number} */ (this.readAttribute("id"))
4150
4034
  await this._reloadWithId(recordId)
4151
4035
  }
4152
4036
 
@@ -126,20 +126,14 @@ export default class VelociousDatabaseRecordBaseInstanceRelationship {
126
126
  async _tryCohortPreload() {
127
127
  const relationshipDef = this.getRelationship()
128
128
  const configuration = relationshipDef.getConfiguration()
129
- const cohort = /**
130
- * Narrows the runtime value to the documented type.
131
- * @type {Array<import("../index.js").default> | undefined} */ (/**
132
- * Narrows the runtime value to the documented type.
133
- * @type {?} */ (this.model)._loadCohort)
129
+ const cohort = /** @type {Array<import("../index.js").default> | undefined} */ (/** @type {?} */ (this.model)._loadCohort)
134
130
 
135
131
  if (!configuration.getAutoload() || !relationshipDef.getAutoload() || !cohort || cohort.length <= 1) {
136
132
  return false
137
133
  }
138
134
 
139
135
  const relationshipName = relationshipDef.getRelationshipName()
140
- const OwnerModelClass = /**
141
- * Narrows the runtime value to the documented type.
142
- * @type {?} */ (this.model).constructor
136
+ const OwnerModelClass = /** @type {?} */ (this.model).constructor
143
137
  /**
144
138
  * Batch.
145
139
  * @type {Array<import("../index.js").default>} */
@@ -166,23 +160,17 @@ export default class VelociousDatabaseRecordBaseInstanceRelationship {
166
160
  const type = relationshipDef.getType()
167
161
 
168
162
  if (type == "belongsTo") {
169
- const belongsToRelationship = /**
170
- * Narrows the runtime value to the documented type.
171
- * @type {import("../relationships/belongs-to.js").default} */ (relationshipDef)
163
+ const belongsToRelationship = /** @type {import("../relationships/belongs-to.js").default} */ (relationshipDef)
172
164
  const preloader = new BelongsToPreloader({models: batch, relationship: belongsToRelationship})
173
165
 
174
166
  await preloader.run()
175
167
  } else if (type == "hasMany") {
176
- const hasManyRelationship = /**
177
- * Narrows the runtime value to the documented type.
178
- * @type {import("../relationships/has-many.js").default} */ (relationshipDef)
168
+ const hasManyRelationship = /** @type {import("../relationships/has-many.js").default} */ (relationshipDef)
179
169
  const preloader = new HasManyPreloader({models: batch, relationship: hasManyRelationship})
180
170
 
181
171
  await preloader.run()
182
172
  } else if (type == "hasOne") {
183
- const hasOneRelationship = /**
184
- * Narrows the runtime value to the documented type.
185
- * @type {import("../relationships/has-one.js").default} */ (relationshipDef)
173
+ const hasOneRelationship = /** @type {import("../relationships/has-one.js").default} */ (relationshipDef)
186
174
  const preloader = new HasOnePreloader({models: batch, relationship: hasOneRelationship})
187
175
 
188
176
  await preloader.run()
@@ -274,9 +262,7 @@ export default class VelociousDatabaseRecordBaseInstanceRelationship {
274
262
  * @returns {TMC | undefined} The model class that this instance relationship
275
263
  */
276
264
  getTargetModelClass() {
277
- const TargetModelClass = /**
278
- * Narrows the runtime value to the documented type.
279
- * @type {TMC} */ (this.getRelationship().getTargetModelClass())
265
+ const TargetModelClass = /** @type {TMC} */ (this.getRelationship().getTargetModelClass())
280
266
 
281
267
  return TargetModelClass
282
268
  }
@@ -23,15 +23,11 @@ export default class VelociousDatabaseRecordBelongsToInstanceRelationship extend
23
23
  * @returns {InstanceType<TMC>} - The build.
24
24
  */
25
25
  build(data) {
26
- const TargetModelClass = /**
27
- * Narrows the runtime value to the documented type.
28
- * @type {TMC} */ (this.getTargetModelClass())
26
+ const TargetModelClass = /** @type {TMC} */ (this.getTargetModelClass())
29
27
 
30
28
  if (!TargetModelClass) throw new Error("Can't build a new record without a target model")
31
29
 
32
- const newInstance = /**
33
- * Narrows the runtime value to the documented type.
34
- * @type {InstanceType<TMC>} */ (new TargetModelClass(data))
30
+ const newInstance = /** @type {InstanceType<TMC>} */ (new TargetModelClass(data))
35
31
 
36
32
  this._loaded = newInstance
37
33
 
@@ -29,9 +29,7 @@ export default class VelociousDatabaseRecordHasManyInstanceRelationship extends
29
29
 
30
30
  if (!targetModelClass) throw new Error("Can't build a new record without a taget model class")
31
31
 
32
- const newInstance = /**
33
- * Narrows the runtime value to the documented type.
34
- * @type {InstanceType<TMC>} */ (new targetModelClass(data))
32
+ const newInstance = /** @type {InstanceType<TMC>} */ (new targetModelClass(data))
35
33
 
36
34
 
37
35
  // Add it to the loaded models of this relationship
@@ -112,9 +110,7 @@ export default class VelociousDatabaseRecordHasManyInstanceRelationship extends
112
110
  return /** @type {InstanceType<TMC>[]} */ (Array.isArray(this._loaded) ? this._loaded : [])
113
111
  }
114
112
 
115
- const foreignModels = /**
116
- * Narrows the runtime value to the documented type.
117
- * @type {InstanceType<TMC>[]} */ (await this.query().load())
113
+ const foreignModels = /** @type {InstanceType<TMC>[]} */ (await this.query().load())
118
114
 
119
115
  this.setLoaded(foreignModels)
120
116
  this.setDirty(false)
@@ -202,9 +198,7 @@ export default class VelociousDatabaseRecordHasManyInstanceRelationship extends
202
198
  const throughTable = throughModelClass.tableName()
203
199
  const driver = TargetModelClass.connection()
204
200
  const parentPrimaryKey = this.getPrimaryKey()
205
- const parentId = /**
206
- * Narrows the runtime value to the documented type.
207
- * @type {string | number} */ (this.getModel().readColumn(parentPrimaryKey))
201
+ const parentId = /** @type {string | number} */ (this.getModel().readColumn(parentPrimaryKey))
208
202
  const joinSql = `LEFT JOIN ${driver.quoteTable(throughTable)} ON ${driver.quoteTable(throughTable)}.${driver.quoteColumn(throughPrimaryKey)} = ${driver.quoteTable(targetTable)}.${driver.quoteColumn(targetForeignKey)}`
209
203
  const whereSql = `${driver.quoteTable(throughTable)}.${driver.quoteColumn(throughForeignKey)} = ${driver.options().quote(parentId)}`
210
204
 
@@ -215,9 +209,7 @@ export default class VelociousDatabaseRecordHasManyInstanceRelationship extends
215
209
 
216
210
  const foreignKey = this.getForeignKey()
217
211
  const primaryKey = this.getPrimaryKey()
218
- const primaryModelID = /**
219
- * Narrows the runtime value to the documented type.
220
- * @type {string | number} */ (this.getModel().readColumn(primaryKey))
212
+ const primaryModelID = /** @type {string | number} */ (this.getModel().readColumn(primaryKey))
221
213
 
222
214
  /**
223
215
  * Where args.