Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dependency-injection-cat

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dependency-injection-cat - npm Package Compare versions

Comparing version 0.1.11 to 0.1.12

36

core/connect-dependencies/buildDependencyGraphAndFillQualifiedBeans.js

@@ -51,2 +51,18 @@ "use strict";

if (beanCandidatesFromCurrentContext.length > 1) {
var beanCandidatesFromCurrentContextQualifiedByParameterName = beanCandidatesFromCurrentContext
.filter(function (it) { return it.classMemberName === dependencyDescriptor.parameterName; });
if (beanCandidatesFromCurrentContextQualifiedByParameterName.length === 1) {
dependencyDescriptor.qualifiedBean = beanCandidatesFromCurrentContextQualifiedByParameterName[0];
DependencyGraph_1.DependencyGraph.addNodeWithEdges(beanDescriptor, beanCandidatesFromCurrentContextQualifiedByParameterName[0]);
return;
}
if (beanCandidatesFromCurrentContextQualifiedByParameterName.length > 1) {
CompilationContext_1.CompilationContext.reportErrorWithMultipleNodes({
nodes: __spreadArray([
dependencyDescriptor.node
], beanCandidatesFromCurrentContextQualifiedByParameterName.map(function (it) { return it.node; })),
message: "Found " + beanCandidatesFromCurrentContextQualifiedByParameterName.length + " Bean candidates, with same name, please rename one of beans",
});
return;
}
CompilationContext_1.CompilationContext.reportErrorWithMultipleNodes({

@@ -56,3 +72,3 @@ nodes: __spreadArray([

], beanCandidatesFromCurrentContext.map(function (it) { return it.node; })),
message: "Found " + beanCandidatesFromCurrentContext.length + " Bean candidates, please use @Qualifier to specify which Bean should be injected",
message: "Found " + beanCandidatesFromCurrentContext.length + " Bean candidates, please use @Qualifier or rename parameter to match bean name, to specify which Bean should be injected",
});

@@ -67,2 +83,18 @@ return;

if (beanCandidatesFromGlobalContext.length > 1) {
var beanCandidatesFromGlobalContextQualifiedByParameterName = beanCandidatesFromGlobalContext
.filter(function (it) { return it.classMemberName === dependencyDescriptor.parameterName; });
if (beanCandidatesFromGlobalContextQualifiedByParameterName.length === 1) {
dependencyDescriptor.qualifiedBean = beanCandidatesFromGlobalContextQualifiedByParameterName[0];
DependencyGraph_1.DependencyGraph.addNodeWithEdges(beanDescriptor, beanCandidatesFromGlobalContextQualifiedByParameterName[0]);
return;
}
if (beanCandidatesFromGlobalContextQualifiedByParameterName.length > 1) {
CompilationContext_1.CompilationContext.reportErrorWithMultipleNodes({
nodes: __spreadArray([
dependencyDescriptor.node
], beanCandidatesFromGlobalContextQualifiedByParameterName.map(function (it) { return it.node; })),
message: "Found " + beanCandidatesFromGlobalContextQualifiedByParameterName.length + " Bean candidates in Global context, with same name, please rename one of beans",
});
return;
}
CompilationContext_1.CompilationContext.reportErrorWithMultipleNodes({

@@ -72,3 +104,3 @@ nodes: __spreadArray([

], beanCandidatesFromGlobalContext.map(function (it) { return it.node; })),
message: "Found " + beanCandidatesFromGlobalContext.length + " Bean candidates in Global context, please use @Qualifier to specify which Bean should be injected",
message: "Found " + beanCandidatesFromGlobalContext.length + " Bean candidates in Global context, please use @Qualifier or rename parameter to match bean name, to specify which Bean should be injected",
});

@@ -75,0 +107,0 @@ return;

5

exceptions/runtime/NoContextByKey.js

@@ -19,3 +19,2 @@ "use strict";

exports.NoContextByKey = void 0;
var lodash_1 = require("lodash");
var NoContextByKey = /** @class */ (function (_super) {

@@ -28,5 +27,3 @@ __extends(NoContextByKey, _super);

_this.name = 'NotFoundException';
_this.message = lodash_1.isString(contextKey)
? "Context " + _this.contextName + " and key " + _this.contextKey + " was not initialized"
: "Context " + _this.contextName + " was not initialized";
_this.message = "Context with name " + _this.contextName + " and key " + _this.contextKey + " was not initialized";
return _this;

@@ -33,0 +30,0 @@ }

{
"name": "dependency-injection-cat",
"version": "0.1.11",
"version": "0.1.12",
"main": "index.js",

@@ -5,0 +5,0 @@ "types": "index.d.ts",

@@ -26,3 +26,3 @@ # Dependency Injection Cat

makeBusinessLogic() {...}
makeBusinessLogic() {}
}

@@ -36,3 +36,3 @@

return (
<button onClick={useCase.makeBusinessLogic}> Click me! </button>
<button onClick={useCase.makeBusinessLogic}> Click me! </button>
)

@@ -234,6 +234,6 @@ }

{
diConfigPattern ?: string; // Glob pattern, default value. Default: '**/*.di.ts'
ignorePatterns ?: string[]; // Array of Glob patterns, default value. Default: ['**/node_modules/**']
compiledContextOutputDir ?: string; // Output directory of transformed contextMap, can be specified for debug purposes. Default: node_modules/dependency-injection-cat/external/built-context
disableLogoPrint ?: boolean; // Disable exposing dependency-injections-cat logo into console
diConfigPattern: string | undefined; // Glob pattern, default value. Default: '**/*.di.ts'
ignorePatterns: Array<string> | undefined; // Array of Glob patterns, default value. Default: ['**/node_modules/**']
compiledContextOutputDir: string | undefined; // Output directory of transformed contextMap, can be specified for debug purposes. Default: node_modules/dependency-injection-cat/external/built-context
disableLogoPrint: boolean | undefined; // Disable exposing dependency-injections-cat logo into console
}

@@ -557,7 +557,9 @@ ```

Qualifier needed, when you have 2 or more **Beans** in the **Context** with same type. Also you can use qualifier, when injecting **Beans** from **GlobalCatContext**
Qualifier needed, when you have 2 or more **Beans** in the **Context** with same type.
By default, the qualifier is the name of the parameter in the class constructor, or in the **Method Bean**`
Also, you can use qualifier, when injecting **Beans** from **GlobalCatContext**
#### Rules
- Qualifiers can be used only in **Method Bean**
- @Qualifier decorator can be used only in **Method Bean**
- Argument passed to Qualifier should be a string literal and should not be an empty string

@@ -569,2 +571,17 @@ - Qualifier should be a name of Bean (class property name, or method name) defined in current **Context**

```typescript
//Implicit declaration of the qualifier
export class ApplicationContext extends CatContext<IBeans> {
httpRequester: IRequester = Bean(HttpRequester);
graphQLRequester: IRequester = Bean(GraphQLRequester);
@Bean
useCase(
graphQLRequester: IRequester, //Will be injected implementation "GraphQLRequester"
): IUseCase {
return new UseCase(graphQLRequester);
}
}
```
```typescript
//When Bean placed in current context

@@ -571,0 +588,0 @@ export class ApplicationContext extends CatContext<IBeans> {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc