velocious 1.0.461 → 1.0.463
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +62 -40
- 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 +86 -46
- package/build/database/pool/base-methods-forward.js +2 -10
- package/build/database/pool/base.js +13 -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 +7 -19
- 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 +5 -13
- 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/index.js +3 -2
- 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 +5 -15
- 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 +13 -0
- package/build/src/configuration.d.ts.map +1 -1
- package/build/src/configuration.js +58 -44
- 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 +18 -0
- package/build/src/database/pool/async-tracked-multi-connection.d.ts.map +1 -1
- package/build/src/database/pool/async-tracked-multi-connection.js +82 -48
- 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 +5 -0
- package/build/src/database/pool/base.d.ts.map +1 -1
- package/build/src/database/pool/base.js +13 -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 +8 -22
- 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 +6 -15
- 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/index.d.ts.map +1 -1
- package/build/src/http-server/worker-handler/index.js +4 -3
- 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 +6 -16
- 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/tsconfig.tsbuildinfo +1 -1
- 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 +5 -3
- 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 +62 -40
- 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 +86 -46
- package/src/database/pool/base-methods-forward.js +2 -10
- package/src/database/pool/base.js +13 -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 +7 -19
- 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 +5 -13
- 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/index.js +3 -2
- 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 +5 -15
- 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/src/utils/ensure-error.d.ts +0 -7
- package/build/src/utils/ensure-error.d.ts.map +0 -1
- package/build/src/utils/ensure-error.js +0 -15
- package/build/utils/ensure-error.js +0 -15
- package/src/utils/ensure-error.js +0 -15
|
@@ -92,12 +92,8 @@ export default class VelociousWebsocketChannelSubscribers {
|
|
|
92
92
|
try {
|
|
93
93
|
const result = callback(payload, meta)
|
|
94
94
|
|
|
95
|
-
if (result && typeof (/**
|
|
96
|
-
|
|
97
|
-
* @type {Promise<void>} */ (result)).then === "function") {
|
|
98
|
-
tasks.push(/**
|
|
99
|
-
* Narrows the runtime value to the documented type.
|
|
100
|
-
* @type {Promise<void>} */ (result))
|
|
95
|
+
if (result && typeof (/** @type {Promise<void>} */ (result)).then === "function") {
|
|
96
|
+
tasks.push(/** @type {Promise<void>} */ (result))
|
|
101
97
|
}
|
|
102
98
|
} catch (error) {
|
|
103
99
|
// Don't let one subscriber's failure abort the others; surface via the returned promises instead.
|
|
@@ -225,9 +225,7 @@ export default class VelociousHttpServerWebsocketEventLogStore {
|
|
|
225
225
|
.order("sequence DESC")
|
|
226
226
|
.limit(1)
|
|
227
227
|
.results()
|
|
228
|
-
const row = /**
|
|
229
|
-
* Narrows the runtime value to the documented type.
|
|
230
|
-
* @type {Record<string, ?> | undefined} */ (rows[0])
|
|
228
|
+
const row = /** @type {Record<string, ?> | undefined} */ (rows[0])
|
|
231
229
|
|
|
232
230
|
if (!row) return null
|
|
233
231
|
|
|
@@ -258,9 +256,7 @@ export default class VelociousHttpServerWebsocketEventLogStore {
|
|
|
258
256
|
query.where(`sequence <= ${db.quote(upToSequence)}`)
|
|
259
257
|
}
|
|
260
258
|
|
|
261
|
-
const rows = /**
|
|
262
|
-
* Narrows the runtime value to the documented type.
|
|
263
|
-
* @type {WebsocketEventRow[]} */ (await query.results())
|
|
259
|
+
const rows = /** @type {WebsocketEventRow[]} */ (await query.results())
|
|
264
260
|
|
|
265
261
|
return rows.map((row) => this._normalizeEventRow(row))
|
|
266
262
|
})
|
|
@@ -278,16 +274,12 @@ export default class VelociousHttpServerWebsocketEventLogStore {
|
|
|
278
274
|
const cutoff = new Date(now.getTime() - this.retentionMs)
|
|
279
275
|
|
|
280
276
|
await this._withDb(async (db) => {
|
|
281
|
-
const expiredEventRows = /**
|
|
282
|
-
* Narrows the runtime value to the documented type.
|
|
283
|
-
* @type {Array<{id: string}>} */ (await db
|
|
277
|
+
const expiredEventRows = /** @type {Array<{id: string}>} */ (await db
|
|
284
278
|
.newQuery()
|
|
285
279
|
.from(EVENTS_TABLE)
|
|
286
280
|
.where(`created_at <= ${db.quote(cutoff)}`)
|
|
287
281
|
.results())
|
|
288
|
-
const expiredReplayChannelRows = /**
|
|
289
|
-
* Narrows the runtime value to the documented type.
|
|
290
|
-
* @type {WebsocketReplayChannelRow[]} */ (await db
|
|
282
|
+
const expiredReplayChannelRows = /** @type {WebsocketReplayChannelRow[]} */ (await db
|
|
291
283
|
.newQuery()
|
|
292
284
|
.from(REPLAY_CHANNELS_TABLE)
|
|
293
285
|
.where(`interested_until <= ${db.quote(now)}`)
|
|
@@ -365,9 +357,7 @@ export default class VelociousHttpServerWebsocketEventLogStore {
|
|
|
365
357
|
* @returns {Promise<{channel: string, createdAt: string, id: string, payload: ?, sequence: number} | null>} - Event row or null.
|
|
366
358
|
*/
|
|
367
359
|
async _getEventById({channel, db, id}) {
|
|
368
|
-
const rows = /**
|
|
369
|
-
* Narrows the runtime value to the documented type.
|
|
370
|
-
* @type {WebsocketEventRow[]} */ (await db
|
|
360
|
+
const rows = /** @type {WebsocketEventRow[]} */ (await db
|
|
371
361
|
.newQuery()
|
|
372
362
|
.from(EVENTS_TABLE)
|
|
373
363
|
.where({channel, id})
|
|
@@ -43,9 +43,7 @@ export class VelociousHttpServerWebsocketEventsHost {
|
|
|
43
43
|
publish(channelOrArgs, payloadArg) {
|
|
44
44
|
const publishArgs = typeof channelOrArgs === "string"
|
|
45
45
|
? {channel: channelOrArgs, payload: payloadArg}
|
|
46
|
-
: /**
|
|
47
|
-
* Narrows the runtime value to the documented type.
|
|
48
|
-
* @type {{channel: string, payload: ?}} */ (channelOrArgs)
|
|
46
|
+
: /** @type {{channel: string, payload: ?}} */ (channelOrArgs)
|
|
49
47
|
const channel = publishArgs.channel
|
|
50
48
|
const payload = publishArgs.payload
|
|
51
49
|
|
|
@@ -28,9 +28,7 @@ export default class VelociousHttpServerInProcessHandler {
|
|
|
28
28
|
|
|
29
29
|
this.logger = new Logger(this)
|
|
30
30
|
this.workerCount = workerCount
|
|
31
|
-
this.unregisterFromEventsHost = websocketEventsHost.register(/**
|
|
32
|
-
* Narrows the runtime value to the documented type.
|
|
33
|
-
* @type {?} */ (this))
|
|
31
|
+
this.unregisterFromEventsHost = websocketEventsHost.register(/** @type {?} */ (this))
|
|
34
32
|
this._stopping = false
|
|
35
33
|
}
|
|
36
34
|
|
|
@@ -72,14 +70,8 @@ export default class VelociousHttpServerInProcessHandler {
|
|
|
72
70
|
|
|
73
71
|
// Create a message-port shim so ServerClient.onSocketData can route data
|
|
74
72
|
// to the in-process HTTP Client without needing a real worker thread.
|
|
75
|
-
const messagePortShim = /**
|
|
76
|
-
|
|
77
|
-
* @type {import("worker_threads").Worker} */ (/**
|
|
78
|
-
* Narrows the runtime value to the documented type.
|
|
79
|
-
* @type {?} */ ({
|
|
80
|
-
postMessage: (/**
|
|
81
|
-
* Narrows the runtime value to the documented type.
|
|
82
|
-
* @type {{command: string, chunk?: Buffer | Uint8Array | string, clientCount?: number}} */ data) => {
|
|
73
|
+
const messagePortShim = /** @type {import("worker_threads").Worker} */ (/** @type {?} */ ({
|
|
74
|
+
postMessage: (/** @type {{command: string, chunk?: Buffer | Uint8Array | string, clientCount?: number}} */ data) => {
|
|
83
75
|
if (data.command === "clientWrite" && data.chunk) {
|
|
84
76
|
const chunk = typeof data.chunk === "string" ? Buffer.from(data.chunk) : Buffer.from(data.chunk)
|
|
85
77
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
+
import {ensureError} from "typanic"
|
|
3
4
|
import Logger from "../../logger.js"
|
|
4
5
|
import {Worker} from "worker_threads"
|
|
5
|
-
import ensureError from "../../utils/ensure-error.js"
|
|
6
6
|
import websocketEventsHost from "../websocket-events-host.js"
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -109,7 +109,8 @@ export default class VelociousHttpServerWorker {
|
|
|
109
109
|
onWorkerError = (error) => {
|
|
110
110
|
this.logger.error(`Velocious worker ${this.workerCount} error`, error)
|
|
111
111
|
void this._closeAllClients()
|
|
112
|
-
|
|
112
|
+
// Preserve Error instances for the original backtrace while wrapping non-Error throwables.
|
|
113
|
+
throw ensureError(error)
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
/**
|
|
@@ -168,9 +168,7 @@ export default class VelociousHttpServerWorkerHandlerWorkerThread {
|
|
|
168
168
|
|
|
169
169
|
const {chunk, clientCount} = data
|
|
170
170
|
if (!chunk) throw new Error("No chunk given")
|
|
171
|
-
const client = /**
|
|
172
|
-
* Narrows the runtime value to the documented type.
|
|
173
|
-
* @type {Client | undefined} */ (digg(this.clients, clientCount))
|
|
171
|
+
const client = /** @type {Client | undefined} */ (digg(this.clients, clientCount))
|
|
174
172
|
|
|
175
173
|
if (!client) throw new Error(`Client not found for clientWrite: ${clientCount}`)
|
|
176
174
|
|
package/src/logger.js
CHANGED
|
@@ -196,9 +196,7 @@ function resolveLoggingOutputs({loggingConfiguration, configuration}) {
|
|
|
196
196
|
for (const logger of loggingConfiguration.loggers) {
|
|
197
197
|
if (!logger) continue
|
|
198
198
|
|
|
199
|
-
const loggerConfig = /**
|
|
200
|
-
* Types the following value.
|
|
201
|
-
* @type {?} */ (logger)
|
|
199
|
+
const loggerConfig = /** @type {?} */ (logger)
|
|
202
200
|
|
|
203
201
|
if (typeof loggerConfig.toOutputConfig === "function") {
|
|
204
202
|
loggerOutputs.push(loggerConfig.toOutputConfig({configuration}))
|
|
@@ -383,9 +381,7 @@ export default class Logger {
|
|
|
383
381
|
*/
|
|
384
382
|
getConfiguration() {
|
|
385
383
|
if (!this._configuration) {
|
|
386
|
-
const objectWithConfig = /**
|
|
387
|
-
* Types the following value.
|
|
388
|
-
* @type {{configuration?: import("./configuration.js").default}} */ (this._object)
|
|
384
|
+
const objectWithConfig = /** @type {{configuration?: import("./configuration.js").default}} */ (this._object)
|
|
389
385
|
this._configuration = objectWithConfig?.configuration || currentConfiguration()
|
|
390
386
|
}
|
|
391
387
|
|
|
@@ -160,11 +160,7 @@ export default class SmtpMailerBackend {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
const sendMessage = () => {
|
|
163
|
-
connection.send({from: envelopeFrom, to: recipients}, /**
|
|
164
|
-
* Narrows the runtime value to the documented type.
|
|
165
|
-
* @type {?} */ (message), (/**
|
|
166
|
-
* Narrows the runtime value to the documented type.
|
|
167
|
-
* @type {Error | null | undefined} */ sendError) => {
|
|
163
|
+
connection.send({from: envelopeFrom, to: recipients}, /** @type {?} */ (message), (/** @type {Error | null | undefined} */ sendError) => {
|
|
168
164
|
if (sendError) {
|
|
169
165
|
rejectDelivery(sendError)
|
|
170
166
|
return
|
package/src/mailer/base.js
CHANGED
|
@@ -58,11 +58,7 @@ function inferActionName(mailerClass, stack) {
|
|
|
58
58
|
if (frameActionName.startsWith("_")) continue
|
|
59
59
|
if (frameActionName === "constructor") continue
|
|
60
60
|
if (Object.prototype.hasOwnProperty.call(VelociousMailerBase.prototype, frameActionName)) continue
|
|
61
|
-
if (typeof /**
|
|
62
|
-
* Narrows the runtime value to the documented type.
|
|
63
|
-
* @type {Record<string, ?>} */ (/**
|
|
64
|
-
* Narrows the runtime value to the documented type.
|
|
65
|
-
* @type {?} */ (prototype))[frameActionName] !== "function") continue
|
|
61
|
+
if (typeof /** @type {Record<string, ?>} */ (/** @type {?} */ (prototype))[frameActionName] !== "function") continue
|
|
66
62
|
|
|
67
63
|
actionName = frameActionName
|
|
68
64
|
}
|
|
@@ -122,9 +118,7 @@ export class VelociousMailerBase {
|
|
|
122
118
|
mail({to, subject, from, cc, bcc, replyTo, headers, actionName, actionPromise, ...restArgs}) {
|
|
123
119
|
restArgsError(restArgs)
|
|
124
120
|
|
|
125
|
-
const resolvedActionName = actionName || inferActionName(/**
|
|
126
|
-
* Narrows the runtime value to the documented type.
|
|
127
|
-
* @type {typeof VelociousMailerBase} */ (this.constructor), new Error().stack || "")
|
|
121
|
+
const resolvedActionName = actionName || inferActionName(/** @type {typeof VelociousMailerBase} */ (this.constructor), new Error().stack || "")
|
|
128
122
|
|
|
129
123
|
if (!resolvedActionName) {
|
|
130
124
|
throw new Error(`Missing actionName for ${this.constructor.name}.mail()`)
|
|
@@ -215,19 +209,13 @@ export class VelociousMailerBase {
|
|
|
215
209
|
const actionName = this._getActionName()
|
|
216
210
|
const fileName = viewFileName(actionName)
|
|
217
211
|
const viewPath = `${configuration.getDirectory()}/src/mailers/${mailerDir}/${fileName}.ejs`
|
|
218
|
-
const translate = (/**
|
|
219
|
-
* Narrows the runtime value to the documented type.
|
|
220
|
-
* @type {string} */ msgID, /**
|
|
221
|
-
* Narrows the runtime value to the documented type.
|
|
222
|
-
* @type {Record<string, ?> | undefined} */ args) => configuration.getTranslator()(msgID, args)
|
|
212
|
+
const translate = (/** @type {string} */ msgID, /** @type {Record<string, ?> | undefined} */ args) => configuration.getTranslator()(msgID, args)
|
|
223
213
|
const viewParams = incorporate({mailer: this, _: translate}, this._viewParams)
|
|
224
214
|
|
|
225
215
|
return await new Promise((resolve, reject) => {
|
|
226
216
|
ejs.renderFile(viewPath, viewParams, {}, (err, str) => {
|
|
227
217
|
if (err) {
|
|
228
|
-
const errorCode = /**
|
|
229
|
-
* Narrows the runtime value to the documented type.
|
|
230
|
-
* @type {{code?: string}} */ (err).code
|
|
218
|
+
const errorCode = /** @type {{code?: string}} */ (err).code
|
|
231
219
|
|
|
232
220
|
if (errorCode === "ENOENT") {
|
|
233
221
|
reject(new Error(`Missing mailer view file: ${viewPath}`))
|
|
@@ -52,9 +52,7 @@ export default class SqlJsWasmRouteController extends Controller {
|
|
|
52
52
|
try {
|
|
53
53
|
await fs.access(assetPath)
|
|
54
54
|
} catch (error) {
|
|
55
|
-
const ensuredError = /**
|
|
56
|
-
* Narrows the runtime value to the documented type.
|
|
57
|
-
* @type {{code?: string}} */ (error)
|
|
55
|
+
const ensuredError = /** @type {{code?: string}} */ (error)
|
|
58
56
|
|
|
59
57
|
if (ensuredError.code === "ENOENT") {
|
|
60
58
|
await this.render({json: {errorMessage: "Not found", status: "error"}, status: "not-found"})
|
|
@@ -40,9 +40,7 @@ export default class VelociousBasicRoute extends BaseRoute {
|
|
|
40
40
|
throw new Error("mount expects a mountable with a 'mountInto' method")
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const at = /**
|
|
44
|
-
* Narrows the runtime value to the documented type.
|
|
45
|
-
* @type {Record<string, ?>} */ (options).at
|
|
43
|
+
const at = /** @type {Record<string, ?>} */ (options).at
|
|
46
44
|
|
|
47
45
|
if (typeof at !== "string" || !at.startsWith("/")) {
|
|
48
46
|
throw new Error(`mount requires an 'at' option starting with '/', got: ${String(at)}`)
|
package/src/routes/resolver.js
CHANGED
|
@@ -4,9 +4,9 @@ import {dirname} from "path"
|
|
|
4
4
|
import {fileURLToPath} from "url"
|
|
5
5
|
import fs from "fs/promises"
|
|
6
6
|
import * as inflection from "inflection"
|
|
7
|
+
import {ensureError} from "typanic"
|
|
7
8
|
import Logger from "../logger.js"
|
|
8
9
|
import UploadedFile from "../http-server/client/uploaded-file/uploaded-file.js"
|
|
9
|
-
import ensureError from "../utils/ensure-error.js"
|
|
10
10
|
import toImportSpecifier from "../utils/to-import-specifier.js"
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -179,9 +179,7 @@ export default class VelociousRoutesResolver {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
const controllerClass = await this.resolveControllerClass({controllerPath})
|
|
182
|
-
const controllerRequest = /**
|
|
183
|
-
* Narrows the runtime value to the documented type.
|
|
184
|
-
* @type {import("../http-server/client/request.js").default} */ (this.request)
|
|
182
|
+
const controllerRequest = /** @type {import("../http-server/client/request.js").default} */ (this.request)
|
|
185
183
|
const controllerInstance = new controllerClass({
|
|
186
184
|
action,
|
|
187
185
|
configuration: this.configuration,
|
|
@@ -196,11 +194,7 @@ export default class VelociousRoutesResolver {
|
|
|
196
194
|
throw new Error(`Missing action on controller: ${controller}#${action}`)
|
|
197
195
|
}
|
|
198
196
|
|
|
199
|
-
const actionHandlers = /**
|
|
200
|
-
* Narrows the runtime value to the documented type.
|
|
201
|
-
* @type {Record<string, () => void | Promise<void>>} */ (/**
|
|
202
|
-
* Narrows the runtime value to the documented type.
|
|
203
|
-
* @type {?} */ (controllerInstance))
|
|
197
|
+
const actionHandlers = /** @type {Record<string, () => void | Promise<void>>} */ (/** @type {?} */ (controllerInstance))
|
|
204
198
|
|
|
205
199
|
const logMethod = this._logMethod()
|
|
206
200
|
|
|
@@ -260,9 +254,7 @@ export default class VelociousRoutesResolver {
|
|
|
260
254
|
stage: "controller-action"
|
|
261
255
|
}
|
|
262
256
|
|
|
263
|
-
const errorWithContext = /**
|
|
264
|
-
* Narrows the runtime value to the documented type.
|
|
265
|
-
* @type {{velociousContext?: object}} */ (ensuredError)
|
|
257
|
+
const errorWithContext = /** @type {{velociousContext?: object}} */ (ensuredError)
|
|
266
258
|
|
|
267
259
|
errorWithContext.velociousContext = {
|
|
268
260
|
...(errorWithContext.velociousContext || {}),
|
|
@@ -423,9 +415,7 @@ export default class VelociousRoutesResolver {
|
|
|
423
415
|
const request = this.request
|
|
424
416
|
const timestamp = this._formatTimestamp(new Date())
|
|
425
417
|
const remoteAddress = request.remoteAddress() || "unknown"
|
|
426
|
-
const loggedParams = /**
|
|
427
|
-
* Narrows the runtime value to the documented type.
|
|
428
|
-
* @type {Record<string, ?>} */ (this._sanitizeParamsForLogging(this.params))
|
|
418
|
+
const loggedParams = /** @type {Record<string, ?>} */ (this._sanitizeParamsForLogging(this.params))
|
|
429
419
|
|
|
430
420
|
delete loggedParams.action
|
|
431
421
|
delete loggedParams.controller
|
|
@@ -49,9 +49,7 @@ function isObjectLike(value) {
|
|
|
49
49
|
* @returns {boolean} - Whether arrayContaining matcher.
|
|
50
50
|
*/
|
|
51
51
|
function isArrayContaining(value) {
|
|
52
|
-
return !!value && typeof value === "object" && (/**
|
|
53
|
-
* Narrows the runtime value to the documented type.
|
|
54
|
-
* @type {?} */ (value)).__velociousMatcher === "arrayContaining"
|
|
52
|
+
return !!value && typeof value === "object" && (/** @type {?} */ (value)).__velociousMatcher === "arrayContaining"
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
/**
|
|
@@ -60,9 +58,7 @@ function isArrayContaining(value) {
|
|
|
60
58
|
* @returns {boolean} - Whether objectContaining matcher.
|
|
61
59
|
*/
|
|
62
60
|
function isObjectContaining(value) {
|
|
63
|
-
return !!value && typeof value === "object" && (/**
|
|
64
|
-
* Narrows the runtime value to the documented type.
|
|
65
|
-
* @type {?} */ (value)).__velociousMatcher === "objectContaining"
|
|
61
|
+
return !!value && typeof value === "object" && (/** @type {?} */ (value)).__velociousMatcher === "objectContaining"
|
|
66
62
|
}
|
|
67
63
|
|
|
68
64
|
/**
|
|
@@ -106,18 +102,12 @@ function valuesEqual(actual, expected) {
|
|
|
106
102
|
*/
|
|
107
103
|
function collectMatchDifferences(actual, expected, path, differences) {
|
|
108
104
|
if (isObjectContaining(expected)) {
|
|
109
|
-
collectMatchDifferences(actual, /**
|
|
110
|
-
* Narrows the runtime value to the documented type.
|
|
111
|
-
* @type {?} */ (expected).value, path, differences)
|
|
105
|
+
collectMatchDifferences(actual, /** @type {?} */ (expected).value, path, differences)
|
|
112
106
|
return
|
|
113
107
|
}
|
|
114
108
|
|
|
115
109
|
if (isArrayContaining(expected)) {
|
|
116
|
-
const {matches} = matchArrayContaining(actual, /**
|
|
117
|
-
* Narrows the runtime value to the documented type.
|
|
118
|
-
* @type {Array<?>} */ (/**
|
|
119
|
-
* Narrows the runtime value to the documented type.
|
|
120
|
-
* @type {?} */ (expected).value))
|
|
110
|
+
const {matches} = matchArrayContaining(actual, /** @type {Array<?>} */ (/** @type {?} */ (expected).value))
|
|
121
111
|
|
|
122
112
|
if (!matches) {
|
|
123
113
|
differences[path || "$"] = [expected, actual]
|
|
@@ -146,12 +136,8 @@ function collectMatchDifferences(actual, expected, path, differences) {
|
|
|
146
136
|
return
|
|
147
137
|
}
|
|
148
138
|
|
|
149
|
-
const expectedObject = /**
|
|
150
|
-
|
|
151
|
-
* @type {Record<string, ?>} */ (expected)
|
|
152
|
-
const actualObject = /**
|
|
153
|
-
* Narrows the runtime value to the documented type.
|
|
154
|
-
* @type {Record<string, ?>} */ (actual)
|
|
139
|
+
const expectedObject = /** @type {Record<string, ?>} */ (expected)
|
|
140
|
+
const actualObject = /** @type {Record<string, ?>} */ (actual)
|
|
155
141
|
|
|
156
142
|
for (const key of Object.keys(expectedObject)) {
|
|
157
143
|
const nextPath = path ? `${path}.${key}` : key
|
|
@@ -218,9 +204,7 @@ function matchArrayContaining(actual, expected) {
|
|
|
218
204
|
if (usedIndexes.has(i)) continue
|
|
219
205
|
|
|
220
206
|
if (isObjectContaining(expectedItem)) {
|
|
221
|
-
const {matches} = matchObject(actual[i], /**
|
|
222
|
-
* Narrows the runtime value to the documented type.
|
|
223
|
-
* @type {?} */ (expectedItem).value)
|
|
207
|
+
const {matches} = matchObject(actual[i], /** @type {?} */ (expectedItem).value)
|
|
224
208
|
if (matches) {
|
|
225
209
|
matchedIndex = i
|
|
226
210
|
break
|
|
@@ -229,9 +213,7 @@ function matchArrayContaining(actual, expected) {
|
|
|
229
213
|
}
|
|
230
214
|
|
|
231
215
|
if (isArrayContaining(expectedItem)) {
|
|
232
|
-
const {matches} = matchArrayContaining(actual[i], /**
|
|
233
|
-
* Narrows the runtime value to the documented type.
|
|
234
|
-
* @type {?} */ (expectedItem).value)
|
|
216
|
+
const {matches} = matchArrayContaining(actual[i], /** @type {?} */ (expectedItem).value)
|
|
235
217
|
if (matches) {
|
|
236
218
|
matchedIndex = i
|
|
237
219
|
break
|
package/src/testing/expect.js
CHANGED
|
@@ -454,9 +454,7 @@ export default class Expect extends BaseExpect {
|
|
|
454
454
|
}
|
|
455
455
|
|
|
456
456
|
if (isObjectContaining(result)) {
|
|
457
|
-
const expectedValue = /**
|
|
458
|
-
* Narrows the runtime value to the documented type.
|
|
459
|
-
* @type {?} */ (result).value
|
|
457
|
+
const expectedValue = /** @type {?} */ (result).value
|
|
460
458
|
const {matches, differences} = matchObject(this._object, expectedValue)
|
|
461
459
|
const objectPrint = formatValue(this._object)
|
|
462
460
|
const expectedPrint = formatValue(expectedValue)
|
|
@@ -475,11 +473,7 @@ export default class Expect extends BaseExpect {
|
|
|
475
473
|
}
|
|
476
474
|
|
|
477
475
|
if (isArrayContaining(result)) {
|
|
478
|
-
const expectedValue = /**
|
|
479
|
-
* Narrows the runtime value to the documented type.
|
|
480
|
-
* @type {Array<?>} */ (/**
|
|
481
|
-
* Narrows the runtime value to the documented type.
|
|
482
|
-
* @type {?} */ (result).value)
|
|
476
|
+
const expectedValue = /** @type {Array<?>} */ (/** @type {?} */ (result).value)
|
|
483
477
|
const {matches, differences} = matchArrayContaining(this._object, expectedValue)
|
|
484
478
|
const objectPrint = formatValue(this._object)
|
|
485
479
|
const expectedPrint = formatValue(expectedValue)
|
|
@@ -747,18 +741,14 @@ export default class Expect extends BaseExpect {
|
|
|
747
741
|
* Differences.
|
|
748
742
|
* @type {Record<string, Array<?>>} */
|
|
749
743
|
const differences = {}
|
|
750
|
-
const objectAsRecord = /**
|
|
751
|
-
* Narrows the runtime value to the documented type.
|
|
752
|
-
* @type {Record<string, ?>} */ (this._object)
|
|
744
|
+
const objectAsRecord = /** @type {Record<string, ?>} */ (this._object)
|
|
753
745
|
|
|
754
746
|
for (const key in result) {
|
|
755
747
|
const value = result[key]
|
|
756
748
|
|
|
757
749
|
if (!(key in objectAsRecord)) throw new Error(`${this._object.constructor.name} doesn't respond to ${key}`)
|
|
758
750
|
|
|
759
|
-
const objectValue = /**
|
|
760
|
-
* Narrows the runtime value to the documented type.
|
|
761
|
-
* @type {() => ?} */ (objectAsRecord[key])()
|
|
751
|
+
const objectValue = /** @type {() => ?} */ (objectAsRecord[key])()
|
|
762
752
|
|
|
763
753
|
if (value != objectValue) {
|
|
764
754
|
differences[key] = [value, objectValue]
|
|
@@ -378,9 +378,7 @@ export default class TestRunner {
|
|
|
378
378
|
hasRunnableTests(tests, descriptions = [], lineMatchedInScope = false) {
|
|
379
379
|
for (const testDescription in tests.tests) {
|
|
380
380
|
const testData = tests.tests[testDescription]
|
|
381
|
-
const testArgs = /**
|
|
382
|
-
* Narrows the runtime value to the documented type.
|
|
383
|
-
* @type {TestArgs} */ (Object.assign({}, testData.args))
|
|
381
|
+
const testArgs = /** @type {TestArgs} */ (Object.assign({}, testData.args))
|
|
384
382
|
const includeByLine = lineMatchedInScope || this.matchesLineFilter(testData)
|
|
385
383
|
|
|
386
384
|
if (this._onlyFocussed && !testArgs.focus) continue
|
|
@@ -731,9 +729,7 @@ export default class TestRunner {
|
|
|
731
729
|
|
|
732
730
|
for (const testDescription in tests.tests) {
|
|
733
731
|
const testData = tests.tests[testDescription]
|
|
734
|
-
const testArgs = /**
|
|
735
|
-
* Narrows the runtime value to the documented type.
|
|
736
|
-
* @type {TestArgs} */ (Object.assign({}, testData.args))
|
|
732
|
+
const testArgs = /** @type {TestArgs} */ (Object.assign({}, testData.args))
|
|
737
733
|
const includeByLine = scopeLineMatch || this.matchesLineFilter(testData)
|
|
738
734
|
|
|
739
735
|
if (this._onlyFocussed && !testArgs.focus) continue
|
|
@@ -1126,9 +1122,7 @@ export default class TestRunner {
|
|
|
1126
1122
|
/**
|
|
1127
1123
|
* Console object.
|
|
1128
1124
|
* @type {Record<ConsoleMethodName, (...args: Array<?>) => void>} */
|
|
1129
|
-
const consoleObject = /**
|
|
1130
|
-
* Narrows the runtime value to the documented type.
|
|
1131
|
-
* @type {Record<ConsoleMethodName, (...args: Array<?>) => void>} */ (console)
|
|
1125
|
+
const consoleObject = /** @type {Record<ConsoleMethodName, (...args: Array<?>) => void>} */ (console)
|
|
1132
1126
|
/**
|
|
1133
1127
|
* Original console methods.
|
|
1134
1128
|
* @type {Record<ConsoleMethodName, (...args: Array<?>) => void>} */
|
package/src/testing/test.js
CHANGED
|
@@ -287,14 +287,10 @@ function it(description, arg1, arg2) {
|
|
|
287
287
|
let testFunction
|
|
288
288
|
|
|
289
289
|
if (typeof arg1 == "function") {
|
|
290
|
-
testFunction = /**
|
|
291
|
-
* Narrows the runtime value to the documented type.
|
|
292
|
-
* @type {() => (void|Promise<void>)} */ (arg1)
|
|
290
|
+
testFunction = /** @type {() => (void|Promise<void>)} */ (arg1)
|
|
293
291
|
testArgs = {}
|
|
294
292
|
} else if (typeof arg2 == "function") {
|
|
295
|
-
testFunction = /**
|
|
296
|
-
* Narrows the runtime value to the documented type.
|
|
297
|
-
* @type {() => (void|Promise<void>)} */ (arg2)
|
|
293
|
+
testFunction = /** @type {() => (void|Promise<void>)} */ (arg2)
|
|
298
294
|
testArgs = arg1
|
|
299
295
|
} else {
|
|
300
296
|
throw new Error(`Invalid arguments for it: ${description}, ${arg1}`)
|
|
@@ -331,14 +327,10 @@ function fit(description, arg1, arg2) {
|
|
|
331
327
|
let testFunction
|
|
332
328
|
|
|
333
329
|
if (typeof arg1 == "function") {
|
|
334
|
-
testFunction = /**
|
|
335
|
-
* Narrows the runtime value to the documented type.
|
|
336
|
-
* @type {() => (void|Promise<void>)} */ (arg1)
|
|
330
|
+
testFunction = /** @type {() => (void|Promise<void>)} */ (arg1)
|
|
337
331
|
testArgs = {focus: true}
|
|
338
332
|
} else if (typeof arg2 == "function") {
|
|
339
|
-
testFunction = /**
|
|
340
|
-
* Narrows the runtime value to the documented type.
|
|
341
|
-
* @type {() => (void|Promise<void>)} */ (arg2)
|
|
333
|
+
testFunction = /** @type {() => (void|Promise<void>)} */ (arg2)
|
|
342
334
|
testArgs = Object.assign({focus: true}, arg1)
|
|
343
335
|
} else {
|
|
344
336
|
throw new Error(`Invalid arguments for it: ${description}, ${arg1}`)
|
package/src/utils/model-scope.js
CHANGED
|
@@ -50,7 +50,5 @@ export function defineModelScope({callback, modelClass, startQuery}) {
|
|
|
50
50
|
* @returns {value is ModelScopeDescriptor} - Whether the value is a scope descriptor.
|
|
51
51
|
*/
|
|
52
52
|
export function isModelScopeDescriptor(value) {
|
|
53
|
-
return Boolean(value && typeof value === "object" && /**
|
|
54
|
-
* Narrows the runtime value to the documented type.
|
|
55
|
-
* @type {Record<string, ?>} */ (value)[MODEL_SCOPE_DESCRIPTOR_MARKER] === true)
|
|
53
|
+
return Boolean(value && typeof value === "object" && /** @type {Record<string, ?>} */ (value)[MODEL_SCOPE_DESCRIPTOR_MARKER] === true)
|
|
56
54
|
}
|
package/src/utils/ransack.js
CHANGED
|
@@ -172,9 +172,7 @@ function normalizeAdvancedRansackConditions({modelClass, value}) {
|
|
|
172
172
|
throw new Error(`Unsupported ransack predicate in condition: ${predicateValue}`)
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
const predicate = /**
|
|
176
|
-
* Narrows the runtime value to the documented type.
|
|
177
|
-
* @type {RansackPredicate} */ (predicateValue)
|
|
175
|
+
const predicate = /** @type {RansackPredicate} */ (predicateValue)
|
|
178
176
|
const rawValue = advancedRansackConditionValue({predicate, value: entry.v})
|
|
179
177
|
const normalizedValue = normalizeRansackValue({predicate, value: rawValue})
|
|
180
178
|
|
|
@@ -523,18 +521,12 @@ function resolveAttributeName({modelClass, value}) {
|
|
|
523
521
|
* @returns {Record<string, {targetModelClass: RansackModelClass}>} - Relationship entries keyed by name.
|
|
524
522
|
*/
|
|
525
523
|
function relationshipEntries(modelClass) {
|
|
526
|
-
if (typeof /**
|
|
527
|
-
* Narrows the runtime value to the documented type.
|
|
528
|
-
* @type {?} */ (modelClass).getRelationshipsMap === "function") {
|
|
524
|
+
if (typeof /** @type {?} */ (modelClass).getRelationshipsMap === "function") {
|
|
529
525
|
return backendRelationshipEntries(modelClass)
|
|
530
526
|
}
|
|
531
527
|
|
|
532
|
-
if (typeof /**
|
|
533
|
-
|
|
534
|
-
* @type {?} */ (modelClass).relationshipDefinitions === "function" &&
|
|
535
|
-
typeof /**
|
|
536
|
-
* Narrows the runtime value to the documented type.
|
|
537
|
-
* @type {?} */ (modelClass).relationshipModelClasses === "function") {
|
|
528
|
+
if (typeof /** @type {?} */ (modelClass).relationshipDefinitions === "function" &&
|
|
529
|
+
typeof /** @type {?} */ (modelClass).relationshipModelClasses === "function") {
|
|
538
530
|
return frontendRelationshipEntries(modelClass)
|
|
539
531
|
}
|
|
540
532
|
|
|
@@ -551,9 +543,7 @@ function backendRelationshipEntries(modelClass) {
|
|
|
551
543
|
* Entries.
|
|
552
544
|
* @type {Record<string, {targetModelClass: RansackModelClass}>} */
|
|
553
545
|
const entries = {}
|
|
554
|
-
const relationshipsMap = /**
|
|
555
|
-
* Narrows the runtime value to the documented type.
|
|
556
|
-
* @type {?} */ (modelClass).getRelationshipsMap()
|
|
546
|
+
const relationshipsMap = /** @type {?} */ (modelClass).getRelationshipsMap()
|
|
557
547
|
|
|
558
548
|
for (const relationshipName of Object.keys(relationshipsMap)) {
|
|
559
549
|
const relationship = relationshipsMap[relationshipName]
|
|
@@ -580,12 +570,8 @@ function frontendRelationshipEntries(modelClass) {
|
|
|
580
570
|
* Entries.
|
|
581
571
|
* @type {Record<string, {targetModelClass: RansackModelClass}>} */
|
|
582
572
|
const entries = {}
|
|
583
|
-
const definitions = /**
|
|
584
|
-
|
|
585
|
-
* @type {?} */ (modelClass).relationshipDefinitions()
|
|
586
|
-
const relationshipModelClasses = /**
|
|
587
|
-
* Narrows the runtime value to the documented type.
|
|
588
|
-
* @type {?} */ (modelClass).relationshipModelClasses()
|
|
573
|
+
const definitions = /** @type {?} */ (modelClass).relationshipDefinitions()
|
|
574
|
+
const relationshipModelClasses = /** @type {?} */ (modelClass).relationshipModelClasses()
|
|
589
575
|
|
|
590
576
|
for (const relationshipName of Object.keys(definitions)) {
|
|
591
577
|
const targetModelClass = resolveFrontendModelClass(relationshipModelClasses[relationshipName])
|
|
@@ -604,20 +590,12 @@ function frontendRelationshipEntries(modelClass) {
|
|
|
604
590
|
* @returns {Record<string, string>} - Attribute-to-column entries keyed by attribute name.
|
|
605
591
|
*/
|
|
606
592
|
function attributeEntries(modelClass) {
|
|
607
|
-
if (typeof /**
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
const resourceConfig = typeof /**
|
|
616
|
-
* Narrows the runtime value to the documented type.
|
|
617
|
-
* @type {?} */ (modelClass).resourceConfig === "function"
|
|
618
|
-
? /**
|
|
619
|
-
* Narrows the runtime value to the documented type.
|
|
620
|
-
* @type {?} */ (modelClass).resourceConfig()
|
|
593
|
+
if (typeof /** @type {?} */ (modelClass).getAttributeNameToColumnNameMap === "function") {
|
|
594
|
+
return /** @type {Record<string, string>} */ ((/** @type {?} */ (modelClass).getAttributeNameToColumnNameMap()))
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
const resourceConfig = typeof /** @type {?} */ (modelClass).resourceConfig === "function"
|
|
598
|
+
? /** @type {?} */ (modelClass).resourceConfig()
|
|
621
599
|
: {}
|
|
622
600
|
const attributes = resourceConfig.attributes
|
|
623
601
|
/**
|
|
@@ -675,9 +653,7 @@ function parseRansackKey(key) {
|
|
|
675
653
|
|
|
676
654
|
return {
|
|
677
655
|
pathValue,
|
|
678
|
-
predicate: /**
|
|
679
|
-
* Narrows the runtime value to the documented type.
|
|
680
|
-
* @type {RansackPredicate} */ (predicate)
|
|
656
|
+
predicate: /** @type {RansackPredicate} */ (predicate)
|
|
681
657
|
}
|
|
682
658
|
}
|
|
683
659
|
|
|
@@ -694,9 +670,7 @@ function parseRansackKey(key) {
|
|
|
694
670
|
|
|
695
671
|
return {
|
|
696
672
|
pathValue,
|
|
697
|
-
predicate: /**
|
|
698
|
-
* Narrows the runtime value to the documented type.
|
|
699
|
-
* @type {RansackPredicate} */ (predicate)
|
|
673
|
+
predicate: /** @type {RansackPredicate} */ (predicate)
|
|
700
674
|
}
|
|
701
675
|
}
|
|
702
676
|
|
|
@@ -10,9 +10,7 @@ let asyncLocalStorage
|
|
|
10
10
|
/**
|
|
11
11
|
* Tracked stack global.
|
|
12
12
|
* @type {{withTrackedStack?: {addTrackedStackToError: (error: Error) => void, withTrackedStack: (arg1: string | (() => Promise<?>), arg2?: (() => Promise<?>) | Error) => Promise<?>}}} */
|
|
13
|
-
const trackedStackGlobal = /**
|
|
14
|
-
* Narrows the runtime value to the documented type.
|
|
15
|
-
* @type {?} */ (globalThis)
|
|
13
|
+
const trackedStackGlobal = /** @type {?} */ (globalThis)
|
|
16
14
|
|
|
17
15
|
if (AsyncLocalStorage) {
|
|
18
16
|
asyncLocalStorage = new AsyncLocalStorage()
|
|
@@ -57,14 +55,10 @@ async function withTrackedStack(arg1, arg2) {
|
|
|
57
55
|
let stack
|
|
58
56
|
|
|
59
57
|
if (typeof arg2 == "function" && typeof arg1 == "string") {
|
|
60
|
-
callback = /**
|
|
61
|
-
* Narrows the runtime value to the documented type.
|
|
62
|
-
* @type {() => Promise<?>} */ (arg2)
|
|
58
|
+
callback = /** @type {() => Promise<?>} */ (arg2)
|
|
63
59
|
stack = arg1
|
|
64
60
|
} else {
|
|
65
|
-
callback = /**
|
|
66
|
-
* Narrows the runtime value to the documented type.
|
|
67
|
-
* @type {() => Promise<?>} */ (arg1)
|
|
61
|
+
callback = /** @type {() => Promise<?>} */ (arg1)
|
|
68
62
|
stack = Error().stack || ""
|
|
69
63
|
}
|
|
70
64
|
|