velocious 1.0.460 → 1.0.462

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/README.md +1 -1
  2. package/build/application.js +1 -3
  3. package/build/background-jobs/cron-expression.js +1 -3
  4. package/build/background-jobs/forked-runner-child.js +1 -3
  5. package/build/background-jobs/job.js +1 -3
  6. package/build/background-jobs/scheduler.js +2 -6
  7. package/build/background-jobs/store.js +2 -6
  8. package/build/background-jobs/web/controller.js +1 -3
  9. package/build/background-jobs/worker.js +1 -3
  10. package/build/beacon/client.js +2 -6
  11. package/build/cli/tenant-database-command-helper.js +1 -3
  12. package/build/configuration.js +29 -32
  13. package/build/controller.js +4 -14
  14. package/build/current.js +2 -2
  15. package/build/database/drivers/mssql/index.js +1 -3
  16. package/build/database/drivers/mysql/index.js +2 -6
  17. package/build/database/drivers/pgsql/index.js +1 -3
  18. package/build/database/drivers/sqlite/base.js +3 -9
  19. package/build/database/drivers/sqlite/index.js +3 -9
  20. package/build/database/drivers/sqlite/table.js +1 -3
  21. package/build/database/migrator.js +1 -3
  22. package/build/database/pool/async-tracked-multi-connection.js +20 -45
  23. package/build/database/pool/base-methods-forward.js +2 -10
  24. package/build/database/pool/base.js +5 -15
  25. package/build/database/query/index.js +4 -12
  26. package/build/database/query/join-object.js +3 -9
  27. package/build/database/query/model-class-query.js +21 -63
  28. package/build/database/query/preloader/belongs-to.js +9 -27
  29. package/build/database/query/preloader/has-many.js +7 -21
  30. package/build/database/query/preloader/has-one.js +3 -9
  31. package/build/database/query/preloader.js +6 -18
  32. package/build/database/query/query-data.js +5 -15
  33. package/build/database/query/where-model-class-hash.js +5 -15
  34. package/build/database/query/with-count.js +5 -15
  35. package/build/database/record/acts-as-list.js +10 -38
  36. package/build/database/record/attachments/normalize-input.js +7 -25
  37. package/build/database/record/attachments/storage-drivers/s3.js +4 -12
  38. package/build/database/record/attachments/store.js +2 -6
  39. package/build/database/record/index.js +56 -172
  40. package/build/database/record/instance-relationships/base.js +6 -20
  41. package/build/database/record/instance-relationships/belongs-to.js +2 -6
  42. package/build/database/record/instance-relationships/has-many.js +4 -12
  43. package/build/database/record/instance-relationships/has-one.js +4 -12
  44. package/build/database/record/relationships/base.js +1 -5
  45. package/build/database/record/validators/presence.js +1 -3
  46. package/build/database/record/validators/uniqueness.js +4 -12
  47. package/build/environment-handlers/browser.js +1 -3
  48. package/build/environment-handlers/node/cli/commands/console.js +2 -6
  49. package/build/environment-handlers/node/cli/commands/db/schema/load.js +1 -3
  50. package/build/environment-handlers/node/cli/commands/generate/frontend-models.js +67 -11
  51. package/build/environment-handlers/node.js +15 -6
  52. package/build/frontend-model-controller.js +34 -110
  53. package/build/frontend-models/base.js +45 -151
  54. package/build/frontend-models/clear-pending-debounced-callback.js +1 -3
  55. package/build/frontend-models/preloader.js +3 -9
  56. package/build/frontend-models/query.js +11 -33
  57. package/build/frontend-models/resource-definition.js +2 -6
  58. package/build/frontend-models/transport-serialization.js +7 -21
  59. package/build/frontend-models/use-destroyed-event.js +2 -6
  60. package/build/frontend-models/use-model-class-event.js +2 -6
  61. package/build/frontend-models/use-updated-event.js +3 -9
  62. package/build/frontend-models/websocket-channel.js +9 -27
  63. package/build/frontend-models/websocket-publishers.js +12 -23
  64. package/build/http-server/client/index.js +6 -18
  65. package/build/http-server/client/params-to-object.js +6 -18
  66. package/build/http-server/client/request-buffer/index.js +1 -3
  67. package/build/http-server/client/request-parser.js +1 -3
  68. package/build/http-server/client/request-runner.js +4 -12
  69. package/build/http-server/client/websocket-session.js +6 -18
  70. package/build/http-server/development-reloader.js +2 -6
  71. package/build/http-server/remote-address.js +1 -5
  72. package/build/http-server/server-client.js +3 -9
  73. package/build/http-server/server-lock.js +2 -6
  74. package/build/http-server/websocket-channel-subscribers.js +2 -6
  75. package/build/http-server/websocket-event-log-store.js +5 -15
  76. package/build/http-server/websocket-events-host.js +1 -3
  77. package/build/http-server/worker-handler/in-process.js +3 -11
  78. package/build/http-server/worker-handler/worker-thread.js +1 -3
  79. package/build/logger.js +2 -6
  80. package/build/mailer/backends/smtp.js +1 -5
  81. package/build/mailer/base.js +4 -16
  82. package/build/plugins/sqljs-wasm-route-controller.js +1 -3
  83. package/build/routes/basic-route.js +1 -3
  84. package/build/routes/resolver.js +4 -14
  85. package/build/src/application.d.ts.map +1 -1
  86. package/build/src/application.js +2 -4
  87. package/build/src/background-jobs/cron-expression.d.ts.map +1 -1
  88. package/build/src/background-jobs/cron-expression.js +2 -4
  89. package/build/src/background-jobs/forked-runner-child.js +2 -4
  90. package/build/src/background-jobs/job.d.ts.map +1 -1
  91. package/build/src/background-jobs/job.js +2 -4
  92. package/build/src/background-jobs/scheduler.d.ts.map +1 -1
  93. package/build/src/background-jobs/scheduler.js +3 -7
  94. package/build/src/background-jobs/store.d.ts.map +1 -1
  95. package/build/src/background-jobs/store.js +3 -7
  96. package/build/src/background-jobs/web/controller.d.ts.map +1 -1
  97. package/build/src/background-jobs/web/controller.js +2 -5
  98. package/build/src/background-jobs/worker.d.ts.map +1 -1
  99. package/build/src/background-jobs/worker.js +2 -4
  100. package/build/src/beacon/client.d.ts.map +1 -1
  101. package/build/src/beacon/client.js +3 -7
  102. package/build/src/cli/tenant-database-command-helper.d.ts.map +1 -1
  103. package/build/src/cli/tenant-database-command-helper.js +2 -4
  104. package/build/src/configuration.d.ts.map +1 -1
  105. package/build/src/configuration.js +27 -35
  106. package/build/src/controller.d.ts.map +1 -1
  107. package/build/src/controller.js +5 -15
  108. package/build/src/current.d.ts +4 -4
  109. package/build/src/current.d.ts.map +1 -1
  110. package/build/src/current.js +3 -3
  111. package/build/src/database/drivers/mssql/index.d.ts.map +1 -1
  112. package/build/src/database/drivers/mssql/index.js +2 -4
  113. package/build/src/database/drivers/mysql/index.d.ts.map +1 -1
  114. package/build/src/database/drivers/mysql/index.js +3 -7
  115. package/build/src/database/drivers/pgsql/index.d.ts.map +1 -1
  116. package/build/src/database/drivers/pgsql/index.js +2 -4
  117. package/build/src/database/drivers/sqlite/base.d.ts.map +1 -1
  118. package/build/src/database/drivers/sqlite/base.js +4 -10
  119. package/build/src/database/drivers/sqlite/index.d.ts.map +1 -1
  120. package/build/src/database/drivers/sqlite/index.js +4 -10
  121. package/build/src/database/drivers/sqlite/table.d.ts.map +1 -1
  122. package/build/src/database/drivers/sqlite/table.js +2 -4
  123. package/build/src/database/migrator.d.ts.map +1 -1
  124. package/build/src/database/migrator.js +2 -4
  125. package/build/src/database/pool/async-tracked-multi-connection.d.ts.map +1 -1
  126. package/build/src/database/pool/async-tracked-multi-connection.js +21 -47
  127. package/build/src/database/pool/base-methods-forward.d.ts.map +1 -1
  128. package/build/src/database/pool/base-methods-forward.js +3 -11
  129. package/build/src/database/pool/base.d.ts.map +1 -1
  130. package/build/src/database/pool/base.js +6 -16
  131. package/build/src/database/query/index.d.ts.map +1 -1
  132. package/build/src/database/query/index.js +5 -13
  133. package/build/src/database/query/join-object.d.ts.map +1 -1
  134. package/build/src/database/query/join-object.js +4 -10
  135. package/build/src/database/query/model-class-query.d.ts.map +1 -1
  136. package/build/src/database/query/model-class-query.js +22 -64
  137. package/build/src/database/query/preloader/belongs-to.d.ts.map +1 -1
  138. package/build/src/database/query/preloader/belongs-to.js +10 -28
  139. package/build/src/database/query/preloader/has-many.d.ts.map +1 -1
  140. package/build/src/database/query/preloader/has-many.js +8 -22
  141. package/build/src/database/query/preloader/has-one.d.ts.map +1 -1
  142. package/build/src/database/query/preloader/has-one.js +4 -10
  143. package/build/src/database/query/preloader.d.ts.map +1 -1
  144. package/build/src/database/query/preloader.js +7 -20
  145. package/build/src/database/query/query-data.d.ts.map +1 -1
  146. package/build/src/database/query/query-data.js +6 -16
  147. package/build/src/database/query/where-model-class-hash.d.ts.map +1 -1
  148. package/build/src/database/query/where-model-class-hash.js +6 -16
  149. package/build/src/database/query/with-count.d.ts.map +1 -1
  150. package/build/src/database/query/with-count.js +6 -17
  151. package/build/src/database/record/acts-as-list.d.ts.map +1 -1
  152. package/build/src/database/record/acts-as-list.js +11 -47
  153. package/build/src/database/record/attachments/normalize-input.d.ts.map +1 -1
  154. package/build/src/database/record/attachments/normalize-input.js +8 -30
  155. package/build/src/database/record/attachments/storage-drivers/s3.d.ts.map +1 -1
  156. package/build/src/database/record/attachments/storage-drivers/s3.js +5 -13
  157. package/build/src/database/record/attachments/store.d.ts.map +1 -1
  158. package/build/src/database/record/attachments/store.js +3 -7
  159. package/build/src/database/record/index.d.ts +6 -11
  160. package/build/src/database/record/index.d.ts.map +1 -1
  161. package/build/src/database/record/index.js +54 -174
  162. package/build/src/database/record/instance-relationships/base.d.ts.map +1 -1
  163. package/build/src/database/record/instance-relationships/base.js +7 -21
  164. package/build/src/database/record/instance-relationships/belongs-to.d.ts.map +1 -1
  165. package/build/src/database/record/instance-relationships/belongs-to.js +3 -7
  166. package/build/src/database/record/instance-relationships/has-many.d.ts.map +1 -1
  167. package/build/src/database/record/instance-relationships/has-many.js +5 -13
  168. package/build/src/database/record/instance-relationships/has-one.d.ts.map +1 -1
  169. package/build/src/database/record/instance-relationships/has-one.js +5 -13
  170. package/build/src/database/record/relationships/base.d.ts.map +1 -1
  171. package/build/src/database/record/relationships/base.js +2 -6
  172. package/build/src/database/record/validators/presence.d.ts.map +1 -1
  173. package/build/src/database/record/validators/presence.js +2 -4
  174. package/build/src/database/record/validators/uniqueness.d.ts.map +1 -1
  175. package/build/src/database/record/validators/uniqueness.js +5 -14
  176. package/build/src/environment-handlers/browser.d.ts.map +1 -1
  177. package/build/src/environment-handlers/browser.js +2 -4
  178. package/build/src/environment-handlers/node/cli/commands/console.d.ts.map +1 -1
  179. package/build/src/environment-handlers/node/cli/commands/console.js +3 -7
  180. package/build/src/environment-handlers/node/cli/commands/db/schema/load.d.ts.map +1 -1
  181. package/build/src/environment-handlers/node/cli/commands/db/schema/load.js +2 -4
  182. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +38 -0
  183. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts.map +1 -1
  184. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.js +58 -12
  185. package/build/src/environment-handlers/node.d.ts.map +1 -1
  186. package/build/src/environment-handlers/node.js +16 -7
  187. package/build/src/frontend-model-controller.d.ts.map +1 -1
  188. package/build/src/frontend-model-controller.js +35 -114
  189. package/build/src/frontend-models/base.d.ts.map +1 -1
  190. package/build/src/frontend-models/base.js +46 -158
  191. package/build/src/frontend-models/clear-pending-debounced-callback.d.ts.map +1 -1
  192. package/build/src/frontend-models/clear-pending-debounced-callback.js +2 -4
  193. package/build/src/frontend-models/preloader.d.ts.map +1 -1
  194. package/build/src/frontend-models/preloader.js +4 -11
  195. package/build/src/frontend-models/query.d.ts.map +1 -1
  196. package/build/src/frontend-models/query.js +12 -34
  197. package/build/src/frontend-models/resource-definition.d.ts.map +1 -1
  198. package/build/src/frontend-models/resource-definition.js +3 -7
  199. package/build/src/frontend-models/transport-serialization.d.ts.map +1 -1
  200. package/build/src/frontend-models/transport-serialization.js +8 -23
  201. package/build/src/frontend-models/use-destroyed-event.js +3 -7
  202. package/build/src/frontend-models/use-model-class-event.d.ts.map +1 -1
  203. package/build/src/frontend-models/use-model-class-event.js +3 -7
  204. package/build/src/frontend-models/use-updated-event.d.ts.map +1 -1
  205. package/build/src/frontend-models/use-updated-event.js +4 -10
  206. package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
  207. package/build/src/frontend-models/websocket-channel.js +10 -32
  208. package/build/src/frontend-models/websocket-publishers.d.ts.map +1 -1
  209. package/build/src/frontend-models/websocket-publishers.js +14 -25
  210. package/build/src/http-server/client/index.d.ts.map +1 -1
  211. package/build/src/http-server/client/index.js +7 -21
  212. package/build/src/http-server/client/params-to-object.d.ts.map +1 -1
  213. package/build/src/http-server/client/params-to-object.js +7 -21
  214. package/build/src/http-server/client/request-buffer/index.d.ts.map +1 -1
  215. package/build/src/http-server/client/request-buffer/index.js +2 -4
  216. package/build/src/http-server/client/request-parser.d.ts.map +1 -1
  217. package/build/src/http-server/client/request-parser.js +2 -4
  218. package/build/src/http-server/client/request-runner.d.ts.map +1 -1
  219. package/build/src/http-server/client/request-runner.js +5 -14
  220. package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
  221. package/build/src/http-server/client/websocket-session.js +7 -20
  222. package/build/src/http-server/development-reloader.d.ts.map +1 -1
  223. package/build/src/http-server/development-reloader.js +3 -7
  224. package/build/src/http-server/remote-address.d.ts.map +1 -1
  225. package/build/src/http-server/remote-address.js +2 -6
  226. package/build/src/http-server/server-client.d.ts.map +1 -1
  227. package/build/src/http-server/server-client.js +4 -10
  228. package/build/src/http-server/server-lock.d.ts.map +1 -1
  229. package/build/src/http-server/server-lock.js +3 -7
  230. package/build/src/http-server/websocket-channel-subscribers.d.ts.map +1 -1
  231. package/build/src/http-server/websocket-channel-subscribers.js +3 -7
  232. package/build/src/http-server/websocket-event-log-store.d.ts.map +1 -1
  233. package/build/src/http-server/websocket-event-log-store.js +6 -16
  234. package/build/src/http-server/websocket-events-host.d.ts.map +1 -1
  235. package/build/src/http-server/websocket-events-host.js +2 -5
  236. package/build/src/http-server/worker-handler/in-process.d.ts.map +1 -1
  237. package/build/src/http-server/worker-handler/in-process.js +4 -12
  238. package/build/src/http-server/worker-handler/worker-thread.d.ts.map +1 -1
  239. package/build/src/http-server/worker-handler/worker-thread.js +2 -4
  240. package/build/src/logger.d.ts.map +1 -1
  241. package/build/src/logger.js +3 -7
  242. package/build/src/mailer/backends/smtp.d.ts.map +1 -1
  243. package/build/src/mailer/backends/smtp.js +2 -6
  244. package/build/src/mailer/base.d.ts.map +1 -1
  245. package/build/src/mailer/base.js +5 -17
  246. package/build/src/plugins/sqljs-wasm-route-controller.d.ts.map +1 -1
  247. package/build/src/plugins/sqljs-wasm-route-controller.js +2 -4
  248. package/build/src/routes/basic-route.d.ts.map +1 -1
  249. package/build/src/routes/basic-route.js +2 -4
  250. package/build/src/routes/resolver.d.ts.map +1 -1
  251. package/build/src/routes/resolver.js +5 -15
  252. package/build/src/testing/expect-utils.d.ts.map +1 -1
  253. package/build/src/testing/expect-utils.js +9 -27
  254. package/build/src/testing/expect.d.ts.map +1 -1
  255. package/build/src/testing/expect.js +5 -15
  256. package/build/src/testing/test-runner.d.ts.map +1 -1
  257. package/build/src/testing/test-runner.js +4 -10
  258. package/build/src/testing/test.d.ts.map +1 -1
  259. package/build/src/testing/test.js +5 -17
  260. package/build/src/utils/model-scope.d.ts.map +1 -1
  261. package/build/src/utils/model-scope.js +2 -5
  262. package/build/src/utils/ransack.d.ts.map +1 -1
  263. package/build/src/utils/ransack.js +15 -42
  264. package/build/src/utils/with-tracked-stack-async-hooks.d.ts.map +1 -1
  265. package/build/src/utils/with-tracked-stack-async-hooks.js +4 -12
  266. package/build/src/utils/with-tracked-stack.d.ts.map +1 -1
  267. package/build/src/utils/with-tracked-stack.js +3 -8
  268. package/build/testing/expect-utils.js +8 -26
  269. package/build/testing/expect.js +4 -14
  270. package/build/testing/test-runner.js +3 -9
  271. package/build/testing/test.js +4 -12
  272. package/build/utils/model-scope.js +1 -3
  273. package/build/utils/ransack.js +15 -41
  274. package/build/utils/with-tracked-stack-async-hooks.js +3 -9
  275. package/build/utils/with-tracked-stack.js +2 -6
  276. package/package.json +3 -2
  277. package/src/application.js +1 -3
  278. package/src/background-jobs/cron-expression.js +1 -3
  279. package/src/background-jobs/forked-runner-child.js +1 -3
  280. package/src/background-jobs/job.js +1 -3
  281. package/src/background-jobs/scheduler.js +2 -6
  282. package/src/background-jobs/store.js +2 -6
  283. package/src/background-jobs/web/controller.js +1 -3
  284. package/src/background-jobs/worker.js +1 -3
  285. package/src/beacon/client.js +2 -6
  286. package/src/cli/tenant-database-command-helper.js +1 -3
  287. package/src/configuration.js +29 -32
  288. package/src/controller.js +4 -14
  289. package/src/current.js +2 -2
  290. package/src/database/drivers/mssql/index.js +1 -3
  291. package/src/database/drivers/mysql/index.js +2 -6
  292. package/src/database/drivers/pgsql/index.js +1 -3
  293. package/src/database/drivers/sqlite/base.js +3 -9
  294. package/src/database/drivers/sqlite/index.js +3 -9
  295. package/src/database/drivers/sqlite/table.js +1 -3
  296. package/src/database/migrator.js +1 -3
  297. package/src/database/pool/async-tracked-multi-connection.js +20 -45
  298. package/src/database/pool/base-methods-forward.js +2 -10
  299. package/src/database/pool/base.js +5 -15
  300. package/src/database/query/index.js +4 -12
  301. package/src/database/query/join-object.js +3 -9
  302. package/src/database/query/model-class-query.js +21 -63
  303. package/src/database/query/preloader/belongs-to.js +9 -27
  304. package/src/database/query/preloader/has-many.js +7 -21
  305. package/src/database/query/preloader/has-one.js +3 -9
  306. package/src/database/query/preloader.js +6 -18
  307. package/src/database/query/query-data.js +5 -15
  308. package/src/database/query/where-model-class-hash.js +5 -15
  309. package/src/database/query/with-count.js +5 -15
  310. package/src/database/record/acts-as-list.js +10 -38
  311. package/src/database/record/attachments/normalize-input.js +7 -25
  312. package/src/database/record/attachments/storage-drivers/s3.js +4 -12
  313. package/src/database/record/attachments/store.js +2 -6
  314. package/src/database/record/index.js +56 -172
  315. package/src/database/record/instance-relationships/base.js +6 -20
  316. package/src/database/record/instance-relationships/belongs-to.js +2 -6
  317. package/src/database/record/instance-relationships/has-many.js +4 -12
  318. package/src/database/record/instance-relationships/has-one.js +4 -12
  319. package/src/database/record/relationships/base.js +1 -5
  320. package/src/database/record/validators/presence.js +1 -3
  321. package/src/database/record/validators/uniqueness.js +4 -12
  322. package/src/environment-handlers/browser.js +1 -3
  323. package/src/environment-handlers/node/cli/commands/console.js +2 -6
  324. package/src/environment-handlers/node/cli/commands/db/schema/load.js +1 -3
  325. package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +67 -11
  326. package/src/environment-handlers/node.js +15 -6
  327. package/src/frontend-model-controller.js +34 -110
  328. package/src/frontend-models/base.js +45 -151
  329. package/src/frontend-models/clear-pending-debounced-callback.js +1 -3
  330. package/src/frontend-models/preloader.js +3 -9
  331. package/src/frontend-models/query.js +11 -33
  332. package/src/frontend-models/resource-definition.js +2 -6
  333. package/src/frontend-models/transport-serialization.js +7 -21
  334. package/src/frontend-models/use-destroyed-event.js +2 -6
  335. package/src/frontend-models/use-model-class-event.js +2 -6
  336. package/src/frontend-models/use-updated-event.js +3 -9
  337. package/src/frontend-models/websocket-channel.js +9 -27
  338. package/src/frontend-models/websocket-publishers.js +12 -23
  339. package/src/http-server/client/index.js +6 -18
  340. package/src/http-server/client/params-to-object.js +6 -18
  341. package/src/http-server/client/request-buffer/index.js +1 -3
  342. package/src/http-server/client/request-parser.js +1 -3
  343. package/src/http-server/client/request-runner.js +4 -12
  344. package/src/http-server/client/websocket-session.js +6 -18
  345. package/src/http-server/development-reloader.js +2 -6
  346. package/src/http-server/remote-address.js +1 -5
  347. package/src/http-server/server-client.js +3 -9
  348. package/src/http-server/server-lock.js +2 -6
  349. package/src/http-server/websocket-channel-subscribers.js +2 -6
  350. package/src/http-server/websocket-event-log-store.js +5 -15
  351. package/src/http-server/websocket-events-host.js +1 -3
  352. package/src/http-server/worker-handler/in-process.js +3 -11
  353. package/src/http-server/worker-handler/worker-thread.js +1 -3
  354. package/src/logger.js +2 -6
  355. package/src/mailer/backends/smtp.js +1 -5
  356. package/src/mailer/base.js +4 -16
  357. package/src/plugins/sqljs-wasm-route-controller.js +1 -3
  358. package/src/routes/basic-route.js +1 -3
  359. package/src/routes/resolver.js +4 -14
  360. package/src/testing/expect-utils.js +8 -26
  361. package/src/testing/expect.js +4 -14
  362. package/src/testing/test-runner.js +3 -9
  363. package/src/testing/test.js +4 -12
  364. package/src/utils/model-scope.js +1 -3
  365. package/src/utils/ransack.js +15 -41
  366. package/src/utils/with-tracked-stack-async-hooks.js +3 -9
  367. package/src/utils/with-tracked-stack.js +2 -6
