velocious 1.0.449 → 1.0.451
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/application.js +4 -4
- package/build/authorization/ability.js +8 -8
- package/build/authorization/base-resource.js +4 -4
- package/build/background-jobs/cron-expression.js +1 -1
- package/build/background-jobs/forked-runner-child.js +1 -1
- package/build/background-jobs/job-registry.js +1 -1
- package/build/background-jobs/job-runner.js +1 -1
- package/build/background-jobs/job.js +1 -1
- package/build/background-jobs/json-socket.js +4 -4
- package/build/background-jobs/main.js +21 -21
- package/build/background-jobs/scheduler.js +7 -7
- package/build/background-jobs/store.js +7 -7
- package/build/background-jobs/web/controller.js +2 -2
- package/build/background-jobs/worker.js +12 -12
- package/build/beacon/client.js +11 -8
- package/build/beacon/in-process-broker.js +2 -2
- package/build/beacon/in-process-client.js +2 -2
- package/build/beacon/server.js +3 -3
- package/build/cli/browser-cli.js +1 -1
- package/build/cli/commands/db/base-command.js +2 -2
- package/build/cli/index.js +2 -2
- package/build/cli/tenant-database-command-helper.js +3 -3
- package/build/cli/use-browser-cli.js +1 -1
- package/build/configuration-types.js +3 -1
- package/build/configuration.js +38 -38
- package/build/controller.js +8 -8
- package/build/current-configuration.js +1 -1
- package/build/database/annotations-async-hooks.js +2 -2
- package/build/database/annotations.js +3 -3
- package/build/database/drivers/base-column.js +1 -1
- package/build/database/drivers/base-foreign-key.js +1 -1
- package/build/database/drivers/base-table.js +1 -1
- package/build/database/drivers/base.js +10 -10
- package/build/database/drivers/mssql/index.js +1 -1
- package/build/database/drivers/mssql/table.js +1 -1
- package/build/database/drivers/mysql/index.js +3 -3
- package/build/database/drivers/mysql/query.js +1 -1
- package/build/database/drivers/mysql/table.js +1 -1
- package/build/database/drivers/pgsql/index.js +2 -2
- package/build/database/drivers/sqlite/base.js +16 -16
- package/build/database/drivers/sqlite/index.js +11 -11
- package/build/database/drivers/sqlite/index.native.js +1 -1
- package/build/database/drivers/sqlite/index.web.js +3 -3
- package/build/database/drivers/sqlite/query.js +1 -1
- package/build/database/drivers/sqlite/query.web.js +1 -1
- package/build/database/drivers/sqlite/sql/alter-table.js +2 -2
- package/build/database/drivers/sqlite/table.js +1 -1
- package/build/database/migrator/files-finder.js +1 -1
- package/build/database/migrator.js +6 -6
- package/build/database/pool/async-tracked-multi-connection.js +27 -27
- package/build/database/pool/base-methods-forward.js +4 -4
- package/build/database/pool/base.js +8 -8
- package/build/database/query/from-base.js +1 -1
- package/build/database/query/index.js +10 -10
- package/build/database/query/join-object.js +3 -3
- package/build/database/query/model-class-query.js +39 -39
- package/build/database/query/preloader/belongs-to.js +22 -22
- package/build/database/query/preloader/has-many.js +20 -20
- package/build/database/query/preloader/has-one.js +8 -8
- package/build/database/query/preloader/selection.js +3 -3
- package/build/database/query/preloader.js +8 -8
- package/build/database/query/query-data.js +9 -9
- package/build/database/query/where-model-class-hash.js +7 -7
- package/build/database/query/with-count.js +9 -9
- package/build/database/record/acts-as-list.js +15 -15
- package/build/database/record/attachments/handle.js +2 -2
- package/build/database/record/attachments/normalize-input.js +12 -12
- package/build/database/record/attachments/storage-drivers/s3.js +6 -6
- package/build/database/record/attachments/store.js +13 -13
- package/build/database/record/index.js +115 -121
- package/build/database/record/instance-relationships/base.js +11 -11
- package/build/database/record/instance-relationships/belongs-to.js +3 -3
- package/build/database/record/instance-relationships/has-many.js +8 -8
- package/build/database/record/instance-relationships/has-one.js +7 -7
- package/build/database/record/relationships/base.js +2 -2
- package/build/database/record/state-machine.js +7 -7
- package/build/database/record/validators/presence.js +1 -1
- package/build/database/record/validators/uniqueness.js +5 -5
- package/build/database/table-data/index.js +4 -4
- package/build/environment-handlers/base.js +2 -2
- package/build/environment-handlers/browser.js +7 -7
- package/build/environment-handlers/node/cli/commands/cli-command-context.js +1 -1
- package/build/environment-handlers/node/cli/commands/console.js +4 -4
- package/build/environment-handlers/node/cli/commands/db/schema/dump.js +1 -1
- package/build/environment-handlers/node/cli/commands/db/schema/load.js +3 -3
- package/build/environment-handlers/node/cli/commands/generate/frontend-models.js +836 -60
- package/build/environment-handlers/node.js +6 -6
- package/build/frontend-model-controller.js +81 -82
- package/build/frontend-model-resource/base-resource.js +78 -115
- package/build/frontend-models/base.js +162 -149
- package/build/frontend-models/clear-pending-debounced-callback.js +1 -1
- package/build/frontend-models/event-hook-models.js +2 -2
- package/build/frontend-models/outgoing-event-buffer.js +2 -2
- package/build/frontend-models/preloader.js +5 -5
- package/build/frontend-models/query.js +43 -38
- package/build/frontend-models/resource-definition.js +6 -6
- package/build/frontend-models/transport-serialization.js +11 -11
- package/build/frontend-models/use-destroyed-event.js +10 -10
- package/build/frontend-models/use-model-class-event.js +11 -11
- package/build/frontend-models/use-updated-event.js +11 -11
- package/build/frontend-models/websocket-channel.js +26 -17
- package/build/frontend-models/websocket-publishers.js +9 -9
- package/build/http-client/response.js +2 -2
- package/build/http-server/client/index.js +8 -8
- package/build/http-server/client/params-to-object.js +10 -10
- package/build/http-server/client/request-buffer/form-data-part.js +2 -2
- package/build/http-server/client/request-buffer/index.js +8 -8
- package/build/http-server/client/request-parser.js +3 -3
- package/build/http-server/client/request-runner.js +6 -6
- package/build/http-server/client/request-timing.js +5 -5
- package/build/http-server/client/request.js +1 -1
- package/build/http-server/client/response.js +5 -5
- package/build/http-server/client/websocket-request.js +4 -4
- package/build/http-server/client/websocket-session.js +18 -18
- package/build/http-server/development-reloader.js +5 -5
- package/build/http-server/index.js +12 -12
- package/build/http-server/remote-address.js +4 -4
- package/build/http-server/server-client.js +3 -3
- package/build/http-server/server-lock.js +4 -4
- package/build/http-server/websocket-channel-subscribers.js +3 -3
- package/build/http-server/websocket-channel.js +1 -1
- package/build/http-server/websocket-connection.js +1 -1
- package/build/http-server/websocket-event-log-store.js +6 -6
- package/build/http-server/websocket-events-host.js +2 -2
- package/build/http-server/worker-handler/in-process.js +7 -7
- package/build/http-server/worker-handler/index.js +4 -4
- package/build/http-server/worker-handler/worker-thread.js +3 -3
- package/build/logger/outputs/array-output.js +3 -3
- package/build/logger/outputs/console-output.js +1 -1
- package/build/logger/outputs/file-output.js +4 -4
- package/build/logger/outputs/stdout-output.js +1 -1
- package/build/logger.js +10 -10
- package/build/mailer/backends/smtp.js +3 -3
- package/build/mailer/base.js +8 -8
- package/build/mailer/delivery.js +4 -4
- package/build/plugins/sqljs-wasm-route-controller.js +1 -1
- package/build/routes/base-route.js +6 -6
- package/build/routes/basic-route.js +1 -1
- package/build/routes/hooks/frontend-model-command-route-hook.js +1 -1
- package/build/routes/index.js +1 -1
- package/build/routes/plugin-routes.js +1 -1
- package/build/routes/resolver.js +11 -11
- package/build/routes/resource-route.js +1 -1
- package/build/src/application.d.ts +3 -3
- package/build/src/application.d.ts.map +1 -1
- package/build/src/application.js +5 -5
- package/build/src/authorization/ability.d.ts +7 -7
- package/build/src/authorization/ability.d.ts.map +1 -1
- package/build/src/authorization/ability.js +9 -9
- package/build/src/authorization/base-resource.d.ts +1 -1
- package/build/src/authorization/base-resource.d.ts.map +1 -1
- package/build/src/authorization/base-resource.js +5 -5
- package/build/src/background-jobs/cron-expression.js +2 -2
- package/build/src/background-jobs/forked-runner-child.js +2 -2
- package/build/src/background-jobs/job-registry.d.ts +1 -1
- package/build/src/background-jobs/job-registry.d.ts.map +1 -1
- package/build/src/background-jobs/job-registry.js +2 -2
- package/build/src/background-jobs/job-runner.js +2 -2
- package/build/src/background-jobs/job.js +2 -2
- package/build/src/background-jobs/json-socket.d.ts +4 -4
- package/build/src/background-jobs/json-socket.d.ts.map +1 -1
- package/build/src/background-jobs/json-socket.js +5 -5
- package/build/src/background-jobs/main.d.ts +18 -18
- package/build/src/background-jobs/main.d.ts.map +1 -1
- package/build/src/background-jobs/main.js +22 -22
- package/build/src/background-jobs/scheduler.d.ts +5 -5
- package/build/src/background-jobs/scheduler.d.ts.map +1 -1
- package/build/src/background-jobs/scheduler.js +8 -8
- package/build/src/background-jobs/store.js +8 -8
- package/build/src/background-jobs/web/controller.js +3 -3
- package/build/src/background-jobs/worker.d.ts +6 -6
- package/build/src/background-jobs/worker.d.ts.map +1 -1
- package/build/src/background-jobs/worker.js +13 -13
- package/build/src/beacon/client.d.ts +4 -4
- package/build/src/beacon/client.d.ts.map +1 -1
- package/build/src/beacon/client.js +12 -9
- package/build/src/beacon/in-process-broker.d.ts.map +1 -1
- package/build/src/beacon/in-process-broker.js +3 -3
- package/build/src/beacon/in-process-client.d.ts +1 -1
- package/build/src/beacon/in-process-client.d.ts.map +1 -1
- package/build/src/beacon/in-process-client.js +3 -3
- package/build/src/beacon/server.d.ts +2 -2
- package/build/src/beacon/server.d.ts.map +1 -1
- package/build/src/beacon/server.js +4 -4
- package/build/src/cli/browser-cli.js +2 -2
- package/build/src/cli/commands/db/base-command.d.ts +2 -2
- package/build/src/cli/commands/db/base-command.d.ts.map +1 -1
- package/build/src/cli/commands/db/base-command.js +3 -3
- package/build/src/cli/index.js +3 -3
- package/build/src/cli/tenant-database-command-helper.d.ts +1 -1
- package/build/src/cli/tenant-database-command-helper.d.ts.map +1 -1
- package/build/src/cli/tenant-database-command-helper.js +4 -4
- package/build/src/cli/use-browser-cli.js +2 -2
- package/build/src/configuration-types.d.ts +12 -2
- package/build/src/configuration-types.d.ts.map +1 -1
- package/build/src/configuration-types.js +4 -2
- package/build/src/configuration.d.ts +14 -14
- package/build/src/configuration.d.ts.map +1 -1
- package/build/src/configuration.js +39 -39
- package/build/src/controller.js +10 -10
- package/build/src/current-configuration.js +2 -2
- package/build/src/database/annotations-async-hooks.js +3 -3
- package/build/src/database/annotations.d.ts.map +1 -1
- package/build/src/database/annotations.js +4 -4
- package/build/src/database/drivers/base-column.d.ts +1 -1
- package/build/src/database/drivers/base-column.d.ts.map +1 -1
- package/build/src/database/drivers/base-column.js +2 -2
- package/build/src/database/drivers/base-foreign-key.d.ts +1 -1
- package/build/src/database/drivers/base-foreign-key.d.ts.map +1 -1
- package/build/src/database/drivers/base-foreign-key.js +2 -2
- package/build/src/database/drivers/base-table.d.ts +1 -1
- package/build/src/database/drivers/base-table.d.ts.map +1 -1
- package/build/src/database/drivers/base-table.js +2 -2
- package/build/src/database/drivers/base.d.ts +6 -6
- package/build/src/database/drivers/base.d.ts.map +1 -1
- package/build/src/database/drivers/base.js +11 -11
- package/build/src/database/drivers/mssql/index.js +2 -2
- package/build/src/database/drivers/mssql/table.js +2 -2
- package/build/src/database/drivers/mysql/index.js +4 -4
- package/build/src/database/drivers/mysql/query.js +2 -2
- package/build/src/database/drivers/mysql/table.js +2 -2
- package/build/src/database/drivers/pgsql/index.js +3 -3
- package/build/src/database/drivers/sqlite/base.d.ts +3 -3
- package/build/src/database/drivers/sqlite/base.d.ts.map +1 -1
- package/build/src/database/drivers/sqlite/base.js +17 -17
- package/build/src/database/drivers/sqlite/index.d.ts +4 -4
- package/build/src/database/drivers/sqlite/index.d.ts.map +1 -1
- package/build/src/database/drivers/sqlite/index.js +12 -12
- package/build/src/database/drivers/sqlite/index.native.js +2 -2
- package/build/src/database/drivers/sqlite/index.web.d.ts +2 -2
- package/build/src/database/drivers/sqlite/index.web.d.ts.map +1 -1
- package/build/src/database/drivers/sqlite/index.web.js +4 -4
- package/build/src/database/drivers/sqlite/query.js +2 -2
- package/build/src/database/drivers/sqlite/query.web.js +2 -2
- package/build/src/database/drivers/sqlite/sql/alter-table.js +3 -3
- package/build/src/database/drivers/sqlite/table.js +2 -2
- package/build/src/database/migrator/files-finder.js +2 -2
- package/build/src/database/migrator.d.ts +1 -1
- package/build/src/database/migrator.d.ts.map +1 -1
- package/build/src/database/migrator.js +7 -7
- package/build/src/database/pool/async-tracked-multi-connection.d.ts +9 -9
- package/build/src/database/pool/async-tracked-multi-connection.d.ts.map +1 -1
- package/build/src/database/pool/async-tracked-multi-connection.js +28 -28
- package/build/src/database/pool/base-methods-forward.js +7 -7
- package/build/src/database/pool/base.d.ts +1 -1
- package/build/src/database/pool/base.d.ts.map +1 -1
- package/build/src/database/pool/base.js +9 -9
- package/build/src/database/query/from-base.d.ts +1 -1
- package/build/src/database/query/from-base.d.ts.map +1 -1
- package/build/src/database/query/from-base.js +2 -2
- package/build/src/database/query/index.d.ts +4 -4
- package/build/src/database/query/index.d.ts.map +1 -1
- package/build/src/database/query/index.js +11 -11
- package/build/src/database/query/join-object.js +4 -4
- package/build/src/database/query/model-class-query.d.ts +4 -4
- package/build/src/database/query/model-class-query.d.ts.map +1 -1
- package/build/src/database/query/model-class-query.js +40 -40
- package/build/src/database/query/preloader/belongs-to.js +23 -23
- package/build/src/database/query/preloader/has-many.js +21 -21
- package/build/src/database/query/preloader/has-one.js +9 -9
- package/build/src/database/query/preloader/selection.js +4 -4
- package/build/src/database/query/preloader.js +9 -9
- package/build/src/database/query/query-data.js +10 -10
- package/build/src/database/query/where-model-class-hash.js +8 -8
- package/build/src/database/query/with-count.js +10 -10
- package/build/src/database/record/acts-as-list.js +20 -20
- package/build/src/database/record/attachments/handle.d.ts +1 -1
- package/build/src/database/record/attachments/handle.d.ts.map +1 -1
- package/build/src/database/record/attachments/handle.js +3 -3
- package/build/src/database/record/attachments/normalize-input.js +15 -15
- package/build/src/database/record/attachments/storage-drivers/s3.js +7 -7
- package/build/src/database/record/attachments/store.d.ts +2 -2
- package/build/src/database/record/attachments/store.d.ts.map +1 -1
- package/build/src/database/record/attachments/store.js +14 -14
- package/build/src/database/record/index.d.ts +18 -25
- package/build/src/database/record/index.d.ts.map +1 -1
- package/build/src/database/record/index.js +135 -141
- package/build/src/database/record/instance-relationships/base.d.ts +3 -3
- package/build/src/database/record/instance-relationships/base.d.ts.map +1 -1
- package/build/src/database/record/instance-relationships/base.js +13 -13
- package/build/src/database/record/instance-relationships/belongs-to.js +4 -4
- package/build/src/database/record/instance-relationships/has-many.js +9 -9
- package/build/src/database/record/instance-relationships/has-one.d.ts +1 -1
- package/build/src/database/record/instance-relationships/has-one.d.ts.map +1 -1
- package/build/src/database/record/instance-relationships/has-one.js +8 -8
- package/build/src/database/record/relationships/base.js +4 -4
- package/build/src/database/record/state-machine.js +8 -8
- package/build/src/database/record/validators/presence.js +2 -2
- package/build/src/database/record/validators/uniqueness.js +6 -6
- package/build/src/database/table-data/index.d.ts +4 -4
- package/build/src/database/table-data/index.d.ts.map +1 -1
- package/build/src/database/table-data/index.js +5 -5
- package/build/src/environment-handlers/base.js +3 -3
- package/build/src/environment-handlers/browser.d.ts +3 -3
- package/build/src/environment-handlers/browser.d.ts.map +1 -1
- package/build/src/environment-handlers/browser.js +8 -8
- package/build/src/environment-handlers/node/cli/commands/cli-command-context.js +2 -2
- package/build/src/environment-handlers/node/cli/commands/console.d.ts.map +1 -1
- package/build/src/environment-handlers/node/cli/commands/console.js +5 -5
- package/build/src/environment-handlers/node/cli/commands/db/schema/dump.d.ts +1 -1
- package/build/src/environment-handlers/node/cli/commands/db/schema/dump.d.ts.map +1 -1
- package/build/src/environment-handlers/node/cli/commands/db/schema/dump.js +2 -2
- package/build/src/environment-handlers/node/cli/commands/db/schema/load.d.ts +1 -1
- 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 +4 -4
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +285 -12
- 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 +712 -61
- package/build/src/environment-handlers/node.d.ts +2 -2
- package/build/src/environment-handlers/node.d.ts.map +1 -1
- package/build/src/environment-handlers/node.js +7 -7
- package/build/src/frontend-model-controller.d.ts +5 -6
- package/build/src/frontend-model-controller.d.ts.map +1 -1
- package/build/src/frontend-model-controller.js +88 -89
- package/build/src/frontend-model-resource/base-resource.d.ts +36 -27
- package/build/src/frontend-model-resource/base-resource.d.ts.map +1 -1
- package/build/src/frontend-model-resource/base-resource.js +67 -120
- package/build/src/frontend-models/base.d.ts +67 -59
- package/build/src/frontend-models/base.d.ts.map +1 -1
- package/build/src/frontend-models/base.js +171 -158
- package/build/src/frontend-models/clear-pending-debounced-callback.js +2 -2
- package/build/src/frontend-models/event-hook-models.d.ts.map +1 -1
- package/build/src/frontend-models/event-hook-models.js +3 -3
- package/build/src/frontend-models/outgoing-event-buffer.d.ts +1 -1
- package/build/src/frontend-models/outgoing-event-buffer.d.ts.map +1 -1
- package/build/src/frontend-models/outgoing-event-buffer.js +3 -3
- package/build/src/frontend-models/preloader.js +6 -6
- package/build/src/frontend-models/query.d.ts +16 -8
- package/build/src/frontend-models/query.d.ts.map +1 -1
- package/build/src/frontend-models/query.js +43 -39
- package/build/src/frontend-models/resource-definition.js +7 -7
- package/build/src/frontend-models/transport-serialization.js +12 -12
- package/build/src/frontend-models/use-destroyed-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-destroyed-event.js +11 -11
- package/build/src/frontend-models/use-model-class-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-model-class-event.js +12 -12
- package/build/src/frontend-models/use-updated-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-updated-event.js +12 -12
- package/build/src/frontend-models/websocket-channel.d.ts +6 -1
- package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
- package/build/src/frontend-models/websocket-channel.js +26 -18
- package/build/src/frontend-models/websocket-publishers.js +11 -11
- package/build/src/http-client/response.d.ts +2 -2
- package/build/src/http-client/response.d.ts.map +1 -1
- package/build/src/http-client/response.js +3 -3
- package/build/src/http-server/client/index.d.ts +1 -1
- package/build/src/http-server/client/index.d.ts.map +1 -1
- package/build/src/http-server/client/index.js +9 -9
- package/build/src/http-server/client/params-to-object.js +11 -11
- package/build/src/http-server/client/request-buffer/form-data-part.d.ts +2 -2
- package/build/src/http-server/client/request-buffer/form-data-part.d.ts.map +1 -1
- package/build/src/http-server/client/request-buffer/form-data-part.js +3 -3
- package/build/src/http-server/client/request-buffer/index.d.ts +4 -4
- package/build/src/http-server/client/request-buffer/index.d.ts.map +1 -1
- package/build/src/http-server/client/request-buffer/index.js +9 -9
- package/build/src/http-server/client/request-parser.d.ts +1 -1
- package/build/src/http-server/client/request-parser.d.ts.map +1 -1
- package/build/src/http-server/client/request-parser.js +4 -4
- package/build/src/http-server/client/request-runner.js +7 -7
- package/build/src/http-server/client/request-timing.d.ts +5 -5
- package/build/src/http-server/client/request-timing.d.ts.map +1 -1
- package/build/src/http-server/client/request-timing.js +6 -6
- package/build/src/http-server/client/request.js +2 -2
- package/build/src/http-server/client/response.d.ts +3 -3
- package/build/src/http-server/client/response.d.ts.map +1 -1
- package/build/src/http-server/client/response.js +6 -6
- package/build/src/http-server/client/websocket-request.d.ts +3 -3
- package/build/src/http-server/client/websocket-request.d.ts.map +1 -1
- package/build/src/http-server/client/websocket-request.js +5 -5
- package/build/src/http-server/client/websocket-session.d.ts +6 -6
- package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
- package/build/src/http-server/client/websocket-session.js +19 -19
- package/build/src/http-server/development-reloader.d.ts +3 -3
- package/build/src/http-server/development-reloader.d.ts.map +1 -1
- package/build/src/http-server/development-reloader.js +6 -6
- package/build/src/http-server/index.d.ts +7 -7
- package/build/src/http-server/index.d.ts.map +1 -1
- package/build/src/http-server/index.js +13 -13
- package/build/src/http-server/remote-address.js +6 -6
- package/build/src/http-server/server-client.js +4 -4
- package/build/src/http-server/server-lock.js +5 -5
- package/build/src/http-server/websocket-channel-subscribers.d.ts +1 -1
- package/build/src/http-server/websocket-channel-subscribers.d.ts.map +1 -1
- package/build/src/http-server/websocket-channel-subscribers.js +4 -4
- package/build/src/http-server/websocket-channel.d.ts +1 -1
- package/build/src/http-server/websocket-channel.d.ts.map +1 -1
- package/build/src/http-server/websocket-channel.js +2 -2
- package/build/src/http-server/websocket-connection.d.ts +1 -1
- package/build/src/http-server/websocket-connection.d.ts.map +1 -1
- package/build/src/http-server/websocket-connection.js +2 -2
- package/build/src/http-server/websocket-event-log-store.d.ts +1 -1
- package/build/src/http-server/websocket-event-log-store.d.ts.map +1 -1
- package/build/src/http-server/websocket-event-log-store.js +7 -7
- package/build/src/http-server/websocket-events-host.d.ts +1 -1
- package/build/src/http-server/websocket-events-host.d.ts.map +1 -1
- package/build/src/http-server/websocket-events-host.js +3 -3
- package/build/src/http-server/worker-handler/in-process.d.ts +3 -3
- package/build/src/http-server/worker-handler/in-process.d.ts.map +1 -1
- package/build/src/http-server/worker-handler/in-process.js +9 -9
- package/build/src/http-server/worker-handler/index.d.ts +4 -4
- package/build/src/http-server/worker-handler/index.d.ts.map +1 -1
- package/build/src/http-server/worker-handler/index.js +5 -5
- package/build/src/http-server/worker-handler/worker-thread.d.ts +2 -2
- package/build/src/http-server/worker-handler/worker-thread.d.ts.map +1 -1
- package/build/src/http-server/worker-handler/worker-thread.js +4 -4
- package/build/src/logger/outputs/array-output.d.ts +3 -3
- package/build/src/logger/outputs/array-output.d.ts.map +1 -1
- package/build/src/logger/outputs/array-output.js +4 -4
- package/build/src/logger/outputs/console-output.d.ts +1 -1
- package/build/src/logger/outputs/console-output.d.ts.map +1 -1
- package/build/src/logger/outputs/console-output.js +2 -2
- package/build/src/logger/outputs/file-output.d.ts +4 -4
- package/build/src/logger/outputs/file-output.d.ts.map +1 -1
- package/build/src/logger/outputs/file-output.js +5 -5
- package/build/src/logger/outputs/stdout-output.d.ts.map +1 -1
- package/build/src/logger/outputs/stdout-output.js +2 -2
- package/build/src/logger.d.ts.map +1 -1
- package/build/src/logger.js +11 -11
- package/build/src/mailer/backends/smtp.d.ts.map +1 -1
- package/build/src/mailer/backends/smtp.js +5 -5
- package/build/src/mailer/base.js +11 -11
- package/build/src/mailer/delivery.d.ts +3 -3
- package/build/src/mailer/delivery.d.ts.map +1 -1
- package/build/src/mailer/delivery.js +5 -5
- package/build/src/plugins/sqljs-wasm-route-controller.js +2 -2
- package/build/src/routes/base-route.d.ts +6 -6
- package/build/src/routes/base-route.d.ts.map +1 -1
- package/build/src/routes/base-route.js +7 -7
- package/build/src/routes/basic-route.js +2 -2
- package/build/src/routes/hooks/frontend-model-command-route-hook.js +2 -2
- package/build/src/routes/index.js +2 -2
- package/build/src/routes/plugin-routes.js +2 -2
- package/build/src/routes/resolver.d.ts +1 -1
- package/build/src/routes/resolver.d.ts.map +1 -1
- package/build/src/routes/resolver.js +13 -13
- package/build/src/routes/resource-route.d.ts +1 -1
- package/build/src/routes/resource-route.d.ts.map +1 -1
- package/build/src/routes/resource-route.js +2 -2
- package/build/src/testing/browser-frontend-model-event-hook-scenarios.d.ts.map +1 -1
- package/build/src/testing/browser-frontend-model-event-hook-scenarios.js +8 -8
- package/build/src/testing/expect-utils.js +13 -13
- package/build/src/testing/expect.d.ts +1 -1
- package/build/src/testing/expect.d.ts.map +1 -1
- package/build/src/testing/expect.js +9 -9
- package/build/src/testing/test-files-finder.d.ts +8 -8
- package/build/src/testing/test-files-finder.d.ts.map +1 -1
- package/build/src/testing/test-files-finder.js +9 -9
- package/build/src/testing/test-filter-parser.js +3 -3
- package/build/src/testing/test-runner.d.ts +2 -2
- package/build/src/testing/test-runner.d.ts.map +1 -1
- package/build/src/testing/test-runner.js +17 -17
- package/build/src/testing/test-suite-splitter.js +2 -2
- package/build/src/testing/test.d.ts +2 -2
- package/build/src/testing/test.d.ts.map +1 -1
- package/build/src/testing/test.js +16 -16
- package/build/src/utils/backtrace-cleaner.d.ts +1 -1
- package/build/src/utils/backtrace-cleaner.d.ts.map +1 -1
- package/build/src/utils/backtrace-cleaner.js +2 -2
- package/build/src/utils/format-value.js +2 -2
- package/build/src/utils/model-scope.js +2 -2
- package/build/src/utils/ransack.js +27 -27
- package/build/src/utils/with-tracked-stack-async-hooks.js +8 -8
- package/build/src/utils/with-tracked-stack.js +4 -4
- package/build/testing/browser-frontend-model-event-hook-scenarios.js +7 -7
- package/build/testing/expect-utils.js +11 -11
- package/build/testing/expect.js +7 -7
- package/build/testing/test-files-finder.js +8 -8
- package/build/testing/test-filter-parser.js +2 -2
- package/build/testing/test-runner.js +16 -16
- package/build/testing/test-suite-splitter.js +1 -1
- package/build/testing/test.js +15 -15
- package/build/utils/backtrace-cleaner.js +1 -1
- package/build/utils/format-value.js +1 -1
- package/build/utils/model-scope.js +1 -1
- package/build/utils/ransack.js +26 -26
- package/build/utils/with-tracked-stack-async-hooks.js +7 -7
- package/build/utils/with-tracked-stack.js +3 -3
- package/package.json +2 -1
- package/src/application.js +4 -4
- package/src/authorization/ability.js +8 -8
- package/src/authorization/base-resource.js +4 -4
- package/src/background-jobs/cron-expression.js +1 -1
- package/src/background-jobs/forked-runner-child.js +1 -1
- package/src/background-jobs/job-registry.js +1 -1
- package/src/background-jobs/job-runner.js +1 -1
- package/src/background-jobs/job.js +1 -1
- package/src/background-jobs/json-socket.js +4 -4
- package/src/background-jobs/main.js +21 -21
- package/src/background-jobs/scheduler.js +7 -7
- package/src/background-jobs/store.js +7 -7
- package/src/background-jobs/web/controller.js +2 -2
- package/src/background-jobs/worker.js +12 -12
- package/src/beacon/client.js +11 -8
- package/src/beacon/in-process-broker.js +2 -2
- package/src/beacon/in-process-client.js +2 -2
- package/src/beacon/server.js +3 -3
- package/src/cli/browser-cli.js +1 -1
- package/src/cli/commands/db/base-command.js +2 -2
- package/src/cli/index.js +2 -2
- package/src/cli/tenant-database-command-helper.js +3 -3
- package/src/cli/use-browser-cli.js +1 -1
- package/src/configuration-types.js +3 -1
- package/src/configuration.js +38 -38
- package/src/controller.js +8 -8
- package/src/current-configuration.js +1 -1
- package/src/database/annotations-async-hooks.js +2 -2
- package/src/database/annotations.js +3 -3
- package/src/database/drivers/base-column.js +1 -1
- package/src/database/drivers/base-foreign-key.js +1 -1
- package/src/database/drivers/base-table.js +1 -1
- package/src/database/drivers/base.js +10 -10
- package/src/database/drivers/mssql/index.js +1 -1
- package/src/database/drivers/mssql/table.js +1 -1
- package/src/database/drivers/mysql/index.js +3 -3
- package/src/database/drivers/mysql/query.js +1 -1
- package/src/database/drivers/mysql/table.js +1 -1
- package/src/database/drivers/pgsql/index.js +2 -2
- package/src/database/drivers/sqlite/base.js +16 -16
- package/src/database/drivers/sqlite/index.js +11 -11
- package/src/database/drivers/sqlite/index.native.js +1 -1
- package/src/database/drivers/sqlite/index.web.js +3 -3
- package/src/database/drivers/sqlite/query.js +1 -1
- package/src/database/drivers/sqlite/query.web.js +1 -1
- package/src/database/drivers/sqlite/sql/alter-table.js +2 -2
- package/src/database/drivers/sqlite/table.js +1 -1
- package/src/database/migrator/files-finder.js +1 -1
- package/src/database/migrator.js +6 -6
- package/src/database/pool/async-tracked-multi-connection.js +27 -27
- package/src/database/pool/base-methods-forward.js +4 -4
- package/src/database/pool/base.js +8 -8
- package/src/database/query/from-base.js +1 -1
- package/src/database/query/index.js +10 -10
- package/src/database/query/join-object.js +3 -3
- package/src/database/query/model-class-query.js +39 -39
- package/src/database/query/preloader/belongs-to.js +22 -22
- package/src/database/query/preloader/has-many.js +20 -20
- package/src/database/query/preloader/has-one.js +8 -8
- package/src/database/query/preloader/selection.js +3 -3
- package/src/database/query/preloader.js +8 -8
- package/src/database/query/query-data.js +9 -9
- package/src/database/query/where-model-class-hash.js +7 -7
- package/src/database/query/with-count.js +9 -9
- package/src/database/record/acts-as-list.js +15 -15
- package/src/database/record/attachments/handle.js +2 -2
- package/src/database/record/attachments/normalize-input.js +12 -12
- package/src/database/record/attachments/storage-drivers/s3.js +6 -6
- package/src/database/record/attachments/store.js +13 -13
- package/src/database/record/index.js +115 -121
- package/src/database/record/instance-relationships/base.js +11 -11
- package/src/database/record/instance-relationships/belongs-to.js +3 -3
- package/src/database/record/instance-relationships/has-many.js +8 -8
- package/src/database/record/instance-relationships/has-one.js +7 -7
- package/src/database/record/relationships/base.js +2 -2
- package/src/database/record/state-machine.js +7 -7
- package/src/database/record/validators/presence.js +1 -1
- package/src/database/record/validators/uniqueness.js +5 -5
- package/src/database/table-data/index.js +4 -4
- package/src/environment-handlers/base.js +2 -2
- package/src/environment-handlers/browser.js +7 -7
- package/src/environment-handlers/node/cli/commands/cli-command-context.js +1 -1
- package/src/environment-handlers/node/cli/commands/console.js +4 -4
- package/src/environment-handlers/node/cli/commands/db/schema/dump.js +1 -1
- package/src/environment-handlers/node/cli/commands/db/schema/load.js +3 -3
- package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +836 -60
- package/src/environment-handlers/node.js +6 -6
- package/src/frontend-model-controller.js +81 -82
- package/src/frontend-model-resource/base-resource.js +78 -115
- package/src/frontend-models/base.js +162 -149
- package/src/frontend-models/clear-pending-debounced-callback.js +1 -1
- package/src/frontend-models/event-hook-models.js +2 -2
- package/src/frontend-models/outgoing-event-buffer.js +2 -2
- package/src/frontend-models/preloader.js +5 -5
- package/src/frontend-models/query.js +43 -38
- package/src/frontend-models/resource-definition.js +6 -6
- package/src/frontend-models/transport-serialization.js +11 -11
- package/src/frontend-models/use-destroyed-event.js +10 -10
- package/src/frontend-models/use-model-class-event.js +11 -11
- package/src/frontend-models/use-updated-event.js +11 -11
- package/src/frontend-models/websocket-channel.js +26 -17
- package/src/frontend-models/websocket-publishers.js +9 -9
- package/src/http-client/response.js +2 -2
- package/src/http-server/client/index.js +8 -8
- package/src/http-server/client/params-to-object.js +10 -10
- package/src/http-server/client/request-buffer/form-data-part.js +2 -2
- package/src/http-server/client/request-buffer/index.js +8 -8
- package/src/http-server/client/request-parser.js +3 -3
- package/src/http-server/client/request-runner.js +6 -6
- package/src/http-server/client/request-timing.js +5 -5
- package/src/http-server/client/request.js +1 -1
- package/src/http-server/client/response.js +5 -5
- package/src/http-server/client/websocket-request.js +4 -4
- package/src/http-server/client/websocket-session.js +18 -18
- package/src/http-server/development-reloader.js +5 -5
- package/src/http-server/index.js +12 -12
- package/src/http-server/remote-address.js +4 -4
- package/src/http-server/server-client.js +3 -3
- package/src/http-server/server-lock.js +4 -4
- package/src/http-server/websocket-channel-subscribers.js +3 -3
- package/src/http-server/websocket-channel.js +1 -1
- package/src/http-server/websocket-connection.js +1 -1
- package/src/http-server/websocket-event-log-store.js +6 -6
- package/src/http-server/websocket-events-host.js +2 -2
- package/src/http-server/worker-handler/in-process.js +7 -7
- package/src/http-server/worker-handler/index.js +4 -4
- package/src/http-server/worker-handler/worker-thread.js +3 -3
- package/src/logger/outputs/array-output.js +3 -3
- package/src/logger/outputs/console-output.js +1 -1
- package/src/logger/outputs/file-output.js +4 -4
- package/src/logger/outputs/stdout-output.js +1 -1
- package/src/logger.js +10 -10
- package/src/mailer/backends/smtp.js +3 -3
- package/src/mailer/base.js +8 -8
- package/src/mailer/delivery.js +4 -4
- package/src/plugins/sqljs-wasm-route-controller.js +1 -1
- package/src/routes/base-route.js +6 -6
- package/src/routes/basic-route.js +1 -1
- package/src/routes/hooks/frontend-model-command-route-hook.js +1 -1
- package/src/routes/index.js +1 -1
- package/src/routes/plugin-routes.js +1 -1
- package/src/routes/resolver.js +11 -11
- package/src/routes/resource-route.js +1 -1
- package/src/testing/browser-frontend-model-event-hook-scenarios.js +7 -7
- package/src/testing/expect-utils.js +11 -11
- package/src/testing/expect.js +7 -7
- package/src/testing/test-files-finder.js +8 -8
- package/src/testing/test-filter-parser.js +2 -2
- package/src/testing/test-runner.js +16 -16
- package/src/testing/test-suite-splitter.js +1 -1
- package/src/testing/test.js +15 -15
- package/src/utils/backtrace-cleaner.js +1 -1
- package/src/utils/format-value.js +1 -1
- package/src/utils/model-scope.js +1 -1
- package/src/utils/ransack.js +26 -26
- package/src/utils/with-tracked-stack-async-hooks.js +7 -7
- package/src/utils/with-tracked-stack.js +3 -3
|
@@ -16,10 +16,10 @@ import {readPayloadAssociationCount, readPayloadComputedAbility, readPayloadQuer
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* FrontendModelCommandType type.
|
|
19
|
-
|
|
19
|
+
* @typedef {"create" | "find" | "index" | "update" | "destroy" | "attach" | "download" | "url"} FrontendModelCommandType */
|
|
20
20
|
/**
|
|
21
21
|
* FrontendModelRequestCommandType type.
|
|
22
|
-
|
|
22
|
+
* @typedef {FrontendModelCommandType | string} FrontendModelRequestCommandType */
|
|
23
23
|
/**
|
|
24
24
|
* Model-like instance value supported by frontend-model transport.
|
|
25
25
|
* @typedef {{attributes: () => Record<string, unknown>}} FrontendModelTransportModelValue
|
|
@@ -64,7 +64,19 @@ import {readPayloadAssociationCount, readPayloadComputedAbility, readPayloadQuer
|
|
|
64
64
|
* @template {FrontendModelBase} [T=FrontendModelBase]
|
|
65
65
|
* @template {Record<string, FrontendModelAttributeValue>} [Attributes=Record<string, FrontendModelAttributeValue>]
|
|
66
66
|
* @template {Record<string, FrontendModelAttributeValue>} [CreateAttributes=Record<string, FrontendModelAttributeValue>]
|
|
67
|
-
* @typedef {{new (
|
|
67
|
+
* @typedef {{new (): T, create(attributes?: CreateAttributes): Promise<T>} & Omit<typeof FrontendModelBase, "create" | "prototype">} FrontendModelClass
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* Create attributes accepted by a frontend model instance.
|
|
71
|
+
* @template {FrontendModelBase} T
|
|
72
|
+
* @typedef {T extends FrontendModelBase<Record<string, FrontendModelAttributeValue>, infer CreateAttributes, infer _UpdateAttributes> ? CreateAttributes : Record<string, FrontendModelAttributeValue>} FrontendModelCreateAttributesFor
|
|
73
|
+
*/
|
|
74
|
+
/**
|
|
75
|
+
* Loaded instance type for relationship helper generics. Older generated
|
|
76
|
+
* frontend models passed model classes into relationship helpers, while newer
|
|
77
|
+
* generated models pass instance types.
|
|
78
|
+
* @template {FrontendModelBase | typeof FrontendModelBase} T
|
|
79
|
+
* @typedef {T extends new (...args: any[]) => infer Instance ? Instance : T} FrontendModelRelationshipModel
|
|
68
80
|
*/
|
|
69
81
|
/**
|
|
70
82
|
* FrontendModelTransportConfig type.
|
|
@@ -85,7 +97,7 @@ import {readPayloadAssociationCount, readPayloadComputedAbility, readPayloadQuer
|
|
|
85
97
|
|
|
86
98
|
/**
|
|
87
99
|
* Frontend model transport config.
|
|
88
|
-
|
|
100
|
+
* @type {FrontendModelTransportConfig} */
|
|
89
101
|
const frontendModelTransportConfig = {}
|
|
90
102
|
const SHARED_FRONTEND_MODEL_API_PATH = "/frontend-models"
|
|
91
103
|
const PRELOADED_RELATIONSHIPS_KEY = "__preloadedRelationships"
|
|
@@ -95,19 +107,19 @@ const QUERY_DATA_KEY = "__queryData"
|
|
|
95
107
|
const ABILITIES_KEY = "__abilities"
|
|
96
108
|
/**
|
|
97
109
|
* Pending shared frontend model requests.
|
|
98
|
-
|
|
110
|
+
* @type {Array<{commandName?: string, commandType: FrontendModelRequestCommandType, customPath?: string, modelClass: FrontendModelClass, payload: Record<string, ?>, requestId: string, resolve: (response: Record<string, ?>) => void, reject: (error: ?) => void, resourcePath?: string | null}>} */
|
|
99
111
|
let pendingSharedFrontendModelRequests = []
|
|
100
112
|
let sharedFrontendModelRequestId = 0
|
|
101
113
|
let sharedFrontendModelFlushScheduled = false
|
|
102
114
|
let activeFrontendModelTransportRequestCount = 0
|
|
103
115
|
/**
|
|
104
116
|
* Frontend model idle resolvers.
|
|
105
|
-
|
|
117
|
+
* @type {Array<() => void>} */
|
|
106
118
|
let frontendModelIdleResolvers = []
|
|
107
119
|
|
|
108
120
|
/**
|
|
109
121
|
* Internal websocket client.
|
|
110
|
-
|
|
122
|
+
* @type {VelociousWebsocketClient | null} */
|
|
111
123
|
let internalWebsocketClient = null
|
|
112
124
|
|
|
113
125
|
/**
|
|
@@ -122,7 +134,7 @@ function frontendModelTransportIsIdle() {
|
|
|
122
134
|
|
|
123
135
|
/**
|
|
124
136
|
* Runs resolve frontend model idle waiters.
|
|
125
|
-
|
|
137
|
+
* @returns {void} */
|
|
126
138
|
function resolveFrontendModelIdleWaiters() {
|
|
127
139
|
if (!frontendModelTransportIsIdle()) return
|
|
128
140
|
|
|
@@ -215,7 +227,7 @@ function resolveInternalWebsocketClient() {
|
|
|
215
227
|
|
|
216
228
|
/**
|
|
217
229
|
* Runs flush buffered outgoing events after reconnect.
|
|
218
|
-
|
|
230
|
+
* @returns {Promise<void>} */
|
|
219
231
|
async function flushBufferedOutgoingEventsAfterReconnect() {
|
|
220
232
|
if (!internalWebsocketClient) return
|
|
221
233
|
|
|
@@ -264,29 +276,29 @@ export class AttributeNotSelectedError extends Error {
|
|
|
264
276
|
|
|
265
277
|
/**
|
|
266
278
|
* Lightweight singular relationship state holder for frontend model instances.
|
|
267
|
-
* @template {FrontendModelBase} S
|
|
268
|
-
* @template {FrontendModelBase} T
|
|
279
|
+
* @template {FrontendModelBase | typeof FrontendModelBase} S
|
|
280
|
+
* @template {FrontendModelBase | typeof FrontendModelBase} T
|
|
269
281
|
* @template {Record<string, FrontendModelAttributeValue>} [TargetCreateAttributes=Record<string, FrontendModelAttributeValue>]
|
|
270
282
|
*/
|
|
271
283
|
export class FrontendModelSingularRelationship {
|
|
272
284
|
/**
|
|
273
285
|
* Runs constructor.
|
|
274
|
-
* @param {
|
|
286
|
+
* @param {FrontendModelBase} model - Parent model.
|
|
275
287
|
* @param {string} relationshipName - Relationship name.
|
|
276
|
-
* @param {FrontendModelClass<T
|
|
288
|
+
* @param {FrontendModelClass<FrontendModelRelationshipModel<T>, Record<string, FrontendModelAttributeValue>, TargetCreateAttributes> | null} targetModelClass - Target model class.
|
|
277
289
|
*/
|
|
278
290
|
constructor(model, relationshipName, targetModelClass) {
|
|
279
291
|
this.model = model
|
|
280
292
|
this.relationshipName = relationshipName
|
|
281
293
|
this.targetModelClass = targetModelClass
|
|
282
294
|
this._preloaded = false
|
|
283
|
-
/** @type {T | null} */
|
|
295
|
+
/** @type {FrontendModelRelationshipModel<T> | null} */
|
|
284
296
|
this._loadedValue = null
|
|
285
297
|
}
|
|
286
298
|
|
|
287
299
|
/**
|
|
288
300
|
* Runs set loaded.
|
|
289
|
-
* @param {T | null | undefined} loadedValue - Loaded relationship value.
|
|
301
|
+
* @param {FrontendModelRelationshipModel<T> | null | undefined} loadedValue - Loaded relationship value.
|
|
290
302
|
* @returns {void}
|
|
291
303
|
*/
|
|
292
304
|
setLoaded(loadedValue) {
|
|
@@ -304,7 +316,7 @@ export class FrontendModelSingularRelationship {
|
|
|
304
316
|
|
|
305
317
|
/**
|
|
306
318
|
* Runs loaded.
|
|
307
|
-
* @returns {T | null} - Loaded relationship value.
|
|
319
|
+
* @returns {FrontendModelRelationshipModel<T> | null} - Loaded relationship value.
|
|
308
320
|
*/
|
|
309
321
|
loaded() {
|
|
310
322
|
if (!this._preloaded) {
|
|
@@ -325,7 +337,7 @@ export class FrontendModelSingularRelationship {
|
|
|
325
337
|
}
|
|
326
338
|
|
|
327
339
|
// Narrows the runtime value to the target relationship's documented model type.
|
|
328
|
-
const loadedValue = /** @type {T | null} */ (sourceRelationship.loaded())
|
|
340
|
+
const loadedValue = /** @type {FrontendModelRelationshipModel<T> | null} */ (sourceRelationship.loaded())
|
|
329
341
|
|
|
330
342
|
this.setLoaded(loadedValue)
|
|
331
343
|
}
|
|
@@ -333,15 +345,15 @@ export class FrontendModelSingularRelationship {
|
|
|
333
345
|
/**
|
|
334
346
|
* Runs build.
|
|
335
347
|
* @param {TargetCreateAttributes} [attributes] - New model attributes.
|
|
336
|
-
* @returns {T} - Built model.
|
|
348
|
+
* @returns {FrontendModelRelationshipModel<T>} - Built model.
|
|
337
349
|
*/
|
|
338
350
|
build(attributes = /** @type {TargetCreateAttributes} */ ({})) {
|
|
339
351
|
if (!this.targetModelClass) {
|
|
340
352
|
throw new Error(`No target model class configured for ${this.model.constructor.name}#${this.relationshipName}`)
|
|
341
353
|
}
|
|
342
354
|
|
|
343
|
-
|
|
344
|
-
const model =
|
|
355
|
+
const ModelClass = /** @type {new (attributes?: TargetCreateAttributes) => FrontendModelRelationshipModel<T>} */ (this.targetModelClass)
|
|
356
|
+
const model = new ModelClass(attributes)
|
|
345
357
|
|
|
346
358
|
this.setLoaded(model)
|
|
347
359
|
|
|
@@ -350,7 +362,7 @@ export class FrontendModelSingularRelationship {
|
|
|
350
362
|
|
|
351
363
|
/**
|
|
352
364
|
* Force-reload the relationship.
|
|
353
|
-
* @returns {Promise<T | null>} - Loaded relationship model.
|
|
365
|
+
* @returns {Promise<FrontendModelRelationshipModel<T> | null>} - Loaded relationship model.
|
|
354
366
|
*/
|
|
355
367
|
async load() {
|
|
356
368
|
this._preloaded = false
|
|
@@ -367,7 +379,7 @@ export class FrontendModelSingularRelationship {
|
|
|
367
379
|
|
|
368
380
|
/**
|
|
369
381
|
* Returns the loaded relationship or loads it.
|
|
370
|
-
* @returns {Promise<T | null>} - Loaded relationship model.
|
|
382
|
+
* @returns {Promise<FrontendModelRelationshipModel<T> | null>} - Loaded relationship model.
|
|
371
383
|
*/
|
|
372
384
|
async orLoad() {
|
|
373
385
|
if (this.getPreloaded()) return this.loaded()
|
|
@@ -384,21 +396,21 @@ export class FrontendModelSingularRelationship {
|
|
|
384
396
|
|
|
385
397
|
/**
|
|
386
398
|
* Lightweight has-many relationship state holder for frontend model instances.
|
|
387
|
-
* @template {FrontendModelBase} S
|
|
388
|
-
* @template {FrontendModelBase} T
|
|
399
|
+
* @template {FrontendModelBase | typeof FrontendModelBase} S
|
|
400
|
+
* @template {FrontendModelBase | typeof FrontendModelBase} T
|
|
389
401
|
* @template {Record<string, FrontendModelAttributeValue>} [TargetCreateAttributes=Record<string, FrontendModelAttributeValue>]
|
|
390
402
|
*/
|
|
391
403
|
export class FrontendModelHasManyRelationship {
|
|
392
404
|
/**
|
|
393
405
|
* Narrows the runtime value to the documented type.
|
|
394
|
-
|
|
406
|
+
* @type {Array<FrontendModelRelationshipModel<T>>} */
|
|
395
407
|
_loadedValue
|
|
396
408
|
|
|
397
409
|
/**
|
|
398
410
|
* Runs constructor.
|
|
399
|
-
* @param {
|
|
411
|
+
* @param {FrontendModelBase} model - Parent model.
|
|
400
412
|
* @param {string} relationshipName - Relationship name.
|
|
401
|
-
* @param {FrontendModelClass<T
|
|
413
|
+
* @param {FrontendModelClass<FrontendModelRelationshipModel<T>, Record<string, FrontendModelAttributeValue>, TargetCreateAttributes> | null} targetModelClass - Target model class.
|
|
402
414
|
*/
|
|
403
415
|
constructor(model, relationshipName, targetModelClass) {
|
|
404
416
|
this.model = model
|
|
@@ -410,7 +422,7 @@ export class FrontendModelHasManyRelationship {
|
|
|
410
422
|
|
|
411
423
|
/**
|
|
412
424
|
* Runs set loaded.
|
|
413
|
-
* @param {Array<T
|
|
425
|
+
* @param {Array<FrontendModelRelationshipModel<T>>} loadedValue - Loaded relationship value.
|
|
414
426
|
* @returns {void}
|
|
415
427
|
*/
|
|
416
428
|
setLoaded(loadedValue) {
|
|
@@ -432,7 +444,7 @@ export class FrontendModelHasManyRelationship {
|
|
|
432
444
|
|
|
433
445
|
/**
|
|
434
446
|
* Runs loaded.
|
|
435
|
-
* @returns {Array<T
|
|
447
|
+
* @returns {Array<FrontendModelRelationshipModel<T>>} - Loaded relationship values.
|
|
436
448
|
*/
|
|
437
449
|
loaded() {
|
|
438
450
|
if (!this._preloaded) {
|
|
@@ -453,14 +465,14 @@ export class FrontendModelHasManyRelationship {
|
|
|
453
465
|
}
|
|
454
466
|
|
|
455
467
|
// Narrows the runtime value to the target relationship's documented model type.
|
|
456
|
-
const loadedValue = /** @type {Array<T
|
|
468
|
+
const loadedValue = /** @type {Array<FrontendModelRelationshipModel<T>>} */ (sourceRelationship.loaded())
|
|
457
469
|
|
|
458
470
|
this.setLoaded(loadedValue)
|
|
459
471
|
}
|
|
460
472
|
|
|
461
473
|
/**
|
|
462
474
|
* Runs add to loaded.
|
|
463
|
-
* @param {Array<T
|
|
475
|
+
* @param {Array<FrontendModelRelationshipModel<T>>} models - Models to append.
|
|
464
476
|
* @returns {void}
|
|
465
477
|
*/
|
|
466
478
|
addToLoaded(models) {
|
|
@@ -472,15 +484,15 @@ export class FrontendModelHasManyRelationship {
|
|
|
472
484
|
/**
|
|
473
485
|
* Runs build.
|
|
474
486
|
* @param {TargetCreateAttributes} [attributes] - New model attributes.
|
|
475
|
-
* @returns {T} - Built model.
|
|
487
|
+
* @returns {FrontendModelRelationshipModel<T>} - Built model.
|
|
476
488
|
*/
|
|
477
489
|
build(attributes = /** @type {TargetCreateAttributes} */ ({})) {
|
|
478
490
|
if (!this.targetModelClass) {
|
|
479
491
|
throw new Error(`No target model class configured for ${this.model.constructor.name}#${this.relationshipName}`)
|
|
480
492
|
}
|
|
481
493
|
|
|
482
|
-
|
|
483
|
-
const model =
|
|
494
|
+
const ModelClass = /** @type {new (attributes?: TargetCreateAttributes) => FrontendModelRelationshipModel<T>} */ (this.targetModelClass)
|
|
495
|
+
const model = new ModelClass(attributes)
|
|
484
496
|
|
|
485
497
|
this.addToLoaded([model])
|
|
486
498
|
|
|
@@ -493,7 +505,7 @@ export class FrontendModelHasManyRelationship {
|
|
|
493
505
|
* batched into one request via the cohort preloader. The scoped query path
|
|
494
506
|
* (`Model.where(...).preload([name]).toArray()` directly from user code)
|
|
495
507
|
* bypasses cohort batching by design.
|
|
496
|
-
* @returns {Promise<Array<T
|
|
508
|
+
* @returns {Promise<Array<FrontendModelRelationshipModel<T>>>} - Loaded relationship models.
|
|
497
509
|
*/
|
|
498
510
|
async load() {
|
|
499
511
|
// Reset so the cohort preloader (or single-record fallback) repopulates.
|
|
@@ -511,7 +523,7 @@ export class FrontendModelHasManyRelationship {
|
|
|
511
523
|
|
|
512
524
|
/**
|
|
513
525
|
* Runs to array.
|
|
514
|
-
* @returns {Promise<Array<T
|
|
526
|
+
* @returns {Promise<Array<FrontendModelRelationshipModel<T>>>} - Loaded relationship models.
|
|
515
527
|
*/
|
|
516
528
|
async toArray() {
|
|
517
529
|
if (this.getPreloaded() || this._loadedValue.length > 0) {
|
|
@@ -611,7 +623,7 @@ export class FrontendModelAttachmentDownload {
|
|
|
611
623
|
function frontendModelAttachmentCommandPayload(attachment, attachmentId) {
|
|
612
624
|
/**
|
|
613
625
|
* Payload.
|
|
614
|
-
|
|
626
|
+
* @type {Record<string, ?>} */
|
|
615
627
|
const payload = {
|
|
616
628
|
attachmentName: attachment.attachmentName,
|
|
617
629
|
id: attachment.model.primaryKeyValue()
|
|
@@ -639,7 +651,7 @@ function frontendAttachmentValueIsBytes(value) {
|
|
|
639
651
|
function frontendAttachmentValueSupportsArrayBuffer(value) {
|
|
640
652
|
return Boolean(value && typeof value === "object" && typeof /**
|
|
641
653
|
* Narrows the runtime value to the documented type.
|
|
642
|
-
|
|
654
|
+
* @type {?} */ (value).arrayBuffer === "function")
|
|
643
655
|
}
|
|
644
656
|
|
|
645
657
|
/**
|
|
@@ -652,10 +664,10 @@ function frontendAttachmentNormalizeBytes(value) {
|
|
|
652
664
|
if (value instanceof ArrayBuffer) return new Uint8Array(value)
|
|
653
665
|
if (typeof Buffer !== "undefined" && Buffer.isBuffer(/**
|
|
654
666
|
* Narrows the runtime value to the documented type.
|
|
655
|
-
|
|
667
|
+
* @type {?} */ (value))) {
|
|
656
668
|
return new Uint8Array(/**
|
|
657
669
|
* Narrows the runtime value to the documented type.
|
|
658
|
-
|
|
670
|
+
* @type {Buffer} */ (value))
|
|
659
671
|
}
|
|
660
672
|
|
|
661
673
|
throw new Error("Unsupported attachment bytes value")
|
|
@@ -788,21 +800,21 @@ async function normalizeFrontendAttachmentInput(input) {
|
|
|
788
800
|
contentBase64: frontendAttachmentBytesToBase64(bytes),
|
|
789
801
|
contentType: typeof /**
|
|
790
802
|
* Narrows the runtime value to the documented type.
|
|
791
|
-
|
|
803
|
+
* @type {?} */ (input).type === "string" && /**
|
|
792
804
|
* Narrows the runtime value to the documented type.
|
|
793
|
-
|
|
805
|
+
* @type {?} */ (input).type.length > 0
|
|
794
806
|
? /**
|
|
795
807
|
* Narrows the runtime value to the documented type.
|
|
796
|
-
|
|
808
|
+
* @type {?} */ (input).type
|
|
797
809
|
: null,
|
|
798
810
|
filename: typeof /**
|
|
799
811
|
* Narrows the runtime value to the documented type.
|
|
800
|
-
|
|
812
|
+
* @type {?} */ (input).name === "string" && /**
|
|
801
813
|
* Narrows the runtime value to the documented type.
|
|
802
|
-
|
|
814
|
+
* @type {?} */ (input).name.length > 0
|
|
803
815
|
? /**
|
|
804
816
|
* Narrows the runtime value to the documented type.
|
|
805
|
-
|
|
817
|
+
* @type {?} */ (input).name
|
|
806
818
|
: "attachment.bin"
|
|
807
819
|
}
|
|
808
820
|
}
|
|
@@ -810,7 +822,7 @@ async function normalizeFrontendAttachmentInput(input) {
|
|
|
810
822
|
if (frontendAttachmentValueIsBytes(input)) {
|
|
811
823
|
const bytes = frontendAttachmentNormalizeBytes(/**
|
|
812
824
|
* Narrows the runtime value to the documented type.
|
|
813
|
-
|
|
825
|
+
* @type {Uint8Array | Buffer | ArrayBuffer} */ (input))
|
|
814
826
|
|
|
815
827
|
return {
|
|
816
828
|
contentBase64: frontendAttachmentBytesToBase64(bytes),
|
|
@@ -1010,7 +1022,7 @@ function frontendModelTransportUrl() {
|
|
|
1010
1022
|
* @returns {Record<string, ?>} - Cloned attributes hash.
|
|
1011
1023
|
*/
|
|
1012
1024
|
function cloneFrontendModelAttributes(value) {
|
|
1013
|
-
return /**
|
|
1025
|
+
return /** @type {Record<string, ?>} */ (deserializeFrontendModelTransportValue(serializeFrontendModelTransportValue(value)))
|
|
1014
1026
|
}
|
|
1015
1027
|
|
|
1016
1028
|
/**
|
|
@@ -1055,10 +1067,10 @@ function mergeFrontendModelEventPreload(target, source) {
|
|
|
1055
1067
|
mergeFrontendModelEventPreload(
|
|
1056
1068
|
/**
|
|
1057
1069
|
* Narrows the runtime value to the documented type.
|
|
1058
|
-
|
|
1070
|
+
* @type {Record<string, import("./query.js").FrontendModelTransportValue>} */ (target[relationshipName]),
|
|
1059
1071
|
/**
|
|
1060
1072
|
* Narrows the runtime value to the documented type.
|
|
1061
|
-
|
|
1073
|
+
* @type {Record<string, import("./query.js").FrontendModelTransportValue>} */ (value)
|
|
1062
1074
|
)
|
|
1063
1075
|
}
|
|
1064
1076
|
}
|
|
@@ -1150,7 +1162,7 @@ function frontendModelMatchedEventFilterKeys(body) {
|
|
|
1150
1162
|
|
|
1151
1163
|
const keys = /**
|
|
1152
1164
|
* Narrows the runtime value to the documented type.
|
|
1153
|
-
|
|
1165
|
+
* @type {{matchedEventFilterKeys?: ?}} */ (body).matchedEventFilterKeys
|
|
1154
1166
|
|
|
1155
1167
|
if (!Array.isArray(keys)) return new Set()
|
|
1156
1168
|
|
|
@@ -1203,56 +1215,57 @@ class FrontendModelEventSubscription {
|
|
|
1203
1215
|
this.ModelClass = ModelClass
|
|
1204
1216
|
/**
|
|
1205
1217
|
* Narrows the runtime value to the documented type.
|
|
1206
|
-
|
|
1218
|
+
* @type {Set<FrontendModelModelEventCallbackEntry>} */
|
|
1207
1219
|
this.classCreateCallbacks = new Set()
|
|
1208
1220
|
/**
|
|
1209
1221
|
* Narrows the runtime value to the documented type.
|
|
1210
|
-
|
|
1222
|
+
* @type {Set<FrontendModelModelEventCallbackEntry>} */
|
|
1211
1223
|
this.classUpdateCallbacks = new Set()
|
|
1212
1224
|
/**
|
|
1213
1225
|
* Narrows the runtime value to the documented type.
|
|
1214
|
-
|
|
1226
|
+
* @type {Set<FrontendModelDestroyEventCallbackEntry>} */
|
|
1215
1227
|
this.classDestroyCallbacks = new Set()
|
|
1216
1228
|
/**
|
|
1217
1229
|
* Narrows the runtime value to the documented type.
|
|
1218
|
-
|
|
1230
|
+
* @type {Map<string, {instance: FrontendModelBase, updateCallbacks: Set<FrontendModelModelEventCallbackEntry>, destroyCallbacks: Set<FrontendModelDestroyEventCallbackEntry>}>} */
|
|
1219
1231
|
this.instanceListeners = new Map()
|
|
1220
1232
|
/**
|
|
1221
1233
|
* Narrows the runtime value to the documented type.
|
|
1222
|
-
|
|
1234
|
+
* @type {?} */
|
|
1223
1235
|
this.channelHandle = null
|
|
1224
1236
|
/**
|
|
1225
1237
|
* Narrows the runtime value to the documented type.
|
|
1226
|
-
|
|
1238
|
+
* @type {Promise<void> | null} */
|
|
1227
1239
|
this.readyPromise = null
|
|
1228
1240
|
/**
|
|
1229
1241
|
* Narrows the runtime value to the documented type.
|
|
1230
|
-
|
|
1242
|
+
* @type {string | null} */
|
|
1231
1243
|
this.subscriptionParamsKey = null
|
|
1232
1244
|
}
|
|
1233
1245
|
|
|
1234
1246
|
/**
|
|
1235
1247
|
* Runs subscription params.
|
|
1236
|
-
* @returns {{model: string, eventFilters?: import("./query.js").FrontendModelEventFilterPayloadEntry[], unfilteredEventDelivery?: boolean} & import("./query.js").FrontendModelProjectionPayload} - Current websocket subscription params.
|
|
1248
|
+
* @returns {{model: string, destroyEventDelivery?: boolean, eventFilters?: import("./query.js").FrontendModelEventFilterPayloadEntry[], unfilteredEventDelivery?: boolean} & import("./query.js").FrontendModelProjectionPayload} - Current websocket subscription params.
|
|
1237
1249
|
*/
|
|
1238
1250
|
subscriptionParams() {
|
|
1239
1251
|
/**
|
|
1240
1252
|
* Projection payload.
|
|
1241
|
-
|
|
1253
|
+
* @type {import("./query.js").FrontendModelProjectionPayload} */
|
|
1242
1254
|
const projectionPayload = {}
|
|
1243
1255
|
/**
|
|
1244
1256
|
* Event filters by key.
|
|
1245
|
-
|
|
1257
|
+
* @type {Record<string, import("./query.js").FrontendModelEventFilterPayloadEntry>} */
|
|
1246
1258
|
const eventFiltersByKey = {}
|
|
1247
1259
|
const projectionEntries = []
|
|
1248
|
-
let
|
|
1260
|
+
let hasDestroyEventDelivery = this.classDestroyCallbacks.size > 0
|
|
1261
|
+
let hasUnfilteredEventDelivery = false
|
|
1249
1262
|
|
|
1250
1263
|
for (const entry of this.classCreateCallbacks) projectionEntries.push(entry)
|
|
1251
1264
|
for (const entry of this.classUpdateCallbacks) projectionEntries.push(entry)
|
|
1252
1265
|
|
|
1253
1266
|
for (const listener of this.instanceListeners.values()) {
|
|
1254
1267
|
for (const entry of listener.updateCallbacks) projectionEntries.push(entry)
|
|
1255
|
-
if (listener.destroyCallbacks.size > 0)
|
|
1268
|
+
if (listener.destroyCallbacks.size > 0) hasDestroyEventDelivery = true
|
|
1256
1269
|
}
|
|
1257
1270
|
|
|
1258
1271
|
for (const entry of projectionEntries) {
|
|
@@ -1272,6 +1285,7 @@ class FrontendModelEventSubscription {
|
|
|
1272
1285
|
const eventFilterParams = eventFilters.length > 0
|
|
1273
1286
|
? {
|
|
1274
1287
|
eventFilters,
|
|
1288
|
+
...(hasDestroyEventDelivery ? {destroyEventDelivery: true} : {}),
|
|
1275
1289
|
...(hasUnfilteredEventDelivery ? {unfilteredEventDelivery: true} : {})
|
|
1276
1290
|
}
|
|
1277
1291
|
: {}
|
|
@@ -1293,7 +1307,7 @@ class FrontendModelEventSubscription {
|
|
|
1293
1307
|
|
|
1294
1308
|
/**
|
|
1295
1309
|
* Runs ensure subscribed.
|
|
1296
|
-
|
|
1310
|
+
* @returns {Promise<void>} */
|
|
1297
1311
|
async ensureSubscribed() {
|
|
1298
1312
|
const paramsJson = this.subscriptionParamsJson()
|
|
1299
1313
|
|
|
@@ -1318,7 +1332,7 @@ class FrontendModelEventSubscription {
|
|
|
1318
1332
|
|
|
1319
1333
|
const client = /**
|
|
1320
1334
|
* Narrows the runtime value to the documented type.
|
|
1321
|
-
|
|
1335
|
+
* @type {?} */ (frontendModelTransportConfig.websocketClient || resolveInternalWebsocketClient())
|
|
1322
1336
|
|
|
1323
1337
|
if (!client || typeof client.subscribeChannel !== "function") {
|
|
1324
1338
|
throw new Error("Frontend model event subscriptions require configureTransport({websocketUrl}) or configureTransport({websocketClient})")
|
|
@@ -1334,7 +1348,7 @@ class FrontendModelEventSubscription {
|
|
|
1334
1348
|
params,
|
|
1335
1349
|
onMessage: (/**
|
|
1336
1350
|
* Narrows the runtime value to the documented type.
|
|
1337
|
-
|
|
1351
|
+
* @type {?} */ body) => this._dispatchEvent(body),
|
|
1338
1352
|
onClose: () => {
|
|
1339
1353
|
this.channelHandle = null
|
|
1340
1354
|
this.readyPromise = null
|
|
@@ -1391,10 +1405,10 @@ class FrontendModelEventSubscription {
|
|
|
1391
1405
|
|
|
1392
1406
|
const deserializedRecord = /**
|
|
1393
1407
|
* Narrows the runtime value to the documented type.
|
|
1394
|
-
|
|
1408
|
+
* @type {Record<string, ?>} */ (deserializeFrontendModelTransportValue(body.record))
|
|
1395
1409
|
const freshModel = /**
|
|
1396
1410
|
* Narrows the runtime value to the documented type.
|
|
1397
|
-
|
|
1411
|
+
* @type {?} */ (this.ModelClass).instantiateFromResponse(deserializedRecord)
|
|
1398
1412
|
const listener = this.instanceListeners.get(id)
|
|
1399
1413
|
|
|
1400
1414
|
if (action === "update" && listener) {
|
|
@@ -1407,7 +1421,7 @@ class FrontendModelEventSubscription {
|
|
|
1407
1421
|
// through the same handle see fresh attributes.
|
|
1408
1422
|
const instanceAny = /**
|
|
1409
1423
|
* Narrows the runtime value to the documented type.
|
|
1410
|
-
|
|
1424
|
+
* @type {?} */ (listener.instance)
|
|
1411
1425
|
|
|
1412
1426
|
instanceAny.assignAttributes(freshModel.attributes())
|
|
1413
1427
|
instanceAny._persistedAttributes = cloneFrontendModelAttributes(listener.instance.attributes())
|
|
@@ -1429,7 +1443,7 @@ class FrontendModelEventSubscription {
|
|
|
1429
1443
|
|
|
1430
1444
|
/**
|
|
1431
1445
|
* Runs maybe teardown.
|
|
1432
|
-
|
|
1446
|
+
* @returns {void} */
|
|
1433
1447
|
maybeTeardown() {
|
|
1434
1448
|
const hasAnyListener = this.classCreateCallbacks.size > 0
|
|
1435
1449
|
|| this.classUpdateCallbacks.size > 0
|
|
@@ -1453,7 +1467,7 @@ class FrontendModelEventSubscription {
|
|
|
1453
1467
|
|
|
1454
1468
|
/**
|
|
1455
1469
|
* Frontend model event subscriptions.
|
|
1456
|
-
|
|
1470
|
+
* @type {WeakMap<FrontendModelClass, FrontendModelEventSubscription>} */
|
|
1457
1471
|
const frontendModelEventSubscriptions = new WeakMap()
|
|
1458
1472
|
|
|
1459
1473
|
/**
|
|
@@ -1565,7 +1579,7 @@ async function performSharedFrontendModelApiRequest(requestPayload) {
|
|
|
1565
1579
|
})
|
|
1566
1580
|
const responseJson = response.json()
|
|
1567
1581
|
|
|
1568
|
-
return /**
|
|
1582
|
+
return /** @type {Record<string, ?>} */ (deserializeFrontendModelTransportValue(responseJson))
|
|
1569
1583
|
}
|
|
1570
1584
|
|
|
1571
1585
|
const response = await fetch(url, {
|
|
@@ -1587,7 +1601,7 @@ async function performSharedFrontendModelApiRequest(requestPayload) {
|
|
|
1587
1601
|
|
|
1588
1602
|
const json = responseText.length > 0 ? JSON.parse(responseText) : {}
|
|
1589
1603
|
|
|
1590
|
-
return /**
|
|
1604
|
+
return /** @type {Record<string, ?>} */ (deserializeFrontendModelTransportValue(json))
|
|
1591
1605
|
}
|
|
1592
1606
|
|
|
1593
1607
|
/**
|
|
@@ -1606,7 +1620,7 @@ function throwFrontendModelHttpError({commandLabel, response, responseText}) {
|
|
|
1606
1620
|
if (responseContentType && responseContentType.includes("application/json") && responseText.length > 0) {
|
|
1607
1621
|
/**
|
|
1608
1622
|
* Defines errorBody.
|
|
1609
|
-
|
|
1623
|
+
* @type {Record<string, ?> | null} */
|
|
1610
1624
|
let errorBody
|
|
1611
1625
|
|
|
1612
1626
|
try {
|
|
@@ -1677,7 +1691,7 @@ async function flushPendingSharedFrontendModelRequests() {
|
|
|
1677
1691
|
|
|
1678
1692
|
request.resolve(/**
|
|
1679
1693
|
* Narrows the runtime value to the documented type.
|
|
1680
|
-
|
|
1694
|
+
* @type {Record<string, ?>} */ (responsePayload))
|
|
1681
1695
|
}
|
|
1682
1696
|
} catch (error) {
|
|
1683
1697
|
for (const request of batchedRequests) {
|
|
@@ -1689,7 +1703,7 @@ async function flushPendingSharedFrontendModelRequests() {
|
|
|
1689
1703
|
|
|
1690
1704
|
/**
|
|
1691
1705
|
* Runs schedule shared frontend model request flush.
|
|
1692
|
-
|
|
1706
|
+
* @returns {void} */
|
|
1693
1707
|
function scheduleSharedFrontendModelRequestFlush() {
|
|
1694
1708
|
if (sharedFrontendModelFlushScheduled) return
|
|
1695
1709
|
|
|
@@ -1783,7 +1797,7 @@ function assertDefinedFindByConditionValue(value, keyPath) {
|
|
|
1783
1797
|
|
|
1784
1798
|
const objectValue = /**
|
|
1785
1799
|
* Narrows the runtime value to the documented type.
|
|
1786
|
-
|
|
1800
|
+
* @type {Record<string, ?>} */ (value)
|
|
1787
1801
|
const prototype = Object.getPrototypeOf(objectValue)
|
|
1788
1802
|
|
|
1789
1803
|
if (prototype !== Object.prototype && prototype !== null) {
|
|
@@ -1798,7 +1812,7 @@ function assertDefinedFindByConditionValue(value, keyPath) {
|
|
|
1798
1812
|
|
|
1799
1813
|
const valueObject = /**
|
|
1800
1814
|
* Narrows the runtime value to the documented type.
|
|
1801
|
-
|
|
1815
|
+
* @type {Record<string, ?>} */ (value)
|
|
1802
1816
|
|
|
1803
1817
|
Object.keys(valueObject).forEach((nestedKey) => {
|
|
1804
1818
|
assertDefinedFindByConditionValue(valueObject[nestedKey], `${keyPath}.${nestedKey}`)
|
|
@@ -1815,7 +1829,7 @@ function assertDefinedFindByConditionValue(value, keyPath) {
|
|
|
1815
1829
|
export default class FrontendModelBase {
|
|
1816
1830
|
/**
|
|
1817
1831
|
* Narrows the runtime value to the documented type.
|
|
1818
|
-
|
|
1832
|
+
* @type {string | undefined} */
|
|
1819
1833
|
static modelName
|
|
1820
1834
|
|
|
1821
1835
|
/**
|
|
@@ -1839,15 +1853,15 @@ export default class FrontendModelBase {
|
|
|
1839
1853
|
|
|
1840
1854
|
/**
|
|
1841
1855
|
* Narrows the runtime value to the documented type.
|
|
1842
|
-
|
|
1856
|
+
* @type {Record<string, FrontendModelAttributeValue>} */
|
|
1843
1857
|
_attributes
|
|
1844
1858
|
/**
|
|
1845
1859
|
* Narrows the runtime value to the documented type.
|
|
1846
|
-
|
|
1860
|
+
* @type {Record<string, FrontendModelHasManyRelationship<FrontendModelBase, FrontendModelBase, Record<string, FrontendModelAttributeValue>> | FrontendModelSingularRelationship<FrontendModelBase, FrontendModelBase, Record<string, FrontendModelAttributeValue>>>} */
|
|
1847
1861
|
_relationships
|
|
1848
1862
|
/**
|
|
1849
1863
|
* Narrows the runtime value to the documented type.
|
|
1850
|
-
|
|
1864
|
+
* @type {Record<string, FrontendModelAttachmentHandle>} */
|
|
1851
1865
|
_attachments
|
|
1852
1866
|
/**
|
|
1853
1867
|
* Rails-style nested attribute payloads queued for the next save.
|
|
@@ -1856,19 +1870,19 @@ export default class FrontendModelBase {
|
|
|
1856
1870
|
_pendingNestedAttributes
|
|
1857
1871
|
/**
|
|
1858
1872
|
* Narrows the runtime value to the documented type.
|
|
1859
|
-
|
|
1873
|
+
* @type {Set<string> | null} */
|
|
1860
1874
|
_selectedAttributes
|
|
1861
1875
|
/**
|
|
1862
1876
|
* Narrows the runtime value to the documented type.
|
|
1863
|
-
|
|
1877
|
+
* @type {boolean} */
|
|
1864
1878
|
_isNewRecord
|
|
1865
1879
|
/**
|
|
1866
1880
|
* Narrows the runtime value to the documented type.
|
|
1867
|
-
|
|
1881
|
+
* @type {boolean} */
|
|
1868
1882
|
_markedForDestruction
|
|
1869
1883
|
/**
|
|
1870
1884
|
* Narrows the runtime value to the documented type.
|
|
1871
|
-
|
|
1885
|
+
* @type {Record<string, FrontendModelAttributeValue>} */
|
|
1872
1886
|
_persistedAttributes
|
|
1873
1887
|
/**
|
|
1874
1888
|
* Narrows the runtime value to the documented type.
|
|
@@ -1906,7 +1920,7 @@ export default class FrontendModelBase {
|
|
|
1906
1920
|
const attachments = this.attachmentDefinitions()
|
|
1907
1921
|
const prototype = /**
|
|
1908
1922
|
* Narrows the runtime value to the documented type.
|
|
1909
|
-
|
|
1923
|
+
* @type {Record<string, ?>} */ (this.prototype)
|
|
1910
1924
|
|
|
1911
1925
|
for (const attachmentName of Object.keys(attachments)) {
|
|
1912
1926
|
if (!(attachmentName in prototype)) {
|
|
@@ -2097,7 +2111,7 @@ export default class FrontendModelBase {
|
|
|
2097
2111
|
changes() {
|
|
2098
2112
|
/**
|
|
2099
2113
|
* Changed attributes.
|
|
2100
|
-
|
|
2114
|
+
* @type {Record<string, Array<?>>} */
|
|
2101
2115
|
const changedAttributes = {}
|
|
2102
2116
|
const attributeNames = new Set([
|
|
2103
2117
|
...Object.keys(this._persistedAttributes),
|
|
@@ -2247,7 +2261,7 @@ export default class FrontendModelBase {
|
|
|
2247
2261
|
|
|
2248
2262
|
/**
|
|
2249
2263
|
* Batch.
|
|
2250
|
-
|
|
2264
|
+
* @type {Array<FrontendModelBase>} */
|
|
2251
2265
|
const batch = []
|
|
2252
2266
|
|
|
2253
2267
|
// Exact same class, persisted, no existing in-memory relationship state.
|
|
@@ -2276,7 +2290,7 @@ export default class FrontendModelBase {
|
|
|
2276
2290
|
|
|
2277
2291
|
/**
|
|
2278
2292
|
* Reloaded by id.
|
|
2279
|
-
|
|
2293
|
+
* @type {Map<string, FrontendModelBase>} */
|
|
2280
2294
|
const reloadedById = new Map()
|
|
2281
2295
|
|
|
2282
2296
|
for (const reloaded of reloadedBatch) {
|
|
@@ -2412,9 +2426,9 @@ export default class FrontendModelBase {
|
|
|
2412
2426
|
readCount(attributeName) {
|
|
2413
2427
|
return readPayloadAssociationCount(/**
|
|
2414
2428
|
* Narrows the runtime value to the documented type.
|
|
2415
|
-
|
|
2429
|
+
* @type {import("../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
|
|
2416
2430
|
* Narrows the runtime value to the documented type.
|
|
2417
|
-
|
|
2431
|
+
* @type {?} */ (this)), attributeName)
|
|
2418
2432
|
}
|
|
2419
2433
|
|
|
2420
2434
|
/**
|
|
@@ -2427,9 +2441,9 @@ export default class FrontendModelBase {
|
|
|
2427
2441
|
_setAssociationCount(attributeName, value) {
|
|
2428
2442
|
setPayloadAssociationCount(/**
|
|
2429
2443
|
* Narrows the runtime value to the documented type.
|
|
2430
|
-
|
|
2444
|
+
* @type {import("../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
|
|
2431
2445
|
* Narrows the runtime value to the documented type.
|
|
2432
|
-
|
|
2446
|
+
* @type {?} */ (this)), attributeName, value)
|
|
2433
2447
|
}
|
|
2434
2448
|
|
|
2435
2449
|
/**
|
|
@@ -2446,9 +2460,9 @@ export default class FrontendModelBase {
|
|
|
2446
2460
|
can(action) {
|
|
2447
2461
|
return readPayloadComputedAbility(/**
|
|
2448
2462
|
* Narrows the runtime value to the documented type.
|
|
2449
|
-
|
|
2463
|
+
* @type {import("../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
|
|
2450
2464
|
* Narrows the runtime value to the documented type.
|
|
2451
|
-
|
|
2465
|
+
* @type {?} */ (this)), action)
|
|
2452
2466
|
}
|
|
2453
2467
|
|
|
2454
2468
|
/**
|
|
@@ -2462,9 +2476,9 @@ export default class FrontendModelBase {
|
|
|
2462
2476
|
_setComputedAbility(action, value) {
|
|
2463
2477
|
setPayloadComputedAbility(/**
|
|
2464
2478
|
* Narrows the runtime value to the documented type.
|
|
2465
|
-
|
|
2479
|
+
* @type {import("../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
|
|
2466
2480
|
* Narrows the runtime value to the documented type.
|
|
2467
|
-
|
|
2481
|
+
* @type {?} */ (this)), action, value)
|
|
2468
2482
|
}
|
|
2469
2483
|
|
|
2470
2484
|
/**
|
|
@@ -2479,9 +2493,9 @@ export default class FrontendModelBase {
|
|
|
2479
2493
|
queryData(name) {
|
|
2480
2494
|
return readPayloadQueryData(/**
|
|
2481
2495
|
* Narrows the runtime value to the documented type.
|
|
2482
|
-
|
|
2496
|
+
* @type {import("../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
|
|
2483
2497
|
* Narrows the runtime value to the documented type.
|
|
2484
|
-
|
|
2498
|
+
* @type {?} */ (this)), name)
|
|
2485
2499
|
}
|
|
2486
2500
|
|
|
2487
2501
|
/**
|
|
@@ -2494,9 +2508,9 @@ export default class FrontendModelBase {
|
|
|
2494
2508
|
_setQueryData(name, value) {
|
|
2495
2509
|
setPayloadQueryData(/**
|
|
2496
2510
|
* Narrows the runtime value to the documented type.
|
|
2497
|
-
|
|
2511
|
+
* @type {import("../record-payload-values.js").RecordPayloadValuesTarget} */ (/**
|
|
2498
2512
|
* Narrows the runtime value to the documented type.
|
|
2499
|
-
|
|
2513
|
+
* @type {?} */ (this)), name, value)
|
|
2500
2514
|
}
|
|
2501
2515
|
|
|
2502
2516
|
/**
|
|
@@ -2559,7 +2573,7 @@ export default class FrontendModelBase {
|
|
|
2559
2573
|
for (const relationshipName of Object.keys(this._relationships)) {
|
|
2560
2574
|
const definition = /**
|
|
2561
2575
|
* Narrows the runtime value to the documented type.
|
|
2562
|
-
|
|
2576
|
+
* @type {?} */ (definitions[relationshipName])
|
|
2563
2577
|
|
|
2564
2578
|
if (!definition || definition.type !== "belongsTo") continue
|
|
2565
2579
|
|
|
@@ -2622,12 +2636,12 @@ export default class FrontendModelBase {
|
|
|
2622
2636
|
return {arg1: payload}
|
|
2623
2637
|
}
|
|
2624
2638
|
|
|
2625
|
-
return /**
|
|
2639
|
+
return /** @type {Record<string, ?>} */ (payload)
|
|
2626
2640
|
}
|
|
2627
2641
|
|
|
2628
2642
|
/**
|
|
2629
2643
|
* Payload.
|
|
2630
|
-
|
|
2644
|
+
* @type {Record<string, number | string | Array<?>>} */
|
|
2631
2645
|
const payload = {}
|
|
2632
2646
|
|
|
2633
2647
|
for (let index = 0; index < args.length; index += 1) {
|
|
@@ -2773,7 +2787,7 @@ export default class FrontendModelBase {
|
|
|
2773
2787
|
static setWebsocketMetadata(key, value) {
|
|
2774
2788
|
const client = /**
|
|
2775
2789
|
* Narrows the runtime value to the documented type.
|
|
2776
|
-
|
|
2790
|
+
* @type {?} */ (frontendModelTransportConfig.websocketClient || resolveInternalWebsocketClient())
|
|
2777
2791
|
|
|
2778
2792
|
if (!client || typeof client.setMetadata !== "function") return
|
|
2779
2793
|
|
|
@@ -2793,12 +2807,12 @@ export default class FrontendModelBase {
|
|
|
2793
2807
|
static openManagedConnection(connectionType, options) {
|
|
2794
2808
|
/**
|
|
2795
2809
|
* Connection.
|
|
2796
|
-
|
|
2810
|
+
* @type {?} */
|
|
2797
2811
|
let connection = null
|
|
2798
2812
|
let closed = false
|
|
2799
2813
|
/**
|
|
2800
2814
|
* Retry timer.
|
|
2801
|
-
|
|
2815
|
+
* @type {ReturnType<typeof setTimeout> | null} */
|
|
2802
2816
|
let retryTimer = null
|
|
2803
2817
|
let lastParamsJson = ""
|
|
2804
2818
|
|
|
@@ -2837,7 +2851,7 @@ export default class FrontendModelBase {
|
|
|
2837
2851
|
// which only reflects the internal client.
|
|
2838
2852
|
const client = /**
|
|
2839
2853
|
* Narrows the runtime value to the documented type.
|
|
2840
|
-
|
|
2854
|
+
* @type {?} */ (frontendModelTransportConfig.websocketClient || resolveInternalWebsocketClient())
|
|
2841
2855
|
|
|
2842
2856
|
if (!client || !client.isOpen()) {
|
|
2843
2857
|
if (retryTimer === null) {
|
|
@@ -2887,7 +2901,7 @@ export default class FrontendModelBase {
|
|
|
2887
2901
|
static openWebsocketConnection(connectionType, options) {
|
|
2888
2902
|
const client = /**
|
|
2889
2903
|
* Narrows the runtime value to the documented type.
|
|
2890
|
-
|
|
2904
|
+
* @type {?} */ (frontendModelTransportConfig.websocketClient || resolveInternalWebsocketClient())
|
|
2891
2905
|
|
|
2892
2906
|
if (!client || typeof client.openConnection !== "function") {
|
|
2893
2907
|
throw new Error("openWebsocketConnection requires configureTransport({websocketUrl})")
|
|
@@ -2906,7 +2920,7 @@ export default class FrontendModelBase {
|
|
|
2906
2920
|
static subscribeWebsocketChannel(channelType, options) {
|
|
2907
2921
|
const client = /**
|
|
2908
2922
|
* Narrows the runtime value to the documented type.
|
|
2909
|
-
|
|
2923
|
+
* @type {?} */ (frontendModelTransportConfig.websocketClient || resolveInternalWebsocketClient())
|
|
2910
2924
|
|
|
2911
2925
|
if (!client || typeof client.subscribeChannel !== "function") {
|
|
2912
2926
|
throw new Error("subscribeWebsocketChannel requires configureTransport({websocketUrl})")
|
|
@@ -2923,7 +2937,7 @@ export default class FrontendModelBase {
|
|
|
2923
2937
|
static installWebsocketTestHooks() {
|
|
2924
2938
|
if (typeof globalThis === "undefined") return
|
|
2925
2939
|
|
|
2926
|
-
/**
|
|
2940
|
+
/** @type {?} */ (globalThis).__velocious_websocket_hooks = {
|
|
2927
2941
|
connect: () => this.connectWebsocket(),
|
|
2928
2942
|
disconnect: () => this.disconnectWebsocket(),
|
|
2929
2943
|
drop: () => this.dropWebsocket(),
|
|
@@ -2959,7 +2973,7 @@ export default class FrontendModelBase {
|
|
|
2959
2973
|
|
|
2960
2974
|
/**
|
|
2961
2975
|
* Defines modelData.
|
|
2962
|
-
|
|
2976
|
+
* @type {Record<string, FrontendModelAttributeValue>} */
|
|
2963
2977
|
let modelData
|
|
2964
2978
|
|
|
2965
2979
|
if (responseObject.model && typeof responseObject.model === "object") {
|
|
@@ -2979,7 +2993,7 @@ export default class FrontendModelBase {
|
|
|
2979
2993
|
const associationCounts = isPlainObject(attributes[ASSOCIATION_COUNTS_KEY])
|
|
2980
2994
|
? /**
|
|
2981
2995
|
* Narrows the runtime value to the documented type.
|
|
2982
|
-
|
|
2996
|
+
* @type {Record<string, number>} */ (attributes[ASSOCIATION_COUNTS_KEY])
|
|
2983
2997
|
: {}
|
|
2984
2998
|
const queryData = isPlainObject(attributes[QUERY_DATA_KEY])
|
|
2985
2999
|
? /** @type {Record<string, FrontendModelAttributeValue>} */ (attributes[QUERY_DATA_KEY])
|
|
@@ -2987,12 +3001,12 @@ export default class FrontendModelBase {
|
|
|
2987
3001
|
const abilities = isPlainObject(attributes[ABILITIES_KEY])
|
|
2988
3002
|
? /**
|
|
2989
3003
|
* Narrows the runtime value to the documented type.
|
|
2990
|
-
|
|
3004
|
+
* @type {Record<string, boolean>} */ (attributes[ABILITIES_KEY])
|
|
2991
3005
|
: {}
|
|
2992
3006
|
const selectedAttributesFromPayload = Array.isArray(attributes[SELECTED_ATTRIBUTES_KEY])
|
|
2993
3007
|
? new Set(/**
|
|
2994
3008
|
* Narrows the runtime value to the documented type.
|
|
2995
|
-
|
|
3009
|
+
* @type {string[]} */ (attributes[SELECTED_ATTRIBUTES_KEY]).filter((attributeName) => typeof attributeName === "string"))
|
|
2996
3010
|
: null
|
|
2997
3011
|
|
|
2998
3012
|
delete attributes[PRELOADED_RELATIONSHIPS_KEY]
|
|
@@ -3087,7 +3101,7 @@ export default class FrontendModelBase {
|
|
|
3087
3101
|
// model instance into a new constructor call and produce a broken model
|
|
3088
3102
|
// with internal state keys promoted to attributes.
|
|
3089
3103
|
if (response instanceof this) {
|
|
3090
|
-
return /**
|
|
3104
|
+
return /** @type {InstanceType<T>} */ (response)
|
|
3091
3105
|
}
|
|
3092
3106
|
|
|
3093
3107
|
const modelData = this.modelDataFromResponse(response)
|
|
@@ -3097,9 +3111,9 @@ export default class FrontendModelBase {
|
|
|
3097
3111
|
const queryData = modelData.queryData
|
|
3098
3112
|
const abilities = modelData.abilities
|
|
3099
3113
|
const selectedAttributes = modelData.selectedAttributes
|
|
3100
|
-
const
|
|
3101
|
-
|
|
3102
|
-
|
|
3114
|
+
const receiver = /** @type {unknown} */ (this)
|
|
3115
|
+
const ModelClass = /** @type {new (attributes?: Record<string, FrontendModelAttributeValue>) => InstanceType<T>} */ (receiver)
|
|
3116
|
+
const model = new ModelClass(attributes)
|
|
3103
3117
|
model._selectedAttributes = selectedAttributes ? new Set(selectedAttributes) : null
|
|
3104
3118
|
|
|
3105
3119
|
this.applyPreloadedRelationships(model, preloadedRelationships)
|
|
@@ -3339,7 +3353,7 @@ export default class FrontendModelBase {
|
|
|
3339
3353
|
async onUpdate(callback, options = {}) {
|
|
3340
3354
|
const self = /**
|
|
3341
3355
|
* Narrows the runtime value to the documented type.
|
|
3342
|
-
|
|
3356
|
+
* @type {?} */ (this)
|
|
3343
3357
|
const ModelClass = frontendModelClassFor(this)
|
|
3344
3358
|
const sub = ensureFrontendModelEventSubscription(ModelClass)
|
|
3345
3359
|
const id = String(self.id())
|
|
@@ -3371,7 +3385,7 @@ export default class FrontendModelBase {
|
|
|
3371
3385
|
async onDestroy(callback, options = {}) {
|
|
3372
3386
|
const self = /**
|
|
3373
3387
|
* Narrows the runtime value to the documented type.
|
|
3374
|
-
|
|
3388
|
+
* @type {?} */ (this)
|
|
3375
3389
|
const ModelClass = frontendModelClassFor(this)
|
|
3376
3390
|
|
|
3377
3391
|
assertNoDestroyEventFilter(ModelClass, options)
|
|
@@ -3484,7 +3498,7 @@ export default class FrontendModelBase {
|
|
|
3484
3498
|
* @returns {FrontendModelQuery<T>} - Query builder.
|
|
3485
3499
|
*/
|
|
3486
3500
|
static query() {
|
|
3487
|
-
return /**
|
|
3501
|
+
return /** @type {FrontendModelQuery<T>} */ (new FrontendModelQuery({modelClass: this}))
|
|
3488
3502
|
}
|
|
3489
3503
|
|
|
3490
3504
|
/**
|
|
@@ -3495,7 +3509,7 @@ export default class FrontendModelBase {
|
|
|
3495
3509
|
* @returns {FrontendModelQuery<T>} - Query with preload.
|
|
3496
3510
|
*/
|
|
3497
3511
|
static preload(preload) {
|
|
3498
|
-
return /**
|
|
3512
|
+
return /** @type {FrontendModelQuery<T>} */ (this.query().preload(preload))
|
|
3499
3513
|
}
|
|
3500
3514
|
|
|
3501
3515
|
/**
|
|
@@ -3506,7 +3520,7 @@ export default class FrontendModelBase {
|
|
|
3506
3520
|
* @returns {FrontendModelQuery<T>} - Query with selected attributes.
|
|
3507
3521
|
*/
|
|
3508
3522
|
static select(select) {
|
|
3509
|
-
return /**
|
|
3523
|
+
return /** @type {FrontendModelQuery<T>} */ (this.query().select(select))
|
|
3510
3524
|
}
|
|
3511
3525
|
|
|
3512
3526
|
/**
|
|
@@ -3517,7 +3531,7 @@ export default class FrontendModelBase {
|
|
|
3517
3531
|
* @returns {FrontendModelQuery<T>} - Query with extra selected attributes.
|
|
3518
3532
|
*/
|
|
3519
3533
|
static selectsExtra(select) {
|
|
3520
|
-
return /**
|
|
3534
|
+
return /** @type {FrontendModelQuery<T>} */ (this.query().selectsExtra(select))
|
|
3521
3535
|
}
|
|
3522
3536
|
|
|
3523
3537
|
/**
|
|
@@ -3565,16 +3579,15 @@ export default class FrontendModelBase {
|
|
|
3565
3579
|
|
|
3566
3580
|
/**
|
|
3567
3581
|
* Runs create.
|
|
3568
|
-
* @template {
|
|
3569
|
-
* @
|
|
3570
|
-
* @
|
|
3571
|
-
* @
|
|
3572
|
-
* @param {ModelCreateAttributes} [attributes] - Initial attributes.
|
|
3573
|
-
* @returns {Promise<Model>} - Persisted model.
|
|
3582
|
+
* @template {FrontendModelClass} ModelClass
|
|
3583
|
+
* @this {ModelClass}
|
|
3584
|
+
* @param {FrontendModelCreateAttributesFor<InstanceType<ModelClass>>} [attributes] - Initial attributes.
|
|
3585
|
+
* @returns {Promise<InstanceType<ModelClass>>} - Persisted model.
|
|
3574
3586
|
*/
|
|
3575
3587
|
static async create(attributes) {
|
|
3576
|
-
|
|
3577
|
-
const
|
|
3588
|
+
const receiver = /** @type {unknown} */ (this)
|
|
3589
|
+
const ModelClass = /** @type {new (attributes?: FrontendModelCreateAttributesFor<InstanceType<ModelClass>>) => InstanceType<ModelClass>} */ (receiver)
|
|
3590
|
+
const model = new ModelClass(attributes)
|
|
3578
3591
|
|
|
3579
3592
|
await model.save()
|
|
3580
3593
|
|
|
@@ -3662,10 +3675,10 @@ export default class FrontendModelBase {
|
|
|
3662
3675
|
|
|
3663
3676
|
const actualObject = /**
|
|
3664
3677
|
* Narrows the runtime value to the documented type.
|
|
3665
|
-
|
|
3678
|
+
* @type {Record<string, ?>} */ (actualValue)
|
|
3666
3679
|
const expectedObject = /**
|
|
3667
3680
|
* Narrows the runtime value to the documented type.
|
|
3668
|
-
|
|
3681
|
+
* @type {Record<string, ?>} */ (expectedValue)
|
|
3669
3682
|
const actualKeys = Object.keys(actualObject)
|
|
3670
3683
|
const expectedKeys = Object.keys(expectedObject)
|
|
3671
3684
|
|
|
@@ -3797,7 +3810,7 @@ export default class FrontendModelBase {
|
|
|
3797
3810
|
const commandType = isNew ? "create" : "update"
|
|
3798
3811
|
/**
|
|
3799
3812
|
* Payload.
|
|
3800
|
-
|
|
3813
|
+
* @type {Record<string, ?>} */
|
|
3801
3814
|
const payload = {
|
|
3802
3815
|
attributes: this._changedAttributesForSave()
|
|
3803
3816
|
}
|
|
@@ -3842,7 +3855,7 @@ export default class FrontendModelBase {
|
|
|
3842
3855
|
_changedAttributesForSave() {
|
|
3843
3856
|
/**
|
|
3844
3857
|
* Changed attributes.
|
|
3845
|
-
|
|
3858
|
+
* @type {Record<string, FrontendModelAttributeValue>} */
|
|
3846
3859
|
const changedAttributes = {}
|
|
3847
3860
|
|
|
3848
3861
|
for (const [attributeName, [previousValue, currentValue]] of Object.entries(this.changes())) {
|
|
@@ -3925,7 +3938,7 @@ export default class FrontendModelBase {
|
|
|
3925
3938
|
|
|
3926
3939
|
/**
|
|
3927
3940
|
* Payload.
|
|
3928
|
-
|
|
3941
|
+
* @type {Record<string, Array<Record<string, ?>>>} */
|
|
3929
3942
|
const payload = {}
|
|
3930
3943
|
|
|
3931
3944
|
for (const relationshipName of Object.keys(nestedAttributesConfig)) {
|
|
@@ -3987,7 +4000,7 @@ export default class FrontendModelBase {
|
|
|
3987
4000
|
if (this.isNewRecord()) {
|
|
3988
4001
|
/**
|
|
3989
4002
|
* Entry.
|
|
3990
|
-
|
|
4003
|
+
* @type {Record<string, ?>} */
|
|
3991
4004
|
const entry = {}
|
|
3992
4005
|
const attributes = this._changedAttributesForSave()
|
|
3993
4006
|
|
|
@@ -4002,7 +4015,7 @@ export default class FrontendModelBase {
|
|
|
4002
4015
|
|
|
4003
4016
|
/**
|
|
4004
4017
|
* Entry.
|
|
4005
|
-
|
|
4018
|
+
* @type {Record<string, ?>} */
|
|
4006
4019
|
const entry = {id: this.primaryKeyValue()}
|
|
4007
4020
|
|
|
4008
4021
|
if (this.isChanged()) entry.attributes = this._changedAttributesForSave()
|
|
@@ -4150,7 +4163,7 @@ export default class FrontendModelBase {
|
|
|
4150
4163
|
|
|
4151
4164
|
/**
|
|
4152
4165
|
* Relevant preloads.
|
|
4153
|
-
|
|
4166
|
+
* @type {Record<string, ?>} */
|
|
4154
4167
|
const relevantPreloads = {}
|
|
4155
4168
|
|
|
4156
4169
|
for (const relationshipName of Object.keys(nestedAttributesConfig)) {
|
|
@@ -4175,7 +4188,7 @@ export default class FrontendModelBase {
|
|
|
4175
4188
|
const commandName = this.commandName(commandType)
|
|
4176
4189
|
const serializedPayload = /**
|
|
4177
4190
|
* Narrows the runtime value to the documented type.
|
|
4178
|
-
|
|
4191
|
+
* @type {Record<string, ?>} */ (serializeFrontendModelTransportValue(payload))
|
|
4179
4192
|
const resourcePath = this.resourcePath()
|
|
4180
4193
|
const containsAttachmentUpload = frontendModelPayloadContainsAttachmentUpload(serializedPayload)
|
|
4181
4194
|
const useSharedTransport = !containsAttachmentUpload
|
|
@@ -4199,7 +4212,7 @@ export default class FrontendModelBase {
|
|
|
4199
4212
|
|
|
4200
4213
|
const decodedBatchResponse = /**
|
|
4201
4214
|
* Narrows the runtime value to the documented type.
|
|
4202
|
-
|
|
4215
|
+
* @type {Record<string, ?>} */ (batchResponse)
|
|
4203
4216
|
|
|
4204
4217
|
this.throwOnErrorFrontendModelResponse({
|
|
4205
4218
|
commandType,
|
|
@@ -4230,7 +4243,7 @@ export default class FrontendModelBase {
|
|
|
4230
4243
|
const directJson = directResponseText.length > 0 ? JSON.parse(directResponseText) : {}
|
|
4231
4244
|
const decodedDirectResponse = /**
|
|
4232
4245
|
* Narrows the runtime value to the documented type.
|
|
4233
|
-
|
|
4246
|
+
* @type {Record<string, ?>} */ (deserializeFrontendModelTransportValue(directJson))
|
|
4234
4247
|
|
|
4235
4248
|
this.throwOnErrorFrontendModelResponse({
|
|
4236
4249
|
commandType,
|
|
@@ -4255,7 +4268,7 @@ export default class FrontendModelBase {
|
|
|
4255
4268
|
static async executeCustomCommand({commandName, commandType, memberId = null, payload, resourcePath}) {
|
|
4256
4269
|
const serializedPayload = /**
|
|
4257
4270
|
* Narrows the runtime value to the documented type.
|
|
4258
|
-
|
|
4271
|
+
* @type {Record<string, ?>} */ (serializeFrontendModelTransportValue(payload))
|
|
4259
4272
|
const customPath = frontendModelCustomCommandPath({
|
|
4260
4273
|
commandName,
|
|
4261
4274
|
memberId,
|
|
@@ -4279,7 +4292,7 @@ export default class FrontendModelBase {
|
|
|
4279
4292
|
|
|
4280
4293
|
const decodedBatchResponse = /**
|
|
4281
4294
|
* Narrows the runtime value to the documented type.
|
|
4282
|
-
|
|
4295
|
+
* @type {Record<string, ?>} */ (batchResponse)
|
|
4283
4296
|
|
|
4284
4297
|
this.throwOnErrorFrontendModelResponse({
|
|
4285
4298
|
commandType,
|
|
@@ -4325,7 +4338,7 @@ export default class FrontendModelBase {
|
|
|
4325
4338
|
|
|
4326
4339
|
const error = /**
|
|
4327
4340
|
* Narrows the runtime value to the documented type.
|
|
4328
|
-
|
|
4341
|
+
* @type {Error & {velocious?: Record<string, ?>, errorType?: string, validationErrors?: Record<string, ?>, debugErrorClass?: string, debugBacktrace?: string[]}} */ (new Error(errorMessage))
|
|
4329
4342
|
if (response.velocious && typeof response.velocious === "object") {
|
|
4330
4343
|
error.velocious = response.velocious
|
|
4331
4344
|
}
|
|
@@ -4356,7 +4369,7 @@ export default class FrontendModelBase {
|
|
|
4356
4369
|
static configuredFrontendModelAttributeNames() {
|
|
4357
4370
|
const resourceConfig = /**
|
|
4358
4371
|
* Narrows the runtime value to the documented type.
|
|
4359
|
-
|
|
4372
|
+
* @type {Record<string, ?>} */ (this.resourceConfig())
|
|
4360
4373
|
const attributes = resourceConfig.attributes
|
|
4361
4374
|
|
|
4362
4375
|
if (Array.isArray(attributes)) {
|