velocious 1.0.448 → 1.0.450
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 +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.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 +127 -128
- 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/base-models.js +1 -16
- package/build/environment-handlers/node/cli/commands/generate/frontend-models.js +179 -89
- package/build/environment-handlers/node.js +6 -6
- package/build/frontend-model-controller.js +90 -82
- package/build/frontend-model-resource/base-resource.js +343 -167
- package/build/frontend-models/base.js +362 -205
- 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 +8 -7
- 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-record.d.ts +2 -1
- package/build/src/background-jobs/job-record.d.ts.map +1 -1
- 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.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.d.ts +2 -2
- package/build/src/database/query/preloader/belongs-to.d.ts.map +1 -1
- package/build/src/database/query/preloader/belongs-to.js +23 -23
- package/build/src/database/query/preloader/has-many.d.ts +1 -1
- package/build/src/database/query/preloader/has-many.d.ts.map +1 -1
- package/build/src/database/query/preloader/has-many.js +21 -21
- package/build/src/database/query/preloader/has-one.d.ts +2 -2
- package/build/src/database/query/preloader/has-one.d.ts.map +1 -1
- 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.d.ts +1 -1
- package/build/src/database/query/preloader.d.ts.map +1 -1
- 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 +2 -2
- 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 +35 -32
- package/build/src/database/record/index.d.ts.map +1 -1
- package/build/src/database/record/index.js +147 -148
- 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/base-models.d.ts.map +1 -1
- package/build/src/environment-handlers/node/cli/commands/generate/base-models.js +2 -15
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +105 -33
- 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 +172 -87
- 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 +95 -89
- package/build/src/frontend-model-resource/base-resource.d.ts +239 -91
- package/build/src/frontend-model-resource/base-resource.d.ts.map +1 -1
- package/build/src/frontend-model-resource/base-resource.js +302 -172
- package/build/src/frontend-models/base.d.ts +186 -115
- package/build/src/frontend-models/base.d.ts.map +1 -1
- package/build/src/frontend-models/base.js +347 -218
- 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.d.ts.map +1 -1
- package/build/src/frontend-models/preloader.js +9 -8
- 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 +9 -9
- package/build/src/testing/expect-utils.js +13 -13
- package/build/src/testing/expect.d.ts +7 -1
- package/build/src/testing/expect.d.ts.map +1 -1
- package/build/src/testing/expect.js +17 -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 +8 -8
- package/build/testing/expect-utils.js +11 -11
- package/build/testing/expect.js +16 -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.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 +127 -128
- 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/base-models.js +1 -16
- package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +179 -89
- package/src/environment-handlers/node.js +6 -6
- package/src/frontend-model-controller.js +90 -82
- package/src/frontend-model-resource/base-resource.js +343 -167
- package/src/frontend-models/base.js +362 -205
- 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 +8 -7
- 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 +8 -8
- package/src/testing/expect-utils.js +11 -11
- package/src/testing/expect.js +16 -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
|
@@ -4,6 +4,22 @@ import path from "node:path"
|
|
|
4
4
|
import * as inflection from "inflection"
|
|
5
5
|
import {frontendModelResourceClassFromDefinition, frontendModelResourceConfigurationFromDefinition, frontendModelResourcesForBackendProject} from "../../../../../frontend-models/resource-definition.js"
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Attribute metadata used for generated frontend-model JSDoc.
|
|
9
|
+
* @typedef {object} FrontendAttributeConfig
|
|
10
|
+
* @property {string} [type] - Column type.
|
|
11
|
+
* @property {string} [columnType] - Column type.
|
|
12
|
+
* @property {string} [sqlType] - SQL type.
|
|
13
|
+
* @property {string} [dataType] - Data type.
|
|
14
|
+
* @property {string} [name] - Attribute name when configured as an array entry.
|
|
15
|
+
* @property {boolean} [null] - Whether null is allowed.
|
|
16
|
+
* @property {() => string} [getType] - Returns column type.
|
|
17
|
+
* @property {() => boolean} [getNull] - Returns whether null is allowed.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Permit spec returned by frontend-model resources during generation.
|
|
21
|
+
* @typedef {Array<string | Record<string, object>>} FrontendModelGeneratorPermitSpec
|
|
22
|
+
*/
|
|
7
23
|
|
|
8
24
|
/** Node CLI command that generates frontend model classes from backend project resource config. */
|
|
9
25
|
export default class DbGenerateFrontendModels extends BaseCommand {
|
|
@@ -29,15 +45,15 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
29
45
|
|
|
30
46
|
/**
|
|
31
47
|
* Ensured directories.
|
|
32
|
-
|
|
48
|
+
* @type {Set<string>} */
|
|
33
49
|
const ensuredDirectories = new Set()
|
|
34
50
|
/**
|
|
35
51
|
* Generated model names by directory.
|
|
36
|
-
|
|
52
|
+
* @type {Map<string, Set<string>>} */
|
|
37
53
|
const generatedModelNamesByDirectory = new Map()
|
|
38
54
|
/**
|
|
39
55
|
* Generated files by directory.
|
|
40
|
-
|
|
56
|
+
* @type {Map<string, Array<{className: string, fileName: string}>>} */
|
|
41
57
|
const generatedFilesByDirectory = new Map()
|
|
42
58
|
|
|
43
59
|
for (const backendProject of backendProjects) {
|
|
@@ -124,8 +140,8 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
124
140
|
* @param {object} args - Arguments.
|
|
125
141
|
* @param {Set<string>} args.availableFrontendModelClassNames - Available frontend model class names in backend project.
|
|
126
142
|
* @param {string} args.className - Model class name.
|
|
127
|
-
* @param {
|
|
128
|
-
* @param {import("../../../../../configuration-types.js").FrontendModelResourceClassType | null} [args.resourceClass]
|
|
143
|
+
* @param {import("../../../../../configuration-types.js").NormalizedFrontendModelResourceConfiguration} args.modelConfig - Model configuration.
|
|
144
|
+
* @param {import("../../../../../configuration-types.js").FrontendModelResourceClassType | null} [args.resourceClass] - Resource class.
|
|
129
145
|
* @returns {void} - No return value.
|
|
130
146
|
*/
|
|
131
147
|
validateModelConfig({availableFrontendModelClassNames, className, modelConfig, resourceClass}) {
|
|
@@ -135,11 +151,12 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
135
151
|
throw new Error(`Model '${className}' is missing required 'abilities' config`)
|
|
136
152
|
}
|
|
137
153
|
|
|
138
|
-
const readActions = [
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
154
|
+
const readActions = [
|
|
155
|
+
{action: "index", abilityAction: abilities.index},
|
|
156
|
+
{action: "find", abilityAction: abilities.find}
|
|
157
|
+
]
|
|
142
158
|
|
|
159
|
+
for (const {action, abilityAction} of readActions) {
|
|
143
160
|
if (typeof abilityAction !== "string" || abilityAction.length < 1) {
|
|
144
161
|
throw new Error(`Model '${className}' is missing required abilities.${action} config`)
|
|
145
162
|
}
|
|
@@ -169,13 +186,13 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
169
186
|
|
|
170
187
|
/**
|
|
171
188
|
* Runs available frontend model class names.
|
|
172
|
-
* @param {Record<string,
|
|
189
|
+
* @param {Record<string, import("../../../../../configuration-types.js").FrontendModelResourceDefinition>} resources - Resource configuration keyed by model name.
|
|
173
190
|
* @returns {Set<string>} - Available frontend model class names.
|
|
174
191
|
*/
|
|
175
192
|
availableFrontendModelClassNames(resources) {
|
|
176
193
|
/**
|
|
177
194
|
* Class names.
|
|
178
|
-
|
|
195
|
+
* @type {Set<string>} */
|
|
179
196
|
const classNames = new Set()
|
|
180
197
|
|
|
181
198
|
for (const resourceModelName in resources) {
|
|
@@ -217,8 +234,8 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
217
234
|
* @param {string} args.className - Model class name.
|
|
218
235
|
* @param {string} args.importPath - Base class import path.
|
|
219
236
|
* @param {typeof import("../../../../../database/record/index.js").default | undefined} args.modelClass - Backend model class.
|
|
220
|
-
* @param {
|
|
221
|
-
* @param {import("../../../../../configuration-types.js").FrontendModelResourceClassType | null} [args.resourceClass]
|
|
237
|
+
* @param {import("../../../../../configuration-types.js").NormalizedFrontendModelResourceConfiguration} args.modelConfig - Model configuration.
|
|
238
|
+
* @param {import("../../../../../configuration-types.js").FrontendModelResourceClassType | null} [args.resourceClass] - Resource class.
|
|
222
239
|
* @returns {string} - Generated file content.
|
|
223
240
|
*/
|
|
224
241
|
buildModelFileContent({className, importPath, modelClass, modelConfig, resourceClass}) {
|
|
@@ -234,6 +251,8 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
234
251
|
const permittedCreateParams = this.permittedParamsForGenerator(resourceClass || null, "create")
|
|
235
252
|
const permittedUpdateParams = this.permittedParamsForGenerator(resourceClass || null, "update")
|
|
236
253
|
const nestedWriteTypes = this.nestedWriteTypesForModel({className, permittedParams: permittedCreateParams.concat(permittedUpdateParams), relationships})
|
|
254
|
+
const usesTransportValue = attributes.some((attribute) => attribute.jsDocType.includes("FrontendModelTransportValue"))
|
|
255
|
+
|| nestedWriteTypes.some((nestedWriteType) => nestedWriteType.attributes.some((attribute) => attribute.type.includes("FrontendModelTransportValue")))
|
|
237
256
|
const builtInCollectionCommands = {
|
|
238
257
|
create: modelConfig.builtInCollectionCommands.create || "create",
|
|
239
258
|
index: modelConfig.builtInCollectionCommands.index || "index"
|
|
@@ -265,6 +284,16 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
265
284
|
fileContent += ` * Frontend model resource config.\n`
|
|
266
285
|
fileContent += ` * @typedef {import("${importPath}").FrontendModelResourceConfig} FrontendModelResourceConfig\n`
|
|
267
286
|
fileContent += " */\n"
|
|
287
|
+
fileContent += "/**\n"
|
|
288
|
+
fileContent += " * Fallback attribute value type for generated fields without narrower metadata.\n"
|
|
289
|
+
fileContent += ` * @typedef {import("${importPath}").FrontendModelAttributeValue} FrontendModelAttributeValue\n`
|
|
290
|
+
fileContent += " */\n"
|
|
291
|
+
if (usesTransportValue) {
|
|
292
|
+
fileContent += "/**\n"
|
|
293
|
+
fileContent += " * Value supported by frontend-model transport serialization and deserialization.\n"
|
|
294
|
+
fileContent += ` * @typedef {import("${importPath}").FrontendModelTransportValue} FrontendModelTransportValue\n`
|
|
295
|
+
fileContent += " */\n"
|
|
296
|
+
}
|
|
268
297
|
fileContent += "\n"
|
|
269
298
|
fileContent += "/**\n"
|
|
270
299
|
fileContent += ` * ${attributesTypeName} type.\n`
|
|
@@ -282,23 +311,13 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
282
311
|
}
|
|
283
312
|
fileContent += " */\n"
|
|
284
313
|
}
|
|
285
|
-
fileContent += this.writeAttributesTypedef({attributes, attributesTypeName, nestedWriteTypes, permittedParams: permittedCreateParams, typeName: createAttributesTypeName})
|
|
286
|
-
fileContent += this.writeAttributesTypedef({attributes, attributesTypeName, nestedWriteTypes, permittedParams: permittedUpdateParams, typeName: updateAttributesTypeName})
|
|
287
|
-
fileContent +=
|
|
288
|
-
fileContent += `
|
|
289
|
-
fileContent +=
|
|
290
|
-
fileContent +=
|
|
291
|
-
fileContent += `
|
|
292
|
-
fileContent += ` * @returns {Promise<${className}>} - Persisted model.\n`
|
|
293
|
-
fileContent += " */\n"
|
|
294
|
-
fileContent += ` static async create(attributes = {}) { return /** @type {Promise<${className}>} */ (super.create(attributes)) }\n\n`
|
|
295
|
-
|
|
296
|
-
fileContent += " /**\n"
|
|
297
|
-
fileContent += ` * Updates this ${className}.\n`
|
|
298
|
-
fileContent += ` * @param {${updateAttributesTypeName}} [newAttributes] - Attributes to assign before saving.\n`
|
|
299
|
-
fileContent += ` * @returns {Promise<${className}>} - Updated model.\n`
|
|
300
|
-
fileContent += " */\n"
|
|
301
|
-
fileContent += ` async update(newAttributes = {}) { return /** @type {Promise<${className}>} */ (super.update(newAttributes)) }\n\n`
|
|
314
|
+
fileContent += this.writeAttributesTypedef({attributes, attributesTypeName, modelClass, nestedWriteTypes, permittedParams: permittedCreateParams, typeName: createAttributesTypeName})
|
|
315
|
+
fileContent += this.writeAttributesTypedef({attributes, attributesTypeName, modelClass, nestedWriteTypes, permittedParams: permittedUpdateParams, typeName: updateAttributesTypeName})
|
|
316
|
+
fileContent += "/**\n"
|
|
317
|
+
fileContent += ` * Frontend model for ${className}.\n`
|
|
318
|
+
fileContent += ` * @augments {FrontendModelBase<${attributesTypeName}, ${createAttributesTypeName}, ${updateAttributesTypeName}>}\n`
|
|
319
|
+
fileContent += " */\n"
|
|
320
|
+
fileContent += `class ${className} extends FrontendModelBase {\n`
|
|
302
321
|
fileContent += " /** @returns {FrontendModelResourceConfig} - Resource config. */\n"
|
|
303
322
|
fileContent += " static resourceConfig() {\n"
|
|
304
323
|
fileContent += " return {\n"
|
|
@@ -416,8 +435,8 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
416
435
|
fileContent += "\n"
|
|
417
436
|
fileContent += " /**\n"
|
|
418
437
|
fileContent += ` * Runs ${methodName}.\n`
|
|
419
|
-
fileContent += " * @param {
|
|
420
|
-
fileContent += " * @returns {Promise<Record<string,
|
|
438
|
+
fileContent += " * @param {...FrontendModelAttributeValue} commandArguments - Custom command arguments.\n"
|
|
439
|
+
fileContent += " * @returns {Promise<Record<string, FrontendModelAttributeValue>>} - Command response.\n"
|
|
421
440
|
fileContent += " */\n"
|
|
422
441
|
fileContent += ` static async ${methodName}(...commandArguments) {\n`
|
|
423
442
|
fileContent += " return await this.executeCustomCommand({\n"
|
|
@@ -433,8 +452,8 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
433
452
|
fileContent += "\n"
|
|
434
453
|
fileContent += " /**\n"
|
|
435
454
|
fileContent += ` * Runs ${methodName}.\n`
|
|
436
|
-
fileContent += " * @param {
|
|
437
|
-
fileContent += " * @returns {Promise<Record<string,
|
|
455
|
+
fileContent += " * @param {...FrontendModelAttributeValue} commandArguments - Custom command arguments.\n"
|
|
456
|
+
fileContent += " * @returns {Promise<Record<string, FrontendModelAttributeValue>>} - Command response.\n"
|
|
438
457
|
fileContent += " */\n"
|
|
439
458
|
fileContent += ` async ${methodName}(...commandArguments) {\n`
|
|
440
459
|
fileContent += ` return await ${className}.executeCustomCommand({\n`
|
|
@@ -450,71 +469,91 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
450
469
|
for (const relationship of relationships) {
|
|
451
470
|
const relationshipNameCamelized = inflection.camelize(relationship.relationshipName)
|
|
452
471
|
const targetImportPath = `./${relationship.targetFileName}.js`
|
|
472
|
+
const targetInstanceType = `import(${JSON.stringify(targetImportPath)}).${relationship.targetClassName}`
|
|
473
|
+
const targetCreateAttributesType = `import(${JSON.stringify(targetImportPath)}).${relationship.targetClassName}CreateAttributes`
|
|
453
474
|
|
|
454
475
|
if (relationship.type == "hasMany") {
|
|
476
|
+
fileContent += "\n"
|
|
477
|
+
fileContent += " /**\n"
|
|
478
|
+
fileContent += ` * Returns ${relationship.relationshipName} relationship helper.\n`
|
|
479
|
+
fileContent += ` * @returns {import(${JSON.stringify(importPath)}).FrontendModelHasManyRelationship<${className}, ${targetInstanceType}, ${targetCreateAttributesType}>} - Relationship helper.\n`
|
|
480
|
+
fileContent += " */\n"
|
|
481
|
+
fileContent += ` ${relationship.relationshipName}Relationship() { return /** @type {import(${JSON.stringify(importPath)}).FrontendModelHasManyRelationship<${className}, ${targetInstanceType}, ${targetCreateAttributesType}>} */ (this.getRelationshipByName(${JSON.stringify(relationship.relationshipName)})) }\n`
|
|
482
|
+
|
|
455
483
|
fileContent += "\n"
|
|
456
484
|
fileContent += " /**\n"
|
|
457
485
|
fileContent += ` * Returns ${relationship.relationshipName}.\n`
|
|
458
|
-
fileContent += ` * @returns {import(${JSON.stringify(importPath)}).FrontendModelHasManyRelationship
|
|
486
|
+
fileContent += ` * @returns {import(${JSON.stringify(importPath)}).FrontendModelHasManyRelationship<${className}, ${targetInstanceType}, ${targetCreateAttributesType}>} - Relationship helper.\n`
|
|
459
487
|
fileContent += " */\n"
|
|
460
|
-
fileContent += ` ${relationship.relationshipName}() { return
|
|
488
|
+
fileContent += ` ${relationship.relationshipName}() { return this.${relationship.relationshipName}Relationship() }\n`
|
|
461
489
|
|
|
462
490
|
fileContent += "\n"
|
|
463
491
|
fileContent += " /**\n"
|
|
464
492
|
fileContent += ` * Returns loaded ${relationship.relationshipName}.\n`
|
|
465
|
-
fileContent += ` * @returns {Array
|
|
493
|
+
fileContent += ` * @returns {Array<${targetInstanceType}>} - Loaded related models.\n`
|
|
466
494
|
fileContent += " */\n"
|
|
467
|
-
fileContent += ` ${relationship.relationshipName}Loaded() { return
|
|
495
|
+
fileContent += ` ${relationship.relationshipName}Loaded() { return this.${relationship.relationshipName}Relationship().loaded() }\n`
|
|
468
496
|
|
|
469
497
|
fileContent += "\n"
|
|
470
498
|
fileContent += " /**\n"
|
|
471
499
|
fileContent += ` * Loads ${relationship.relationshipName}.\n`
|
|
472
|
-
fileContent += ` * @returns {Promise<Array
|
|
500
|
+
fileContent += ` * @returns {Promise<Array<${targetInstanceType}>>} - Loaded related models.\n`
|
|
473
501
|
fileContent += " */\n"
|
|
474
|
-
fileContent += ` async load${relationshipNameCamelized}() { return
|
|
502
|
+
fileContent += ` async load${relationshipNameCamelized}() { return await this.${relationship.relationshipName}Relationship().load() }\n`
|
|
475
503
|
} else {
|
|
504
|
+
fileContent += "\n"
|
|
505
|
+
fileContent += " /**\n"
|
|
506
|
+
fileContent += ` * Returns ${relationship.relationshipName} relationship helper.\n`
|
|
507
|
+
fileContent += ` * @returns {import(${JSON.stringify(importPath)}).FrontendModelSingularRelationship<${className}, ${targetInstanceType}, ${targetCreateAttributesType}>} - Relationship helper.\n`
|
|
508
|
+
fileContent += " */\n"
|
|
509
|
+
fileContent += ` ${relationship.relationshipName}Relationship() { return /** @type {import(${JSON.stringify(importPath)}).FrontendModelSingularRelationship<${className}, ${targetInstanceType}, ${targetCreateAttributesType}>} */ (this.getRelationshipByName(${JSON.stringify(relationship.relationshipName)})) }\n`
|
|
510
|
+
|
|
476
511
|
fileContent += "\n"
|
|
477
512
|
fileContent += " /**\n"
|
|
478
513
|
fileContent += ` * Returns ${relationship.relationshipName}.\n`
|
|
479
|
-
fileContent += ` * @returns {
|
|
514
|
+
fileContent += ` * @returns {${targetInstanceType} | null} - Loaded related model.\n`
|
|
480
515
|
fileContent += " */\n"
|
|
481
|
-
fileContent += ` ${relationship.relationshipName}() { return
|
|
516
|
+
fileContent += ` ${relationship.relationshipName}() { return this.${relationship.relationshipName}Relationship().loaded() }\n`
|
|
482
517
|
|
|
483
518
|
fileContent += "\n"
|
|
484
519
|
fileContent += " /**\n"
|
|
485
520
|
fileContent += ` * Builds ${relationship.relationshipName}.\n`
|
|
486
|
-
fileContent += ` * @param {
|
|
487
|
-
fileContent += ` * @returns {
|
|
521
|
+
fileContent += ` * @param {${targetCreateAttributesType}} [attributes] - Attributes for the new related model.\n`
|
|
522
|
+
fileContent += ` * @returns {${targetInstanceType}} - Built related model.\n`
|
|
488
523
|
fileContent += " */\n"
|
|
489
|
-
fileContent += ` build${relationshipNameCamelized}(attributes = {}) { return
|
|
524
|
+
fileContent += ` build${relationshipNameCamelized}(attributes = {}) { return this.${relationship.relationshipName}Relationship().build(attributes) }\n`
|
|
490
525
|
|
|
491
526
|
fileContent += "\n"
|
|
492
527
|
fileContent += " /**\n"
|
|
493
528
|
fileContent += ` * Loads ${relationship.relationshipName}.\n`
|
|
494
|
-
fileContent += ` * @returns {Promise
|
|
529
|
+
fileContent += ` * @returns {Promise<${targetInstanceType} | null>} - Loaded related model.\n`
|
|
495
530
|
fileContent += " */\n"
|
|
496
|
-
fileContent += ` async load${relationshipNameCamelized}() { return
|
|
531
|
+
fileContent += ` async load${relationshipNameCamelized}() { return await this.${relationship.relationshipName}Relationship().load() }\n`
|
|
497
532
|
|
|
498
533
|
fileContent += "\n"
|
|
499
534
|
fileContent += " /**\n"
|
|
500
535
|
fileContent += ` * Returns or loads ${relationship.relationshipName}.\n`
|
|
501
|
-
fileContent += ` * @returns {Promise
|
|
536
|
+
fileContent += ` * @returns {Promise<${targetInstanceType} | null>} - Loaded related model.\n`
|
|
502
537
|
fileContent += " */\n"
|
|
503
|
-
fileContent += ` async ${relationship.relationshipName}OrLoad() { return
|
|
538
|
+
fileContent += ` async ${relationship.relationshipName}OrLoad() { return await this.${relationship.relationshipName}Relationship().orLoad() }\n`
|
|
504
539
|
|
|
505
540
|
fileContent += "\n"
|
|
506
541
|
fileContent += " /**\n"
|
|
507
542
|
fileContent += ` * Sets ${relationship.relationshipName}.\n`
|
|
508
|
-
fileContent += ` * @param {
|
|
509
|
-
fileContent +=
|
|
543
|
+
fileContent += ` * @param {${targetInstanceType} | null} model - Related model.\n`
|
|
544
|
+
fileContent += " * @returns {void}\n"
|
|
510
545
|
fileContent += " */\n"
|
|
511
|
-
fileContent += ` set${relationshipNameCamelized}(model) {
|
|
546
|
+
fileContent += ` set${relationshipNameCamelized}(model) { this.${relationship.relationshipName}Relationship().setLoaded(model) }\n`
|
|
512
547
|
}
|
|
513
548
|
}
|
|
514
549
|
|
|
515
550
|
fileContent += "}\n"
|
|
516
551
|
fileContent += "\n"
|
|
517
552
|
fileContent += `FrontendModelBase.registerModel(${className})\n`
|
|
553
|
+
fileContent += "\n"
|
|
554
|
+
fileContent += `export {${className}}\n`
|
|
555
|
+
fileContent += "\n"
|
|
556
|
+
fileContent += `export default ${className}\n`
|
|
518
557
|
|
|
519
558
|
return fileContent
|
|
520
559
|
}
|
|
@@ -556,46 +595,83 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
556
595
|
* @param {object} args - Arguments.
|
|
557
596
|
* @param {Array<{jsDocType: string, name: string}>} args.attributes - Generated read attributes.
|
|
558
597
|
* @param {string} args.attributesTypeName - Generated read attributes typedef name.
|
|
598
|
+
* @param {typeof import("../../../../../database/record/index.js").default | undefined} args.modelClass - Backend model class.
|
|
559
599
|
* @param {Array<{attributes: Array<{name: string, type: string}>, relationshipName: string, typeName: string}>} args.nestedWriteTypes - Nested write typedefs.
|
|
560
|
-
* @param {Array<string | Record<string,
|
|
600
|
+
* @param {Array<string | Record<string, object>>} args.permittedParams - Resource permitted params spec.
|
|
561
601
|
* @param {string} args.typeName - Typedef name.
|
|
562
602
|
* @returns {string} - Generated typedef source.
|
|
563
603
|
*/
|
|
564
|
-
writeAttributesTypedef({attributes, attributesTypeName, nestedWriteTypes, permittedParams, typeName}) {
|
|
565
|
-
|
|
604
|
+
writeAttributesTypedef({attributes, attributesTypeName, modelClass, nestedWriteTypes, permittedParams, typeName}) {
|
|
605
|
+
const attributeLines = []
|
|
566
606
|
|
|
567
|
-
output
|
|
568
|
-
output += ` * @typedef {object} ${typeName}\n`
|
|
607
|
+
let output = "/**\n"
|
|
569
608
|
|
|
570
609
|
const attributesByName = new Map(attributes.map((attribute) => [attribute.name, attribute]))
|
|
571
610
|
const nestedWriteTypesByKey = new Map(nestedWriteTypes.map((nestedWriteType) => [`${nestedWriteType.relationshipName}Attributes`, nestedWriteType]))
|
|
611
|
+
const emittedAttributeNames = new Set()
|
|
572
612
|
|
|
573
613
|
for (const entry of permittedParams) {
|
|
574
614
|
if (typeof entry == "string") {
|
|
575
|
-
const
|
|
576
|
-
|
|
615
|
+
const attributeName = this.frontendWriteAttributeName({attributeName: entry, attributesByName, modelClass})
|
|
616
|
+
|
|
617
|
+
if (emittedAttributeNames.has(attributeName)) continue
|
|
618
|
+
|
|
619
|
+
emittedAttributeNames.add(attributeName)
|
|
577
620
|
|
|
578
|
-
|
|
621
|
+
const attribute = attributesByName.get(attributeName)
|
|
622
|
+
const type = attribute ? `${attributesTypeName}[${JSON.stringify(attribute.name)}]` : "FrontendModelAttributeValue"
|
|
623
|
+
|
|
624
|
+
attributeLines.push(` * @property {${type}} [${attributeName}] - Permitted ${attributeName} value.\n`)
|
|
579
625
|
} else if (entry && typeof entry == "object" && !Array.isArray(entry)) {
|
|
580
626
|
for (const key of Object.keys(entry)) {
|
|
581
627
|
const nestedWriteType = nestedWriteTypesByKey.get(key)
|
|
582
|
-
const type = nestedWriteType ? `Array<${nestedWriteType.typeName}>` : "Array<
|
|
628
|
+
const type = nestedWriteType ? `Array<${nestedWriteType.typeName}>` : "Array<object>"
|
|
583
629
|
|
|
584
|
-
|
|
630
|
+
attributeLines.push(` * @property {${type}} [${key}] - Permitted nested ${key} values.\n`)
|
|
585
631
|
}
|
|
586
632
|
}
|
|
587
633
|
}
|
|
588
634
|
|
|
635
|
+
output += ` * Attributes accepted by ${typeName}.\n`
|
|
636
|
+
if (attributeLines.length === 0) {
|
|
637
|
+
output += ` * @typedef {Record<string, never>} ${typeName}\n`
|
|
638
|
+
} else {
|
|
639
|
+
output += ` * @typedef {object} ${typeName}\n`
|
|
640
|
+
output += attributeLines.join("")
|
|
641
|
+
}
|
|
589
642
|
output += " */\n"
|
|
590
643
|
|
|
591
644
|
return output
|
|
592
645
|
}
|
|
593
646
|
|
|
647
|
+
/**
|
|
648
|
+
* Resolves a permitted write attribute to the generated frontend attribute name.
|
|
649
|
+
* @param {{attributeName: string, attributesByName: Map<string, {jsDocType: string, name: string}>, modelClass: typeof import("../../../../../database/record/index.js").default | undefined}} args - Arguments.
|
|
650
|
+
* @returns {string} - Frontend attribute name used by generated accessors.
|
|
651
|
+
*/
|
|
652
|
+
frontendWriteAttributeName({attributeName, attributesByName, modelClass}) {
|
|
653
|
+
if (attributesByName.has(attributeName)) return attributeName
|
|
654
|
+
|
|
655
|
+
if (modelClass) {
|
|
656
|
+
const resolvedAttributeName = modelClass.resolveAttributeName(attributeName)
|
|
657
|
+
|
|
658
|
+
if (resolvedAttributeName && attributesByName.has(resolvedAttributeName)) return resolvedAttributeName
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
const normalizedAttributeName = inflection.camelize(attributeName, true).toLowerCase()
|
|
662
|
+
const matchingAttributeName = Array.from(attributesByName.keys()).find((candidateName) => candidateName.toLowerCase() === normalizedAttributeName)
|
|
663
|
+
|
|
664
|
+
if (matchingAttributeName) return matchingAttributeName
|
|
665
|
+
|
|
666
|
+
// Write-only virtual params are valid permitted params even when they have no read attribute.
|
|
667
|
+
return attributeName
|
|
668
|
+
}
|
|
669
|
+
|
|
594
670
|
/**
|
|
595
671
|
* Runs nested write types for model.
|
|
596
672
|
* @param {object} args - Arguments.
|
|
597
673
|
* @param {string} args.className - Frontend model class name.
|
|
598
|
-
* @param {
|
|
674
|
+
* @param {FrontendModelGeneratorPermitSpec} args.permittedParams - Combined permitted params specs.
|
|
599
675
|
* @param {Array<{autoload: boolean, relationshipName: string, targetClassName: string, targetFileName: string, type: "belongsTo" | "hasOne" | "hasMany"}>} args.relationships - Generated relationships.
|
|
600
676
|
* @returns {Array<{attributes: Array<{name: string, type: string}>, relationshipName: string, typeName: string}>} - Nested write typedefs.
|
|
601
677
|
*/
|
|
@@ -637,7 +713,7 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
637
713
|
/**
|
|
638
714
|
* Runs nested write attributes for spec.
|
|
639
715
|
* @param {object} args - Arguments.
|
|
640
|
-
* @param {
|
|
716
|
+
* @param {Array<string | Record<string, object>> | object | string | null | undefined} args.nestedSpec - Nested permit spec.
|
|
641
717
|
* @param {typeof import("../../../../../database/record/index.js").default | undefined} args.targetModelClass - Target backend model class.
|
|
642
718
|
* @returns {Array<{name: string, type: string}>} - Nested write attributes.
|
|
643
719
|
*/
|
|
@@ -645,11 +721,12 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
645
721
|
if (!Array.isArray(nestedSpec)) return []
|
|
646
722
|
|
|
647
723
|
return nestedSpec.filter((entry) => typeof entry == "string").map((attributeName) => {
|
|
648
|
-
const
|
|
724
|
+
const resolvedAttributeName = targetModelClass?.resolveAttributeName(attributeName) || attributeName
|
|
725
|
+
const attributeConfig = this.frontendAttributeConfigForModelAttribute({attributeName: resolvedAttributeName, modelClass: targetModelClass})
|
|
649
726
|
|
|
650
727
|
return {
|
|
651
|
-
name:
|
|
652
|
-
type: attributeConfig ? this.jsDocTypeForFrontendAttribute({attributeConfig}) : "
|
|
728
|
+
name: resolvedAttributeName,
|
|
729
|
+
type: attributeConfig ? this.jsDocTypeForFrontendAttribute({attributeConfig}) : "FrontendModelAttributeValue"
|
|
653
730
|
}
|
|
654
731
|
})
|
|
655
732
|
}
|
|
@@ -658,14 +735,14 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
658
735
|
* Runs permitted params for generator.
|
|
659
736
|
* @param {import("../../../../../configuration-types.js").FrontendModelResourceClassType | null} resourceClass - Resource class.
|
|
660
737
|
* @param {"create" | "update"} action - Write action.
|
|
661
|
-
* @returns {
|
|
738
|
+
* @returns {FrontendModelGeneratorPermitSpec} - Permitted params spec.
|
|
662
739
|
*/
|
|
663
740
|
permittedParamsForGenerator(resourceClass, action) {
|
|
664
741
|
if (!resourceClass || typeof resourceClass !== "function") return []
|
|
665
742
|
|
|
666
743
|
const prototypeWithMethod = /**
|
|
667
744
|
* Resource prototype.
|
|
668
|
-
* @type {{permittedParams?: (arg?: object) =>
|
|
745
|
+
* @type {{permittedParams?: (arg?: object) => FrontendModelGeneratorPermitSpec}}
|
|
669
746
|
*/ (resourceClass.prototype)
|
|
670
747
|
|
|
671
748
|
if (typeof prototypeWithMethod?.permittedParams !== "function") return []
|
|
@@ -708,7 +785,7 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
708
785
|
|
|
709
786
|
const prototypeWithMethod = /**
|
|
710
787
|
* Resource prototype.
|
|
711
|
-
* @type {{permittedParams?: (arg?: object) =>
|
|
788
|
+
* @type {{permittedParams?: (arg?: object) => FrontendModelGeneratorPermitSpec}}
|
|
712
789
|
*/ (resourceClass.prototype)
|
|
713
790
|
|
|
714
791
|
if (typeof prototypeWithMethod?.permittedParams !== "function") return []
|
|
@@ -737,7 +814,7 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
737
814
|
|
|
738
815
|
/**
|
|
739
816
|
* Relationship names.
|
|
740
|
-
|
|
817
|
+
* @type {string[]} */
|
|
741
818
|
const relationshipNames = []
|
|
742
819
|
|
|
743
820
|
for (const entry of spec) {
|
|
@@ -818,7 +895,7 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
818
895
|
* Runs attribute definitions for model.
|
|
819
896
|
* @param {object} args - Arguments.
|
|
820
897
|
* @param {typeof import("../../../../../database/record/index.js").default | undefined} args.modelClass - Backend model class.
|
|
821
|
-
* @param {
|
|
898
|
+
* @param {import("../../../../../configuration-types.js").NormalizedFrontendModelResourceConfiguration} args.modelConfig - Model configuration.
|
|
822
899
|
* @returns {Array<{jsDocType: string, name: string}>} - Attribute definitions.
|
|
823
900
|
*/
|
|
824
901
|
attributeDefinitionsForModel({modelClass, modelConfig}) {
|
|
@@ -838,13 +915,25 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
838
915
|
}
|
|
839
916
|
|
|
840
917
|
if (Array.isArray(attributes)) {
|
|
841
|
-
return attributes.map((
|
|
842
|
-
|
|
918
|
+
return attributes.map((attributeDefinition) => {
|
|
919
|
+
/** @type {FrontendAttributeConfig | null} */
|
|
920
|
+
let attributeConfig = null
|
|
921
|
+
let attributeName
|
|
922
|
+
|
|
923
|
+
if (typeof attributeDefinition == "string") {
|
|
924
|
+
attributeName = attributeDefinition
|
|
925
|
+
attributeConfig = this.frontendAttributeConfigForModelAttribute({attributeName, modelClass})
|
|
926
|
+
} else if (attributeDefinition && typeof attributeDefinition == "object" && !Array.isArray(attributeDefinition)) {
|
|
927
|
+
attributeConfig = /** @type {FrontendAttributeConfig} */ (attributeDefinition)
|
|
928
|
+
attributeName = attributeConfig.name
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
if (typeof attributeName != "string" || attributeName.length < 1) {
|
|
932
|
+
throw new Error(`Expected frontend model attribute array entries to be strings or objects with a name, got: ${JSON.stringify(attributeDefinition)}`)
|
|
933
|
+
}
|
|
843
934
|
|
|
844
935
|
return {
|
|
845
|
-
jsDocType: this.jsDocTypeForFrontendAttribute({
|
|
846
|
-
attributeConfig: this.frontendAttributeConfigForModelAttribute({attributeName, modelClass})
|
|
847
|
-
}),
|
|
936
|
+
jsDocType: this.jsDocTypeForFrontendAttribute({attributeConfig}),
|
|
848
937
|
name: attributeName
|
|
849
938
|
}
|
|
850
939
|
})
|
|
@@ -856,9 +945,10 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
856
945
|
|
|
857
946
|
return Object.keys(attributes).map((attributeName) => {
|
|
858
947
|
const attributeConfig = attributes[attributeName]
|
|
948
|
+
const normalizedAttributeConfig = attributeConfig && typeof attributeConfig === "object" ? attributeConfig : null
|
|
859
949
|
|
|
860
950
|
return {
|
|
861
|
-
jsDocType: this.jsDocTypeForFrontendAttribute({attributeConfig}),
|
|
951
|
+
jsDocType: this.jsDocTypeForFrontendAttribute({attributeConfig: normalizedAttributeConfig}),
|
|
862
952
|
name: attributeName
|
|
863
953
|
}
|
|
864
954
|
})
|
|
@@ -867,7 +957,7 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
867
957
|
/**
|
|
868
958
|
* Runs js doc type for frontend attribute.
|
|
869
959
|
* @param {object} args - Arguments.
|
|
870
|
-
* @param {
|
|
960
|
+
* @param {FrontendAttributeConfig | null | undefined} args.attributeConfig - Attribute configuration value.
|
|
871
961
|
* @returns {string} - JSDoc type.
|
|
872
962
|
*/
|
|
873
963
|
jsDocTypeForFrontendAttribute({attributeConfig}) {
|
|
@@ -882,12 +972,12 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
882
972
|
|
|
883
973
|
/**
|
|
884
974
|
* Runs js doc type for frontend attribute base type.
|
|
885
|
-
* @param {
|
|
975
|
+
* @param {FrontendAttributeConfig | null | undefined} attributeConfig - Attribute configuration value.
|
|
886
976
|
* @returns {string} - Non-nullable JSDoc type.
|
|
887
977
|
*/
|
|
888
978
|
jsDocTypeForFrontendAttributeBaseType(attributeConfig) {
|
|
889
979
|
if (!attributeConfig || typeof attributeConfig !== "object") {
|
|
890
|
-
return "
|
|
980
|
+
return "FrontendModelAttributeValue"
|
|
891
981
|
}
|
|
892
982
|
|
|
893
983
|
const type = this.frontendAttributeTypeValue(attributeConfig)
|
|
@@ -895,7 +985,7 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
895
985
|
if (type == "boolean") {
|
|
896
986
|
return "boolean"
|
|
897
987
|
} else if (type == "json" || type == "jsonb") {
|
|
898
|
-
return "
|
|
988
|
+
return "FrontendModelTransportValue"
|
|
899
989
|
} else if (type && ["blob", "char", "nvarchar", "varchar", "text", "longtext", "uuid", "character varying"].includes(type)) {
|
|
900
990
|
return "string"
|
|
901
991
|
} else if (type && ["bit", "bigint", "decimal", "double", "double precision", "float", "int", "integer", "numeric", "real", "smallint", "tinyint"].includes(type)) {
|
|
@@ -903,13 +993,13 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
903
993
|
} else if (type && ["date", "datetime", "timestamp", "timestamp without time zone", "timestamptz"].includes(type)) {
|
|
904
994
|
return "Date"
|
|
905
995
|
} else {
|
|
906
|
-
return "
|
|
996
|
+
return "FrontendModelAttributeValue"
|
|
907
997
|
}
|
|
908
998
|
}
|
|
909
999
|
|
|
910
1000
|
/**
|
|
911
1001
|
* Runs frontend attribute can be null.
|
|
912
|
-
* @param {
|
|
1002
|
+
* @param {FrontendAttributeConfig | null | undefined} attributeConfig - Attribute configuration value.
|
|
913
1003
|
* @returns {boolean} - Whether the attribute allows null values.
|
|
914
1004
|
*/
|
|
915
1005
|
frontendAttributeCanBeNull(attributeConfig) {
|
|
@@ -926,7 +1016,7 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
926
1016
|
|
|
927
1017
|
/**
|
|
928
1018
|
* Runs frontend attribute type value.
|
|
929
|
-
* @param {
|
|
1019
|
+
* @param {FrontendAttributeConfig | null | undefined} attributeConfig - Attribute configuration value.
|
|
930
1020
|
* @returns {string | null} - Normalized column type.
|
|
931
1021
|
*/
|
|
932
1022
|
frontendAttributeTypeValue(attributeConfig) {
|
|
@@ -952,7 +1042,7 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
952
1042
|
* @param {object} args - Arguments.
|
|
953
1043
|
* @param {string} args.attributeName - Frontend model attribute name.
|
|
954
1044
|
* @param {typeof import("../../../../../database/record/index.js").default | undefined} args.modelClass - Backend model class.
|
|
955
|
-
* @returns {
|
|
1045
|
+
* @returns {FrontendAttributeConfig | null} - Attribute config inferred from the backend model when available.
|
|
956
1046
|
*/
|
|
957
1047
|
frontendAttributeConfigForModelAttribute({attributeName, modelClass}) {
|
|
958
1048
|
if (!modelClass) {
|
|
@@ -972,8 +1062,8 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
972
1062
|
* Runs relationships for model.
|
|
973
1063
|
* @param {object} args - Arguments.
|
|
974
1064
|
* @param {string} args.className - Model class name.
|
|
975
|
-
* @param {
|
|
976
|
-
* @param {import("../../../../../configuration-types.js").FrontendModelResourceClassType | null} [args.resourceClass]
|
|
1065
|
+
* @param {import("../../../../../configuration-types.js").NormalizedFrontendModelResourceConfiguration} args.modelConfig - Model configuration.
|
|
1066
|
+
* @param {import("../../../../../configuration-types.js").FrontendModelResourceClassType | null} [args.resourceClass] - Resource class.
|
|
977
1067
|
* @returns {Array<{autoload: boolean, relationshipName: string, targetClassName: string, targetFileName: string, type: "belongsTo" | "hasOne" | "hasMany"}>} - Relationships.
|
|
978
1068
|
*/
|
|
979
1069
|
relationshipsForModel({className, modelConfig, resourceClass}) {
|
|
@@ -995,7 +1085,7 @@ export default class DbGenerateFrontendModels extends BaseCommand {
|
|
|
995
1085
|
* @param {object} args - Arguments.
|
|
996
1086
|
* @param {string} args.className - Model class name.
|
|
997
1087
|
* @param {string} args.relationshipName - Relationship name.
|
|
998
|
-
* @param {import("../../../../../configuration-types.js").FrontendModelResourceClassType | null} [args.resourceClass]
|
|
1088
|
+
* @param {import("../../../../../configuration-types.js").FrontendModelResourceClassType | null} [args.resourceClass] - Resource class.
|
|
999
1089
|
* @returns {{autoload: boolean, relationshipName: string, targetClassName: string, targetFileName: string, type: "belongsTo" | "hasOne" | "hasMany"}} Inferred relationship definition.
|
|
1000
1090
|
*/
|
|
1001
1091
|
inferredRelationshipDefinition({className, relationshipName, resourceClass}) {
|
|
@@ -35,7 +35,7 @@ import toImportSpecifier from "../utils/to-import-specifier.js"
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Defines this typedef.
|
|
38
|
-
|
|
38
|
+
* @typedef {{ability?: import("../authorization/ability.js").default, offsetMinutes: number, requestTiming?: import("../http-server/client/request-timing.js").default, tenant?: ?}} TimezoneStore */
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Runs path within allowed prefixes.
|
|
@@ -61,12 +61,12 @@ function pathWithinAllowedPrefixes(filePath, allowedPathPrefixes) {
|
|
|
61
61
|
export default class VelociousEnvironmentHandlerNode extends Base{
|
|
62
62
|
/**
|
|
63
63
|
* Timezone async local storage.
|
|
64
|
-
|
|
64
|
+
* @type {import("node:async_hooks").AsyncLocalStorage<TimezoneStore> | undefined} */
|
|
65
65
|
_timezoneAsyncLocalStorage = NodeAsyncLocalStorage ? new NodeAsyncLocalStorage() : undefined
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Find commands result.
|
|
69
|
-
|
|
69
|
+
* @type {import("./base.js").CommandFileObjectType[] | undefined} */
|
|
70
70
|
_findCommandsResult = undefined
|
|
71
71
|
|
|
72
72
|
/**
|
|
@@ -113,7 +113,7 @@ export default class VelociousEnvironmentHandlerNode extends Base{
|
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Discovered.
|
|
116
|
-
|
|
116
|
+
* @type {Record<string, ?>} */
|
|
117
117
|
const discovered = {}
|
|
118
118
|
|
|
119
119
|
for (const file of files) {
|
|
@@ -131,7 +131,7 @@ export default class VelociousEnvironmentHandlerNode extends Base{
|
|
|
131
131
|
.split("-")
|
|
132
132
|
.map((/**
|
|
133
133
|
* Narrows the runtime value to the documented type.
|
|
134
|
-
|
|
134
|
+
* @type {string} */ part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
135
135
|
.join("")
|
|
136
136
|
|
|
137
137
|
discovered[modelName] = ResourceClass
|
|
@@ -863,7 +863,7 @@ export default class VelociousEnvironmentHandlerNode extends Base{
|
|
|
863
863
|
async _structureSqlByIdentifier({dbs}) {
|
|
864
864
|
const sqlByIdentifier = /**
|
|
865
865
|
* Narrows the runtime value to the documented type.
|
|
866
|
-
|
|
866
|
+
* @type {Record<string, string>} */ ({})
|
|
867
867
|
|
|
868
868
|
for (const identifier of Object.keys(dbs)) {
|
|
869
869
|
const db = dbs[identifier]
|