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
|
@@ -28,15 +28,11 @@ export default class VelociousDatabaseRecordHasOneInstanceRelationship extends B
|
|
|
28
28
|
* @returns {InstanceType<TMC>} - The build.
|
|
29
29
|
*/
|
|
30
30
|
build(data) {
|
|
31
|
-
const TargetModelClass = /**
|
|
32
|
-
* Narrows the runtime value to the documented type.
|
|
33
|
-
* @type {TMC} */ (this.getTargetModelClass())
|
|
31
|
+
const TargetModelClass = /** @type {TMC} */ (this.getTargetModelClass())
|
|
34
32
|
|
|
35
33
|
if (!TargetModelClass) throw new Error("Can't build a new record without a target model class")
|
|
36
34
|
|
|
37
|
-
const newInstance = /**
|
|
38
|
-
* Narrows the runtime value to the documented type.
|
|
39
|
-
* @type {InstanceType<TMC>} */ (new TargetModelClass(data))
|
|
35
|
+
const newInstance = /** @type {InstanceType<TMC>} */ (new TargetModelClass(data))
|
|
40
36
|
|
|
41
37
|
this._loaded = newInstance
|
|
42
38
|
|
|
@@ -56,12 +52,8 @@ export default class VelociousDatabaseRecordHasOneInstanceRelationship extends B
|
|
|
56
52
|
|
|
57
53
|
const foreignKey = this.getForeignKey()
|
|
58
54
|
const primaryKey = this.getPrimaryKey()
|
|
59
|
-
const primaryModelID = /**
|
|
60
|
-
|
|
61
|
-
* @type {string | number} */ (this.getModel().readColumn(primaryKey))
|
|
62
|
-
const TargetModelClass = /**
|
|
63
|
-
* Narrows the runtime value to the documented type.
|
|
64
|
-
* @type {TMC} */ (this.getTargetModelClass())
|
|
55
|
+
const primaryModelID = /** @type {string | number} */ (this.getModel().readColumn(primaryKey))
|
|
56
|
+
const TargetModelClass = /** @type {TMC} */ (this.getTargetModelClass())
|
|
65
57
|
|
|
66
58
|
if (!TargetModelClass) throw new Error("Can't load without a target model class")
|
|
67
59
|
|
|
@@ -133,11 +133,7 @@ export default class VelociousDatabaseRecordBaseRelationship {
|
|
|
133
133
|
|
|
134
134
|
if (!scope) return query
|
|
135
135
|
|
|
136
|
-
const scopedQuery = /**
|
|
137
|
-
* Narrows the runtime value to the documented type.
|
|
138
|
-
* @type {T | void} */ (scope.call(query, /**
|
|
139
|
-
* Narrows the runtime value to the documented type.
|
|
140
|
-
* @type {import("../../query/model-class-query.js").default<typeof import("../index.js").default>} */ (query)))
|
|
136
|
+
const scopedQuery = /** @type {T | void} */ (scope.call(query, /** @type {import("../../query/model-class-query.js").default<typeof import("../index.js").default>} */ (query)))
|
|
141
137
|
|
|
142
138
|
return scopedQuery || query
|
|
143
139
|
}
|
|
@@ -10,9 +10,7 @@ export default class VelociousDatabaseRecordValidatorsPresence extends Base {
|
|
|
10
10
|
* @param {string} args.attributeName - Attribute name.
|
|
11
11
|
*/
|
|
12
12
|
async validate({model, attributeName}) {
|
|
13
|
-
const rawValue = /**
|
|
14
|
-
* Narrows the runtime value to the documented type.
|
|
15
|
-
* @type {string | undefined} */ (model.readAttribute(attributeName))
|
|
13
|
+
const rawValue = /** @type {string | undefined} */ (model.readAttribute(attributeName))
|
|
16
14
|
const attributeValue = rawValue?.trim()
|
|
17
15
|
|
|
18
16
|
if (!attributeValue) {
|
|
@@ -12,15 +12,11 @@ export default class VelociousDatabaseRecordValidatorsUniqueness extends Base {
|
|
|
12
12
|
* @returns {Promise<void>} - Resolves when complete.
|
|
13
13
|
*/
|
|
14
14
|
async validate({model, attributeName}) {
|
|
15
|
-
const modelClass = /**
|
|
16
|
-
* Narrows the runtime value to the documented type.
|
|
17
|
-
* @type {typeof import("../index.js").default} */ (model.constructor)
|
|
15
|
+
const modelClass = /** @type {typeof import("../index.js").default} */ (model.constructor)
|
|
18
16
|
|
|
19
17
|
const connection = modelClass.connection()
|
|
20
18
|
const tableName = modelClass._getTable().getName()
|
|
21
|
-
const attributeValue = /**
|
|
22
|
-
* Narrows the runtime value to the documented type.
|
|
23
|
-
* @type {string | number} */ (model.readAttribute(attributeName))
|
|
19
|
+
const attributeValue = /** @type {string | number} */ (model.readAttribute(attributeName))
|
|
24
20
|
const attributeNameUnderscore = inflection.underscore(attributeName)
|
|
25
21
|
|
|
26
22
|
/**
|
|
@@ -49,9 +45,7 @@ export default class VelociousDatabaseRecordValidatorsUniqueness extends Base {
|
|
|
49
45
|
|
|
50
46
|
if (scopeValue == null) return
|
|
51
47
|
|
|
52
|
-
whereArgs[scopeUnderscore] = /**
|
|
53
|
-
* Narrows the runtime value to the documented type.
|
|
54
|
-
* @type {string | number} */ (scopeValue)
|
|
48
|
+
whereArgs[scopeUnderscore] = /** @type {string | number} */ (scopeValue)
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
let existingRecordQuery = modelClass
|
|
@@ -82,9 +76,7 @@ export default class VelociousDatabaseRecordValidatorsUniqueness extends Base {
|
|
|
82
76
|
* @returns {string | number | null}
|
|
83
77
|
*/
|
|
84
78
|
_resolveScopeValueFromRelationship(model, scopeColumn) {
|
|
85
|
-
const modelClass = /**
|
|
86
|
-
* Narrows the runtime value to the documented type.
|
|
87
|
-
* @type {typeof import("../index.js").default} */ (model.constructor)
|
|
79
|
+
const modelClass = /** @type {typeof import("../index.js").default} */ (model.constructor)
|
|
88
80
|
const relationships = modelClass.getRelationshipsMap()
|
|
89
81
|
|
|
90
82
|
for (const relationshipName in relationships) {
|
|
@@ -229,9 +229,7 @@ export default class VelociousEnvironmentsHandlerBrowser extends Base {
|
|
|
229
229
|
/**
|
|
230
230
|
* Files.
|
|
231
231
|
* @type {import("./base.js").MigrationObjectType[]} */
|
|
232
|
-
const files = /**
|
|
233
|
-
* Narrows the runtime value to the documented type.
|
|
234
|
-
* @type {import("./base.js").MigrationObjectType[]} */ (migrations)
|
|
232
|
+
const files = /** @type {import("./base.js").MigrationObjectType[]} */ (migrations)
|
|
235
233
|
|
|
236
234
|
files.sort((migration1, migration2) => migration1.date - migration2.date)
|
|
237
235
|
|
|
@@ -22,9 +22,7 @@ function buildConsoleContext({application, configuration}) {
|
|
|
22
22
|
if (dbs[identifier]) continue
|
|
23
23
|
|
|
24
24
|
const pool = configuration.getDatabasePool(identifier)
|
|
25
|
-
const poolWithGlobal = /**
|
|
26
|
-
* Narrows the runtime value to the documented type.
|
|
27
|
-
* @type {{getGlobalConnection?: () => import("../../../../database/drivers/base.js").default | undefined}} */ (pool)
|
|
25
|
+
const poolWithGlobal = /** @type {{getGlobalConnection?: () => import("../../../../database/drivers/base.js").default | undefined}} */ (pool)
|
|
28
26
|
const globalConnection = poolWithGlobal.getGlobalConnection?.()
|
|
29
27
|
|
|
30
28
|
if (globalConnection) {
|
|
@@ -65,9 +63,7 @@ function buildConsoleContext({application, configuration}) {
|
|
|
65
63
|
function assignConsoleContext({context, replServer}) {
|
|
66
64
|
Object.assign(replServer.context, context)
|
|
67
65
|
|
|
68
|
-
const modelClasses = /**
|
|
69
|
-
* Narrows the runtime value to the documented type.
|
|
70
|
-
* @type {Record<string, typeof import("../../../../database/record/index.js").default>} */ (
|
|
66
|
+
const modelClasses = /** @type {Record<string, typeof import("../../../../database/record/index.js").default>} */ (
|
|
71
67
|
context.models || {}
|
|
72
68
|
)
|
|
73
69
|
|
|
@@ -57,9 +57,7 @@ export default class DbSchemaLoad extends BaseCommand {
|
|
|
57
57
|
* @returns {{exec: (sql: string) => Promise<?>} | undefined} - Connection with exec support.
|
|
58
58
|
*/
|
|
59
59
|
executableConnection(db) {
|
|
60
|
-
const dbWithConnection = /**
|
|
61
|
-
* Narrows the runtime value to the documented type.
|
|
62
|
-
* @type {import("../../../../../../database/drivers/base.js").default & {connection?: ?}} */ (db)
|
|
60
|
+
const dbWithConnection = /** @type {import("../../../../../../database/drivers/base.js").default & {connection?: ?}} */ (db)
|
|
63
61
|
const connection = dbWithConnection.connection
|
|
64
62
|
|
|
65
63
|
if (connection && typeof connection == "object" && "exec" in connection && typeof connection.exec == "function") {
|
|
@@ -397,8 +397,10 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
397
397
|
values: memberCommands
|
|
398
398
|
})
|
|
399
399
|
}
|
|
400
|
-
|
|
401
|
-
|
|
400
|
+
const primaryKey = this.frontendModelPrimaryKeyForResource({attributeNames, modelClass, modelConfig})
|
|
401
|
+
|
|
402
|
+
if (primaryKey !== "id") {
|
|
403
|
+
fileContent += ` primaryKey: ${JSON.stringify(primaryKey)},\n`
|
|
402
404
|
}
|
|
403
405
|
const nestedRelationshipNames = this.nestedRelationshipNamesForGenerator(resourceClass || null)
|
|
404
406
|
if (nestedRelationshipNames.length > 0) {
|
|
@@ -840,10 +842,7 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
840
842
|
modelClass,
|
|
841
843
|
modelName: modelClass.getModelName(),
|
|
842
844
|
params: {},
|
|
843
|
-
resourceConfiguration: /**
|
|
844
|
-
* Resource configuration.
|
|
845
|
-
* @type {import("../../../../../configuration-types.js").FrontendModelResourceConfiguration}
|
|
846
|
-
*/ ({attributes: []})
|
|
845
|
+
resourceConfiguration: /** @type {import("../../../../../configuration-types.js").FrontendModelResourceConfiguration} */ ({attributes: []})
|
|
847
846
|
})
|
|
848
847
|
const spec = instance.permittedParams({action, ability: undefined, locals: {}, params: {}})
|
|
849
848
|
|
|
@@ -880,10 +879,7 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
880
879
|
modelClass,
|
|
881
880
|
modelName: modelClass.getModelName(),
|
|
882
881
|
params: {},
|
|
883
|
-
resourceConfiguration: /**
|
|
884
|
-
* Resource configuration.
|
|
885
|
-
* @type {import("../../../../../configuration-types.js").FrontendModelResourceConfiguration}
|
|
886
|
-
*/ ({attributes: []})
|
|
882
|
+
resourceConfiguration: /** @type {import("../../../../../configuration-types.js").FrontendModelResourceConfiguration} */ ({attributes: []})
|
|
887
883
|
})
|
|
888
884
|
spec = instance.permittedParams()
|
|
889
885
|
} catch (error) {
|
|
@@ -1095,6 +1091,66 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
1095
1091
|
return modelClass.resolveAttributeName(primaryKey) === attributeName
|
|
1096
1092
|
}
|
|
1097
1093
|
|
|
1094
|
+
/**
|
|
1095
|
+
* Resolves the primary key from explicit resource config or the backend model.
|
|
1096
|
+
* @param {{attributeNames: Array<string>, modelClass: typeof import("../../../../../database/record/index.js").default | undefined, modelConfig: import("../../../../../configuration-types.js").NormalizedFrontendModelResourceConfiguration}} args - Primary key resolution args.
|
|
1097
|
+
* @returns {string | Array<string>} - Frontend-model primary key attribute name.
|
|
1098
|
+
*/
|
|
1099
|
+
frontendModelPrimaryKeyForResource({attributeNames, modelClass, modelConfig}) {
|
|
1100
|
+
if (modelConfig.primaryKey) {
|
|
1101
|
+
return this.validatedConfiguredPrimaryKey({attributeNames, primaryKey: modelConfig.primaryKey})
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
if (!modelClass) return "id"
|
|
1105
|
+
|
|
1106
|
+
return this.frontendModelPrimaryKeyForModelClass({attributeNames, modelClass})
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* Validates an explicitly configured frontend-model primary key.
|
|
1111
|
+
* @param {{attributeNames: Array<string>, primaryKey: string}} args - Configured primary key args.
|
|
1112
|
+
* @returns {string} - Configured primary key.
|
|
1113
|
+
*/
|
|
1114
|
+
validatedConfiguredPrimaryKey({attributeNames, primaryKey}) {
|
|
1115
|
+
if (attributeNames.includes(primaryKey)) return primaryKey
|
|
1116
|
+
|
|
1117
|
+
throw new Error(`Configured frontend model primary key "${primaryKey}" is not a generated frontend model attribute.`)
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* Resolves the backend primary key to generated frontend-model attribute names.
|
|
1122
|
+
* @param {{attributeNames: Array<string>, modelClass: typeof import("../../../../../database/record/index.js").default}} args - Primary key resolution args.
|
|
1123
|
+
* @returns {string | Array<string>} - Frontend-model primary key attribute name.
|
|
1124
|
+
*/
|
|
1125
|
+
frontendModelPrimaryKeyForModelClass({attributeNames, modelClass}) {
|
|
1126
|
+
const primaryKey = modelClass.primaryKey()
|
|
1127
|
+
|
|
1128
|
+
if (primaryKey === "id") return "id"
|
|
1129
|
+
|
|
1130
|
+
if (Array.isArray(primaryKey)) {
|
|
1131
|
+
return primaryKey.map((columnName) => this.frontendModelPrimaryKeyAttributeName({attributeNames, columnName, modelClass}))
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
return this.frontendModelPrimaryKeyAttributeName({attributeNames, columnName: primaryKey, modelClass})
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* Resolves one backend primary key column to a generated frontend-model attribute name.
|
|
1139
|
+
* @param {{attributeNames: Array<string>, columnName: string, modelClass: typeof import("../../../../../database/record/index.js").default}} args - Primary key args.
|
|
1140
|
+
* @returns {string} - Frontend-model primary key attribute name.
|
|
1141
|
+
*/
|
|
1142
|
+
frontendModelPrimaryKeyAttributeName({attributeNames, columnName, modelClass}) {
|
|
1143
|
+
if (attributeNames.includes(columnName)) return columnName
|
|
1144
|
+
|
|
1145
|
+
const attributeName = modelClass.resolveAttributeName(columnName)
|
|
1146
|
+
|
|
1147
|
+
if (attributeName && attributeNames.includes(attributeName)) {
|
|
1148
|
+
return attributeName
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
throw new Error(`${modelClass.name}.primaryKey() column "${columnName}" does not resolve to a generated frontend model attribute.`)
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1098
1154
|
/**
|
|
1099
1155
|
* Resolves frontend attribute config from explicit metadata, resource methods, model columns, translated columns, or model accessor JSDoc.
|
|
1100
1156
|
* @param {object} args - Arguments.
|
|
@@ -1376,7 +1432,7 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
1376
1432
|
*/
|
|
1377
1433
|
customCommandMethodSignature({commandMetadata, methodName}) {
|
|
1378
1434
|
const metadata = commandMetadata[methodName] || {args: [], returnType: null}
|
|
1379
|
-
const returnType = metadata.returnType || "Record<string,
|
|
1435
|
+
const returnType = metadata.returnType || "Record<string, FrontendModelAttributeValue>"
|
|
1380
1436
|
|
|
1381
1437
|
if (metadata.args.length > 0) {
|
|
1382
1438
|
const parameterNames = metadata.args.map((arg) => arg.name)
|
|
@@ -125,13 +125,14 @@ export default class VelociousEnvironmentHandlerNode extends Base{
|
|
|
125
125
|
const ResourceClass = imported.default
|
|
126
126
|
|
|
127
127
|
if (!frontendModelResourceDefinitionIsClass(ResourceClass)) continue
|
|
128
|
+
// Skip abstract/common base resources that declare no `ModelClass` — they are
|
|
129
|
+
// not models, so they must not be recorded as discovered frontend models.
|
|
130
|
+
if (!ResourceClass.ModelClass) continue
|
|
128
131
|
|
|
129
132
|
const baseName = file.replace(/\.(js|mjs)$/, "")
|
|
130
133
|
const modelName = baseName.replace(/-resource$/, "")
|
|
131
134
|
.split("-")
|
|
132
|
-
.map((/**
|
|
133
|
-
* Narrows the runtime value to the documented type.
|
|
134
|
-
* @type {string} */ part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
135
|
+
.map((/** @type {string} */ part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
135
136
|
.join("")
|
|
136
137
|
|
|
137
138
|
discovered[modelName] = ResourceClass
|
|
@@ -861,9 +862,7 @@ export default class VelociousEnvironmentHandlerNode extends Base{
|
|
|
861
862
|
* @returns {Promise<Record<string, string>>} - Resolves with SQL string.
|
|
862
863
|
*/
|
|
863
864
|
async _structureSqlByIdentifier({dbs}) {
|
|
864
|
-
const sqlByIdentifier = /**
|
|
865
|
-
* Narrows the runtime value to the documented type.
|
|
866
|
-
* @type {Record<string, string>} */ ({})
|
|
865
|
+
const sqlByIdentifier = /** @type {Record<string, string>} */ ({})
|
|
867
866
|
|
|
868
867
|
for (const identifier of Object.keys(dbs)) {
|
|
869
868
|
const db = dbs[identifier]
|
|
@@ -890,6 +889,16 @@ export default class VelociousEnvironmentHandlerNode extends Base{
|
|
|
890
889
|
* @returns {Promise<void>} - Resolves when complete.
|
|
891
890
|
*/
|
|
892
891
|
async initializeFrontendModelWebsocketPublishers(configuration) {
|
|
892
|
+
// Discover each backend project's resources before registering publishers. The publishers are
|
|
893
|
+
// derived from `backendProject.frontendModels`, which `autoDiscoverResources` populates. Without
|
|
894
|
+
// this, registration runs against an empty/partial resource set (only built-ins), so apps that
|
|
895
|
+
// resolve resources through an `abilityResolver` rather than a static ability-resource list never
|
|
896
|
+
// register lifecycle publishers and their realtime frontend-model updates silently stop. The
|
|
897
|
+
// lifecycle hooks are deduped per model class via a process-global set, so a later, fully
|
|
898
|
+
// discovered pass cannot retroactively add the missing publishers. `autoDiscoverResources` is
|
|
899
|
+
// idempotent (it skips backend projects whose `frontendModels` are already set).
|
|
900
|
+
await this.autoDiscoverResources(configuration)
|
|
901
|
+
|
|
893
902
|
const {ensureFrontendModelWebsocketPublishersRegistered} = await import("../frontend-models/websocket-publishers.js")
|
|
894
903
|
|
|
895
904
|
await ensureFrontendModelWebsocketPublishersRegistered(configuration)
|