@warlock.js/core 5.31.0 → 5.32.0
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/CHANGELOG.md +23 -0
- package/esm/application/app.d.mts +3 -3
- package/esm/application/app.d.mts.map +1 -1
- package/esm/application/application-config-types.d.mts +1 -2
- package/esm/application/application-config-types.d.mts.map +1 -1
- package/esm/application/application.d.mts +5 -7
- package/esm/application/application.d.mts.map +1 -1
- package/esm/application/application.mjs +3 -1
- package/esm/application/application.mjs.map +1 -1
- package/esm/application/boot-signal.d.mts +14 -12
- package/esm/application/boot-signal.d.mts.map +1 -1
- package/esm/application/index.d.mts +2 -1
- package/esm/application/index.mjs +1 -1
- package/esm/application/public-url.d.mts +1 -2
- package/esm/application/public-url.d.mts.map +1 -1
- package/esm/application/roles.d.mts +10 -11
- package/esm/application/roles.d.mts.map +1 -1
- package/esm/benchmark/benchmark-snapshots.d.mts +1 -3
- package/esm/benchmark/benchmark-snapshots.d.mts.map +1 -1
- package/esm/benchmark/benchmark.d.mts +1 -3
- package/esm/benchmark/benchmark.d.mts.map +1 -1
- package/esm/benchmark/channels/console.channel.d.mts +1 -3
- package/esm/benchmark/channels/console.channel.d.mts.map +1 -1
- package/esm/benchmark/channels/noop.channel.d.mts +1 -3
- package/esm/benchmark/channels/noop.channel.d.mts.map +1 -1
- package/esm/benchmark/index.mjs +1 -1
- package/esm/benchmark/profiler.d.mts +1 -3
- package/esm/benchmark/profiler.d.mts.map +1 -1
- package/esm/benchmark/profiler.mjs +2 -1
- package/esm/benchmark/profiler.mjs.map +1 -1
- package/esm/benchmark/types.d.mts +22 -17
- package/esm/benchmark/types.d.mts.map +1 -1
- package/esm/bootstrap/setup.d.mts +1 -2
- package/esm/bootstrap/setup.d.mts.map +1 -1
- package/esm/bootstrap.d.mts +1 -2
- package/esm/bootstrap.d.mts.map +1 -1
- package/esm/cache/database-cache-driver.d.mts +3 -5
- package/esm/cache/database-cache-driver.d.mts.map +1 -1
- package/esm/cache/database-cache-driver.mjs +1 -1
- package/esm/cache/index.d.mts +2 -1
- package/esm/cache/index.mjs +1 -1
- package/esm/cli/cli-commands.manager.mjs +6 -3
- package/esm/cli/cli-commands.manager.mjs.map +1 -1
- package/esm/cli/commands/agents-md/agents-md-command.action.mjs +3 -2
- package/esm/cli/commands/agents-md/agents-md-command.action.mjs.map +1 -1
- package/esm/cli/commands/board/board-command.action.mjs +1 -1
- package/esm/cli/commands/check/check-command.action.mjs +1 -1
- package/esm/cli/commands/check/child-typecheck.mjs +1 -1
- package/esm/cli/commands/check/child-typecheck.mjs.map +1 -1
- package/esm/cli/commands/check/format-problems.mjs +1 -1
- package/esm/cli/commands/dev-server.command.mjs +3 -2
- package/esm/cli/commands/dev-server.command.mjs.map +1 -1
- package/esm/cli/commands/doctor/check.types.d.mts +29 -16
- package/esm/cli/commands/doctor/check.types.d.mts.map +1 -1
- package/esm/cli/commands/doctor/checks/locales-ts-deprecated.check.mjs +22 -27
- package/esm/cli/commands/doctor/checks/locales-ts-deprecated.check.mjs.map +1 -1
- package/esm/cli/commands/doctor/doctor-command.action.mjs +2 -1
- package/esm/cli/commands/doctor/doctor-command.action.mjs.map +1 -1
- package/esm/cli/commands/explain/explain-command.action.mjs +1 -1
- package/esm/cli/commands/generate/generators/controller.generator.mjs +5 -2
- package/esm/cli/commands/generate/generators/controller.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/endpoint.generator.mjs +5 -3
- package/esm/cli/commands/generate/generators/endpoint.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/model.generator.mjs +3 -2
- package/esm/cli/commands/generate/generators/model.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/repository.generator.mjs +3 -1
- package/esm/cli/commands/generate/generators/repository.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/resource.generator.mjs +3 -1
- package/esm/cli/commands/generate/generators/resource.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/service.generator.mjs +3 -1
- package/esm/cli/commands/generate/generators/service.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/templates/endpoint-stubs.mjs +2 -2
- package/esm/cli/commands/generate/templates/endpoint-stubs.mjs.map +1 -1
- package/esm/cli/commands/generate/utils/endpoint-schema.mjs +1 -2
- package/esm/cli/commands/generate/utils/endpoint-schema.mjs.map +1 -1
- package/esm/cli/commands/generate/utils/name-parser.mjs +1 -1
- package/esm/cli/commands/generate/utils/path-resolver.mjs +1 -1
- package/esm/cli/commands/inspect/inspect-command.action.mjs +3 -2
- package/esm/cli/commands/inspect/inspect-command.action.mjs.map +1 -1
- package/esm/cli/commands/issue/collect-environment.mjs +187 -0
- package/esm/cli/commands/issue/collect-environment.mjs.map +1 -0
- package/esm/cli/commands/issue/issue-command.action.mjs +70 -0
- package/esm/cli/commands/issue/issue-command.action.mjs.map +1 -0
- package/esm/cli/commands/issue.command.mjs +31 -0
- package/esm/cli/commands/issue.command.mjs.map +1 -0
- package/esm/cli/commands/mcp/mcp-command.action.mjs +15 -14
- package/esm/cli/commands/mcp/mcp-command.action.mjs.map +1 -1
- package/esm/cli/commands/openapi-generator.action.mjs +1 -1
- package/esm/cli/commands/postman-generator.action.mjs +1 -1
- package/esm/cli/commands/routes/format-routes-table.mjs +1 -1
- package/esm/cli/commands/routes/route-row.mjs +1 -1
- package/esm/cli/commands/routes/routes-diff.action.mjs +2 -2
- package/esm/cli/commands/routes/routes-diff.action.mjs.map +1 -1
- package/esm/cli/commands/test.command.mjs +1 -1
- package/esm/cli/commands/trace/trace-command.action.mjs +1 -1
- package/esm/cli/commands-loader.mjs +1 -1
- package/esm/cli/framework-cli-commands.mjs +2 -0
- package/esm/cli/framework-cli-commands.mjs.map +1 -1
- package/esm/cli/parse-cli-args.mjs +2 -2
- package/esm/cli/parse-cli-args.mjs.map +1 -1
- package/esm/cli/start.d.mts +1 -1
- package/esm/cli/string-similarity.mjs +1 -1
- package/esm/commands/cli-command.d.mts +2 -4
- package/esm/commands/cli-command.d.mts.map +1 -1
- package/esm/commands/index.d.mts +2 -1
- package/esm/commands/index.mjs +1 -1
- package/esm/commands/types.d.mts +8 -8
- package/esm/commands/types.d.mts.map +1 -1
- package/esm/config/config-getter.d.mts +2 -3
- package/esm/config/config-getter.d.mts.map +1 -1
- package/esm/config/config-getter.mjs +5 -5
- package/esm/config/config-getter.mjs.map +1 -1
- package/esm/config/config-handlers.d.mts +1 -3
- package/esm/config/config-handlers.d.mts.map +1 -1
- package/esm/config/config-loader.d.mts +1 -2
- package/esm/config/config-loader.d.mts.map +1 -1
- package/esm/config/config-loader.mjs +3 -3
- package/esm/config/config-loader.mjs.map +1 -1
- package/esm/config/config-manager.mjs +1 -1
- package/esm/config/config-schema.d.mts +19 -16
- package/esm/config/config-schema.d.mts.map +1 -1
- package/esm/config/config-setter.d.mts +2 -4
- package/esm/config/config-setter.d.mts.map +1 -1
- package/esm/config/config-setter.mjs +2 -2
- package/esm/config/config-setter.mjs.map +1 -1
- package/esm/config/config-special-handlers.d.mts +2 -4
- package/esm/config/config-special-handlers.d.mts.map +1 -1
- package/esm/config/index.d.mts +2 -1
- package/esm/config/index.mjs +1 -1
- package/esm/config/types.d.mts +4 -5
- package/esm/config/types.d.mts.map +1 -1
- package/esm/connectors/access-connector.d.mts +1 -3
- package/esm/connectors/access-connector.d.mts.map +1 -1
- package/esm/connectors/access-connector.mjs +2 -2
- package/esm/connectors/access-connector.mjs.map +1 -1
- package/esm/connectors/ai-connector.d.mts +1 -3
- package/esm/connectors/ai-connector.d.mts.map +1 -1
- package/esm/connectors/ai-connector.mjs +2 -2
- package/esm/connectors/ai-connector.mjs.map +1 -1
- package/esm/connectors/assert-no-reserved-connector-names.d.mts +1 -3
- package/esm/connectors/assert-no-reserved-connector-names.d.mts.map +1 -1
- package/esm/connectors/assert-unique-connector-names.d.mts +1 -3
- package/esm/connectors/assert-unique-connector-names.d.mts.map +1 -1
- package/esm/connectors/assert-unique-connector-names.mjs +2 -1
- package/esm/connectors/assert-unique-connector-names.mjs.map +1 -1
- package/esm/connectors/base-connector.d.mts +1 -3
- package/esm/connectors/base-connector.d.mts.map +1 -1
- package/esm/connectors/cache-connector.d.mts +1 -3
- package/esm/connectors/cache-connector.d.mts.map +1 -1
- package/esm/connectors/cache-connector.mjs +3 -3
- package/esm/connectors/cache-connector.mjs.map +1 -1
- package/esm/connectors/connectors-manager.d.mts +2 -4
- package/esm/connectors/connectors-manager.d.mts.map +1 -1
- package/esm/connectors/connectors-manager.mjs +2 -2
- package/esm/connectors/connectors-manager.mjs.map +1 -1
- package/esm/connectors/database-connector.d.mts +1 -3
- package/esm/connectors/database-connector.d.mts.map +1 -1
- package/esm/connectors/database-connector.mjs +2 -2
- package/esm/connectors/database-connector.mjs.map +1 -1
- package/esm/connectors/describe-server-address.mjs +4 -4
- package/esm/connectors/describe-server-address.mjs.map +1 -1
- package/esm/connectors/herald-connector.d.mts +1 -3
- package/esm/connectors/herald-connector.d.mts.map +1 -1
- package/esm/connectors/herald-connector.mjs +2 -2
- package/esm/connectors/herald-connector.mjs.map +1 -1
- package/esm/connectors/http-connector.d.mts +1 -3
- package/esm/connectors/http-connector.d.mts.map +1 -1
- package/esm/connectors/http-connector.mjs +8 -7
- package/esm/connectors/http-connector.mjs.map +1 -1
- package/esm/connectors/index.d.mts +2 -1
- package/esm/connectors/index.mjs +1 -1
- package/esm/connectors/logger-connector.d.mts +1 -3
- package/esm/connectors/logger-connector.d.mts.map +1 -1
- package/esm/connectors/logger-connector.mjs +2 -2
- package/esm/connectors/logger-connector.mjs.map +1 -1
- package/esm/connectors/mail-connector.d.mts +1 -3
- package/esm/connectors/mail-connector.d.mts.map +1 -1
- package/esm/connectors/mail-connector.mjs +2 -2
- package/esm/connectors/mail-connector.mjs.map +1 -1
- package/esm/connectors/notifications-connector.d.mts +1 -3
- package/esm/connectors/notifications-connector.d.mts.map +1 -1
- package/esm/connectors/notifications-connector.mjs +2 -2
- package/esm/connectors/notifications-connector.mjs.map +1 -1
- package/esm/connectors/register-configured-connectors.d.mts +2 -4
- package/esm/connectors/register-configured-connectors.d.mts.map +1 -1
- package/esm/connectors/socket-connector.d.mts +1 -3
- package/esm/connectors/socket-connector.d.mts.map +1 -1
- package/esm/connectors/socket-connector.mjs +12 -10
- package/esm/connectors/socket-connector.mjs.map +1 -1
- package/esm/connectors/storage.connector.d.mts +1 -3
- package/esm/connectors/storage.connector.d.mts.map +1 -1
- package/esm/connectors/storage.connector.mjs +2 -2
- package/esm/connectors/storage.connector.mjs.map +1 -1
- package/esm/connectors/types.d.mts +17 -14
- package/esm/connectors/types.d.mts.map +1 -1
- package/esm/container/container-instance-registry.mjs.map +1 -1
- package/esm/container/development-app-modules.d.mts +7 -5
- package/esm/container/development-app-modules.d.mts.map +1 -1
- package/esm/container/development-model-modules.d.mts +6 -5
- package/esm/container/development-model-modules.d.mts.map +1 -1
- package/esm/container/index.d.mts +4 -4
- package/esm/container/index.d.mts.map +1 -1
- package/esm/database/index.d.mts +3 -1
- package/esm/database/index.mjs +1 -1
- package/esm/database/migrate-action.mjs +1 -1
- package/esm/database/models/database-log/database-log.d.mts +2 -3
- package/esm/database/models/database-log/database-log.d.mts.map +1 -1
- package/esm/database/models/database-log/index.d.mts +2 -1
- package/esm/database/models/database-log/index.mjs +1 -1
- package/esm/database/seed-command-action.mjs +1 -1
- package/esm/database/seeds/seeder.d.mts +2 -4
- package/esm/database/seeds/seeder.d.mts.map +1 -1
- package/esm/database/seeds/seeder.errors.d.mts +2 -3
- package/esm/database/seeds/seeder.errors.d.mts.map +1 -1
- package/esm/database/seeds/seeders.manager.mjs +2 -1
- package/esm/database/seeds/seeders.manager.mjs.map +1 -1
- package/esm/database/seeds/types.d.mts +7 -8
- package/esm/database/seeds/types.d.mts.map +1 -1
- package/esm/database/utils.d.mts +4 -5
- package/esm/database/utils.d.mts.map +1 -1
- package/esm/dev-server/app-module-registry.mjs +1 -1
- package/esm/dev-server/create-worker.mjs +5 -3
- package/esm/dev-server/create-worker.mjs.map +1 -1
- package/esm/dev-server/dependency-graph.d.mts +1 -3
- package/esm/dev-server/dependency-graph.d.mts.map +1 -1
- package/esm/dev-server/dependency-graph.mjs +1 -1
- package/esm/dev-server/dependency-graph.mjs.map +1 -1
- package/esm/dev-server/extract-translation-keys.mjs +16 -17
- package/esm/dev-server/extract-translation-keys.mjs.map +1 -1
- package/esm/dev-server/file-manager.d.mts +3 -7
- package/esm/dev-server/file-manager.d.mts.map +1 -1
- package/esm/dev-server/file-operations.d.mts +1 -3
- package/esm/dev-server/file-operations.d.mts.map +1 -1
- package/esm/dev-server/files-watcher.mjs +12 -11
- package/esm/dev-server/files-watcher.mjs.map +1 -1
- package/esm/dev-server/health-checker/checkers/typescript-health-checker.mjs +36 -115
- package/esm/dev-server/health-checker/checkers/typescript-health-checker.mjs.map +1 -1
- package/esm/dev-server/health-checker/file-health-checker.contract.d.mts +5 -5
- package/esm/dev-server/health-checker/file-health-checker.contract.d.mts.map +1 -1
- package/esm/dev-server/health-checker/file-health-result.d.mts +2 -2
- package/esm/dev-server/health-checker/file-health-result.d.mts.map +1 -1
- package/esm/dev-server/health-checker/files-healthcare.manager.mjs +1 -0
- package/esm/dev-server/health-checker/files-healthcare.manager.mjs.map +1 -1
- package/esm/dev-server/health-checker/oxlint-runner.mjs +6 -5
- package/esm/dev-server/health-checker/oxlint-runner.mjs.map +1 -1
- package/esm/dev-server/health-checker/workers/eslint-health.worker.d.mts +1 -1
- package/esm/dev-server/health-checker/workers/oxlint-health.worker.d.mts +1 -1
- package/esm/dev-server/health-checker/workers/ts-health.worker.d.mts +1 -1
- package/esm/dev-server/health-checker/workers/ts-health.worker.mjs +40 -174
- package/esm/dev-server/health-checker/workers/ts-health.worker.mjs.map +1 -1
- package/esm/dev-server/loader/hook-thread.d.mts +4 -8
- package/esm/dev-server/loader/hook-thread.d.mts.map +1 -1
- package/esm/dev-server/loader/load-hook.d.mts +10 -6
- package/esm/dev-server/loader/load-hook.d.mts.map +1 -1
- package/esm/dev-server/loader/load-hook.mjs +4 -3
- package/esm/dev-server/loader/load-hook.mjs.map +1 -1
- package/esm/dev-server/loader/own-resolver.mjs +1 -1
- package/esm/dev-server/loader/register-loader.mjs +3 -2
- package/esm/dev-server/loader/register-loader.mjs.map +1 -1
- package/esm/dev-server/loader/resolve-hook.d.mts +2 -2
- package/esm/dev-server/loader/resolve-hook.d.mts.map +1 -1
- package/esm/dev-server/loader/resolve-hook.mjs +2 -1
- package/esm/dev-server/loader/resolve-hook.mjs.map +1 -1
- package/esm/dev-server/loader/transpile-cache.mjs +2 -1
- package/esm/dev-server/loader/transpile-cache.mjs.map +1 -1
- package/esm/dev-server/manifest-manager.d.mts +1 -3
- package/esm/dev-server/manifest-manager.d.mts.map +1 -1
- package/esm/dev-server/model-module-registry.mjs +3 -3
- package/esm/dev-server/model-module-registry.mjs.map +1 -1
- package/esm/dev-server/model-resource-typings.mjs +40 -47
- package/esm/dev-server/model-resource-typings.mjs.map +1 -1
- package/esm/dev-server/module-loader.mjs +2 -2
- package/esm/dev-server/module-loader.mjs.map +1 -1
- package/esm/dev-server/package-json-manager.mjs +1 -1
- package/esm/dev-server/parse-imports.mjs +6 -38
- package/esm/dev-server/parse-imports.mjs.map +1 -1
- package/esm/dev-server/read-config-ast.mjs +3 -33
- package/esm/dev-server/read-config-ast.mjs.map +1 -1
- package/esm/dev-server/ready-block.mjs +1 -1
- package/esm/dev-server/shortcuts.mjs +1 -1
- package/esm/dev-server/special-files-collector.d.mts +2 -4
- package/esm/dev-server/special-files-collector.d.mts.map +1 -1
- package/esm/dev-server/supervisor.mjs +1 -1
- package/esm/dev-server/tsconfig-manager.mjs +3 -3
- package/esm/dev-server/tsconfig-manager.mjs.map +1 -1
- package/esm/dev-server/type-generator.mjs +28 -35
- package/esm/dev-server/type-generator.mjs.map +1 -1
- package/esm/dev-server/types.d.mts +3 -4
- package/esm/dev-server/types.d.mts.map +1 -1
- package/esm/dev-server/update-check-cache.mjs +2 -2
- package/esm/dev-server/update-check-cache.mjs.map +1 -1
- package/esm/encryption/encrypt.d.mts +2 -3
- package/esm/encryption/encrypt.d.mts.map +1 -1
- package/esm/encryption/hash.d.mts +1 -2
- package/esm/encryption/hash.d.mts.map +1 -1
- package/esm/encryption/index.mjs +1 -1
- package/esm/encryption/password.d.mts +2 -3
- package/esm/encryption/password.d.mts.map +1 -1
- package/esm/encryption/types.d.mts +2 -3
- package/esm/encryption/types.d.mts.map +1 -1
- package/esm/errors/error-codes.d.mts +29 -22
- package/esm/errors/error-codes.d.mts.map +1 -1
- package/esm/errors/warlock-error.d.mts +1 -3
- package/esm/errors/warlock-error.d.mts.map +1 -1
- package/esm/generations/add-command.action.mjs +3 -2
- package/esm/generations/add-command.action.mjs.map +1 -1
- package/esm/generations/features/bull-board.feature.mjs +2 -1
- package/esm/generations/features/bull-board.feature.mjs.map +1 -1
- package/esm/generations/features/notifications.feature.mjs +2 -1
- package/esm/generations/features/notifications.feature.mjs.map +1 -1
- package/esm/generations/features/shared/merge-web-sitemap-config.mjs +16 -23
- package/esm/generations/features/shared/merge-web-sitemap-config.mjs.map +1 -1
- package/esm/generations/features/shared/patch-tsconfig-include.mjs +1 -1
- package/esm/generations/features/shared/relocate-conflicting-home-route.mjs +1 -1
- package/esm/generations/features/sitemap.feature.mjs +2 -1
- package/esm/generations/features/sitemap.feature.mjs.map +1 -1
- package/esm/generations/generation-fs.mjs +1 -1
- package/esm/generations/generation-run.mjs +1 -1
- package/esm/generations/stubs.mjs +1 -1
- package/esm/generations/stubs.mjs.map +1 -1
- package/esm/http/boot-port-preflight.d.mts +4 -5
- package/esm/http/boot-port-preflight.d.mts.map +1 -1
- package/esm/http/boot-port-preflight.mjs +2 -2
- package/esm/http/boot-port-preflight.mjs.map +1 -1
- package/esm/http/bounded-stream-queue.d.mts +4 -4
- package/esm/http/bounded-stream-queue.d.mts.map +1 -1
- package/esm/http/bounded-stream-queue.mjs +1 -1
- package/esm/http/bounded-stream-queue.mjs.map +1 -1
- package/esm/http/build-cors-options.mjs +2 -2
- package/esm/http/build-cors-options.mjs.map +1 -1
- package/esm/http/build-rate-limit-options.d.mts +2 -3
- package/esm/http/build-rate-limit-options.d.mts.map +1 -1
- package/esm/http/build-rate-limit-options.mjs +1 -1
- package/esm/http/build-rate-limit-options.mjs.map +1 -1
- package/esm/http/conditional-request.d.mts +14 -13
- package/esm/http/conditional-request.d.mts.map +1 -1
- package/esm/http/config.d.mts +2 -4
- package/esm/http/config.d.mts.map +1 -1
- package/esm/http/config.mjs +2 -2
- package/esm/http/config.mjs.map +1 -1
- package/esm/http/context/request-context.d.mts +6 -7
- package/esm/http/context/request-context.d.mts.map +1 -1
- package/esm/http/context/request-memo.d.mts +1 -2
- package/esm/http/context/request-memo.d.mts.map +1 -1
- package/esm/http/createHttpApplication.d.mts +2 -3
- package/esm/http/createHttpApplication.d.mts.map +1 -1
- package/esm/http/createHttpApplication.mjs +2 -2
- package/esm/http/createHttpApplication.mjs.map +1 -1
- package/esm/http/csp.d.mts +10 -12
- package/esm/http/csp.d.mts.map +1 -1
- package/esm/http/csp.mjs +2 -2
- package/esm/http/csp.mjs.map +1 -1
- package/esm/http/csrf-default-guard.d.mts +2 -4
- package/esm/http/csrf-default-guard.d.mts.map +1 -1
- package/esm/http/csrf-default-guard.mjs +1 -1
- package/esm/http/csrf-default-guard.mjs.map +1 -1
- package/esm/http/csrf-origin-policy.d.mts +7 -9
- package/esm/http/csrf-origin-policy.d.mts.map +1 -1
- package/esm/http/csrf-origin-policy.mjs +2 -2
- package/esm/http/csrf-origin-policy.mjs.map +1 -1
- package/esm/http/database/RequestLog.d.mts +2 -3
- package/esm/http/database/RequestLog.d.mts.map +1 -1
- package/esm/http/error-codes.d.mts +1 -2
- package/esm/http/error-codes.d.mts.map +1 -1
- package/esm/http/error-mapper.d.mts +2 -4
- package/esm/http/error-mapper.d.mts.map +1 -1
- package/esm/http/error-mapper.mjs +2 -2
- package/esm/http/error-mapper.mjs.map +1 -1
- package/esm/http/errors/errors.d.mts +28 -29
- package/esm/http/errors/errors.d.mts.map +1 -1
- package/esm/http/escape-header-value.d.mts +1 -2
- package/esm/http/escape-header-value.d.mts.map +1 -1
- package/esm/http/events.d.mts +2 -4
- package/esm/http/events.d.mts.map +1 -1
- package/esm/http/health.d.mts +4 -4
- package/esm/http/health.d.mts.map +1 -1
- package/esm/http/index.d.mts +4 -1
- package/esm/http/index.mjs +1 -1
- package/esm/http/middleware/cache-response-middleware.d.mts +2 -4
- package/esm/http/middleware/cache-response-middleware.d.mts.map +1 -1
- package/esm/http/middleware/concurrency-limit.middleware.d.mts +3 -3
- package/esm/http/middleware/concurrency-limit.middleware.d.mts.map +1 -1
- package/esm/http/middleware/idempotency.middleware.d.mts +3 -3
- package/esm/http/middleware/idempotency.middleware.d.mts.map +1 -1
- package/esm/http/middleware/idempotency.middleware.mjs +6 -6
- package/esm/http/middleware/idempotency.middleware.mjs.map +1 -1
- package/esm/http/middleware/index.d.mts +3 -1
- package/esm/http/middleware/index.mjs +1 -1
- package/esm/http/middleware/inject-request-context.d.mts +2 -4
- package/esm/http/middleware/inject-request-context.d.mts.map +1 -1
- package/esm/http/middleware/inject-request-context.mjs +3 -3
- package/esm/http/middleware/inject-request-context.mjs.map +1 -1
- package/esm/http/middleware/ip-filter.middleware.d.mts +3 -3
- package/esm/http/middleware/ip-filter.middleware.d.mts.map +1 -1
- package/esm/http/middleware/maintenance.middleware.d.mts +3 -3
- package/esm/http/middleware/maintenance.middleware.d.mts.map +1 -1
- package/esm/http/middleware/maintenance.middleware.mjs +4 -4
- package/esm/http/middleware/maintenance.middleware.mjs.map +1 -1
- package/esm/http/middleware/max-body-size.middleware.d.mts +2 -2
- package/esm/http/middleware/max-body-size.middleware.d.mts.map +1 -1
- package/esm/http/middleware/middleware-list.d.mts +1 -3
- package/esm/http/middleware/middleware-list.d.mts.map +1 -1
- package/esm/http/middleware/rate-limit.middleware.d.mts +3 -3
- package/esm/http/middleware/rate-limit.middleware.d.mts.map +1 -1
- package/esm/http/middleware/rate-limit.middleware.mjs +2 -2
- package/esm/http/middleware/rate-limit.middleware.mjs.map +1 -1
- package/esm/http/middleware/utils/cidr-match.d.mts +2 -3
- package/esm/http/middleware/utils/cidr-match.d.mts.map +1 -1
- package/esm/http/middleware/utils/idempotency-key.d.mts +3 -5
- package/esm/http/middleware/utils/idempotency-key.d.mts.map +1 -1
- package/esm/http/middleware/utils/index.d.mts +2 -1
- package/esm/http/middleware/utils/parse-size.d.mts +1 -2
- package/esm/http/middleware/utils/parse-size.d.mts.map +1 -1
- package/esm/http/middleware/utils/parse-size.mjs +2 -2
- package/esm/http/middleware/utils/parse-size.mjs.map +1 -1
- package/esm/http/plugins.d.mts +2 -4
- package/esm/http/plugins.d.mts.map +1 -1
- package/esm/http/plugins.mjs +10 -10
- package/esm/http/plugins.mjs.map +1 -1
- package/esm/http/port-preflight.d.mts +3 -4
- package/esm/http/port-preflight.d.mts.map +1 -1
- package/esm/http/rate-limit-cache-store.mjs +4 -3
- package/esm/http/rate-limit-cache-store.mjs.map +1 -1
- package/esm/http/ready-report.d.mts +15 -10
- package/esm/http/ready-report.d.mts.map +1 -1
- package/esm/http/request-controller.d.mts +1 -3
- package/esm/http/request-controller.d.mts.map +1 -1
- package/esm/http/request-log-snapshot.d.mts +20 -16
- package/esm/http/request-log-snapshot.d.mts.map +1 -1
- package/esm/http/request-log-snapshot.mjs +3 -3
- package/esm/http/request-log-snapshot.mjs.map +1 -1
- package/esm/http/request.d.mts +8 -7
- package/esm/http/request.d.mts.map +1 -1
- package/esm/http/request.mjs +8 -7
- package/esm/http/request.mjs.map +1 -1
- package/esm/http/response.d.mts +12 -11
- package/esm/http/response.d.mts.map +1 -1
- package/esm/http/response.mjs +7 -7
- package/esm/http/response.mjs.map +1 -1
- package/esm/http/safe-redirect.d.mts +3 -4
- package/esm/http/safe-redirect.d.mts.map +1 -1
- package/esm/http/serialized.d.mts +12 -13
- package/esm/http/serialized.d.mts.map +1 -1
- package/esm/http/server-rebuilt.d.mts +3 -5
- package/esm/http/server-rebuilt.d.mts.map +1 -1
- package/esm/http/server.d.mts +9 -9
- package/esm/http/server.d.mts.map +1 -1
- package/esm/http/server.mjs +4 -4
- package/esm/http/server.mjs.map +1 -1
- package/esm/http/stream-react-response.d.mts +7 -7
- package/esm/http/stream-react-response.d.mts.map +1 -1
- package/esm/http/tracing/index.mjs +1 -1
- package/esm/http/tracing/trace-id.d.mts +2 -3
- package/esm/http/tracing/trace-id.d.mts.map +1 -1
- package/esm/http/tracing/tracing-dispatcher.d.mts +10 -11
- package/esm/http/tracing/tracing-dispatcher.d.mts.map +1 -1
- package/esm/http/tracing/tracing-dispatcher.mjs +2 -2
- package/esm/http/tracing/tracing-dispatcher.mjs.map +1 -1
- package/esm/http/tracing/tracing.type.d.mts +11 -9
- package/esm/http/tracing/tracing.type.d.mts.map +1 -1
- package/esm/http/types.d.mts +49 -43
- package/esm/http/types.d.mts.map +1 -1
- package/esm/http/uploaded-file.d.mts +6 -5
- package/esm/http/uploaded-file.d.mts.map +1 -1
- package/esm/http/uploads/generate-image-variants.d.mts +6 -6
- package/esm/http/uploads/generate-image-variants.d.mts.map +1 -1
- package/esm/http/uploads/generate-image-variants.mjs +1 -1
- package/esm/http/uploads/generate-image-variants.mjs.map +1 -1
- package/esm/http/uploads/image-variant-cache-entries.mjs +1 -1
- package/esm/http/uploads/image-variant-cache.mjs +8 -8
- package/esm/http/uploads/image-variant-cache.mjs.map +1 -1
- package/esm/http/uploads/image-variant-types.d.mts +7 -9
- package/esm/http/uploads/image-variant-types.d.mts.map +1 -1
- package/esm/http/uploads/image-variants-config-error.d.mts +1 -2
- package/esm/http/uploads/image-variants-config-error.d.mts.map +1 -1
- package/esm/http/uploads/index.d.mts +2 -1
- package/esm/http/uploads/index.mjs +1 -1
- package/esm/http/uploads/parse-uploaded-file-query.mjs +1 -1
- package/esm/http/uploads/parse-uploaded-file-query.mjs.map +1 -1
- package/esm/http/uploads/purge-image-variants.d.mts +2 -4
- package/esm/http/uploads/purge-image-variants.d.mts.map +1 -1
- package/esm/http/uploads/resolve-image-variant.d.mts +3 -5
- package/esm/http/uploads/resolve-image-variant.d.mts.map +1 -1
- package/esm/http/uploads/resolve-image-variants-config.mjs +4 -4
- package/esm/http/uploads/resolve-image-variants-config.mjs.map +1 -1
- package/esm/http/uploads/resolve-original-content-type.mjs +1 -1
- package/esm/http/uploads/resolve-original-content-type.mjs.map +1 -1
- package/esm/http/uploads/trim-image-variant-cache.mjs +3 -3
- package/esm/http/uploads/trim-image-variant-cache.mjs.map +1 -1
- package/esm/http/uploads/uploaded-file.controller.d.mts +6 -5
- package/esm/http/uploads/uploaded-file.controller.d.mts.map +1 -1
- package/esm/http/uploads/uploaded-file.controller.mjs +2 -1
- package/esm/http/uploads/uploaded-file.controller.mjs.map +1 -1
- package/esm/http/uploads/variant-cache-key.mjs +1 -1
- package/esm/http/uploads-config.d.mts +2 -4
- package/esm/http/uploads-config.d.mts.map +1 -1
- package/esm/http/uploads-types.d.mts +19 -17
- package/esm/http/uploads-types.d.mts.map +1 -1
- package/esm/http/xmlable.d.mts +1 -2
- package/esm/http/xmlable.d.mts.map +1 -1
- package/esm/image/image.d.mts +6 -7
- package/esm/image/image.d.mts.map +1 -1
- package/esm/image/image.mjs.map +1 -1
- package/esm/image/index.d.mts +2 -1
- package/esm/image/index.mjs +1 -1
- package/esm/index.d.mts +21 -0
- package/esm/loader/app-module-importer.d.mts +1 -2
- package/esm/loader/app-module-importer.d.mts.map +1 -1
- package/esm/localization/index.mjs +1 -1
- package/esm/localization/parse-locale-dictionary.d.mts +4 -5
- package/esm/localization/parse-locale-dictionary.d.mts.map +1 -1
- package/esm/localization/parse-locale-dictionary.mjs +1 -1
- package/esm/localization/parse-locale-dictionary.mjs.map +1 -1
- package/esm/localization/register-locale-dictionary.d.mts +3 -4
- package/esm/localization/register-locale-dictionary.d.mts.map +1 -1
- package/esm/localization/register-locale-dictionary.mjs +2 -2
- package/esm/localization/register-locale-dictionary.mjs.map +1 -1
- package/esm/logger/fatal-visibility.d.mts +1 -2
- package/esm/logger/fatal-visibility.d.mts.map +1 -1
- package/esm/logger/index.d.mts +2 -1
- package/esm/logger/index.mjs +1 -1
- package/esm/logger/logger.d.mts +1 -3
- package/esm/logger/logger.d.mts.map +1 -1
- package/esm/logger/types.d.mts +2 -3
- package/esm/logger/types.d.mts.map +1 -1
- package/esm/mail/config.d.mts +12 -14
- package/esm/mail/config.d.mts.map +1 -1
- package/esm/mail/events.d.mts +4 -6
- package/esm/mail/events.d.mts.map +1 -1
- package/esm/mail/index.d.mts +2 -1
- package/esm/mail/index.mjs +1 -1
- package/esm/mail/mail.d.mts +1 -3
- package/esm/mail/mail.d.mts.map +1 -1
- package/esm/mail/mailer-pool.d.mts +5 -7
- package/esm/mail/mailer-pool.d.mts.map +1 -1
- package/esm/mail/react-mail.d.mts +1 -3
- package/esm/mail/react-mail.d.mts.map +1 -1
- package/esm/mail/send-mail.d.mts +1 -3
- package/esm/mail/send-mail.d.mts.map +1 -1
- package/esm/mail/send-mail.mjs +2 -1
- package/esm/mail/send-mail.mjs.map +1 -1
- package/esm/mail/test-mailbox.d.mts +11 -13
- package/esm/mail/test-mailbox.d.mts.map +1 -1
- package/esm/mail/types.d.mts +17 -18
- package/esm/mail/types.d.mts.map +1 -1
- package/esm/manifest/manifest-manager.mjs +1 -1
- package/esm/openapi/build-openapi-document.d.mts +2 -4
- package/esm/openapi/build-openapi-document.d.mts.map +1 -1
- package/esm/openapi/cast-schema.mjs +1 -1
- package/esm/openapi/development-openapi-provider.d.mts +5 -6
- package/esm/openapi/development-openapi-provider.d.mts.map +1 -1
- package/esm/openapi/index.d.mts +3 -1
- package/esm/openapi/index.mjs +1 -1
- package/esm/openapi/openapi-child-output.mjs +2 -2
- package/esm/openapi/openapi-child-output.mjs.map +1 -1
- package/esm/openapi/postman/build-request-url.mjs +1 -1
- package/esm/openapi/postman/example-from-schema.d.mts +1 -3
- package/esm/openapi/postman/example-from-schema.d.mts.map +1 -1
- package/esm/openapi/postman/index.d.mts +2 -1
- package/esm/openapi/postman/openapi-to-postman-collection.d.mts +3 -5
- package/esm/openapi/postman/openapi-to-postman-collection.d.mts.map +1 -1
- package/esm/openapi/postman/postman-types.d.mts +19 -18
- package/esm/openapi/postman/postman-types.d.mts.map +1 -1
- package/esm/openapi/postman/schema-refs.d.mts +1 -3
- package/esm/openapi/postman/schema-refs.d.mts.map +1 -1
- package/esm/openapi/postman/uuid-v5.mjs +1 -1
- package/esm/openapi/schema-registry.d.mts +1 -1
- package/esm/openapi/security.mjs +1 -1
- package/esm/openapi/types.d.mts +23 -21
- package/esm/openapi/types.d.mts.map +1 -1
- package/esm/production/assert-generated-imports.mjs +1 -1
- package/esm/production/build-contributions.mjs +1 -1
- package/esm/production/bundle-framework-dependencies.mjs +1 -1
- package/esm/production/dist-build-manifest.mjs +1 -1
- package/esm/production/esbuild-plugins.mjs.map +1 -1
- package/esm/production/esbuild-preflight.mjs +1 -1
- package/esm/production/production-builder.mjs +2 -1
- package/esm/production/production-builder.mjs.map +1 -1
- package/esm/production/production-supervisor.mjs +1 -1
- package/esm/production/registration-child-runner.mjs +4 -3
- package/esm/production/registration-child-runner.mjs.map +1 -1
- package/esm/production/resolve-build-config.d.mts +4 -4
- package/esm/production/resolve-build-config.d.mts.map +1 -1
- package/esm/production/resolve-build-config.mjs +1 -1
- package/esm/production/route-registration-child.d.mts +1 -1
- package/esm/production/route-registration-child.mjs +8 -7
- package/esm/production/route-registration-child.mjs.map +1 -1
- package/esm/production/tsconfig-path-aliases.mjs +1 -1
- package/esm/react/index.d.mts +1 -3
- package/esm/react/index.d.mts.map +1 -1
- package/esm/react/index.mjs.map +1 -1
- package/esm/repositories/adapters/cascade/cascade-adapter.d.mts +3 -4
- package/esm/repositories/adapters/cascade/cascade-adapter.d.mts.map +1 -1
- package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts +2 -3
- package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts.map +1 -1
- package/esm/repositories/adapters/cascade/filter-applicator.mjs +10 -9
- package/esm/repositories/adapters/cascade/filter-applicator.mjs.map +1 -1
- package/esm/repositories/adapters/cascade/index.d.mts +2 -1
- package/esm/repositories/adapters/cascade/index.mjs +1 -1
- package/esm/repositories/contracts/index.d.mts +2 -1
- package/esm/repositories/contracts/query-builder.contract.d.mts +4 -6
- package/esm/repositories/contracts/query-builder.contract.d.mts.map +1 -1
- package/esm/repositories/contracts/repository-adapter.contract.d.mts +1 -3
- package/esm/repositories/contracts/repository-adapter.contract.d.mts.map +1 -1
- package/esm/repositories/contracts/types.d.mts +23 -25
- package/esm/repositories/contracts/types.d.mts.map +1 -1
- package/esm/repositories/index.d.mts +4 -1
- package/esm/repositories/index.mjs +1 -1
- package/esm/repositories/repository.manager.d.mts +2 -3
- package/esm/repositories/repository.manager.d.mts.map +1 -1
- package/esm/repositories/repository.manager.mjs +2 -2
- package/esm/repositories/repository.manager.mjs.map +1 -1
- package/esm/resource/define-resource.d.mts +3 -5
- package/esm/resource/define-resource.d.mts.map +1 -1
- package/esm/resource/index.d.mts +2 -1
- package/esm/resource/index.mjs +1 -1
- package/esm/resource/nullable-resource.d.mts +5 -7
- package/esm/resource/nullable-resource.d.mts.map +1 -1
- package/esm/resource/register-resource.d.mts +1 -3
- package/esm/resource/register-resource.d.mts.map +1 -1
- package/esm/resource/resource-field-builder.d.mts +1 -3
- package/esm/resource/resource-field-builder.d.mts.map +1 -1
- package/esm/resource/resource.d.mts +3 -5
- package/esm/resource/resource.d.mts.map +1 -1
- package/esm/resource/resource.mjs +4 -2
- package/esm/resource/resource.mjs.map +1 -1
- package/esm/resource/types.d.mts +21 -21
- package/esm/resource/types.d.mts.map +1 -1
- package/esm/restful/index.d.mts +2 -1
- package/esm/restful/index.mjs +1 -1
- package/esm/restful/restful.d.mts +12 -32
- package/esm/restful/restful.d.mts.map +1 -1
- package/esm/router/index.d.mts +2 -1
- package/esm/router/index.mjs +1 -1
- package/esm/router/named-api-routes-with-responses.mjs +2 -1
- package/esm/router/named-api-routes-with-responses.mjs.map +1 -1
- package/esm/router/normalize-request-path.d.mts +1 -2
- package/esm/router/normalize-request-path.d.mts.map +1 -1
- package/esm/router/normalize-route-path.d.mts +1 -2
- package/esm/router/normalize-route-path.d.mts.map +1 -1
- package/esm/router/positional-handler-diagnostics.d.mts +15 -13
- package/esm/router/positional-handler-diagnostics.d.mts.map +1 -1
- package/esm/router/resolve-route-rate-limit.mjs +3 -3
- package/esm/router/resolve-route-rate-limit.mjs.map +1 -1
- package/esm/router/route-builder.d.mts +1 -3
- package/esm/router/route-builder.d.mts.map +1 -1
- package/esm/router/route-guard-names.mjs +1 -1
- package/esm/router/route-guard-names.mjs.map +1 -1
- package/esm/router/route-name-method-suffix.d.mts +2 -3
- package/esm/router/route-name-method-suffix.d.mts.map +1 -1
- package/esm/router/route-name-taken-error.d.mts +1 -3
- package/esm/router/route-name-taken-error.d.mts.map +1 -1
- package/esm/router/route-registry.d.mts +1 -3
- package/esm/router/route-registry.d.mts.map +1 -1
- package/esm/router/router.d.mts +2 -4
- package/esm/router/router.d.mts.map +1 -1
- package/esm/router/router.mjs +8 -6
- package/esm/router/router.mjs.map +1 -1
- package/esm/router/types.d.mts +25 -26
- package/esm/router/types.d.mts.map +1 -1
- package/esm/router/unguarded-route-diagnostics.d.mts +6 -8
- package/esm/router/unguarded-route-diagnostics.d.mts.map +1 -1
- package/esm/socket/index.d.mts +2 -1
- package/esm/socket/index.mjs +1 -1
- package/esm/socket/types.d.mts +2 -4
- package/esm/socket/types.d.mts.map +1 -1
- package/esm/socket/utils.d.mts +1 -3
- package/esm/socket/utils.d.mts.map +1 -1
- package/esm/storage/config.d.mts +4 -6
- package/esm/storage/config.d.mts.map +1 -1
- package/esm/storage/context/storage-driver-context.d.mts +3 -4
- package/esm/storage/context/storage-driver-context.d.mts.map +1 -1
- package/esm/storage/drivers/cloud-driver.d.mts +2 -4
- package/esm/storage/drivers/cloud-driver.d.mts.map +1 -1
- package/esm/storage/drivers/cloud-driver.mjs.map +1 -1
- package/esm/storage/drivers/do-spaces-driver.d.mts +1 -3
- package/esm/storage/drivers/do-spaces-driver.d.mts.map +1 -1
- package/esm/storage/drivers/local-driver.d.mts +2 -3
- package/esm/storage/drivers/local-driver.d.mts.map +1 -1
- package/esm/storage/drivers/local-driver.mjs +8 -3
- package/esm/storage/drivers/local-driver.mjs.map +1 -1
- package/esm/storage/drivers/r2-driver.d.mts +1 -3
- package/esm/storage/drivers/r2-driver.d.mts.map +1 -1
- package/esm/storage/drivers/s3-driver.d.mts +1 -3
- package/esm/storage/drivers/s3-driver.d.mts.map +1 -1
- package/esm/storage/index.d.mts +2 -1
- package/esm/storage/index.mjs +1 -1
- package/esm/storage/local-disk-roots.mjs +2 -2
- package/esm/storage/local-disk-roots.mjs.map +1 -1
- package/esm/storage/scoped-storage.d.mts +2 -3
- package/esm/storage/scoped-storage.d.mts.map +1 -1
- package/esm/storage/storage-file.d.mts +1 -3
- package/esm/storage/storage-file.d.mts.map +1 -1
- package/esm/storage/storage.d.mts +3 -4
- package/esm/storage/storage.d.mts.map +1 -1
- package/esm/storage/types.d.mts +36 -36
- package/esm/storage/types.d.mts.map +1 -1
- package/esm/storage/utils/classify-ip-address.d.mts +1 -2
- package/esm/storage/utils/classify-ip-address.d.mts.map +1 -1
- package/esm/storage/utils/contain-path.d.mts +1 -2
- package/esm/storage/utils/contain-path.d.mts.map +1 -1
- package/esm/storage/utils/mime.d.mts +2 -3
- package/esm/storage/utils/mime.d.mts.map +1 -1
- package/esm/storage/utils/safe-fetch.d.mts +6 -6
- package/esm/storage/utils/safe-fetch.d.mts.map +1 -1
- package/esm/storage/utils/safe-fetch.mjs +3 -3
- package/esm/storage/utils/safe-fetch.mjs.map +1 -1
- package/esm/storage/utils/storage-capability-error.d.mts +1 -3
- package/esm/storage/utils/storage-capability-error.d.mts.map +1 -1
- package/esm/storage/utils/storage-error.d.mts +2 -3
- package/esm/storage/utils/storage-error.d.mts.map +1 -1
- package/esm/storage/utils/storage-not-initialized-error.d.mts +1 -2
- package/esm/storage/utils/storage-not-initialized-error.d.mts.map +1 -1
- package/esm/tests/authenticated-test-client.d.mts +5 -6
- package/esm/tests/authenticated-test-client.d.mts.map +1 -1
- package/esm/tests/factories.d.mts +38 -23
- package/esm/tests/factories.d.mts.map +1 -1
- package/esm/tests/fakes/cache-fake.d.mts +14 -9
- package/esm/tests/fakes/cache-fake.d.mts.map +1 -1
- package/esm/tests/fakes/clock-fake.d.mts +13 -8
- package/esm/tests/fakes/clock-fake.d.mts.map +1 -1
- package/esm/tests/fakes/fake-assertion-error.d.mts +2 -3
- package/esm/tests/fakes/fake-assertion-error.d.mts.map +1 -1
- package/esm/tests/fakes/ids-fake.d.mts +5 -4
- package/esm/tests/fakes/ids-fake.d.mts.map +1 -1
- package/esm/tests/fakes/index.d.mts +2 -1
- package/esm/tests/fakes/index.mjs +1 -1
- package/esm/tests/fakes/mail-fake.d.mts +21 -13
- package/esm/tests/fakes/mail-fake.d.mts.map +1 -1
- package/esm/tests/fakes/queue-fake.d.mts +21 -13
- package/esm/tests/fakes/queue-fake.d.mts.map +1 -1
- package/esm/tests/fakes/storage-fake.d.mts +12 -8
- package/esm/tests/fakes/storage-fake.d.mts.map +1 -1
- package/esm/tests/fakes/storage-fake.mjs +1 -1
- package/esm/tests/fakes/test-fakes.d.mts +8 -9
- package/esm/tests/fakes/test-fakes.d.mts.map +1 -1
- package/esm/tests/fakes/test-fakes.mjs +1 -1
- package/esm/tests/fakes/test-fakes.mjs.map +1 -1
- package/esm/tests/index.d.mts +1 -0
- package/esm/tests/snapshot-response.d.mts +4 -5
- package/esm/tests/snapshot-response.d.mts.map +1 -1
- package/esm/tests/start-http-development-server.d.mts +4 -6
- package/esm/tests/start-http-development-server.d.mts.map +1 -1
- package/esm/tests/start-http-development-server.mjs +5 -5
- package/esm/tests/start-http-development-server.mjs.map +1 -1
- package/esm/tests/test-connectors-selection.d.mts +2 -2
- package/esm/tests/test-connectors-selection.d.mts.map +1 -1
- package/esm/tests/test-connectors-selection.mjs +1 -1
- package/esm/tests/test-helpers.d.mts +11 -12
- package/esm/tests/test-helpers.d.mts.map +1 -1
- package/esm/tests/test-http-server.d.mts +14 -10
- package/esm/tests/test-http-server.d.mts.map +1 -1
- package/esm/tests/test-lifecycle-state.mjs +1 -1
- package/esm/tests/vitest-setup.d.mts +6 -7
- package/esm/tests/vitest-setup.d.mts.map +1 -1
- package/esm/tooling/agents-md/agents-md-markers.d.mts +4 -5
- package/esm/tooling/agents-md/agents-md-markers.d.mts.map +1 -1
- package/esm/tooling/agents-md/agents-md-markers.mjs +2 -1
- package/esm/tooling/agents-md/agents-md-markers.mjs.map +1 -1
- package/esm/tooling/agents-md/agents-md-refresher.d.mts +19 -12
- package/esm/tooling/agents-md/agents-md-refresher.d.mts.map +1 -1
- package/esm/tooling/agents-md/installed-skills.d.mts +13 -9
- package/esm/tooling/agents-md/installed-skills.d.mts.map +1 -1
- package/esm/tooling/agents-md/render-agents-md.d.mts +8 -7
- package/esm/tooling/agents-md/render-agents-md.d.mts.map +1 -1
- package/esm/tooling/agents-md/render-agents-md.mjs +2 -2
- package/esm/tooling/agents-md/render-agents-md.mjs.map +1 -1
- package/esm/tooling/agents-md/write-agents-md.d.mts +17 -12
- package/esm/tooling/agents-md/write-agents-md.d.mts.map +1 -1
- package/esm/tooling/board/board-message.d.mts +4 -6
- package/esm/tooling/board/board-message.d.mts.map +1 -1
- package/esm/tooling/board/board.d.mts +50 -38
- package/esm/tooling/board/board.d.mts.map +1 -1
- package/esm/tooling/board/board.mjs +4 -3
- package/esm/tooling/board/board.mjs.map +1 -1
- package/esm/tooling/board/board.types.d.mts +32 -23
- package/esm/tooling/board/board.types.d.mts.map +1 -1
- package/esm/tooling/check/changed-files.d.mts +4 -6
- package/esm/tooling/check/changed-files.d.mts.map +1 -1
- package/esm/tooling/check/changed-files.mjs +2 -2
- package/esm/tooling/check/changed-files.mjs.map +1 -1
- package/esm/tooling/check/check-report.types.d.mts +22 -17
- package/esm/tooling/check/check-report.types.d.mts.map +1 -1
- package/esm/tooling/check/code-style-conventions.mjs +25 -25
- package/esm/tooling/check/code-style-conventions.mjs.map +1 -1
- package/esm/tooling/check/conventions-step.d.mts +4 -6
- package/esm/tooling/check/conventions-step.d.mts.map +1 -1
- package/esm/tooling/check/conventions-step.mjs +7 -18
- package/esm/tooling/check/conventions-step.mjs.map +1 -1
- package/esm/tooling/check/environment-step.d.mts +2 -4
- package/esm/tooling/check/environment-step.d.mts.map +1 -1
- package/esm/tooling/check/environment-step.mjs +1 -1
- package/esm/tooling/check/index.mjs +1 -1
- package/esm/tooling/check/lint-step.d.mts +4 -5
- package/esm/tooling/check/lint-step.d.mts.map +1 -1
- package/esm/tooling/check/lint-step.mjs +2 -1
- package/esm/tooling/check/lint-step.mjs.map +1 -1
- package/esm/tooling/check/request-input.mjs +15 -15
- package/esm/tooling/check/request-input.mjs.map +1 -1
- package/esm/tooling/check/run-check.d.mts +22 -14
- package/esm/tooling/check/run-check.d.mts.map +1 -1
- package/esm/tooling/check/run-tests.d.mts +22 -15
- package/esm/tooling/check/run-tests.d.mts.map +1 -1
- package/esm/tooling/check/security-conventions.mjs +133 -131
- package/esm/tooling/check/security-conventions.mjs.map +1 -1
- package/esm/tooling/check/source-ast.mjs +92 -132
- package/esm/tooling/check/source-ast.mjs.map +1 -1
- package/esm/tooling/check/tests-step.d.mts +7 -8
- package/esm/tooling/check/tests-step.d.mts.map +1 -1
- package/esm/tooling/check/tests-step.mjs +3 -3
- package/esm/tooling/check/tests-step.mjs.map +1 -1
- package/esm/tooling/dev-state/dev-server-state.d.mts +17 -13
- package/esm/tooling/dev-state/dev-server-state.d.mts.map +1 -1
- package/esm/tooling/devtools/devtools-client.d.mts +29 -20
- package/esm/tooling/devtools/devtools-client.d.mts.map +1 -1
- package/esm/tooling/generate/generation.d.mts +34 -22
- package/esm/tooling/generate/generation.d.mts.map +1 -1
- package/esm/tooling/generate/generation.mjs +9 -5
- package/esm/tooling/generate/generation.mjs.map +1 -1
- package/esm/tooling/generate/generator-spec.d.mts +9 -9
- package/esm/tooling/generate/generator-spec.d.mts.map +1 -1
- package/esm/tooling/generate/index.mjs +1 -1
- package/esm/tooling/generate/project-files.mjs +3 -3
- package/esm/tooling/generate/project-files.mjs.map +1 -1
- package/esm/tooling/generate/run-cli.d.mts +14 -11
- package/esm/tooling/generate/run-cli.d.mts.map +1 -1
- package/esm/tooling/generate/run-cli.mjs +2 -2
- package/esm/tooling/generate/run-cli.mjs.map +1 -1
- package/esm/tooling/generate/unified-diff.d.mts +10 -7
- package/esm/tooling/generate/unified-diff.d.mts.map +1 -1
- package/esm/tooling/index.d.mts +1 -0
- package/esm/tooling/inspect/boot-for-inspect.d.mts +7 -7
- package/esm/tooling/inspect/boot-for-inspect.d.mts.map +1 -1
- package/esm/tooling/inspect/collect-config.mjs +3 -3
- package/esm/tooling/inspect/collect-config.mjs.map +1 -1
- package/esm/tooling/inspect/collect-models.d.mts +4 -3
- package/esm/tooling/inspect/collect-models.d.mts.map +1 -1
- package/esm/tooling/inspect/collect-models.mjs +1 -1
- package/esm/tooling/inspect/collect-packages.d.mts +1 -2
- package/esm/tooling/inspect/collect-packages.d.mts.map +1 -1
- package/esm/tooling/inspect/collect-pages.mjs +10 -10
- package/esm/tooling/inspect/collect-pages.mjs.map +1 -1
- package/esm/tooling/inspect/collect-routes.mjs +1 -1
- package/esm/tooling/inspect/event-recorder.d.mts +7 -7
- package/esm/tooling/inspect/event-recorder.d.mts.map +1 -1
- package/esm/tooling/inspect/index.d.mts +2 -1
- package/esm/tooling/inspect/index.mjs +1 -1
- package/esm/tooling/inspect/inspect-app.d.mts +25 -16
- package/esm/tooling/inspect/inspect-app.d.mts.map +1 -1
- package/esm/tooling/inspect/inspect-report.schema.d.mts +1 -2
- package/esm/tooling/inspect/inspect-report.schema.d.mts.map +1 -1
- package/esm/tooling/inspect/inspect-report.types.d.mts +86 -54
- package/esm/tooling/inspect/inspect-report.types.d.mts.map +1 -1
- package/esm/tooling/mcp/create-mcp-context.d.mts +11 -8
- package/esm/tooling/mcp/create-mcp-context.d.mts.map +1 -1
- package/esm/tooling/mcp/db-schema.d.mts +10 -9
- package/esm/tooling/mcp/db-schema.d.mts.map +1 -1
- package/esm/tooling/mcp/docs-search.d.mts +20 -15
- package/esm/tooling/mcp/docs-search.d.mts.map +1 -1
- package/esm/tooling/mcp/index.mjs +1 -1
- package/esm/tooling/mcp/load-ai-tools.d.mts +7 -8
- package/esm/tooling/mcp/load-ai-tools.d.mts.map +1 -1
- package/esm/tooling/mcp/load-ai-tools.mjs +2 -1
- package/esm/tooling/mcp/load-ai-tools.mjs.map +1 -1
- package/esm/tooling/mcp/mcp-tools.d.mts +29 -19
- package/esm/tooling/mcp/mcp-tools.d.mts.map +1 -1
- package/esm/tooling/mcp/mcp-tools.mjs +3 -2
- package/esm/tooling/mcp/mcp-tools.mjs.map +1 -1
- package/esm/tooling/mcp/start-mcp-server.d.mts +24 -17
- package/esm/tooling/mcp/start-mcp-server.d.mts.map +1 -1
- package/esm/tooling/mcp/start-mcp-server.mjs +1 -1
- package/esm/tooling/mcp/start-mcp-server.mjs.map +1 -1
- package/esm/tooling/mcp/tool-input.d.mts +7 -7
- package/esm/tooling/mcp/tool-input.d.mts.map +1 -1
- package/esm/tooling/problem.d.mts +27 -17
- package/esm/tooling/problem.d.mts.map +1 -1
- package/esm/tooling/syntax/ast.mjs +230 -0
- package/esm/tooling/syntax/ast.mjs.map +1 -0
- package/esm/tooling/syntax/imports.mjs +34 -0
- package/esm/tooling/syntax/imports.mjs.map +1 -0
- package/esm/tooling/trace/trace-report.types.d.mts +36 -22
- package/esm/tooling/trace/trace-report.types.d.mts.map +1 -1
- package/esm/tooling/trace/trace-request.d.mts +27 -20
- package/esm/tooling/trace/trace-request.d.mts.map +1 -1
- package/esm/tooling/trace/trace-request.mjs +2 -2
- package/esm/tooling/trace/trace-request.mjs.map +1 -1
- package/esm/tooling/typecheck/index.mjs +1 -1
- package/esm/tooling/typecheck/run-typecheck.d.mts +15 -48
- package/esm/tooling/typecheck/run-typecheck.d.mts.map +1 -1
- package/esm/tooling/typecheck/run-typecheck.mjs +42 -105
- package/esm/tooling/typecheck/run-typecheck.mjs.map +1 -1
- package/esm/tooling/typescript/compiler.d.mts +31 -0
- package/esm/tooling/typescript/compiler.d.mts.map +1 -0
- package/esm/tooling/typescript/compiler.mjs +120 -0
- package/esm/tooling/typescript/compiler.mjs.map +1 -0
- package/esm/updater/update-warlock-packages.mjs +3 -2
- package/esm/updater/update-warlock-packages.mjs.map +1 -1
- package/esm/upgrade/codemods/index.mjs +1 -1
- package/esm/upgrade/codemods/logger-sync-calls.mjs +1 -1
- package/esm/upgrade/codemods/logger-sync-calls.mjs.map +1 -1
- package/esm/upgrade/codemods/request-log-snapshot.mjs +1 -1
- package/esm/upgrade/codemods/request-log-snapshot.mjs.map +1 -1
- package/esm/upgrade/diff.mjs +1 -1
- package/esm/upgrade/diff.mjs.map +1 -1
- package/esm/upgrade/load-ts-morph.mjs +3 -2
- package/esm/upgrade/load-ts-morph.mjs.map +1 -1
- package/esm/upgrade/run-upgrade.mjs +1 -1
- package/esm/use-cases/index.d.mts +2 -1
- package/esm/use-cases/index.mjs +1 -1
- package/esm/use-cases/types.d.mts +116 -63
- package/esm/use-cases/types.d.mts.map +1 -1
- package/esm/use-cases/use-case-broadcast.d.mts +1 -3
- package/esm/use-cases/use-case-broadcast.d.mts.map +1 -1
- package/esm/use-cases/use-case-events.d.mts +3 -5
- package/esm/use-cases/use-case-events.d.mts.map +1 -1
- package/esm/use-cases/use-case-pipeline.d.mts +6 -6
- package/esm/use-cases/use-case-pipeline.d.mts.map +1 -1
- package/esm/use-cases/use-case.d.mts +2 -4
- package/esm/use-cases/use-case.d.mts.map +1 -1
- package/esm/use-cases/use-case.errors.d.mts +1 -3
- package/esm/use-cases/use-case.errors.d.mts.map +1 -1
- package/esm/use-cases/use-cases-registry.d.mts +8 -10
- package/esm/use-cases/use-cases-registry.d.mts.map +1 -1
- package/esm/utils/app-log.d.mts +1 -2
- package/esm/utils/app-log.d.mts.map +1 -1
- package/esm/utils/clock.d.mts +8 -6
- package/esm/utils/clock.d.mts.map +1 -1
- package/esm/utils/database-log.d.mts +3 -4
- package/esm/utils/database-log.d.mts.map +1 -1
- package/esm/utils/environment.d.mts +4 -5
- package/esm/utils/environment.d.mts.map +1 -1
- package/esm/utils/framework-vesion.mjs.map +1 -1
- package/esm/utils/get-localized.d.mts +2 -3
- package/esm/utils/get-localized.d.mts.map +1 -1
- package/esm/utils/ids.d.mts +9 -6
- package/esm/utils/ids.d.mts.map +1 -1
- package/esm/utils/index.d.mts +2 -1
- package/esm/utils/index.mjs +1 -1
- package/esm/utils/normalized-path.d.mts +1 -2
- package/esm/utils/normalized-path.d.mts.map +1 -1
- package/esm/utils/npm-registry.d.mts +1 -2
- package/esm/utils/npm-registry.d.mts.map +1 -1
- package/esm/utils/paths.d.mts +13 -14
- package/esm/utils/paths.d.mts.map +1 -1
- package/esm/utils/paths.mjs +2 -2
- package/esm/utils/paths.mjs.map +1 -1
- package/esm/utils/promise-all-object.d.mts +1 -2
- package/esm/utils/promise-all-object.d.mts.map +1 -1
- package/esm/utils/queue.d.mts +1 -2
- package/esm/utils/queue.d.mts.map +1 -1
- package/esm/utils/runtime.d.mts +11 -10
- package/esm/utils/runtime.d.mts.map +1 -1
- package/esm/utils/sleep.d.mts +1 -2
- package/esm/utils/sleep.d.mts.map +1 -1
- package/esm/utils/sluggable.d.mts +1 -3
- package/esm/utils/sluggable.d.mts.map +1 -1
- package/esm/utils/to-json.d.mts +1 -2
- package/esm/utils/to-json.d.mts.map +1 -1
- package/esm/utils/types.d.mts +1 -2
- package/esm/utils/types.d.mts.map +1 -1
- package/esm/utils/urls.d.mts +5 -6
- package/esm/utils/urls.d.mts.map +1 -1
- package/esm/utils/version-compare.d.mts +1 -2
- package/esm/utils/version-compare.d.mts.map +1 -1
- package/esm/validation/database/exists-except-current-id.d.mts +2 -3
- package/esm/validation/database/exists-except-current-id.d.mts.map +1 -1
- package/esm/validation/database/exists-except-current-user.d.mts +2 -3
- package/esm/validation/database/exists-except-current-user.d.mts.map +1 -1
- package/esm/validation/database/index.d.mts +2 -1
- package/esm/validation/database/index.mjs +1 -1
- package/esm/validation/database/types.d.mts +14 -10
- package/esm/validation/database/types.d.mts.map +1 -1
- package/esm/validation/database/unique-except-current-id.d.mts +2 -3
- package/esm/validation/database/unique-except-current-id.d.mts.map +1 -1
- package/esm/validation/database/unique-except-current-user.d.mts +2 -3
- package/esm/validation/database/unique-except-current-user.d.mts.map +1 -1
- package/esm/validation/file/file.d.mts +4 -6
- package/esm/validation/file/file.d.mts.map +1 -1
- package/esm/validation/file/index.d.mts +2 -1
- package/esm/validation/file/index.mjs +1 -1
- package/esm/validation/index.d.mts +5 -1
- package/esm/validation/index.mjs +1 -1
- package/esm/validation/plugins/index.mjs +1 -1
- package/esm/validation/types.d.mts +6 -4
- package/esm/validation/types.d.mts.map +1 -1
- package/esm/validation/validateAll.mjs +2 -2
- package/esm/validation/validateAll.mjs.map +1 -1
- package/esm/validation/validation-failure-status.mjs +2 -2
- package/esm/validation/validation-failure-status.mjs.map +1 -1
- package/esm/validation/validators/file-validator.d.mts +2 -4
- package/esm/validation/validators/file-validator.d.mts.map +1 -1
- package/esm/validation/validators/index.d.mts +2 -1
- package/esm/validation/validators/index.mjs +1 -1
- package/esm/vite/lower-stage3-decorators.d.mts +2 -3
- package/esm/vite/lower-stage3-decorators.d.mts.map +1 -1
- package/esm/warlock-config/define-config.d.mts +1 -3
- package/esm/warlock-config/define-config.d.mts.map +1 -1
- package/esm/warlock-config/define-config.mjs +3 -2
- package/esm/warlock-config/define-config.mjs.map +1 -1
- package/esm/warlock-config/index.d.mts +2 -1
- package/esm/warlock-config/index.mjs +1 -1
- package/esm/warlock-config/types.d.mts +6 -5
- package/esm/warlock-config/types.d.mts.map +1 -1
- package/esm/warlock-config/warlock-config.manager.d.mts +5 -7
- package/esm/warlock-config/warlock-config.manager.d.mts.map +1 -1
- package/esm/warlock-config/warlock-config.manager.mjs +2 -1
- package/esm/warlock-config/warlock-config.manager.mjs.map +1 -1
- package/esm/warlock-config/warn-deprecated-config.mjs +1 -1
- package/llms-full.txt +55 -5
- package/package.json +17 -15
- package/skills/create-module/SKILL.md +7 -0
- package/skills/index.md +2 -0
- package/skills/report-framework-issue.md +154 -0
- package/skills/run-app/SKILL.md +6 -5
- package/skills/upgrade-from-5-29/SKILL.md +41 -0
- package/skills/warlock-check/SKILL.md +1 -0
- package/esm/tooling/check/index.d.mts +0 -8
- package/esm/tooling/typecheck/index.d.mts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.mjs","names":[],"sources":["../../../../../../../../packages/core/src/resource/resource.ts"],"sourcesContent":["import { get, isLazy, set, type GenericObject } from \"@mongez/reinforcements\";\nimport { Model } from \"@warlock.js/cascade\";\nimport { useRequestStore } from \"../http/context/request-context\";\nimport { isNullableResource } from \"./nullable-resource\";\nimport { ResourceFieldBuilder } from \"./resource-field-builder\";\nimport {\n type ResourceArraySchema,\n type ResourceFieldConfig,\n type ResourceOutputValueCastType,\n} from \"./types\";\n\n/**\n * Maximum recursion depth for self-referencing fields.\n * Prevents runaway serialization on deep trees or circular data.\n */\nconst MAX_SELF_DEPTH = 10;\n\n/**\n * Whether the given schema entry is an `arrayOf` item schema\n */\nfunction isArrayOfSchema(value: unknown): value is ResourceArraySchema {\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n (value as { __type?: unknown }).__type === \"arrayOf\" &&\n typeof (value as { schema?: unknown }).schema === \"object\" &&\n (value as { schema?: unknown }).schema !== null\n );\n}\n\n/**\n * Resource contract\n */\nexport interface ResourceContract<Out = GenericObject> {\n /**\n * Resource data\n */\n resource: GenericObject;\n\n /**\n * Resource final output\n */\n data: GenericObject;\n\n /**\n * Original data\n */\n originalData: GenericObject;\n\n /**\n * Convert resource to JSON\n */\n toJSON(): Out;\n\n /**\n * Transform the given value with given type\n */\n transform(value: any, type: ResourceOutputValueCastType, locale?: string): any;\n\n /**\n * Get a input value for the given key\n */\n get(key: string, defaultValue?: any): any;\n\n /**\n * Set the given value for the given field\n */\n set(key: string, value: any): ResourceContract;\n\n /**\n * Create an array schema for transforming array items\n */\n arrayOf(schema: Record<string, ResourceFieldConfig>): ResourceArraySchema;\n\n /**\n * Get a string field builder\n */\n string(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a date field builder\n */\n date(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a localized field builder\n */\n localized(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a url field builder\n */\n url(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a uploadsUrl field builder\n */\n uploadsUrl(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a number field builder\n */\n number(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a boolean field builder\n */\n boolean(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a float field builder\n */\n float(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a int field builder\n */\n int(inputKey?: string): ResourceFieldBuilder;\n}\n\n/**\n * Resource constructor\n */\nexport interface ResourceConstructor<Out = GenericObject> {\n new (originalData: GenericObject | Resource | Model): ResourceContract<Out>;\n}\n\nexport class Resource implements ResourceContract {\n /**\n * Resource data\n */\n public resource: GenericObject = {};\n\n /**\n * Resource final output\n */\n public data: GenericObject = {};\n\n /**\n * Tracks visited object identities during self-reference recursion.\n * Prevents infinite loops on circular data (e.g. A.parent → B, B.parent → A).\n */\n protected _selfSeen?: Set<unknown>;\n\n /**\n * Raw resource schema — field declarations as written by the developer.\n * Used by doc generators for introspection.\n */\n public static schema: Record<string, ResourceFieldConfig | string> = {};\n\n /**\n * Normalized schema — all string cast types and tuples converted to\n * ResourceFieldBuilder instances at definition time. Used by transformOutput at runtime.\n */\n public static parsedSchema: Record<string, ResourceFieldConfig> = {};\n\n /**\n * Normalize a raw schema into parsedSchema.\n * Converts string cast types (including suffixes) and tuples into pre-built builders.\n * Other entry types (ResourceConstructor, resolver functions, ResourceArraySchema) are kept as-is.\n */\n public static normalizeSchema(\n schema: Record<string, ResourceFieldConfig | string>,\n ): Record<string, ResourceFieldConfig> {\n const parsed: Record<string, ResourceFieldConfig> = {};\n\n for (const [key, value] of Object.entries(schema)) {\n if (value === \"self\" || value === \"self[]\") {\n // Keep self-references as-is — resolved lazily in transformValue\n parsed[key] = value;\n } else if (isLazy<ResourceConstructor>(value)) {\n // Keep Lazy<ResourceConstructor> as-is — resolved at transform\n // time so cyclic resource refs (A embeds B embeds A) compose\n // without import-graph cycles.\n parsed[key] = value;\n } else if (typeof value === \"string\") {\n parsed[key] = ResourceFieldBuilder.fromCastType(value);\n } else if (\n Array.isArray(value) &&\n value.length === 2 &&\n typeof value[0] === \"string\" &&\n typeof value[1] === \"string\"\n ) {\n const builder = ResourceFieldBuilder.fromCastType(value[1]);\n builder.setInputKey(value[0]);\n parsed[key] = builder;\n } else if (isArrayOfSchema(value)) {\n // arrayOf item schemas follow the same rules as the top level: cast\n // strings and tuples become builders (nested arrayOf recurses).\n parsed[key] = { ...value, schema: Resource.normalizeSchema(value.schema) };\n } else {\n parsed[key] = value;\n }\n }\n\n return parsed;\n }\n\n /**\n * Constructor\n */\n public constructor(public originalData: GenericObject | Resource | Model) {\n if (this.originalData instanceof Model) {\n this.resource = this.originalData.data;\n } else if (this.originalData instanceof Resource) {\n this.resource = this.originalData.data;\n } else {\n this.resource = this.originalData;\n }\n }\n\n /**\n * Convert resource to JSON\n */\n public toJSON() {\n this.boot();\n this.transformOutput();\n this.extend();\n\n return this.data;\n }\n\n /**\n * Boot method\n * Called before transforming the resource\n */\n protected boot() {\n //\n }\n\n /**\n * Transform resource to output using the pre-normalized parsedSchema.\n * Builders handle their own array/nullable logic internally.\n * ResourceConstructor and ResourceArraySchema handle arrays in transformValue.\n */\n protected transformOutput() {\n const localeCode = useRequestStore()?.request?.locale;\n const parsedSchema = this.resolveParsedSchema();\n // A model is read through its accessors; anything else through the\n // constructor's normalized input (a wrapped resource's serialized data).\n const source = this.originalData instanceof Model ? this.originalData : this.resource;\n\n for (const [outputKey, outputSettings] of Object.entries(parsedSchema)) {\n const inputKey =\n outputSettings instanceof ResourceFieldBuilder ? outputSettings.getInputKey() : undefined;\n const inputValue = this.resolveSourceValue(source, outputKey, inputKey);\n const outputValue = this.transformValue(inputValue, outputSettings, localeCode);\n\n if (outputValue !== undefined) {\n this.set(outputKey, outputValue);\n }\n }\n }\n\n /**\n * Resolve the normalized schema of THIS class.\n * `@RegisterResource()` is optional: when the class has no own `parsedSchema`\n * (a static field is inherited from the base as `{}`), normalize its own\n * static `schema` (or an instance `schema` field) once and cache it on the class.\n */\n protected resolveParsedSchema(): Record<string, ResourceFieldConfig> {\n const ctor = this.constructor as typeof Resource;\n\n if (Object.hasOwn(ctor, \"parsedSchema\")) {\n return ctor.parsedSchema;\n }\n\n const instanceSchema = (\n this as unknown as { schema?: Record<string, ResourceFieldConfig | string> }\n ).schema;\n const schema = instanceSchema ?? ctor.schema;\n\n if (!schema || Object.keys(schema).length === 0) {\n throw new Error(\n `Resource \"${ctor.name}\" has no schema. Declare \\`static schema = { ... }\\` on the class.`,\n );\n }\n\n const parsed = Resource.normalizeSchema(schema);\n\n // Instance schemas are per-class by convention, so caching on the class is safe\n ctor.parsedSchema = parsed;\n\n return parsed;\n }\n\n /**\n * Transform the given value with given type\n */\n public transform(value: any, type: ResourceOutputValueCastType, locale?: string) {\n return new ResourceFieldBuilder(type).transform(value, locale);\n }\n\n /**\n * Transform the given value for the given output setting.\n * After normalization, string cast types no longer reach here — they are pre-converted to builders.\n */\n protected transformValue(value: any, outputSettings: ResourceFieldConfig, locale?: string): any {\n let outputValue: any;\n\n if (isLazy<ResourceConstructor>(outputSettings)) {\n // Resolve the lazy ref now (cyclic resource imports are fully loaded\n // by serialization time) and recurse — the resolved constructor is\n // handled by the ResourceConstructor branch below.\n return this.transformValue(value, outputSettings.resolve(), locale);\n }\n\n if (isNullableResource(outputSettings)) {\n // nullable(Resource) — always present: null for a missing input, the resource output otherwise\n if (value === null || value === undefined) return null;\n\n return this.transformValue(value, outputSettings.resource, locale) ?? null;\n }\n\n if (Array.isArray(outputSettings) && outputSettings.length === 1) {\n // [Resource] — a list field. [] stays [], a missing/null input omits the field.\n if (!Array.isArray(value)) return;\n\n return value\n .map((item) => this.transformValue(item, outputSettings[0], locale))\n .filter((v) => v !== undefined);\n }\n\n if (outputSettings === \"self\" || outputSettings === \"self[]\") {\n // Self-reference — resolve using the same resource class with cycle detection\n outputValue = this.transformSelfReference(value, outputSettings === \"self[]\");\n } else if (\n typeof outputSettings === \"function\" &&\n outputSettings.prototype instanceof Resource\n ) {\n if (!value) return;\n // Nested resource — handle both single and array values\n if (Array.isArray(value)) {\n // An empty list stays an empty list ([] is the honest output); only a\n // missing/null input omits the field.\n outputValue = value\n .map((item) => new (outputSettings as typeof Resource)(item).toJSON())\n .filter((v) => v !== undefined);\n } else {\n outputValue = new (outputSettings as typeof Resource)(value).toJSON();\n }\n } else if (typeof outputSettings === \"function\") {\n // Resolver function - bind to Resource instance for access to this.get(), etc.\n outputValue = (outputSettings as Function).call(this, value, this);\n } else if (outputSettings instanceof ResourceFieldBuilder) {\n // Builder — handles array mapping and nullable internally via isArrayField\n outputValue = outputSettings.transform(value, locale);\n } else if (\n typeof outputSettings === \"object\" &&\n outputSettings !== null &&\n \"__type\" in outputSettings &&\n outputSettings.__type === \"arrayOf\"\n ) {\n // ResourceArraySchema — structured array items with their own sub-schema\n if (Array.isArray(value)) {\n outputValue = value\n .map((item) => this.transformArrayItem(item, outputSettings.schema, locale))\n .filter((v) => v !== undefined);\n } else {\n outputValue = this.transformArrayItem(value, outputSettings.schema, locale);\n }\n }\n\n return outputValue;\n }\n\n /**\n * Extend the resource output\n */\n protected extend() {\n //\n }\n\n /**\n * Transform a self-referencing field value.\n *\n * @example\n * // Single: parent: \"self\"\n * // Array: children: \"self[]\"\n */\n protected transformSelfReference(value: any, isArray: boolean): any {\n if (isArray) {\n return Array.isArray(value)\n ? value.map((item) => this.resolveSelf(item)).filter((v) => v !== undefined)\n : undefined;\n }\n\n return this.resolveSelf(value);\n }\n\n /**\n * Resolve a single self-reference value.\n * Uses identity-based cycle detection (id/_id) and a max depth guard.\n */\n protected resolveSelf(value: any): any {\n if (!value) return undefined;\n\n const identity = value.id ?? value._id ?? value;\n // Ancestors of the current path only: siblings never see each other,\n // so the set size is the depth.\n const ancestors = this._selfSeen ?? new Set();\n\n // Circular reference or depth limit reached — stop recursion\n if (ancestors.has(identity) || ancestors.size >= MAX_SELF_DEPTH) {\n return undefined;\n }\n\n const SelfConstructor = this.constructor as typeof Resource;\n const child = new SelfConstructor(value);\n child._selfSeen = new Set(ancestors).add(identity);\n\n return child.toJSON();\n }\n\n /**\n * Transform a single array item according to the given schema\n */\n protected transformArrayItem(\n item: any,\n schema: Record<string, ResourceFieldConfig>,\n locale?: string,\n ) {\n const transformedItem: GenericObject = {};\n\n for (const [outputKey, outputSettings] of Object.entries(schema)) {\n let fieldKey = outputKey;\n let valueTransformType = outputSettings as ResourceFieldConfig;\n\n if (Array.isArray(outputSettings) && outputSettings.length === 2) {\n fieldKey = outputSettings[0] as string;\n valueTransformType = outputSettings[1] as ResourceFieldConfig;\n }\n\n const inputKey =\n valueTransformType instanceof ResourceFieldBuilder\n ? valueTransformType.getInputKey()\n : undefined;\n const inputValue = this.resolveSourceValue(item, outputKey, inputKey ?? fieldKey);\n const outputValue = this.transformValue(inputValue, valueTransformType, locale);\n\n if (outputValue !== undefined) {\n set(transformedItem, outputKey, outputValue);\n }\n }\n\n return transformedItem;\n }\n\n /**\n * Resolve one schema field from a model or plain object. Mongo records use `_id`\n * internally, while resources expose `id` by convention.\n */\n protected resolveSourceValue(\n source: GenericObject | Resource | Model,\n outputKey: string,\n inputKey?: string,\n ) {\n const key = inputKey ?? outputKey;\n const read = (field: string) =>\n source instanceof Model ? source.get(field) : get(source, field);\n const value = read(key);\n\n return outputKey === \"id\" && key === \"id\" && value === undefined ? read(\"_id\") : value;\n }\n\n /**\n * Get a input value for the given key\n */\n public get(key: string, defaultValue?: any) {\n return get(this.resource, key, defaultValue);\n }\n\n /**\n * Set the given value for the given field\n */\n public set(key: string, value: any): ResourceContract {\n set(this.data, key, value);\n\n return this;\n }\n\n /**\n * Create an array schema for transforming array items\n */\n public arrayOf(schema: Record<string, ResourceFieldConfig>): ResourceArraySchema {\n return {\n __type: \"arrayOf\",\n schema,\n };\n }\n\n /**\n * Get a string field builder\n */\n public string(inputKey?: string) {\n return this.fieldBuilder(\"string\", inputKey);\n }\n\n /**\n * Get a date field builder\n */\n public date(inputKey?: string) {\n return this.fieldBuilder(\"date\", inputKey);\n }\n\n /**\n * Get a localized field builder\n */\n public localized(inputKey?: string) {\n return this.fieldBuilder(\"localized\", inputKey);\n }\n\n /**\n * Get a url field builder\n */\n public url(inputKey?: string) {\n return this.fieldBuilder(\"url\", inputKey);\n }\n\n /**\n * Get a uploadsUrl field builder\n */\n public uploadsUrl(inputKey?: string) {\n return this.fieldBuilder(\"uploadsUrl\", inputKey);\n }\n\n /**\n * Get a number field builder\n */\n public number(inputKey?: string) {\n return this.fieldBuilder(\"number\", inputKey);\n }\n\n /**\n * Get a boolean field builder\n */\n public boolean(inputKey?: string) {\n return this.fieldBuilder(\"boolean\", inputKey);\n }\n\n /**\n * Get a float field builder\n */\n public float(inputKey?: string) {\n return this.fieldBuilder(\"float\", inputKey);\n }\n\n /**\n * Get a int field builder\n */\n public int(inputKey?: string) {\n return this.fieldBuilder(\"int\", inputKey);\n }\n\n /**\n * New field builder\n */\n protected fieldBuilder(type: ResourceOutputValueCastType, inputKey?: string) {\n const builder = new ResourceFieldBuilder(type);\n\n if (inputKey) {\n builder.setInputKey(inputKey);\n }\n\n return builder;\n }\n}\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,iBAAiB;;;;AAKvB,SAAS,gBAAgB,OAA8C;CACrE,OACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,MAAM,QAAQ,KAAK,KACnB,MAA+B,WAAW,aAC3C,O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;;;;CAKA,AAAO,KAAK,UAAmB;EAC7B,OAAO,KAAK,aAAa,QAAQ,QAAQ;CAC3C;;;;CAKA,AAAO,UAAU,UAAmB;EAClC,OAAO,KAAK,aAAa,aAAa,QAAQ;CAChD;;;;CAKA,AAAO,IAAI,UAAmB;EAC5B,OAAO,KAAK,aAAa,OAAO,QAAQ;CAC1C;;;;CAKA,AAAO,WAAW,UAAmB;EACnC,OAAO,KAAK,aAAa,cAAc,QAAQ;CACjD;;;;CAKA,AAAO,OAAO,UAAmB;EAC/B,OAAO,KAAK,aAAa,UAAU,QAAQ;CAC7C;;;;CAKA,AAAO,QAAQ,UAAmB;EAChC,OAAO,KAAK,aAAa,WAAW,QAAQ;CAC9C;;;;CAKA,AAAO,MAAM,UAAmB;EAC9B,OAAO,KAAK,aAAa,SAAS,QAAQ;CAC5C;;;;CAKA,AAAO,IAAI,UAAmB;EAC5B,OAAO,KAAK,aAAa,OAAO,QAAQ;CAC1C;;;;CAKA,AAAU,aAAa,MAAmC,UAAmB;EAC3E,MAAM,UAAU,IAAI,qBAAqB,IAAI;EAE7C,IAAI,UACF,QAAQ,YAAY,QAAQ;EAG9B,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"resource.mjs","names":[],"sources":["../../../../../../../../packages/core/src/resource/resource.ts"],"sourcesContent":["import { get, isLazy, set, type GenericObject } from \"@mongez/reinforcements\";\nimport { Model } from \"@warlock.js/cascade\";\nimport { useRequestStore } from \"../http/context/request-context\";\nimport { isNullableResource } from \"./nullable-resource\";\nimport { ResourceFieldBuilder } from \"./resource-field-builder\";\nimport {\n type ResourceArraySchema,\n type ResourceFieldConfig,\n type ResourceOutputValueCastType,\n} from \"./types\";\n\n/**\n * Maximum recursion depth for self-referencing fields.\n * Prevents runaway serialization on deep trees or circular data.\n */\nconst MAX_SELF_DEPTH = 10;\n\n/**\n * Whether the given schema entry is an `arrayOf` item schema\n */\nfunction isArrayOfSchema(value: unknown): value is ResourceArraySchema {\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n (value as { __type?: unknown }).__type === \"arrayOf\" &&\n typeof (value as { schema?: unknown }).schema === \"object\" &&\n (value as { schema?: unknown }).schema !== null\n );\n}\n\n/**\n * Resource contract\n */\nexport interface ResourceContract<Out = GenericObject> {\n /**\n * Resource data\n */\n resource: GenericObject;\n\n /**\n * Resource final output\n */\n data: GenericObject;\n\n /**\n * Original data\n */\n originalData: GenericObject;\n\n /**\n * Convert resource to JSON\n */\n toJSON(): Out;\n\n /**\n * Transform the given value with given type\n */\n transform(value: any, type: ResourceOutputValueCastType, locale?: string): any;\n\n /**\n * Get a input value for the given key\n */\n get(key: string, defaultValue?: any): any;\n\n /**\n * Set the given value for the given field\n */\n set(key: string, value: any): ResourceContract;\n\n /**\n * Create an array schema for transforming array items\n */\n arrayOf(schema: Record<string, ResourceFieldConfig>): ResourceArraySchema;\n\n /**\n * Get a string field builder\n */\n string(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a date field builder\n */\n date(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a localized field builder\n */\n localized(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a url field builder\n */\n url(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a uploadsUrl field builder\n */\n uploadsUrl(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a number field builder\n */\n number(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a boolean field builder\n */\n boolean(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a float field builder\n */\n float(inputKey?: string): ResourceFieldBuilder;\n\n /**\n * Get a int field builder\n */\n int(inputKey?: string): ResourceFieldBuilder;\n}\n\n/**\n * Resource constructor\n */\nexport interface ResourceConstructor<Out = GenericObject> {\n new (originalData: GenericObject | Resource | Model): ResourceContract<Out>;\n}\n\nexport class Resource implements ResourceContract {\n /**\n * Resource data\n */\n public resource: GenericObject = {};\n\n /**\n * Resource final output\n */\n public data: GenericObject = {};\n\n /**\n * Tracks visited object identities during self-reference recursion.\n * Prevents infinite loops on circular data (e.g. A.parent → B, B.parent → A).\n */\n protected _selfSeen?: Set<unknown>;\n\n /**\n * Raw resource schema — field declarations as written by the developer.\n * Used by doc generators for introspection.\n */\n public static schema: Record<string, ResourceFieldConfig | string> = {};\n\n /**\n * Normalized schema — all string cast types and tuples converted to\n * ResourceFieldBuilder instances at definition time. Used by transformOutput at runtime.\n */\n public static parsedSchema: Record<string, ResourceFieldConfig> = {};\n\n /**\n * Normalize a raw schema into parsedSchema.\n * Converts string cast types (including suffixes) and tuples into pre-built builders.\n * Other entry types (ResourceConstructor, resolver functions, ResourceArraySchema) are kept as-is.\n */\n public static normalizeSchema(\n schema: Record<string, ResourceFieldConfig | string>,\n ): Record<string, ResourceFieldConfig> {\n const parsed: Record<string, ResourceFieldConfig> = {};\n\n for (const [key, value] of Object.entries(schema)) {\n if (value === \"self\" || value === \"self[]\") {\n // Keep self-references as-is — resolved lazily in transformValue\n parsed[key] = value;\n } else if (isLazy<ResourceConstructor>(value)) {\n // Keep Lazy<ResourceConstructor> as-is — resolved at transform\n // time so cyclic resource refs (A embeds B embeds A) compose\n // without import-graph cycles.\n parsed[key] = value;\n } else if (typeof value === \"string\") {\n parsed[key] = ResourceFieldBuilder.fromCastType(value);\n } else if (\n Array.isArray(value) &&\n value.length === 2 &&\n typeof value[0] === \"string\" &&\n typeof value[1] === \"string\"\n ) {\n const builder = ResourceFieldBuilder.fromCastType(value[1]);\n builder.setInputKey(value[0]);\n parsed[key] = builder;\n } else if (isArrayOfSchema(value)) {\n // arrayOf item schemas follow the same rules as the top level: cast\n // strings and tuples become builders (nested arrayOf recurses).\n parsed[key] = { ...value, schema: Resource.normalizeSchema(value.schema) };\n } else {\n parsed[key] = value;\n }\n }\n\n return parsed;\n }\n\n /**\n * Constructor\n */\n public constructor(public originalData: GenericObject | Resource | Model) {\n if (this.originalData instanceof Model) {\n this.resource = this.originalData.data;\n } else if (this.originalData instanceof Resource) {\n this.resource = this.originalData.data;\n } else {\n this.resource = this.originalData;\n }\n }\n\n /**\n * Convert resource to JSON\n */\n public toJSON() {\n this.boot();\n this.transformOutput();\n this.extend();\n\n return this.data;\n }\n\n /**\n * Boot method\n * Called before transforming the resource\n */\n protected boot() {\n //\n }\n\n /**\n * Transform resource to output using the pre-normalized parsedSchema.\n * Builders handle their own array/nullable logic internally.\n * ResourceConstructor and ResourceArraySchema handle arrays in transformValue.\n */\n protected transformOutput() {\n const localeCode = useRequestStore()?.request?.locale;\n const parsedSchema = this.resolveParsedSchema();\n // A model is read through its accessors; anything else through the\n // constructor's normalized input (a wrapped resource's serialized data).\n const source = this.originalData instanceof Model ? this.originalData : this.resource;\n\n for (const [outputKey, outputSettings] of Object.entries(parsedSchema)) {\n const inputKey =\n outputSettings instanceof ResourceFieldBuilder ? outputSettings.getInputKey() : undefined;\n const inputValue = this.resolveSourceValue(source, outputKey, inputKey);\n const outputValue = this.transformValue(inputValue, outputSettings, localeCode);\n\n if (outputValue !== undefined) {\n this.set(outputKey, outputValue);\n }\n }\n }\n\n /**\n * Resolve the normalized schema of THIS class.\n * `@RegisterResource()` is optional: when the class has no own `parsedSchema`\n * (a static field is inherited from the base as `{}`), normalize its own\n * static `schema` (or an instance `schema` field) once and cache it on the class.\n */\n protected resolveParsedSchema(): Record<string, ResourceFieldConfig> {\n const ctor = this.constructor as typeof Resource;\n\n if (Object.hasOwn(ctor, \"parsedSchema\")) {\n return ctor.parsedSchema;\n }\n\n const instanceSchema = (\n this as unknown as { schema?: Record<string, ResourceFieldConfig | string> }\n ).schema;\n const schema = instanceSchema ?? ctor.schema;\n\n if (!schema || Object.keys(schema).length === 0) {\n throw new Error(\n `Resource \"${ctor.name}\" has no schema. Declare \\`static schema = { ... }\\` on the class.`,\n );\n }\n\n const parsed = Resource.normalizeSchema(schema);\n\n // Instance schemas are per-class by convention, so caching on the class is safe\n ctor.parsedSchema = parsed;\n\n return parsed;\n }\n\n /**\n * Transform the given value with given type\n */\n public transform(value: any, type: ResourceOutputValueCastType, locale?: string) {\n return new ResourceFieldBuilder(type).transform(value, locale);\n }\n\n /**\n * Transform the given value for the given output setting.\n * After normalization, string cast types no longer reach here — they are pre-converted to builders.\n */\n protected transformValue(value: any, outputSettings: ResourceFieldConfig, locale?: string): any {\n let outputValue: any;\n\n if (isLazy<ResourceConstructor>(outputSettings)) {\n // Resolve the lazy ref now (cyclic resource imports are fully loaded\n // by serialization time) and recurse — the resolved constructor is\n // handled by the ResourceConstructor branch below.\n return this.transformValue(value, outputSettings.resolve(), locale);\n }\n\n if (isNullableResource(outputSettings)) {\n // nullable(Resource) — always present: null for a missing input, the resource output otherwise\n if (value === null || value === undefined) return null;\n\n return this.transformValue(value, outputSettings.resource, locale) ?? null;\n }\n\n if (Array.isArray(outputSettings) && outputSettings.length === 1) {\n // [Resource] — a list field. [] stays [], a missing/null input omits the field.\n if (!Array.isArray(value)) return;\n\n return value\n .map((item) => this.transformValue(item, outputSettings[0], locale))\n .filter((v) => v !== undefined);\n }\n\n if (outputSettings === \"self\" || outputSettings === \"self[]\") {\n // Self-reference — resolve using the same resource class with cycle detection\n outputValue = this.transformSelfReference(value, outputSettings === \"self[]\");\n } else if (\n typeof outputSettings === \"function\" &&\n outputSettings.prototype instanceof Resource\n ) {\n if (!value) return;\n // Nested resource — handle both single and array values\n if (Array.isArray(value)) {\n // An empty list stays an empty list ([] is the honest output); only a\n // missing/null input omits the field.\n outputValue = value\n .map((item) => new (outputSettings as typeof Resource)(item).toJSON())\n .filter((v) => v !== undefined);\n } else {\n outputValue = new (outputSettings as typeof Resource)(value).toJSON();\n }\n } else if (typeof outputSettings === \"function\") {\n // Resolver function - bind to Resource instance for access to this.get(), etc.\n outputValue = (outputSettings as Function).call(this, value, this);\n } else if (outputSettings instanceof ResourceFieldBuilder) {\n // Builder — handles array mapping and nullable internally via isArrayField\n outputValue = outputSettings.transform(value, locale);\n } else if (\n typeof outputSettings === \"object\" &&\n outputSettings !== null &&\n \"__type\" in outputSettings &&\n outputSettings.__type === \"arrayOf\"\n ) {\n // ResourceArraySchema — structured array items with their own sub-schema\n if (Array.isArray(value)) {\n outputValue = value\n .map((item) => this.transformArrayItem(item, outputSettings.schema, locale))\n .filter((v) => v !== undefined);\n } else {\n outputValue = this.transformArrayItem(value, outputSettings.schema, locale);\n }\n }\n\n return outputValue;\n }\n\n /**\n * Extend the resource output\n */\n protected extend() {\n //\n }\n\n /**\n * Transform a self-referencing field value.\n *\n * @example\n * // Single: parent: \"self\"\n * // Array: children: \"self[]\"\n */\n protected transformSelfReference(value: any, isArray: boolean): any {\n if (isArray) {\n return Array.isArray(value)\n ? value.map((item) => this.resolveSelf(item)).filter((v) => v !== undefined)\n : undefined;\n }\n\n return this.resolveSelf(value);\n }\n\n /**\n * Resolve a single self-reference value.\n * Uses identity-based cycle detection (id/_id) and a max depth guard.\n */\n protected resolveSelf(value: any): any {\n if (!value) return undefined;\n\n const identity = value.id ?? value._id ?? value;\n // Ancestors of the current path only: siblings never see each other,\n // so the set size is the depth.\n const ancestors = this._selfSeen ?? new Set();\n\n // Circular reference or depth limit reached — stop recursion\n if (ancestors.has(identity) || ancestors.size >= MAX_SELF_DEPTH) {\n return undefined;\n }\n\n const SelfConstructor = this.constructor as typeof Resource;\n const child = new SelfConstructor(value);\n child._selfSeen = new Set(ancestors).add(identity);\n\n return child.toJSON();\n }\n\n /**\n * Transform a single array item according to the given schema\n */\n protected transformArrayItem(\n item: any,\n schema: Record<string, ResourceFieldConfig>,\n locale?: string,\n ) {\n const transformedItem: GenericObject = {};\n\n for (const [outputKey, outputSettings] of Object.entries(schema)) {\n let fieldKey = outputKey;\n let valueTransformType = outputSettings as ResourceFieldConfig;\n\n if (Array.isArray(outputSettings) && outputSettings.length === 2) {\n fieldKey = outputSettings[0] as string;\n valueTransformType = outputSettings[1] as ResourceFieldConfig;\n }\n\n const inputKey =\n valueTransformType instanceof ResourceFieldBuilder\n ? valueTransformType.getInputKey()\n : undefined;\n const inputValue = this.resolveSourceValue(item, outputKey, inputKey ?? fieldKey);\n const outputValue = this.transformValue(inputValue, valueTransformType, locale);\n\n if (outputValue !== undefined) {\n set(transformedItem, outputKey, outputValue);\n }\n }\n\n return transformedItem;\n }\n\n /**\n * Resolve one schema field from a model or plain object. Mongo records use `_id`\n * internally, while resources expose `id` by convention.\n */\n protected resolveSourceValue(\n source: GenericObject | Resource | Model,\n outputKey: string,\n inputKey?: string,\n ) {\n const key = inputKey ?? outputKey;\n const read = (field: string) =>\n source instanceof Model ? source.get(field) : get(source, field);\n const value = read(key);\n\n return outputKey === \"id\" && key === \"id\" && value === undefined ? read(\"_id\") : value;\n }\n\n /**\n * Get a input value for the given key\n */\n public get(key: string, defaultValue?: any) {\n return get(this.resource, key, defaultValue);\n }\n\n /**\n * Set the given value for the given field\n */\n public set(key: string, value: any): ResourceContract {\n set(this.data, key, value);\n\n return this;\n }\n\n /**\n * Create an array schema for transforming array items\n */\n public arrayOf(schema: Record<string, ResourceFieldConfig>): ResourceArraySchema {\n return {\n __type: \"arrayOf\",\n schema,\n };\n }\n\n /**\n * Get a string field builder\n */\n public string(inputKey?: string) {\n return this.fieldBuilder(\"string\", inputKey);\n }\n\n /**\n * Get a date field builder\n */\n public date(inputKey?: string) {\n return this.fieldBuilder(\"date\", inputKey);\n }\n\n /**\n * Get a localized field builder\n */\n public localized(inputKey?: string) {\n return this.fieldBuilder(\"localized\", inputKey);\n }\n\n /**\n * Get a url field builder\n */\n public url(inputKey?: string) {\n return this.fieldBuilder(\"url\", inputKey);\n }\n\n /**\n * Get a uploadsUrl field builder\n */\n public uploadsUrl(inputKey?: string) {\n return this.fieldBuilder(\"uploadsUrl\", inputKey);\n }\n\n /**\n * Get a number field builder\n */\n public number(inputKey?: string) {\n return this.fieldBuilder(\"number\", inputKey);\n }\n\n /**\n * Get a boolean field builder\n */\n public boolean(inputKey?: string) {\n return this.fieldBuilder(\"boolean\", inputKey);\n }\n\n /**\n * Get a float field builder\n */\n public float(inputKey?: string) {\n return this.fieldBuilder(\"float\", inputKey);\n }\n\n /**\n * Get a int field builder\n */\n public int(inputKey?: string) {\n return this.fieldBuilder(\"int\", inputKey);\n }\n\n /**\n * New field builder\n */\n protected fieldBuilder(type: ResourceOutputValueCastType, inputKey?: string) {\n const builder = new ResourceFieldBuilder(type);\n\n if (inputKey) {\n builder.setInputKey(inputKey);\n }\n\n return builder;\n }\n}\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,iBAAiB;;;;AAKvB,SAAS,gBAAgB,OAA8C;CACrE,OACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,MAAM,QAAQ,KAAK,KACnB,MAA+B,WAAW,aAC3C,OAAQ,MAA+B,WAAW,YACjD,MAA+B,WAAW;AAE/C;AAmGA,IAAa,WAAb,MAAa,SAAqC;;gBAqBqB,CAAC;;;sBAMJ,CAAC;;;;;;;CAOnE,OAAc,gBACZ,QACqC;EACrC,MAAM,SAA8C,CAAC;EAErD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,GAC9C,IAAI,UAAU,UAAU,UAAU,UAEhC,OAAO,OAAO;OACT,IAAI,OAA4B,KAAK,GAI1C,OAAO,OAAO;OACT,IAAI,OAAO,UAAU,UAC1B,OAAO,OAAO,qBAAqB,aAAa,KAAK;OAChD,IACL,MAAM,QAAQ,KAAK,KACnB,MAAM,WAAW,KACjB,OAAO,MAAM,OAAO,YACpB,OAAO,MAAM,OAAO,UACpB;GACA,MAAM,UAAU,qBAAqB,aAAa,MAAM,EAAE;GAC1D,QAAQ,YAAY,MAAM,EAAE;GAC5B,OAAO,OAAO;EAChB,OAAO,IAAI,gBAAgB,KAAK,GAG9B,OAAO,OAAO;GAAE,GAAG;GAAO,QAAQ,SAAS,gBAAgB,MAAM,MAAM;EAAE;OAEzE,OAAO,OAAO;EAIlB,OAAO;CACT;;;;CAKA,AAAO,YAAY,AAAO,cAAgD;EAAhD;kBAtEO,CAAC;cAKL,CAAC;EAkE5B,IAAI,KAAK,wBAAwB,OAC/B,KA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";
|
|
2
|
+
import "../http/index.mjs";
|
|
2
3
|
import { ResourceFieldBuilder } from "./resource-field-builder.mjs";
|
|
3
4
|
import { ResourceConstructor, ResourceContract } from "./resource.mjs";
|
|
4
5
|
import { NullableResource } from "./nullable-resource.mjs";
|
|
5
6
|
import { Lazy } from "@mongez/reinforcements";
|
|
6
|
-
|
|
7
7
|
//#region ../../packages/core/src/resource/types.d.ts
|
|
8
|
-
type ResourceOutputValueCastType = "string" | "number" | "date" | "localized" | "boolean" | "url" | "float" | "int" | "object" | "array" | "uploadsUrl"
|
|
8
|
+
export type ResourceOutputValueCastType = "string" | "number" | "date" | "localized" | "boolean" | "url" | "float" | "int" | "object" | "array" | "uploadsUrl" |
|
|
9
9
|
/**
|
|
10
10
|
* Storage url means the value will be generated using current storage.url method
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
"storageUrl";
|
|
13
13
|
/**
|
|
14
14
|
* Self-referencing type — resolves the field using the same resource class.
|
|
15
15
|
* - `"self"` for a single nested self-reference
|
|
16
16
|
* - `"self[]"` for an array of self-references
|
|
17
17
|
*/
|
|
18
|
-
type ResourceSelfReference = "self" | "self[]";
|
|
18
|
+
export type ResourceSelfReference = "self" | "self[]";
|
|
19
19
|
/**
|
|
20
20
|
* Cast type with modifier suffixes for use in resource schemas.
|
|
21
21
|
* - `[]` suffix declares the field as an array (e.g. "string[]")
|
|
22
22
|
* - `?` suffix declares the field as nullable — always present in output, value or null (e.g. "number?")
|
|
23
23
|
* - Combined: `[]` must come before `?` (e.g. "string[]?")
|
|
24
24
|
*/
|
|
25
|
-
type ResourceCastType = ResourceOutputValueCastType | `${ResourceOutputValueCastType}[]` | `${ResourceOutputValueCastType}?` | `${ResourceOutputValueCastType}[]?`;
|
|
26
|
-
type ResourceArraySchema = {
|
|
25
|
+
export type ResourceCastType = ResourceOutputValueCastType | `${ResourceOutputValueCastType}[]` | `${ResourceOutputValueCastType}?` | `${ResourceOutputValueCastType}[]?`;
|
|
26
|
+
export type ResourceArraySchema = {
|
|
27
27
|
__type: "arrayOf";
|
|
28
28
|
schema: Record<string, ResourceFieldConfig>;
|
|
29
29
|
};
|
|
30
|
-
type ResourceFieldConfig = ResourceCastType | ResourceConstructor | ResourceSelfReference | Lazy<ResourceConstructor> | NullableResource | [ResourceConstructor] | [string, ResourceCastType] | ResourceFieldBuilder | ResourceArraySchema | ((value: any, resource: ResourceContract) => any);
|
|
31
|
-
type ResourceSchema = Record<string, ResourceFieldConfig>;
|
|
32
|
-
type ResourceFieldBuilderDateOutputOptions = {
|
|
30
|
+
export type ResourceFieldConfig = ResourceCastType | ResourceConstructor | ResourceSelfReference | Lazy<ResourceConstructor> | NullableResource | [ResourceConstructor] | [string, ResourceCastType] | ResourceFieldBuilder | ResourceArraySchema | ((value: any, resource: ResourceContract) => any);
|
|
31
|
+
export type ResourceSchema = Record<string, ResourceFieldConfig>;
|
|
32
|
+
export type ResourceFieldBuilderDateOutputOptions = {
|
|
33
33
|
/**
|
|
34
34
|
* If set to true, then it will be returned as a formatted date
|
|
35
35
|
*/
|
|
@@ -68,18 +68,18 @@ type ResourceFieldBuilderDateOutputOptions = {
|
|
|
68
68
|
* - nullable(ResourceConstructor) for a nested resource that is `null` when the value is missing
|
|
69
69
|
* - A nested plain object of any of the above
|
|
70
70
|
*/
|
|
71
|
-
type ResponseBodyValue = ResourceCastType | ResourceConstructor | [ResourceConstructor] | NullableResource<ResourceConstructor<any>> | {
|
|
71
|
+
export type ResponseBodyValue = ResourceCastType | ResourceConstructor | [ResourceConstructor] | NullableResource<ResourceConstructor<any>> | {
|
|
72
72
|
[key: string]: ResponseBodyValue;
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
75
75
|
* Response schema for a controller — used for documentation / OpenAPI generation.
|
|
76
76
|
* Keyed by HTTP status code, each entry declares the expected response body shape.
|
|
77
77
|
*/
|
|
78
|
-
type ResponseSchema = { [statusCode in ResponseStatus]?: {
|
|
78
|
+
export type ResponseSchema = { [statusCode in ResponseStatus]?: {
|
|
79
79
|
body: {
|
|
80
80
|
[key: string]: ResponseBodyValue;
|
|
81
81
|
};
|
|
82
|
-
} };
|
|
82
|
+
}; };
|
|
83
83
|
/**
|
|
84
84
|
* Collapse `any` to `unknown` so an untyped resolver never leaks `any` into a resource output.
|
|
85
85
|
*/
|
|
@@ -91,7 +91,7 @@ type AnyToUnknown<T> = 0 extends 1 & T ? unknown : T;
|
|
|
91
91
|
* humanTime are on; timezone, locale and offset are off). A date field customised through a
|
|
92
92
|
* builder (`dateOptions()`) is a builder field and resolves to `unknown`.
|
|
93
93
|
*/
|
|
94
|
-
type BaseCastOutput<C extends string> = C extends "string" | "localized" | "url" | "uploadsUrl" | "storageUrl" ? string : C extends "number" | "float" | "int" ? number : C extends "boolean" ? boolean : C extends "object" ? Record<string, unknown> : C extends "array" ? unknown[] : C extends "date" ? {
|
|
94
|
+
export type BaseCastOutput<C extends string> = C extends "string" | "localized" | "url" | "uploadsUrl" | "storageUrl" ? string : C extends "number" | "float" | "int" ? number : C extends "boolean" ? boolean : C extends "object" ? Record<string, unknown> : C extends "array" ? unknown[] : C extends "date" ? {
|
|
95
95
|
iso: string;
|
|
96
96
|
format: string;
|
|
97
97
|
timestamp: number;
|
|
@@ -107,14 +107,14 @@ type BaseCastOutput<C extends string> = C extends "string" | "localized" | "url"
|
|
|
107
107
|
* CastOutput<"string[]"> // string[]
|
|
108
108
|
* CastOutput<"url[]?"> // string[] | null
|
|
109
109
|
*/
|
|
110
|
-
type CastOutput<C extends string> = C extends `${infer B}[]?` ? BaseCastOutput<B>[] | null : C extends `${infer B}[]` ? BaseCastOutput<B>[] : C extends `${infer B}?` ? BaseCastOutput<B> | null : BaseCastOutput<C>;
|
|
110
|
+
export type CastOutput<C extends string> = C extends `${infer B}[]?` ? BaseCastOutput<B>[] | null : C extends `${infer B}[]` ? BaseCastOutput<B>[] : C extends `${infer B}?` ? BaseCastOutput<B> | null : BaseCastOutput<C>;
|
|
111
111
|
/**
|
|
112
112
|
* Output type of one schema field.
|
|
113
113
|
*
|
|
114
114
|
* `Root` is the schema of the resource being defined, used to resolve `"self"` and `"self[]"`.
|
|
115
115
|
* Anything that cannot be inferred statically (builders) is `unknown`, never `any`.
|
|
116
116
|
*/
|
|
117
|
-
type FieldOutput<F, Root extends ResourceSchema = ResourceSchema> = F extends "self" ? ResourceOutputOf<Root, Root> : F extends "self[]" ? ResourceOutputOf<Root, Root>[] : F extends string ? CastOutput<F> : F extends NullableResource<infer R> ? FieldOutput<R, Root> | null : F extends readonly [new (...args: any[]) => {
|
|
117
|
+
export type FieldOutput<F, Root extends ResourceSchema = ResourceSchema> = F extends "self" ? ResourceOutputOf<Root, Root> : F extends "self[]" ? ResourceOutputOf<Root, Root>[] : F extends string ? CastOutput<F> : F extends NullableResource<infer R> ? FieldOutput<R, Root> | null : F extends readonly [new (...args: any[]) => {
|
|
118
118
|
toJSON(): infer O;
|
|
119
119
|
}] ? AnyToUnknown<O>[] : F extends readonly [string, infer C extends string] ? CastOutput<C> : F extends ResourceFieldBuilder ? unknown : F extends Lazy<infer R> ? FieldOutput<R, Root> : F extends {
|
|
120
120
|
readonly __type: "arrayOf";
|
|
@@ -129,7 +129,7 @@ type FieldOutput<F, Root extends ResourceSchema = ResourceSchema> = F extends "s
|
|
|
129
129
|
* type UserJson = ResourceOutputOf<{ id: "number"; name: "string?" }>;
|
|
130
130
|
* // { id: number; name: string | null }
|
|
131
131
|
*/
|
|
132
|
-
type ResourceOutputOf<S extends ResourceSchema, Root extends ResourceSchema = S> = { -readonly [K in keyof S]: FieldOutput<S[K], Root
|
|
132
|
+
export type ResourceOutputOf<S extends ResourceSchema, Root extends ResourceSchema = S> = { -readonly [K in keyof S]: FieldOutput<S[K], Root>; };
|
|
133
133
|
/**
|
|
134
134
|
* JSON output type of a resource class or of a resource instance.
|
|
135
135
|
*
|
|
@@ -137,7 +137,7 @@ type ResourceOutputOf<S extends ResourceSchema, Root extends ResourceSchema = S>
|
|
|
137
137
|
* type UserJson = ResourceOutput<typeof UserResource>;
|
|
138
138
|
* type SameJson = ResourceOutput<InstanceType<typeof UserResource>>;
|
|
139
139
|
*/
|
|
140
|
-
type ResourceOutput<R> = R extends (new (...args: any[]) => {
|
|
140
|
+
export type ResourceOutput<R> = R extends (new (...args: any[]) => {
|
|
141
141
|
toJSON(): infer O;
|
|
142
142
|
}) ? O : R extends {
|
|
143
143
|
toJSON(): infer O;
|
|
@@ -151,7 +151,7 @@ type ResourceOutput<R> = R extends (new (...args: any[]) => {
|
|
|
151
151
|
* @example
|
|
152
152
|
* type Out = ResponseBodyOutput<{ user: typeof UserResource; token: "string"; tags: "string[]?" }>;
|
|
153
153
|
*/
|
|
154
|
-
type ResponseBodyOutput<B> = B extends string ? CastOutput<B> : B extends readonly [infer R] ? ResourceOutput<R>[] : B extends (new (...args: any[]) => unknown) ? ResourceOutput<B> : B extends NullableResource<infer R> ? ResourceOutput<R> | null : B extends object ? { -readonly [K in keyof B]: ResponseBodyOutput<B[K]
|
|
154
|
+
export type ResponseBodyOutput<B> = B extends string ? CastOutput<B> : B extends readonly [infer R] ? ResourceOutput<R>[] : B extends (new (...args: any[]) => unknown) ? ResourceOutput<B> : B extends NullableResource<infer R> ? ResourceOutput<R> | null : B extends object ? { -readonly [K in keyof B]: ResponseBodyOutput<B[K]>; } : never;
|
|
155
155
|
/**
|
|
156
156
|
* Output type of a whole response schema: the body output per declared status code.
|
|
157
157
|
*
|
|
@@ -159,9 +159,9 @@ type ResponseBodyOutput<B> = B extends string ? CastOutput<B> : B extends readon
|
|
|
159
159
|
* type LoginResponses = ResponseSchemaOutput<typeof loginSchema>;
|
|
160
160
|
* // { 200: { user: UserJson; token: string }; 400: { error: string } }
|
|
161
161
|
*/
|
|
162
|
-
type ResponseSchemaOutput<S extends ResponseSchema> = { -readonly [K in keyof S]-?: S[K] extends {
|
|
162
|
+
export type ResponseSchemaOutput<S extends ResponseSchema> = { -readonly [K in keyof S]-?: S[K] extends {
|
|
163
163
|
body: infer B;
|
|
164
|
-
} ? ResponseBodyOutput<B> : never };
|
|
164
|
+
} ? ResponseBodyOutput<B> : never; };
|
|
165
165
|
//#endregion
|
|
166
|
-
export {
|
|
166
|
+
export {};
|
|
167
167
|
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../../../../packages/core/src/resource/types.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../../../../packages/core/src/resource/types.ts"],"mappings":";;;;;;;YAMY;;;;;;;;;;YAsBA;;;;;;;YAQA,mBACR,iCACG,qCACA,oCACA;YAEK;EACV;EACA,QAAQ,eAAe;;YAGb,sBACR,mBACA,sBACA,wBACA,KAAK,uBACL,oBACC,gCACQ,oBACT,uBACA,wBACE,YAAY,UAAU;YAEhB,iBAAiB,eAAe;YAEhC;;;;EAKN;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;;;;;;;;YAiBM,oBACR,mBACA,uBACC,uBACD,iBAAiB;GACd,cAAc;;;;;;YAMT,oBACT,cAAc;EACb;KAAS,cAAc;;;;;;KAOtB,aAAa,mBAAmB,cAAc;;;;;;;;YASvC,eAAe,oBAAoB,kFAO3C,gDAEE,gCAEE,qBACE,0BACA,gCAEE;EACI;EAAa;EAAgB;EAAmB;;;;;;;;;;;;YAapD,WAAW,oBAAoB,mBAAmB,SAC1D,eAAe,cACf,mBAAmB,QACjB,eAAe,OACf,mBAAmB,OACjB,eAAe,YACf,eAAe;;;;;;;YAQX,YAAY,GAAG,aAAa,iBAAiB,kBAAkB,mBACvE,iBAAiB,MAAM,QACvB,qBACE,iBAAiB,MAAM,UACvB,mBACE,WAAW,KACX,UAAU,uBAAuB,KAC/B,YAAY,GAAG,eACf,4BAA4B;EAAkB,gBAAgB;KAC5D,aAAa,OACb,kCAAkC,oBAChC,WAAW,KACX,UAAU,iCAER,UAAU,WAAW,KACnB,YAAY,GAAG,QACf;WACa;WACA,cAAc,aAAa;IAEtC,iBAAiB,MAAM,UACvB,mBAAkB;EAAkB,gBAAgB;KAClD,aAAa,KACb,eAAc,sBAAsB,KAClC,aAAa;;;;;;;;YAUzB,iBAAiB,UAAU,gBAAgB,aAAa,iBAAiB,kBACxE,WAAW,IAAI,YAAY,EAAE,IAAI;;;;;;;;YAUlC,eAAe,KAAK,mBAAkB;EAAkB,gBAAgB;KAChF,IACA;EAAY,gBAAgB;IAC1B;;;;;;;;;;YAYM,mBAAmB,KAAK,mBAChC,WAAW,KACX,0BAA0B,KACxB,eAAe,OACf,mBAAkB,2BAChB,eAAe,KACf,UAAU,uBAAuB,KAC/B,eAAe,YACf,gCACe,WAAW,IAAI,mBAAmB,EAAE;;;;;;;;YAUjD,qBAAqB,UAAU,+BAC9B,WAAW,MAAM,EAAE;EAAa,YAAY;IAAM,mBAAmB"}
|
package/esm/restful/index.d.mts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import { Restful } from "./restful.mjs";
|
|
1
|
+
import { Restful } from "./restful.mjs";
|
|
2
|
+
export { Restful };
|
package/esm/restful/index.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Response } from "../http/response.mjs";
|
|
2
2
|
import { Request } from "../http/request.mjs";
|
|
3
|
+
import "../http/index.mjs";
|
|
3
4
|
import { HttpContext, RestfulMiddleware, RouteResource } from "../router/types.mjs";
|
|
5
|
+
import "../router/index.mjs";
|
|
4
6
|
import { RepositoryManager } from "../repositories/repository.manager.mjs";
|
|
7
|
+
import "../repositories/index.mjs";
|
|
5
8
|
import { Model } from "@warlock.js/cascade";
|
|
6
9
|
import { GenericObject } from "@mongez/reinforcements";
|
|
7
|
-
|
|
8
10
|
//#region ../../packages/core/src/restful/restful.d.ts
|
|
9
|
-
declare abstract class Restful<T extends Model> implements RouteResource {
|
|
11
|
+
export declare abstract class Restful<T extends Model> implements RouteResource {
|
|
10
12
|
/**
|
|
11
13
|
* Middleware for each method
|
|
12
14
|
*/
|
|
@@ -40,52 +42,31 @@ declare abstract class Restful<T extends Model> implements RouteResource {
|
|
|
40
42
|
/**
|
|
41
43
|
* List records
|
|
42
44
|
*/
|
|
43
|
-
list({
|
|
44
|
-
request,
|
|
45
|
-
response
|
|
46
|
-
}: HttpContext): Promise<any[] | Response | Record<string, any>>;
|
|
45
|
+
list({ request, response }: HttpContext): Promise<any[] | Record<string, any> | Response>;
|
|
47
46
|
/**
|
|
48
47
|
* Get single record
|
|
49
48
|
*/
|
|
50
|
-
get({
|
|
51
|
-
request,
|
|
52
|
-
response
|
|
53
|
-
}: HttpContext): Promise<any[] | Response | Record<string, any>>;
|
|
49
|
+
get({ request, response }: HttpContext): Promise<any[] | Record<string, any> | Response>;
|
|
54
50
|
/**
|
|
55
51
|
* Create a new record
|
|
56
52
|
*/
|
|
57
|
-
create({
|
|
58
|
-
request,
|
|
59
|
-
response
|
|
60
|
-
}: HttpContext): Promise<any>;
|
|
53
|
+
create({ request, response }: HttpContext): Promise<any>;
|
|
61
54
|
/**
|
|
62
55
|
* Update record
|
|
63
56
|
*/
|
|
64
|
-
update({
|
|
65
|
-
request,
|
|
66
|
-
response
|
|
67
|
-
}: HttpContext): Promise<any>;
|
|
57
|
+
update({ request, response }: HttpContext): Promise<any>;
|
|
68
58
|
/**
|
|
69
59
|
* Patch record
|
|
70
60
|
*/
|
|
71
|
-
patch({
|
|
72
|
-
request,
|
|
73
|
-
response
|
|
74
|
-
}: HttpContext): Promise<any>;
|
|
61
|
+
patch({ request, response }: HttpContext): Promise<any>;
|
|
75
62
|
/**
|
|
76
63
|
* Delete record
|
|
77
64
|
*/
|
|
78
|
-
delete({
|
|
79
|
-
request,
|
|
80
|
-
response
|
|
81
|
-
}: HttpContext): Promise<any[] | Response | Record<string, any>>;
|
|
65
|
+
delete({ request, response }: HttpContext): Promise<any[] | Record<string, any> | Response>;
|
|
82
66
|
/**
|
|
83
67
|
* Bulk delete records
|
|
84
68
|
*/
|
|
85
|
-
bulkDelete({
|
|
86
|
-
request,
|
|
87
|
-
response
|
|
88
|
-
}: HttpContext): Promise<any[] | Response | Record<string, any>>;
|
|
69
|
+
bulkDelete({ request, response }: HttpContext): Promise<any[] | Record<string, any> | Response>;
|
|
89
70
|
/**
|
|
90
71
|
* Before create
|
|
91
72
|
*/
|
|
@@ -136,8 +117,7 @@ declare abstract class Restful<T extends Model> implements RouteResource {
|
|
|
136
117
|
* Call middleware for the given method
|
|
137
118
|
*
|
|
138
119
|
*/
|
|
139
|
-
protected callMiddleware(method: string, request: Request, response: Response, _record?: any): Promise<any[] |
|
|
120
|
+
protected callMiddleware(method: string, request: Request, response: Response, _record?: any): Promise<any[] | Record<string, any> | Response | undefined>;
|
|
140
121
|
}
|
|
141
122
|
//#endregion
|
|
142
|
-
export { Restful };
|
|
143
123
|
//# sourceMappingURL=restful.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restful.d.mts","names":[],"sources":["../../../../../../../../packages/core/src/restful/restful.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"restful.d.mts","names":[],"sources":["../../../../../../../../packages/core/src/restful/restful.ts"],"mappings":";;;;;;;;;;8BASsB,QAAQ,UAAU,kBAAkB;;;;YAI9C,YAAY;;;;YAKZ;;;;YAKA;;;;qBAKS,YAAY,kBAAkB;;;;YAKvC,UAAU;;;;;;EAYb;;;;EAKM,KAAK,aAAU,QAAA;;;;EAQf,OAAO,SAAS,YAAY,cAAW,gBAAA,sBAAA;;;;EAkCvC,MAAM,SAAS,YAAY,cAAW,gBAAA,sBAAA;;;;EAyBtC,SAAS,SAAS,YAAY,cAAW;;;;EAsDzC,SAAS,SAAS,YAAY,cAAW;;;;EAkDzC,QAAQ,SAAS,YAAY,cAAW;;;;EAkDxC,SAAS,SAAS,YAAY,cAAW,gBAAA,sBAAA;;;;EAiCzC,aAAa,SAAS,YAAY,cAAW,gBAAA,sBAAA;;;;YA+C1C,aAAa,UAAU,SAAS,WAAW,UAAU,SAAS,IAAI;;;;YAOlE,SAAS,UAAU,SAAS,WAAW,UAAU,SAAS,IAAI;;;;YAO9D,aACd,UAAU,SACV,WAAW,UACX,SAAS,GACT,aAAa,IACZ;;;;YAOa,SACd,UAAU,SACV,WAAW,UACX,SAAS,GACT,YAAY,IACX;;;;YAOa,aAAa,UAAU,SAAS,WAAW,UAAU,SAAS,IAAI;;;;YAOlE,SAAS,UAAU,SAAS,WAAW,UAAU,SAAS,IAAI;;;;YAO9D,YACd,UAAU,SACV,WAAW,UACX,SAAS,GACT,aAAa,IACZ;;;;YAOa,QACd,UAAU,SACV,WAAW,UACX,SAAS,GACT,YAAY,IACX;;;;YAOa,WACd,UAAU,SACV,WAAW,UACX,UAAU,GACV,aAAa,IACZ;;;;YAOa,OACd,UAAU,SACV,WAAW,UACX,SAAS,GACT,aAAa,IACZ;;;;;;YASO,QAAQ,uCAAuC,SAAS,UAAU;;;;;YA6B5D,eACd,gBACA,SAAS,SACT,UAAU,UACV,gBAAa,gBAAA,sBAAA"}
|
package/esm/router/index.d.mts
CHANGED
|
@@ -6,4 +6,5 @@ import { matchesDerivedRouteName, routeNameMethodSuffix } from "./route-name-met
|
|
|
6
6
|
import { RouteNameTakenError } from "./route-name-taken-error.mjs";
|
|
7
7
|
import { RouteRegistry } from "./route-registry.mjs";
|
|
8
8
|
import { Router, router } from "./router.mjs";
|
|
9
|
-
import { AUTH_GUARD_MARKER, isAuthGuardMiddleware, isUnguardedMutatingRoute, markAuthGuard, reportUnguardedMutatingRoutes, resetUnguardedRouteReports } from "./unguarded-route-diagnostics.mjs";
|
|
9
|
+
import { AUTH_GUARD_MARKER, isAuthGuardMiddleware, isUnguardedMutatingRoute, markAuthGuard, reportUnguardedMutatingRoutes, resetUnguardedRouteReports } from "./unguarded-route-diagnostics.mjs";
|
|
10
|
+
export { AUTH_GUARD_MARKER, GroupedRoutesOptions, HttpContext, Middleware, MiddlewareResponse, NamedApiRoute, NamedApiRoutesOptions, PartialPick, PositionalHandlerSuspect, RequestControllerContract, RequestHandler, RequestHandlerType, RequestHandlerValidation, RequestMethod, ResourceMethod, RestfulMiddleware, Route, RouteNameTakenError, RouteOptions, RouteRateLimitOptions, RouteRegistry, RouteResource, Router, RouterGroupCallback, RouterStacks, StaticMountOptions, ValidationFailureContext, ValidationFailureHandler, ValidationFailureResponse, clearPositionalHandlerSuspects, describePositionalHandlerSuspect, forgetPositionalHandlerSuspects, inspectHandlerSignature, isAuthGuardMiddleware, isUnguardedMutatingRoute, listPositionalHandlerSuspects, looksLikePositionalHandler, markAuthGuard, matchesDerivedRouteName, normalizeRequestPath, normalizeRoutePath, reportPositionalHandlerSuspects, reportUnguardedMutatingRoutes, resetUnguardedRouteReports, routeNameMethodSuffix, router };
|
package/esm/router/index.mjs
CHANGED
|
@@ -7,4 +7,4 @@ import { RouteRegistry } from "./route-registry.mjs";
|
|
|
7
7
|
import { AUTH_GUARD_MARKER, isAuthGuardMiddleware, isUnguardedMutatingRoute, markAuthGuard, reportUnguardedMutatingRoutes, resetUnguardedRouteReports } from "./unguarded-route-diagnostics.mjs";
|
|
8
8
|
import { Router, router } from "./router.mjs";
|
|
9
9
|
|
|
10
|
-
export {
|
|
10
|
+
export { AUTH_GUARD_MARKER, RouteNameTakenError, RouteRegistry, Router, clearPositionalHandlerSuspects, describePositionalHandlerSuspect, forgetPositionalHandlerSuspects, inspectHandlerSignature, isAuthGuardMiddleware, isUnguardedMutatingRoute, listPositionalHandlerSuspects, looksLikePositionalHandler, markAuthGuard, matchesDerivedRouteName, normalizeRequestPath, normalizeRoutePath, reportPositionalHandlerSuspects, reportUnguardedMutatingRoutes, resetUnguardedRouteReports, routeNameMethodSuffix, router };
|
|
@@ -30,7 +30,8 @@ async function importResourceNamespaces(files, onWarn) {
|
|
|
30
30
|
* cannot be imported is reported once through `onWarn` and left out of the map.
|
|
31
31
|
*/
|
|
32
32
|
async function collectResourceExportMap(files, onWarn) {
|
|
33
|
-
|
|
33
|
+
const namespaces = await importResourceNamespaces([...files].filter(isResourceFile), onWarn);
|
|
34
|
+
return buildResourceMap(namespaces);
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Named API route snapshots, with a `response` type map on every route whose handler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"named-api-routes-with-responses.mjs","names":[],"sources":["../../../../../../../../packages/core/src/router/named-api-routes-with-responses.ts"],"sourcesContent":["import { pathToFileURL } from \"node:url\";\nimport { importAppModule } from \"../loader/app-module-importer\";\nimport {\n buildResourceMap,\n createResourceTypeResolver,\n describeResponseSchemaTypes,\n type ResourceModuleExport,\n type ResourceModuleNamespace,\n type ResourceTypeResolver,\n} from \"./response-schema-types\";\nimport { router } from \"./router\";\nimport type { NamedApiRoute } from \"./types\";\n\nconst RESOURCE_FILE_PATTERN = /(^|\\/)src\\/.*\\.resource\\.tsx?$/;\n\nexport type ResourceSourceFile = Readonly<{\n absolutePath: string;\n relativePath: string;\n}>;\n\nexport type NamedApiRoutesWithResponsesOptions = Readonly<{\n /**\n * Application root, the folder that contains `.warlock/typings/`.\n */\n appRoot: string;\n /**\n * Every file the orchestrator knows about. `*.resource.ts(x)` files under `src/` are\n * imported to map resource classes back to their exports.\n */\n files: Iterable<ResourceSourceFile>;\n /**\n * Receives a human readable warning (unmapped resource, unreadable resource module).\n */\n onWarn?: (message: string) => void;\n}>;\n\nfunction isResourceFile(file: ResourceSourceFile): boolean {\n return RESOURCE_FILE_PATTERN.test(file.relativePath.replace(/\\\\/g, \"/\"));\n}\n\nasync function importResourceNamespaces(\n files: readonly ResourceSourceFile[],\n onWarn: ((message: string) => void) | undefined,\n): Promise<ResourceModuleNamespace[]> {\n const namespaces: ResourceModuleNamespace[] = [];\n\n for (const file of files) {\n try {\n const namespace = (await importAppModule(pathToFileURL(file.absolutePath).href)) as Record<\n string,\n unknown\n >;\n\n namespaces.push({ file: file.absolutePath, namespace });\n } catch (error) {\n onWarn?.(\n `Could not import ${file.relativePath} to type API responses: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n }\n\n return namespaces;\n}\n\n/**\n * Identity map from every resource class exported by a `*.resource.ts(x)` file under\n * `src/` to the module export it came from.\n *\n * The modules are imported through the same importer the routes used, so a resource class\n * found in a `responseSchema` is the very instance exported by its module. A module that\n * cannot be imported is reported once through `onWarn` and left out of the map.\n */\nexport async function collectResourceExportMap(\n files: Iterable<ResourceSourceFile>,\n onWarn?: (message: string) => void,\n): Promise<Map<unknown, ResourceModuleExport>> {\n const namespaces = await importResourceNamespaces([...files].filter(isResourceFile), onWarn);\n\n return buildResourceMap(namespaces);\n}\n\n/**\n * Named API route snapshots, with a `response` type map on every route whose handler\n * declares `responseSchema`.\n *\n * Resource modules are imported only when at least one route declares a schema, through\n * the same importer the routes used, so a resource class seen in a schema is the very\n * instance exported by its module. Never throws: if anything fails the routes come back\n * without `response` (and the failure is reported once through `onWarn`).\n */\nexport async function collectNamedApiRoutesWithResponses(\n options: NamedApiRoutesWithResponsesOptions,\n): Promise<readonly NamedApiRoute[]> {\n try {\n const declaresSchema = router.list().some((route) => route.handler?.responseSchema);\n\n if (!declaresSchema) return router.getNamedApiRoutes();\n\n const resolveResource: ResourceTypeResolver = createResourceTypeResolver(\n await collectResourceExportMap(options.files, options.onWarn),\n options.appRoot,\n );\n\n return router.getNamedApiRoutes({\n resolveResponse: (schema, route) =>\n describeResponseSchemaTypes(schema, resolveResource, (fieldPath) => {\n options.onWarn?.(\n `Route \"${route.name}\" (${route.method} ${route.path}): response ${fieldPath} is a resource that is not exported from a *.resource.ts file, typed as unknown.`,\n );\n }),\n });\n } catch (error) {\n options.onWarn?.(\n `Could not type API responses: ${error instanceof Error ? error.message : String(error)}`,\n );\n\n return router.getNamedApiRoutes();\n }\n}\n"],"mappings":";;;;;;AAaA,MAAM,wBAAwB;AAuB9B,SAAS,eAAe,MAAmC;CACzD,OAAO,sBAAsB,KAAK,KAAK,aAAa,QAAQ,OAAO,GAAG,CAAC;AACzE;AAEA,eAAe,yBACb,OACA,QACoC;CACpC,MAAM,aAAwC,CAAC;CAE/C,KAAK,MAAM,QAAQ,OACjB,IAAI;EACF,MAAM,YAAa,MAAM,gBAAgB,cAAc,KAAK,YAAY,CAAC,CAAC,IAAI;EAK9E,WAAW,KAAK;GAAE,MAAM,KAAK;GAAc;EAAU,CAAC;CACxD,SAAS,OAAO;EACd,SACE,oBAAoB,KAAK,aAAa,0BACpC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAEzD;CACF;CAGF,OAAO;AACT;;;;;;;;;AAUA,eAAsB,yBACpB,OACA,QAC6C;
|
|
1
|
+
{"version":3,"file":"named-api-routes-with-responses.mjs","names":[],"sources":["../../../../../../../../packages/core/src/router/named-api-routes-with-responses.ts"],"sourcesContent":["import { pathToFileURL } from \"node:url\";\nimport { importAppModule } from \"../loader/app-module-importer\";\nimport {\n buildResourceMap,\n createResourceTypeResolver,\n describeResponseSchemaTypes,\n type ResourceModuleExport,\n type ResourceModuleNamespace,\n type ResourceTypeResolver,\n} from \"./response-schema-types\";\nimport { router } from \"./router\";\nimport type { NamedApiRoute } from \"./types\";\n\nconst RESOURCE_FILE_PATTERN = /(^|\\/)src\\/.*\\.resource\\.tsx?$/;\n\nexport type ResourceSourceFile = Readonly<{\n absolutePath: string;\n relativePath: string;\n}>;\n\nexport type NamedApiRoutesWithResponsesOptions = Readonly<{\n /**\n * Application root, the folder that contains `.warlock/typings/`.\n */\n appRoot: string;\n /**\n * Every file the orchestrator knows about. `*.resource.ts(x)` files under `src/` are\n * imported to map resource classes back to their exports.\n */\n files: Iterable<ResourceSourceFile>;\n /**\n * Receives a human readable warning (unmapped resource, unreadable resource module).\n */\n onWarn?: (message: string) => void;\n}>;\n\nfunction isResourceFile(file: ResourceSourceFile): boolean {\n return RESOURCE_FILE_PATTERN.test(file.relativePath.replace(/\\\\/g, \"/\"));\n}\n\nasync function importResourceNamespaces(\n files: readonly ResourceSourceFile[],\n onWarn: ((message: string) => void) | undefined,\n): Promise<ResourceModuleNamespace[]> {\n const namespaces: ResourceModuleNamespace[] = [];\n\n for (const file of files) {\n try {\n const namespace = (await importAppModule(pathToFileURL(file.absolutePath).href)) as Record<\n string,\n unknown\n >;\n\n namespaces.push({ file: file.absolutePath, namespace });\n } catch (error) {\n onWarn?.(\n `Could not import ${file.relativePath} to type API responses: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n }\n\n return namespaces;\n}\n\n/**\n * Identity map from every resource class exported by a `*.resource.ts(x)` file under\n * `src/` to the module export it came from.\n *\n * The modules are imported through the same importer the routes used, so a resource class\n * found in a `responseSchema` is the very instance exported by its module. A module that\n * cannot be imported is reported once through `onWarn` and left out of the map.\n */\nexport async function collectResourceExportMap(\n files: Iterable<ResourceSourceFile>,\n onWarn?: (message: string) => void,\n): Promise<Map<unknown, ResourceModuleExport>> {\n const namespaces = await importResourceNamespaces([...files].filter(isResourceFile), onWarn);\n\n return buildResourceMap(namespaces);\n}\n\n/**\n * Named API route snapshots, with a `response` type map on every route whose handler\n * declares `responseSchema`.\n *\n * Resource modules are imported only when at least one route declares a schema, through\n * the same importer the routes used, so a resource class seen in a schema is the very\n * instance exported by its module. Never throws: if anything fails the routes come back\n * without `response` (and the failure is reported once through `onWarn`).\n */\nexport async function collectNamedApiRoutesWithResponses(\n options: NamedApiRoutesWithResponsesOptions,\n): Promise<readonly NamedApiRoute[]> {\n try {\n const declaresSchema = router.list().some((route) => route.handler?.responseSchema);\n\n if (!declaresSchema) return router.getNamedApiRoutes();\n\n const resolveResource: ResourceTypeResolver = createResourceTypeResolver(\n await collectResourceExportMap(options.files, options.onWarn),\n options.appRoot,\n );\n\n return router.getNamedApiRoutes({\n resolveResponse: (schema, route) =>\n describeResponseSchemaTypes(schema, resolveResource, (fieldPath) => {\n options.onWarn?.(\n `Route \"${route.name}\" (${route.method} ${route.path}): response ${fieldPath} is a resource that is not exported from a *.resource.ts file, typed as unknown.`,\n );\n }),\n });\n } catch (error) {\n options.onWarn?.(\n `Could not type API responses: ${error instanceof Error ? error.message : String(error)}`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ACF"}
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* slash optional. The root path is already canonical and must never become an
|
|
9
9
|
* empty string.
|
|
10
10
|
*/
|
|
11
|
-
declare function normalizeRequestPath(pathname: string): string;
|
|
11
|
+
export declare function normalizeRequestPath(pathname: string): string;
|
|
12
12
|
//#endregion
|
|
13
|
-
export { normalizeRequestPath };
|
|
14
13
|
//# sourceMappingURL=normalize-request-path.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-request-path.d.mts","names":[],"sources":["../../../../../../../../packages/core/src/router/normalize-request-path.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize-request-path.d.mts","names":[],"sources":["../../../../../../../../packages/core/src/router/normalize-request-path.ts"],"mappings":";;;;;;;;;;wBASgB,qBAAqB"}
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
* @example normalizeRoutePath("/users/", "/:id") // "/users/:id"
|
|
23
23
|
* @example normalizeRoutePath("") // "/"
|
|
24
24
|
*/
|
|
25
|
-
declare function normalizeRoutePath(...segments: string[]): string;
|
|
25
|
+
export declare function normalizeRoutePath(...segments: string[]): string;
|
|
26
26
|
//#endregion
|
|
27
|
-
export { normalizeRoutePath };
|
|
28
27
|
//# sourceMappingURL=normalize-route-path.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-route-path.d.mts","names":[],"sources":["../../../../../../../../packages/core/src/router/normalize-route-path.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize-route-path.d.mts","names":[],"sources":["../../../../../../../../packages/core/src/router/normalize-route-path.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;wBAyBgB,sBAAsB"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Route } from "./types.mjs";
|
|
2
2
|
import { log } from "@warlock.js/logger";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/core/src/router/positional-handler-diagnostics.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* One route whose handler looks like it was written for v4.
|
|
7
6
|
*/
|
|
8
|
-
type PositionalHandlerSuspect = {
|
|
9
|
-
/** HTTP method the route was registered under. */
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
export type PositionalHandlerSuspect = {
|
|
8
|
+
/** HTTP method the route was registered under. */
|
|
9
|
+
method: Route["method"];
|
|
10
|
+
/** Full route path, prefixes already applied. */
|
|
11
|
+
path: string;
|
|
12
|
+
/** Handler function name, or `"(anonymous)"` when it has none. */
|
|
13
|
+
handlerName: string;
|
|
14
|
+
/** Route file the route came from, when the router knows it. */
|
|
12
15
|
sourceFile: string;
|
|
13
16
|
};
|
|
14
17
|
/**
|
|
@@ -43,7 +46,7 @@ type PositionalHandlerSuspect = {
|
|
|
43
46
|
* `({ … })` form are essentially nil, and every miss simply leaves today's
|
|
44
47
|
* behaviour in place.
|
|
45
48
|
*/
|
|
46
|
-
declare function looksLikePositionalHandler(handler: unknown): boolean;
|
|
49
|
+
export declare function looksLikePositionalHandler(handler: unknown): boolean;
|
|
47
50
|
/**
|
|
48
51
|
* Inspect one route's handler as it registers, recording it when it looks like
|
|
49
52
|
* the v4 positional form. Called from `Router.add`, so the cost is paid once per
|
|
@@ -52,7 +55,7 @@ declare function looksLikePositionalHandler(handler: unknown): boolean;
|
|
|
52
55
|
* Deliberately total: any unexpected failure in the heuristic is swallowed, so a
|
|
53
56
|
* diagnostic can never be the reason a route fails to register.
|
|
54
57
|
*/
|
|
55
|
-
declare function inspectHandlerSignature(handler: unknown, route: {
|
|
58
|
+
export declare function inspectHandlerSignature(handler: unknown, route: {
|
|
56
59
|
method: Route["method"];
|
|
57
60
|
path: string;
|
|
58
61
|
sourceFile: string;
|
|
@@ -60,31 +63,30 @@ declare function inspectHandlerSignature(handler: unknown, route: {
|
|
|
60
63
|
/**
|
|
61
64
|
* Every suspect recorded so far, in registration order.
|
|
62
65
|
*/
|
|
63
|
-
declare function listPositionalHandlerSuspects(): readonly PositionalHandlerSuspect[];
|
|
66
|
+
export declare function listPositionalHandlerSuspects(): readonly PositionalHandlerSuspect[];
|
|
64
67
|
/**
|
|
65
68
|
* Drop the suspects belonging to a route file. Kept in step with
|
|
66
69
|
* `Router.removeRoutesBySourceFile` so an HMR reload that fixes a handler does
|
|
67
70
|
* not keep reporting the version it replaced.
|
|
68
71
|
*/
|
|
69
|
-
declare function forgetPositionalHandlerSuspects(sourceFile: string): void;
|
|
72
|
+
export declare function forgetPositionalHandlerSuspects(sourceFile: string): void;
|
|
70
73
|
/**
|
|
71
74
|
* Drop every recorded suspect. Intended for tests, which share the router
|
|
72
75
|
* singleton.
|
|
73
76
|
*/
|
|
74
|
-
declare function clearPositionalHandlerSuspects(): void;
|
|
77
|
+
export declare function clearPositionalHandlerSuspects(): void;
|
|
75
78
|
/**
|
|
76
79
|
* The one-line diagnostic for a single route. Written for someone who has never
|
|
77
80
|
* read Warlock's internals: it names the handler, the route, what is wrong, and
|
|
78
81
|
* the exact edit that fixes it.
|
|
79
82
|
*/
|
|
80
|
-
declare function describePositionalHandlerSuspect(suspect: PositionalHandlerSuspect): string;
|
|
83
|
+
export declare function describePositionalHandlerSuspect(suspect: PositionalHandlerSuspect): string;
|
|
81
84
|
/**
|
|
82
85
|
* The full boot-time warning: every suspect, once, in one entry.
|
|
83
86
|
*
|
|
84
87
|
* One boot, one list — not one warning per route, and emphatically not one 500
|
|
85
88
|
* per request. Returns the reported suspects so callers can assert on them.
|
|
86
89
|
*/
|
|
87
|
-
declare function reportPositionalHandlerSuspects(logger?: Pick<typeof log, "warn">): PositionalHandlerSuspect[];
|
|
90
|
+
export declare function reportPositionalHandlerSuspects(logger?: Pick<typeof log, "warn">): PositionalHandlerSuspect[];
|
|
88
91
|
//#endregion
|
|
89
|
-
export { PositionalHandlerSuspect, clearPositionalHandlerSuspects, describePositionalHandlerSuspect, forgetPositionalHandlerSuspects, inspectHandlerSignature, listPositionalHandlerSuspects, looksLikePositionalHandler, reportPositionalHandlerSuspects };
|
|
90
92
|
//# sourceMappingURL=positional-handler-diagnostics.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positional-handler-diagnostics.d.mts","names":[],"sources":["../../../../../../../../packages/core/src/router/positional-handler-diagnostics.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"positional-handler-diagnostics.d.mts","names":[],"sources":["../../../../../../../../packages/core/src/router/positional-handler-diagnostics.ts"],"mappings":";;;;;;YAoCY;;EAEV,QAAQ;;EAGR;;EAGA;;EAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA6Kc,2BAA2B;;;;;;;;;wBAmC3B,wBACd,kBACA;EAAS,QAAQ;EAAiB;EAAc;;;;;wBAmBlC,0CAA0C;;;;;;wBAS1C,gCAAgC;;;;;wBAchC;;;;;;wBASA,iCAAiC,SAAS;;;;;;;wBAc1C,gCAAgC,SAAQ,YAAY,eAAkB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildRouteRateLimit } from "./build-route-rate-limit.mjs";
|
|
2
|
-
import
|
|
2
|
+
import baseConfig from "@mongez/config";
|
|
3
3
|
|
|
4
4
|
//#region ../../packages/core/src/router/resolve-route-rate-limit.ts
|
|
5
5
|
/**
|
|
@@ -10,7 +10,7 @@ import config from "@mongez/config";
|
|
|
10
10
|
* opts them back in.
|
|
11
11
|
*/
|
|
12
12
|
function staticFilesAreRateLimited() {
|
|
13
|
-
return
|
|
13
|
+
return baseConfig.get("http.rateLimit.staticFiles") === true;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Resolve a static mount's rate-limit setting: `true` keeps it under the
|
|
@@ -43,5 +43,5 @@ function resolveExplicitRateLimit(rateLimit) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
//#endregion
|
|
46
|
-
export { resolveRouteRateLimit, resolveStaticRateLimit };
|
|
46
|
+
export { resolveRouteRateLimit, resolveStaticRateLimit, staticFilesAreRateLimited };
|
|
47
47
|
//# sourceMappingURL=resolve-route-rate-limit.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-route-rate-limit.mjs","names":[],"sources":["../../../../../../../../packages/core/src/router/resolve-route-rate-limit.ts"],"sourcesContent":["import config from \"@mongez/config\";\nimport { buildRouteRateLimit } from \"./build-route-rate-limit\";\nimport type { Route, RouteRateLimitOptions } from \"./types\";\n\n/**\n * What `@fastify/rate-limit` reads from a route's `config.rateLimit`:\n * `false` exempts the route, an object gives it its own limit and bucket, and\n * `undefined` leaves it under the global policy.\n */\nexport type RouteRateLimitSetting = false | Record<string, unknown> | undefined;\n\n/**\n * Whether static files (the public folder, `router.directory()` mounts and\n * `router.file()` routes) count against the global limiter. Off by default:\n * one page load fetches many assets, which would spend a client's quota on\n * files instead of pages and API calls. `http.rateLimit.staticFiles: true`\n * opts them back in.\n */\nexport function staticFilesAreRateLimited(): boolean {\n return config.get(\"http.rateLimit.staticFiles\") === true;\n}\n\n/**\n * Resolve a static mount's rate-limit setting: `true` keeps it under the\n * global limiter, `false` exempts it, an object gives it its own limit, and\n * leaving it unset follows `http.rateLimit.staticFiles`.\n */\nexport function resolveStaticRateLimit(\n rateLimit: RouteRateLimitOptions | boolean | undefined,\n): RouteRateLimitSetting {\n if (rateLimit === undefined) {\n return staticFilesAreRateLimited() ? undefined : false;\n }\n\n return resolveExplicitRateLimit(rateLimit);\n}\n\n/**\n * Resolve a router route's rate-limit setting, identically for production\n * registration and the development wildcard dispatcher.\n *\n * Precedence: the route's own `rateLimit` option, then a\n * `serverOptions.config.rateLimit` passed through to Fastify, then the\n * static-file default for `router.file()` routes, then the global policy.\n */\nexport function resolveRouteRateLimit(\n route: Pick<Route, \"rateLimit\" | \"serverOptions\" | \"$staticFile\">,\n): RouteRateLimitSetting {\n if (route.rateLimit !== undefined) {\n return resolveExplicitRateLimit(route.rateLimit);\n }\n\n const passedThrough: unknown = (\n route.serverOptions?.config as { rateLimit?: unknown } | undefined\n )?.rateLimit;\n\n if (passedThrough === false) return false;\n\n if (typeof passedThrough === \"object\" && passedThrough !== null) {\n return passedThrough as Record<string, unknown>;\n }\n\n if (route.$staticFile) return resolveStaticRateLimit(undefined);\n\n return undefined;\n}\n\nfunction resolveExplicitRateLimit(\n rateLimit: RouteRateLimitOptions | boolean,\n): RouteRateLimitSetting {\n if (rateLimit === true) return undefined;\n\n if (rateLimit === false) return false;\n\n return buildRouteRateLimit(rateLimit);\n}\n"],"mappings":";;;;;;;;;;;AAkBA,SAAgB,4BAAqC;CACnD,
|
|
1
|
+
{"version":3,"file":"resolve-route-rate-limit.mjs","names":["config"],"sources":["../../../../../../../../packages/core/src/router/resolve-route-rate-limit.ts"],"sourcesContent":["import config from \"@mongez/config\";\nimport { buildRouteRateLimit } from \"./build-route-rate-limit\";\nimport type { Route, RouteRateLimitOptions } from \"./types\";\n\n/**\n * What `@fastify/rate-limit` reads from a route's `config.rateLimit`:\n * `false` exempts the route, an object gives it its own limit and bucket, and\n * `undefined` leaves it under the global policy.\n */\nexport type RouteRateLimitSetting = false | Record<string, unknown> | undefined;\n\n/**\n * Whether static files (the public folder, `router.directory()` mounts and\n * `router.file()` routes) count against the global limiter. Off by default:\n * one page load fetches many assets, which would spend a client's quota on\n * files instead of pages and API calls. `http.rateLimit.staticFiles: true`\n * opts them back in.\n */\nexport function staticFilesAreRateLimited(): boolean {\n return config.get(\"http.rateLimit.staticFiles\") === true;\n}\n\n/**\n * Resolve a static mount's rate-limit setting: `true` keeps it under the\n * global limiter, `false` exempts it, an object gives it its own limit, and\n * leaving it unset follows `http.rateLimit.staticFiles`.\n */\nexport function resolveStaticRateLimit(\n rateLimit: RouteRateLimitOptions | boolean | undefined,\n): RouteRateLimitSetting {\n if (rateLimit === undefined) {\n return staticFilesAreRateLimited() ? undefined : false;\n }\n\n return resolveExplicitRateLimit(rateLimit);\n}\n\n/**\n * Resolve a router route's rate-limit setting, identically for production\n * registration and the development wildcard dispatcher.\n *\n * Precedence: the route's own `rateLimit` option, then a\n * `serverOptions.config.rateLimit` passed through to Fastify, then the\n * static-file default for `router.file()` routes, then the global policy.\n */\nexport function resolveRouteRateLimit(\n route: Pick<Route, \"rateLimit\" | \"serverOptions\" | \"$staticFile\">,\n): RouteRateLimitSetting {\n if (route.rateLimit !== undefined) {\n return resolveExplicitRateLimit(route.rateLimit);\n }\n\n const passedThrough: unknown = (\n route.serverOptions?.config as { rateLimit?: unknown } | undefined\n )?.rateLimit;\n\n if (passedThrough === false) return false;\n\n if (typeof passedThrough === \"object\" && passedThrough !== null) {\n return passedThrough as Record<string, unknown>;\n }\n\n if (route.$staticFile) return resolveStaticRateLimit(undefined);\n\n return undefined;\n}\n\nfunction resolveExplicitRateLimit(\n rateLimit: RouteRateLimitOptions | boolean,\n): RouteRateLimitSetting {\n if (rateLimit === true) return undefined;\n\n if (rateLimit === false) return false;\n\n return buildRouteRateLimit(rateLimit);\n}\n"],"mappings":";;;;;;;;;;;AAkBA,SAAgB,4BAAqC;CACnD,OAAOA,WAAO,IAAI,4BAA4B,MAAM;AACtD;;;;;;AAOA,SAAgB,uBACd,WACuB;CACvB,IAAI,cAAc,QAChB,OAAO,0BAA0B,IAAI,SAAY;CAGnD,OAAO,yBAAyB,SAAS;AAC3C;;;;;;;;;AAUA,SAAgB,sBACd,OACuB;CACvB,IAAI,MAAM,cAAc,QACtB,OAAO,yBAAyB,MAAM,SAAS;CAGjD,MAAM,iBACJ,MAAM,eAAe,OAAM,EAC1B;CAEH,IAAI,kBAAkB,OAAO,OAAO;CAEpC,IAAI,OAAO,kBAAkB,YAAY,kBAAkB,MACzD,OAAO;CAGT,IAAI,MAAM,aAAa,OAAO,uBAAuB,MAAS;AAGhE;AAEA,SAAS,yBACP,WACuB;CACvB,IAAI,cAAc,MAAM,OAAO;CAE/B,IAAI,cAAc,OAAO,OAAO;CAEhC,OAAO,oBAAoB,SAAS;AACtC"}
|