fragment-ts 1.0.25 → 1.0.27
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/dist/cli/commands/init.command.js +1 -1
- package/dist/core/container/di-container.d.ts +6 -0
- package/dist/core/container/di-container.d.ts.map +1 -1
- package/dist/core/container/di-container.js +124 -87
- package/dist/core/container/di-container.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/init.command.ts +1 -1
- package/src/core/container/di-container.ts +212 -129
|
@@ -10,6 +10,12 @@ export declare class DIContainer {
|
|
|
10
10
|
resolve<T>(token: any): T;
|
|
11
11
|
private createInstance;
|
|
12
12
|
private injectProperties;
|
|
13
|
+
private checkForDecoratedProperties;
|
|
14
|
+
private tryInjectAutowired;
|
|
15
|
+
private tryInjectByToken;
|
|
16
|
+
private tryInjectValue;
|
|
17
|
+
private tryInjectRepository;
|
|
18
|
+
private tryInjectLazy;
|
|
13
19
|
private resolveValue;
|
|
14
20
|
private resolveRepository;
|
|
15
21
|
has(token: any): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di-container.d.ts","sourceRoot":"","sources":["../../../src/core/container/di-container.ts"],"names":[],"mappings":"AAGA,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IACrC,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,SAAS,CAAkC;IACnD,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,UAAU,CAAuB;IAEzC,MAAM,CAAC,WAAW,IAAI,WAAW;IAOjC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"di-container.d.ts","sourceRoot":"","sources":["../../../src/core/container/di-container.ts"],"names":[],"mappings":"AAGA,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IACrC,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,SAAS,CAAkC;IACnD,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,UAAU,CAAuB;IAEzC,MAAM,CAAC,WAAW,IAAI,WAAW;IAOjC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG,IAAI;IAU/D,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC;IAsDzB,OAAO,CAAC,cAAc;IAuCtB,OAAO,CAAC,gBAAgB;IAgDxB,OAAO,CAAC,2BAA2B;IAkDnC,OAAO,CAAC,kBAAkB;IA8B1B,OAAO,CAAC,gBAAgB;IA+BxB,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,mBAAmB;IA8B3B,OAAO,CAAC,aAAa;IAkCrB,OAAO,CAAC,YAAY;IAsCpB,OAAO,CAAC,iBAAiB;IAiBzB,GAAG,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO;IAIxB,eAAe,IAAI,GAAG,EAAE;IAIxB,KAAK,IAAI,IAAI;IAQb,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -8,7 +8,7 @@ class DIContainer {
|
|
|
8
8
|
this.transients = new Map();
|
|
9
9
|
this.factories = new Map();
|
|
10
10
|
this.constructing = new Set();
|
|
11
|
-
this.registered = new Set();
|
|
11
|
+
this.registered = new Set();
|
|
12
12
|
}
|
|
13
13
|
static getInstance() {
|
|
14
14
|
if (!DIContainer.instance) {
|
|
@@ -17,7 +17,6 @@ class DIContainer {
|
|
|
17
17
|
return DIContainer.instance;
|
|
18
18
|
}
|
|
19
19
|
register(token, instance, factory) {
|
|
20
|
-
// Mark this token as registered
|
|
21
20
|
this.registered.add(token);
|
|
22
21
|
if (instance) {
|
|
23
22
|
this.singletons.set(token, instance);
|
|
@@ -25,10 +24,8 @@ class DIContainer {
|
|
|
25
24
|
else if (factory) {
|
|
26
25
|
this.factories.set(token, factory);
|
|
27
26
|
}
|
|
28
|
-
// If neither instance nor factory, it will be created on-demand
|
|
29
27
|
}
|
|
30
28
|
resolve(token) {
|
|
31
|
-
// Check if this is actually an injectable class
|
|
32
29
|
if (typeof token === "function" && !this.registered.has(token)) {
|
|
33
30
|
throw new Error(`Cannot resolve ${token.name}: Not registered as injectable. ` +
|
|
34
31
|
`Did you forget to add @Injectable(), @Service(), @Controller(), or @Repository()?`);
|
|
@@ -71,16 +68,16 @@ class DIContainer {
|
|
|
71
68
|
const paramTypes = Reflect.getMetadata("design:paramtypes", target) || [];
|
|
72
69
|
const params = paramTypes.map((type, index) => {
|
|
73
70
|
if (!type || type === Object) {
|
|
74
|
-
console.warn(` ⚠️ Constructor param ${index} of ${target.name} has no type
|
|
71
|
+
console.warn(` ⚠️ Constructor param ${index} of ${target.name} has no type`);
|
|
75
72
|
return undefined;
|
|
76
73
|
}
|
|
77
74
|
console.log(` 📦 Resolving constructor dependency: ${type.name}`);
|
|
78
75
|
return this.resolve(type);
|
|
79
76
|
});
|
|
80
77
|
const instance = new target(...params);
|
|
81
|
-
// Inject properties
|
|
78
|
+
// CRITICAL: Inject properties
|
|
82
79
|
this.injectProperties(instance);
|
|
83
|
-
// Call
|
|
80
|
+
// Call @PostConstruct
|
|
84
81
|
const postConstructMethod = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.POST_CONSTRUCT, target);
|
|
85
82
|
if (postConstructMethod &&
|
|
86
83
|
typeof instance[postConstructMethod] === "function") {
|
|
@@ -90,90 +87,133 @@ class DIContainer {
|
|
|
90
87
|
return instance;
|
|
91
88
|
}
|
|
92
89
|
injectProperties(instance) {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
// Walk the prototype chain
|
|
90
|
+
const constructor = instance.constructor;
|
|
91
|
+
console.log(` 🔍 Checking properties for injection on ${constructor.name}`);
|
|
92
|
+
// Walk through the entire prototype chain
|
|
93
|
+
let currentProto = constructor.prototype;
|
|
96
94
|
while (currentProto && currentProto !== Object.prototype) {
|
|
97
|
-
// Get
|
|
98
|
-
const
|
|
99
|
-
for (const
|
|
100
|
-
|
|
101
|
-
if (prop === "constructor")
|
|
95
|
+
// Get ALL property descriptors (including getters/setters)
|
|
96
|
+
const descriptors = Object.getOwnPropertyDescriptors(currentProto);
|
|
97
|
+
for (const [propName, descriptor] of Object.entries(descriptors)) {
|
|
98
|
+
if (propName === "constructor")
|
|
102
99
|
continue;
|
|
103
|
-
//
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
|
|
100
|
+
// Try each injection type
|
|
101
|
+
this.tryInjectAutowired(instance, currentProto, propName, constructor.name);
|
|
102
|
+
this.tryInjectByToken(instance, currentProto, propName, constructor.name);
|
|
103
|
+
this.tryInjectValue(instance, currentProto, propName, constructor.name);
|
|
104
|
+
this.tryInjectRepository(instance, currentProto, propName, constructor.name);
|
|
105
|
+
this.tryInjectLazy(instance, currentProto, propName, constructor.name);
|
|
106
|
+
}
|
|
107
|
+
currentProto = Object.getPrototypeOf(currentProto);
|
|
108
|
+
}
|
|
109
|
+
// Also check for properties that might be defined directly on the instance
|
|
110
|
+
// but decorated with @Autowired on the class definition
|
|
111
|
+
this.checkForDecoratedProperties(instance, constructor);
|
|
112
|
+
}
|
|
113
|
+
checkForDecoratedProperties(instance, constructor) {
|
|
114
|
+
// Check all metadata keys that might be attached to properties
|
|
115
|
+
const propertyKeys = [
|
|
116
|
+
...(Reflect.getMetadataKeys(constructor.prototype) || []),
|
|
117
|
+
...(Reflect.getMetadataKeys(instance) || []),
|
|
118
|
+
];
|
|
119
|
+
// Filter for property-related metadata
|
|
120
|
+
for (const key of propertyKeys) {
|
|
121
|
+
if (key.includes("fragment:")) {
|
|
122
|
+
// This is a Fragment metadata key, need to check if it's attached to a property
|
|
123
|
+
const metadataValue = Reflect.getMetadata(key, constructor.prototype);
|
|
124
|
+
if (metadataValue && typeof metadataValue === "object") {
|
|
125
|
+
// Could be a property metadata
|
|
126
|
+
for (const prop of Object.keys(metadataValue)) {
|
|
127
|
+
if (prop !== "constructor") {
|
|
128
|
+
this.tryInjectAutowired(instance, constructor.prototype, prop, constructor.name);
|
|
129
|
+
this.tryInjectByToken(instance, constructor.prototype, prop, constructor.name);
|
|
130
|
+
this.tryInjectValue(instance, constructor.prototype, prop, constructor.name);
|
|
131
|
+
this.tryInjectRepository(instance, constructor.prototype, prop, constructor.name);
|
|
132
132
|
}
|
|
133
|
-
console.warn(` ⚠️ Optional inject dependency ${tokenName} not available`);
|
|
134
|
-
instance[prop] = undefined;
|
|
135
133
|
}
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
// Check @Value
|
|
139
|
-
const valueExpression = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.VALUE, currentProto, prop);
|
|
140
|
-
if (valueExpression !== undefined) {
|
|
141
|
-
console.log(` 🔧 @Value: ${target.name}.${prop} = ${valueExpression}`);
|
|
142
|
-
instance[prop] = this.resolveValue(valueExpression);
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
// Check @InjectRepository
|
|
146
|
-
const repositoryEntity = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.INJECT_REPOSITORY, currentProto, prop);
|
|
147
|
-
if (repositoryEntity) {
|
|
148
|
-
console.log(` 💾 @InjectRepository: ${target.name}.${prop} = Repository<${repositoryEntity.name}>`);
|
|
149
|
-
instance[prop] = this.resolveRepository(repositoryEntity);
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
// Check @Lazy
|
|
153
|
-
const isLazy = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.LAZY, currentProto, prop);
|
|
154
|
-
if (isLazy) {
|
|
155
|
-
const type = Reflect.getMetadata("design:type", currentProto, prop);
|
|
156
|
-
console.log(` ⏳ @Lazy: ${target.name}.${prop} (will resolve on access)`);
|
|
157
|
-
let cached = null;
|
|
158
|
-
let resolved = false;
|
|
159
|
-
Object.defineProperty(instance, prop, {
|
|
160
|
-
get: () => {
|
|
161
|
-
if (!resolved) {
|
|
162
|
-
console.log(` 🔓 Lazy-loading ${type.name} for ${target.name}.${prop}`);
|
|
163
|
-
cached = this.resolve(type);
|
|
164
|
-
resolved = true;
|
|
165
|
-
}
|
|
166
|
-
return cached;
|
|
167
|
-
},
|
|
168
|
-
enumerable: true,
|
|
169
|
-
configurable: true,
|
|
170
|
-
});
|
|
171
|
-
continue;
|
|
172
134
|
}
|
|
173
135
|
}
|
|
174
|
-
currentProto = Object.getPrototypeOf(currentProto);
|
|
175
136
|
}
|
|
176
137
|
}
|
|
138
|
+
tryInjectAutowired(instance, proto, prop, className) {
|
|
139
|
+
const type = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.AUTOWIRED, proto, prop);
|
|
140
|
+
if (!type)
|
|
141
|
+
return;
|
|
142
|
+
console.log(` 💉 @Autowired found: ${className}.${prop} -> ${type.name}`);
|
|
143
|
+
const isOptional = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.OPTIONAL, proto, prop);
|
|
144
|
+
try {
|
|
145
|
+
instance[prop] = this.resolve(type);
|
|
146
|
+
console.log(` ✅ Injected ${type.name} into ${className}.${prop}`);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
if (!isOptional) {
|
|
150
|
+
throw new Error(`Failed to autowire ${type.name} into ${className}.${prop}: ${error}`);
|
|
151
|
+
}
|
|
152
|
+
console.warn(` ⚠️ Optional dependency ${type.name} not available for ${className}.${prop}`);
|
|
153
|
+
instance[prop] = undefined;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
tryInjectByToken(instance, proto, prop, className) {
|
|
157
|
+
const token = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.INJECT, proto, prop);
|
|
158
|
+
if (!token)
|
|
159
|
+
return;
|
|
160
|
+
const tokenName = typeof token === "string" ? token : token.name;
|
|
161
|
+
console.log(` 💉 @Inject found: ${className}.${prop} -> ${tokenName}`);
|
|
162
|
+
const isOptional = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.OPTIONAL, proto, prop);
|
|
163
|
+
try {
|
|
164
|
+
instance[prop] = this.resolve(token);
|
|
165
|
+
console.log(` ✅ Injected ${tokenName} into ${className}.${prop}`);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (!isOptional) {
|
|
169
|
+
throw new Error(`Failed to inject ${tokenName} into ${className}.${prop}: ${error}`);
|
|
170
|
+
}
|
|
171
|
+
console.warn(` ⚠️ Optional dependency ${tokenName} not available for ${className}.${prop}`);
|
|
172
|
+
instance[prop] = undefined;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
tryInjectValue(instance, proto, prop, className) {
|
|
176
|
+
const expression = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.VALUE, proto, prop);
|
|
177
|
+
if (expression === undefined)
|
|
178
|
+
return;
|
|
179
|
+
console.log(` 🔧 @Value found: ${className}.${prop} = ${expression}`);
|
|
180
|
+
instance[prop] = this.resolveValue(expression);
|
|
181
|
+
console.log(` ✅ Set value for ${className}.${prop}`);
|
|
182
|
+
}
|
|
183
|
+
tryInjectRepository(instance, proto, prop, className) {
|
|
184
|
+
const entity = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.INJECT_REPOSITORY, proto, prop);
|
|
185
|
+
if (!entity)
|
|
186
|
+
return;
|
|
187
|
+
console.log(` 💾 @InjectRepository found: ${className}.${prop} -> Repository<${entity.name}>`);
|
|
188
|
+
try {
|
|
189
|
+
instance[prop] = this.resolveRepository(entity);
|
|
190
|
+
console.log(` ✅ Injected Repository<${entity.name}> into ${className}.${prop}`);
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
throw new Error(`Failed to inject repository for ${entity.name} into ${className}.${prop}: ${error}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
tryInjectLazy(instance, proto, prop, className) {
|
|
197
|
+
const isLazy = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.LAZY, proto, prop);
|
|
198
|
+
if (!isLazy)
|
|
199
|
+
return;
|
|
200
|
+
const type = Reflect.getMetadata("design:type", proto, prop);
|
|
201
|
+
console.log(` ⏳ @Lazy found: ${className}.${prop} (${type?.name || "unknown"})`);
|
|
202
|
+
let cached = null;
|
|
203
|
+
let resolved = false;
|
|
204
|
+
Object.defineProperty(instance, prop, {
|
|
205
|
+
get: () => {
|
|
206
|
+
if (!resolved) {
|
|
207
|
+
console.log(` 🔓 Lazy-loading ${type.name} for ${className}.${prop}`);
|
|
208
|
+
cached = this.resolve(type);
|
|
209
|
+
resolved = true;
|
|
210
|
+
}
|
|
211
|
+
return cached;
|
|
212
|
+
},
|
|
213
|
+
enumerable: true,
|
|
214
|
+
configurable: true,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
177
217
|
resolveValue(expression) {
|
|
178
218
|
const match = expression.match(/\$\{([^:}]+)(?::([^}]*))?\}|\$([A-Z_][A-Z0-9_]*)/i);
|
|
179
219
|
if (match) {
|
|
@@ -184,10 +224,9 @@ class DIContainer {
|
|
|
184
224
|
if (defaultValue !== undefined) {
|
|
185
225
|
return defaultValue;
|
|
186
226
|
}
|
|
187
|
-
console.warn(
|
|
227
|
+
console.warn(` ⚠️ Environment variable "${key}" not defined`);
|
|
188
228
|
return "";
|
|
189
229
|
}
|
|
190
|
-
// Parse JSON
|
|
191
230
|
if (value.startsWith("{") || value.startsWith("[")) {
|
|
192
231
|
try {
|
|
193
232
|
return JSON.parse(value);
|
|
@@ -196,11 +235,9 @@ class DIContainer {
|
|
|
196
235
|
return value;
|
|
197
236
|
}
|
|
198
237
|
}
|
|
199
|
-
// Parse numbers
|
|
200
238
|
if (/^\d+(\.\d+)?$/.test(value)) {
|
|
201
239
|
return parseFloat(value);
|
|
202
240
|
}
|
|
203
|
-
// Parse booleans
|
|
204
241
|
if (value.toLowerCase() === "true")
|
|
205
242
|
return true;
|
|
206
243
|
if (value.toLowerCase() === "false")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di-container.js","sourceRoot":"","sources":["../../../src/core/container/di-container.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAG1D,MAAa,WAAW;IAAxB;QAEU,eAAU,GAAkB,IAAI,GAAG,EAAE,CAAC;QACtC,eAAU,GAAkB,IAAI,GAAG,EAAE,CAAC;QACtC,cAAS,GAAwB,IAAI,GAAG,EAAE,CAAC;QAC3C,iBAAY,GAAa,IAAI,GAAG,EAAE,CAAC;QACnC,eAAU,GAAa,IAAI,GAAG,EAAE,CAAC,CAAC,mCAAmC;IAqV/E,CAAC;IAnVC,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;YAC1B,WAAW,CAAC,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;QAC3C,CAAC;QACD,OAAO,WAAW,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,QAAQ,CAAC,KAAU,EAAE,QAAc,EAAE,OAAmB;QACtD,gCAAgC;QAChC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAE3B,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACvC,CAAC;aAAM,IAAI,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,SAAS,CAAC,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AI,KAAK,CACb,oCAAoC,MAAM,CAAC,IAAI,KAAM,KAAe,EAAE,OAAO,EAAE,CAChF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,GAAG,CAAC,KAAU;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,eAAe;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF;AA9aD,kCA8aC"}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ export class DIContainer {
|
|
|
7
7
|
private transients: Map<any, any> = new Map();
|
|
8
8
|
private factories: Map<any, () => any> = new Map();
|
|
9
9
|
private constructing: Set<any> = new Set();
|
|
10
|
-
private registered: Set<any> = new Set();
|
|
10
|
+
private registered: Set<any> = new Set();
|
|
11
11
|
|
|
12
12
|
static getInstance(): DIContainer {
|
|
13
13
|
if (!DIContainer.instance) {
|
|
@@ -17,7 +17,6 @@ export class DIContainer {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
register(token: any, instance?: any, factory?: () => any): void {
|
|
20
|
-
// Mark this token as registered
|
|
21
20
|
this.registered.add(token);
|
|
22
21
|
|
|
23
22
|
if (instance) {
|
|
@@ -25,11 +24,9 @@ export class DIContainer {
|
|
|
25
24
|
} else if (factory) {
|
|
26
25
|
this.factories.set(token, factory);
|
|
27
26
|
}
|
|
28
|
-
// If neither instance nor factory, it will be created on-demand
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
resolve<T>(token: any): T {
|
|
32
|
-
// Check if this is actually an injectable class
|
|
33
30
|
if (typeof token === "function" && !this.registered.has(token)) {
|
|
34
31
|
throw new Error(
|
|
35
32
|
`Cannot resolve ${token.name}: Not registered as injectable. ` +
|
|
@@ -91,7 +88,7 @@ export class DIContainer {
|
|
|
91
88
|
const params = paramTypes.map((type: any, index: number) => {
|
|
92
89
|
if (!type || type === Object) {
|
|
93
90
|
console.warn(
|
|
94
|
-
` ⚠️ Constructor param ${index} of ${target.name} has no type
|
|
91
|
+
` ⚠️ Constructor param ${index} of ${target.name} has no type`,
|
|
95
92
|
);
|
|
96
93
|
return undefined;
|
|
97
94
|
}
|
|
@@ -101,10 +98,10 @@ export class DIContainer {
|
|
|
101
98
|
|
|
102
99
|
const instance = new target(...params);
|
|
103
100
|
|
|
104
|
-
// Inject properties
|
|
101
|
+
// CRITICAL: Inject properties
|
|
105
102
|
this.injectProperties(instance);
|
|
106
103
|
|
|
107
|
-
// Call
|
|
104
|
+
// Call @PostConstruct
|
|
108
105
|
const postConstructMethod = Reflect.getMetadata(
|
|
109
106
|
METADATA_KEYS.POST_CONSTRUCT,
|
|
110
107
|
target,
|
|
@@ -123,154 +120,243 @@ export class DIContainer {
|
|
|
123
120
|
}
|
|
124
121
|
|
|
125
122
|
private injectProperties(instance: any): void {
|
|
126
|
-
const
|
|
127
|
-
|
|
123
|
+
const constructor = instance.constructor;
|
|
124
|
+
|
|
125
|
+
console.log(
|
|
126
|
+
` 🔍 Checking properties for injection on ${constructor.name}`,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// Walk through the entire prototype chain
|
|
130
|
+
let currentProto = constructor.prototype;
|
|
128
131
|
|
|
129
|
-
// Walk the prototype chain
|
|
130
132
|
while (currentProto && currentProto !== Object.prototype) {
|
|
131
|
-
// Get
|
|
132
|
-
const
|
|
133
|
+
// Get ALL property descriptors (including getters/setters)
|
|
134
|
+
const descriptors = Object.getOwnPropertyDescriptors(currentProto);
|
|
133
135
|
|
|
134
|
-
for (const
|
|
135
|
-
|
|
136
|
-
if (prop === "constructor") continue;
|
|
136
|
+
for (const [propName, descriptor] of Object.entries(descriptors)) {
|
|
137
|
+
if (propName === "constructor") continue;
|
|
137
138
|
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
// Try each injection type
|
|
140
|
+
this.tryInjectAutowired(
|
|
141
|
+
instance,
|
|
142
|
+
currentProto,
|
|
143
|
+
propName,
|
|
144
|
+
constructor.name,
|
|
145
|
+
);
|
|
146
|
+
this.tryInjectByToken(
|
|
147
|
+
instance,
|
|
141
148
|
currentProto,
|
|
142
|
-
|
|
149
|
+
propName,
|
|
150
|
+
constructor.name,
|
|
143
151
|
);
|
|
152
|
+
this.tryInjectValue(instance, currentProto, propName, constructor.name);
|
|
153
|
+
this.tryInjectRepository(
|
|
154
|
+
instance,
|
|
155
|
+
currentProto,
|
|
156
|
+
propName,
|
|
157
|
+
constructor.name,
|
|
158
|
+
);
|
|
159
|
+
this.tryInjectLazy(instance, currentProto, propName, constructor.name);
|
|
160
|
+
}
|
|
144
161
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
` 💉 @Autowired: ${target.name}.${prop} = ${autowiredType.name}`,
|
|
148
|
-
);
|
|
162
|
+
currentProto = Object.getPrototypeOf(currentProto);
|
|
163
|
+
}
|
|
149
164
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
);
|
|
165
|
+
// Also check for properties that might be defined directly on the instance
|
|
166
|
+
// but decorated with @Autowired on the class definition
|
|
167
|
+
this.checkForDecoratedProperties(instance, constructor);
|
|
168
|
+
}
|
|
155
169
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
170
|
+
private checkForDecoratedProperties(
|
|
171
|
+
instance: any,
|
|
172
|
+
constructor: Function,
|
|
173
|
+
): void {
|
|
174
|
+
// Check all metadata keys that might be attached to properties
|
|
175
|
+
const propertyKeys = [
|
|
176
|
+
...(Reflect.getMetadataKeys(constructor.prototype) || []),
|
|
177
|
+
...(Reflect.getMetadataKeys(instance) || []),
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
// Filter for property-related metadata
|
|
181
|
+
for (const key of propertyKeys) {
|
|
182
|
+
if (key.includes("fragment:")) {
|
|
183
|
+
// This is a Fragment metadata key, need to check if it's attached to a property
|
|
184
|
+
const metadataValue = Reflect.getMetadata(key, constructor.prototype);
|
|
185
|
+
if (metadataValue && typeof metadataValue === "object") {
|
|
186
|
+
// Could be a property metadata
|
|
187
|
+
for (const prop of Object.keys(metadataValue)) {
|
|
188
|
+
if (prop !== "constructor") {
|
|
189
|
+
this.tryInjectAutowired(
|
|
190
|
+
instance,
|
|
191
|
+
constructor.prototype,
|
|
192
|
+
prop,
|
|
193
|
+
constructor.name,
|
|
194
|
+
);
|
|
195
|
+
this.tryInjectByToken(
|
|
196
|
+
instance,
|
|
197
|
+
constructor.prototype,
|
|
198
|
+
prop,
|
|
199
|
+
constructor.name,
|
|
200
|
+
);
|
|
201
|
+
this.tryInjectValue(
|
|
202
|
+
instance,
|
|
203
|
+
constructor.prototype,
|
|
204
|
+
prop,
|
|
205
|
+
constructor.name,
|
|
206
|
+
);
|
|
207
|
+
this.tryInjectRepository(
|
|
208
|
+
instance,
|
|
209
|
+
constructor.prototype,
|
|
210
|
+
prop,
|
|
211
|
+
constructor.name,
|
|
162
212
|
);
|
|
163
213
|
}
|
|
164
|
-
console.warn(
|
|
165
|
-
` ⚠️ Optional autowired dependency ${autowiredType.name} not available`,
|
|
166
|
-
);
|
|
167
|
-
instance[prop] = undefined;
|
|
168
214
|
}
|
|
169
|
-
continue;
|
|
170
215
|
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
171
219
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
220
|
+
private tryInjectAutowired(
|
|
221
|
+
instance: any,
|
|
222
|
+
proto: any,
|
|
223
|
+
prop: string,
|
|
224
|
+
className: string,
|
|
225
|
+
): void {
|
|
226
|
+
const type = Reflect.getMetadata(METADATA_KEYS.AUTOWIRED, proto, prop);
|
|
178
227
|
|
|
179
|
-
|
|
180
|
-
const tokenName =
|
|
181
|
-
typeof injectToken === "string" ? injectToken : injectToken.name;
|
|
182
|
-
console.log(` 💉 @Inject: ${target.name}.${prop} = ${tokenName}`);
|
|
228
|
+
if (!type) return;
|
|
183
229
|
|
|
184
|
-
|
|
185
|
-
METADATA_KEYS.OPTIONAL,
|
|
186
|
-
currentProto,
|
|
187
|
-
prop,
|
|
188
|
-
);
|
|
230
|
+
console.log(` 💉 @Autowired found: ${className}.${prop} -> ${type.name}`);
|
|
189
231
|
|
|
190
|
-
|
|
191
|
-
instance[prop] = this.resolve(injectToken);
|
|
192
|
-
} catch (error) {
|
|
193
|
-
if (!isOptional) {
|
|
194
|
-
throw new Error(
|
|
195
|
-
`Failed to inject ${tokenName} into ${target.name}.${prop}: ${error}`,
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
console.warn(
|
|
199
|
-
` ⚠️ Optional inject dependency ${tokenName} not available`,
|
|
200
|
-
);
|
|
201
|
-
instance[prop] = undefined;
|
|
202
|
-
}
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
232
|
+
const isOptional = Reflect.getMetadata(METADATA_KEYS.OPTIONAL, proto, prop);
|
|
205
233
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
234
|
+
try {
|
|
235
|
+
instance[prop] = this.resolve(type);
|
|
236
|
+
console.log(` ✅ Injected ${type.name} into ${className}.${prop}`);
|
|
237
|
+
} catch (error) {
|
|
238
|
+
if (!isOptional) {
|
|
239
|
+
throw new Error(
|
|
240
|
+
`Failed to autowire ${type.name} into ${className}.${prop}: ${error}`,
|
|
211
241
|
);
|
|
242
|
+
}
|
|
243
|
+
console.warn(
|
|
244
|
+
` ⚠️ Optional dependency ${type.name} not available for ${className}.${prop}`,
|
|
245
|
+
);
|
|
246
|
+
instance[prop] = undefined;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
212
249
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
250
|
+
private tryInjectByToken(
|
|
251
|
+
instance: any,
|
|
252
|
+
proto: any,
|
|
253
|
+
prop: string,
|
|
254
|
+
className: string,
|
|
255
|
+
): void {
|
|
256
|
+
const token = Reflect.getMetadata(METADATA_KEYS.INJECT, proto, prop);
|
|
220
257
|
|
|
221
|
-
|
|
222
|
-
const repositoryEntity = Reflect.getMetadata(
|
|
223
|
-
METADATA_KEYS.INJECT_REPOSITORY,
|
|
224
|
-
currentProto,
|
|
225
|
-
prop,
|
|
226
|
-
);
|
|
258
|
+
if (!token) return;
|
|
227
259
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
` 💾 @InjectRepository: ${target.name}.${prop} = Repository<${repositoryEntity.name}>`,
|
|
231
|
-
);
|
|
232
|
-
instance[prop] = this.resolveRepository(repositoryEntity);
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
260
|
+
const tokenName = typeof token === "string" ? token : token.name;
|
|
261
|
+
console.log(` 💉 @Inject found: ${className}.${prop} -> ${tokenName}`);
|
|
235
262
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
263
|
+
const isOptional = Reflect.getMetadata(METADATA_KEYS.OPTIONAL, proto, prop);
|
|
264
|
+
|
|
265
|
+
try {
|
|
266
|
+
instance[prop] = this.resolve(token);
|
|
267
|
+
console.log(` ✅ Injected ${tokenName} into ${className}.${prop}`);
|
|
268
|
+
} catch (error) {
|
|
269
|
+
if (!isOptional) {
|
|
270
|
+
throw new Error(
|
|
271
|
+
`Failed to inject ${tokenName} into ${className}.${prop}: ${error}`,
|
|
241
272
|
);
|
|
273
|
+
}
|
|
274
|
+
console.warn(
|
|
275
|
+
` ⚠️ Optional dependency ${tokenName} not available for ${className}.${prop}`,
|
|
276
|
+
);
|
|
277
|
+
instance[prop] = undefined;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
242
280
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
281
|
+
private tryInjectValue(
|
|
282
|
+
instance: any,
|
|
283
|
+
proto: any,
|
|
284
|
+
prop: string,
|
|
285
|
+
className: string,
|
|
286
|
+
): void {
|
|
287
|
+
const expression = Reflect.getMetadata(METADATA_KEYS.VALUE, proto, prop);
|
|
248
288
|
|
|
249
|
-
|
|
250
|
-
let resolved = false;
|
|
251
|
-
|
|
252
|
-
Object.defineProperty(instance, prop, {
|
|
253
|
-
get: () => {
|
|
254
|
-
if (!resolved) {
|
|
255
|
-
console.log(
|
|
256
|
-
` 🔓 Lazy-loading ${type.name} for ${target.name}.${prop}`,
|
|
257
|
-
);
|
|
258
|
-
cached = this.resolve(type);
|
|
259
|
-
resolved = true;
|
|
260
|
-
}
|
|
261
|
-
return cached;
|
|
262
|
-
},
|
|
263
|
-
enumerable: true,
|
|
264
|
-
configurable: true,
|
|
265
|
-
});
|
|
266
|
-
continue;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
289
|
+
if (expression === undefined) return;
|
|
269
290
|
|
|
270
|
-
|
|
291
|
+
console.log(` 🔧 @Value found: ${className}.${prop} = ${expression}`);
|
|
292
|
+
instance[prop] = this.resolveValue(expression);
|
|
293
|
+
console.log(` ✅ Set value for ${className}.${prop}`);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
private tryInjectRepository(
|
|
297
|
+
instance: any,
|
|
298
|
+
proto: any,
|
|
299
|
+
prop: string,
|
|
300
|
+
className: string,
|
|
301
|
+
): void {
|
|
302
|
+
const entity = Reflect.getMetadata(
|
|
303
|
+
METADATA_KEYS.INJECT_REPOSITORY,
|
|
304
|
+
proto,
|
|
305
|
+
prop,
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
if (!entity) return;
|
|
309
|
+
|
|
310
|
+
console.log(
|
|
311
|
+
` 💾 @InjectRepository found: ${className}.${prop} -> Repository<${entity.name}>`,
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
try {
|
|
315
|
+
instance[prop] = this.resolveRepository(entity);
|
|
316
|
+
console.log(
|
|
317
|
+
` ✅ Injected Repository<${entity.name}> into ${className}.${prop}`,
|
|
318
|
+
);
|
|
319
|
+
} catch (error) {
|
|
320
|
+
throw new Error(
|
|
321
|
+
`Failed to inject repository for ${entity.name} into ${className}.${prop}: ${error}`,
|
|
322
|
+
);
|
|
271
323
|
}
|
|
272
324
|
}
|
|
273
325
|
|
|
326
|
+
private tryInjectLazy(
|
|
327
|
+
instance: any,
|
|
328
|
+
proto: any,
|
|
329
|
+
prop: string,
|
|
330
|
+
className: string,
|
|
331
|
+
): void {
|
|
332
|
+
const isLazy = Reflect.getMetadata(METADATA_KEYS.LAZY, proto, prop);
|
|
333
|
+
|
|
334
|
+
if (!isLazy) return;
|
|
335
|
+
|
|
336
|
+
const type = Reflect.getMetadata("design:type", proto, prop);
|
|
337
|
+
console.log(
|
|
338
|
+
` ⏳ @Lazy found: ${className}.${prop} (${type?.name || "unknown"})`,
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
let cached: any = null;
|
|
342
|
+
let resolved = false;
|
|
343
|
+
|
|
344
|
+
Object.defineProperty(instance, prop, {
|
|
345
|
+
get: () => {
|
|
346
|
+
if (!resolved) {
|
|
347
|
+
console.log(
|
|
348
|
+
` 🔓 Lazy-loading ${type.name} for ${className}.${prop}`,
|
|
349
|
+
);
|
|
350
|
+
cached = this.resolve(type);
|
|
351
|
+
resolved = true;
|
|
352
|
+
}
|
|
353
|
+
return cached;
|
|
354
|
+
},
|
|
355
|
+
enumerable: true,
|
|
356
|
+
configurable: true,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
274
360
|
private resolveValue(expression: string): any {
|
|
275
361
|
const match = expression.match(
|
|
276
362
|
/\$\{([^:}]+)(?::([^}]*))?\}|\$([A-Z_][A-Z0-9_]*)/i,
|
|
@@ -284,11 +370,10 @@ export class DIContainer {
|
|
|
284
370
|
if (defaultValue !== undefined) {
|
|
285
371
|
return defaultValue;
|
|
286
372
|
}
|
|
287
|
-
console.warn(
|
|
373
|
+
console.warn(` ⚠️ Environment variable "${key}" not defined`);
|
|
288
374
|
return "";
|
|
289
375
|
}
|
|
290
376
|
|
|
291
|
-
// Parse JSON
|
|
292
377
|
if (value.startsWith("{") || value.startsWith("[")) {
|
|
293
378
|
try {
|
|
294
379
|
return JSON.parse(value);
|
|
@@ -297,12 +382,10 @@ export class DIContainer {
|
|
|
297
382
|
}
|
|
298
383
|
}
|
|
299
384
|
|
|
300
|
-
// Parse numbers
|
|
301
385
|
if (/^\d+(\.\d+)?$/.test(value)) {
|
|
302
386
|
return parseFloat(value);
|
|
303
387
|
}
|
|
304
388
|
|
|
305
|
-
// Parse booleans
|
|
306
389
|
if (value.toLowerCase() === "true") return true;
|
|
307
390
|
if (value.toLowerCase() === "false") return false;
|
|
308
391
|
|