raiton 6.8.8-beta.24 → 6.10.0-beta.28
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 +50 -0
- package/README.md +46 -1
- package/benchmarks/README.md +16 -0
- package/benchmarks/latest.json +172 -0
- package/benchmarks/latest.md +66 -0
- package/build/bin/index.mjs +33575 -21723
- 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/client.command.d.ts +7 -0
- package/build/types/commands/contract.command.d.ts +8 -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/generate.command.d.ts +7 -0
- package/build/types/commands/inspect.command.d.ts +7 -0
- package/build/types/commands/mcp.command.d.ts +11 -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/routes.command.d.ts +7 -0
- package/build/types/commands/start.command.d.ts +9 -0
- package/build/types/commands/why.command.d.ts +7 -0
- package/build/types/contracts/decorators.d.ts +41 -0
- package/build/types/contracts/errors.d.ts +42 -0
- package/build/types/contracts/index.d.ts +4 -0
- package/build/types/contracts/schema.d.ts +70 -0
- package/build/types/contracts/typebox.d.ts +81 -0
- package/build/types/core/application.d.ts +37 -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/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 +42 -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 +177 -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 +62 -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 +26 -0
- package/docs/generated/config-schema.json +150 -0
- package/docs/generated/manifest-schema.json +236 -0
- package/docs/generated/manifest.json +101 -0
- package/docs/llms-full.txt +1271 -0
- package/docs/llms.txt +46 -0
- package/docs/user-guide/README.md +18 -12
- package/docs/user-guide/cli.md +21 -0
- package/docs/user-guide/config.md +14 -0
- package/docs/user-guide/contracts.md +67 -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 +40 -7
- 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 +23 -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/client.command.ts +64 -0
- package/source/commands/contract.command.ts +104 -0
- package/source/commands/docs.command.ts +263 -0
- package/source/commands/doctor.command.ts +226 -0
- package/source/commands/generate.command.ts +58 -0
- package/source/commands/inspect.command.ts +108 -0
- package/source/commands/mcp.command.ts +258 -0
- package/source/commands/new.command.ts +135 -0
- package/source/commands/openapi.command.ts +95 -0
- package/source/commands/routes.command.ts +39 -0
- package/source/commands/why.command.ts +61 -0
- package/source/contracts/decorators.ts +151 -0
- package/source/contracts/errors.ts +76 -0
- package/source/contracts/index.ts +4 -0
- package/source/contracts/schema.ts +377 -0
- package/source/contracts/typebox.ts +193 -0
- package/source/core/application.ts +215 -73
- package/source/core/builder.ts +6 -2
- package/source/core/config/config.ts +144 -26
- package/source/core/config/define.ts +35 -8
- package/source/core/config/index.ts +2 -1
- package/source/core/config/schema.ts +263 -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 +91 -31
- 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/framework/artifacts.ts +92 -19
- 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 +159 -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 +131 -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 +705 -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 +52 -0
- package/source/manifest/manifest.ts +341 -0
- package/source/manifest/schema.ts +149 -0
- package/source/types/builder.ts +5 -0
- package/source/types/config.ts +64 -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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {SchedulerMetaInterface, SchedulerRegistrationInterface} from "../../types/index.ts";
|
|
2
|
-
import {METADATA_KEYS} from "../../framework/constants/
|
|
2
|
+
import {METADATA_KEYS} from "../../framework/constants/decorators.constant.ts";
|
|
3
3
|
import "reflect-metadata";
|
|
4
4
|
|
|
5
5
|
const registry = new Map<string, SchedulerRegistrationInterface>();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {ConstructorType, SocketMetaInterface} from "../../types/index.ts";
|
|
2
|
-
import {METADATA_KEYS} from "../../framework/
|
|
2
|
+
import {METADATA_KEYS} from "../../framework/constants/decorators.constant.ts";
|
|
3
3
|
import "reflect-metadata";
|
|
4
4
|
|
|
5
5
|
export interface SocketRegistryEntryInterface {
|
package/source/core/thread.ts
CHANGED
|
@@ -22,6 +22,10 @@ import {Injection} from "./injection/injection.ts";
|
|
|
22
22
|
import {Throwable} from "../framework/exceptions/index.ts";
|
|
23
23
|
import {isBunUsed, isDenoUsed, isNodeUsed} from "../bin/constants.ts";
|
|
24
24
|
import {getLanIp} from "../framework/utilities/ip.util.ts";
|
|
25
|
+
import {RaitonConfig} from "./config/config.ts";
|
|
26
|
+
import {ConfigValidationError, validateConfig} from "./config/schema.ts";
|
|
27
|
+
import {Readiness} from "../framework/observability/readiness.ts";
|
|
28
|
+
import {shutdown} from "../framework/observability/shutdown.ts";
|
|
25
29
|
|
|
26
30
|
|
|
27
31
|
export class RaitonThread implements ThreadInterface {
|
|
@@ -33,6 +37,10 @@ export class RaitonThread implements ThreadInterface {
|
|
|
33
37
|
return RaitonThread.instance;
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
public static reset(): void {
|
|
41
|
+
RaitonThread.instance = null;
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
public application: ApplicationInterface | null = null;
|
|
37
45
|
public runtime: RuntimeAdapterInterface | null = null;
|
|
38
46
|
public runtimeServer: RuntimeServerInterface | null = null;
|
|
@@ -62,6 +70,21 @@ export class RaitonThread implements ThreadInterface {
|
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
public async stop(): Promise<void> {
|
|
73
|
+
// Readiness fails immediately, before any new request is accepted.
|
|
74
|
+
Readiness.markNotReady('shutting down')
|
|
75
|
+
const timeout = RaitonConfig.getShutdownTimeout()
|
|
76
|
+
const result = await shutdown.drain(timeout)
|
|
77
|
+
Logger.info(
|
|
78
|
+
`Shutdown: drained ${result.drained ? 'all' : 'partially'} ` +
|
|
79
|
+
`(${result.remaining} request(s) remaining, timeout ${timeout}ms)`
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
await this.runtimeServer?.close()
|
|
84
|
+
} catch (error: any) {
|
|
85
|
+
Logger.debug('Server close failed', error?.message ?? error)
|
|
86
|
+
}
|
|
87
|
+
|
|
65
88
|
await SchedulerManager.current.stop();
|
|
66
89
|
await Injection.shutdown();
|
|
67
90
|
if (isDenoUsed) {
|
|
@@ -89,6 +112,8 @@ export class RaitonThread implements ThreadInterface {
|
|
|
89
112
|
: (isDenoUsed ? RuntimeType.Deno : RuntimeType.Node);
|
|
90
113
|
this.runtime = new Runtime(runtime || defaultRuntime);
|
|
91
114
|
this.application = application;
|
|
115
|
+
// Idempotent: `Application.initialize()` already installs it, but
|
|
116
|
+
// custom ApplicationInterface implementations rely on this setup hook.
|
|
92
117
|
this.application.use(bodyParserPlugin())
|
|
93
118
|
return this;
|
|
94
119
|
}
|
|
@@ -100,6 +125,16 @@ export class RaitonThread implements ThreadInterface {
|
|
|
100
125
|
if (!this.runtime)
|
|
101
126
|
throw new Throwable('Runtime not defined');
|
|
102
127
|
|
|
128
|
+
// Configuration is validated before any socket is opened.
|
|
129
|
+
if (RaitonConfig.errors.length) throw new ConfigValidationError(RaitonConfig.errors)
|
|
130
|
+
const applicationValidation = validateConfig(this.application.config as any)
|
|
131
|
+
if (!applicationValidation.valid) throw new ConfigValidationError(applicationValidation.errors)
|
|
132
|
+
|
|
133
|
+
// Load only the adapter of the selected runtime.
|
|
134
|
+
await (this.runtime as any).prepare?.()
|
|
135
|
+
|
|
136
|
+
Readiness.markReady()
|
|
137
|
+
|
|
103
138
|
const scanRoot = isNodeUsed
|
|
104
139
|
? (this.builder.out || this.builder.source)
|
|
105
140
|
: this.builder.source;
|
|
@@ -109,9 +144,9 @@ export class RaitonThread implements ThreadInterface {
|
|
|
109
144
|
registerDefaultHealthCheck(this.application)
|
|
110
145
|
}
|
|
111
146
|
|
|
112
|
-
await SchedulerManager.current.start();
|
|
113
|
-
|
|
114
147
|
if (this._options.serve) {
|
|
148
|
+
await SchedulerManager.current.start();
|
|
149
|
+
|
|
115
150
|
if (isDenoUsed) {
|
|
116
151
|
const addSignalListener = (globalThis as any).Deno.addSignalListener;
|
|
117
152
|
if (typeof addSignalListener === 'function') {
|
|
@@ -2,9 +2,49 @@ import {Injection} from "../core/injection/index.ts";
|
|
|
2
2
|
import {Logger} from "@protorians/logger";
|
|
3
3
|
import type {ConstructorType} from "../types/index.ts";
|
|
4
4
|
import {Raiton} from "../core/raiton.ts";
|
|
5
|
-
import {isArtifact} from "./utilities/index.ts";
|
|
6
|
-
import {compileMcp} from "../core/mcp/builder.ts";
|
|
7
5
|
import {compileScheduler} from "../core/scheduler/builder.ts";
|
|
6
|
+
import {compileMcp} from "../core/mcp/builder.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Un artefact middleware/hook peut être exporté sous deux formes : une classe
|
|
10
|
+
* (instanciée par le conteneur) ou une fonction `(context) => …`. Instancier
|
|
11
|
+
* systématiquement lève « function is not a constructor » dès que la fonction
|
|
12
|
+
* est fléchée ou `async` — et un `function` classique, lui constructible, ne
|
|
13
|
+
* doit pas être instancié non plus. On ne reconnaît donc que la syntaxe classe.
|
|
14
|
+
*/
|
|
15
|
+
function isClass(value: unknown): value is ConstructorType {
|
|
16
|
+
if (typeof value !== 'function') return false
|
|
17
|
+
if (!/^\s*class[\s{]/.test(Function.prototype.toString.call(value))) return false
|
|
18
|
+
try {
|
|
19
|
+
Reflect.construct(Object, [], value)
|
|
20
|
+
return true
|
|
21
|
+
} catch {
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Un artefact de middleware *décorateur* n'est pas enregistré dans le pipeline
|
|
28
|
+
* racine : le remplacer l'y ajouterait et le ferait exécuter sur **toutes** les
|
|
29
|
+
* requêtes. On ne remplace donc que les entrées déjà présentes.
|
|
30
|
+
*/
|
|
31
|
+
function isRegistered(registry: any, name: string): boolean {
|
|
32
|
+
const normalized = name.toLowerCase()
|
|
33
|
+
const stack = registry?.stack
|
|
34
|
+
if (Array.isArray(stack)) {
|
|
35
|
+
return stack.some((entry: any) => {
|
|
36
|
+
const entryName = typeof entry === 'function' ? entry.name : entry?.name
|
|
37
|
+
return typeof entryName === 'string' && entryName.toLowerCase() === normalized
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
const hooks = registry?.hooks
|
|
41
|
+
if (hooks instanceof Map) {
|
|
42
|
+
return [...hooks.keys()].some(
|
|
43
|
+
(key) => typeof key === 'string' && key.toLowerCase() === normalized
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
return false
|
|
47
|
+
}
|
|
8
48
|
|
|
9
49
|
export type HmrChannel =
|
|
10
50
|
| 'hmr:di'
|
|
@@ -53,6 +93,43 @@ export const HMR_CHANNELS: Record<HmrChannel, readonly string[]> = {
|
|
|
53
93
|
'hmr:scheduler': ['scheduler', 'task', 'cron', 'job'],
|
|
54
94
|
}
|
|
55
95
|
|
|
96
|
+
const ARTIFACT_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs'] as const
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Lookup `type.extension` -> classification construit une seule fois.
|
|
100
|
+
* `Artifacts.classify()` ne fait donc qu'un lookup par fichier au lieu de
|
|
101
|
+
* parcourir tous les canaux et tous les types.
|
|
102
|
+
*/
|
|
103
|
+
const CLASSIFICATION_LOOKUP: Map<string, ArtifactClassification> = (() => {
|
|
104
|
+
const lookup = new Map<string, ArtifactClassification>()
|
|
105
|
+
for (const [channel, types] of Object.entries(HMR_CHANNELS)) {
|
|
106
|
+
for (const artifactType of types) {
|
|
107
|
+
for (const extension of ARTIFACT_EXTENSIONS) {
|
|
108
|
+
lookup.set(`${artifactType}${extension}`, {
|
|
109
|
+
channel: channel as HmrChannel,
|
|
110
|
+
artifactType,
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return lookup
|
|
116
|
+
})()
|
|
117
|
+
|
|
118
|
+
function artifactTypeOf(filename: string): string | null {
|
|
119
|
+
const lower = filename.toLowerCase()
|
|
120
|
+
const dot = lower.lastIndexOf('.')
|
|
121
|
+
if (dot <= 0) return null
|
|
122
|
+
|
|
123
|
+
const extension = lower.slice(dot)
|
|
124
|
+
if (!ARTIFACT_EXTENSIONS.includes(extension as any)) return null
|
|
125
|
+
|
|
126
|
+
const stem = lower.slice(0, dot)
|
|
127
|
+
const typeDot = stem.lastIndexOf('.')
|
|
128
|
+
if (typeDot === -1) return null
|
|
129
|
+
|
|
130
|
+
return stem.slice(typeDot + 1)
|
|
131
|
+
}
|
|
132
|
+
|
|
56
133
|
export class Artifacts {
|
|
57
134
|
|
|
58
135
|
static readonly types: Set<string> = new Set();
|
|
@@ -104,20 +181,16 @@ export class Artifacts {
|
|
|
104
181
|
}
|
|
105
182
|
|
|
106
183
|
static is(filename: string) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
.some(Boolean)
|
|
184
|
+
const artifactType = artifactTypeOf(filename)
|
|
185
|
+
return artifactType !== null && this.types.has(artifactType)
|
|
110
186
|
}
|
|
111
187
|
|
|
112
188
|
static classify(filename: string): ArtifactClassification | null {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return null
|
|
189
|
+
const artifactType = artifactTypeOf(filename)
|
|
190
|
+
if (!artifactType) return null
|
|
191
|
+
|
|
192
|
+
const extension = filename.slice(filename.lastIndexOf('.')).toLowerCase()
|
|
193
|
+
return CLASSIFICATION_LOOKUP.get(`${artifactType}${extension}`) ?? null
|
|
121
194
|
}
|
|
122
195
|
|
|
123
196
|
static reload(modulo: any, filename?: string) {
|
|
@@ -179,9 +252,9 @@ export class Artifacts {
|
|
|
179
252
|
typeof mod === 'function' ? mod.name ?? mod.constructor.name : undefined
|
|
180
253
|
);
|
|
181
254
|
|
|
182
|
-
if (typeof name === 'string') {
|
|
255
|
+
if (typeof name === 'string' && isRegistered(rootScope.middleware, name)) {
|
|
183
256
|
if (typeof mod === 'function') {
|
|
184
|
-
const instance = new (mod as ConstructorType)()
|
|
257
|
+
const instance = isClass(mod) ? new (mod as ConstructorType)() : mod
|
|
185
258
|
rootScope.middleware.replace(name, instance)
|
|
186
259
|
} else if (typeof mod === 'object' && mod !== null) {
|
|
187
260
|
rootScope.middleware.replace(name, mod)
|
|
@@ -208,12 +281,12 @@ export class Artifacts {
|
|
|
208
281
|
typeof mod === 'function' ? mod.name ?? mod.constructor.name : undefined
|
|
209
282
|
);
|
|
210
283
|
|
|
211
|
-
if (typeof name === 'string') {
|
|
284
|
+
if (typeof name === 'string' && isRegistered(rootScope.hooks, name)) {
|
|
212
285
|
if (typeof mod === 'function') {
|
|
213
|
-
const instance = new (mod as ConstructorType)()
|
|
214
|
-
rootScope.hooks.
|
|
286
|
+
const instance = isClass(mod) ? new (mod as ConstructorType)() : mod
|
|
287
|
+
rootScope.hooks.replaceAll(name, instance)
|
|
215
288
|
} else if (typeof mod === 'object' && mod !== null) {
|
|
216
|
-
rootScope.hooks.
|
|
289
|
+
rootScope.hooks.replaceAll(name, mod)
|
|
217
290
|
}
|
|
218
291
|
}
|
|
219
292
|
}
|
|
@@ -58,6 +58,8 @@ export class MemoryCacheStore implements CacheStore {
|
|
|
58
58
|
export class CacheManager {
|
|
59
59
|
private static _store: CacheStore = new MemoryCacheStore();
|
|
60
60
|
private static _defaults: Partial<CacheOptions> = {};
|
|
61
|
+
private static readonly _routeVersions = new Map<string, number>();
|
|
62
|
+
private static readonly _routeKeys = new Map<string, Set<string>>();
|
|
61
63
|
|
|
62
64
|
static configure(options: Partial<CacheOptions>): void {
|
|
63
65
|
this._defaults = {...this._defaults, ...options};
|
|
@@ -78,8 +80,43 @@ export class CacheManager {
|
|
|
78
80
|
this._store = store;
|
|
79
81
|
}
|
|
80
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Version courante d'une route. La version est intégrée aux clés de cache
|
|
85
|
+
* afin qu'une invalidation HMR rende immédiatement les anciennes entrées
|
|
86
|
+
* inaccessibles, même si le handler est recompilé.
|
|
87
|
+
*/
|
|
88
|
+
static version(route: string): number {
|
|
89
|
+
return this._routeVersions.get(route) ?? 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static track(route: string, key: string): void {
|
|
93
|
+
let keys = this._routeKeys.get(route);
|
|
94
|
+
if (!keys) {
|
|
95
|
+
keys = new Set();
|
|
96
|
+
this._routeKeys.set(route, keys);
|
|
97
|
+
}
|
|
98
|
+
keys.add(key);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static invalidateRoute(route: string): void {
|
|
102
|
+
this._routeVersions.set(route, this.version(route) + 1);
|
|
103
|
+
const keys = this._routeKeys.get(route);
|
|
104
|
+
if (keys) {
|
|
105
|
+
for (const key of keys) {
|
|
106
|
+
try {
|
|
107
|
+
this._store.delete(key);
|
|
108
|
+
} catch {
|
|
109
|
+
// A custom store may not support deletion; the version bump
|
|
110
|
+
// is enough to stop serving the old entry.
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
this._routeKeys.delete(route);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
81
117
|
static clear(): void {
|
|
82
118
|
this._store.clear();
|
|
119
|
+
this._routeKeys.clear();
|
|
83
120
|
}
|
|
84
121
|
}
|
|
85
122
|
|
|
@@ -148,11 +185,13 @@ export class RouteCache {
|
|
|
148
185
|
private readonly store: CacheStore;
|
|
149
186
|
private readonly route: string;
|
|
150
187
|
private readonly options: CacheOptions;
|
|
188
|
+
private readonly version: number;
|
|
151
189
|
|
|
152
190
|
constructor(route: string, options: CacheOptions = {}) {
|
|
153
191
|
this.route = route;
|
|
154
192
|
this.options = resolveCacheOptions(route, options);
|
|
155
193
|
this.store = CacheManager.getStore();
|
|
194
|
+
this.version = CacheManager.version(route);
|
|
156
195
|
}
|
|
157
196
|
|
|
158
197
|
get enabled(): boolean {
|
|
@@ -163,8 +202,12 @@ export class RouteCache {
|
|
|
163
202
|
return (this.options.methods ?? DEFAULT_METHODS).includes(method.toUpperCase());
|
|
164
203
|
}
|
|
165
204
|
|
|
166
|
-
key
|
|
167
|
-
return
|
|
205
|
+
private scope(key: string): string {
|
|
206
|
+
return `${this.version}|${key}`;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async key(context: RequestContext): Promise<string> {
|
|
210
|
+
return this.scope(await buildCacheKey(context, this.route, this.options));
|
|
168
211
|
}
|
|
169
212
|
|
|
170
213
|
async get<T = any>(context: RequestContext, key?: string): Promise<CacheEntry<T> | undefined> {
|
|
@@ -173,13 +216,15 @@ export class RouteCache {
|
|
|
173
216
|
|
|
174
217
|
async set<T = any>(context: RequestContext, body: T, status = 200, headers: Record<string, string> = {}, key?: string): Promise<void> {
|
|
175
218
|
const ttl = this.options.ttl ?? 60_000;
|
|
176
|
-
|
|
219
|
+
const scopedKey = key ?? await this.key(context);
|
|
220
|
+
this.store.set(scopedKey, {
|
|
177
221
|
body,
|
|
178
222
|
status,
|
|
179
223
|
headers,
|
|
180
224
|
createdAt: Date.now(),
|
|
181
225
|
expiresAt: Date.now() + ttl,
|
|
182
226
|
}, ttl);
|
|
227
|
+
CacheManager.track(this.route, scopedKey);
|
|
183
228
|
}
|
|
184
229
|
|
|
185
230
|
shouldCache(status: number): boolean {
|
|
@@ -28,4 +28,9 @@ export const METADATA_KEYS = {
|
|
|
28
28
|
MCP_ARGUMENTS: Symbol('mcp:arguments'),
|
|
29
29
|
// Scheduler metadata keys
|
|
30
30
|
SCHEDULER: Symbol('scheduler:meta'),
|
|
31
|
+
// Schema-first contract metadata keys
|
|
32
|
+
CONTRACT_INPUT: Symbol('contract:input'),
|
|
33
|
+
CONTRACT_OUTPUT: Symbol('contract:output'),
|
|
34
|
+
// Documentation / discoverability metadata
|
|
35
|
+
PUBLIC_EXPORT: Symbol('docs:public-export'),
|
|
31
36
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type {ValidationError} from "class-validator";
|
|
2
|
+
import {loadClassValidator} from "./utilities/validation.util.ts";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export class DataTransferObject {
|
|
@@ -12,6 +12,7 @@ export class DataTransferObject {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async validation(strict: boolean = true): Promise<void | ValidationError[]> {
|
|
15
|
+
const {validate, validateOrReject} = await loadClassValidator()
|
|
15
16
|
return await ((strict ? validateOrReject : validate)(this))
|
|
16
17
|
}
|
|
17
|
-
}
|
|
18
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {getControllerMetadata} from "../../core/controller/
|
|
2
|
-
import {Injectable} from "
|
|
1
|
+
import {getControllerMetadata} from "../../core/controller/metadata.ts";
|
|
2
|
+
import {Injectable} from "./injection.decorator.ts";
|
|
3
3
|
import {LifetimeEnum} from "@protorians/core";
|
|
4
|
-
import {ControllerDecoratorCallable} from "../../types/
|
|
4
|
+
import type {ControllerDecoratorCallable} from "../../types/controller.ts";
|
|
5
5
|
|
|
6
6
|
export function Controllable(prefix = '') {
|
|
7
7
|
return (target: any) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {MiddlewareParametersInterface, CsrfGuardOptions} from "../../types/index.ts";
|
|
1
|
+
import type {MiddlewareParametersInterface, CsrfGuardOptions} from "../../types/index.ts";
|
|
2
2
|
import {Middleware} from "./middleware.decorator.ts";
|
|
3
|
-
import {HttpStatus
|
|
3
|
+
import {HttpStatus} from "../enums/http-status.enum.ts";
|
|
4
|
+
import {RaitonResponses} from "../responses/helpers.ts";
|
|
4
5
|
import {CsrfUtil} from "../utilities/csrf.util.ts";
|
|
5
6
|
|
|
6
7
|
const DEFAULT_METHODS = ['POST', 'PUT', 'PATCH', 'DELETE']
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {GuardOptions} from "../../types/
|
|
1
|
+
import type {GuardOptions} from "../../types/guard.ts";
|
|
2
2
|
import {Middleware} from "./middleware.decorator.ts";
|
|
3
3
|
import {RaitonGuards} from "../../core/guards.ts";
|
|
4
|
-
import {HttpStatus
|
|
4
|
+
import {HttpStatus} from "../enums/http-status.enum.ts";
|
|
5
|
+
import {RaitonResponses} from "../responses/helpers.ts";
|
|
5
6
|
|
|
6
7
|
export function createGuardDecoration({name, handler}: GuardOptions) {
|
|
7
8
|
return Middleware(async ({next, context}) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import {METADATA_KEYS} from "../constants/decorators.constant.ts";
|
|
3
|
-
import {getControllerMetadata} from "../../core/controller/
|
|
3
|
+
import {getControllerMetadata} from "../../core/controller/metadata.ts";
|
|
4
4
|
import {RouteMetaInterface} from "../../types/index.ts";
|
|
5
5
|
|
|
6
6
|
export interface HealthCheckOptions {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import {registerMcpServer, unregisterMcpServer, getMcpServerMetadata} from "../../core/mcp/
|
|
3
|
-
import {Injectable} from "./
|
|
2
|
+
import {registerMcpServer, unregisterMcpServer, getMcpServerMetadata} from "../../core/mcp/metadata.ts";
|
|
3
|
+
import {Injectable} from "./injection.decorator.ts";
|
|
4
4
|
import {LifetimeEnum} from "@protorians/core";
|
|
5
|
-
import {METADATA_KEYS} from "../constants/
|
|
5
|
+
import {METADATA_KEYS} from "../constants/decorators.constant.ts";
|
|
6
6
|
import type {
|
|
7
7
|
McpArgumentMetaInterface,
|
|
8
8
|
McpArgumentSchema,
|
|
9
9
|
McpElementMetaInterface,
|
|
10
10
|
McpElementType,
|
|
11
11
|
McpServerOptionsInterface,
|
|
12
|
+
McpToolOptions,
|
|
12
13
|
} from "../../types/index.ts";
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -16,6 +17,9 @@ import type {
|
|
|
16
17
|
* {@link McpTool}, {@link McpPrompt}, {@link McpResource} and
|
|
17
18
|
* {@link McpResourceTemplate} become the server's exposed elements.
|
|
18
19
|
*
|
|
20
|
+
* Destructive tools are not exposed unless `exposeDestructive: true` is set
|
|
21
|
+
* explicitly on the server or in project configuration.
|
|
22
|
+
*
|
|
19
23
|
* @example
|
|
20
24
|
* ```ts
|
|
21
25
|
* @McpServer({ name: 'math', version: '1.0.0', path: '/mcp' })
|
|
@@ -37,6 +41,8 @@ export function McpServer(options: McpServerOptionsInterface = {}) {
|
|
|
37
41
|
meta.description = options.description
|
|
38
42
|
meta.path = options.path || '/mcp'
|
|
39
43
|
meta.instructions = options.instructions
|
|
44
|
+
meta.exposeDestructive = options.exposeDestructive ?? false
|
|
45
|
+
meta.rateLimitPerMinute = options.rateLimitPerMinute
|
|
40
46
|
|
|
41
47
|
unregisterMcpServer(options.name || target.name)
|
|
42
48
|
registerMcpServer(target)
|
|
@@ -44,7 +50,18 @@ export function McpServer(options: McpServerOptionsInterface = {}) {
|
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
function createElementDecorator(type: McpElementType) {
|
|
47
|
-
return (nameOrOptions?: string | {
|
|
53
|
+
return (nameOrOptions?: string | {
|
|
54
|
+
name?: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
uri?: string;
|
|
57
|
+
mimeType?: string;
|
|
58
|
+
title?: string;
|
|
59
|
+
inputSchema?: any;
|
|
60
|
+
outputSchema?: any;
|
|
61
|
+
annotations?: any;
|
|
62
|
+
destructive?: boolean;
|
|
63
|
+
scopes?: string[];
|
|
64
|
+
}) =>
|
|
48
65
|
(target: any, propertyKey: string) => {
|
|
49
66
|
const meta = getMcpServerMetadata(target)
|
|
50
67
|
const name = typeof nameOrOptions === 'string'
|
|
@@ -60,6 +77,11 @@ function createElementDecorator(type: McpElementType) {
|
|
|
60
77
|
uri: typeof nameOrOptions === 'object' ? nameOrOptions?.uri : undefined,
|
|
61
78
|
mimeType: typeof nameOrOptions === 'object' ? nameOrOptions?.mimeType : undefined,
|
|
62
79
|
title: typeof nameOrOptions === 'object' ? nameOrOptions?.title : undefined,
|
|
80
|
+
inputSchema: typeof nameOrOptions === 'object' ? nameOrOptions?.inputSchema : undefined,
|
|
81
|
+
outputSchema: typeof nameOrOptions === 'object' ? nameOrOptions?.outputSchema : undefined,
|
|
82
|
+
annotations: typeof nameOrOptions === 'object' ? nameOrOptions?.annotations : undefined,
|
|
83
|
+
destructive: typeof nameOrOptions === 'object' ? nameOrOptions?.destructive : undefined,
|
|
84
|
+
scopes: typeof nameOrOptions === 'object' ? nameOrOptions?.scopes : undefined,
|
|
63
85
|
}
|
|
64
86
|
|
|
65
87
|
const list = meta[elementChildren(type)]
|
|
@@ -76,9 +98,10 @@ function elementChildren(type: McpElementType) {
|
|
|
76
98
|
}
|
|
77
99
|
|
|
78
100
|
/**
|
|
79
|
-
* Expose a class method as an MCP tool.
|
|
101
|
+
* Expose a class method as an MCP tool. `annotations` follows the MCP safety
|
|
102
|
+
* hints; a tool with `destructiveHint: true` is hidden by default.
|
|
80
103
|
*/
|
|
81
|
-
export function McpTool(options:
|
|
104
|
+
export function McpTool(options: McpToolOptions = {}) {
|
|
82
105
|
return createElementDecorator('tool')(options)
|
|
83
106
|
}
|
|
84
107
|
|
|
@@ -167,4 +190,12 @@ export function schemaFromMetatype(metatype?: any): McpArgumentSchema | undefine
|
|
|
167
190
|
default:
|
|
168
191
|
return undefined
|
|
169
192
|
}
|
|
170
|
-
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Return whether a tool must be hidden because it is destructive and the server
|
|
197
|
+
* has not explicitly authorised destructive exposure.
|
|
198
|
+
*/
|
|
199
|
+
export function isDestructiveTool(element: McpElementMetaInterface): boolean {
|
|
200
|
+
return element.annotations?.destructiveHint === true || element.destructive === true;
|
|
201
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {MiddlewareCallable} from "../../types/
|
|
2
|
-
import {getControllerMetadata} from "../../core/
|
|
1
|
+
import type {MiddlewareCallable} from "../../types/middleware.ts";
|
|
2
|
+
import {getControllerMetadata} from "../../core/controller/metadata.ts";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export function Middleware(middleware: MiddlewareCallable) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import type {ContextInterface, ParamMetaInterface} from "../../types/index.ts";
|
|
3
|
-
import {METADATA_KEYS
|
|
3
|
+
import {METADATA_KEYS} from "../constants/decorators.constant.ts";
|
|
4
|
+
import {Parametrable} from "../enums/http-parameters.enum.ts";
|
|
4
5
|
|
|
5
6
|
function createRouteParametrableDecorator(type: ParamMetaInterface['type'], callable?: (context: ContextInterface) => any) {
|
|
6
7
|
return (key?: string) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {getControllerMetadata} from "../../core/
|
|
2
|
-
import {HttpMethod} from "../
|
|
3
|
-
import {ControllerMetaInterface, RouteDecoratorCallable, RouteMetaInterface} from "../../types/
|
|
1
|
+
import {getControllerMetadata} from "../../core/controller/metadata.ts";
|
|
2
|
+
import {HttpMethod} from "../enums/http-method.enum.ts";
|
|
3
|
+
import type {ControllerMetaInterface, RouteDecoratorCallable, RouteMetaInterface} from "../../types/controller.ts";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
function stabilizeRoute(meta: ControllerMetaInterface, {path, method, propertyKey}: Partial<RouteMetaInterface>) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import {METADATA_KEYS} from "../constants/decorators.constant.ts";
|
|
3
|
-
import {getControllerMetadata} from "../../core/controller/
|
|
4
|
-
import {RouteInteractionsSubscriber} from "../../types/router.ts";
|
|
3
|
+
import {getControllerMetadata} from "../../core/controller/metadata.ts";
|
|
4
|
+
import type {RouteInteractionsSubscriber} from "../../types/router.ts";
|
|
5
5
|
import { Raiton } from "../../core/raiton.ts";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import {getSchedulerMetadata, registerScheduler, unregisterScheduler} from "../../core/scheduler/
|
|
3
|
-
import {Injectable} from "./
|
|
2
|
+
import {getSchedulerMetadata, registerScheduler, unregisterScheduler} from "../../core/scheduler/metadata.ts";
|
|
3
|
+
import {Injectable} from "./injection.decorator.ts";
|
|
4
4
|
import {LifetimeEnum} from "@protorians/core";
|
|
5
5
|
import {parseDuration} from "../../core/scheduler/duration.ts";
|
|
6
|
-
import {TaskTriggerEnum} from "../enums/
|
|
6
|
+
import {TaskTriggerEnum} from "../enums/scheduler.enum.ts";
|
|
7
7
|
import type {
|
|
8
8
|
CronOptionsInterface,
|
|
9
9
|
IntervalOptionsInterface,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {getSocketMetadata, registerSocket} from "../../core/socket/
|
|
2
|
-
import {Injectable} from "
|
|
1
|
+
import {getSocketMetadata, registerSocket} from "../../core/socket/metadata.ts";
|
|
2
|
+
import {Injectable} from "./injection.decorator.ts";
|
|
3
3
|
import {LifetimeEnum} from "@protorians/core";
|
|
4
|
-
import {SocketEventType} from "../../types/index.ts";
|
|
4
|
+
import type {SocketEventType} from "../../types/index.ts";
|
|
5
5
|
|
|
6
6
|
export function Socket(namespace = '/') {
|
|
7
7
|
return (target: any) => {
|