Closed gxkl closed 2 weeks ago
The pull request introduces enhancements to the Inject
decorator and related classes, allowing for optional dependency injection. Key modifications include the addition of the InjectOptional
function, updates to existing decorators to support optional parameters, and refinements in the handling of injected objects. The changes extend to various test cases and interfaces, ensuring comprehensive coverage of the new functionality. Overall, the updates improve the clarity and flexibility of dependency management within the framework.
File Path | Change Summary |
---|---|
core/core-decorator/src/decorator/Inject.ts |
Modified the Inject decorator to handle parameters more consistently, added InjectOptional function for optional injections, and streamlined logic. |
core/core-decorator/test/decorators.test.ts |
Updated tests to include new optional injection objects and modified existing test cases to reflect optional dependencies. |
core/core-decorator/test/fixtures/decators/CacheService.ts |
Added optional service injections in CacheService , updated import paths, and modified existing injection configurations. |
core/core-decorator/test/fixtures/decators/ConstructorObject.ts |
Enhanced ConstructorObject to support optional constructor parameters using Inject and InjectOptional . |
core/metadata/src/impl/EggPrototypeBuilder.ts |
Updated findInjectObjectPrototype method to accept InjectConstructor , refactored build method for better error handling with optional injects. |
core/metadata/test/LoadUnit.test.ts |
Introduced a new test suite for optional injection, validating the creation of load units with optional dependencies. |
core/metadata/test/fixtures/modules/optional-inject-module/OptionalInjectService.ts |
Created new OptionalInjectService class with optional dependency properties. |
core/metadata/test/fixtures/modules/optional-inject-module/package.json |
Added package.json for the optional-inject-service module. |
core/types/core-decorator/Inject.ts |
Modified InjectParams interface to include an optional optional property. |
core/types/core-decorator/model/InjectObjectInfo.ts |
Added an optional optional property to InjectObjectInfo interface. |
core/types/metadata/model/EggPrototype.ts |
Introduced an optional optional property to several interfaces: InjectObjectProto , InjectConstructorProto , InjectObject , and InjectConstructor . |
core/types/core-decorator/model/InjectConstructorInfo.ts |
Added an optional optional property to InjectConstructorInfo interface. |
plugin/tegg/test/Inject.test.ts |
Introduced a new test suite for optional injection scenarios within the tegg plugin, validating functionality and error handling. |
plugin/tegg/test/fixtures/apps/invalid-inject/app/modules/module-a/BarService.ts |
Created BarService class with an injected property marked for dependency injection. |
plugin/tegg/test/fixtures/apps/optional-inject/app/modules/module-a/BarService.ts |
Defined BarService class with optional injected properties and a method to check their presence. |
plugin/tegg/test/fixtures/apps/optional-inject/app/modules/module-a/FooService.ts |
Defined FooService class with optional injected properties and a method to check their presence. |
standalone/standalone/test/fixtures/optional-inject/bar.ts |
Introduced Bar class with optional parameters for dependency injection. |
standalone/standalone/test/fixtures/optional-inject/foo.ts |
Introduced Foo class implementing MainRunner with optional injected properties. |
standalone/standalone/test/index.test.ts |
Added a new test suite for optional injection scenarios, verifying expected behaviors and error handling. |
Inject
decorator.Inject
decorator.Inject
decorator.🐰 "In the garden where we play,
Optional injections come our way.
WithInject
andInjectOptional
too,
Flexibility blooms, oh what a view!
Hops of joy, we celebrate,
For dependencies now cooperate!" 🐇
Checklist
npm test
passesAffected core subsystem(s)
Description of change
Summary by CodeRabbit
Release Notes
New Features
InjectOptional
decorator for marking parameters as optional.Improvements
EggPrototypeBuilder
for optional inject objects.Inject
decorator.Tests
Documentation