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.
- package/README.md +1 -1
- package/build/application.js +1 -3
- package/build/background-jobs/cron-expression.js +1 -3
- package/build/background-jobs/forked-runner-child.js +1 -3
- package/build/background-jobs/job.js +1 -3
- package/build/background-jobs/scheduler.js +2 -6
- package/build/background-jobs/store.js +2 -6
- package/build/background-jobs/web/controller.js +1 -3
- package/build/background-jobs/worker.js +1 -3
- package/build/beacon/client.js +2 -6
- package/build/cli/tenant-database-command-helper.js +1 -3
- package/build/configuration.js +29 -32
- package/build/controller.js +4 -14
- package/build/current.js +2 -2
- package/build/database/drivers/mssql/index.js +1 -3
- package/build/database/drivers/mysql/index.js +2 -6
- package/build/database/drivers/pgsql/index.js +1 -3
- package/build/database/drivers/sqlite/base.js +3 -9
- package/build/database/drivers/sqlite/index.js +3 -9
- package/build/database/drivers/sqlite/table.js +1 -3
- package/build/database/migrator.js +1 -3
- package/build/database/pool/async-tracked-multi-connection.js +20 -45
- package/build/database/pool/base-methods-forward.js +2 -10
- package/build/database/pool/base.js +5 -15
- package/build/database/query/index.js +4 -12
- package/build/database/query/join-object.js +3 -9
- package/build/database/query/model-class-query.js +21 -63
- package/build/database/query/preloader/belongs-to.js +9 -27
- package/build/database/query/preloader/has-many.js +7 -21
- package/build/database/query/preloader/has-one.js +3 -9
- package/build/database/query/preloader.js +6 -18
- package/build/database/query/query-data.js +5 -15
- package/build/database/query/where-model-class-hash.js +5 -15
- package/build/database/query/with-count.js +5 -15
- package/build/database/record/acts-as-list.js +10 -38
- package/build/database/record/attachments/normalize-input.js +7 -25
- package/build/database/record/attachments/storage-drivers/s3.js +4 -12
- package/build/database/record/attachments/store.js +2 -6
- package/build/database/record/index.js +56 -172
- package/build/database/record/instance-relationships/base.js +6 -20
- package/build/database/record/instance-relationships/belongs-to.js +2 -6
- package/build/database/record/instance-relationships/has-many.js +4 -12
- package/build/database/record/instance-relationships/has-one.js +4 -12
- package/build/database/record/relationships/base.js +1 -5
- package/build/database/record/validators/presence.js +1 -3
- package/build/database/record/validators/uniqueness.js +4 -12
- package/build/environment-handlers/browser.js +1 -3
- package/build/environment-handlers/node/cli/commands/console.js +2 -6
- package/build/environment-handlers/node/cli/commands/db/schema/load.js +1 -3
- package/build/environment-handlers/node/cli/commands/generate/frontend-models.js +67 -11
- package/build/environment-handlers/node.js +15 -6
- package/build/frontend-model-controller.js +34 -110
- package/build/frontend-models/base.js +45 -151
- package/build/frontend-models/clear-pending-debounced-callback.js +1 -3
- package/build/frontend-models/preloader.js +3 -9
- package/build/frontend-models/query.js +11 -33
- package/build/frontend-models/resource-definition.js +2 -6
- package/build/frontend-models/transport-serialization.js +7 -21
- package/build/frontend-models/use-destroyed-event.js +2 -6
- package/build/frontend-models/use-model-class-event.js +2 -6
- package/build/frontend-models/use-updated-event.js +3 -9
- package/build/frontend-models/websocket-channel.js +9 -27
- package/build/frontend-models/websocket-publishers.js +12 -23
- package/build/http-server/client/index.js +6 -18
- package/build/http-server/client/params-to-object.js +6 -18
- package/build/http-server/client/request-buffer/index.js +1 -3
- package/build/http-server/client/request-parser.js +1 -3
- package/build/http-server/client/request-runner.js +4 -12
- package/build/http-server/client/websocket-session.js +6 -18
- package/build/http-server/development-reloader.js +2 -6
- package/build/http-server/remote-address.js +1 -5
- package/build/http-server/server-client.js +3 -9
- package/build/http-server/server-lock.js +2 -6
- package/build/http-server/websocket-channel-subscribers.js +2 -6
- package/build/http-server/websocket-event-log-store.js +5 -15
- package/build/http-server/websocket-events-host.js +1 -3
- package/build/http-server/worker-handler/in-process.js +3 -11
- package/build/http-server/worker-handler/worker-thread.js +1 -3
- package/build/logger.js +2 -6
- package/build/mailer/backends/smtp.js +1 -5
- package/build/mailer/base.js +4 -16
- package/build/plugins/sqljs-wasm-route-controller.js +1 -3
- package/build/routes/basic-route.js +1 -3
- package/build/routes/resolver.js +4 -14
- package/build/src/application.d.ts.map +1 -1
- package/build/src/application.js +2 -4
- package/build/src/background-jobs/cron-expression.d.ts.map +1 -1
- package/build/src/background-jobs/cron-expression.js +2 -4
- package/build/src/background-jobs/forked-runner-child.js +2 -4
- package/build/src/background-jobs/job.d.ts.map +1 -1
- package/build/src/background-jobs/job.js +2 -4
- package/build/src/background-jobs/scheduler.d.ts.map +1 -1
- package/build/src/background-jobs/scheduler.js +3 -7
- package/build/src/background-jobs/store.d.ts.map +1 -1
- package/build/src/background-jobs/store.js +3 -7
- package/build/src/background-jobs/web/controller.d.ts.map +1 -1
- package/build/src/background-jobs/web/controller.js +2 -5
- package/build/src/background-jobs/worker.d.ts.map +1 -1
- package/build/src/background-jobs/worker.js +2 -4
- package/build/src/beacon/client.d.ts.map +1 -1
- package/build/src/beacon/client.js +3 -7
- package/build/src/cli/tenant-database-command-helper.d.ts.map +1 -1
- package/build/src/cli/tenant-database-command-helper.js +2 -4
- package/build/src/configuration.d.ts.map +1 -1
- package/build/src/configuration.js +27 -35
- package/build/src/controller.d.ts.map +1 -1
- package/build/src/controller.js +5 -15
- package/build/src/current.d.ts +4 -4
- package/build/src/current.d.ts.map +1 -1
- package/build/src/current.js +3 -3
- package/build/src/database/drivers/mssql/index.d.ts.map +1 -1
- package/build/src/database/drivers/mssql/index.js +2 -4
- package/build/src/database/drivers/mysql/index.d.ts.map +1 -1
- package/build/src/database/drivers/mysql/index.js +3 -7
- package/build/src/database/drivers/pgsql/index.d.ts.map +1 -1
- package/build/src/database/drivers/pgsql/index.js +2 -4
- package/build/src/database/drivers/sqlite/base.d.ts.map +1 -1
- package/build/src/database/drivers/sqlite/base.js +4 -10
- package/build/src/database/drivers/sqlite/index.d.ts.map +1 -1
- package/build/src/database/drivers/sqlite/index.js +4 -10
- package/build/src/database/drivers/sqlite/table.d.ts.map +1 -1
- package/build/src/database/drivers/sqlite/table.js +2 -4
- package/build/src/database/migrator.d.ts.map +1 -1
- package/build/src/database/migrator.js +2 -4
- package/build/src/database/pool/async-tracked-multi-connection.d.ts.map +1 -1
- package/build/src/database/pool/async-tracked-multi-connection.js +21 -47
- package/build/src/database/pool/base-methods-forward.d.ts.map +1 -1
- package/build/src/database/pool/base-methods-forward.js +3 -11
- package/build/src/database/pool/base.d.ts.map +1 -1
- package/build/src/database/pool/base.js +6 -16
- package/build/src/database/query/index.d.ts.map +1 -1
- package/build/src/database/query/index.js +5 -13
- package/build/src/database/query/join-object.d.ts.map +1 -1
- package/build/src/database/query/join-object.js +4 -10
- package/build/src/database/query/model-class-query.d.ts.map +1 -1
- package/build/src/database/query/model-class-query.js +22 -64
- package/build/src/database/query/preloader/belongs-to.d.ts.map +1 -1
- package/build/src/database/query/preloader/belongs-to.js +10 -28
- package/build/src/database/query/preloader/has-many.d.ts.map +1 -1
- package/build/src/database/query/preloader/has-many.js +8 -22
- package/build/src/database/query/preloader/has-one.d.ts.map +1 -1
- package/build/src/database/query/preloader/has-one.js +4 -10
- package/build/src/database/query/preloader.d.ts.map +1 -1
- package/build/src/database/query/preloader.js +7 -20
- package/build/src/database/query/query-data.d.ts.map +1 -1
- package/build/src/database/query/query-data.js +6 -16
- package/build/src/database/query/where-model-class-hash.d.ts.map +1 -1
- package/build/src/database/query/where-model-class-hash.js +6 -16
- package/build/src/database/query/with-count.d.ts.map +1 -1
- package/build/src/database/query/with-count.js +6 -17
- package/build/src/database/record/acts-as-list.d.ts.map +1 -1
- package/build/src/database/record/acts-as-list.js +11 -47
- package/build/src/database/record/attachments/normalize-input.d.ts.map +1 -1
- package/build/src/database/record/attachments/normalize-input.js +8 -30
- package/build/src/database/record/attachments/storage-drivers/s3.d.ts.map +1 -1
- package/build/src/database/record/attachments/storage-drivers/s3.js +5 -13
- package/build/src/database/record/attachments/store.d.ts.map +1 -1
- package/build/src/database/record/attachments/store.js +3 -7
- package/build/src/database/record/index.d.ts +6 -11
- package/build/src/database/record/index.d.ts.map +1 -1
- package/build/src/database/record/index.js +54 -174
- package/build/src/database/record/instance-relationships/base.d.ts.map +1 -1
- package/build/src/database/record/instance-relationships/base.js +7 -21
- package/build/src/database/record/instance-relationships/belongs-to.d.ts.map +1 -1
- package/build/src/database/record/instance-relationships/belongs-to.js +3 -7
- package/build/src/database/record/instance-relationships/has-many.d.ts.map +1 -1
- package/build/src/database/record/instance-relationships/has-many.js +5 -13
- package/build/src/database/record/instance-relationships/has-one.d.ts.map +1 -1
- package/build/src/database/record/instance-relationships/has-one.js +5 -13
- package/build/src/database/record/relationships/base.d.ts.map +1 -1
- package/build/src/database/record/relationships/base.js +2 -6
- package/build/src/database/record/validators/presence.d.ts.map +1 -1
- package/build/src/database/record/validators/presence.js +2 -4
- package/build/src/database/record/validators/uniqueness.d.ts.map +1 -1
- package/build/src/database/record/validators/uniqueness.js +5 -14
- package/build/src/environment-handlers/browser.d.ts.map +1 -1
- package/build/src/environment-handlers/browser.js +2 -4
- package/build/src/environment-handlers/node/cli/commands/console.d.ts.map +1 -1
- package/build/src/environment-handlers/node/cli/commands/console.js +3 -7
- package/build/src/environment-handlers/node/cli/commands/db/schema/load.d.ts.map +1 -1
- package/build/src/environment-handlers/node/cli/commands/db/schema/load.js +2 -4
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +38 -0
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts.map +1 -1
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.js +58 -12
- package/build/src/environment-handlers/node.d.ts.map +1 -1
- package/build/src/environment-handlers/node.js +16 -7
- package/build/src/frontend-model-controller.d.ts.map +1 -1
- package/build/src/frontend-model-controller.js +35 -114
- package/build/src/frontend-models/base.d.ts.map +1 -1
- package/build/src/frontend-models/base.js +46 -158
- package/build/src/frontend-models/clear-pending-debounced-callback.d.ts.map +1 -1
- package/build/src/frontend-models/clear-pending-debounced-callback.js +2 -4
- package/build/src/frontend-models/preloader.d.ts.map +1 -1
- package/build/src/frontend-models/preloader.js +4 -11
- package/build/src/frontend-models/query.d.ts.map +1 -1
- package/build/src/frontend-models/query.js +12 -34
- package/build/src/frontend-models/resource-definition.d.ts.map +1 -1
- package/build/src/frontend-models/resource-definition.js +3 -7
- package/build/src/frontend-models/transport-serialization.d.ts.map +1 -1
- package/build/src/frontend-models/transport-serialization.js +8 -23
- package/build/src/frontend-models/use-destroyed-event.js +3 -7
- package/build/src/frontend-models/use-model-class-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-model-class-event.js +3 -7
- package/build/src/frontend-models/use-updated-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-updated-event.js +4 -10
- package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
- package/build/src/frontend-models/websocket-channel.js +10 -32
- package/build/src/frontend-models/websocket-publishers.d.ts.map +1 -1
- package/build/src/frontend-models/websocket-publishers.js +14 -25
- package/build/src/http-server/client/index.d.ts.map +1 -1
- package/build/src/http-server/client/index.js +7 -21
- package/build/src/http-server/client/params-to-object.d.ts.map +1 -1
- package/build/src/http-server/client/params-to-object.js +7 -21
- package/build/src/http-server/client/request-buffer/index.d.ts.map +1 -1
- package/build/src/http-server/client/request-buffer/index.js +2 -4
- package/build/src/http-server/client/request-parser.d.ts.map +1 -1
- package/build/src/http-server/client/request-parser.js +2 -4
- package/build/src/http-server/client/request-runner.d.ts.map +1 -1
- package/build/src/http-server/client/request-runner.js +5 -14
- package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
- package/build/src/http-server/client/websocket-session.js +7 -20
- package/build/src/http-server/development-reloader.d.ts.map +1 -1
- package/build/src/http-server/development-reloader.js +3 -7
- package/build/src/http-server/remote-address.d.ts.map +1 -1
- package/build/src/http-server/remote-address.js +2 -6
- package/build/src/http-server/server-client.d.ts.map +1 -1
- package/build/src/http-server/server-client.js +4 -10
- package/build/src/http-server/server-lock.d.ts.map +1 -1
- package/build/src/http-server/server-lock.js +3 -7
- package/build/src/http-server/websocket-channel-subscribers.d.ts.map +1 -1
- package/build/src/http-server/websocket-channel-subscribers.js +3 -7
- package/build/src/http-server/websocket-event-log-store.d.ts.map +1 -1
- package/build/src/http-server/websocket-event-log-store.js +6 -16
- package/build/src/http-server/websocket-events-host.d.ts.map +1 -1
- package/build/src/http-server/websocket-events-host.js +2 -5
- package/build/src/http-server/worker-handler/in-process.d.ts.map +1 -1
- package/build/src/http-server/worker-handler/in-process.js +4 -12
- package/build/src/http-server/worker-handler/worker-thread.d.ts.map +1 -1
- package/build/src/http-server/worker-handler/worker-thread.js +2 -4
- package/build/src/logger.d.ts.map +1 -1
- package/build/src/logger.js +3 -7
- package/build/src/mailer/backends/smtp.d.ts.map +1 -1
- package/build/src/mailer/backends/smtp.js +2 -6
- package/build/src/mailer/base.d.ts.map +1 -1
- package/build/src/mailer/base.js +5 -17
- package/build/src/plugins/sqljs-wasm-route-controller.d.ts.map +1 -1
- package/build/src/plugins/sqljs-wasm-route-controller.js +2 -4
- package/build/src/routes/basic-route.d.ts.map +1 -1
- package/build/src/routes/basic-route.js +2 -4
- package/build/src/routes/resolver.d.ts.map +1 -1
- package/build/src/routes/resolver.js +5 -15
- package/build/src/testing/expect-utils.d.ts.map +1 -1
- package/build/src/testing/expect-utils.js +9 -27
- package/build/src/testing/expect.d.ts.map +1 -1
- package/build/src/testing/expect.js +5 -15
- package/build/src/testing/test-runner.d.ts.map +1 -1
- package/build/src/testing/test-runner.js +4 -10
- package/build/src/testing/test.d.ts.map +1 -1
- package/build/src/testing/test.js +5 -17
- package/build/src/utils/model-scope.d.ts.map +1 -1
- package/build/src/utils/model-scope.js +2 -5
- package/build/src/utils/ransack.d.ts.map +1 -1
- package/build/src/utils/ransack.js +15 -42
- package/build/src/utils/with-tracked-stack-async-hooks.d.ts.map +1 -1
- package/build/src/utils/with-tracked-stack-async-hooks.js +4 -12
- package/build/src/utils/with-tracked-stack.d.ts.map +1 -1
- package/build/src/utils/with-tracked-stack.js +3 -8
- package/build/testing/expect-utils.js +8 -26
- package/build/testing/expect.js +4 -14
- package/build/testing/test-runner.js +3 -9
- package/build/testing/test.js +4 -12
- package/build/utils/model-scope.js +1 -3
- package/build/utils/ransack.js +15 -41
- package/build/utils/with-tracked-stack-async-hooks.js +3 -9
- package/build/utils/with-tracked-stack.js +2 -6
- package/package.json +3 -2
- package/src/application.js +1 -3
- package/src/background-jobs/cron-expression.js +1 -3
- package/src/background-jobs/forked-runner-child.js +1 -3
- package/src/background-jobs/job.js +1 -3
- package/src/background-jobs/scheduler.js +2 -6
- package/src/background-jobs/store.js +2 -6
- package/src/background-jobs/web/controller.js +1 -3
- package/src/background-jobs/worker.js +1 -3
- package/src/beacon/client.js +2 -6
- package/src/cli/tenant-database-command-helper.js +1 -3
- package/src/configuration.js +29 -32
- package/src/controller.js +4 -14
- package/src/current.js +2 -2
- package/src/database/drivers/mssql/index.js +1 -3
- package/src/database/drivers/mysql/index.js +2 -6
- package/src/database/drivers/pgsql/index.js +1 -3
- package/src/database/drivers/sqlite/base.js +3 -9
- package/src/database/drivers/sqlite/index.js +3 -9
- package/src/database/drivers/sqlite/table.js +1 -3
- package/src/database/migrator.js +1 -3
- package/src/database/pool/async-tracked-multi-connection.js +20 -45
- package/src/database/pool/base-methods-forward.js +2 -10
- package/src/database/pool/base.js +5 -15
- package/src/database/query/index.js +4 -12
- package/src/database/query/join-object.js +3 -9
- package/src/database/query/model-class-query.js +21 -63
- package/src/database/query/preloader/belongs-to.js +9 -27
- package/src/database/query/preloader/has-many.js +7 -21
- package/src/database/query/preloader/has-one.js +3 -9
- package/src/database/query/preloader.js +6 -18
- package/src/database/query/query-data.js +5 -15
- package/src/database/query/where-model-class-hash.js +5 -15
- package/src/database/query/with-count.js +5 -15
- package/src/database/record/acts-as-list.js +10 -38
- package/src/database/record/attachments/normalize-input.js +7 -25
- package/src/database/record/attachments/storage-drivers/s3.js +4 -12
- package/src/database/record/attachments/store.js +2 -6
- package/src/database/record/index.js +56 -172
- package/src/database/record/instance-relationships/base.js +6 -20
- package/src/database/record/instance-relationships/belongs-to.js +2 -6
- package/src/database/record/instance-relationships/has-many.js +4 -12
- package/src/database/record/instance-relationships/has-one.js +4 -12
- package/src/database/record/relationships/base.js +1 -5
- package/src/database/record/validators/presence.js +1 -3
- package/src/database/record/validators/uniqueness.js +4 -12
- package/src/environment-handlers/browser.js +1 -3
- package/src/environment-handlers/node/cli/commands/console.js +2 -6
- package/src/environment-handlers/node/cli/commands/db/schema/load.js +1 -3
- package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +67 -11
- package/src/environment-handlers/node.js +15 -6
- package/src/frontend-model-controller.js +34 -110
- package/src/frontend-models/base.js +45 -151
- package/src/frontend-models/clear-pending-debounced-callback.js +1 -3
- package/src/frontend-models/preloader.js +3 -9
- package/src/frontend-models/query.js +11 -33
- package/src/frontend-models/resource-definition.js +2 -6
- package/src/frontend-models/transport-serialization.js +7 -21
- package/src/frontend-models/use-destroyed-event.js +2 -6
- package/src/frontend-models/use-model-class-event.js +2 -6
- package/src/frontend-models/use-updated-event.js +3 -9
- package/src/frontend-models/websocket-channel.js +9 -27
- package/src/frontend-models/websocket-publishers.js +12 -23
- package/src/http-server/client/index.js +6 -18
- package/src/http-server/client/params-to-object.js +6 -18
- package/src/http-server/client/request-buffer/index.js +1 -3
- package/src/http-server/client/request-parser.js +1 -3
- package/src/http-server/client/request-runner.js +4 -12
- package/src/http-server/client/websocket-session.js +6 -18
- package/src/http-server/development-reloader.js +2 -6
- package/src/http-server/remote-address.js +1 -5
- package/src/http-server/server-client.js +3 -9
- package/src/http-server/server-lock.js +2 -6
- package/src/http-server/websocket-channel-subscribers.js +2 -6
- package/src/http-server/websocket-event-log-store.js +5 -15
- package/src/http-server/websocket-events-host.js +1 -3
- package/src/http-server/worker-handler/in-process.js +3 -11
- package/src/http-server/worker-handler/worker-thread.js +1 -3
- package/src/logger.js +2 -6
- package/src/mailer/backends/smtp.js +1 -5
- package/src/mailer/base.js +4 -16
- package/src/plugins/sqljs-wasm-route-controller.js +1 -3
- package/src/routes/basic-route.js +1 -3
- package/src/routes/resolver.js +4 -14
- package/src/testing/expect-utils.js +8 -26
- package/src/testing/expect.js +4 -14
- package/src/testing/test-runner.js +3 -9
- package/src/testing/test.js +4 -12
- package/src/utils/model-scope.js +1 -3
- package/src/utils/ransack.js +15 -41
- package/src/utils/with-tracked-stack-async-hooks.js +3 -9
- package/src/utils/with-tracked-stack.js +2 -6
|
@@ -99,9 +99,12 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
99
99
|
*/
|
|
100
100
|
constructor({configuration, identifier}) {
|
|
101
101
|
super({configuration, identifier})
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Runs a callback without the inherited current connection context.
|
|
104
|
+
* @type {(callback: () => ?) => ?}
|
|
105
|
+
*/
|
|
106
|
+
const withoutCurrentConnectionContext = (callback) => this.asyncLocalStorage.run(undefined, callback)
|
|
107
|
+
this._withoutCurrentConnectionContext = withoutCurrentConnectionContext
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
/**
|
|
@@ -111,9 +114,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
111
114
|
*/
|
|
112
115
|
async checkin(connection) {
|
|
113
116
|
const id = connection.getIdSeq()
|
|
114
|
-
const trackedConnection = /**
|
|
115
|
-
* Narrows the runtime value to the documented type.
|
|
116
|
-
* @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean, [CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
|
|
117
|
+
const trackedConnection = /** @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean, [CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
|
|
117
118
|
|
|
118
119
|
if (trackedConnection[CLOSED_CONNECTION]) {
|
|
119
120
|
this.untrackConnectionInUse(connection, id)
|
|
@@ -243,9 +244,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
243
244
|
* @returns {boolean} - Whether the connection matches the reuse key.
|
|
244
245
|
*/
|
|
245
246
|
connectionMatchesReuseKey(connection, reuseKey) {
|
|
246
|
-
const connectionWithPoolKey = /**
|
|
247
|
-
* Narrows the runtime value to the documented type.
|
|
248
|
-
* @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
|
|
247
|
+
const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
|
|
249
248
|
|
|
250
249
|
return connectionWithPoolKey[POOL_CONFIGURATION_KEY] === reuseKey
|
|
251
250
|
}
|
|
@@ -261,9 +260,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
261
260
|
|
|
262
261
|
const id = this.idSeq++
|
|
263
262
|
|
|
264
|
-
const trackedConnection = /**
|
|
265
|
-
* Narrows the runtime value to the documented type.
|
|
266
|
-
* @type {import("../drivers/base.js").default & {[CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
|
|
263
|
+
const trackedConnection = /** @type {import("../drivers/base.js").default & {[CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
|
|
267
264
|
delete trackedConnection[IDLE_CONNECTION_CHECKED_IN_AT]
|
|
268
265
|
trackedConnection[CONNECTION_CHECKED_OUT_AT] = Date.now()
|
|
269
266
|
|
|
@@ -362,9 +359,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
362
359
|
|
|
363
360
|
try {
|
|
364
361
|
const connection = await this.spawnConnectionWithConfiguration(databaseConfig)
|
|
365
|
-
const connectionWithPoolKey = /**
|
|
366
|
-
* Narrows the runtime value to the documented type.
|
|
367
|
-
* @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
|
|
362
|
+
const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
|
|
368
363
|
|
|
369
364
|
connectionWithPoolKey[POOL_CONFIGURATION_KEY] = reuseKey
|
|
370
365
|
connection.setSchemaCacheInvalidator(() => {
|
|
@@ -709,9 +704,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
709
704
|
* @returns {void} - No return value.
|
|
710
705
|
*/
|
|
711
706
|
setGlobalConnection(connection) {
|
|
712
|
-
const klass = /**
|
|
713
|
-
* Narrows the runtime value to the documented type.
|
|
714
|
-
* @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
|
|
707
|
+
const klass = /** @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
|
|
715
708
|
let mapForConfiguration = klass.globalConnections.get(this.configuration)
|
|
716
709
|
|
|
717
710
|
if (!mapForConfiguration) {
|
|
@@ -816,9 +809,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
816
809
|
*/
|
|
817
810
|
addInUseDebugConnectionSnapshots({connections, now, seenConnections}) {
|
|
818
811
|
for (const [id, connection] of Object.entries(this.connectionsInUse)) {
|
|
819
|
-
const trackedConnection = /**
|
|
820
|
-
* Narrows the runtime value to the documented type.
|
|
821
|
-
* @type {import("../drivers/base.js").default & {[CONNECTION_CHECKED_OUT_AT]?: number}} */ (connection)
|
|
812
|
+
const trackedConnection = /** @type {import("../drivers/base.js").default & {[CONNECTION_CHECKED_OUT_AT]?: number}} */ (connection)
|
|
822
813
|
const checkedOutAt = trackedConnection[CONNECTION_CHECKED_OUT_AT]
|
|
823
814
|
const checkedOutForMs = typeof checkedOutAt === "number" ? Math.max(0, now - checkedOutAt) : undefined
|
|
824
815
|
|
|
@@ -838,9 +829,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
838
829
|
|
|
839
830
|
seenConnections.add(connection)
|
|
840
831
|
|
|
841
|
-
const trackedConnection = /**
|
|
842
|
-
* Narrows the runtime value to the documented type.
|
|
843
|
-
* @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
|
|
832
|
+
const trackedConnection = /** @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
|
|
844
833
|
const checkedInAt = trackedConnection[IDLE_CONNECTION_CHECKED_IN_AT]
|
|
845
834
|
const idleForMs = typeof checkedInAt === "number" ? Math.max(0, now - checkedInAt) : undefined
|
|
846
835
|
|
|
@@ -906,9 +895,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
906
895
|
* @returns {import("../drivers/base.js").default | undefined} - The global connection for this pool identifier.
|
|
907
896
|
*/
|
|
908
897
|
getGlobalConnectionForIdentifier() {
|
|
909
|
-
const klass = /**
|
|
910
|
-
* Narrows the runtime value to the documented type.
|
|
911
|
-
* @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
|
|
898
|
+
const klass = /** @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
|
|
912
899
|
const mapForConfiguration = klass.globalConnections.get(this.configuration)
|
|
913
900
|
|
|
914
901
|
return mapForConfiguration?.[this.identifier]
|
|
@@ -919,9 +906,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
919
906
|
* @returns {void} - No return value.
|
|
920
907
|
*/
|
|
921
908
|
clearGlobalConnectionForIdentifier() {
|
|
922
|
-
const klass = /**
|
|
923
|
-
* Narrows the runtime value to the documented type.
|
|
924
|
-
* @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
|
|
909
|
+
const klass = /** @type {typeof VelociousDatabasePoolAsyncTrackedMultiConnection} */ (this.constructor)
|
|
925
910
|
const mapForConfiguration = klass.globalConnections.get(this.configuration)
|
|
926
911
|
|
|
927
912
|
if (!mapForConfiguration) return
|
|
@@ -975,9 +960,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
975
960
|
if (this.idleConnectionReaperTimer) return
|
|
976
961
|
if (!this.hasIdleConnectionsToReap()) return
|
|
977
962
|
|
|
978
|
-
const delay = this.nextIdleConnectionReapDelay(/**
|
|
979
|
-
* Narrows the runtime value to the documented type.
|
|
980
|
-
* @type {number} */ (this.idleTimeoutMillis()))
|
|
963
|
+
const delay = this.nextIdleConnectionReapDelay(/** @type {number} */ (this.idleTimeoutMillis()))
|
|
981
964
|
|
|
982
965
|
this.idleConnectionReaperTimer = setTimeout(() => {
|
|
983
966
|
this.idleConnectionReaperTimer = undefined
|
|
@@ -1011,9 +994,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
1011
994
|
for (const connection of this.connections) {
|
|
1012
995
|
if (this.connectionHasOpenTransaction(connection)) continue
|
|
1013
996
|
|
|
1014
|
-
const trackedConnection = /**
|
|
1015
|
-
* Narrows the runtime value to the documented type.
|
|
1016
|
-
* @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
|
|
997
|
+
const trackedConnection = /** @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
|
|
1017
998
|
const checkedInAt = trackedConnection[IDLE_CONNECTION_CHECKED_IN_AT]
|
|
1018
999
|
|
|
1019
1000
|
if (typeof checkedInAt !== "number") continue
|
|
@@ -1109,9 +1090,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
1109
1090
|
* @returns {boolean} - Whether the connection is marked closed.
|
|
1110
1091
|
*/
|
|
1111
1092
|
connectionIsClosed(connection) {
|
|
1112
|
-
const trackedConnection = /**
|
|
1113
|
-
* Narrows the runtime value to the documented type.
|
|
1114
|
-
* @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean}} */ (connection)
|
|
1093
|
+
const trackedConnection = /** @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean}} */ (connection)
|
|
1115
1094
|
|
|
1116
1095
|
return Boolean(trackedConnection[CLOSED_CONNECTION])
|
|
1117
1096
|
}
|
|
@@ -1122,9 +1101,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
1122
1101
|
* @returns {boolean} - Whether the idle connection expired.
|
|
1123
1102
|
*/
|
|
1124
1103
|
idleConnectionExpired({connection, idleTimeoutMillis, now}) {
|
|
1125
|
-
const trackedConnection = /**
|
|
1126
|
-
* Narrows the runtime value to the documented type.
|
|
1127
|
-
* @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
|
|
1104
|
+
const trackedConnection = /** @type {import("../drivers/base.js").default & {[IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
|
|
1128
1105
|
const checkedInAt = trackedConnection[IDLE_CONNECTION_CHECKED_IN_AT]
|
|
1129
1106
|
|
|
1130
1107
|
return typeof checkedInAt === "number" && now - checkedInAt >= idleTimeoutMillis
|
|
@@ -1174,9 +1151,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
1174
1151
|
return await existingClose
|
|
1175
1152
|
}
|
|
1176
1153
|
|
|
1177
|
-
const trackedConnection = /**
|
|
1178
|
-
* Narrows the runtime value to the documented type.
|
|
1179
|
-
* @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean, [CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
|
|
1154
|
+
const trackedConnection = /** @type {import("../drivers/base.js").default & {[CLOSED_CONNECTION]?: boolean, [CONNECTION_CHECKED_OUT_AT]?: number, [IDLE_CONNECTION_CHECKED_IN_AT]?: number}} */ (connection)
|
|
1180
1155
|
|
|
1181
1156
|
trackedConnection[CLOSED_CONNECTION] = true
|
|
1182
1157
|
delete trackedConnection[CONNECTION_CHECKED_OUT_AT]
|
|
@@ -28,20 +28,12 @@ export default function baseMethodsForward(PoolBase) {
|
|
|
28
28
|
"updateSql"
|
|
29
29
|
]
|
|
30
30
|
|
|
31
|
-
const prototype = /**
|
|
32
|
-
* Narrows the runtime value to the documented type.
|
|
33
|
-
* @type {Record<string, (...args: Array<?>) => ?>} */ (/**
|
|
34
|
-
* Narrows the runtime value to the documented type.
|
|
35
|
-
* @type {?} */ (PoolBase.prototype))
|
|
31
|
+
const prototype = /** @type {Record<string, (...args: Array<?>) => ?>} */ (/** @type {?} */ (PoolBase.prototype))
|
|
36
32
|
|
|
37
33
|
for (const forwardMethod of forwardMethods) {
|
|
38
34
|
prototype[forwardMethod] = function(...args) {
|
|
39
35
|
const connection = this.getCurrentConnection()
|
|
40
|
-
const connectionRecord = /**
|
|
41
|
-
* Narrows the runtime value to the documented type.
|
|
42
|
-
* @type {Record<string, (...args: Array<?>) => ?>} */ (/**
|
|
43
|
-
* Narrows the runtime value to the documented type.
|
|
44
|
-
* @type {?} */ (connection))
|
|
36
|
+
const connectionRecord = /** @type {Record<string, (...args: Array<?>) => ?>} */ (/** @type {?} */ (connection))
|
|
45
37
|
const connectionMethod = connectionRecord[forwardMethod]
|
|
46
38
|
|
|
47
39
|
if (!connectionMethod) throw new Error(`${forwardMethod} isn't defined on driver`)
|
|
@@ -58,13 +58,9 @@ function stableStringify(value) {
|
|
|
58
58
|
|
|
59
59
|
if (value && typeof value === "object") {
|
|
60
60
|
const entries = Object
|
|
61
|
-
.keys(/**
|
|
62
|
-
* Narrows the runtime value to the documented type.
|
|
63
|
-
* @type {Record<string, ?>} */ (value))
|
|
61
|
+
.keys(/** @type {Record<string, ?>} */ (value))
|
|
64
62
|
.sort()
|
|
65
|
-
.map((key) => `${JSON.stringify(key)}:${stableStringify(/**
|
|
66
|
-
* Narrows the runtime value to the documented type.
|
|
67
|
-
* @type {Record<string, ?>} */ (value)[key])}`)
|
|
63
|
+
.map((key) => `${JSON.stringify(key)}:${stableStringify(/** @type {Record<string, ?>} */ (value)[key])}`)
|
|
68
64
|
|
|
69
65
|
return `{${entries.join(",")}}`
|
|
70
66
|
}
|
|
@@ -195,9 +191,7 @@ class VelociousDatabasePoolBase {
|
|
|
195
191
|
* @returns {boolean} - Whether connection matches current resolved configuration.
|
|
196
192
|
*/
|
|
197
193
|
connectionMatchesCurrentConfiguration(connection) {
|
|
198
|
-
const connectionWithPoolKey = /**
|
|
199
|
-
* Narrows the runtime value to the documented type.
|
|
200
|
-
* @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
|
|
194
|
+
const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
|
|
201
195
|
|
|
202
196
|
return connectionWithPoolKey[POOL_CONFIGURATION_KEY] === this.getConfigurationReuseKey()
|
|
203
197
|
}
|
|
@@ -256,9 +250,7 @@ class VelociousDatabasePoolBase {
|
|
|
256
250
|
|
|
257
251
|
const connection = await this.spawnConnectionWithConfiguration(databaseConfig)
|
|
258
252
|
|
|
259
|
-
const connectionWithPoolKey = /**
|
|
260
|
-
* Narrows the runtime value to the documented type.
|
|
261
|
-
* @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
|
|
253
|
+
const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
|
|
262
254
|
connectionWithPoolKey[POOL_CONFIGURATION_KEY] = this.getConfigurationReuseKey()
|
|
263
255
|
connection.setSchemaCacheInvalidator(() => {
|
|
264
256
|
this.clearSchemaCache()
|
|
@@ -371,9 +363,7 @@ class VelociousDatabasePoolBase {
|
|
|
371
363
|
* @returns {Record<string, ?>} - Connection diagnostic snapshot.
|
|
372
364
|
*/
|
|
373
365
|
debugConnectionSnapshot(connection, details = {}) {
|
|
374
|
-
const connectionWithPoolKey = /**
|
|
375
|
-
* Narrows the runtime value to the documented type.
|
|
376
|
-
* @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
|
|
366
|
+
const connectionWithPoolKey = /** @type {import("../drivers/base.js").default & {[POOL_CONFIGURATION_KEY]?: string}} */ (connection)
|
|
377
367
|
|
|
378
368
|
return {
|
|
379
369
|
...connection.getDebugSnapshot(),
|
|
@@ -188,9 +188,7 @@ export default class VelociousDatabaseQuery {
|
|
|
188
188
|
* @type {import("./where-base.js").default[]} */
|
|
189
189
|
this._wheres = wheres
|
|
190
190
|
|
|
191
|
-
const boundWhere = /**
|
|
192
|
-
* Narrows the runtime value to the documented type.
|
|
193
|
-
* @type {?} */ (this.where.bind(this))
|
|
191
|
+
const boundWhere = /** @type {?} */ (this.where.bind(this))
|
|
194
192
|
boundWhere.not = this.whereNot.bind(this)
|
|
195
193
|
this.where = boundWhere
|
|
196
194
|
}
|
|
@@ -200,9 +198,7 @@ export default class VelociousDatabaseQuery {
|
|
|
200
198
|
* @returns {this} - The clone.
|
|
201
199
|
*/
|
|
202
200
|
clone() {
|
|
203
|
-
const QueryClass = /**
|
|
204
|
-
* Narrows the runtime value to the documented type.
|
|
205
|
-
* @type {new (args: QueryArgsType) => this} */ (this.constructor)
|
|
201
|
+
const QueryClass = /** @type {new (args: QueryArgsType) => this} */ (this.constructor)
|
|
206
202
|
const newQuery = new QueryClass({
|
|
207
203
|
driver: this._driverFn,
|
|
208
204
|
froms: [...this._froms],
|
|
@@ -494,9 +490,7 @@ export default class VelociousDatabaseQuery {
|
|
|
494
490
|
if (typeof where == "string") {
|
|
495
491
|
this._wheres.push(new WherePlain(this, where))
|
|
496
492
|
} else if (typeof where == "object" && (where.constructor.name == "object" || where.constructor.name == "Object")) {
|
|
497
|
-
this._wheres.push(new WhereHash(this, /**
|
|
498
|
-
* Narrows the runtime value to the documented type.
|
|
499
|
-
* @type {import("./where-hash.js").WhereHash} */ (where)))
|
|
493
|
+
this._wheres.push(new WhereHash(this, /** @type {import("./where-hash.js").WhereHash} */ (where)))
|
|
500
494
|
} else {
|
|
501
495
|
throw new Error(`Invalid type of where: ${typeof where} (${where.constructor.name})`)
|
|
502
496
|
}
|
|
@@ -513,9 +507,7 @@ export default class VelociousDatabaseQuery {
|
|
|
513
507
|
if (typeof where == "string") {
|
|
514
508
|
this._wheres.push(new WhereNot(new WherePlain(this, where)))
|
|
515
509
|
} else if (typeof where == "object" && (where.constructor.name == "object" || where.constructor.name == "Object")) {
|
|
516
|
-
this._wheres.push(new WhereNot(new WhereHash(this, /**
|
|
517
|
-
* Narrows the runtime value to the documented type.
|
|
518
|
-
* @type {import("./where-hash.js").WhereHash} */ (where))))
|
|
510
|
+
this._wheres.push(new WhereNot(new WhereHash(this, /** @type {import("./where-hash.js").WhereHash} */ (where))))
|
|
519
511
|
} else {
|
|
520
512
|
throw new Error(`Invalid type of where: ${typeof where} (${where.constructor.name})`)
|
|
521
513
|
}
|
|
@@ -29,12 +29,8 @@ export default class VelociousDatabaseQueryJoinObject extends JoinBase {
|
|
|
29
29
|
throw new Error(`Query has to be a ModelClassQuery but was a ${query.constructor.name}`)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const modelQuery = /**
|
|
33
|
-
|
|
34
|
-
* @type {import("./model-class-query.js").default} */ (query)
|
|
35
|
-
const ModelClass = /**
|
|
36
|
-
* Narrows the runtime value to the documented type.
|
|
37
|
-
* @type {typeof import("../record/index.js").default} */ (
|
|
32
|
+
const modelQuery = /** @type {import("./model-class-query.js").default} */ (query)
|
|
33
|
+
const ModelClass = /** @type {typeof import("../record/index.js").default} */ (
|
|
38
34
|
this.basePath.length > 0 ? modelQuery._resolveModelClassForJoinPath(this.basePath) : modelQuery.modelClass
|
|
39
35
|
)
|
|
40
36
|
|
|
@@ -53,9 +49,7 @@ export default class VelociousDatabaseQueryJoinObject extends JoinBase {
|
|
|
53
49
|
joinObject(join, modelClass, sql, joinsCount, path) {
|
|
54
50
|
const pretty = this.pretty
|
|
55
51
|
const conn = this.getQuery().driver
|
|
56
|
-
const query = /**
|
|
57
|
-
* Narrows the runtime value to the documented type.
|
|
58
|
-
* @type {import("./model-class-query.js").default} */ (this.getQuery())
|
|
52
|
+
const query = /** @type {import("./model-class-query.js").default} */ (this.getQuery())
|
|
59
53
|
|
|
60
54
|
for (const joinKey in join) {
|
|
61
55
|
const joinValue = join[joinKey]
|
|
@@ -216,9 +216,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
216
216
|
* @returns {this} - The clone.
|
|
217
217
|
*/
|
|
218
218
|
clone() {
|
|
219
|
-
const newQuery = /**
|
|
220
|
-
* Narrows the runtime value to the documented type.
|
|
221
|
-
* @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (new VelociousDatabaseQueryModelClassQuery({
|
|
219
|
+
const newQuery = /** @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (new VelociousDatabaseQueryModelClassQuery({
|
|
222
220
|
driver: this._driverFn,
|
|
223
221
|
froms: [...this._froms],
|
|
224
222
|
handler: this.handler.clone(),
|
|
@@ -338,9 +336,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
338
336
|
countQuery._selects = []
|
|
339
337
|
countQuery.select(sql)
|
|
340
338
|
|
|
341
|
-
const results = /**
|
|
342
|
-
* Narrows the runtime value to the documented type.
|
|
343
|
-
* @type {{count: number}[]} */ (await countQuery._executeQuery({
|
|
339
|
+
const results = /** @type {{count: number}[]} */ (await countQuery._executeQuery({
|
|
344
340
|
logName: countQuery.queryLogName("Count")
|
|
345
341
|
}))
|
|
346
342
|
|
|
@@ -374,9 +370,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
374
370
|
`SELECT ${countSql} AS ${this.driver.quoteColumn("count")}`,
|
|
375
371
|
`FROM (${countQuery.toSql()}) AS ${this.driver.quoteTable("paginated_count_rows")}`
|
|
376
372
|
].join(" ")
|
|
377
|
-
const results = /**
|
|
378
|
-
* Narrows the runtime value to the documented type.
|
|
379
|
-
* @type {{count: number}[]} */ (await this.driver.query(
|
|
373
|
+
const results = /** @type {{count: number}[]} */ (await this.driver.query(
|
|
380
374
|
sql,
|
|
381
375
|
{logName: this.queryLogName("Count")}
|
|
382
376
|
))
|
|
@@ -470,18 +464,12 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
470
464
|
const froms = this.getFroms()
|
|
471
465
|
const lastFrom = froms[froms.length - 1]
|
|
472
466
|
|
|
473
|
-
if (lastFrom && typeof /**
|
|
474
|
-
* Narrows the runtime value to the documented type.
|
|
475
|
-
* @type {?} */ (lastFrom).tableName === "string") {
|
|
467
|
+
if (lastFrom && typeof /** @type {?} */ (lastFrom).tableName === "string") {
|
|
476
468
|
return /** @type {?} */ (lastFrom).tableName
|
|
477
469
|
}
|
|
478
470
|
|
|
479
|
-
if (lastFrom && typeof /**
|
|
480
|
-
|
|
481
|
-
* @type {?} */ (lastFrom).plain === "string") {
|
|
482
|
-
const parsedReference = parseFromPlainTableReference(/**
|
|
483
|
-
* Narrows the runtime value to the documented type.
|
|
484
|
-
* @type {?} */ (lastFrom).plain)
|
|
471
|
+
if (lastFrom && typeof /** @type {?} */ (lastFrom).plain === "string") {
|
|
472
|
+
const parsedReference = parseFromPlainTableReference(/** @type {?} */ (lastFrom).plain)
|
|
485
473
|
|
|
486
474
|
if (parsedReference) return parsedReference
|
|
487
475
|
}
|
|
@@ -539,9 +527,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
539
527
|
* @returns {VelociousDatabaseQueryModelClassQuery<MC>} - The scoped query.
|
|
540
528
|
*/
|
|
541
529
|
withJoinPath(joinBasePath) {
|
|
542
|
-
const scopedQuery = /**
|
|
543
|
-
* Narrows the runtime value to the documented type.
|
|
544
|
-
* @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
|
|
530
|
+
const scopedQuery = /** @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
|
|
545
531
|
|
|
546
532
|
scopedQuery._joinBasePath = joinBasePath
|
|
547
533
|
scopedQuery._joinTracker = this._joinTracker
|
|
@@ -638,9 +624,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
638
624
|
}
|
|
639
625
|
|
|
640
626
|
return this._applyJoinPathScope({
|
|
641
|
-
joinPath: normalizeScopePath(/**
|
|
642
|
-
* Narrows the runtime value to the documented type.
|
|
643
|
-
* @type {string | string[]} */ (pathOrScopeDescriptor)),
|
|
627
|
+
joinPath: normalizeScopePath(/** @type {string | string[]} */ (pathOrScopeDescriptor)),
|
|
644
628
|
scopeDescriptor: maybeScopeDescriptor
|
|
645
629
|
})
|
|
646
630
|
}
|
|
@@ -659,9 +643,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
659
643
|
throw new Error(`Cannot apply ${scopeDescriptor.modelClass.name} scope to ${this.getModelClass().name} query`)
|
|
660
644
|
}
|
|
661
645
|
|
|
662
|
-
const scopedQuery = /**
|
|
663
|
-
* Narrows the runtime value to the documented type.
|
|
664
|
-
* @type {this | void} */ (scopeDescriptor.callback({
|
|
646
|
+
const scopedQuery = /** @type {this | void} */ (scopeDescriptor.callback({
|
|
665
647
|
driver: this.driver,
|
|
666
648
|
modelClass: this.getModelClass(),
|
|
667
649
|
query: this,
|
|
@@ -693,9 +675,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
693
675
|
const scopedQuery = this.buildJoinScopeQuery(targetModelClass, fullJoinPath)
|
|
694
676
|
const originalJoinCount = scopedQuery._joins.length
|
|
695
677
|
const originalWhereCount = scopedQuery._wheres.length
|
|
696
|
-
const appliedQuery = /**
|
|
697
|
-
* Narrows the runtime value to the documented type.
|
|
698
|
-
* @type {typeof scopedQuery | void} */ (scopeDescriptor.callback({
|
|
678
|
+
const appliedQuery = /** @type {typeof scopedQuery | void} */ (scopeDescriptor.callback({
|
|
699
679
|
driver: scopedQuery.driver,
|
|
700
680
|
modelClass: targetModelClass,
|
|
701
681
|
path: [...fullJoinPath],
|
|
@@ -742,9 +722,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
742
722
|
* @returns {VelociousDatabaseQueryModelClassQuery<MC>} - The scoped join query.
|
|
743
723
|
*/
|
|
744
724
|
buildJoinScopeQuery(targetModelClass, joinPath) {
|
|
745
|
-
const scopedQuery = /**
|
|
746
|
-
* Narrows the runtime value to the documented type.
|
|
747
|
-
* @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (targetModelClass._newQuery())
|
|
725
|
+
const scopedQuery = /** @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (targetModelClass._newQuery())
|
|
748
726
|
|
|
749
727
|
scopedQuery._joinTracker = this._joinTracker
|
|
750
728
|
scopedQuery._joinBasePath = joinPath
|
|
@@ -817,9 +795,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
817
795
|
|
|
818
796
|
conditions[this.getModelClass().primaryKey()] = recordId
|
|
819
797
|
|
|
820
|
-
const newQuery = /**
|
|
821
|
-
* Narrows the runtime value to the documented type.
|
|
822
|
-
* @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
|
|
798
|
+
const newQuery = /** @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
|
|
823
799
|
|
|
824
800
|
newQuery.where(conditions)
|
|
825
801
|
|
|
@@ -838,9 +814,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
838
814
|
* @returns {Promise<InstanceType<MC> | null>} - Resolves with the by.
|
|
839
815
|
*/
|
|
840
816
|
async findBy(conditions) {
|
|
841
|
-
const newQuery = /**
|
|
842
|
-
* Narrows the runtime value to the documented type.
|
|
843
|
-
* @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
|
|
817
|
+
const newQuery = /** @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
|
|
844
818
|
|
|
845
819
|
newQuery.where(conditions)
|
|
846
820
|
|
|
@@ -890,9 +864,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
890
864
|
if (record) return record
|
|
891
865
|
|
|
892
866
|
const ModelClass = this.getModelClass()
|
|
893
|
-
const newRecord = /**
|
|
894
|
-
* Narrows the runtime value to the documented type.
|
|
895
|
-
* @type {InstanceType<MC>} */ (new ModelClass(conditions))
|
|
867
|
+
const newRecord = /** @type {InstanceType<MC>} */ (new ModelClass(conditions))
|
|
896
868
|
|
|
897
869
|
if (callback) {
|
|
898
870
|
callback(newRecord)
|
|
@@ -945,9 +917,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
945
917
|
|
|
946
918
|
for (const result of results) {
|
|
947
919
|
const ModelClass = this.getModelClass()
|
|
948
|
-
const model = /**
|
|
949
|
-
* Narrows the runtime value to the documented type.
|
|
950
|
-
* @type {InstanceType<MC>} */ (new ModelClass())
|
|
920
|
+
const model = /** @type {InstanceType<MC>} */ (new ModelClass())
|
|
951
921
|
|
|
952
922
|
model.loadExistingRecord(result)
|
|
953
923
|
models.push(model)
|
|
@@ -1013,9 +983,7 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
1013
983
|
const attributeMap = modelClass.getAttributeNameToColumnNameMap()
|
|
1014
984
|
const columnNames = flatColumns.map((column) => attributeMap[column] || column)
|
|
1015
985
|
|
|
1016
|
-
const query = /**
|
|
1017
|
-
* Narrows the runtime value to the documented type.
|
|
1018
|
-
* @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
|
|
986
|
+
const query = /** @type {VelociousDatabaseQueryModelClassQuery<MC>} */ (this.clone())
|
|
1019
987
|
|
|
1020
988
|
query._preload = {}
|
|
1021
989
|
query._selects = []
|
|
@@ -1030,15 +998,11 @@ export default class VelociousDatabaseQueryModelClassQuery extends DatabaseQuery
|
|
|
1030
998
|
|
|
1031
999
|
if (columnNames.length === 1) {
|
|
1032
1000
|
const [columnName] = columnNames
|
|
1033
|
-
return rows.map((row) => /**
|
|
1034
|
-
* Narrows the runtime value to the documented type.
|
|
1035
|
-
* @type {Record<string, ?>} */ (row)[columnName])
|
|
1001
|
+
return rows.map((row) => /** @type {Record<string, ?>} */ (row)[columnName])
|
|
1036
1002
|
}
|
|
1037
1003
|
|
|
1038
1004
|
return rows.map((row) => {
|
|
1039
|
-
const rowHash = /**
|
|
1040
|
-
* Narrows the runtime value to the documented type.
|
|
1041
|
-
* @type {Record<string, ?>} */ (row)
|
|
1005
|
+
const rowHash = /** @type {Record<string, ?>} */ (row)
|
|
1042
1006
|
|
|
1043
1007
|
return columnNames.map((columnName) => rowHash[columnName])
|
|
1044
1008
|
})
|
|
@@ -1496,9 +1460,7 @@ function normalizeRelationshipWhereOperator(operator) {
|
|
|
1496
1460
|
}
|
|
1497
1461
|
|
|
1498
1462
|
return /** @type {"eq" | "notEq" | "gt" | "gteq" | "lt" | "lteq" | "like"} */ (
|
|
1499
|
-
operatorAliases[/**
|
|
1500
|
-
* Narrows the runtime value to the documented type.
|
|
1501
|
-
* @type {"<" | "<=" | ">" | ">="} */ (operator)] || operator
|
|
1463
|
+
operatorAliases[/** @type {"<" | "<=" | ">" | ">="} */ (operator)] || operator
|
|
1502
1464
|
)
|
|
1503
1465
|
}
|
|
1504
1466
|
|
|
@@ -1537,9 +1499,7 @@ function normalizeRelationshipWhereOperatorTuples(value) {
|
|
|
1537
1499
|
*/
|
|
1538
1500
|
const addCondition = (conditionValue) => {
|
|
1539
1501
|
if (isRelationshipWhereOperatorTuple(conditionValue)) {
|
|
1540
|
-
const tuple = /**
|
|
1541
|
-
* Narrows the runtime value to the documented type.
|
|
1542
|
-
* @type {[string, "eq" | "notEq" | "gt" | "gteq" | "lt" | "lteq" | "like" | ">" | ">=" | "<" | "<=", unknown, ...Array<unknown>]} */ (conditionValue)
|
|
1502
|
+
const tuple = /** @type {[string, "eq" | "notEq" | "gt" | "gteq" | "lt" | "lteq" | "like" | ">" | ">=" | "<" | "<=", unknown, ...Array<unknown>]} */ (conditionValue)
|
|
1543
1503
|
const normalizedOperator = normalizeRelationshipWhereOperator(tuple[1])
|
|
1544
1504
|
|
|
1545
1505
|
normalized.push([
|
|
@@ -1561,9 +1521,7 @@ function normalizeRelationshipWhereOperatorTuples(value) {
|
|
|
1561
1521
|
throw new Error("Relationship where conditions must be tuples")
|
|
1562
1522
|
}
|
|
1563
1523
|
|
|
1564
|
-
/**
|
|
1565
|
-
* Narrows the runtime value to the documented type.
|
|
1566
|
-
* @type {Array<?>} */ (conditionValue).forEach((nestedConditionValue) => {
|
|
1524
|
+
/** @type {Array<?>} */ (conditionValue).forEach((nestedConditionValue) => {
|
|
1567
1525
|
addCondition(nestedConditionValue)
|
|
1568
1526
|
})
|
|
1569
1527
|
}
|
|
@@ -46,9 +46,7 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
|
|
|
46
46
|
const instanceRelationship = model.getRelationshipByName(relationshipName)
|
|
47
47
|
|
|
48
48
|
if (this.selection.isSatisfied({instanceRelationship, targetModelClass, mappingColumns: [primaryKey]})) {
|
|
49
|
-
const loaded = /**
|
|
50
|
-
* Narrows the runtime value to the documented type.
|
|
51
|
-
* @type {import("../../record/index.js").default | undefined} */ (instanceRelationship.getLoadedOrUndefined())
|
|
49
|
+
const loaded = /** @type {import("../../record/index.js").default | undefined} */ (instanceRelationship.getLoadedOrUndefined())
|
|
52
50
|
|
|
53
51
|
if (loaded) satisfiedTargets.push(loaded)
|
|
54
52
|
} else {
|
|
@@ -64,9 +62,7 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
|
|
|
64
62
|
const foreignKeyValues = []
|
|
65
63
|
|
|
66
64
|
for (const model of modelsToLoad) {
|
|
67
|
-
const foreignKeyValue = /**
|
|
68
|
-
* Narrows the runtime value to the documented type.
|
|
69
|
-
* @type {string | number | null | undefined} */ (model.readColumn(foreignKey))
|
|
65
|
+
const foreignKeyValue = /** @type {string | number | null | undefined} */ (model.readColumn(foreignKey))
|
|
70
66
|
|
|
71
67
|
// Skip null/undefined foreign keys: a belongsTo with no foreign key has no
|
|
72
68
|
// target, and including them would serialize to e.g. `IN (null)` which
|
|
@@ -106,9 +102,7 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
|
|
|
106
102
|
targetModels = await query.toArray()
|
|
107
103
|
|
|
108
104
|
for (const targetModel of targetModels) {
|
|
109
|
-
const primaryKeyValue = /**
|
|
110
|
-
* Narrows the runtime value to the documented type.
|
|
111
|
-
* @type {string | number} */ (targetModel.readColumn(primaryKey))
|
|
105
|
+
const primaryKeyValue = /** @type {string | number} */ (targetModel.readColumn(primaryKey))
|
|
112
106
|
|
|
113
107
|
targetModelsById[primaryKeyValue] = targetModel
|
|
114
108
|
}
|
|
@@ -116,9 +110,7 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
|
|
|
116
110
|
|
|
117
111
|
// Set the target preloaded models on the given models
|
|
118
112
|
for (const model of modelsToLoad) {
|
|
119
|
-
const foreignKeyValue = /**
|
|
120
|
-
* Narrows the runtime value to the documented type.
|
|
121
|
-
* @type {string | number} */ (model.readColumn(foreignKey))
|
|
113
|
+
const foreignKeyValue = /** @type {string | number} */ (model.readColumn(foreignKey))
|
|
122
114
|
const targetModel = targetModelsById[foreignKeyValue]
|
|
123
115
|
const modelRelationship = model.getRelationshipByName(relationshipName)
|
|
124
116
|
|
|
@@ -158,23 +150,17 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
|
|
|
158
150
|
const targetModelsByClassName = {}
|
|
159
151
|
|
|
160
152
|
for (const model of this.models) {
|
|
161
|
-
const targetType = /**
|
|
162
|
-
* Narrows the runtime value to the documented type.
|
|
163
|
-
* @type {string | undefined} */ (model.readColumn(typeColumn))
|
|
153
|
+
const targetType = /** @type {string | undefined} */ (model.readColumn(typeColumn))
|
|
164
154
|
const instanceRelationship = model.getRelationshipByName(relationshipName)
|
|
165
155
|
const targetModelClass = targetType ? configuration.getModelClass(targetType) : undefined
|
|
166
156
|
|
|
167
157
|
if (targetModelClass && this.selection.isSatisfied({instanceRelationship, targetModelClass, mappingColumns: [primaryKey]})) {
|
|
168
|
-
const loaded = /**
|
|
169
|
-
* Narrows the runtime value to the documented type.
|
|
170
|
-
* @type {import("../../record/index.js").default | undefined} */ (instanceRelationship.getLoadedOrUndefined())
|
|
158
|
+
const loaded = /** @type {import("../../record/index.js").default | undefined} */ (instanceRelationship.getLoadedOrUndefined())
|
|
171
159
|
|
|
172
160
|
if (loaded) {
|
|
173
161
|
satisfiedTargets.push(loaded)
|
|
174
162
|
|
|
175
|
-
const className = /**
|
|
176
|
-
* Narrows the runtime value to the documented type.
|
|
177
|
-
* @type {typeof import("../../record/index.js").default} */ (loaded.constructor).getModelName()
|
|
163
|
+
const className = /** @type {typeof import("../../record/index.js").default} */ (loaded.constructor).getModelName()
|
|
178
164
|
|
|
179
165
|
if (!targetModelsByClassName[className]) targetModelsByClassName[className] = []
|
|
180
166
|
targetModelsByClassName[className].push(loaded)
|
|
@@ -184,9 +170,7 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
|
|
|
184
170
|
}
|
|
185
171
|
|
|
186
172
|
modelMeta.push({
|
|
187
|
-
foreignKeyValue: /**
|
|
188
|
-
* Narrows the runtime value to the documented type.
|
|
189
|
-
* @type {string | number | undefined} */ (model.readColumn(foreignKey)),
|
|
173
|
+
foreignKeyValue: /** @type {string | number | undefined} */ (model.readColumn(foreignKey)),
|
|
190
174
|
model,
|
|
191
175
|
targetType
|
|
192
176
|
})
|
|
@@ -244,9 +228,7 @@ export default class VelociousDatabaseQueryPreloaderBelongsTo {
|
|
|
244
228
|
targetModelsByTypeAndId[targetType] = {}
|
|
245
229
|
|
|
246
230
|
for (const targetModel of foundTargetModels) {
|
|
247
|
-
const primaryKeyValue = /**
|
|
248
|
-
* Narrows the runtime value to the documented type.
|
|
249
|
-
* @type {string | number} */ (targetModel.readColumn(primaryKey))
|
|
231
|
+
const primaryKeyValue = /** @type {string | number} */ (targetModel.readColumn(primaryKey))
|
|
250
232
|
|
|
251
233
|
targetModelsByTypeAndId[targetType][primaryKeyValue] = targetModel
|
|
252
234
|
}
|