velocious 1.0.461 → 1.0.462
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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 +55 -171
- 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/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 +4 -9
- package/build/src/database/record/index.d.ts.map +1 -1
- package/build/src/database/record/index.js +53 -173
- 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/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 +55 -171
- 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
package/build/application.js
CHANGED
|
@@ -119,9 +119,7 @@ export default class VelociousApplication {
|
|
|
119
119
|
async startLockedHttpServer({configuration, host, httpServerConfiguration, port}) {
|
|
120
120
|
try {
|
|
121
121
|
if (!configuration.getWebsocketEvents()) {
|
|
122
|
-
configuration.setWebsocketEvents(/**
|
|
123
|
-
* Types the following value.
|
|
124
|
-
* @type {?} */ (websocketEventsHost))
|
|
122
|
+
configuration.setWebsocketEvents(/** @type {?} */ (websocketEventsHost))
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
await configuration.connectBeacon({peerType: "server"})
|
|
@@ -60,9 +60,7 @@ export function parseCronExpression(expression) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
const trimmed = expression.trim().toLowerCase()
|
|
63
|
-
const expanded = SHORTCUTS[/**
|
|
64
|
-
* Narrows the runtime value to the documented type.
|
|
65
|
-
* @type {keyof typeof SHORTCUTS} */ (trimmed)] || trimmed
|
|
63
|
+
const expanded = SHORTCUTS[/** @type {keyof typeof SHORTCUTS} */ (trimmed)] || trimmed
|
|
66
64
|
const fields = expanded.split(/\s+/)
|
|
67
65
|
|
|
68
66
|
if (fields.length !== 5) {
|
|
@@ -12,9 +12,7 @@ let finishing = false
|
|
|
12
12
|
function isJobMessage(message) {
|
|
13
13
|
if (!message || typeof message !== "object") return false
|
|
14
14
|
|
|
15
|
-
const messageRecord = /**
|
|
16
|
-
* Narrows the runtime value to the documented type.
|
|
17
|
-
* @type {{type?: ?, payload?: ?}} */ (message)
|
|
15
|
+
const messageRecord = /** @type {{type?: ?, payload?: ?}} */ (message)
|
|
18
16
|
|
|
19
17
|
return messageRecord.type === "job" && Object.hasOwn(messageRecord, "payload")
|
|
20
18
|
}
|
|
@@ -58,9 +58,7 @@ export default class VelociousJob {
|
|
|
58
58
|
const isOptionsArg = lastArg && typeof lastArg === "object" && !Array.isArray(lastArg) && "jobOptions" in lastArg
|
|
59
59
|
|
|
60
60
|
if (isOptionsArg) {
|
|
61
|
-
const {jobOptions} = /**
|
|
62
|
-
* Narrows the runtime value to the documented type.
|
|
63
|
-
* @type {{jobOptions: import("./types.js").BackgroundJobOptions}} */ (lastArg)
|
|
61
|
+
const {jobOptions} = /** @type {{jobOptions: import("./types.js").BackgroundJobOptions}} */ (lastArg)
|
|
64
62
|
return {jobArgs: args.slice(0, -1), jobOptions: jobOptions || {}}
|
|
65
63
|
}
|
|
66
64
|
|
|
@@ -52,9 +52,7 @@ export function parseScheduledDuration(value, fieldName) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const numericValue = Number(match[1])
|
|
55
|
-
const multiplier = DURATION_MULTIPLIERS[/**
|
|
56
|
-
* Narrows the runtime value to the documented type.
|
|
57
|
-
* @type {DurationUnit} */ (match[2])]
|
|
55
|
+
const multiplier = DURATION_MULTIPLIERS[/** @type {DurationUnit} */ (match[2])]
|
|
58
56
|
|
|
59
57
|
if (!multiplier) {
|
|
60
58
|
throw new Error(`Invalid scheduled background job ${fieldName}: ${value}`)
|
|
@@ -168,9 +166,7 @@ export default class BackgroundJobsScheduler {
|
|
|
168
166
|
* @returns {void}
|
|
169
167
|
*/
|
|
170
168
|
scheduleEveryJob({jobConfiguration, jobKey}) {
|
|
171
|
-
const everyConfig = /**
|
|
172
|
-
* Narrows the runtime value to the documented type.
|
|
173
|
-
* @type {NonNullable<typeof jobConfiguration.every>} */ (jobConfiguration.every)
|
|
169
|
+
const everyConfig = /** @type {NonNullable<typeof jobConfiguration.every>} */ (jobConfiguration.every)
|
|
174
170
|
const {everyValue, firstInValue} = this.normalizeEvery(everyConfig)
|
|
175
171
|
const intervalMs = parseScheduledDuration(everyValue, `${jobKey}.every`)
|
|
176
172
|
const firstInMs = firstInValue !== undefined ? parseScheduledDuration(firstInValue, `${jobKey}.first_in`) : intervalMs
|
|
@@ -237,9 +237,7 @@ export default class BackgroundJobsStore {
|
|
|
237
237
|
const counts = {}
|
|
238
238
|
|
|
239
239
|
for (const row of rows) {
|
|
240
|
-
const typedRow = /**
|
|
241
|
-
* Narrows the runtime value to the documented type.
|
|
242
|
-
* @type {Record<string, ?>} */ (row)
|
|
240
|
+
const typedRow = /** @type {Record<string, ?>} */ (row)
|
|
243
241
|
|
|
244
242
|
counts[String(typedRow.status)] = this._normalizeNumber(typedRow.count) || 0
|
|
245
243
|
}
|
|
@@ -265,9 +263,7 @@ export default class BackgroundJobsStore {
|
|
|
265
263
|
if (jobName) query = query.where({job_name: jobName})
|
|
266
264
|
|
|
267
265
|
const rows = await query.results()
|
|
268
|
-
const countRow = /**
|
|
269
|
-
* Narrows the runtime value to the documented type.
|
|
270
|
-
* @type {Record<string, ?>} */ (rows[0] || {})
|
|
266
|
+
const countRow = /** @type {Record<string, ?>} */ (rows[0] || {})
|
|
271
267
|
|
|
272
268
|
return this._normalizeNumber(countRow.count) || 0
|
|
273
269
|
})
|
|
@@ -222,9 +222,7 @@ export default class VelociousBackgroundJobsWebController extends Controller {
|
|
|
222
222
|
const redactArgs = Boolean(this._mountOptions().redactArgs)
|
|
223
223
|
|
|
224
224
|
return Object.keys(jobs).map((name) => {
|
|
225
|
-
const entry = jobs[name] || /**
|
|
226
|
-
* Narrows the runtime value to the documented type.
|
|
227
|
-
* @type {?} */ ({})
|
|
225
|
+
const entry = jobs[name] || /** @type {?} */ ({})
|
|
228
226
|
|
|
229
227
|
return {
|
|
230
228
|
args: redactArgs ? undefined : (entry.args || []),
|
|
@@ -276,9 +276,7 @@ export default class BackgroundJobsWorker {
|
|
|
276
276
|
/**
|
|
277
277
|
* Identified payload.
|
|
278
278
|
* @type {import("./types.js").BackgroundJobPayload & {id: string}} */
|
|
279
|
-
const identifiedPayload = /**
|
|
280
|
-
* Narrows the runtime value to the documented type.
|
|
281
|
-
* @type {?} */ (payload)
|
|
279
|
+
const identifiedPayload = /** @type {?} */ (payload)
|
|
282
280
|
|
|
283
281
|
const executionMode = this._executionModeForPayload(identifiedPayload)
|
|
284
282
|
|
package/build/beacon/client.js
CHANGED
|
@@ -116,9 +116,7 @@ export default class BeaconClient extends EventEmitter {
|
|
|
116
116
|
this.off("connect-error", onError)
|
|
117
117
|
resolve()
|
|
118
118
|
}
|
|
119
|
-
const onError = (/**
|
|
120
|
-
* Narrows the runtime value to the documented type.
|
|
121
|
-
* @type {Error} */ error) => {
|
|
119
|
+
const onError = (/** @type {Error} */ error) => {
|
|
122
120
|
this.off("connect", onConnect)
|
|
123
121
|
this.off("connect-error", onError)
|
|
124
122
|
reject(error)
|
|
@@ -271,9 +269,7 @@ export default class BeaconClient extends EventEmitter {
|
|
|
271
269
|
this.emit("connect")
|
|
272
270
|
})
|
|
273
271
|
|
|
274
|
-
jsonSocket.on("message", (/**
|
|
275
|
-
* Narrows the runtime value to the documented type.
|
|
276
|
-
* @type {import("./types.js").BeaconSocketMessage} */ message) => {
|
|
272
|
+
jsonSocket.on("message", (/** @type {import("./types.js").BeaconSocketMessage} */ message) => {
|
|
277
273
|
if (message?.type === "hello-ack" && message.peerId === this.peerId) {
|
|
278
274
|
this._ready = true
|
|
279
275
|
this.emit("ready")
|
|
@@ -184,9 +184,7 @@ export default class TenantDatabaseCommandHelper {
|
|
|
184
184
|
*/
|
|
185
185
|
tenantLabel(tenant) {
|
|
186
186
|
if (tenant && typeof tenant === "object") {
|
|
187
|
-
const tenantObject = /**
|
|
188
|
-
* Narrows the runtime value to the documented type.
|
|
189
|
-
* @type {{id?: ?, name?: ?, slug?: ?}} */ (tenant)
|
|
187
|
+
const tenantObject = /** @type {{id?: ?, name?: ?, slug?: ?}} */ (tenant)
|
|
190
188
|
|
|
191
189
|
if (tenantObject.slug) return String(tenantObject.slug)
|
|
192
190
|
if (tenantObject.name) return String(tenantObject.name)
|
package/build/configuration.js
CHANGED
|
@@ -30,15 +30,34 @@ export {CurrentConfigurationNotSetError}
|
|
|
30
30
|
* @returns {string | undefined} - Current working directory when the runtime exposes one.
|
|
31
31
|
*/
|
|
32
32
|
function currentWorkingDirectory() {
|
|
33
|
-
const processObject = /**
|
|
34
|
-
* Types the following value.
|
|
35
|
-
* @type {{cwd?: ?} | undefined} */ (globalThis.process)
|
|
33
|
+
const processObject = /** @type {{cwd?: ?} | undefined} */ (globalThis.process)
|
|
36
34
|
|
|
37
35
|
if (typeof processObject?.cwd !== "function") return undefined
|
|
38
36
|
|
|
39
37
|
return processObject.cwd()
|
|
40
38
|
}
|
|
41
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Resolves the overloaded with/ensure connections arguments.
|
|
42
|
+
* @template T
|
|
43
|
+
* @param {WithConnectionsOptionsType | WithConnectionsCallbackType<T>} optionsOrCallback - Checkout options or callback function.
|
|
44
|
+
* @param {WithConnectionsCallbackType<T> | undefined} callback - Callback function.
|
|
45
|
+
* @param {string} defaultName - Default checkout name.
|
|
46
|
+
* @returns {{name: string, callback: WithConnectionsCallbackType<T> | undefined}} Resolved checkout name and callback.
|
|
47
|
+
*/
|
|
48
|
+
function resolveWithConnectionsArgs(optionsOrCallback, callback, defaultName) {
|
|
49
|
+
if (typeof optionsOrCallback == "function") {
|
|
50
|
+
const actualCallback = /** @type {WithConnectionsCallbackType<T>} */ (optionsOrCallback)
|
|
51
|
+
|
|
52
|
+
return {name: defaultName, callback: actualCallback}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
name: optionsOrCallback.name || defaultName,
|
|
57
|
+
callback
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
42
61
|
/**
|
|
43
62
|
* Runs canonical debug snapshot value.
|
|
44
63
|
* @param {?} value - Snapshot value to canonicalize.
|
|
@@ -49,13 +68,9 @@ function canonicalDebugSnapshotValue(value) {
|
|
|
49
68
|
if (Array.isArray(value)) return value.map((entry) => canonicalDebugSnapshotValue(entry))
|
|
50
69
|
|
|
51
70
|
return Object.keys(value).sort().reduce((result, key) => {
|
|
52
|
-
result[key] = canonicalDebugSnapshotValue(/**
|
|
53
|
-
* Types the following value.
|
|
54
|
-
* @type {Record<string, ?>} */ (value)[key])
|
|
71
|
+
result[key] = canonicalDebugSnapshotValue(/** @type {Record<string, ?>} */ (value)[key])
|
|
55
72
|
return result
|
|
56
|
-
}, /**
|
|
57
|
-
* Types the following value.
|
|
58
|
-
* @type {Record<string, ?>} */ ({}))
|
|
73
|
+
}, /** @type {Record<string, ?>} */ ({}))
|
|
59
74
|
}
|
|
60
75
|
|
|
61
76
|
/**
|
|
@@ -496,9 +511,7 @@ export default class VelociousConfiguration {
|
|
|
496
511
|
* @returns {Promise<Record<string, ?>>} - HTTP server worker diagnostics.
|
|
497
512
|
*/
|
|
498
513
|
async _debugHttpServerSnapshot() {
|
|
499
|
-
const httpServer = /**
|
|
500
|
-
* Types the following value.
|
|
501
|
-
* @type {{getDebugSnapshot?: () => Promise<Record<string, ?>>} | undefined} */ (this._httpServerInstance)
|
|
514
|
+
const httpServer = /** @type {{getDebugSnapshot?: () => Promise<Record<string, ?>>} | undefined} */ (this._httpServerInstance)
|
|
502
515
|
|
|
503
516
|
if (!httpServer?.getDebugSnapshot) {
|
|
504
517
|
return {configured: Boolean(this.httpServer), active: false}
|
|
@@ -597,9 +610,7 @@ export default class VelociousConfiguration {
|
|
|
597
610
|
const detailsBuckets = new Map()
|
|
598
611
|
|
|
599
612
|
for (const subscription of channelSubscriptions) {
|
|
600
|
-
const details = /**
|
|
601
|
-
* Types the following value.
|
|
602
|
-
* @type {Record<string, ?>} */ (canonicalDebugSnapshotValue(subscription.debugSnapshot()))
|
|
613
|
+
const details = /** @type {Record<string, ?>} */ (canonicalDebugSnapshotValue(subscription.debugSnapshot()))
|
|
603
614
|
const key = JSON.stringify(details)
|
|
604
615
|
const existingBucket = detailsBuckets.get(key)
|
|
605
616
|
|
|
@@ -624,9 +635,7 @@ export default class VelociousConfiguration {
|
|
|
624
635
|
const channelSubscriptionBuckets = new Map()
|
|
625
636
|
|
|
626
637
|
for (const {channelType, subscription} of session._channelSubscriptions.values()) {
|
|
627
|
-
const details = /**
|
|
628
|
-
* Types the following value.
|
|
629
|
-
* @type {Record<string, ?>} */ (subscription.debugSnapshot())
|
|
638
|
+
const details = /** @type {Record<string, ?>} */ (subscription.debugSnapshot())
|
|
630
639
|
const model = typeof details.model === "string" ? details.model : null
|
|
631
640
|
const key = JSON.stringify({channelType, model})
|
|
632
641
|
const existingBucket = channelSubscriptionBuckets.get(key)
|
|
@@ -2422,13 +2431,7 @@ export default class VelociousConfiguration {
|
|
|
2422
2431
|
* @returns {Promise<T>} - Resolves with the callback result.
|
|
2423
2432
|
*/
|
|
2424
2433
|
async withConnections(optionsOrCallback, callback) {
|
|
2425
|
-
const name
|
|
2426
|
-
/**
|
|
2427
|
-
* Actual with connections callback.
|
|
2428
|
-
* @type {WithConnectionsCallbackType<T> | undefined} */
|
|
2429
|
-
const actualWithConnectionsCallback = typeof optionsOrCallback == "function" ? /**
|
|
2430
|
-
* Types the following value.
|
|
2431
|
-
* @type {WithConnectionsCallbackType<T>} */ (optionsOrCallback) : callback
|
|
2434
|
+
const {name, callback: actualWithConnectionsCallback} = resolveWithConnectionsArgs(optionsOrCallback, callback, "Configuration.withConnections")
|
|
2432
2435
|
|
|
2433
2436
|
if (!actualWithConnectionsCallback) throw new Error("withConnections requires a callback")
|
|
2434
2437
|
|
|
@@ -2537,13 +2540,7 @@ export default class VelociousConfiguration {
|
|
|
2537
2540
|
* @returns {Promise<T>} - Resolves with the callback result.
|
|
2538
2541
|
*/
|
|
2539
2542
|
async ensureConnections(optionsOrCallback, callback) {
|
|
2540
|
-
const name
|
|
2541
|
-
/**
|
|
2542
|
-
* Actual with connections callback.
|
|
2543
|
-
* @type {WithConnectionsCallbackType<T> | undefined} */
|
|
2544
|
-
const actualWithConnectionsCallback = typeof optionsOrCallback == "function" ? /**
|
|
2545
|
-
* Types the following value.
|
|
2546
|
-
* @type {WithConnectionsCallbackType<T>} */ (optionsOrCallback) : callback
|
|
2543
|
+
const {name, callback: actualWithConnectionsCallback} = resolveWithConnectionsArgs(optionsOrCallback, callback, "Configuration.ensureConnections")
|
|
2547
2544
|
|
|
2548
2545
|
if (!actualWithConnectionsCallback) throw new Error("ensureConnections requires a callback")
|
|
2549
2546
|
|
package/build/controller.js
CHANGED
|
@@ -141,9 +141,7 @@ export default class VelociousController {
|
|
|
141
141
|
* @returns {typeof VelociousController} - The controller class.
|
|
142
142
|
*/
|
|
143
143
|
_getControllerClass() {
|
|
144
|
-
const controllerClass = /**
|
|
145
|
-
* Types the following value.
|
|
146
|
-
* @type {typeof VelociousController} */ (this.constructor)
|
|
144
|
+
const controllerClass = /** @type {typeof VelociousController} */ (this.constructor)
|
|
147
145
|
|
|
148
146
|
return controllerClass
|
|
149
147
|
}
|
|
@@ -159,11 +157,7 @@ export default class VelociousController {
|
|
|
159
157
|
const beforeActions = currentControllerClass._beforeActions
|
|
160
158
|
|
|
161
159
|
if (beforeActions) {
|
|
162
|
-
const controllerPrototype = /**
|
|
163
|
-
* Types the following value.
|
|
164
|
-
* @type {Record<string, Function | undefined>} */ (/**
|
|
165
|
-
* Types the following value.
|
|
166
|
-
* @type {?} */ (currentControllerClass.prototype))
|
|
160
|
+
const controllerPrototype = /** @type {Record<string, Function | undefined>} */ (/** @type {?} */ (currentControllerClass.prototype))
|
|
167
161
|
|
|
168
162
|
for (const beforeActionName of beforeActions) {
|
|
169
163
|
const beforeAction = controllerPrototype[beforeActionName]
|
|
@@ -215,9 +209,7 @@ export default class VelociousController {
|
|
|
215
209
|
|
|
216
210
|
return paramsToObject.toObject()
|
|
217
211
|
} catch (error) {
|
|
218
|
-
const ensuredError = /**
|
|
219
|
-
* Types the following value.
|
|
220
|
-
* @type {Error & {velociousContext?: Record<string, ?>}} */ (error)
|
|
212
|
+
const ensuredError = /** @type {Error & {velociousContext?: Record<string, ?>}} */ (error)
|
|
221
213
|
|
|
222
214
|
ensuredError.velociousContext = {
|
|
223
215
|
...(ensuredError.velociousContext || {}),
|
|
@@ -295,9 +287,7 @@ export default class VelociousController {
|
|
|
295
287
|
|
|
296
288
|
ejs.renderFile(viewPath, actualViewParams, {}, (err, str) => {
|
|
297
289
|
if (err) {
|
|
298
|
-
const renderError = /**
|
|
299
|
-
* Types the following value.
|
|
300
|
-
* @type {Error & {code?: string}} */ (err)
|
|
290
|
+
const renderError = /** @type {Error & {code?: string}} */ (err)
|
|
301
291
|
|
|
302
292
|
if (renderError.code === "ENOENT") {
|
|
303
293
|
this.logger.warn(`Missing view file: ${viewPath}`)
|
|
@@ -340,9 +340,7 @@ export default class VelociousDatabaseDriversMssql extends Base{
|
|
|
340
340
|
const tables = []
|
|
341
341
|
|
|
342
342
|
for (const row of result) {
|
|
343
|
-
const table = new Table(this, /**
|
|
344
|
-
* Narrows the runtime value to the documented type.
|
|
345
|
-
* @type {Record<string, string>} */ (row))
|
|
343
|
+
const table = new Table(this, /** @type {Record<string, string>} */ (row))
|
|
346
344
|
|
|
347
345
|
tables.push(table)
|
|
348
346
|
}
|
|
@@ -223,9 +223,7 @@ export default class VelociousDatabaseDriversMysql extends Base{
|
|
|
223
223
|
* @returns {import("../base.js").RetryableDatabaseErrorResult} - Retry info.
|
|
224
224
|
*/
|
|
225
225
|
retryableDatabaseError(error) {
|
|
226
|
-
const errorCode = /**
|
|
227
|
-
* Narrows the runtime value to the documented type.
|
|
228
|
-
* @type {?} */ (error).code
|
|
226
|
+
const errorCode = /** @type {?} */ (error).code
|
|
229
227
|
const message = error.message || ""
|
|
230
228
|
const shouldRetry = (
|
|
231
229
|
errorCode == "ECONNREFUSED" ||
|
|
@@ -337,9 +335,7 @@ export default class VelociousDatabaseDriversMysql extends Base{
|
|
|
337
335
|
const tables = []
|
|
338
336
|
|
|
339
337
|
for (const row of result) {
|
|
340
|
-
const table = new Table(this, /**
|
|
341
|
-
* Narrows the runtime value to the documented type.
|
|
342
|
-
* @type {Record<string, string>} */ (row))
|
|
338
|
+
const table = new Table(this, /** @type {Record<string, string>} */ (row))
|
|
343
339
|
|
|
344
340
|
tables.push(table)
|
|
345
341
|
}
|
|
@@ -292,9 +292,7 @@ export default class VelociousDatabaseDriversPgsql extends Base{
|
|
|
292
292
|
const tables = []
|
|
293
293
|
|
|
294
294
|
for (const row of result) {
|
|
295
|
-
const table = new Table(this, /**
|
|
296
|
-
* Narrows the runtime value to the documented type.
|
|
297
|
-
* @type {Record<string, string>} */ (row))
|
|
295
|
+
const table = new Table(this, /** @type {Record<string, string>} */ (row))
|
|
298
296
|
|
|
299
297
|
tables.push(table)
|
|
300
298
|
}
|
|
@@ -87,9 +87,7 @@ export default class VelociousDatabaseDriversSqliteBase extends Base {
|
|
|
87
87
|
* @returns {Promise<string[]>} - Resolves with SQL statements.
|
|
88
88
|
*/
|
|
89
89
|
async dropTableSQLs(tableName, args = {}) {
|
|
90
|
-
const driver = /**
|
|
91
|
-
* Narrows the runtime value to the documented type.
|
|
92
|
-
* @type {import("../base.js").default} */ (this)
|
|
90
|
+
const driver = /** @type {import("../base.js").default} */ (this)
|
|
93
91
|
const dropArgs = Object.assign({tableName, driver}, args)
|
|
94
92
|
const dropTable = new DropTable(dropArgs)
|
|
95
93
|
|
|
@@ -126,9 +124,7 @@ export default class VelociousDatabaseDriversSqliteBase extends Base {
|
|
|
126
124
|
const tables = []
|
|
127
125
|
|
|
128
126
|
for (const row of result) {
|
|
129
|
-
const table = new Table({driver: this, row: /**
|
|
130
|
-
* Narrows the runtime value to the documented type.
|
|
131
|
-
* @type {Record<string, string | number | null>} */ (row)})
|
|
127
|
+
const table = new Table({driver: this, row: /** @type {Record<string, string | number | null>} */ (row)})
|
|
132
128
|
|
|
133
129
|
tables.push(table)
|
|
134
130
|
}
|
|
@@ -403,9 +399,7 @@ export default class VelociousDatabaseDriversSqliteBase extends Base {
|
|
|
403
399
|
if (timeoutHandle) clearTimeout(timeoutHandle)
|
|
404
400
|
|
|
405
401
|
const current = state.waitersByName.get(name) || []
|
|
406
|
-
const index = current.indexOf(/**
|
|
407
|
-
* Narrows the runtime value to the documented type.
|
|
408
|
-
* @type {() => void} */ (removeAndResolve))
|
|
402
|
+
const index = current.indexOf(/** @type {() => void} */ (removeAndResolve))
|
|
409
403
|
|
|
410
404
|
if (index >= 0) current.splice(index, 1)
|
|
411
405
|
if (current.length === 0) state.waitersByName.delete(name)
|
|
@@ -247,9 +247,7 @@ export default class VelociousDatabaseDriversSqliteNode extends Base {
|
|
|
247
247
|
|
|
248
248
|
return true
|
|
249
249
|
} catch (error) {
|
|
250
|
-
if (/**
|
|
251
|
-
* Narrows the runtime value to the documented type.
|
|
252
|
-
* @type {NodeJS.ErrnoException} */ (error)?.code !== "EEXIST") throw error
|
|
250
|
+
if (/** @type {NodeJS.ErrnoException} */ (error)?.code !== "EEXIST") throw error
|
|
253
251
|
|
|
254
252
|
if (await this._isAdvisoryLockStale(lockPath)) {
|
|
255
253
|
await fs.rm(lockPath, {recursive: true, force: true})
|
|
@@ -285,9 +283,7 @@ export default class VelociousDatabaseDriversSqliteNode extends Base {
|
|
|
285
283
|
|
|
286
284
|
return true
|
|
287
285
|
} catch (error) {
|
|
288
|
-
if (/**
|
|
289
|
-
* Narrows the runtime value to the documented type.
|
|
290
|
-
* @type {NodeJS.ErrnoException} */ (error)?.code !== "EEXIST") throw error
|
|
286
|
+
if (/** @type {NodeJS.ErrnoException} */ (error)?.code !== "EEXIST") throw error
|
|
291
287
|
|
|
292
288
|
if (await this._isAdvisoryLockStale(lockPath)) {
|
|
293
289
|
await fs.rm(lockPath, {recursive: true, force: true})
|
|
@@ -298,9 +294,7 @@ export default class VelociousDatabaseDriversSqliteNode extends Base {
|
|
|
298
294
|
|
|
299
295
|
return true
|
|
300
296
|
} catch (retryError) {
|
|
301
|
-
if (/**
|
|
302
|
-
* Narrows the runtime value to the documented type.
|
|
303
|
-
* @type {NodeJS.ErrnoException} */ (retryError)?.code === "EEXIST") return false
|
|
297
|
+
if (/** @type {NodeJS.ErrnoException} */ (retryError)?.code === "EEXIST") return false
|
|
304
298
|
|
|
305
299
|
throw retryError
|
|
306
300
|
}
|
|
@@ -71,9 +71,7 @@ export default class VelociousDatabaseDriversSqliteTable extends BaseTable {
|
|
|
71
71
|
|
|
72
72
|
if (!sql) throw new Error(`Could not find SQL for index ${columnsIndex.getName()}`)
|
|
73
73
|
|
|
74
|
-
const indexData = /**
|
|
75
|
-
* Narrows the runtime value to the documented type.
|
|
76
|
-
* @type {typeof columnsIndex.data & {columnNames?: string[]}} */ (columnsIndex.data)
|
|
74
|
+
const indexData = /** @type {typeof columnsIndex.data & {columnNames?: string[]}} */ (columnsIndex.data)
|
|
77
75
|
|
|
78
76
|
indexData.columnNames = this._parseColumnsFromSQL(String(sql))
|
|
79
77
|
|
|
@@ -301,9 +301,7 @@ export default class VelociousDatabaseMigrator {
|
|
|
301
301
|
const migrationName = match[2]
|
|
302
302
|
const migrationClassName = inflection.camelize(migrationName)
|
|
303
303
|
|
|
304
|
-
const migrationObject = /**
|
|
305
|
-
* Narrows the runtime value to the documented type.
|
|
306
|
-
* @type {import("./migrator/types.js").MigrationObjectType} */ ({
|
|
304
|
+
const migrationObject = /** @type {import("./migrator/types.js").MigrationObjectType} */ ({
|
|
307
305
|
file,
|
|
308
306
|
date,
|
|
309
307
|
migrationClassName
|
|
@@ -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`)
|