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
@@ -105,9 +105,7 @@ export default class VelociousDatabaseQueryPreloaderHasMany {
105
105
  throw new Error(`${this.relationship.getModelClass().name}#${this.relationship.getRelationshipName()} doesn't have a primary key`)
106
106
  }
107
107
 
108
- const throughRelationshipName = /**
109
- * Narrows the runtime value to the documented type.
110
- * @type {string} */ (this.relationship.through)
108
+ const throughRelationshipName = /** @type {string} */ (this.relationship.through)
111
109
  const parentModelClass = this.relationship.getModelClass()
112
110
  const throughRelationship = parentModelClass.getRelationshipByName(throughRelationshipName)
113
111
  const throughModelClass = throughRelationship.getTargetModelClass()
@@ -146,9 +144,7 @@ export default class VelociousDatabaseQueryPreloaderHasMany {
146
144
  const preloadCollections = {}
147
145
 
148
146
  for (const model of modelsToLoad) {
149
- const primaryKeyValue = /**
150
- * Narrows the runtime value to the documented type.
151
- * @type {string | number} */ (model.readColumn(primaryKey))
147
+ const primaryKeyValue = /** @type {string | number} */ (model.readColumn(primaryKey))
152
148
 
153
149
  preloadCollections[primaryKeyValue] = []
154
150
 
@@ -174,12 +170,8 @@ export default class VelociousDatabaseQueryPreloaderHasMany {
174
170
  const allTargetIds = new Set()
175
171
 
176
172
  for (const throughModel of throughModels) {
177
- const parentId = /**
178
- * Narrows the runtime value to the documented type.
179
- * @type {string | number} */ (throughModel.readColumn(throughForeignKey))
180
- const throughId = /**
181
- * Narrows the runtime value to the documented type.
182
- * @type {string | number} */ (throughModel.readColumn(throughModelClass.primaryKey()))
173
+ const parentId = /** @type {string | number} */ (throughModel.readColumn(throughForeignKey))
174
+ const throughId = /** @type {string | number} */ (throughModel.readColumn(throughModelClass.primaryKey()))
183
175
 
184
176
  if (!(parentId in parentToTargetIds)) parentToTargetIds[parentId] = []
185
177
 
@@ -208,9 +200,7 @@ export default class VelociousDatabaseQueryPreloaderHasMany {
208
200
  const targetModelsByForeignKey = {}
209
201
 
210
202
  for (const targetModel of targetModels) {
211
- const fkValue = /**
212
- * Narrows the runtime value to the documented type.
213
- * @type {string | number} */ (targetModel.readColumn(targetForeignKey))
203
+ const fkValue = /** @type {string | number} */ (targetModel.readColumn(targetForeignKey))
214
204
 
215
205
  if (!(fkValue in targetModelsByForeignKey)) targetModelsByForeignKey[fkValue] = []
216
206
 
@@ -284,9 +274,7 @@ export default class VelociousDatabaseQueryPreloaderHasMany {
284
274
  const preloadCollections = {}
285
275
 
286
276
  for (const model of modelsToLoad) {
287
- const primaryKeyValue = /**
288
- * Narrows the runtime value to the documented type.
289
- * @type {string | number} */ (model.readColumn(primaryKey))
277
+ const primaryKeyValue = /** @type {string | number} */ (model.readColumn(primaryKey))
290
278
 
291
279
  preloadCollections[primaryKeyValue] = []
292
280
 
@@ -319,9 +307,7 @@ export default class VelociousDatabaseQueryPreloaderHasMany {
319
307
  const targetModels = await query.toArray()
320
308
 
321
309
  for (const targetModel of targetModels) {
322
- const foreignKeyValue = /**
323
- * Narrows the runtime value to the documented type.
324
- * @type {string | number} */ (targetModel.readColumn(foreignKey))
310
+ const foreignKeyValue = /** @type {string | number} */ (targetModel.readColumn(foreignKey))
325
311
 
326
312
  preloadCollections[foreignKeyValue].push(targetModel)
327
313
  }
@@ -53,17 +53,13 @@ export default class VelociousDatabaseQueryPreloaderHasOne {
53
53
  const instanceRelationship = model.getRelationshipByName(relationshipName)
54
54
 
55
55
  if (this.selection.isSatisfied({instanceRelationship, targetModelClass, mappingColumns: [foreignKey]})) {
56
- const loaded = /**
57
- * Narrows the runtime value to the documented type.
58
- * @type {import("../../record/index.js").default | undefined} */ (instanceRelationship.getLoadedOrUndefined())
56
+ const loaded = /** @type {import("../../record/index.js").default | undefined} */ (instanceRelationship.getLoadedOrUndefined())
59
57
 
60
58
  if (loaded) satisfiedTargets.push(loaded)
61
59
  continue
62
60
  }
63
61
 
64
- const primaryKeyValue = /**
65
- * Narrows the runtime value to the documented type.
66
- * @type {string | number} */ (model.readColumn(primaryKey))
62
+ const primaryKeyValue = /** @type {string | number} */ (model.readColumn(primaryKey))
67
63
 
68
64
  preloadCollections[primaryKeyValue] = undefined
69
65
 
@@ -99,9 +95,7 @@ export default class VelociousDatabaseQueryPreloaderHasOne {
99
95
  const targetModels = await query.toArray()
100
96
 
101
97
  for (const targetModel of targetModels) {
102
- const foreignKeyValue = /**
103
- * Narrows the runtime value to the documented type.
104
- * @type {string | number} */ (targetModel.readColumn(foreignKey))
98
+ const foreignKeyValue = /** @type {string | number} */ (targetModel.readColumn(foreignKey))
105
99
 
106
100
  preloadCollections[foreignKeyValue] = targetModel
107
101
  }
@@ -88,19 +88,13 @@ export default class VelociousDatabaseQueryPreloader {
88
88
  static async preload(models, queryOrSpec, {force = false} = {}) {
89
89
  if (models.length == 0) return
90
90
 
91
- const modelClass = /**
92
- * Narrows the runtime value to the documented type.
93
- * @type {typeof import("../record/index.js").default} */ (models[0].constructor)
91
+ const modelClass = /** @type {typeof import("../record/index.js").default} */ (models[0].constructor)
94
92
  const isQuery = Boolean(queryOrSpec) && typeof queryOrSpec == "object" && "_preload" in queryOrSpec
95
93
  // Reuse the query builder's preload/select normalization for raw specs
96
94
  // instead of duplicating it here.
97
95
  const query = isQuery
98
- ? /**
99
- * Narrows the runtime value to the documented type.
100
- * @type {import("./model-class-query.js").default} */ (queryOrSpec)
101
- : modelClass.preload(/**
102
- * Narrows the runtime value to the documented type.
103
- * @type {?} */ (queryOrSpec))
96
+ ? /** @type {import("./model-class-query.js").default} */ (queryOrSpec)
97
+ : modelClass.preload(/** @type {?} */ (queryOrSpec))
104
98
 
105
99
  const preloader = new VelociousDatabaseQueryPreloader({
106
100
  modelClass,
@@ -141,23 +135,17 @@ export default class VelociousDatabaseQueryPreloader {
141
135
  let preloadResult
142
136
 
143
137
  if (relationship.getType() == "belongsTo") {
144
- const belongsToRelationship = /**
145
- * Narrows the runtime value to the documented type.
146
- * @type {import("../record/relationships/belongs-to.js").default} */ (relationship)
138
+ const belongsToRelationship = /** @type {import("../record/relationships/belongs-to.js").default} */ (relationship)
147
139
  const hasManyPreloader = new BelongsToPreloader({models: this.models, relationship: belongsToRelationship, selection: this.selection})
148
140
 
149
141
  preloadResult = await hasManyPreloader.run()
150
142
  } else if (relationship.getType() == "hasMany") {
151
- const hasManyRelationship = /**
152
- * Narrows the runtime value to the documented type.
153
- * @type {import("../record/relationships/has-many.js").default} */ (relationship)
143
+ const hasManyRelationship = /** @type {import("../record/relationships/has-many.js").default} */ (relationship)
154
144
  const hasManyPreloader = new HasManyPreloader({models: this.models, relationship: hasManyRelationship, selection: this.selection})
155
145
 
156
146
  preloadResult = await hasManyPreloader.run()
157
147
  } else if (relationship.getType() == "hasOne") {
158
- const hasOneRelationship = /**
159
- * Narrows the runtime value to the documented type.
160
- * @type {import("../record/relationships/has-one.js").default} */ (relationship)
148
+ const hasOneRelationship = /** @type {import("../record/relationships/has-one.js").default} */ (relationship)
161
149
  const hasOnePreloader = new HasOnePreloader({models: this.models, relationship: hasOneRelationship, selection: this.selection})
162
150
 
163
151
  preloadResult = await hasOnePreloader.run()
@@ -69,9 +69,7 @@ export function normalizeQueryDataSpec(spec, chain = []) {
69
69
  }
70
70
 
71
71
  if (isPlainObject(item)) {
72
- for (const nested of normalizeQueryDataSpec(/**
73
- * Narrows the runtime value to the documented type.
74
- * @type {?} */ (item), chain)) {
72
+ for (const nested of normalizeQueryDataSpec(/** @type {?} */ (item), chain)) {
75
73
  entries.push(nested)
76
74
  }
77
75
  continue
@@ -98,9 +96,7 @@ export function normalizeQueryDataSpec(spec, chain = []) {
98
96
  if (value === false) continue
99
97
 
100
98
  if (typeof value === "string" || Array.isArray(value) || isPlainObject(value)) {
101
- for (const nested of normalizeQueryDataSpec(/**
102
- * Narrows the runtime value to the documented type.
103
- * @type {?} */ (value), [...chain, key])) {
99
+ for (const nested of normalizeQueryDataSpec(/** @type {?} */ (value), [...chain, key])) {
104
100
  entries.push(nested)
105
101
  }
106
102
  continue
@@ -193,9 +189,7 @@ export async function runQueryData({rootModelClass, rootModels, entries}) {
193
189
  if (rootModels.length === 0 || entries.length === 0) return
194
190
 
195
191
  const primaryKey = rootModelClass.primaryKey()
196
- const rootIds = rootModels.map((model) => /**
197
- * Narrows the runtime value to the documented type.
198
- * @type {string | number} */ (model.readColumn(primaryKey)))
192
+ const rootIds = rootModels.map((model) => /** @type {string | number} */ (model.readColumn(primaryKey)))
199
193
 
200
194
  for (const entry of entries) {
201
195
  await runEntry({entry, primaryKey, rootIds, rootModelClass, rootModels})
@@ -270,9 +264,7 @@ async function runEntry({entry, primaryKey, rootIds, rootModelClass, rootModels}
270
264
  tableName: targetTableRef
271
265
  })
272
266
 
273
- const rows = /**
274
- * Narrows the runtime value to the documented type.
275
- * @type {Array<Record<string, ?>>} */ (await query._executeQuery())
267
+ const rows = /** @type {Array<Record<string, ?>>} */ (await query._executeQuery())
276
268
  const byParent = new Map()
277
269
 
278
270
  for (const row of rows) {
@@ -284,9 +276,7 @@ async function runEntry({entry, primaryKey, rootIds, rootModelClass, rootModels}
284
276
  }
285
277
 
286
278
  for (const model of rootModels) {
287
- const modelId = /**
288
- * Narrows the runtime value to the documented type.
289
- * @type {string | number} */ (model.readColumn(primaryKey))
279
+ const modelId = /** @type {string | number} */ (model.readColumn(primaryKey))
290
280
  // Driver-type tolerance: MySQL can return PKs as strings even when
291
281
  // the column is numeric. Fall back to a string lookup so results
292
282
  // still land on the right model.
@@ -26,9 +26,7 @@ function normalizeRelationshipWhereOperator(operator) {
26
26
  }
27
27
 
28
28
  return /** @type {"eq" | "notEq" | "gt" | "gteq" | "lt" | "lteq" | "like"} */ (
29
- operatorAliases[/**
30
- * Narrows the runtime value to the documented type.
31
- * @type {"<" | "<=" | ">" | ">="} */ (operator)] || operator
29
+ operatorAliases[/** @type {"<" | "<=" | ">" | ">="} */ (operator)] || operator
32
30
  )
33
31
  }
34
32
 
@@ -66,9 +64,7 @@ export default class VelociousDatabaseQueryWhereModelClassHash extends WhereBase
66
64
  toSql() {
67
65
  let sql = "("
68
66
 
69
- const modelQuery = /**
70
- * Narrows the runtime value to the documented type.
71
- * @type {import("./model-class-query.js").default} */ (this.query)
67
+ const modelQuery = /** @type {import("./model-class-query.js").default} */ (this.query)
72
68
  const baseTableName = this.qualifyBaseTable
73
69
  ? modelQuery.getTableReferenceForJoin()
74
70
  : undefined
@@ -144,9 +140,7 @@ export default class VelociousDatabaseQueryWhereModelClassHash extends WhereBase
144
140
  */
145
141
  const addCondition = (conditionValue) => {
146
142
  if (this._isRelationshipWhereOperatorTuple(conditionValue)) {
147
- const tuple = /**
148
- * Narrows the runtime value to the documented type.
149
- * @type {[string, "eq" | "notEq" | "gt" | "gteq" | "lt" | "lteq" | "like" | ">" | ">=" | "<" | "<=", unknown, ...Array<unknown>]} */ (conditionValue)
143
+ const tuple = /** @type {[string, "eq" | "notEq" | "gt" | "gteq" | "lt" | "lteq" | "like" | ">" | ">=" | "<" | "<=", unknown, ...Array<unknown>]} */ (conditionValue)
150
144
  const normalizedOperator = normalizeRelationshipWhereOperator(tuple[1])
151
145
 
152
146
  normalized.push([
@@ -393,9 +387,7 @@ export default class VelociousDatabaseQueryWhereModelClassHash extends WhereBase
393
387
  */
394
388
  _whereSQLFromHash(hash, modelClass, path, tableName, index = 0) {
395
389
  const options = this.getOptions()
396
- const modelQuery = /**
397
- * Narrows the runtime value to the documented type.
398
- * @type {import("./model-class-query.js").default} */ (this.query)
390
+ const modelQuery = /** @type {import("./model-class-query.js").default} */ (this.query)
399
391
  let sql = ""
400
392
 
401
393
  for (const whereKey in hash) {
@@ -441,9 +433,7 @@ export default class VelociousDatabaseQueryWhereModelClassHash extends WhereBase
441
433
 
442
434
  if (!targetModelClass) throw new Error(`Relationship "${whereKey}" for ${modelClass.name} has no target model class`)
443
435
 
444
- const nestedHash = /**
445
- * Narrows the runtime value to the documented type.
446
- * @type {WhereHash} */ (whereValue)
436
+ const nestedHash = /** @type {WhereHash} */ (whereValue)
447
437
  const nestedPath = path.concat([whereKey])
448
438
  const nestedTableName = modelQuery.getTableReferenceForJoin(...nestedPath)
449
439
 
@@ -110,24 +110,18 @@ export async function runWithCount({models, modelClass, entries}) {
110
110
  if (models.length === 0 || entries.length === 0) return
111
111
 
112
112
  const primaryKey = modelClass.primaryKey()
113
- const parentIds = models.map((model) => /**
114
- * Narrows the runtime value to the documented type.
115
- * @type {string | number} */ (model.readColumn(primaryKey)))
113
+ const parentIds = models.map((model) => /** @type {string | number} */ (model.readColumn(primaryKey)))
116
114
 
117
115
  for (const entry of entries) {
118
116
  const counts = await countForEntry({entries, entry, modelClass, parentIds})
119
117
 
120
118
  for (const model of models) {
121
- const modelPrimaryKeyValue = /**
122
- * Narrows the runtime value to the documented type.
123
- * @type {string | number} */ (model.readColumn(primaryKey))
119
+ const modelPrimaryKeyValue = /** @type {string | number} */ (model.readColumn(primaryKey))
124
120
  // Tolerate driver differences in numeric return types: SQLite
125
121
  // returns integers as JS numbers, but MySQL's raw driver can
126
122
  // return count primary keys as strings. Try both.
127
123
  const resolvedCount = counts.has(modelPrimaryKeyValue)
128
- ? /**
129
- * Narrows the runtime value to the documented type.
130
- * @type {number} */ (counts.get(modelPrimaryKeyValue))
124
+ ? /** @type {number} */ (counts.get(modelPrimaryKeyValue))
131
125
  : Number(counts.get(String(modelPrimaryKeyValue)) ?? 0)
132
126
 
133
127
  // Counts go on the record's dedicated association-count map,
@@ -196,9 +190,7 @@ async function countForEntry({entries, entry, modelClass, parentIds}) {
196
190
  countQuery.select(`${quotedTable}.${quotedFk} AS parent_id`)
197
191
  countQuery.select("COUNT(*) AS count_value")
198
192
 
199
- const rows = /**
200
- * Narrows the runtime value to the documented type.
201
- * @type {Array<{parent_id: string | number, count_value: string | number}>} */ (
193
+ const rows = /** @type {Array<{parent_id: string | number, count_value: string | number}>} */ (
202
194
  await countQuery._executeQuery()
203
195
  )
204
196
 
@@ -208,9 +200,7 @@ async function countForEntry({entries, entry, modelClass, parentIds}) {
208
200
  const counts = new Map()
209
201
 
210
202
  for (const row of rows) {
211
- const parentId = /**
212
- * Narrows the runtime value to the documented type.
213
- * @type {string | number} */ (row.parent_id)
203
+ const parentId = /** @type {string | number} */ (row.parent_id)
214
204
  const countValue = Number(row.count_value) || 0
215
205
  counts.set(parentId, countValue)
216
206
  }
@@ -62,9 +62,7 @@ export default function registerActsAsListCallbacks(modelClass, positionColumn,
62
62
  if (isShifting(record)) return
63
63
  if (!record.isPersisted()) return
64
64
 
65
- const modelClass = /**
66
- * Narrows the runtime value to the documented type.
67
- * @type {typeof import("./index.js").default} */ (record.constructor)
65
+ const modelClass = /** @type {typeof import("./index.js").default} */ (record.constructor)
68
66
  const posColumn = modelClass.getColumnNameForAttributeName(positionColumn)
69
67
  const scopeCol = modelClass.getColumnNameForAttributeName(scope)
70
68
  /** @type {Record<string, ?>} */
@@ -79,26 +77,10 @@ export default function registerActsAsListCallbacks(modelClass, positionColumn,
79
77
 
80
78
  if (!posChanged && !scopeChanged) return
81
79
 
82
- const oldPosition = posChanged ? /**
83
- * Narrows the runtime value to the documented type.
84
- * @type {number} */ (rawAttributes[posColumn]) : /**
85
- * Narrows the runtime value to the documented type.
86
- * @type {number} */ (record.readAttribute(positionColumn))
87
- const newPosition = posChanged ? /**
88
- * Narrows the runtime value to the documented type.
89
- * @type {number} */ (changes[posColumn]) : /**
90
- * Narrows the runtime value to the documented type.
91
- * @type {number} */ (record.readAttribute(positionColumn))
92
- const oldScopeValue = scopeChanged ? /**
93
- * Narrows the runtime value to the documented type.
94
- * @type {number} */ (rawAttributes[scopeCol]) : /**
95
- * Narrows the runtime value to the documented type.
96
- * @type {number} */ (record.readAttribute(scope))
97
- const newScopeValue = scopeChanged ? /**
98
- * Narrows the runtime value to the documented type.
99
- * @type {number} */ (changes[scopeCol]) : /**
100
- * Narrows the runtime value to the documented type.
101
- * @type {number} */ (record.readAttribute(scope))
80
+ const oldPosition = posChanged ? /** @type {number} */ (rawAttributes[posColumn]) : /** @type {number} */ (record.readAttribute(positionColumn))
81
+ const newPosition = posChanged ? /** @type {number} */ (changes[posColumn]) : /** @type {number} */ (record.readAttribute(positionColumn))
82
+ const oldScopeValue = scopeChanged ? /** @type {number} */ (rawAttributes[scopeCol]) : /** @type {number} */ (record.readAttribute(scope))
83
+ const newScopeValue = scopeChanged ? /** @type {number} */ (changes[scopeCol]) : /** @type {number} */ (record.readAttribute(scope))
102
84
 
103
85
  if (oldPosition == null || newPosition == null) return
104
86
  if (newPosition === oldPosition && newScopeValue === oldScopeValue) return
@@ -210,9 +192,7 @@ function clearBelongsToChangeForScope(record) {
210
192
  * @returns {Promise<void>}
211
193
  */
212
194
  async function shiftPositionsUp({record, positionColumn, scope, fromPosition, toPosition, scopeValue, excludeRecordId}) {
213
- const modelClass = /**
214
- * Narrows the runtime value to the documented type.
215
- * @type {typeof import("./index.js").default} */ (record.constructor)
195
+ const modelClass = /** @type {typeof import("./index.js").default} */ (record.constructor)
216
196
  const connection = modelClass.connection()
217
197
  const tableName = modelClass._getTable().getName()
218
198
  const resolvedScopeValue = scopeValue != null ? scopeValue : resolveScopeValue(record, scope)
@@ -277,9 +257,7 @@ async function shiftPositionsUp({record, positionColumn, scope, fromPosition, to
277
257
  * @returns {Promise<void>}
278
258
  */
279
259
  async function shiftPositionsDown({record, positionColumn, scope, fromPosition, toPosition, scopeValue}) {
280
- const modelClass = /**
281
- * Narrows the runtime value to the documented type.
282
- * @type {typeof import("./index.js").default} */ (record.constructor)
260
+ const modelClass = /** @type {typeof import("./index.js").default} */ (record.constructor)
283
261
  const connection = modelClass.connection()
284
262
  const tableName = modelClass._getTable().getName()
285
263
  const resolvedScopeValue = scopeValue != null ? scopeValue : resolveScopeValue(record, scope)
@@ -335,9 +313,7 @@ async function shiftPositionsDown({record, positionColumn, scope, fromPosition,
335
313
  * @returns {Promise<number>} - Highest position in scope, or 0 when scope is empty.
336
314
  */
337
315
  async function highestPositionInScope({record, positionColumn, scope, scopeValue}) {
338
- const modelClass = /**
339
- * Narrows the runtime value to the documented type.
340
- * @type {typeof import("./index.js").default} */ (record.constructor)
316
+ const modelClass = /** @type {typeof import("./index.js").default} */ (record.constructor)
341
317
  const connection = modelClass.connection()
342
318
  const scopeColumnName = modelClass.getColumnNameForAttributeName(scope)
343
319
  const positionColumnName = modelClass.getColumnNameForAttributeName(positionColumn)
@@ -372,9 +348,7 @@ function resolveScopeValue(record, scope) {
372
348
 
373
349
  if (attrValue != null) return /** @type {string | number} */ (attrValue)
374
350
 
375
- const modelClass = /**
376
- * Narrows the runtime value to the documented type.
377
- * @type {typeof import("./index.js").default} */ (record.constructor)
351
+ const modelClass = /** @type {typeof import("./index.js").default} */ (record.constructor)
378
352
  const relationships = modelClass.getRelationshipsMap()
379
353
  const scopeColumnName = modelClass.getColumnNameForAttributeName(scope)
380
354
 
@@ -410,9 +384,7 @@ function resolveScopeValue(record, scope) {
410
384
  * @returns {Promise<void>}
411
385
  */
412
386
  async function moveOutOfWay({record, positionColumn, scope, scopeValue, targetScopeValue}) {
413
- const modelClass = /**
414
- * Narrows the runtime value to the documented type.
415
- * @type {typeof import("./index.js").default} */ (record.constructor)
387
+ const modelClass = /** @type {typeof import("./index.js").default} */ (record.constructor)
416
388
  const connection = modelClass.connection()
417
389
  const tableName = modelClass._getTable().getName()
418
390
  const resolvedScopeValue = scopeValue != null ? scopeValue : resolveScopeValue(record, scope)
@@ -55,9 +55,7 @@ function isArrayBuffer(value) {
55
55
  * @returns {value is {arrayBuffer: () => Promise<ArrayBuffer>}} - Whether value supports arrayBuffer().
56
56
  */
57
57
  function isArrayBufferLike(value) {
58
- return Boolean(value && typeof value === "object" && typeof /**
59
- * Narrows the runtime value to the documented type.
60
- * @type {?} */ (value).arrayBuffer === "function")
58
+ return Boolean(value && typeof value === "object" && typeof /** @type {?} */ (value).arrayBuffer === "function")
61
59
  }
62
60
 
63
61
  /**
@@ -81,15 +79,11 @@ function toBuffer(value) {
81
79
  * @returns {Promise<Buffer>} - File content buffer.
82
80
  */
83
81
  async function uploadedFileBuffer(uploadedFile, environmentHandler) {
84
- const memoryBuffer = /**
85
- * Narrows the runtime value to the documented type.
86
- * @type {{getBuffer?: () => Buffer}} */ (uploadedFile).getBuffer?.()
82
+ const memoryBuffer = /** @type {{getBuffer?: () => Buffer}} */ (uploadedFile).getBuffer?.()
87
83
 
88
84
  if (Buffer.isBuffer(memoryBuffer)) return memoryBuffer
89
85
 
90
- const tempPath = /**
91
- * Narrows the runtime value to the documented type.
92
- * @type {{getPath?: () => string}} */ (uploadedFile).getPath?.()
86
+ const tempPath = /** @type {{getPath?: () => string}} */ (uploadedFile).getPath?.()
93
87
 
94
88
  if (typeof tempPath === "string" && tempPath.length > 0) {
95
89
  if (!environmentHandler || typeof environmentHandler.readAttachmentInputFile !== "function") {
@@ -174,23 +168,11 @@ export default async function normalizeRecordAttachmentInput(input, args = {}) {
174
168
  const arrayBuffer = await input.arrayBuffer()
175
169
 
176
170
  buffer = Buffer.from(arrayBuffer)
177
- filename = typeof /**
178
- * Narrows the runtime value to the documented type.
179
- * @type {?} */ (input).name === "string" && /**
180
- * Narrows the runtime value to the documented type.
181
- * @type {?} */ (input).name.length > 0
182
- ? /**
183
- * Narrows the runtime value to the documented type.
184
- * @type {?} */ (input).name
171
+ filename = typeof /** @type {?} */ (input).name === "string" && /** @type {?} */ (input).name.length > 0
172
+ ? /** @type {?} */ (input).name
185
173
  : defaultFilename
186
- contentType = typeof /**
187
- * Narrows the runtime value to the documented type.
188
- * @type {?} */ (input).type === "string" && /**
189
- * Narrows the runtime value to the documented type.
190
- * @type {?} */ (input).type.length > 0
191
- ? /**
192
- * Narrows the runtime value to the documented type.
193
- * @type {?} */ (input).type
174
+ contentType = typeof /** @type {?} */ (input).type === "string" && /** @type {?} */ (input).type.length > 0
175
+ ? /** @type {?} */ (input).type
194
176
  : null
195
177
  } else if (typeof input === "string" || Buffer.isBuffer(input) || isArrayBuffer(input) || isUint8Array(input)) {
196
178
  buffer = toBuffer(input)
@@ -15,9 +15,7 @@ function throwS3ConfigurationError(message) {
15
15
  * @returns {boolean} - Whether value is a readable stream.
16
16
  */
17
17
  function isReadableStream(value) {
18
- return Boolean(value && typeof value === "object" && typeof /**
19
- * Narrows the runtime value to the documented type.
20
- * @type {?} */ (value).pipe === "function")
18
+ return Boolean(value && typeof value === "object" && typeof /** @type {?} */ (value).pipe === "function")
21
19
  }
22
20
 
23
21
  /**
@@ -26,9 +24,7 @@ function isReadableStream(value) {
26
24
  * @returns {Promise<?>} - Imported module.
27
25
  */
28
26
  async function dynamicImport(specifier) {
29
- const importer = /**
30
- * Narrows the runtime value to the documented type.
31
- * @type {(moduleSpecifier: string) => Promise<?>} */ (
27
+ const importer = /** @type {(moduleSpecifier: string) => Promise<?>} */ (
32
28
  new Function("moduleSpecifier", "return import(moduleSpecifier)")
33
29
  )
34
30
 
@@ -54,14 +50,10 @@ async function streamToBuffer(value) {
54
50
  * @type {Buffer[]} */
55
51
  const chunks = []
56
52
 
57
- const readableStream = /**
58
- * Narrows the runtime value to the documented type.
59
- * @type {?} */ (value)
53
+ const readableStream = /** @type {?} */ (value)
60
54
 
61
55
  await new Promise((resolve, reject) => {
62
- readableStream.on("data", (/**
63
- * Narrows the runtime value to the documented type.
64
- * @type {Buffer | Uint8Array | ArrayBuffer | string} */ chunk) => {
56
+ readableStream.on("data", (/** @type {Buffer | Uint8Array | ArrayBuffer | string} */ chunk) => {
65
57
  if (Buffer.isBuffer(chunk)) {
66
58
  chunks.push(chunk)
67
59
  } else if (chunk instanceof ArrayBuffer) {
@@ -456,9 +456,7 @@ export default class RecordAttachmentsStore {
456
456
  let attachmentDriver
457
457
 
458
458
  if (typeof driverReference === "function") {
459
- const DriverClass = /**
460
- * Narrows the runtime value to the documented type.
461
- * @type {AttachmentDriverConstructor} */ (driverReference)
459
+ const DriverClass = /** @type {AttachmentDriverConstructor} */ (driverReference)
462
460
 
463
461
  attachmentDriver = new DriverClass({
464
462
  attachmentName,
@@ -561,9 +559,7 @@ export default class RecordAttachmentsStore {
561
559
  .order("position DESC")
562
560
  .limit(1)
563
561
  const rows = await query.results()
564
- const currentRow = /**
565
- * Narrows the runtime value to the documented type.
566
- * @type {{position?: string | number | null} | undefined} */ (rows[0])
562
+ const currentRow = /** @type {{position?: string | number | null} | undefined} */ (rows[0])
567
563
  const current = Number(currentRow?.position)
568
564
 
569
565
  if (!Number.isFinite(current)) return 0