@c9up/ream 0.1.3
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/LICENSE +21 -0
- package/README.md +70 -0
- package/dist/Application.d.ts +71 -0
- package/dist/Application.d.ts.map +1 -0
- package/dist/Application.js +151 -0
- package/dist/Application.js.map +1 -0
- package/dist/Codemods.d.ts +16 -0
- package/dist/Codemods.d.ts.map +1 -0
- package/dist/Codemods.js +277 -0
- package/dist/Codemods.js.map +1 -0
- package/dist/ConfigLoader.d.ts +29 -0
- package/dist/ConfigLoader.d.ts.map +1 -0
- package/dist/ConfigLoader.js +43 -0
- package/dist/ConfigLoader.js.map +1 -0
- package/dist/ErrorBoundary.d.ts +51 -0
- package/dist/ErrorBoundary.d.ts.map +1 -0
- package/dist/ErrorBoundary.js +122 -0
- package/dist/ErrorBoundary.js.map +1 -0
- package/dist/GracefulShutdown.d.ts +28 -0
- package/dist/GracefulShutdown.d.ts.map +1 -0
- package/dist/GracefulShutdown.js +55 -0
- package/dist/GracefulShutdown.js.map +1 -0
- package/dist/HealthCheck.d.ts +42 -0
- package/dist/HealthCheck.d.ts.map +1 -0
- package/dist/HealthCheck.js +65 -0
- package/dist/HealthCheck.js.map +1 -0
- package/dist/HotReload.d.ts +28 -0
- package/dist/HotReload.d.ts.map +1 -0
- package/dist/HotReload.js +60 -0
- package/dist/HotReload.js.map +1 -0
- package/dist/HttpKernel.d.ts +62 -0
- package/dist/HttpKernel.d.ts.map +1 -0
- package/dist/HttpKernel.js +210 -0
- package/dist/HttpKernel.js.map +1 -0
- package/dist/Ignitor.d.ts +195 -0
- package/dist/Ignitor.d.ts.map +1 -0
- package/dist/Ignitor.js +505 -0
- package/dist/Ignitor.js.map +1 -0
- package/dist/Provider.d.ts +54 -0
- package/dist/Provider.d.ts.map +1 -0
- package/dist/Provider.js +37 -0
- package/dist/Provider.js.map +1 -0
- package/dist/bodyparser/BodyParserMiddleware.d.ts +38 -0
- package/dist/bodyparser/BodyParserMiddleware.d.ts.map +1 -0
- package/dist/bodyparser/BodyParserMiddleware.js +143 -0
- package/dist/bodyparser/BodyParserMiddleware.js.map +1 -0
- package/dist/bodyparser/MultipartFile.d.ts +77 -0
- package/dist/bodyparser/MultipartFile.d.ts.map +1 -0
- package/dist/bodyparser/MultipartFile.js +138 -0
- package/dist/bodyparser/MultipartFile.js.map +1 -0
- package/dist/bodyparser/parseSize.d.ts +6 -0
- package/dist/bodyparser/parseSize.d.ts.map +1 -0
- package/dist/bodyparser/parseSize.js +21 -0
- package/dist/bodyparser/parseSize.js.map +1 -0
- package/dist/bootstrap/hyper-server.d.ts +27 -0
- package/dist/bootstrap/hyper-server.d.ts.map +1 -0
- package/dist/bootstrap/hyper-server.js +63 -0
- package/dist/bootstrap/hyper-server.js.map +1 -0
- package/dist/console/CommandRunner.d.ts +18 -0
- package/dist/console/CommandRunner.d.ts.map +1 -0
- package/dist/console/CommandRunner.js +65 -0
- package/dist/console/CommandRunner.js.map +1 -0
- package/dist/container/Container.d.ts +60 -0
- package/dist/container/Container.d.ts.map +1 -0
- package/dist/container/Container.js +329 -0
- package/dist/container/Container.js.map +1 -0
- package/dist/container/types.d.ts +25 -0
- package/dist/container/types.d.ts.map +1 -0
- package/dist/container/types.js +6 -0
- package/dist/container/types.js.map +1 -0
- package/dist/decorators/Lazy.d.ts +19 -0
- package/dist/decorators/Lazy.d.ts.map +1 -0
- package/dist/decorators/Lazy.js +53 -0
- package/dist/decorators/Lazy.js.map +1 -0
- package/dist/decorators/Service.d.ts +48 -0
- package/dist/decorators/Service.d.ts.map +1 -0
- package/dist/decorators/Service.js +70 -0
- package/dist/decorators/Service.js.map +1 -0
- package/dist/errors/FuzzyMatcher.d.ts +41 -0
- package/dist/errors/FuzzyMatcher.d.ts.map +1 -0
- package/dist/errors/FuzzyMatcher.js +81 -0
- package/dist/errors/FuzzyMatcher.js.map +1 -0
- package/dist/errors/ModuleErrors.d.ts +41 -0
- package/dist/errors/ModuleErrors.d.ts.map +1 -0
- package/dist/errors/ModuleErrors.js +65 -0
- package/dist/errors/ModuleErrors.js.map +1 -0
- package/dist/errors/PipelineStageError.d.ts +31 -0
- package/dist/errors/PipelineStageError.d.ts.map +1 -0
- package/dist/errors/PipelineStageError.js +77 -0
- package/dist/errors/PipelineStageError.js.map +1 -0
- package/dist/errors/ReamError.d.ts +50 -0
- package/dist/errors/ReamError.d.ts.map +1 -0
- package/dist/errors/ReamError.js +108 -0
- package/dist/errors/ReamError.js.map +1 -0
- package/dist/events/Emitter.d.ts +124 -0
- package/dist/events/Emitter.d.ts.map +1 -0
- package/dist/events/Emitter.js +271 -0
- package/dist/events/Emitter.js.map +1 -0
- package/dist/events/EventsProvider.d.ts +28 -0
- package/dist/events/EventsProvider.d.ts.map +1 -0
- package/dist/events/EventsProvider.js +36 -0
- package/dist/events/EventsProvider.js.map +1 -0
- package/dist/events/config.d.ts +8 -0
- package/dist/events/config.d.ts.map +1 -0
- package/dist/events/config.js +4 -0
- package/dist/events/config.js.map +1 -0
- package/dist/events/configure.d.ts +10 -0
- package/dist/events/configure.d.ts.map +1 -0
- package/dist/events/configure.js +11 -0
- package/dist/events/configure.js.map +1 -0
- package/dist/events/helix/helpers.d.ts +62 -0
- package/dist/events/helix/helpers.d.ts.map +1 -0
- package/dist/events/helix/helpers.js +187 -0
- package/dist/events/helix/helpers.js.map +1 -0
- package/dist/events/index.d.ts +17 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +15 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/native.d.ts +21 -0
- package/dist/events/native.d.ts.map +1 -0
- package/dist/events/native.js +17 -0
- package/dist/events/native.js.map +1 -0
- package/dist/events/services/main.d.ts +18 -0
- package/dist/events/services/main.d.ts.map +1 -0
- package/dist/events/services/main.js +31 -0
- package/dist/events/services/main.js.map +1 -0
- package/dist/events/testing/FakeBus.d.ts +66 -0
- package/dist/events/testing/FakeBus.d.ts.map +1 -0
- package/dist/events/testing/FakeBus.js +356 -0
- package/dist/events/testing/FakeBus.js.map +1 -0
- package/dist/graphql/GraphQLEngine.d.ts +69 -0
- package/dist/graphql/GraphQLEngine.d.ts.map +1 -0
- package/dist/graphql/GraphQLEngine.js +309 -0
- package/dist/graphql/GraphQLEngine.js.map +1 -0
- package/dist/graphql/GraphQLProvider.d.ts +32 -0
- package/dist/graphql/GraphQLProvider.d.ts.map +1 -0
- package/dist/graphql/GraphQLProvider.js +49 -0
- package/dist/graphql/GraphQLProvider.js.map +1 -0
- package/dist/helpers/base64.d.ts +40 -0
- package/dist/helpers/base64.d.ts.map +1 -0
- package/dist/helpers/base64.js +70 -0
- package/dist/helpers/base64.js.map +1 -0
- package/dist/helpers/index.d.ts +7 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +5 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/is.d.ts +101 -0
- package/dist/helpers/is.d.ts.map +1 -0
- package/dist/helpers/is.js +151 -0
- package/dist/helpers/is.js.map +1 -0
- package/dist/helpers/napi-loader.d.ts +46 -0
- package/dist/helpers/napi-loader.d.ts.map +1 -0
- package/dist/helpers/napi-loader.js +69 -0
- package/dist/helpers/napi-loader.js.map +1 -0
- package/dist/helpers/safeEqual.d.ts +9 -0
- package/dist/helpers/safeEqual.d.ts.map +1 -0
- package/dist/helpers/safeEqual.js +16 -0
- package/dist/helpers/safeEqual.js.map +1 -0
- package/dist/helpers/string.d.ts +161 -0
- package/dist/helpers/string.d.ts.map +1 -0
- package/dist/helpers/string.js +429 -0
- package/dist/helpers/string.js.map +1 -0
- package/dist/helpers/types.d.ts +83 -0
- package/dist/helpers/types.d.ts.map +1 -0
- package/dist/helpers/types.js +6 -0
- package/dist/helpers/types.js.map +1 -0
- package/dist/http/Exception.d.ts +103 -0
- package/dist/http/Exception.d.ts.map +1 -0
- package/dist/http/Exception.js +228 -0
- package/dist/http/Exception.js.map +1 -0
- package/dist/http/HttpContext.d.ts +69 -0
- package/dist/http/HttpContext.d.ts.map +1 -0
- package/dist/http/HttpContext.js +55 -0
- package/dist/http/HttpContext.js.map +1 -0
- package/dist/http/RedirectBuilder.d.ts +31 -0
- package/dist/http/RedirectBuilder.d.ts.map +1 -0
- package/dist/http/RedirectBuilder.js +75 -0
- package/dist/http/RedirectBuilder.js.map +1 -0
- package/dist/http/Request.d.ts +160 -0
- package/dist/http/Request.d.ts.map +1 -0
- package/dist/http/Request.js +484 -0
- package/dist/http/Request.js.map +1 -0
- package/dist/http/Response.d.ts +114 -0
- package/dist/http/Response.d.ts.map +1 -0
- package/dist/http/Response.js +303 -0
- package/dist/http/Response.js.map +1 -0
- package/dist/http/SseStream.d.ts +89 -0
- package/dist/http/SseStream.d.ts.map +1 -0
- package/dist/http/SseStream.js +228 -0
- package/dist/http/SseStream.js.map +1 -0
- package/dist/http/urlDecode.d.ts +8 -0
- package/dist/http/urlDecode.d.ts.map +1 -0
- package/dist/http/urlDecode.js +18 -0
- package/dist/http/urlDecode.js.map +1 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/Pipeline.d.ts +36 -0
- package/dist/middleware/Pipeline.d.ts.map +1 -0
- package/dist/middleware/Pipeline.js +104 -0
- package/dist/middleware/Pipeline.js.map +1 -0
- package/dist/openapi/OpenApiGenerator.d.ts +58 -0
- package/dist/openapi/OpenApiGenerator.d.ts.map +1 -0
- package/dist/openapi/OpenApiGenerator.js +192 -0
- package/dist/openapi/OpenApiGenerator.js.map +1 -0
- package/dist/openapi/OpenApiMiddleware.d.ts +24 -0
- package/dist/openapi/OpenApiMiddleware.d.ts.map +1 -0
- package/dist/openapi/OpenApiMiddleware.js +78 -0
- package/dist/openapi/OpenApiMiddleware.js.map +1 -0
- package/dist/openapi/OpenApiProvider.d.ts +36 -0
- package/dist/openapi/OpenApiProvider.d.ts.map +1 -0
- package/dist/openapi/OpenApiProvider.js +42 -0
- package/dist/openapi/OpenApiProvider.js.map +1 -0
- package/dist/resources/ApiResource.d.ts +45 -0
- package/dist/resources/ApiResource.d.ts.map +1 -0
- package/dist/resources/ApiResource.js +58 -0
- package/dist/resources/ApiResource.js.map +1 -0
- package/dist/router/Router.d.ts +205 -0
- package/dist/router/Router.d.ts.map +1 -0
- package/dist/router/Router.js +552 -0
- package/dist/router/Router.js.map +1 -0
- package/dist/rpc/RpcProvider.d.ts +34 -0
- package/dist/rpc/RpcProvider.d.ts.map +1 -0
- package/dist/rpc/RpcProvider.js +37 -0
- package/dist/rpc/RpcProvider.js.map +1 -0
- package/dist/rpc/RpcRouter.d.ts +61 -0
- package/dist/rpc/RpcRouter.d.ts.map +1 -0
- package/dist/rpc/RpcRouter.js +187 -0
- package/dist/rpc/RpcRouter.js.map +1 -0
- package/dist/scheduler/Schedule.d.ts +53 -0
- package/dist/scheduler/Schedule.d.ts.map +1 -0
- package/dist/scheduler/Schedule.js +76 -0
- package/dist/scheduler/Schedule.js.map +1 -0
- package/dist/scheduler/ScheduleProvider.d.ts +56 -0
- package/dist/scheduler/ScheduleProvider.d.ts.map +1 -0
- package/dist/scheduler/ScheduleProvider.js +145 -0
- package/dist/scheduler/ScheduleProvider.js.map +1 -0
- package/dist/scheduler/Scheduler.d.ts +209 -0
- package/dist/scheduler/Scheduler.d.ts.map +1 -0
- package/dist/scheduler/Scheduler.js +432 -0
- package/dist/scheduler/Scheduler.js.map +1 -0
- package/dist/scheduler/index.d.ts +14 -0
- package/dist/scheduler/index.d.ts.map +1 -0
- package/dist/scheduler/index.js +6 -0
- package/dist/scheduler/index.js.map +1 -0
- package/dist/scheduler/locks/LockBackend.d.ts +37 -0
- package/dist/scheduler/locks/LockBackend.d.ts.map +1 -0
- package/dist/scheduler/locks/LockBackend.js +13 -0
- package/dist/scheduler/locks/LockBackend.js.map +1 -0
- package/dist/scheduler/locks/MemoryLockBackend.d.ts +39 -0
- package/dist/scheduler/locks/MemoryLockBackend.d.ts.map +1 -0
- package/dist/scheduler/locks/MemoryLockBackend.js +71 -0
- package/dist/scheduler/locks/MemoryLockBackend.js.map +1 -0
- package/dist/scheduler/observability/ErrorReporter.d.ts +15 -0
- package/dist/scheduler/observability/ErrorReporter.d.ts.map +1 -0
- package/dist/scheduler/observability/ErrorReporter.js +13 -0
- package/dist/scheduler/observability/ErrorReporter.js.map +1 -0
- package/dist/scheduler/observability/ScheduleEvent.d.ts +57 -0
- package/dist/scheduler/observability/ScheduleEvent.d.ts.map +1 -0
- package/dist/scheduler/observability/ScheduleEvent.js +12 -0
- package/dist/scheduler/observability/ScheduleEvent.js.map +1 -0
- package/dist/scheduler/observability/ScheduleEventSink.d.ts +20 -0
- package/dist/scheduler/observability/ScheduleEventSink.d.ts.map +1 -0
- package/dist/scheduler/observability/ScheduleEventSink.js +17 -0
- package/dist/scheduler/observability/ScheduleEventSink.js.map +1 -0
- package/dist/scheduler/observability/StatsTracker.d.ts +50 -0
- package/dist/scheduler/observability/StatsTracker.d.ts.map +1 -0
- package/dist/scheduler/observability/StatsTracker.js +96 -0
- package/dist/scheduler/observability/StatsTracker.js.map +1 -0
- package/dist/security/CookieSigner.d.ts +13 -0
- package/dist/security/CookieSigner.d.ts.map +1 -0
- package/dist/security/CookieSigner.js +51 -0
- package/dist/security/CookieSigner.js.map +1 -0
- package/dist/security/SignedUrl.d.ts +17 -0
- package/dist/security/SignedUrl.d.ts.map +1 -0
- package/dist/security/SignedUrl.js +63 -0
- package/dist/security/SignedUrl.js.map +1 -0
- package/dist/security/crypto.d.ts +25 -0
- package/dist/security/crypto.d.ts.map +1 -0
- package/dist/security/crypto.js +82 -0
- package/dist/security/crypto.js.map +1 -0
- package/dist/server/HyperServer.d.ts +64 -0
- package/dist/server/HyperServer.d.ts.map +1 -0
- package/dist/server/HyperServer.js +54 -0
- package/dist/server/HyperServer.js.map +1 -0
- package/dist/server/Server.d.ts +68 -0
- package/dist/server/Server.d.ts.map +1 -0
- package/dist/server/Server.js +113 -0
- package/dist/server/Server.js.map +1 -0
- package/dist/services/app.d.ts +14 -0
- package/dist/services/app.d.ts.map +1 -0
- package/dist/services/app.js +27 -0
- package/dist/services/app.js.map +1 -0
- package/dist/services/router.d.ts +21 -0
- package/dist/services/router.d.ts.map +1 -0
- package/dist/services/router.js +36 -0
- package/dist/services/router.js.map +1 -0
- package/dist/services/server.d.ts +16 -0
- package/dist/services/server.d.ts.map +1 -0
- package/dist/services/server.js +32 -0
- package/dist/services/server.js.map +1 -0
- package/dist/session/Session.d.ts +88 -0
- package/dist/session/Session.d.ts.map +1 -0
- package/dist/session/Session.js +186 -0
- package/dist/session/Session.js.map +1 -0
- package/dist/session/SessionMiddleware.d.ts +16 -0
- package/dist/session/SessionMiddleware.d.ts.map +1 -0
- package/dist/session/SessionMiddleware.js +132 -0
- package/dist/session/SessionMiddleware.js.map +1 -0
- package/dist/session/drivers/CookieDriver.d.ts +17 -0
- package/dist/session/drivers/CookieDriver.d.ts.map +1 -0
- package/dist/session/drivers/CookieDriver.js +42 -0
- package/dist/session/drivers/CookieDriver.js.map +1 -0
- package/dist/session/drivers/MemoryDriver.d.ts +9 -0
- package/dist/session/drivers/MemoryDriver.d.ts.map +1 -0
- package/dist/session/drivers/MemoryDriver.js +24 -0
- package/dist/session/drivers/MemoryDriver.js.map +1 -0
- package/dist/storage/S3Driver.d.ts +27 -0
- package/dist/storage/S3Driver.d.ts.map +1 -0
- package/dist/storage/S3Driver.js +135 -0
- package/dist/storage/S3Driver.js.map +1 -0
- package/dist/storage/StaticMiddleware.d.ts +27 -0
- package/dist/storage/StaticMiddleware.d.ts.map +1 -0
- package/dist/storage/StaticMiddleware.js +153 -0
- package/dist/storage/StaticMiddleware.js.map +1 -0
- package/dist/storage/StaticProvider.d.ts +26 -0
- package/dist/storage/StaticProvider.d.ts.map +1 -0
- package/dist/storage/StaticProvider.js +31 -0
- package/dist/storage/StaticProvider.js.map +1 -0
- package/dist/storage/StorageManager.d.ts +31 -0
- package/dist/storage/StorageManager.d.ts.map +1 -0
- package/dist/storage/StorageManager.js +120 -0
- package/dist/storage/StorageManager.js.map +1 -0
- package/dist/testing/RequestBuilder.d.ts +67 -0
- package/dist/testing/RequestBuilder.d.ts.map +1 -0
- package/dist/testing/RequestBuilder.js +202 -0
- package/dist/testing/RequestBuilder.js.map +1 -0
- package/dist/testing/TestClient.d.ts +96 -0
- package/dist/testing/TestClient.d.ts.map +1 -0
- package/dist/testing/TestClient.js +263 -0
- package/dist/testing/TestClient.js.map +1 -0
- package/dist/types/helpers.d.ts +47 -0
- package/dist/types/helpers.d.ts.map +1 -0
- package/dist/types/helpers.js +5 -0
- package/dist/types/helpers.js.map +1 -0
- package/events.darwin-arm64.node +0 -0
- package/events.darwin-x64.node +0 -0
- package/events.linux-arm64-gnu.node +0 -0
- package/events.linux-x64-gnu.node +0 -0
- package/events.win32-x64-msvc.node +0 -0
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +106 -0
- package/scheduler.darwin-arm64.node +0 -0
- package/scheduler.darwin-x64.node +0 -0
- package/scheduler.linux-arm64-gnu.node +0 -0
- package/scheduler.linux-x64-gnu.node +0 -0
- package/scheduler.win32-x64-msvc.node +0 -0
- package/scripts/copy-napi.mjs +113 -0
- package/src/Application.ts +177 -0
- package/src/Codemods.ts +343 -0
- package/src/ConfigLoader.ts +49 -0
- package/src/ErrorBoundary.ts +157 -0
- package/src/GracefulShutdown.ts +80 -0
- package/src/HealthCheck.ts +96 -0
- package/src/HotReload.ts +78 -0
- package/src/HttpKernel.ts +305 -0
- package/src/Ignitor.ts +656 -0
- package/src/Provider.ts +74 -0
- package/src/bodyparser/BodyParserMiddleware.ts +183 -0
- package/src/bodyparser/MultipartFile.ts +181 -0
- package/src/bodyparser/parseSize.ts +19 -0
- package/src/bootstrap/hyper-server.ts +78 -0
- package/src/console/CommandRunner.ts +82 -0
- package/src/container/Container.ts +383 -0
- package/src/container/types.ts +30 -0
- package/src/decorators/Lazy.ts +57 -0
- package/src/decorators/Service.ts +85 -0
- package/src/errors/FuzzyMatcher.ts +93 -0
- package/src/errors/ModuleErrors.ts +73 -0
- package/src/errors/PipelineStageError.ts +97 -0
- package/src/errors/ReamError.ts +138 -0
- package/src/events/Emitter.ts +333 -0
- package/src/events/EventsProvider.ts +58 -0
- package/src/events/config.ts +10 -0
- package/src/events/configure.ts +19 -0
- package/src/events/helix/helpers.ts +260 -0
- package/src/events/index.ts +22 -0
- package/src/events/native.ts +37 -0
- package/src/events/services/main.ts +39 -0
- package/src/events/testing/FakeBus.ts +420 -0
- package/src/graphql/GraphQLEngine.ts +421 -0
- package/src/graphql/GraphQLProvider.ts +59 -0
- package/src/helpers/base64.ts +72 -0
- package/src/helpers/index.ts +6 -0
- package/src/helpers/is.ts +162 -0
- package/src/helpers/napi-loader.ts +106 -0
- package/src/helpers/safeEqual.ts +15 -0
- package/src/helpers/string.ts +469 -0
- package/src/helpers/types.ts +100 -0
- package/src/http/Exception.ts +272 -0
- package/src/http/HttpContext.ts +108 -0
- package/src/http/RedirectBuilder.ts +89 -0
- package/src/http/Request.ts +540 -0
- package/src/http/Response.ts +351 -0
- package/src/http/SseStream.ts +250 -0
- package/src/http/urlDecode.ts +18 -0
- package/src/index.ts +263 -0
- package/src/middleware/Pipeline.ts +136 -0
- package/src/openapi/OpenApiGenerator.ts +254 -0
- package/src/openapi/OpenApiMiddleware.ts +101 -0
- package/src/openapi/OpenApiProvider.ts +67 -0
- package/src/resources/ApiResource.ts +79 -0
- package/src/router/Router.ts +733 -0
- package/src/rpc/RpcProvider.ts +54 -0
- package/src/rpc/RpcRouter.ts +243 -0
- package/src/scheduler/Schedule.ts +96 -0
- package/src/scheduler/ScheduleProvider.ts +177 -0
- package/src/scheduler/Scheduler.ts +601 -0
- package/src/scheduler/index.ts +24 -0
- package/src/scheduler/locks/LockBackend.ts +38 -0
- package/src/scheduler/locks/MemoryLockBackend.ts +85 -0
- package/src/scheduler/observability/ErrorReporter.ts +13 -0
- package/src/scheduler/observability/ScheduleEvent.ts +61 -0
- package/src/scheduler/observability/ScheduleEventSink.ts +21 -0
- package/src/scheduler/observability/StatsTracker.ts +134 -0
- package/src/security/CookieSigner.ts +54 -0
- package/src/security/SignedUrl.ts +71 -0
- package/src/security/crypto.ts +98 -0
- package/src/server/HyperServer.ts +121 -0
- package/src/server/Server.ts +147 -0
- package/src/services/app.ts +34 -0
- package/src/services/router.ts +44 -0
- package/src/services/server.ts +40 -0
- package/src/session/Session.ts +231 -0
- package/src/session/SessionMiddleware.ts +153 -0
- package/src/session/drivers/CookieDriver.ts +48 -0
- package/src/session/drivers/MemoryDriver.ts +29 -0
- package/src/storage/S3Driver.ts +171 -0
- package/src/storage/StaticMiddleware.ts +182 -0
- package/src/storage/StaticProvider.ts +40 -0
- package/src/storage/StorageManager.ts +142 -0
- package/src/testing/RequestBuilder.ts +275 -0
- package/src/testing/TestClient.ts +344 -0
- package/src/types/helpers.ts +52 -0
- package/swcrc.app.json +17 -0
- package/tsconfig.app.json +21 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exception system — AdonisJS-compatible exception handling.
|
|
3
|
+
*
|
|
4
|
+
* - Exception: base class with self-handling support
|
|
5
|
+
* - ExceptionHandler: global exception handler with content negotiation
|
|
6
|
+
* - Built-in E_* exceptions
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Base exception class. Extend this to create self-handling exceptions.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* throw new Exception('Something went wrong', { status: 400, code: 'E_BAD_REQUEST' })
|
|
13
|
+
*
|
|
14
|
+
* Self-handled exception:
|
|
15
|
+
* class PaymentFailed extends Exception {
|
|
16
|
+
* static status = 402
|
|
17
|
+
* static code = 'E_PAYMENT_FAILED'
|
|
18
|
+
* async handle(error: this, ctx: HttpContext) {
|
|
19
|
+
* ctx.response.status(402).json({ error: 'Payment failed' })
|
|
20
|
+
* }
|
|
21
|
+
* async report(error: this, ctx: HttpContext) {
|
|
22
|
+
* logger.error('Payment failed', { userId: ctx.auth.user?.id })
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
export class Exception extends Error {
|
|
27
|
+
static status = 500;
|
|
28
|
+
static code = 'E_UNKNOWN';
|
|
29
|
+
status;
|
|
30
|
+
code;
|
|
31
|
+
constructor(message, options) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = this.constructor.name;
|
|
34
|
+
// biome-ignore lint/suspicious/noExplicitAny: this.constructor is typed as Function; subclass pattern requires the cast
|
|
35
|
+
const ctor = this.constructor;
|
|
36
|
+
this.status = options?.status ?? ctor.status;
|
|
37
|
+
this.code = options?.code ?? ctor.code;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// ─── Built-in exceptions ──────────────────────────────────
|
|
41
|
+
export class E_ROUTE_NOT_FOUND extends Exception {
|
|
42
|
+
static status = 404;
|
|
43
|
+
static code = 'E_ROUTE_NOT_FOUND';
|
|
44
|
+
constructor(method, path) {
|
|
45
|
+
super(`Route not found: ${method} ${path}`, { status: 404, code: 'E_ROUTE_NOT_FOUND' });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class E_UNAUTHORIZED extends Exception {
|
|
49
|
+
static status = 401;
|
|
50
|
+
static code = 'E_UNAUTHORIZED';
|
|
51
|
+
constructor(message = 'Authentication required') {
|
|
52
|
+
super(message, { status: 401, code: 'E_UNAUTHORIZED' });
|
|
53
|
+
}
|
|
54
|
+
handle(_error, ctx) {
|
|
55
|
+
ctx.response.status(401).json({ error: { code: 'E_UNAUTHORIZED', message: this.message } });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export class E_FORBIDDEN extends Exception {
|
|
59
|
+
static status = 403;
|
|
60
|
+
static code = 'E_FORBIDDEN';
|
|
61
|
+
required;
|
|
62
|
+
constructor(message = 'Insufficient permissions', required) {
|
|
63
|
+
super(message, { status: 403, code: 'E_FORBIDDEN' });
|
|
64
|
+
this.required = required;
|
|
65
|
+
}
|
|
66
|
+
handle(_error, ctx) {
|
|
67
|
+
ctx.response.status(403).json({
|
|
68
|
+
error: {
|
|
69
|
+
code: 'E_FORBIDDEN',
|
|
70
|
+
message: this.message,
|
|
71
|
+
...(this.required ? { required: this.required } : {}),
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export class E_VALIDATION_ERROR extends Exception {
|
|
77
|
+
static status = 422;
|
|
78
|
+
static code = 'E_VALIDATION_ERROR';
|
|
79
|
+
errors;
|
|
80
|
+
constructor(errors) {
|
|
81
|
+
super('Validation failed', { status: 422, code: 'E_VALIDATION_ERROR' });
|
|
82
|
+
this.errors = errors;
|
|
83
|
+
}
|
|
84
|
+
handle(_error, ctx) {
|
|
85
|
+
ctx.response.status(422).json({ errors: this.errors });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export class E_ROW_NOT_FOUND extends Exception {
|
|
89
|
+
static status = 404;
|
|
90
|
+
static code = 'E_ROW_NOT_FOUND';
|
|
91
|
+
constructor(model) {
|
|
92
|
+
super(model ? `${model} not found` : 'Resource not found', {
|
|
93
|
+
status: 404,
|
|
94
|
+
code: 'E_ROW_NOT_FOUND',
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
handle(_error, ctx) {
|
|
98
|
+
ctx.response.status(404).json({ error: { code: 'E_ROW_NOT_FOUND', message: this.message } });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export class E_HTTP_EXCEPTION extends Exception {
|
|
102
|
+
constructor(message, status) {
|
|
103
|
+
super(message, { status, code: 'E_HTTP_EXCEPTION' });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// ─── ExceptionHandler ─────────────────────────────────────
|
|
107
|
+
/**
|
|
108
|
+
* Global exception handler — catches all unhandled exceptions and converts
|
|
109
|
+
* them to HTTP responses.
|
|
110
|
+
*
|
|
111
|
+
* Extend this in your app:
|
|
112
|
+
* export default class Handler extends ExceptionHandler {
|
|
113
|
+
* protected debug = app.inDev
|
|
114
|
+
* protected ignoreStatuses = [400, 401, 404, 422]
|
|
115
|
+
* }
|
|
116
|
+
*
|
|
117
|
+
* Flow:
|
|
118
|
+
* 1. If exception has handle() → self-handled (bypass global)
|
|
119
|
+
* 2. Else → this.handle() → content negotiation (JSON or HTML)
|
|
120
|
+
* 3. Then → this.report() → logging/monitoring
|
|
121
|
+
*/
|
|
122
|
+
export class ExceptionHandler {
|
|
123
|
+
debug;
|
|
124
|
+
ignoreStatuses = [400, 401, 404, 422];
|
|
125
|
+
ignoreCodes = [];
|
|
126
|
+
constructor(debug = false) {
|
|
127
|
+
this.debug = debug;
|
|
128
|
+
}
|
|
129
|
+
/** Convert an exception to an HTTP response. */
|
|
130
|
+
async handle(error, ctx) {
|
|
131
|
+
// Self-handled exceptions take over entirely.
|
|
132
|
+
if (error instanceof Exception && typeof error.handle === 'function') {
|
|
133
|
+
await error.handle(error, ctx);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const { status, code } = extractErrorMeta(error);
|
|
137
|
+
const message = this.#errorMessage(error);
|
|
138
|
+
if (wantsJson(ctx)) {
|
|
139
|
+
this.#sendJsonError(ctx, status, code, message, error);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.#sendHtmlError(ctx, status, message);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/** Pick the user-facing message — full detail only in debug mode. */
|
|
146
|
+
#errorMessage(error) {
|
|
147
|
+
if (this.debug && error instanceof Error)
|
|
148
|
+
return error.message;
|
|
149
|
+
if (error instanceof Exception)
|
|
150
|
+
return error.message;
|
|
151
|
+
return 'An internal error occurred';
|
|
152
|
+
}
|
|
153
|
+
#sendJsonError(ctx, status, code, message, error) {
|
|
154
|
+
const errorPayload = { code, message };
|
|
155
|
+
if (this.debug && error instanceof Error && error.stack) {
|
|
156
|
+
errorPayload.stack = error.stack;
|
|
157
|
+
}
|
|
158
|
+
ctx.response.status(status).json({ error: errorPayload });
|
|
159
|
+
}
|
|
160
|
+
#sendHtmlError(ctx, status, message) {
|
|
161
|
+
ctx.response
|
|
162
|
+
.status(status)
|
|
163
|
+
.type('text/html; charset=utf-8')
|
|
164
|
+
.send(`<!DOCTYPE html><html><head><title>Error ${status}</title></head>` +
|
|
165
|
+
`<body><h1>${status}</h1><p>${escapeHtml(message)}</p></body></html>`);
|
|
166
|
+
}
|
|
167
|
+
/** Log/report an exception. Override for custom monitoring. */
|
|
168
|
+
async report(error, ctx) {
|
|
169
|
+
if (error instanceof Exception) {
|
|
170
|
+
if (this.ignoreStatuses.includes(error.status))
|
|
171
|
+
return;
|
|
172
|
+
if (this.ignoreCodes.includes(error.code))
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
// Self-reported exceptions
|
|
176
|
+
if (error instanceof Exception && typeof error.report === 'function') {
|
|
177
|
+
await error.report(error, ctx);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
// Default: log to stderr
|
|
181
|
+
const context = this.context(ctx);
|
|
182
|
+
if (error instanceof Error) {
|
|
183
|
+
console.error(`[${new Date().toISOString()}] ${error.message}`, context, error.stack);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
console.error(`[${new Date().toISOString()}] Unknown error:`, error, context);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/** Provide additional context for error reports. Override for custom data. */
|
|
190
|
+
context(ctx) {
|
|
191
|
+
return {
|
|
192
|
+
requestId: ctx.id,
|
|
193
|
+
method: ctx.request.method(),
|
|
194
|
+
url: ctx.request.url(),
|
|
195
|
+
userId: ctx.auth.user?.id,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/** Extract status + code from an Exception, ReamError, or duck-typed error. */
|
|
200
|
+
function extractErrorMeta(error) {
|
|
201
|
+
let status = 500;
|
|
202
|
+
let code = 'E_UNKNOWN';
|
|
203
|
+
if (error instanceof Exception) {
|
|
204
|
+
status = error.status;
|
|
205
|
+
code = error.code;
|
|
206
|
+
}
|
|
207
|
+
else if (error !== null && typeof error === 'object') {
|
|
208
|
+
if ('status' in error && typeof error.status === 'number')
|
|
209
|
+
status = error.status;
|
|
210
|
+
if ('code' in error && typeof error.code === 'string')
|
|
211
|
+
code = error.code;
|
|
212
|
+
}
|
|
213
|
+
return { status, code };
|
|
214
|
+
}
|
|
215
|
+
/** Content negotiation: JSON unless the client explicitly prefers HTML. */
|
|
216
|
+
function wantsJson(ctx) {
|
|
217
|
+
return (ctx.request.accepts(['json', 'html']) === 'json' ||
|
|
218
|
+
(ctx.request.header('accept')?.includes('application/json') ?? false) ||
|
|
219
|
+
!ctx.request.header('accept')?.includes('text/html'));
|
|
220
|
+
}
|
|
221
|
+
function escapeHtml(str) {
|
|
222
|
+
return str
|
|
223
|
+
.replace(/&/g, '&')
|
|
224
|
+
.replace(/</g, '<')
|
|
225
|
+
.replace(/>/g, '>')
|
|
226
|
+
.replace(/"/g, '"');
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=Exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../src/http/Exception.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAA;IACnB,MAAM,CAAC,IAAI,GAAG,WAAW,CAAA;IAEzB,MAAM,CAAQ;IACd,IAAI,CAAQ;IAEZ,YAAY,OAAe,EAAE,OAA4C;QACvE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QACjC,wHAAwH;QACxH,MAAM,IAAI,GAAG,IAAI,CAAC,WAAsC,CAAA;QACxD,IAAI,CAA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;QACrB,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;IACnB,CAAC;SAAM,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvD,IAAI,QAAQ,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;YAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;QAChF,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;YAAE,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;IAC1E,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;AACzB,CAAC;AAED,2EAA2E;AAC3E,SAAS,SAAS,CAAC,GAAgB;IACjC,OAAO,CACL,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,MAAM;QAChD,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC;QACrE,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,CACrD,CAAA;AACH,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,GAAG;SACP,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HttpContext — fully typed HTTP context for handlers, middleware, and controllers.
|
|
3
|
+
*
|
|
4
|
+
* Replaces Context.http() for HTTP transport. Always has request + response (no ! assertions).
|
|
5
|
+
* Compatible with AdonisJS destructuring: { request, response, auth, params }
|
|
6
|
+
*
|
|
7
|
+
* @implements FR21
|
|
8
|
+
*/
|
|
9
|
+
import type { Emitter } from '../events/Emitter.js';
|
|
10
|
+
import type { RouteUrlResolver } from './RedirectBuilder.js';
|
|
11
|
+
import type { RawRequest } from './Request.js';
|
|
12
|
+
import { Request } from './Request.js';
|
|
13
|
+
import { Response } from './Response.js';
|
|
14
|
+
export interface AuthState {
|
|
15
|
+
authenticated: boolean;
|
|
16
|
+
user?: {
|
|
17
|
+
id: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
roles?: string[];
|
|
20
|
+
permissions?: string[];
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
roles?: string[];
|
|
24
|
+
permissions?: string[];
|
|
25
|
+
}
|
|
26
|
+
export interface RouteInfo {
|
|
27
|
+
pattern: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
middleware: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Controller class + method that owns this route, when the route was
|
|
32
|
+
* registered as `router.get('/x', SomeController, 'method')` (vs an
|
|
33
|
+
* inline arrow handler). Middleware that reads decorator metadata —
|
|
34
|
+
* `@Guard`, `@Permission`, `@Role` (Warden), `@Meta` (Photon) —
|
|
35
|
+
* needs both fields. Absent when the route handler is an inline
|
|
36
|
+
* function. Populated by `HttpKernel` from `match.route.controller`.
|
|
37
|
+
*/
|
|
38
|
+
controller?: object;
|
|
39
|
+
action?: string;
|
|
40
|
+
}
|
|
41
|
+
export declare class HttpContext {
|
|
42
|
+
#private;
|
|
43
|
+
/** Unique request/correlation ID. */
|
|
44
|
+
readonly id: string;
|
|
45
|
+
/** Typed HTTP request. */
|
|
46
|
+
readonly request: Request;
|
|
47
|
+
/** Typed HTTP response builder. */
|
|
48
|
+
readonly response: Response;
|
|
49
|
+
/** Route parameters extracted from the URL pattern. */
|
|
50
|
+
readonly params: Record<string, string>;
|
|
51
|
+
/** Information about the matched route. */
|
|
52
|
+
readonly route: RouteInfo;
|
|
53
|
+
/** Authentication state — populated by auth middleware. */
|
|
54
|
+
auth: AuthState;
|
|
55
|
+
/** Detected locale. */
|
|
56
|
+
locale: string;
|
|
57
|
+
/** Per-request key-value store (for middleware to pass data downstream). */
|
|
58
|
+
readonly store: Map<string, unknown>;
|
|
59
|
+
/**
|
|
60
|
+
* The event bus emitter, when the app registered `EventsProvider`. Lets a
|
|
61
|
+
* handler emit/subscribe without resolving from the container:
|
|
62
|
+
* `ctx.events?.emit('user:updated', user)`. Undefined when events aren't wired.
|
|
63
|
+
*/
|
|
64
|
+
events?: Emitter;
|
|
65
|
+
constructor(id: string, rawRequest: RawRequest, params: Record<string, string>, route: RouteInfo);
|
|
66
|
+
/** @internal Set the route URL resolver (injected by HttpKernel from Router). */
|
|
67
|
+
setRouteUrlResolver(resolver: RouteUrlResolver): void;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=HttpContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpContext.d.ts","sourceRoot":"","sources":["../../src/http/HttpContext.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,MAAM,WAAW,SAAS;IACxB,aAAa,EAAE,OAAO,CAAA;IACtB,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAA;QACV,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;QAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;QACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAA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context.http() for HTTP transport. Always has request + response (no ! assertions).
|
|
5
|
+
* Compatible with AdonisJS destructuring: { request, response, auth, params }
|
|
6
|
+
*
|
|
7
|
+
* @implements FR21
|
|
8
|
+
*/
|
|
9
|
+
import { RedirectBuilder } from './RedirectBuilder.js';
|
|
10
|
+
import { Request } from './Request.js';
|
|
11
|
+
import { Response } from './Response.js';
|
|
12
|
+
export class HttpContext {
|
|
13
|
+
/** Unique request/correlation ID. */
|
|
14
|
+
id;
|
|
15
|
+
/** Typed HTTP request. */
|
|
16
|
+
request;
|
|
17
|
+
/** Typed HTTP response builder. */
|
|
18
|
+
response;
|
|
19
|
+
/** Route parameters extracted from the URL pattern. */
|
|
20
|
+
params;
|
|
21
|
+
/** Information about the matched route. */
|
|
22
|
+
route;
|
|
23
|
+
/** Authentication state — populated by auth middleware. */
|
|
24
|
+
auth = { authenticated: false };
|
|
25
|
+
/** Detected locale. */
|
|
26
|
+
locale = 'en';
|
|
27
|
+
/** Per-request key-value store (for middleware to pass data downstream). */
|
|
28
|
+
store = new Map();
|
|
29
|
+
/**
|
|
30
|
+
* The event bus emitter, when the app registered `EventsProvider`. Lets a
|
|
31
|
+
* handler emit/subscribe without resolving from the container:
|
|
32
|
+
* `ctx.events?.emit('user:updated', user)`. Undefined when events aren't wired.
|
|
33
|
+
*/
|
|
34
|
+
events;
|
|
35
|
+
/** Route URL resolver for redirect().toRoute(). */
|
|
36
|
+
#routeUrlResolver;
|
|
37
|
+
constructor(id, rawRequest, params, route) {
|
|
38
|
+
this.id = id;
|
|
39
|
+
this.params = params;
|
|
40
|
+
this.route = route;
|
|
41
|
+
this.request = new Request(rawRequest, params);
|
|
42
|
+
this.response = new Response();
|
|
43
|
+
// Wire redirect builder with request context
|
|
44
|
+
this.response.setRedirectFactory(() => new RedirectBuilder(this.response, {
|
|
45
|
+
requestUrl: this.request.url(),
|
|
46
|
+
requestReferer: this.request.header('referer'),
|
|
47
|
+
routeUrlResolver: this.#routeUrlResolver,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
/** @internal Set the route URL resolver (injected by HttpKernel from Router). */
|
|
51
|
+
setRouteUrlResolver(resolver) {
|
|
52
|
+
this.#routeUrlResolver = resolver;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=HttpContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpContext.js","sourceRoot":"","sources":["../../src/http/HttpContext.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AA+BxC,MAAM,OAAO,WAAW;IACtB,qCAAqC;IAC5B,EAAE,CAAQ;IAEnB,0BAA0B;IACjB,OAAO,CAAS;IAEzB,mCAAmC;IAC1B,QAAQ,CAAU;IAE3B,uDAAuD;IAC9C,MAAM,CAAwB;IAEvC,2CAA2C;IAClC,KAAK,CAAW;IAEzB,2DAA2D;IAC3D,IAAI,GAAc,EAAE,aAAa,EAAE,KAAK,EAAE,CAAA;IAE1C,uBAAuB;IACvB,MAAM,GAAG,IAAI,CAAA;IAEb,4EAA4E;IACnE,KAAK,GAAyB,IAAI,GAAG,EAAE,CAAA;IAEhD;;;;OAIG;IACH,MAAM,CAAU;IAEhB,mDAAmD;IACnD,iBAAiB,CAAmB;IAEpC,YACE,EAAU,EACV,UAAsB,EACtB,MAA8B,EAC9B,KAAgB;QAEhB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAA;QAE9B,6CAA6C;QAC7C,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAC9B,GAAG,EAAE,CACH,IAAI,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE;YACjC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YAC9B,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;YAC9C,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;SACzC,CAAC,CACL,CAAA;IACH,CAAC;IAED,iFAAiF;IACjF,mBAAmB,CAAC,QAA0B;QAC5C,IAAI,CAAC,iBAAiB,GAAG,QAAQ,CAAA;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RedirectBuilder — fluent API for building redirect responses.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* response.redirect().toPath('/login')
|
|
6
|
+
* response.redirect().status(301).toPath('/new-url')
|
|
7
|
+
* response.redirect().back()
|
|
8
|
+
* response.redirect().withQs({ page: '2' }).toPath('/results')
|
|
9
|
+
* response.redirect().toRoute('posts.show', { id: '42' })
|
|
10
|
+
*/
|
|
11
|
+
import type { Response } from './Response.js';
|
|
12
|
+
export type RouteUrlResolver = (name: string, params?: Record<string, string>) => string;
|
|
13
|
+
export declare class RedirectBuilder {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(response: Response, options?: {
|
|
16
|
+
requestUrl?: string;
|
|
17
|
+
requestReferer?: string;
|
|
18
|
+
routeUrlResolver?: RouteUrlResolver;
|
|
19
|
+
});
|
|
20
|
+
/** Set redirect status code. */
|
|
21
|
+
status(code: number): this;
|
|
22
|
+
/** Forward current query string to the redirect target. */
|
|
23
|
+
withQs(qs?: Record<string, string>): this;
|
|
24
|
+
/** Redirect to an absolute or relative path. */
|
|
25
|
+
toPath(path: string): void;
|
|
26
|
+
/** Redirect to a named route. */
|
|
27
|
+
toRoute(name: string, params?: Record<string, string>): void;
|
|
28
|
+
/** Redirect back to the previous page (Referer header). */
|
|
29
|
+
back(fallback?: string): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=RedirectBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedirectBuilder.d.ts","sourceRoot":"","sources":["../../src/http/RedirectBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAA;AAExF,qBAAa,eAAe;;gBAUxB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;KACpC;IAQH,gCAAgC;IAChC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK1B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IASzC,gDAAgD;IAChD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAO1B,iCAAiC;IACjC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAQ5D,2DAA2D;IAC3D,IAAI,CAAC,QAAQ,SAAM,GAAG,IAAI;CAgB3B"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RedirectBuilder — fluent API for building redirect responses.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* response.redirect().toPath('/login')
|
|
6
|
+
* response.redirect().status(301).toPath('/new-url')
|
|
7
|
+
* response.redirect().back()
|
|
8
|
+
* response.redirect().withQs({ page: '2' }).toPath('/results')
|
|
9
|
+
* response.redirect().toRoute('posts.show', { id: '42' })
|
|
10
|
+
*/
|
|
11
|
+
export class RedirectBuilder {
|
|
12
|
+
#response;
|
|
13
|
+
#status = 302;
|
|
14
|
+
#qs = null;
|
|
15
|
+
#forwardQs = false;
|
|
16
|
+
#requestUrl;
|
|
17
|
+
#requestReferer;
|
|
18
|
+
#routeUrlResolver;
|
|
19
|
+
constructor(response, options) {
|
|
20
|
+
this.#response = response;
|
|
21
|
+
this.#requestUrl = options?.requestUrl;
|
|
22
|
+
this.#requestReferer = options?.requestReferer;
|
|
23
|
+
this.#routeUrlResolver = options?.routeUrlResolver;
|
|
24
|
+
}
|
|
25
|
+
/** Set redirect status code. */
|
|
26
|
+
status(code) {
|
|
27
|
+
this.#status = code;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
/** Forward current query string to the redirect target. */
|
|
31
|
+
withQs(qs) {
|
|
32
|
+
if (qs) {
|
|
33
|
+
this.#qs = qs;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.#forwardQs = true;
|
|
37
|
+
}
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/** Redirect to an absolute or relative path. */
|
|
41
|
+
toPath(path) {
|
|
42
|
+
const url = this.#appendQs(path);
|
|
43
|
+
this.#response.status(this.#status);
|
|
44
|
+
this.#response.header('location', url);
|
|
45
|
+
this.#response.setBody('');
|
|
46
|
+
}
|
|
47
|
+
/** Redirect to a named route. */
|
|
48
|
+
toRoute(name, params) {
|
|
49
|
+
if (!this.#routeUrlResolver) {
|
|
50
|
+
throw new Error('Route URL resolver not configured. Cannot redirect to named route.');
|
|
51
|
+
}
|
|
52
|
+
const path = this.#routeUrlResolver(name, params);
|
|
53
|
+
this.toPath(path);
|
|
54
|
+
}
|
|
55
|
+
/** Redirect back to the previous page (Referer header). */
|
|
56
|
+
back(fallback = '/') {
|
|
57
|
+
const referer = this.#requestReferer ?? fallback;
|
|
58
|
+
this.toPath(referer);
|
|
59
|
+
}
|
|
60
|
+
#appendQs(path) {
|
|
61
|
+
let qs = '';
|
|
62
|
+
if (this.#qs) {
|
|
63
|
+
qs = new URLSearchParams(this.#qs).toString();
|
|
64
|
+
}
|
|
65
|
+
else if (this.#forwardQs && this.#requestUrl) {
|
|
66
|
+
const qsIdx = this.#requestUrl.indexOf('?');
|
|
67
|
+
if (qsIdx !== -1)
|
|
68
|
+
qs = this.#requestUrl.slice(qsIdx + 1);
|
|
69
|
+
}
|
|
70
|
+
if (!qs)
|
|
71
|
+
return path;
|
|
72
|
+
return path.includes('?') ? `${path}&${qs}` : `${path}?${qs}`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=RedirectBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedirectBuilder.js","sourceRoot":"","sources":["../../src/http/RedirectBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,MAAM,OAAO,eAAe;IAC1B,SAAS,CAAU;IACnB,OAAO,GAAG,GAAG,CAAA;IACb,GAAG,GAAkC,IAAI,CAAA;IACzC,UAAU,GAAG,KAAK,CAAA;IAClB,WAAW,CAAS;IACpB,eAAe,CAAS;IACxB,iBAAiB,CAAmB;IAEpC,YACE,QAAkB,EAClB,OAIC;QAED,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,CAAC,WAAW,GAAG,OAAO,EAAE,UAAU,CAAA;QACtC,IAAI,CAAC,eAAe,GAAG,OAAO,EAAE,cAAc,CAAA;QAC9C,IAAI,CAAC,iBAAiB,GAAG,OAAO,EAAE,gBAAgB,CAAA;IACpD,CAAC;IAED,gCAAgC;IAChC,MAAM,CAAC,IAAY;QACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,OAAO,IAAI,CAAA;I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IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YAC3C,IAAI,KAAK,KAAK,CAAC,CAAC;gBAAE,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;QAC1D,CAAC;QACD,IAAI,CAAC,EAAE;YAAE,OAAO,IAAI,CAAA;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,CAAA;IAC/D,CAAC;CACF"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request — wraps raw HTTP request data from the NAPI layer.
|
|
3
|
+
*
|
|
4
|
+
* Provides a fluent, AdonisJS-compatible API for reading request data.
|
|
5
|
+
* JSON body parsing is lazy — deferred until first access via input()/all()/body().
|
|
6
|
+
*
|
|
7
|
+
* @implements FR21
|
|
8
|
+
*/
|
|
9
|
+
import type { Dict } from '../types/helpers.js';
|
|
10
|
+
export interface RawRequest {
|
|
11
|
+
method: string;
|
|
12
|
+
path: string;
|
|
13
|
+
query: string;
|
|
14
|
+
headers: Dict;
|
|
15
|
+
body: string;
|
|
16
|
+
bodyEncoding?: 'utf8' | 'base64';
|
|
17
|
+
/** Socket-level peer address (filled by the HTTP server). */
|
|
18
|
+
remoteAddr?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Resolved client IP — pre-computed by the Rust-side HyperServer using the
|
|
21
|
+
* configured trusted-proxy CIDR list. JS reads this field directly; CIDR
|
|
22
|
+
* matching no longer happens in TS. When absent (mock/test fixtures) the
|
|
23
|
+
* `ip()` accessor falls back to legacy header parsing.
|
|
24
|
+
*/
|
|
25
|
+
ip?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Pre-parsed `multipart/form-data` payload — the HyperServer parses bodies
|
|
28
|
+
* server-side via `multer` and ships fields/files in this typed shape.
|
|
29
|
+
* Files are base64-encoded so the payload stays JSON-safe.
|
|
30
|
+
*/
|
|
31
|
+
multipart?: {
|
|
32
|
+
fields: Array<{
|
|
33
|
+
name: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}>;
|
|
36
|
+
files: Array<{
|
|
37
|
+
fieldName: string;
|
|
38
|
+
clientName: string;
|
|
39
|
+
contentType: string;
|
|
40
|
+
size: number;
|
|
41
|
+
contentB64: string;
|
|
42
|
+
}>;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Pre-parsed `Cookie:` header — name → value map computed by the Rust
|
|
46
|
+
* cookie crate. JS reads via `request.cookie(name)`. When absent (test
|
|
47
|
+
* fixtures), the accessor falls back to inline header parsing.
|
|
48
|
+
*/
|
|
49
|
+
cookies?: Dict;
|
|
50
|
+
}
|
|
51
|
+
export declare class Request {
|
|
52
|
+
#private;
|
|
53
|
+
/**
|
|
54
|
+
* CSRF token for this request (AdonisJS idiom: `request.csrfToken`). Seeded
|
|
55
|
+
* by the `@c9up/blackhole` middleware when CSRF is enabled; `undefined`
|
|
56
|
+
* otherwise. Also published to `ctx.store` for templating helpers.
|
|
57
|
+
*/
|
|
58
|
+
csrfToken?: string;
|
|
59
|
+
constructor(raw: RawRequest, params?: Dict);
|
|
60
|
+
/** HTTP method (GET, POST, etc.). */
|
|
61
|
+
method(): string;
|
|
62
|
+
/** Request URL (path + query string). */
|
|
63
|
+
url(includeQs?: boolean): string;
|
|
64
|
+
/** Request path (without query string). */
|
|
65
|
+
path(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Resolved client IP. The HyperServer computes this once per request from
|
|
68
|
+
* the socket peer + `X-Forwarded-For` / `X-Real-IP` headers, gated by the
|
|
69
|
+
* configured trusted-proxy CIDR list, and ships the resolved value on
|
|
70
|
+
* `request.ip`. JS reads that field as-is.
|
|
71
|
+
*
|
|
72
|
+
* When `#raw.ip` is missing — only happens in test fixtures that
|
|
73
|
+
* hand-build `RawRequest` without going through the Rust pipeline — fall
|
|
74
|
+
* back to the socket peer (`remoteAddr`). Do NOT consult `X-Forwarded-For`
|
|
75
|
+
* or `X-Real-IP` here: those headers are attacker-controlled on direct
|
|
76
|
+
* requests and the trusted-proxy gate lives in Rust. Honouring them in
|
|
77
|
+
* the TS fallback would let test fixtures masking real spoofing
|
|
78
|
+
* regressions (two semantics for the same API). Fixtures that need to
|
|
79
|
+
* simulate a proxy-resolved IP must set `#raw.ip` directly to the
|
|
80
|
+
* desired resolved value.
|
|
81
|
+
*/
|
|
82
|
+
ip(): string;
|
|
83
|
+
/**
|
|
84
|
+
* Return all cookies sent on this request as a name → value map. The
|
|
85
|
+
* HyperServer parses the `Cookie:` header once via the `cookie` crate
|
|
86
|
+
* (RFC 6265) and ships the result on `RawRequest.cookies`. Test fixtures
|
|
87
|
+
* that don't pre-fill the field fall back to inline parsing of the raw
|
|
88
|
+
* header — same tolerant `;`-split with quoted-value passthrough.
|
|
89
|
+
*/
|
|
90
|
+
cookies(): Dict;
|
|
91
|
+
/** Pre-parsed cookie value by name, or `null` when absent. */
|
|
92
|
+
cookie(name: string): string | null;
|
|
93
|
+
/** Get the raw body as a string (decoded from base64 if binary). */
|
|
94
|
+
raw(): string;
|
|
95
|
+
/** Get the raw body as a Buffer (preserves binary integrity for file uploads). */
|
|
96
|
+
rawBuffer(): Buffer;
|
|
97
|
+
/** Get a single request header (case-insensitive). */
|
|
98
|
+
header(key: string): string | undefined;
|
|
99
|
+
/** Get all request headers. */
|
|
100
|
+
headers(): Readonly<Dict>;
|
|
101
|
+
/** Get a single route parameter. */
|
|
102
|
+
param(key: string, defaultValue?: string): string | undefined;
|
|
103
|
+
/** Get all route parameters. */
|
|
104
|
+
params(): Readonly<Dict>;
|
|
105
|
+
/** Get parsed query string as an object. */
|
|
106
|
+
qs(): Dict<unknown>;
|
|
107
|
+
/** Get the parsed request body. */
|
|
108
|
+
body(): unknown;
|
|
109
|
+
/** Get a single input value from body or query string. */
|
|
110
|
+
input<T = unknown>(key: string, defaultValue?: T): T;
|
|
111
|
+
/** Get all input (query string merged with body). */
|
|
112
|
+
all(): Dict<unknown>;
|
|
113
|
+
/** Cherry-pick specific keys from input. */
|
|
114
|
+
only<K extends string>(keys: K[]): Partial<Record<K, unknown>>;
|
|
115
|
+
/** Get all input except specific keys. */
|
|
116
|
+
except(keys: string[]): Dict<unknown>;
|
|
117
|
+
/** Check if the request content-type matches any of the given types. */
|
|
118
|
+
is(types: string[]): string | null;
|
|
119
|
+
/**
|
|
120
|
+
* Content negotiation — which of the offered types does the client accept,
|
|
121
|
+
* honouring RFC 7231 §5.3.2 quality values?
|
|
122
|
+
*
|
|
123
|
+
* Walks the parsed Accept header in descending q-order and returns the
|
|
124
|
+
* first server-offered type that matches. The server's preference order
|
|
125
|
+
* (`types` argument) is the tiebreaker only when multiple client entries
|
|
126
|
+
* share the same q. A bare `accepts(types)` therefore respects the
|
|
127
|
+
* client's stated priorities (`application/json;q=0.9, text/html;q=0.1`
|
|
128
|
+
* beats a server passing `['html', 'json']`).
|
|
129
|
+
*
|
|
130
|
+
* Aliases (`'json'` ↔ `application/json`, `'html'` ↔ `text/html`,
|
|
131
|
+
* `'xml'` ↔ any subtype containing `xml`) are honoured.
|
|
132
|
+
*/
|
|
133
|
+
accepts(types: string[]): string | null;
|
|
134
|
+
/**
|
|
135
|
+
* Language negotiation from Accept-Language honouring RFC 4647 / 7231
|
|
136
|
+
* quality values. Returns the first offered language whose tag (or its
|
|
137
|
+
* primary subtag) matches the highest-q client entry, falling back to
|
|
138
|
+
* `langs[0]` when nothing matches and the client header is empty/absent.
|
|
139
|
+
*/
|
|
140
|
+
language(langs: string[]): string | null;
|
|
141
|
+
/** Get an uploaded file by field name. */
|
|
142
|
+
file(fieldName: string, options?: import('../bodyparser/MultipartFile.js').FileValidationOptions): import('../bodyparser/MultipartFile.js').MultipartFile | null;
|
|
143
|
+
/** Get all uploaded files for a field name. */
|
|
144
|
+
files(fieldName: string, options?: import('../bodyparser/MultipartFile.js').FileValidationOptions): import('../bodyparser/MultipartFile.js').MultipartFile[];
|
|
145
|
+
/** Get all uploaded files. */
|
|
146
|
+
allFiles(): Map<string, import('../bodyparser/MultipartFile.js').MultipartFile[]>;
|
|
147
|
+
/**
|
|
148
|
+
* Pre-parsed `multipart/form-data` payload as the HyperServer wrote it.
|
|
149
|
+
* Returns `undefined` when the request wasn't multipart (or the test
|
|
150
|
+
* fixture didn't fill the field). BodyParser hydrates `MultipartFile`
|
|
151
|
+
* instances from this — application code should keep using
|
|
152
|
+
* `request.file()` / `request.files()`.
|
|
153
|
+
*/
|
|
154
|
+
multipart(): NonNullable<RawRequest['multipart']> | undefined;
|
|
155
|
+
/** @internal Set files (called by BodyParser middleware). */
|
|
156
|
+
setFiles(files: import('../bodyparser/MultipartFile.js').MultipartFile[]): void;
|
|
157
|
+
/** @internal Set the parsed body (called by BodyParser middleware). */
|
|
158
|
+
setParsedBody(body: Dict<unknown>): void;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=Request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Request.d.ts","sourceRoot":"","sources":["../../src/http/Request.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE/C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,IAAI,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAA;IAChC,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;OAKG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;;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