raiton 6.8.9-beta.25 → 6.11.0-beta.29
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 +67 -0
- package/README.md +65 -1
- package/benchmarks/README.md +31 -0
- package/benchmarks/ai-debug.json +145 -0
- package/benchmarks/ai-debug.md +64 -0
- package/benchmarks/latest.json +172 -0
- package/benchmarks/latest.md +66 -0
- package/build/bin/index.mjs +37621 -21866
- package/build/types/bin/bootstrapper.d.ts +2 -0
- package/build/types/bin/cli-output.d.ts +46 -0
- package/build/types/bin/cli-tools.d.ts +13 -0
- package/build/types/bin/cli.d.ts +3 -0
- package/build/types/bin/commands.registry.d.ts +4 -0
- package/build/types/bin/constants.d.ts +3 -0
- package/build/types/bin/file-utils.d.ts +21 -0
- package/build/types/bin/index.d.ts +2 -0
- package/build/types/bin/name-utils.d.ts +4 -0
- package/build/types/bin/project-utils.d.ts +12 -0
- package/build/types/commands/artifact.command.d.ts +7 -0
- package/build/types/commands/build.command.d.ts +8 -0
- package/build/types/commands/call.command.d.ts +10 -0
- package/build/types/commands/client.command.d.ts +7 -0
- package/build/types/commands/contract.command.d.ts +8 -0
- package/build/types/commands/debug.shared.d.ts +16 -0
- package/build/types/commands/develop.command.d.ts +9 -0
- package/build/types/commands/docs.command.d.ts +8 -0
- package/build/types/commands/doctor.command.d.ts +9 -0
- package/build/types/commands/explain.command.d.ts +8 -0
- package/build/types/commands/generate.command.d.ts +7 -0
- package/build/types/commands/inspect.command.d.ts +7 -0
- package/build/types/commands/mcp.command.d.ts +12 -0
- package/build/types/commands/new.command.d.ts +7 -0
- package/build/types/commands/openapi.command.d.ts +7 -0
- package/build/types/commands/requests.command.d.ts +8 -0
- package/build/types/commands/routes.command.d.ts +7 -0
- package/build/types/commands/start.command.d.ts +9 -0
- package/build/types/commands/verify.command.d.ts +8 -0
- package/build/types/commands/why.command.d.ts +7 -0
- package/build/types/contracts/decorators.d.ts +59 -0
- package/build/types/contracts/errors.d.ts +68 -0
- package/build/types/contracts/index.d.ts +4 -0
- package/build/types/contracts/schema.d.ts +83 -0
- package/build/types/contracts/typebox.d.ts +81 -0
- package/build/types/core/application.d.ts +45 -0
- package/build/types/core/artifacts/artifact.d.ts +3 -0
- package/build/types/core/artifacts/index.d.ts +1 -0
- package/build/types/core/artifacts/runner.d.ts +1 -0
- package/build/types/core/builder.d.ts +42 -0
- package/build/types/core/bytes.util.d.ts +3 -0
- package/build/types/core/command.d.ts +13 -0
- package/build/types/core/commands.d.ts +10 -0
- package/build/types/core/config/config.d.ts +27 -0
- package/build/types/core/config/define.d.ts +8 -0
- package/build/types/core/config/index.d.ts +3 -0
- package/build/types/core/config/schema.d.ts +24 -0
- package/build/types/core/context.d.ts +11 -0
- package/build/types/core/controller/builder.d.ts +26 -0
- package/build/types/core/controller/compiler.d.ts +2 -0
- package/build/types/core/controller/index.d.ts +4 -0
- package/build/types/core/controller/metadata.d.ts +3 -0
- package/build/types/core/controller/tracker.d.ts +9 -0
- package/build/types/core/directories.d.ts +10 -0
- package/build/types/core/guards.d.ts +11 -0
- package/build/types/core/helpers/index.d.ts +1 -0
- package/build/types/core/helpers/raiton.d.ts +1 -0
- package/build/types/core/hooks.d.ts +14 -0
- package/build/types/core/index.d.ts +17 -0
- package/build/types/core/injection/index.d.ts +1 -0
- package/build/types/core/injection/injection.d.ts +37 -0
- package/build/types/core/mcp/builder.d.ts +2 -0
- package/build/types/core/mcp/index.d.ts +3 -0
- package/build/types/core/mcp/metadata.d.ts +9 -0
- package/build/types/core/mcp/tracker.d.ts +9 -0
- package/build/types/core/middleware/compose.d.ts +8 -0
- package/build/types/core/middleware/index.d.ts +2 -0
- package/build/types/core/middleware/pipeline.d.ts +12 -0
- package/build/types/core/plugins/index.d.ts +2 -0
- package/build/types/core/plugins/plugin.d.ts +2 -0
- package/build/types/core/plugins/scope.d.ts +15 -0
- package/build/types/core/process.util.d.ts +1 -0
- package/build/types/core/raiton.d.ts +15 -0
- package/build/types/core/router/handler.d.ts +2 -0
- package/build/types/core/router/handler.utils.d.ts +37 -0
- package/build/types/core/router/index.d.ts +4 -0
- package/build/types/core/router/matcher.d.ts +50 -0
- package/build/types/core/router/route.d.ts +52 -0
- package/build/types/core/router/router.d.ts +23 -0
- package/build/types/core/scheduler/builder.d.ts +2 -0
- package/build/types/core/scheduler/cron.d.ts +32 -0
- package/build/types/core/scheduler/duration.d.ts +7 -0
- package/build/types/core/scheduler/index.d.ts +6 -0
- package/build/types/core/scheduler/manager.d.ts +47 -0
- package/build/types/core/scheduler/metadata.d.ts +8 -0
- package/build/types/core/scheduler/queue/backend.d.ts +42 -0
- package/build/types/core/scheduler/queue/index.d.ts +3 -0
- package/build/types/core/scheduler/queue/rabbitmq.backend.d.ts +37 -0
- package/build/types/core/scheduler/queue/redis.backend.d.ts +38 -0
- package/build/types/core/server.d.ts +9 -0
- package/build/types/core/socket/builder.d.ts +1 -0
- package/build/types/core/socket/index.d.ts +2 -0
- package/build/types/core/socket/metadata.d.ts +14 -0
- package/build/types/core/thread.d.ts +21 -0
- package/build/types/debug/cli.d.ts +33 -0
- package/build/types/debug/collector.d.ts +41 -0
- package/build/types/debug/collector.internal.d.ts +27 -0
- package/build/types/debug/config.d.ts +19 -0
- package/build/types/debug/examples.d.ts +43 -0
- package/build/types/debug/explain.d.ts +9 -0
- package/build/types/debug/index.d.ts +15 -0
- package/build/types/debug/invocation.d.ts +53 -0
- package/build/types/debug/journal.d.ts +49 -0
- package/build/types/debug/mcp-http.d.ts +17 -0
- package/build/types/debug/mcp.d.ts +14 -0
- package/build/types/debug/redaction.d.ts +48 -0
- package/build/types/debug/requests.d.ts +37 -0
- package/build/types/debug/runtime.d.ts +52 -0
- package/build/types/debug/session.d.ts +21 -0
- package/build/types/debug/source.d.ts +17 -0
- package/build/types/debug/surface.d.ts +10 -0
- package/build/types/debug/types.d.ts +271 -0
- package/build/types/debug/verify.d.ts +23 -0
- package/build/types/framework/artifacts.d.ts +20 -0
- package/build/types/framework/cache/cache.d.ts +84 -0
- package/build/types/framework/cache/cache.decorator.d.ts +21 -0
- package/build/types/framework/cache/etag.d.ts +62 -0
- package/build/types/framework/cache/index.d.ts +4 -0
- package/build/types/framework/cache/types.d.ts +89 -0
- package/build/types/framework/constants/decorators.constant.d.ts +28 -0
- package/build/types/framework/constants/index.d.ts +2 -0
- package/build/types/framework/constants/microservices.constant.d.ts +3 -0
- package/build/types/framework/controllers.d.ts +2 -0
- package/build/types/framework/data-transfer-object.d.ts +5 -0
- package/build/types/framework/decorators/access-guard.decorator.d.ts +1 -0
- package/build/types/framework/decorators/api-response.decorator.d.ts +66 -0
- package/build/types/framework/decorators/api.decorator.d.ts +160 -0
- package/build/types/framework/decorators/controllable.decorator.d.ts +3 -0
- package/build/types/framework/decorators/csrf-guard.decorator.d.ts +2 -0
- package/build/types/framework/decorators/csrf-token.decorator.d.ts +1 -0
- package/build/types/framework/decorators/guard.decorator.d.ts +2 -0
- package/build/types/framework/decorators/health-check.decorator.d.ts +17 -0
- package/build/types/framework/decorators/index.d.ts +15 -0
- package/build/types/framework/decorators/injection.decorator.d.ts +5 -0
- package/build/types/framework/decorators/mcp.decorator.d.ts +68 -0
- package/build/types/framework/decorators/middleware.decorator.d.ts +3 -0
- package/build/types/framework/decorators/parametrable.decorator.d.ts +9 -0
- package/build/types/framework/decorators/routable.decorator.d.ts +12 -0
- package/build/types/framework/decorators/route-interaction.decorator.d.ts +81 -0
- package/build/types/framework/decorators/scheduler.decorator.d.ts +54 -0
- package/build/types/framework/decorators/socket.decorator.d.ts +5 -0
- package/build/types/framework/encryption.d.ts +25 -0
- package/build/types/framework/enums/csrf.enum.d.ts +4 -0
- package/build/types/framework/enums/encrypted.enum.d.ts +20 -0
- package/build/types/framework/enums/event.message.enum.d.ts +4 -0
- package/build/types/framework/enums/http-method.enum.d.ts +10 -0
- package/build/types/framework/enums/http-parameters.enum.d.ts +11 -0
- package/build/types/framework/enums/http-status.enum.d.ts +64 -0
- package/build/types/framework/enums/index.d.ts +9 -0
- package/build/types/framework/enums/runtime.enum.d.ts +5 -0
- package/build/types/framework/enums/scheduler.enum.d.ts +21 -0
- package/build/types/framework/enums/timestamp.enum.d.ts +6 -0
- package/build/types/framework/env.d.ts +3 -0
- package/build/types/framework/errors/catalog.d.ts +57 -0
- package/build/types/framework/exceptions/http-exception.d.ts +18 -0
- package/build/types/framework/exceptions/index.d.ts +2 -0
- package/build/types/framework/exceptions/throwable.d.ts +76 -0
- package/build/types/framework/health-check.d.ts +42 -0
- package/build/types/framework/index.d.ts +20 -0
- package/build/types/framework/mcp/audit.d.ts +12 -0
- package/build/types/framework/mcp/conformance.d.ts +31 -0
- package/build/types/framework/mcp/handler.d.ts +11 -0
- package/build/types/framework/mcp/index.d.ts +5 -0
- package/build/types/framework/mcp/protocol.d.ts +17 -0
- package/build/types/framework/mcp/rate-limit.d.ts +10 -0
- package/build/types/framework/mcp/stdio.d.ts +40 -0
- package/build/types/framework/mcp/streamable-http.d.ts +17 -0
- package/build/types/framework/observability/index.d.ts +6 -0
- package/build/types/framework/observability/metrics.d.ts +23 -0
- package/build/types/framework/observability/plugin.d.ts +20 -0
- package/build/types/framework/observability/readiness.d.ts +9 -0
- package/build/types/framework/observability/request.d.ts +7 -0
- package/build/types/framework/observability/shutdown.d.ts +21 -0
- package/build/types/framework/observability/trace.d.ts +96 -0
- package/build/types/framework/parameter-bag.d.ts +14 -0
- package/build/types/framework/plugins/body-parser.plugin.d.ts +3 -0
- package/build/types/framework/plugins/dev.plugin.d.ts +12 -0
- package/build/types/framework/plugins/index.d.ts +5 -0
- package/build/types/framework/plugins/mcp.plugin.d.ts +15 -0
- package/build/types/framework/plugins/openapi.plugin.d.ts +58 -0
- package/build/types/framework/plugins/security/body-limit.d.ts +1 -0
- package/build/types/framework/plugins/security/cors.d.ts +10 -0
- package/build/types/framework/plugins/security/csrf.d.ts +2 -0
- package/build/types/framework/plugins/security/headers.d.ts +1 -0
- package/build/types/framework/plugins/security/index.d.ts +13 -0
- package/build/types/framework/plugins/security/method-guard.d.ts +1 -0
- package/build/types/framework/plugins/security/rate-limit.d.ts +5 -0
- package/build/types/framework/repositories.d.ts +5 -0
- package/build/types/framework/responses/error.d.ts +13 -0
- package/build/types/framework/responses/helpers.d.ts +7 -0
- package/build/types/framework/responses/http-throwable.d.ts +14 -0
- package/build/types/framework/responses/http.d.ts +13 -0
- package/build/types/framework/responses/index.d.ts +4 -0
- package/build/types/framework/runtime/bun/server.d.ts +2 -0
- package/build/types/framework/runtime/deno/server.d.ts +2 -0
- package/build/types/framework/runtime/index.d.ts +17 -0
- package/build/types/framework/runtime/node/reply.d.ts +12 -0
- package/build/types/framework/runtime/node/request.d.ts +33 -0
- package/build/types/framework/runtime/node/server.d.ts +2 -0
- package/build/types/framework/runtime/web/server.d.ts +1 -0
- package/build/types/framework/services.d.ts +5 -0
- package/build/types/framework/utilities/alias-path.util.d.ts +1 -0
- package/build/types/framework/utilities/artifact.util.d.ts +7 -0
- package/build/types/framework/utilities/callable.util.d.ts +1 -0
- package/build/types/framework/utilities/cookie.util.d.ts +1 -0
- package/build/types/framework/utilities/csrf.util.d.ts +26 -0
- package/build/types/framework/utilities/https.util.d.ts +49 -0
- package/build/types/framework/utilities/index.d.ts +12 -0
- package/build/types/framework/utilities/ip.util.d.ts +15 -0
- package/build/types/framework/utilities/json.util.d.ts +10 -0
- package/build/types/framework/utilities/openapi.utils.d.ts +7 -0
- package/build/types/framework/utilities/openapi.utils.impl.d.ts +18 -0
- package/build/types/framework/utilities/path.util.d.ts +3 -0
- package/build/types/framework/utilities/route-suggestion.util.d.ts +10 -0
- package/build/types/framework/utilities/url.util.d.ts +1 -0
- package/build/types/framework/utilities/utilities.util.d.ts +3 -0
- package/build/types/framework/utilities/validation.util.d.ts +8 -0
- package/build/types/framework/view-model.d.ts +4 -0
- package/build/types/generators/artifact.templates.d.ts +7 -0
- package/build/types/generators/index.d.ts +2 -0
- package/build/types/generators/project.templates.d.ts +21 -0
- package/build/types/manifest/client.d.ts +12 -0
- package/build/types/manifest/contract.d.ts +25 -0
- package/build/types/manifest/index.d.ts +5 -0
- package/build/types/manifest/introspect.d.ts +18 -0
- package/build/types/manifest/manifest.d.ts +18 -0
- package/build/types/manifest/schema.d.ts +241 -0
- package/build/types/requirements.d.ts +1 -0
- package/build/types/types/access-guards.d.ts +4 -0
- package/build/types/types/application.d.ts +32 -0
- package/build/types/types/artifact.d.ts +8 -0
- package/build/types/types/builder.d.ts +37 -0
- package/build/types/types/config.d.ts +112 -0
- package/build/types/types/controller.d.ts +27 -0
- package/build/types/types/contruct.d.ts +1 -0
- package/build/types/types/core.d.ts +11 -0
- package/build/types/types/csrf.d.ts +33 -0
- package/build/types/types/directory.d.ts +6 -0
- package/build/types/types/encryption.d.ts +14 -0
- package/build/types/types/generic.d.ts +2 -0
- package/build/types/types/guard.d.ts +9 -0
- package/build/types/types/http-responses.d.ts +7 -0
- package/build/types/types/index.d.ts +27 -0
- package/build/types/types/injection.d.ts +11 -0
- package/build/types/types/lifecycle.d.ts +9 -0
- package/build/types/types/mcp.d.ts +148 -0
- package/build/types/types/middleware.d.ts +12 -0
- package/build/types/types/parseable.d.ts +3 -0
- package/build/types/types/plugin.d.ts +6 -0
- package/build/types/types/raiton.d.ts +13 -0
- package/build/types/types/responses.d.ts +20 -0
- package/build/types/types/router.d.ts +13 -0
- package/build/types/types/runtime.d.ts +48 -0
- package/build/types/types/scheduler.d.ts +140 -0
- package/build/types/types/scheme.d.ts +125 -0
- package/build/types/types/server.d.ts +10 -0
- package/build/types/types/socket.d.ts +11 -0
- package/build/types/types/thread.d.ts +25 -0
- package/build/types/types/utilities.d.ts +4 -0
- package/build/types/types/values.d.ts +2 -0
- package/docs/AGENTS.md +55 -0
- package/docs/CLAUDE.md +55 -0
- package/docs/README.md +5 -0
- package/docs/contributors/cli/README.md +17 -3
- package/docs/contributors/cli/commands.md +28 -17
- package/docs/contributors/framework/plugins/openapi.md +12 -3
- package/docs/generated/cli/commands.md +31 -0
- package/docs/generated/config-schema.json +243 -0
- package/docs/generated/manifest-schema.json +312 -0
- package/docs/generated/manifest.json +118 -0
- package/docs/llms-full.txt +1450 -0
- package/docs/llms.txt +51 -0
- package/docs/user-guide/README.md +19 -12
- package/docs/user-guide/cli.md +26 -0
- package/docs/user-guide/config.md +32 -0
- package/docs/user-guide/contracts.md +67 -0
- package/docs/user-guide/debug.md +130 -0
- package/docs/user-guide/en/README.md +83 -0
- package/docs/user-guide/getting-started.md +13 -1
- package/docs/user-guide/mcp.md +45 -2
- package/docs/user-guide/observability.md +74 -0
- package/docs/user-guide/openapi/plugin.md +10 -0
- package/docs/user-guide/recipes/README.md +32 -0
- package/docs/user-guide/recipes/contracts.md +52 -0
- package/docs/user-guide/recipes/doctor.md +16 -0
- package/docs/user-guide/recipes/generate.md +28 -0
- package/docs/user-guide/recipes/manifest.md +17 -0
- package/docs/user-guide/recipes/mcp-stdio.md +35 -0
- package/docs/user-guide/recipes/new-project.md +34 -0
- package/docs/user-guide/recipes/observability.md +17 -0
- package/package.json +42 -7
- package/scripts/bench-ai-debug.ts +572 -0
- package/scripts/bench.ts +586 -0
- package/scripts/postinstall.mjs +15 -0
- package/source/bin/cli-output.ts +139 -0
- package/source/bin/commands.registry.ts +31 -3
- package/source/bin/file-utils.ts +95 -0
- package/source/bin/name-utils.ts +26 -0
- package/source/bin/project-utils.ts +78 -0
- package/source/commands/artifact.command.ts +30 -15
- package/source/commands/call.command.ts +247 -0
- package/source/commands/client.command.ts +64 -0
- package/source/commands/contract.command.ts +104 -0
- package/source/commands/debug.shared.ts +90 -0
- package/source/commands/docs.command.ts +269 -0
- package/source/commands/doctor.command.ts +226 -0
- package/source/commands/explain.command.ts +119 -0
- package/source/commands/generate.command.ts +58 -0
- package/source/commands/inspect.command.ts +108 -0
- package/source/commands/mcp.command.ts +322 -0
- package/source/commands/new.command.ts +135 -0
- package/source/commands/openapi.command.ts +95 -0
- package/source/commands/requests.command.ts +137 -0
- package/source/commands/routes.command.ts +39 -0
- package/source/commands/verify.command.ts +173 -0
- package/source/commands/why.command.ts +61 -0
- package/source/contracts/decorators.ts +216 -0
- package/source/contracts/errors.ts +135 -0
- package/source/contracts/index.ts +4 -0
- package/source/contracts/schema.ts +438 -0
- package/source/contracts/typebox.ts +193 -0
- package/source/core/application.ts +322 -72
- package/source/core/builder.ts +10 -2
- package/source/core/config/config.ts +155 -26
- package/source/core/config/define.ts +35 -8
- package/source/core/config/index.ts +2 -1
- package/source/core/config/schema.ts +406 -0
- package/source/core/controller/builder.ts +38 -13
- package/source/core/controller/compiler.ts +14 -7
- package/source/core/controller/metadata.ts +1 -1
- package/source/core/hooks.ts +13 -1
- package/source/core/injection/injection.ts +47 -9
- package/source/core/mcp/builder.ts +13 -2
- package/source/core/mcp/metadata.ts +2 -1
- package/source/core/middleware/compose.ts +48 -0
- package/source/core/middleware/pipeline.ts +69 -46
- package/source/core/raiton.ts +8 -0
- package/source/core/router/handler.ts +246 -37
- package/source/core/router/handler.utils.ts +107 -51
- package/source/core/router/matcher.ts +195 -24
- package/source/core/router/route.ts +100 -31
- package/source/core/router/router.ts +27 -2
- package/source/core/scheduler/metadata.ts +1 -1
- package/source/core/socket/metadata.ts +1 -1
- package/source/core/thread.ts +37 -2
- package/source/debug/cli.ts +206 -0
- package/source/debug/collector.internal.ts +27 -0
- package/source/debug/collector.ts +294 -0
- package/source/debug/config.ts +142 -0
- package/source/debug/examples.ts +188 -0
- package/source/debug/explain.ts +187 -0
- package/source/debug/index.ts +15 -0
- package/source/debug/invocation.ts +695 -0
- package/source/debug/journal.ts +249 -0
- package/source/debug/mcp-http.ts +145 -0
- package/source/debug/mcp.ts +410 -0
- package/source/debug/redaction.ts +225 -0
- package/source/debug/requests.ts +136 -0
- package/source/debug/runtime.ts +181 -0
- package/source/debug/session.ts +107 -0
- package/source/debug/source.ts +95 -0
- package/source/debug/surface.ts +375 -0
- package/source/debug/types.ts +311 -0
- package/source/debug/verify.ts +186 -0
- package/source/framework/artifacts.ts +47 -15
- package/source/framework/cache/cache.ts +48 -3
- package/source/framework/constants/decorators.constant.ts +5 -0
- package/source/framework/data-transfer-object.ts +4 -3
- package/source/framework/decorators/controllable.decorator.ts +3 -3
- package/source/framework/decorators/csrf-guard.decorator.ts +3 -2
- package/source/framework/decorators/csrf-token.decorator.ts +1 -1
- package/source/framework/decorators/guard.decorator.ts +3 -2
- package/source/framework/decorators/health-check.decorator.ts +1 -1
- package/source/framework/decorators/mcp.decorator.ts +38 -7
- package/source/framework/decorators/middleware.decorator.ts +2 -2
- package/source/framework/decorators/parametrable.decorator.ts +2 -1
- package/source/framework/decorators/routable.decorator.ts +3 -3
- package/source/framework/decorators/route-interaction.decorator.ts +2 -2
- package/source/framework/decorators/scheduler.decorator.ts +3 -3
- package/source/framework/decorators/socket.decorator.ts +3 -3
- package/source/framework/encryption.ts +46 -7
- package/source/framework/errors/catalog.ts +205 -0
- package/source/framework/exceptions/http-exception.ts +1 -1
- package/source/framework/health-check.ts +18 -0
- package/source/framework/index.ts +2 -0
- package/source/framework/mcp/audit.ts +57 -0
- package/source/framework/mcp/conformance.ts +195 -0
- package/source/framework/mcp/handler.ts +139 -9
- package/source/framework/mcp/index.ts +6 -1
- package/source/framework/mcp/protocol.ts +6 -0
- package/source/framework/mcp/rate-limit.ts +33 -0
- package/source/framework/mcp/stdio.ts +150 -0
- package/source/framework/mcp/streamable-http.ts +36 -5
- package/source/framework/observability/index.ts +6 -0
- package/source/framework/observability/metrics.ts +162 -0
- package/source/framework/observability/plugin.ts +151 -0
- package/source/framework/observability/readiness.ts +22 -0
- package/source/framework/observability/request.ts +31 -0
- package/source/framework/observability/shutdown.ts +68 -0
- package/source/framework/observability/trace.ts +241 -0
- package/source/framework/plugins/body-parser.plugin.ts +88 -85
- package/source/framework/plugins/dev.plugin.ts +227 -0
- package/source/framework/plugins/index.ts +2 -1
- package/source/framework/plugins/mcp.plugin.ts +14 -3
- package/source/framework/plugins/openapi.plugin.ts +56 -13
- package/source/framework/responses/helpers.ts +4 -4
- package/source/framework/responses/http-throwable.ts +1 -1
- package/source/framework/runtime/bun/server.ts +2 -1
- package/source/framework/runtime/deno/server.ts +2 -1
- package/source/framework/runtime/index.ts +45 -13
- package/source/framework/runtime/node/request.ts +59 -13
- package/source/framework/utilities/index.ts +3 -1
- package/source/framework/utilities/openapi.utils.impl.ts +733 -0
- package/source/framework/utilities/openapi.utils.ts +6 -636
- package/source/framework/utilities/route-suggestion.util.ts +59 -0
- package/source/framework/utilities/validation.util.ts +20 -0
- package/source/generators/artifact.templates.ts +230 -0
- package/source/generators/index.ts +2 -0
- package/source/generators/project.templates.ts +392 -0
- package/source/manifest/client.ts +299 -0
- package/source/manifest/contract.ts +138 -0
- package/source/manifest/index.ts +5 -0
- package/source/manifest/introspect.ts +57 -0
- package/source/manifest/manifest.ts +364 -0
- package/source/manifest/schema.ts +200 -0
- package/source/types/builder.ts +5 -0
- package/source/types/config.ts +120 -2
- package/source/types/mcp.ts +63 -1
- package/tsconfig.build.json +13 -0
- package/source/commands/grafts.command.ts +0 -27
- package/tests/artifact-resolution.test.ts +0 -60
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import type {ProjectManifest, ProjectRouteManifest} from "./schema.ts";
|
|
2
|
+
|
|
3
|
+
export interface ClientGenerationOptions {
|
|
4
|
+
/** Client class/function prefix. Defaults to `RaitonClient`. */
|
|
5
|
+
name?: string;
|
|
6
|
+
/** Base URL used when the caller does not provide one. */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function pascal(value: string): string {
|
|
11
|
+
return value
|
|
12
|
+
.replace(/[^a-zA-Z0-9]+/g, " ")
|
|
13
|
+
.split(" ")
|
|
14
|
+
.filter(Boolean)
|
|
15
|
+
.map(part => part[0].toUpperCase() + part.slice(1))
|
|
16
|
+
.join("");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function camel(value: string): string {
|
|
20
|
+
const result = pascal(value);
|
|
21
|
+
return result ? result[0].toLowerCase() + result.slice(1) : "value";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function uniqueTypes(): Map<string, string> {
|
|
25
|
+
return new Map();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function typeFromSchema(schema: any, models: Map<string, string>, hint: string): string {
|
|
29
|
+
if (!schema || typeof schema !== "object") return "unknown";
|
|
30
|
+
|
|
31
|
+
if (schema.$ref && typeof schema.$ref === "string") {
|
|
32
|
+
const name = schema.$ref.split("/").pop();
|
|
33
|
+
return name ? pascal(name) : "unknown";
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(schema.anyOf)) {
|
|
36
|
+
return [...new Set(schema.anyOf.map((item: any) => typeFromSchema(item, models, hint)))].join(" | ") || "unknown";
|
|
37
|
+
}
|
|
38
|
+
if (Array.isArray(schema.oneOf)) {
|
|
39
|
+
return [...new Set(schema.oneOf.map((item: any) => typeFromSchema(item, models, hint)))].join(" | ") || "unknown";
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(schema.allOf)) {
|
|
42
|
+
return schema.allOf.map((item: any) => typeFromSchema(item, models, hint)).join(" & ");
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(schema.type)) {
|
|
45
|
+
return schema.type.map((type: string) => typeFromSchema({...schema, type}, models, hint)).join(" | ");
|
|
46
|
+
}
|
|
47
|
+
if (Array.isArray(schema.enum)) {
|
|
48
|
+
return schema.enum.map((value: any) => JSON.stringify(value)).join(" | ");
|
|
49
|
+
}
|
|
50
|
+
if (schema.const !== undefined) return JSON.stringify(schema.const);
|
|
51
|
+
|
|
52
|
+
switch (schema.type) {
|
|
53
|
+
case "string":
|
|
54
|
+
return "string";
|
|
55
|
+
case "number":
|
|
56
|
+
case "integer":
|
|
57
|
+
return "number";
|
|
58
|
+
case "boolean":
|
|
59
|
+
return "boolean";
|
|
60
|
+
case "null":
|
|
61
|
+
return "null";
|
|
62
|
+
case "array":
|
|
63
|
+
return `Array<${typeFromSchema(schema.items, models, hint)}>`;
|
|
64
|
+
case "object":
|
|
65
|
+
case undefined: {
|
|
66
|
+
if (schema.properties) {
|
|
67
|
+
const name = schema.title ? pascal(schema.title) : pascal(hint);
|
|
68
|
+
if (!models.has(name)) {
|
|
69
|
+
models.set(name, "pending");
|
|
70
|
+
const required = new Set<string>(Array.isArray(schema.required) ? schema.required : []);
|
|
71
|
+
const properties = Object.entries(schema.properties)
|
|
72
|
+
.map(([key, child]) => {
|
|
73
|
+
const optional = required.has(key) ? "" : "?";
|
|
74
|
+
return ` ${safeProperty(key)}${optional}: ${typeFromSchema(child as any, models, `${hint}${pascal(key)}`)};`;
|
|
75
|
+
})
|
|
76
|
+
.join("\n");
|
|
77
|
+
models.set(name, `export interface ${name} {\n${properties}\n}`);
|
|
78
|
+
}
|
|
79
|
+
return name;
|
|
80
|
+
}
|
|
81
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
|
|
82
|
+
return `Record<string, ${typeFromSchema(schema.additionalProperties, models, hint)}>`;
|
|
83
|
+
}
|
|
84
|
+
return "Record<string, unknown>";
|
|
85
|
+
}
|
|
86
|
+
default:
|
|
87
|
+
return "unknown";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function safeProperty(key: string): string {
|
|
92
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function pathParams(route: ProjectRouteManifest): string[] {
|
|
96
|
+
return [...route.path.matchAll(/:([A-Za-z0-9_]+)/g)].map(match => match[1]);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function routeFunctionName(route: ProjectRouteManifest, used: Set<string>): string {
|
|
100
|
+
const base = camel(`${route.method.toLowerCase()} ${route.path}`) || "request";
|
|
101
|
+
let name = base;
|
|
102
|
+
let index = 2;
|
|
103
|
+
while (used.has(name)) name = `${base}${index++}`;
|
|
104
|
+
used.add(name);
|
|
105
|
+
return name;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const GENERIC_SCHEMA_NAMES = new Set(["object", "array", "string", "number", "integer", "boolean", "null"]);
|
|
109
|
+
|
|
110
|
+
function bodyModel(route: ProjectRouteManifest): string | undefined {
|
|
111
|
+
if (!route.inputSchema) return undefined;
|
|
112
|
+
const explicit = route.input && !GENERIC_SCHEMA_NAMES.has(route.input.toLowerCase())
|
|
113
|
+
? route.input
|
|
114
|
+
: `${route.controller}${pascal(route.handler)}Input`;
|
|
115
|
+
return pascal(explicit);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function outputModel(route: ProjectRouteManifest): string | undefined {
|
|
119
|
+
if (!route.outputSchema) return undefined;
|
|
120
|
+
const explicit = route.output && !GENERIC_SCHEMA_NAMES.has(route.output.toLowerCase())
|
|
121
|
+
? route.output
|
|
122
|
+
: `${route.controller}${pascal(route.handler)}Output`;
|
|
123
|
+
return pascal(explicit);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Generate a typed client from the manifest. Public signatures never use `any`:
|
|
128
|
+
* unknown schemas degrade to `unknown`, never to an unsafe escape hatch.
|
|
129
|
+
*/
|
|
130
|
+
export function generateClient(manifest: ProjectManifest, options: ClientGenerationOptions = {}): string {
|
|
131
|
+
const models = uniqueTypes();
|
|
132
|
+
const used = new Set<string>();
|
|
133
|
+
const functions: string[] = [];
|
|
134
|
+
const typeDeclarations: string[] = [];
|
|
135
|
+
|
|
136
|
+
const sorted = [...manifest.routes].sort((left, right) =>
|
|
137
|
+
`${left.path}:${left.method}`.localeCompare(`${right.path}:${method(right)}`));
|
|
138
|
+
|
|
139
|
+
for (const route of sorted) {
|
|
140
|
+
const inputName = bodyModel(route);
|
|
141
|
+
const outputName = outputModel(route);
|
|
142
|
+
const inputType = route.inputSchema
|
|
143
|
+
? typeFromSchema(route.inputSchema, models, inputName ?? "Input")
|
|
144
|
+
: "unknown";
|
|
145
|
+
const outputType = route.outputSchema
|
|
146
|
+
? typeFromSchema(route.outputSchema, models, outputName ?? "Output")
|
|
147
|
+
: "unknown";
|
|
148
|
+
|
|
149
|
+
if (inputName && !models.has(inputName) && route.inputSchema?.type === "object" && !route.inputSchema.properties) {
|
|
150
|
+
models.set(inputName, `export type ${inputName} = ${inputType};`);
|
|
151
|
+
}
|
|
152
|
+
if (outputName && !models.has(outputName) && (!route.outputSchema?.properties)) {
|
|
153
|
+
models.set(outputName, `export type ${outputName} = ${outputType};`);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const name = routeFunctionName(route, used);
|
|
157
|
+
const params = pathParams(route);
|
|
158
|
+
const paramsType = params.length
|
|
159
|
+
? `{${params.map(param => `${safeProperty(param)}: string | number;`).join(" ")}}`
|
|
160
|
+
: "undefined";
|
|
161
|
+
|
|
162
|
+
const signature: string[] = [];
|
|
163
|
+
if (params.length) signature.push(`params: ${paramsType}`);
|
|
164
|
+
if (route.method !== "GET" && route.method !== "HEAD" && route.inputSchema) {
|
|
165
|
+
signature.push(`body: ${inputType}`);
|
|
166
|
+
}
|
|
167
|
+
signature.push("options: RequestOptions = {}");
|
|
168
|
+
|
|
169
|
+
const pathExpression = params.length
|
|
170
|
+
? "`" + route.path.replace(/:([A-Za-z0-9_]+)/g, "${encodeURIComponent(String(params.$1))}") + "`"
|
|
171
|
+
: JSON.stringify(route.path);
|
|
172
|
+
|
|
173
|
+
const query = route.method === "GET"
|
|
174
|
+
? ` const query = options.query ? \`?\${new URLSearchParams(Object.entries(options.query).filter(([, value]) => value !== undefined).map(([key, value]) => [key, String(value)])).toString()}\` : '';\n`
|
|
175
|
+
: "";
|
|
176
|
+
|
|
177
|
+
functions.push([
|
|
178
|
+
`/** ${route.method} ${route.path}${route.controller ? ` — ${route.controller}.${route.handler}` : ""} */`,
|
|
179
|
+
`export async function ${name}(${signature.join(", ")}): Promise<${outputType}> {`,
|
|
180
|
+
query + ` return request<${outputType}>({`,
|
|
181
|
+
` method: ${JSON.stringify(route.method)},`,
|
|
182
|
+
` path: ${pathExpression} + (${route.method === "GET" ? "query" : "''"}),`,
|
|
183
|
+
route.method !== "GET" && route.method !== "HEAD" && route.inputSchema ? " body," : "",
|
|
184
|
+
` options,`,
|
|
185
|
+
` });`,
|
|
186
|
+
`}`,
|
|
187
|
+
].filter(Boolean).join("\n"));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Models may reference each other; emit declarations lazily until stable.
|
|
191
|
+
let previous = "";
|
|
192
|
+
for (let pass = 0; pass < 6; pass++) {
|
|
193
|
+
typeDeclarations.length = 0;
|
|
194
|
+
for (const declaration of models.values()) {
|
|
195
|
+
if (declaration && declaration !== "pending") typeDeclarations.push(declaration);
|
|
196
|
+
}
|
|
197
|
+
const joined = typeDeclarations.join("\n");
|
|
198
|
+
if (joined === previous) break;
|
|
199
|
+
previous = joined;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const clientName = options.name ?? "RaitonClient";
|
|
203
|
+
|
|
204
|
+
return `/* eslint-disable */
|
|
205
|
+
// Generated by \`raiton client\`. Do not edit by hand.
|
|
206
|
+
// Source: ${manifest.framework.name} ${manifest.framework.version} — manifest ${manifest.schemaVersion}
|
|
207
|
+
|
|
208
|
+
export interface ApiErrorBody {
|
|
209
|
+
error: true;
|
|
210
|
+
code: string;
|
|
211
|
+
message: string;
|
|
212
|
+
statusCode: number;
|
|
213
|
+
docsUrl?: string;
|
|
214
|
+
requestId?: string;
|
|
215
|
+
details?: unknown;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export class ${clientName}Error extends Error {
|
|
219
|
+
constructor(
|
|
220
|
+
message: string,
|
|
221
|
+
public readonly statusCode: number,
|
|
222
|
+
public readonly code: string,
|
|
223
|
+
public readonly details?: unknown,
|
|
224
|
+
public readonly docsUrl?: string,
|
|
225
|
+
public readonly requestId?: string,
|
|
226
|
+
) {
|
|
227
|
+
super(message);
|
|
228
|
+
this.name = ${JSON.stringify(`${clientName}Error`)};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface RequestOptions {
|
|
233
|
+
baseUrl?: string;
|
|
234
|
+
headers?: Record<string, string>;
|
|
235
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
236
|
+
signal?: AbortSignal;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface ClientConfig {
|
|
240
|
+
baseUrl: string;
|
|
241
|
+
headers?: Record<string, string>;
|
|
242
|
+
fetch?: typeof fetch;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
let clientConfig: ClientConfig = {
|
|
246
|
+
baseUrl: ${JSON.stringify(options.baseUrl ?? "")},
|
|
247
|
+
fetch: typeof fetch !== "undefined" ? fetch : undefined,
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export function configureClient(config: Partial<ClientConfig>): void {
|
|
251
|
+
clientConfig = {...clientConfig, ...config};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async function request<T>(input: {
|
|
255
|
+
method: string;
|
|
256
|
+
path: string;
|
|
257
|
+
body?: unknown;
|
|
258
|
+
options: RequestOptions;
|
|
259
|
+
}): Promise<T> {
|
|
260
|
+
const fetchImpl = clientConfig.fetch;
|
|
261
|
+
if (!fetchImpl) throw new Error("No fetch implementation available");
|
|
262
|
+
const baseUrl = (input.options.baseUrl ?? clientConfig.baseUrl).replace(/\\/$/, "");
|
|
263
|
+
const headers = new Headers({Accept: "application/json", ...(clientConfig.headers ?? {}), ...(input.options.headers ?? {})});
|
|
264
|
+
if (input.body !== undefined) headers.set("Content-Type", "application/json");
|
|
265
|
+
|
|
266
|
+
const response = await fetchImpl(baseUrl + input.path, {
|
|
267
|
+
method: input.method,
|
|
268
|
+
headers,
|
|
269
|
+
body: input.body === undefined ? undefined : JSON.stringify(input.body),
|
|
270
|
+
signal: input.options.signal,
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const text = await response.text();
|
|
274
|
+
const payload: unknown = text ? JSON.parse(text) : undefined;
|
|
275
|
+
|
|
276
|
+
if (!response.ok) {
|
|
277
|
+
const body = (payload ?? {}) as Partial<ApiErrorBody>;
|
|
278
|
+
throw new ${clientName}Error(
|
|
279
|
+
body.message ?? response.statusText,
|
|
280
|
+
response.status,
|
|
281
|
+
body.code ?? "HTTP_ERROR",
|
|
282
|
+
body.details,
|
|
283
|
+
body.docsUrl,
|
|
284
|
+
body.requestId,
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return payload as T;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
${typeDeclarations.join("\n\n")}
|
|
292
|
+
|
|
293
|
+
${functions.join("\n\n")}
|
|
294
|
+
`;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function method(route: ProjectRouteManifest): string {
|
|
298
|
+
return route.method;
|
|
299
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type {ProjectManifest} from "./schema.ts";
|
|
2
|
+
import {flattenContractFields, type FlattenedContractField} from "../contracts/schema.ts";
|
|
3
|
+
|
|
4
|
+
export interface ContractChange {
|
|
5
|
+
route: string;
|
|
6
|
+
field: string;
|
|
7
|
+
kind: "route-removed" | "field-removed" | "field-added-required" | "field-type-changed" | "response-field-removed" | "response-field-added-required";
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ContractCheckResult {
|
|
12
|
+
breaking: ContractChange[];
|
|
13
|
+
checked: number;
|
|
14
|
+
compatible: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface RouteContractSnapshot {
|
|
18
|
+
route: string;
|
|
19
|
+
input: FlattenedContractField[];
|
|
20
|
+
output: FlattenedContractField[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function routeKey(method: string, path: string): string {
|
|
24
|
+
return `${method.toUpperCase()} ${path}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function fromManifest(manifest: ProjectManifest): Map<string, RouteContractSnapshot> {
|
|
28
|
+
const output = new Map<string, RouteContractSnapshot>();
|
|
29
|
+
for (const route of manifest.routes) {
|
|
30
|
+
output.set(routeKey(route.method, route.path), {
|
|
31
|
+
route: routeKey(route.method, route.path),
|
|
32
|
+
input: route.inputSchema ? flattenContractFields(route.inputSchema as any) : [],
|
|
33
|
+
output: route.outputSchema ? flattenContractFields(route.outputSchema as any) : [],
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return output;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function fromOpenApi(document: any): Map<string, RouteContractSnapshot> {
|
|
40
|
+
const output = new Map<string, RouteContractSnapshot>();
|
|
41
|
+
for (const [path, item] of Object.entries(document?.paths ?? {})) {
|
|
42
|
+
for (const [method, operation] of Object.entries((item ?? {}) as Record<string, any>)) {
|
|
43
|
+
if (!["get", "post", "put", "patch", "delete", "options", "head", "trace"].includes(method)) continue;
|
|
44
|
+
const requestSchema = operation?.requestBody?.content?.["application/json"]?.schema;
|
|
45
|
+
const responseSchema = operation?.responses?.["200"]?.content?.["application/json"]?.schema
|
|
46
|
+
?? operation?.responses?.["201"]?.content?.["application/json"]?.schema;
|
|
47
|
+
output.set(routeKey(method, path), {
|
|
48
|
+
route: routeKey(method, path),
|
|
49
|
+
input: requestSchema ? flattenContractFields(requestSchema as any) : [],
|
|
50
|
+
output: responseSchema ? flattenContractFields(responseSchema as any) : [],
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return output;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function snapshotFromBaseline(baseline: any): Map<string, RouteContractSnapshot> {
|
|
58
|
+
if (baseline?.openapi) return fromOpenApi(baseline);
|
|
59
|
+
if (Array.isArray(baseline?.routes)) return fromManifest(baseline as ProjectManifest);
|
|
60
|
+
throw new Error("Unsupported baseline: expected an OpenAPI document or a Raiton manifest");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Compare a current manifest to a baseline and report breaking changes with the
|
|
65
|
+
* route and field responsible.
|
|
66
|
+
*/
|
|
67
|
+
export function checkContracts(manifest: ProjectManifest, baseline: any): ContractCheckResult {
|
|
68
|
+
const current = fromManifest(manifest);
|
|
69
|
+
const previous = snapshotFromBaseline(baseline);
|
|
70
|
+
const breaking: ContractChange[] = [];
|
|
71
|
+
|
|
72
|
+
for (const [route, before] of previous) {
|
|
73
|
+
const after = current.get(route);
|
|
74
|
+
if (!after) {
|
|
75
|
+
breaking.push({
|
|
76
|
+
route,
|
|
77
|
+
field: "",
|
|
78
|
+
kind: "route-removed",
|
|
79
|
+
message: `Route ${route} was removed`,
|
|
80
|
+
});
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
compareFields(route, "input", before.input, after.input, breaking, "field");
|
|
85
|
+
compareFields(route, "output", before.output, after.output, breaking, "response-field");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
breaking,
|
|
90
|
+
checked: current.size,
|
|
91
|
+
compatible: breaking.length === 0,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function compareFields(
|
|
96
|
+
route: string,
|
|
97
|
+
side: "input" | "output",
|
|
98
|
+
before: FlattenedContractField[],
|
|
99
|
+
after: FlattenedContractField[],
|
|
100
|
+
breaking: ContractChange[],
|
|
101
|
+
prefix: "field" | "response-field",
|
|
102
|
+
) {
|
|
103
|
+
const afterMap = new Map(after.map(field => [field.path, field]));
|
|
104
|
+
const beforeMap = new Map(before.map(field => [field.path, field]));
|
|
105
|
+
|
|
106
|
+
for (const field of before) {
|
|
107
|
+
const current = afterMap.get(field.path);
|
|
108
|
+
if (!current) {
|
|
109
|
+
breaking.push({
|
|
110
|
+
route,
|
|
111
|
+
field: field.path,
|
|
112
|
+
kind: `${prefix}-removed` as ContractChange["kind"],
|
|
113
|
+
message: `${side} field "${field.path}" was removed`,
|
|
114
|
+
});
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (current.type !== field.type) {
|
|
118
|
+
breaking.push({
|
|
119
|
+
route,
|
|
120
|
+
field: field.path,
|
|
121
|
+
kind: "field-type-changed",
|
|
122
|
+
message: `${side} field "${field.path}" changed type from ${field.type ?? "unknown"} to ${current.type ?? "unknown"}`,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
for (const field of after) {
|
|
128
|
+
const existed = beforeMap.get(field.path);
|
|
129
|
+
if (!existed && field.required) {
|
|
130
|
+
breaking.push({
|
|
131
|
+
route,
|
|
132
|
+
field: field.path,
|
|
133
|
+
kind: `${prefix}-added-required` as ContractChange["kind"],
|
|
134
|
+
message: `required ${side} field "${field.path}" was added`,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {RaitonBuilder} from "../core/builder.ts";
|
|
2
|
+
import {RaitonThread} from "../core/thread.ts";
|
|
3
|
+
import {Raiton} from "../core/raiton.ts";
|
|
4
|
+
import {RaitonConfig} from "../core/config/config.ts";
|
|
5
|
+
import type {ApplicationInterface} from "../types/application.ts";
|
|
6
|
+
import {generateManifest, type GenerateManifestOptions} from "./manifest.ts";
|
|
7
|
+
import {type ProjectManifest, validateManifest} from "./schema.ts";
|
|
8
|
+
import {setDebugContext} from "../debug/runtime.ts";
|
|
9
|
+
|
|
10
|
+
export interface Introspection {
|
|
11
|
+
builder: RaitonBuilder;
|
|
12
|
+
thread: RaitonThread;
|
|
13
|
+
application: ApplicationInterface;
|
|
14
|
+
manifest: ProjectManifest;
|
|
15
|
+
validation: ReturnType<typeof validateManifest>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Boot a project without opening a listening socket. The project's own
|
|
20
|
+
* bootstrapper is used so routes, DI and configuration are exactly those of the
|
|
21
|
+
* application, then a manifest is generated from the live registries.
|
|
22
|
+
*/
|
|
23
|
+
export async function introspectProject(
|
|
24
|
+
workdir = process.cwd(),
|
|
25
|
+
options: GenerateManifestOptions = {},
|
|
26
|
+
): Promise<Introspection> {
|
|
27
|
+
await RaitonConfig.sync(workdir, {force: true});
|
|
28
|
+
|
|
29
|
+
RaitonThread.reset();
|
|
30
|
+
Raiton.resetThread();
|
|
31
|
+
|
|
32
|
+
const builder = new RaitonBuilder(workdir, {serve: false, hmr: false, compile: false});
|
|
33
|
+
await builder.prepare();
|
|
34
|
+
await builder.boot();
|
|
35
|
+
|
|
36
|
+
const thread = RaitonThread.current;
|
|
37
|
+
const application = thread?.application;
|
|
38
|
+
if (!thread || !application) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`No application was created by ${builder.bootstrapper ?? "the bootstrapper"}. ` +
|
|
41
|
+
`Ensure its default export calls thread.setup({ application }).run().`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// CLI introspection knows the project root even when the bootstrapper did
|
|
46
|
+
// not pass it to the Application: align debug session paths.
|
|
47
|
+
setDebugContext({workdir, application});
|
|
48
|
+
|
|
49
|
+
const manifest = generateManifest({workdir, refresh: true, ...options});
|
|
50
|
+
return {
|
|
51
|
+
builder,
|
|
52
|
+
thread,
|
|
53
|
+
application,
|
|
54
|
+
manifest,
|
|
55
|
+
validation: validateManifest(manifest),
|
|
56
|
+
};
|
|
57
|
+
}
|