package/README.md CHANGED
@@ -2200,7 +2200,7 @@ export default new Configuration({
2200
2200
  })
2201
2201
  ```
2202
2202
 
2203
- Use `configuration.runWithTenant(tenant, callback)` or `Current.tenant()` when custom model/database routing needs to read the active tenant manually.
2203
+ Use `configuration.runWithTenant(tenant, callback)` or `Current.tenant()` when custom model/database routing needs to read the active tenant manually. The tenant is an app-defined value — inputs (`runWithTenant`/`Current.setTenant`/`Current.withTenant`) accept any `object`, `Current.tenant()` returns `Record<string, unknown> | undefined`, and the `switchesTenantDatabase(...)` resolver callback receives `Record<string, unknown> | null | undefined`, so narrow before reading fields. See [tenant object typing](docs/tenant-databases.md#tenant-object-typing).
2204
2204
 
2205
2205
  Tenant-switched model classes fail closed by default: if `switchesTenantDatabase(...)` cannot resolve a tenant database identifier for the current tenant, Velocious raises `TenantDatabaseScopeError` instead of running the query against the configured fallback database. Set `enforceTenantDatabaseScopes: false` only for legacy apps that still need the old fallback behavior during migration.
2206
2206
 
@@ -119,9 +119,7 @@ export default class VelociousApplication {
119
119
  async startLockedHttpServer({configuration, host, httpServerConfiguration, port}) {
120
120
  try {
121
121
  if (!configuration.getWebsocketEvents()) {
122
- configuration.setWebsocketEvents(/**
123
- * Types the following value.
124
- * @type {?} */ (websocketEventsHost))
122
+ configuration.setWebsocketEvents(/** @type {?} */ (websocketEventsHost))
125
123
  }
126
124
 
127
125
  await configuration.connectBeacon({peerType: "server"})
@@ -60,9 +60,7 @@ export function parseCronExpression(expression) {
60
60
  }
61
61
 
62
62
  const trimmed = expression.trim().toLowerCase()
63
- const expanded = SHORTCUTS[/**
64
- * Narrows the runtime value to the documented type.
65
- * @type {keyof typeof SHORTCUTS} */ (trimmed)] || trimmed
63
+ const expanded = SHORTCUTS[/** @type {keyof typeof SHORTCUTS} */ (trimmed)] || trimmed
66
64
  const fields = expanded.split(/\s+/)
67
65
 
68
66
  if (fields.length !== 5) {
@@ -12,9 +12,7 @@ let finishing = false
12
12
  function isJobMessage(message) {
13
13
  if (!message || typeof message !== "object") return false
14
14
 
15
- const messageRecord = /**
16
- * Narrows the runtime value to the documented type.
17
- * @type {{type?: ?, payload?: ?}} */ (message)
15
+ const messageRecord = /** @type {{type?: ?, payload?: ?}} */ (message)
18
16
 
19
17
  return messageRecord.type === "job" && Object.hasOwn(messageRecord, "payload")
20
18
  }
@@ -58,9 +58,7 @@ export default class VelociousJob {
58
58
  const isOptionsArg = lastArg && typeof lastArg === "object" && !Array.isArray(lastArg) && "jobOptions" in lastArg
59
59
 
60
60
  if (isOptionsArg) {
61
- const {jobOptions} = /**
62
- * Narrows the runtime value to the documented type.
63
- * @type {{jobOptions: import("./types.js").BackgroundJobOptions}} */ (lastArg)
61
+ const {jobOptions} = /** @type {{jobOptions: import("./types.js").BackgroundJobOptions}} */ (lastArg)
64
62
  return {jobArgs: args.slice(0, -1), jobOptions: jobOptions || {}}
65
63
  }
66
64
 
@@ -52,9 +52,7 @@ export function parseScheduledDuration(value, fieldName) {
52
52
  }
53
53
 
54
54
  const numericValue = Number(match[1])
55
- const multiplier = DURATION_MULTIPLIERS[/**
56
- * Narrows the runtime value to the documented type.
57
- * @type {DurationUnit} */ (match[2])]
55
+ const multiplier = DURATION_MULTIPLIERS[/** @type {DurationUnit} */ (match[2])]
58
56
 
59
57
  if (!multiplier) {
60
58
  throw new Error(`Invalid scheduled background job ${fieldName}: ${value}`)
@@ -168,9 +166,7 @@ export default class BackgroundJobsScheduler {
168
166
  * @returns {void}
169
167
  */
170
168
  scheduleEveryJob({jobConfiguration, jobKey}) {
171
- const everyConfig = /**
172
- * Narrows the runtime value to the documented type.
173
- * @type {NonNullable<typeof jobConfiguration.every>} */ (jobConfiguration.every)
169
+ const everyConfig = /** @type {NonNullable<typeof jobConfiguration.every>} */ (jobConfiguration.every)
174
170
  const {everyValue, firstInValue} = this.normalizeEvery(everyConfig)
175
171
  const intervalMs = parseScheduledDuration(everyValue, `${jobKey}.every`)
176
172
  const firstInMs = firstInValue !== undefined ? parseScheduledDuration(firstInValue, `${jobKey}.first_in`) : intervalMs
@@ -237,9 +237,7 @@ export default class BackgroundJobsStore {
237
237
  const counts = {}
238
238
 
239
239
  for (const row of rows) {
240
- const typedRow = /**
241
- * Narrows the runtime value to the documented type.
242
- * @type {Record<string, ?>} */ (row)
240
+ const typedRow = /** @type {Record<string, ?>} */ (row)
243
241
 
244
242
  counts[String(typedRow.status)] = this._normalizeNumber(typedRow.count) || 0
245
243
  }
@@ -265,9 +263,7 @@ export default class BackgroundJobsStore {
265
263
  if (jobName) query = query.where({job_name: jobName})
266
264
 
267
265
  const rows = await query.results()
268
- const countRow = /**
269
- * Narrows the runtime value to the documented type.
270
- * @type {Record<string, ?>} */ (rows[0] || {})
266
+ const countRow = /** @type {Record<string, ?>} */ (rows[0] || {})
271
267
 
272
268
  return this._normalizeNumber(countRow.count) || 0
273
269
  })
@@ -222,9 +222,7 @@ export default class VelociousBackgroundJobsWebController extends Controller {
222
222
  const redactArgs = Boolean(this._mountOptions().redactArgs)
223
223
 
224
224
  return Object.keys(jobs).map((name) => {
225
- const entry = jobs[name] || /**
226
- * Narrows the runtime value to the documented type.
227
- * @type {?} */ ({})
225
+ const entry = jobs[name] || /** @type {?} */ ({})
228
226
 
229
227
  return {
230
228
  args: redactArgs ? undefined : (entry.args || []),
@@ -276,9 +276,7 @@ export default class BackgroundJobsWorker {
276
276
  /**
277
277
  * Identified payload.
278
278
  * @type {import("./types.js").BackgroundJobPayload & {id: string}} */
279
- const identifiedPayload = /**
280
- * Narrows the runtime value to the documented type.
281
- * @type {?} */ (payload)
279
+ const identifiedPayload = /** @type {?} */ (payload)
282
280
 
283
281
  const executionMode = this._executionModeForPayload(identifiedPayload)
284
282
 
@@ -116,9 +116,7 @@ export default class BeaconClient extends EventEmitter {
116
116
  this.off("connect-error", onError)
117
117
  resolve()
118
118
  }
119
- const onError = (/**
120
- * Narrows the runtime value to the documented type.
121
- * @type {Error} */ error) => {
119
+ const onError = (/** @type {Error} */ error) => {
122
120
  this.off("connect", onConnect)
123
121
  this.off("connect-error", onError)
124
122
  reject(error)
@@ -271,9 +269,7 @@ export default class BeaconClient extends EventEmitter {
271
269
  this.emit("connect")
272
270
  })
273
271
 
274
- jsonSocket.on("message", (/**
275
- * Narrows the runtime value to the documented type.
276
- * @type {import("./types.js").BeaconSocketMessage} */ message) => {
272
+ jsonSocket.on("message", (/** @type {import("./types.js").BeaconSocketMessage} */ message) => {
277
273
  if (message?.type === "hello-ack" && message.peerId === this.peerId) {
278
274
  this._ready = true
279
275
  this.emit("ready")
@@ -184,9 +184,7 @@ export default class TenantDatabaseCommandHelper {
184
184
  */
185
185
  tenantLabel(tenant) {
186
186
  if (tenant && typeof tenant === "object") {
187
- const tenantObject = /**
188
- * Narrows the runtime value to the documented type.
189
- * @type {{id?: ?, name?: ?, slug?: ?}} */ (tenant)
187
+ const tenantObject = /** @type {{id?: ?, name?: ?, slug?: ?}} */ (tenant)
190
188
 
191
189
  if (tenantObject.slug) return String(tenantObject.slug)
192
190
  if (tenantObject.name) return String(tenantObject.name)
@@ -30,15 +30,34 @@ export {CurrentConfigurationNotSetError}
30
30
  * @returns {string | undefined} - Current working directory when the runtime exposes one.
31
31
  */
32
32
  function currentWorkingDirectory() {
33
- const processObject = /**
34
- * Types the following value.
35
- * @type {{cwd?: ?} | undefined} */ (globalThis.process)
33
+ const processObject = /** @type {{cwd?: ?} | undefined} */ (globalThis.process)
36
34
 
37
35
  if (typeof processObject?.cwd !== "function") return undefined
38
36
 
39
37
  return processObject.cwd()
40
38
  }
41
39
 
40
+ /**
41
+ * Resolves the overloaded with/ensure connections arguments.
42
+ * @template T
43
+ * @param {WithConnectionsOptionsType | WithConnectionsCallbackType<T>} optionsOrCallback - Checkout options or callback function.
44
+ * @param {WithConnectionsCallbackType<T> | undefined} callback - Callback function.
45
+ * @param {string} defaultName - Default checkout name.
46
+ * @returns {{name: string, callback: WithConnectionsCallbackType<T> | undefined}} Resolved checkout name and callback.
47
+ */
48
+ function resolveWithConnectionsArgs(optionsOrCallback, callback, defaultName) {
49
+ if (typeof optionsOrCallback == "function") {
50
+ const actualCallback = /** @type {WithConnectionsCallbackType<T>} */ (optionsOrCallback)
51
+
52
+ return {name: defaultName, callback: actualCallback}
53
+ }
54
+
55
+ return {
56
+ name: optionsOrCallback.name || defaultName,
57
+ callback
58
+ }
59
+ }
60
+
42
61
  /**
43
62
  * Runs canonical debug snapshot value.
44
63
  * @param {?} value - Snapshot value to canonicalize.
@@ -49,13 +68,9 @@ function canonicalDebugSnapshotValue(value) {
49
68
  if (Array.isArray(value)) return value.map((entry) => canonicalDebugSnapshotValue(entry))
50
69
 
51
70
  return Object.keys(value).sort().reduce((result, key) => {
52
- result[key] = canonicalDebugSnapshotValue(/**
53
- * Types the following value.
54
- * @type {Record<string, ?>} */ (value)[key])
71
+ result[key] = canonicalDebugSnapshotValue(/** @type {Record<string, ?>} */ (value)[key])
55
72
  return result
56
- }, /**
57
- * Types the following value.
58
- * @type {Record<string, ?>} */ ({}))
73
+ }, /** @type {Record<string, ?>} */ ({}))
59
74
  }
60
75
 
61
76
  /**
@@ -496,9 +511,7 @@ export default class VelociousConfiguration {
496
511
  * @returns {Promise<Record<string, ?>>} - HTTP server worker diagnostics.
497
512
  */
498
513
  async _debugHttpServerSnapshot() {
499
- const httpServer = /**
500
- * Types the following value.
501
- * @type {{getDebugSnapshot?: () => Promise<Record<string, ?>>} | undefined} */ (this._httpServerInstance)
514
+ const httpServer = /** @type {{getDebugSnapshot?: () => Promise<Record<string, ?>>} | undefined} */ (this._httpServerInstance)
502
515
 
503
516
  if (!httpServer?.getDebugSnapshot) {
504
517
  return {configured: Boolean(this.httpServer), active: false}
@@ -597,9 +610,7 @@ export default class VelociousConfiguration {
597
610
  const detailsBuckets = new Map()
598
611
 
599
612
  for (const subscription of channelSubscriptions) {
600
- const details = /**
601
- * Types the following value.
602
- * @type {Record<string, ?>} */ (canonicalDebugSnapshotValue(subscription.debugSnapshot()))
613
+ const details = /** @type {Record<string, ?>} */ (canonicalDebugSnapshotValue(subscription.debugSnapshot()))
603
614
  const key = JSON.stringify(details)
604
615
  const existingBucket = detailsBuckets.get(key)
605
616
 
@@ -624,9 +635,7 @@ export default class VelociousConfiguration {
624
635
  const channelSubscriptionBuckets = new Map()
625
636
 
626
637
  for (const {channelType, subscription} of session._channelSubscriptions.values()) {
627
- const details = /**
628
- * Types the following value.
629
- * @type {Record<string, ?>} */ (subscription.debugSnapshot())
638
+ const details = /** @type {Record<string, ?>} */ (subscription.debugSnapshot())
630
639
  const model = typeof details.model === "string" ? details.model : null
631
640
  const key = JSON.stringify({channelType, model})
632
641
  const existingBucket = channelSubscriptionBuckets.get(key)
@@ -2422,13 +2431,7 @@ export default class VelociousConfiguration {
2422
2431
  * @returns {Promise<T>} - Resolves with the callback result.
2423
2432
  */
2424
2433
  async withConnections(optionsOrCallback, callback) {
2425
- const name = typeof optionsOrCallback == "function" ? "Configuration.withConnections" : (optionsOrCallback.name || "Configuration.withConnections")
2426
- /**
2427
- * Actual with connections callback.
2428
- * @type {WithConnectionsCallbackType<T> | undefined} */
2429
- const actualWithConnectionsCallback = typeof optionsOrCallback == "function" ? /**
2430
- * Types the following value.
2431
- * @type {WithConnectionsCallbackType<T>} */ (optionsOrCallback) : callback
2434
+ const {name, callback: actualWithConnectionsCallback} = resolveWithConnectionsArgs(optionsOrCallback, callback, "Configuration.withConnections")
2432
2435
 
2433
2436
  if (!actualWithConnectionsCallback) throw new Error("withConnections requires a callback")
2434
2437
 
@@ -2537,13 +2540,7 @@ export default class VelociousConfiguration {
2537
2540
  * @returns {Promise<T>} - Resolves with the callback result.
2538
2541
  */
2539
2542
  async ensureConnections(optionsOrCallback, callback) {
2540
- const name = typeof optionsOrCallback == "function" ? "Configuration.ensureConnections" : (optionsOrCallback.name || "Configuration.ensureConnections")
2541
- /**
2542
- * Actual with connections callback.
2543
- * @type {WithConnectionsCallbackType<T> | undefined} */
2544
- const actualWithConnectionsCallback = typeof optionsOrCallback == "function" ? /**
2545
- * Types the following value.
2546
- * @type {WithConnectionsCallbackType<T>} */ (optionsOrCallback) : callback
2543
+ const {name, callback: actualWithConnectionsCallback} = resolveWithConnectionsArgs(optionsOrCallback, callback, "Configuration.ensureConnections")
2547
2544
 
2548
2545
  if (!actualWithConnectionsCallback) throw new Error("ensureConnections requires a callback")
2549
2546
 
@@ -141,9 +141,7 @@ export default class VelociousController {
141
141
  * @returns {typeof VelociousController} - The controller class.
142
142
  */
143
143
  _getControllerClass() {
144
- const controllerClass = /**
145
- * Types the following value.
146
- * @type {typeof VelociousController} */ (this.constructor)
144
+ const controllerClass = /** @type {typeof VelociousController} */ (this.constructor)
147
145
 
148
146
  return controllerClass
149
147
  }
@@ -159,11 +157,7 @@ export default class VelociousController {
159
157
  const beforeActions = currentControllerClass._beforeActions
160
158
 
161
159
  if (beforeActions) {
162
- const controllerPrototype = /**
163
- * Types the following value.
164
- * @type {Record<string, Function | undefined>} */ (/**
165
- * Types the following value.
166
- * @type {?} */ (currentControllerClass.prototype))
160
+ const controllerPrototype = /** @type {Record<string, Function | undefined>} */ (/** @type {?} */ (currentControllerClass.prototype))
167
161
 
168
162
  for (const beforeActionName of beforeActions) {
169
163
  const beforeAction = controllerPrototype[beforeActionName]
@@ -215,9 +209,7 @@ export default class VelociousController {
215
209
 
216
210
  return paramsToObject.toObject()
217
211
  } catch (error) {
218
- const ensuredError = /**
219
- * Types the following value.
220
- * @type {Error & {velociousContext?: Record<string, ?>}} */ (error)
212
+ const ensuredError = /** @type {Error & {velociousContext?: Record<string, ?>}} */ (error)
221
213
 
222
214
  ensuredError.velociousContext = {
223
215
  ...(ensuredError.velociousContext || {}),
@@ -295,9 +287,7 @@ export default class VelociousController {
295
287
 
296
288
  ejs.renderFile(viewPath, actualViewParams, {}, (err, str) => {
297
289
  if (err) {
298
- const renderError = /**
299
- * Types the following value.
300
- * @type {Error & {code?: string}} */ (err)
290
+ const renderError = /** @type {Error & {code?: string}} */ (err)
301
291
 
302
292
  if (renderError.code === "ENOENT") {
303
293
  this.logger.warn(`Missing view file: ${viewPath}`)
package/build/current.js CHANGED
@@ -61,7 +61,7 @@ export default class Current {
61
61
 
62
62
  /**
63
63
  * Runs set tenant.
64
- * @param {Record<string, unknown>} tenant - Tenant.
64
+ * @param {object} tenant - Tenant. Any caller-defined object shape; read back (and narrowed) via tenant().
65
65
  * @returns {void} - No return value.
66
66
  */
67
67
  static setTenant(tenant) {
@@ -70,7 +70,7 @@ export default class Current {
70
70
 
71
71
  /**
72
72
  * Runs with tenant.
73
- * @param {Record<string, unknown>} tenant - Tenant.
73
+ * @param {object} tenant - Tenant. Any caller-defined object shape; read back (and narrowed) via tenant().
74
74
  * @param {() => Promise<?>} callback - Callback.
75
75
  * @returns {Promise<?>} - Callback result.
76
76
  */
@@ -340,9 +340,7 @@ export default class VelociousDatabaseDriversMssql extends Base{
340
340
  const tables = []
341
341
 
342
342
  for (const row of result) {
343
- const table = new Table(this, /**
344
- * Narrows the runtime value to the documented type.
345
- * @type {Record<string, string>} */ (row))
343
+ const table = new Table(this, /** @type {Record<string, string>} */ (row))
346
344
 
347
345
  tables.push(table)
348
346
  }
@@ -223,9 +223,7 @@ export default class VelociousDatabaseDriversMysql extends Base{
223
223
  * @returns {import("../base.js").RetryableDatabaseErrorResult} - Retry info.
224
224
  */
225
225
  retryableDatabaseError(error) {
226
- const errorCode = /**
227
- * Narrows the runtime value to the documented type.
228
- * @type {?} */ (error).code
226
+ const errorCode = /** @type {?} */ (error).code
229
227
  const message = error.message || ""
230
228
  const shouldRetry = (
231
229
  errorCode == "ECONNREFUSED" ||
@@ -337,9 +335,7 @@ export default class VelociousDatabaseDriversMysql extends Base{
337
335
  const tables = []
338
336
 
339
337
  for (const row of result) {
340
- const table = new Table(this, /**
341
- * Narrows the runtime value to the documented type.
342
- * @type {Record<string, string>} */ (row))
338
+ const table = new Table(this, /** @type {Record<string, string>} */ (row))
343
339
 
344
340
  tables.push(table)
345
341
  }
@@ -292,9 +292,7 @@ export default class VelociousDatabaseDriversPgsql extends Base{
292
292
  const tables = []
293
293
 
294
294
  for (const row of result) {
295
- const table = new Table(this, /**
296
- * Narrows the runtime value to the documented type.
297
- * @type {Record<string, string>} */ (row))
295
+ const table = new Table(this, /** @type {Record<string, string>} */ (row))
298
296
 
299
297
  tables.push(table)
300
298
  }
@@ -87,9 +87,7 @@ export default class VelociousDatabaseDriversSqliteBase extends Base {
87
87
  * @returns {Promise<string[]>} - Resolves with SQL statements.
88
88
  */
89
89
  async dropTableSQLs(tableName, args = {}) {
90
- const driver = /**
91
- * Narrows the runtime value to the documented type.
92
- * @type {import("../base.js").default} */ (this)
90
+ const driver = /** @type {import("../base.js").default} */ (this)
93
91
  const dropArgs = Object.assign({tableName, driver}, args)
94
92
  const dropTable = new DropTable(dropArgs)
95
93
 
@@ -126,9 +124,7 @@ export default class VelociousDatabaseDriversSqliteBase extends Base {
126
124
  const tables = []
127
125
 
128
126
  for (const row of result) {
129
- const table = new Table({driver: this, row: /**
130
- * Narrows the runtime value to the documented type.
131
- * @type {Record<string, string | number | null>} */ (row)})
127
+ const table = new Table({driver: this, row: /** @type {Record<string, string | number | null>} */ (row)})
132
128
 
133
129
  tables.push(table)
134
130
  }
@@ -403,9 +399,7 @@ export default class VelociousDatabaseDriversSqliteBase extends Base {
403
399
  if (timeoutHandle) clearTimeout(timeoutHandle)
404
400
 
405
401
  const current = state.waitersByName.get(name) || []
406
- const index = current.indexOf(/**
407
- * Narrows the runtime value to the documented type.
408
- * @type {() => void} */ (removeAndResolve))
402
+ const index = current.indexOf(/** @type {() => void} */ (removeAndResolve))
409
403
 
410
404
  if (index >= 0) current.splice(index, 1)
411
405
  if (current.length === 0) state.waitersByName.delete(name)
@@ -247,9 +247,7 @@ export default class VelociousDatabaseDriversSqliteNode extends Base {
247
247
 
248
248
  return true
249
249
  } catch (error) {
250
- if (/**
251
- * Narrows the runtime value to the documented type.
252
- * @type {NodeJS.ErrnoException} */ (error)?.code !== "EEXIST") throw error
250
+ if (/** @type {NodeJS.ErrnoException} */ (error)?.code !== "EEXIST") throw error
253
251
 
254
252
  if (await this._isAdvisoryLockStale(lockPath)) {
255
253
  await fs.rm(lockPath, {recursive: true, force: true})
@@ -285,9 +283,7 @@ export default class VelociousDatabaseDriversSqliteNode extends Base {
285
283
 
286
284
  return true
287
285
  } catch (error) {
288
- if (/**
289
- * Narrows the runtime value to the documented type.
290
- * @type {NodeJS.ErrnoException} */ (error)?.code !== "EEXIST") throw error
286
+ if (/** @type {NodeJS.ErrnoException} */ (error)?.code !== "EEXIST") throw error
291
287
 
292
288
  if (await this._isAdvisoryLockStale(lockPath)) {
293
289
  await fs.rm(lockPath, {recursive: true, force: true})
@@ -298,9 +294,7 @@ export default class VelociousDatabaseDriversSqliteNode extends Base {
298
294
 
299
295
  return true
300
296
  } catch (retryError) {
301
- if (/**
302
- * Narrows the runtime value to the documented type.
303
- * @type {NodeJS.ErrnoException} */ (retryError)?.code === "EEXIST") return false
297
+ if (/** @type {NodeJS.ErrnoException} */ (retryError)?.code === "EEXIST") return false
304
298
 
305
299
  throw retryError
306
300
  }
@@ -71,9 +71,7 @@ export default class VelociousDatabaseDriversSqliteTable extends BaseTable {
71
71
 
72
72
  if (!sql) throw new Error(`Could not find SQL for index ${columnsIndex.getName()}`)
73
73
 
74
- const indexData = /**
75
- * Narrows the runtime value to the documented type.
76
- * @type {typeof columnsIndex.data & {columnNames?: string[]}} */ (columnsIndex.data)
74
+ const indexData = /** @type {typeof columnsIndex.data & {columnNames?: string[]}} */ (columnsIndex.data)
77
75
 
78
76
  indexData.columnNames = this._parseColumnsFromSQL(String(sql))
79
77
 
@@ -301,9 +301,7 @@ export default class VelociousDatabaseMigrator {
301
301
  const migrationName = match[2]
302
302
  const migrationClassName = inflection.camelize(migrationName)
303
303
 
304
- const migrationObject = /**
305
- * Narrows the runtime value to the documented type.
306
- * @type {import("./migrator/types.js").MigrationObjectType} */ ({
304
+ const migrationObject = /** @type {import("./migrator/types.js").MigrationObjectType} */ ({
307
305
  file,
308
306
  date,
309
307
  migrationClassName