@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,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IoC Container — AdonisJS Fold-compatible dependency injection.
|
|
3
|
+
*
|
|
4
|
+
* - make(Class) auto-constructs any class with @inject(), no explicit binding needed
|
|
5
|
+
* - call(instance, 'method') for method-level injection
|
|
6
|
+
* - singleton() / bind() for explicit factory bindings
|
|
7
|
+
* - swap() / restore() for testing
|
|
8
|
+
*
|
|
9
|
+
* @implements FR11, FR12, FR14, FR16
|
|
10
|
+
*/
|
|
11
|
+
import 'reflect-metadata';
|
|
12
|
+
import type { ServiceFactory, ServiceToken } from './types.js';
|
|
13
|
+
export declare class Container {
|
|
14
|
+
#private;
|
|
15
|
+
/** Register a singleton binding (factory called once, cached). */
|
|
16
|
+
singleton<_T>(token: ServiceToken, factory: ServiceFactory): void;
|
|
17
|
+
/** Register a transient binding (new instance per resolve). */
|
|
18
|
+
bind<_T>(token: ServiceToken, factory: ServiceFactory): void;
|
|
19
|
+
/** Bind an existing value directly. */
|
|
20
|
+
bindValue<T>(token: ServiceToken, value: T): void;
|
|
21
|
+
/**
|
|
22
|
+
* Replace a binding's factory for testing (AdonisJS-compatible swap).
|
|
23
|
+
* Snapshots the existing singleton (if any) so `restore()` re-seats the
|
|
24
|
+
* original instance instead of re-invoking the underlying factory.
|
|
25
|
+
*/
|
|
26
|
+
swap(token: ServiceToken, factory: ServiceFactory): void;
|
|
27
|
+
/**
|
|
28
|
+
* Replace a binding with a literal value for testing. The value is wrapped
|
|
29
|
+
* as a factory internally, so each `resolve()` call returns it unchanged.
|
|
30
|
+
* Pair with `restore()` to undo without losing the original singleton's
|
|
31
|
+
* identity.
|
|
32
|
+
*/
|
|
33
|
+
override<T>(token: ServiceToken, value: T): void;
|
|
34
|
+
/** Restore a specific swap, or all swaps if no token given. */
|
|
35
|
+
restore(token?: ServiceToken): void;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve/construct a class or binding.
|
|
38
|
+
* Like AdonisJS `container.make()`:
|
|
39
|
+
* 1. Check swaps (test overrides)
|
|
40
|
+
* 2. Check cached singletons
|
|
41
|
+
* 3. Check explicit bindings (singleton/bind)
|
|
42
|
+
* 4. Auto-construct if class has @inject() or @Service()
|
|
43
|
+
* 5. Auto-construct any class (plain `new Class()`) as fallback
|
|
44
|
+
*/
|
|
45
|
+
make<T>(token: ServiceToken): T;
|
|
46
|
+
/** Alias for make() — backward compatible. */
|
|
47
|
+
resolve<T>(token: ServiceToken): T;
|
|
48
|
+
/**
|
|
49
|
+
* Call a method on an instance with dependency injection.
|
|
50
|
+
* Like AdonisJS `container.call()`.
|
|
51
|
+
* Resolves method parameters from reflect-metadata and @inject().
|
|
52
|
+
*/
|
|
53
|
+
call<T, K extends string & keyof T>(instance: T, method: K, runtimeValues?: unknown[]): Promise<unknown>;
|
|
54
|
+
/** Check if a token is registered or resolvable. */
|
|
55
|
+
has(token: ServiceToken): boolean;
|
|
56
|
+
get size(): number;
|
|
57
|
+
/** Auto-register all @Service() decorated classes from the global registry. */
|
|
58
|
+
autoRegister(): void;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=Container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../src/container/Container.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,kBAAkB,CAAA;AAKzB,OAAO,KAAK,EAAW,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AASvE,qBAAa,SAAS;;IAgBpB,kEAAkE;IAClE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI;IAKjE,+DAA+D;IAC/D,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI;IAK5D,uCAAuC;IACvC,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAQjD;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI;IASxD;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAIhD,+DAA+D;IAC/D,OAAO,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,IAAI;IAqBnC;;;;;;;;OAQG;IACH,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,GAAG,CAAC;IAI/B,8CAA8C;IAC9C,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,GAAG,CAAC;IAqBlC;;;;OAIG;IACG,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,EACtC,QAAQ,EAAE,CAAC,EACX,MAAM,EAAE,CAAC,EACT,aAAa,CAAC,EAAE,OAAO,EAAE,GACxB,OAAO,CAAC,OAAO,CAAC;IA6BnB,oDAAoD;IACpD,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO;IAUjC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,+EAA+E;IAC/E,YAAY,IAAI,IAAI;CAuJrB"}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IoC Container — AdonisJS Fold-compatible dependency injection.
|
|
3
|
+
*
|
|
4
|
+
* - make(Class) auto-constructs any class with @inject(), no explicit binding needed
|
|
5
|
+
* - call(instance, 'method') for method-level injection
|
|
6
|
+
* - singleton() / bind() for explicit factory bindings
|
|
7
|
+
* - swap() / restore() for testing
|
|
8
|
+
*
|
|
9
|
+
* @implements FR11, FR12, FR14, FR16
|
|
10
|
+
*/
|
|
11
|
+
import 'reflect-metadata';
|
|
12
|
+
import { createLazyProxy, getLazyParams } from '../decorators/Lazy.js';
|
|
13
|
+
import { getInjectTokens, getServiceMetadata, getServiceRegistry } from '../decorators/Service.js';
|
|
14
|
+
import { didYouMean } from '../errors/FuzzyMatcher.js';
|
|
15
|
+
import { ReamError } from '../errors/ReamError.js';
|
|
16
|
+
/**
|
|
17
|
+
* Symbol descriptions that would collide with object-prototype keys if used
|
|
18
|
+
* as raw map keys. We reject them on registration so tokens cannot be used
|
|
19
|
+
* as a prototype-pollution vector.
|
|
20
|
+
*/
|
|
21
|
+
const RESERVED_TOKEN_NAMES = new Set(['__proto__', 'constructor', 'prototype']);
|
|
22
|
+
export class Container {
|
|
23
|
+
#bindings = new Map();
|
|
24
|
+
#singletons = new Map();
|
|
25
|
+
#overrides = new Map();
|
|
26
|
+
/**
|
|
27
|
+
* Snapshot of singletons taken when `swap`/`override` shadows a previously
|
|
28
|
+
* resolved instance. `restore()` re-seats them without re-invoking the
|
|
29
|
+
* original factory, so callers that captured the live reference keep
|
|
30
|
+
* pointing at the same object after the test ends.
|
|
31
|
+
*/
|
|
32
|
+
#singletonBackup = new Map();
|
|
33
|
+
#resolutionStack = [];
|
|
34
|
+
#resolutionSet = new Set();
|
|
35
|
+
// ─── Explicit bindings ────────────────────────────────────
|
|
36
|
+
/** Register a singleton binding (factory called once, cached). */
|
|
37
|
+
singleton(token, factory) {
|
|
38
|
+
const key = this.#tokenToKey(token);
|
|
39
|
+
this.#bindings.set(key, { token, factory, scope: 'singleton', dependencies: [] });
|
|
40
|
+
}
|
|
41
|
+
/** Register a transient binding (new instance per resolve). */
|
|
42
|
+
bind(token, factory) {
|
|
43
|
+
const key = this.#tokenToKey(token);
|
|
44
|
+
this.#bindings.set(key, { token, factory, scope: 'transient', dependencies: [] });
|
|
45
|
+
}
|
|
46
|
+
/** Bind an existing value directly. */
|
|
47
|
+
bindValue(token, value) {
|
|
48
|
+
const key = this.#tokenToKey(token);
|
|
49
|
+
this.#singletons.set(key, value);
|
|
50
|
+
this.#bindings.set(key, { token, factory: () => value, scope: 'singleton', dependencies: [] });
|
|
51
|
+
}
|
|
52
|
+
// ─── Testing ──────────────────────────────────────────────
|
|
53
|
+
/**
|
|
54
|
+
* Replace a binding's factory for testing (AdonisJS-compatible swap).
|
|
55
|
+
* Snapshots the existing singleton (if any) so `restore()` re-seats the
|
|
56
|
+
* original instance instead of re-invoking the underlying factory.
|
|
57
|
+
*/
|
|
58
|
+
swap(token, factory) {
|
|
59
|
+
const key = this.#tokenToKey(token);
|
|
60
|
+
if (!this.#overrides.has(key) && this.#singletons.has(key)) {
|
|
61
|
+
this.#singletonBackup.set(key, this.#singletons.get(key));
|
|
62
|
+
}
|
|
63
|
+
this.#overrides.set(key, factory);
|
|
64
|
+
this.#singletons.delete(key);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Replace a binding with a literal value for testing. The value is wrapped
|
|
68
|
+
* as a factory internally, so each `resolve()` call returns it unchanged.
|
|
69
|
+
* Pair with `restore()` to undo without losing the original singleton's
|
|
70
|
+
* identity.
|
|
71
|
+
*/
|
|
72
|
+
override(token, value) {
|
|
73
|
+
this.swap(token, () => value);
|
|
74
|
+
}
|
|
75
|
+
/** Restore a specific swap, or all swaps if no token given. */
|
|
76
|
+
restore(token) {
|
|
77
|
+
if (token) {
|
|
78
|
+
this.#restoreOne(this.#tokenToKey(token));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
for (const key of [...this.#overrides.keys()]) {
|
|
82
|
+
this.#restoreOne(key);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
#restoreOne(key) {
|
|
86
|
+
this.#overrides.delete(key);
|
|
87
|
+
this.#singletons.delete(key);
|
|
88
|
+
if (this.#singletonBackup.has(key)) {
|
|
89
|
+
this.#singletons.set(key, this.#singletonBackup.get(key));
|
|
90
|
+
this.#singletonBackup.delete(key);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// ─── Resolution ───────────────────────────────────────────
|
|
94
|
+
/**
|
|
95
|
+
* Resolve/construct a class or binding.
|
|
96
|
+
* Like AdonisJS `container.make()`:
|
|
97
|
+
* 1. Check swaps (test overrides)
|
|
98
|
+
* 2. Check cached singletons
|
|
99
|
+
* 3. Check explicit bindings (singleton/bind)
|
|
100
|
+
* 4. Auto-construct if class has @inject() or @Service()
|
|
101
|
+
* 5. Auto-construct any class (plain `new Class()`) as fallback
|
|
102
|
+
*/
|
|
103
|
+
make(token) {
|
|
104
|
+
return this.resolve(token);
|
|
105
|
+
}
|
|
106
|
+
/** Alias for make() — backward compatible. */
|
|
107
|
+
resolve(token) {
|
|
108
|
+
const key = this.#tokenToKey(token);
|
|
109
|
+
if (this.#resolutionSet.has(key)) {
|
|
110
|
+
const cycle = [...this.#resolutionStack, key].join(' → ');
|
|
111
|
+
throw new ReamError('CIRCULAR_DEPENDENCY', `Circular dependency detected: ${cycle}`, {
|
|
112
|
+
hint: 'Use @Lazy() on one of the constructor parameters to break the cycle.',
|
|
113
|
+
context: { chain: cycle },
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
this.#resolutionStack.push(key);
|
|
117
|
+
this.#resolutionSet.add(key);
|
|
118
|
+
try {
|
|
119
|
+
return this.#resolveInner(key, token);
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
this.#resolutionStack.pop();
|
|
123
|
+
this.#resolutionSet.delete(key);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Call a method on an instance with dependency injection.
|
|
128
|
+
* Like AdonisJS `container.call()`.
|
|
129
|
+
* Resolves method parameters from reflect-metadata and @inject().
|
|
130
|
+
*/
|
|
131
|
+
async call(instance, method, runtimeValues) {
|
|
132
|
+
// `Object.getPrototypeOf` is typed `any` in lib.dom, so the assignment
|
|
133
|
+
// narrows it back to a typed constructor without a cast expression.
|
|
134
|
+
const target = Object.getPrototypeOf(instance).constructor;
|
|
135
|
+
const paramTypes = Reflect.getMetadata('design:paramtypes', target.prototype, method) ?? [];
|
|
136
|
+
const args = paramTypes.map((type, index) => {
|
|
137
|
+
// Runtime values take precedence
|
|
138
|
+
if (runtimeValues && index < runtimeValues.length) {
|
|
139
|
+
return runtimeValues[index];
|
|
140
|
+
}
|
|
141
|
+
// Auto-resolve class dependencies — type is a constructor function here
|
|
142
|
+
if (isClassConstructor(type)) {
|
|
143
|
+
return this.resolve(type);
|
|
144
|
+
}
|
|
145
|
+
return undefined;
|
|
146
|
+
});
|
|
147
|
+
const member = instance[method];
|
|
148
|
+
if (!isCallable(member)) {
|
|
149
|
+
throw new Error(`Container.call: '${method}' is not a callable method`);
|
|
150
|
+
}
|
|
151
|
+
return member.apply(instance, args);
|
|
152
|
+
}
|
|
153
|
+
// ─── Introspection ────────────────────────────────────────
|
|
154
|
+
/** Check if a token is registered or resolvable. */
|
|
155
|
+
has(token) {
|
|
156
|
+
const key = this.#tokenToKey(token);
|
|
157
|
+
return (this.#bindings.has(key) ||
|
|
158
|
+
this.#overrides.has(key) ||
|
|
159
|
+
this.#singletons.has(key) ||
|
|
160
|
+
(typeof token === 'function' && getServiceMetadata(token) !== undefined));
|
|
161
|
+
}
|
|
162
|
+
get size() {
|
|
163
|
+
return this.#bindings.size;
|
|
164
|
+
}
|
|
165
|
+
/** Auto-register all @Service() decorated classes from the global registry. */
|
|
166
|
+
autoRegister() {
|
|
167
|
+
for (const [target, metadata] of getServiceRegistry()) {
|
|
168
|
+
const key = metadata.as ?? target.name;
|
|
169
|
+
if (!this.#bindings.has(key)) {
|
|
170
|
+
const targetClass = target;
|
|
171
|
+
this.#bindings.set(key, {
|
|
172
|
+
token: metadata.as ?? target,
|
|
173
|
+
factory: () => this.#autoConstruct(targetClass),
|
|
174
|
+
scope: metadata.scope,
|
|
175
|
+
dependencies: [],
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// ─── Internal resolution ──────────────────────────────────
|
|
181
|
+
#resolveInner(key, token) {
|
|
182
|
+
// 1. Check swaps (test overrides)
|
|
183
|
+
if (this.#overrides.has(key)) {
|
|
184
|
+
// biome-ignore lint/suspicious/noExplicitAny: IoC container factory returns unknown; caller brands via T
|
|
185
|
+
return this.#overrides.get(key)?.();
|
|
186
|
+
}
|
|
187
|
+
// 2. Check cached singletons
|
|
188
|
+
if (this.#singletons.has(key)) {
|
|
189
|
+
// biome-ignore lint/suspicious/noExplicitAny: IoC singleton stored as unknown; caller brands via T
|
|
190
|
+
return this.#singletons.get(key);
|
|
191
|
+
}
|
|
192
|
+
// 3. Check explicit bindings
|
|
193
|
+
const binding = this.#bindings.get(key);
|
|
194
|
+
if (binding) {
|
|
195
|
+
const instance = binding.factory ? binding.factory() : undefined;
|
|
196
|
+
if (binding.scope === 'singleton') {
|
|
197
|
+
this.#singletons.set(key, instance);
|
|
198
|
+
}
|
|
199
|
+
// biome-ignore lint/suspicious/noExplicitAny: IoC binding factory returns unknown; caller brands via T
|
|
200
|
+
return instance;
|
|
201
|
+
}
|
|
202
|
+
// 4. Auto-construct if it's a class
|
|
203
|
+
if (typeof token === 'function') {
|
|
204
|
+
// biome-ignore lint/suspicious/noExplicitAny: IoC auto-construct returns unknown; caller brands via T
|
|
205
|
+
return this.#autoConstruct(token);
|
|
206
|
+
}
|
|
207
|
+
// 5. Not found
|
|
208
|
+
const allKeys = [...this.#bindings.keys(), ...this.#overrides.keys()];
|
|
209
|
+
const suggestion = didYouMean(key, allKeys);
|
|
210
|
+
throw new ReamError('CONTAINER_NOT_FOUND', `No binding found for '${key}'.${suggestion ? ` ${suggestion}` : ''}`, {
|
|
211
|
+
hint: 'Register it with container.singleton() or decorate with @inject().',
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Auto-construct a class by reading its dependency hints.
|
|
216
|
+
*
|
|
217
|
+
* Resolution order (like AdonisJS Fold):
|
|
218
|
+
* 1. static containerInjections._constructor.dependencies — explicit deps array
|
|
219
|
+
* 2. Reflect.getMetadata('design:paramtypes') — decorator metadata (requires SWC/tsc)
|
|
220
|
+
* 3. No params → plain `new Class()`
|
|
221
|
+
*/
|
|
222
|
+
#autoConstruct(target) {
|
|
223
|
+
const metadata = getServiceMetadata(target);
|
|
224
|
+
const scope = metadata?.scope ?? 'transient';
|
|
225
|
+
const key = metadata?.as ?? target.name;
|
|
226
|
+
if (scope === 'singleton' && this.#singletons.has(key)) {
|
|
227
|
+
return this.#singletons.get(key);
|
|
228
|
+
}
|
|
229
|
+
// 1. Check static containerInjections (AdonisJS Fold-compatible, works
|
|
230
|
+
// without emitDecoratorMetadata). The `in` operator narrows the optional
|
|
231
|
+
// field to `unknown`, then `readContainerInjectionDeps` validates the
|
|
232
|
+
// shape at runtime — no type-level cast required.
|
|
233
|
+
const explicitDeps = readContainerInjectionDeps(target);
|
|
234
|
+
// 2. Fallback to reflect-metadata
|
|
235
|
+
const paramTypes = explicitDeps ?? Reflect.getMetadata('design:paramtypes', target) ?? [];
|
|
236
|
+
if (paramTypes.length === 0) {
|
|
237
|
+
const instance = new target();
|
|
238
|
+
if (scope === 'singleton')
|
|
239
|
+
this.#singletons.set(key, instance);
|
|
240
|
+
return instance;
|
|
241
|
+
}
|
|
242
|
+
const injectTokens = getInjectTokens(target);
|
|
243
|
+
const lazyIndices = getLazyParams(target);
|
|
244
|
+
const deps = paramTypes.map((type, index) => {
|
|
245
|
+
const namedToken = injectTokens.get(index);
|
|
246
|
+
// After the typeof check, type is a constructor function and valid as ServiceToken
|
|
247
|
+
const depToken = namedToken ??
|
|
248
|
+
// biome-ignore lint/suspicious/noExplicitAny: reflect-metadata returns unknown; constructor functions are valid ServiceTokens
|
|
249
|
+
(typeof type === 'function' && type !== Object ? type : undefined);
|
|
250
|
+
if (!depToken)
|
|
251
|
+
return undefined;
|
|
252
|
+
if (lazyIndices.includes(index)) {
|
|
253
|
+
// biome-ignore lint/suspicious/noExplicitAny: lazy proxy target must be object; IoC resolution returns unknown
|
|
254
|
+
return createLazyProxy(() => this.resolve(depToken));
|
|
255
|
+
}
|
|
256
|
+
return this.resolve(depToken);
|
|
257
|
+
});
|
|
258
|
+
const instance = new target(...deps);
|
|
259
|
+
if (scope === 'singleton')
|
|
260
|
+
this.#singletons.set(key, instance);
|
|
261
|
+
return instance;
|
|
262
|
+
}
|
|
263
|
+
#tokenToKey(token) {
|
|
264
|
+
if (typeof token === 'string') {
|
|
265
|
+
this.#assertNotReserved(token, 'string');
|
|
266
|
+
return token;
|
|
267
|
+
}
|
|
268
|
+
if (typeof token === 'symbol') {
|
|
269
|
+
// Reject unique `Symbol(x)` — two `Symbol("foo")` calls create distinct
|
|
270
|
+
// symbols, so an override registered with one would be invisible to a
|
|
271
|
+
// resolver holding the other. Force callers onto `Symbol.for(x)` which
|
|
272
|
+
// is the global registry and round-trips across modules.
|
|
273
|
+
if (Symbol.keyFor(token) === undefined) {
|
|
274
|
+
throw new ReamError('CONTAINER_INVALID_TOKEN', `Unique Symbol() tokens are not supported — use Symbol.for("${token.description ?? 'name'}") so different modules see the same symbol.`);
|
|
275
|
+
}
|
|
276
|
+
const desc = token.description;
|
|
277
|
+
if (desc === undefined) {
|
|
278
|
+
throw new ReamError('CONTAINER_INVALID_TOKEN', 'Symbol tokens must have a description.');
|
|
279
|
+
}
|
|
280
|
+
this.#assertNotReserved(desc, 'symbol description');
|
|
281
|
+
return `Symbol(${desc})`;
|
|
282
|
+
}
|
|
283
|
+
return token.name;
|
|
284
|
+
}
|
|
285
|
+
#assertNotReserved(name, kind) {
|
|
286
|
+
if (RESERVED_TOKEN_NAMES.has(name)) {
|
|
287
|
+
throw new ReamError('CONTAINER_RESERVED_TOKEN', `Reserved container token name '${name}'.`, {
|
|
288
|
+
hint: `'${name}' would collide with an Object.prototype key. Pick a different ${kind}.`,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// `design:paramtypes` returns `unknown[]` per our annotation; we narrow each
|
|
294
|
+
// entry before treating it as a class token. `Object` slips through because
|
|
295
|
+
// emitDecoratorMetadata uses it for `any`/`unknown` parameters.
|
|
296
|
+
function isClassConstructor(value) {
|
|
297
|
+
return typeof value === 'function' && value !== Object;
|
|
298
|
+
}
|
|
299
|
+
function isCallable(value) {
|
|
300
|
+
return typeof value === 'function';
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Read `static containerInjections._constructor.dependencies` from a class,
|
|
304
|
+
* AdonisJS Fold-style, when the static is present. The static is undeclared
|
|
305
|
+
* on the constructor signature, so we walk the shape with `in`-narrowing
|
|
306
|
+
* (TS 4.9+) plus a per-element `isServiceToken` guard — no casts.
|
|
307
|
+
*/
|
|
308
|
+
function readContainerInjectionDeps(target) {
|
|
309
|
+
if (!('containerInjections' in target))
|
|
310
|
+
return undefined;
|
|
311
|
+
const injections = target.containerInjections;
|
|
312
|
+
if (typeof injections !== 'object' || injections === null)
|
|
313
|
+
return undefined;
|
|
314
|
+
if (!('_constructor' in injections))
|
|
315
|
+
return undefined;
|
|
316
|
+
const ctor = injections._constructor;
|
|
317
|
+
if (typeof ctor !== 'object' || ctor === null)
|
|
318
|
+
return undefined;
|
|
319
|
+
if (!('dependencies' in ctor))
|
|
320
|
+
return undefined;
|
|
321
|
+
const deps = ctor.dependencies;
|
|
322
|
+
if (!Array.isArray(deps))
|
|
323
|
+
return undefined;
|
|
324
|
+
return deps.every(isServiceToken) ? deps : undefined;
|
|
325
|
+
}
|
|
326
|
+
function isServiceToken(value) {
|
|
327
|
+
return typeof value === 'string' || typeof value === 'symbol' || typeof value === 'function';
|
|
328
|
+
}
|
|
329
|
+
//# sourceMappingURL=Container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Container.js","sourceRoot":"","sources":["../../src/container/Container.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,kBAAkB,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAClG,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAGlD;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAA;AAE/E,MAAM,OAAO,SAAS;IACpB,SAAS,GAAyB,IAAI,GAAG,EAAE,CAAA;IAC3C,WAAW,GAAyB,IAAI,GAAG,EAAE,CAAA;IAC7C,UAAU,GAAgC,IAAI,GAAG,EAAE,CAAA;IACnD;;;;;OAKG;IACH,gBAAgB,GAAyB,IAAI,GAAG,EAAE,CAAA;IAClD,gBAAgB,GAAa,EAAE,CAAA;IAC/B,cAAc,GAAgB,IAAI,GAAG,EAAE,CAAA;IAEvC,6DAA6D;IAE7D,kEAAkE;IAClE,SAAS,CAAK,KAAmB,EAAE,OAAuB;QACxD,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,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;;;;GAKG;AACH,SAAS,0BAA0B,CAAC,MAAc;IAChD,IAAI,CAAC,CAAC,qBAAqB,IAAI,MAAM,CAAC;QAAE,OAAO,SAAS,CAAA;IACxD,MAAM,UAAU,GAAG,MAAM,CAAC,mBAAmB,CAAA;IAC7C,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IAC3E,IAAI,CAAC,CAAC,cAAc,IAAI,UAAU,CAAC;QAAE,OAAO,SAAS,CAAA;IACrD,MAAM,IAAI,GAAG,UAAU,CAAC,YAAY,CAAA;IACpC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IAC/D,IAAI,CAAC,CAAC,cAAc,IAAI,IAAI,CAAC;QAAE,OAAO,SAAS,CAAA;IAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAA;IAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAA;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AACtD,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAA;AAC9F,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Container types and interfaces.
|
|
3
|
+
* @implements FR11, FR14, FR16
|
|
4
|
+
*/
|
|
5
|
+
/** Service scope determines instance lifecycle. */
|
|
6
|
+
export type ServiceScope = 'singleton' | 'transient' | 'request';
|
|
7
|
+
/** Service metadata stored by @Service() decorator. */
|
|
8
|
+
export interface ServiceMetadata {
|
|
9
|
+
scope: ServiceScope;
|
|
10
|
+
/** If set, binds as this named interface instead of the class itself. */
|
|
11
|
+
as?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Token used to resolve a service — class constructor, string name, or registered symbol. */
|
|
14
|
+
export type ServiceToken = (new (...args: any[]) => unknown) | string | symbol;
|
|
15
|
+
/** Factory function for creating service instances. */
|
|
16
|
+
export type ServiceFactory = () => unknown;
|
|
17
|
+
/** Binding entry in the container. */
|
|
18
|
+
export interface Binding {
|
|
19
|
+
token: ServiceToken;
|
|
20
|
+
factory?: ServiceFactory;
|
|
21
|
+
instance?: unknown;
|
|
22
|
+
scope: ServiceScope;
|
|
23
|
+
dependencies: ServiceToken[];
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/container/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,mDAAmD;AACnD,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,CAAA;AAEhE,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,YAAY,CAAA;IACnB,yEAAyE;IACzE,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ;AAED,8FAA8F;AAE9F,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,MAAM,GAAG,MAAM,CAAA;AAE9E,uDAAuD;AACvD,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAA;AAE1C,sCAAsC;AACtC,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,YAAY,CAAA;IACnB,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,YAAY,CAAA;IACnB,YAAY,EAAE,YAAY,EAAE,CAAA;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/container/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Lazy() decorator — deferred injection to break circular dependencies.
|
|
3
|
+
*
|
|
4
|
+
* @implements FR15
|
|
5
|
+
*/
|
|
6
|
+
import 'reflect-metadata';
|
|
7
|
+
/**
|
|
8
|
+
* @Lazy() — marks a constructor parameter for deferred resolution.
|
|
9
|
+
* The dependency is resolved on first property access, not at construction.
|
|
10
|
+
*/
|
|
11
|
+
export declare function Lazy(): ParameterDecorator;
|
|
12
|
+
/** Get lazy parameter indices for a constructor. */
|
|
13
|
+
export declare function getLazyParams(target: object): number[];
|
|
14
|
+
/**
|
|
15
|
+
* Create a lazy proxy that defers resolution until first access.
|
|
16
|
+
* Traps get, set, has, ownKeys, getOwnPropertyDescriptor for full compatibility.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createLazyProxy<T extends object>(resolver: () => T): T;
|
|
19
|
+
//# sourceMappingURL=Lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Lazy.d.ts","sourceRoot":"","sources":["../../src/decorators/Lazy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,kBAAkB,CAAA;AAIzB;;;GAGG;AACH,wBAAgB,IAAI,IAAI,kBAAkB,CAMzC;AAED,oDAAoD;AACpD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAyBtE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Lazy() decorator — deferred injection to break circular dependencies.
|
|
3
|
+
*
|
|
4
|
+
* @implements FR15
|
|
5
|
+
*/
|
|
6
|
+
import 'reflect-metadata';
|
|
7
|
+
const LAZY_KEY = Symbol.for('ream:lazy');
|
|
8
|
+
/**
|
|
9
|
+
* @Lazy() — marks a constructor parameter for deferred resolution.
|
|
10
|
+
* The dependency is resolved on first property access, not at construction.
|
|
11
|
+
*/
|
|
12
|
+
export function Lazy() {
|
|
13
|
+
return (target, propertyKey, parameterIndex) => {
|
|
14
|
+
const existing = Reflect.getOwnMetadata(LAZY_KEY, target, propertyKey ?? '') ?? [];
|
|
15
|
+
existing.push(parameterIndex);
|
|
16
|
+
Reflect.defineMetadata(LAZY_KEY, existing, target, propertyKey ?? '');
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Get lazy parameter indices for a constructor. */
|
|
20
|
+
export function getLazyParams(target) {
|
|
21
|
+
return Reflect.getOwnMetadata(LAZY_KEY, target, '') ?? [];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create a lazy proxy that defers resolution until first access.
|
|
25
|
+
* Traps get, set, has, ownKeys, getOwnPropertyDescriptor for full compatibility.
|
|
26
|
+
*/
|
|
27
|
+
export function createLazyProxy(resolver) {
|
|
28
|
+
let instance;
|
|
29
|
+
const ensure = () => {
|
|
30
|
+
if (!instance)
|
|
31
|
+
instance = resolver();
|
|
32
|
+
return instance;
|
|
33
|
+
};
|
|
34
|
+
// biome-ignore lint/suspicious/noExplicitAny: Proxy target must be an object literal; T is branded at call site
|
|
35
|
+
return new Proxy({}, {
|
|
36
|
+
get(_target, prop, receiver) {
|
|
37
|
+
return Reflect.get(ensure(), prop, receiver);
|
|
38
|
+
},
|
|
39
|
+
set(_target, prop, value, receiver) {
|
|
40
|
+
return Reflect.set(ensure(), prop, value, receiver);
|
|
41
|
+
},
|
|
42
|
+
has(_target, prop) {
|
|
43
|
+
return Reflect.has(ensure(), prop);
|
|
44
|
+
},
|
|
45
|
+
ownKeys() {
|
|
46
|
+
return Reflect.ownKeys(ensure());
|
|
47
|
+
},
|
|
48
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
49
|
+
return Object.getO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,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;QAC9C,CAAC;QACD,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ;YAChC,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;QACrD,CAAC;QACD,GAAG,CAAC,OAAO,EAAE,IAAI;YACf,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,CAAA;QACpC,CAAC;QACD,OAAO;YACL,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;QAClC,CAAC;QACD,wBAAwB,CAAC,OAAO,EAAE,IAAI;YACpC,OAAO,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,CAAA;QACxD,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Service() and @Inject() decorators for IoC container integration.
|
|
3
|
+
*
|
|
4
|
+
* @implements FR11, FR12, FR14
|
|
5
|
+
*/
|
|
6
|
+
import 'reflect-metadata';
|
|
7
|
+
import type { ServiceMetadata, ServiceScope } from '../container/types.js';
|
|
8
|
+
declare const SERVICE_METADATA_KEY: unique symbol;
|
|
9
|
+
declare const INJECT_METADATA_KEY: unique symbol;
|
|
10
|
+
/** Constructor type — accepts unknown args, returns unknown instance. */
|
|
11
|
+
type AnyConstructor = new (...args: unknown[]) => unknown;
|
|
12
|
+
export declare function getServiceRegistry(): ReadonlyMap<AnyConstructor, ServiceMetadata>;
|
|
13
|
+
/** Clear the service registry (for test isolation and hot-reload). */
|
|
14
|
+
export declare function clearServiceRegistry(): void;
|
|
15
|
+
export declare function getServiceMetadata(target: AnyConstructor): ServiceMetadata | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* @Service() decorator.
|
|
18
|
+
* Registers the class in the IoC container for auto-resolution.
|
|
19
|
+
*/
|
|
20
|
+
export declare function Service(options?: {
|
|
21
|
+
scope?: ServiceScope;
|
|
22
|
+
as?: string;
|
|
23
|
+
}): ClassDecorator;
|
|
24
|
+
/**
|
|
25
|
+
* @Inject() decorator — marks a constructor parameter for named injection.
|
|
26
|
+
*
|
|
27
|
+
* @implements FR16
|
|
28
|
+
*/
|
|
29
|
+
export declare function Inject(token: string): ParameterDecorator;
|
|
30
|
+
/**
|
|
31
|
+
* Get named injection tokens for a class constructor.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getInjectTokens(target: AnyConstructor): Map<number, string>;
|
|
34
|
+
/**
|
|
35
|
+
* @inject() class decorator — marks a controller (or service) for transient IoC resolution.
|
|
36
|
+
*
|
|
37
|
+
* Equivalent to @Service({ scope: 'transient' }). Use on controllers so the container
|
|
38
|
+
* auto-resolves constructor dependencies per-request.
|
|
39
|
+
*
|
|
40
|
+
* Usage:
|
|
41
|
+
* @inject()
|
|
42
|
+
* export default class UsersController {
|
|
43
|
+
* constructor(private userService: UserService) {}
|
|
44
|
+
* }
|
|
45
|
+
*/
|
|
46
|
+
export declare function inject(): ClassDecorator;
|
|
47
|
+
export { INJECT_METADATA_KEY, SERVICE_METADATA_KEY };
|
|
48
|
+
//# sourceMappingURL=Service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Service.d.ts","sourceRoot":"","sources":["../../src/decorators/Service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAE1E,QAAA,MAAM,oBAAoB,eAAyB,CAAA;AACnD,QAAA,MAAM,mBAAmB,eAAwB,CAAA;AAEjD,yEAAyE;AACzE,KAAK,cAAc,GAAG,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAA;AAKzD,wBAAgB,kBAAkB,IAAI,WAAW,CAAC,cAAc,EAAE,eAAe,CAAC,CAEjF;AAED,sEAAsE;AACtE,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,eAAe,GAAG,SAAS,CAEtF;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,YAAY,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,cAAc,CAU3F;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAOxD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAE3E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,IAAI,cAAc,CAEvC;AAED,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,CAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Service() and @Inject() decorators for IoC container integration.
|
|
3
|
+
*
|
|
4
|
+
* @implements FR11, FR12, FR14
|
|
5
|
+
*/
|
|
6
|
+
import 'reflect-metadata';
|
|
7
|
+
const SERVICE_METADATA_KEY = Symbol('ream:service');
|
|
8
|
+
const INJECT_METADATA_KEY = Symbol('ream:inject');
|
|
9
|
+
/** Registry of all decorated services. */
|
|
10
|
+
const serviceRegistry = new Map();
|
|
11
|
+
export function getServiceRegistry() {
|
|
12
|
+
return serviceRegistry;
|
|
13
|
+
}
|
|
14
|
+
/** Clear the service registry (for test isolation and hot-reload). */
|
|
15
|
+
export function clearServiceRegistry() {
|
|
16
|
+
serviceRegistry.clear();
|
|
17
|
+
}
|
|
18
|
+
export function getServiceMetadata(target) {
|
|
19
|
+
return serviceRegistry.get(target);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @Service() decorator.
|
|
23
|
+
* Registers the class in the IoC container for auto-resolution.
|
|
24
|
+
*/
|
|
25
|
+
export function Service(options = {}) {
|
|
26
|
+
return (target) => {
|
|
27
|
+
const metadata = {
|
|
28
|
+
scope: options.scope ?? 'singleton',
|
|
29
|
+
as: options.as,
|
|
30
|
+
};
|
|
31
|
+
// biome-ignore lint/suspicious/noExplicitAny: ClassDecorator target is Function; registry requires AnyConstructor which is a subtype
|
|
32
|
+
serviceRegistry.set(target, metadata);
|
|
33
|
+
Reflect.defineMetadata(SERVICE_METADATA_KEY, metadata, target);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @Inject() decorator — marks a constructor parameter for named injection.
|
|
38
|
+
*
|
|
39
|
+
* @implements FR16
|
|
40
|
+
*/
|
|
41
|
+
export function Inject(token) {
|
|
42
|
+
return (target, _propertyKey, parameterIndex) => {
|
|
43
|
+
const existingTokens = Reflect.getOwnMetadata(INJECT_METADATA_KEY, target) ?? new Map();
|
|
44
|
+
existingTokens.set(parameterIndex, token);
|
|
45
|
+
Reflect.defineMetadata(INJECT_METADATA_KEY, existingTokens, target);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get named injection tokens for a class constructor.
|
|
50
|
+
*/
|
|
51
|
+
export function getInjectTokens(target) {
|
|
52
|
+
return Reflect.getOwnMetadata(INJECT_METADATA_KEY, target) ?? new Map();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @inject() class decorator — marks a controller (or service) for transient IoC resolution.
|
|
56
|
+
*
|
|
57
|
+
* Equivalent to @Service({ scope: 'transient' }). Use on controllers so the container
|
|
58
|
+
* auto-resolves constructor dependencies per-request.
|
|
59
|
+
*
|
|
60
|
+
* Usage:
|
|
61
|
+
* @inject()
|
|
62
|
+
* export default class UsersController {
|
|
63
|
+
* constructor(private userService: UserService) {}
|
|
64
|
+
* }
|
|
65
|
+
*/
|
|
66
|
+
export function inject() {
|
|
67
|
+
return Service({ scope: 'transient' });
|
|
68
|
+
}
|
|
69
|
+
export { INJECT_METADATA_KEY, SERVICE_METADATA_KEY };
|
|
70
|
+
//# sourceMappingURL=Service.js.map
|