fragment-ts 1.0.29 → 1.0.31
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 +7 -7
- package/dist/core/container/di-container.d.ts.map +1 -1
- package/dist/core/container/di-container.js +126 -138
- package/dist/core/container/di-container.js.map +1 -1
- package/dist/core/decorators/application.decorator.d.ts.map +1 -1
- package/dist/core/decorators/application.decorator.js +2 -1
- package/dist/core/decorators/application.decorator.js.map +1 -1
- package/dist/core/decorators/auto-configuration.decorator.d.ts.map +1 -1
- package/dist/core/decorators/auto-configuration.decorator.js +4 -3
- package/dist/core/decorators/auto-configuration.decorator.js.map +1 -1
- package/dist/core/decorators/controller.decorator.d.ts.map +1 -1
- package/dist/core/decorators/controller.decorator.js +1 -0
- package/dist/core/decorators/controller.decorator.js.map +1 -1
- package/dist/core/decorators/http.decorators.d.ts.map +1 -1
- package/dist/core/decorators/http.decorators.js +9 -0
- package/dist/core/decorators/http.decorators.js.map +1 -1
- package/dist/core/decorators/injectable.decorator.d.ts.map +1 -1
- package/dist/core/decorators/injectable.decorator.js +1 -0
- package/dist/core/decorators/injectable.decorator.js.map +1 -1
- package/dist/core/decorators/injection.decorators.d.ts.map +1 -1
- package/dist/core/decorators/injection.decorators.js +50 -21
- package/dist/core/decorators/injection.decorators.js.map +1 -1
- package/dist/core/decorators/repository.decorator.d.ts.map +1 -1
- package/dist/core/decorators/repository.decorator.js +1 -0
- package/dist/core/decorators/repository.decorator.js.map +1 -1
- package/dist/core/decorators/service.decorator.d.ts.map +1 -1
- package/dist/core/decorators/service.decorator.js +1 -0
- package/dist/core/decorators/service.decorator.js.map +1 -1
- package/dist/core/metadata/metadata-storage.d.ts +8 -13
- package/dist/core/metadata/metadata-storage.d.ts.map +1 -1
- package/dist/core/metadata/metadata-storage.js +19 -18
- package/dist/core/metadata/metadata-storage.js.map +1 -1
- package/dist/web/application.d.ts +0 -6
- package/dist/web/application.d.ts.map +1 -1
- package/dist/web/application.js +93 -41
- package/dist/web/application.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 +188 -203
- package/src/core/decorators/application.decorator.ts +2 -1
- package/src/core/decorators/auto-configuration.decorator.ts +9 -8
- package/src/core/decorators/controller.decorator.ts +2 -1
- package/src/core/decorators/http.decorators.ts +17 -0
- package/src/core/decorators/injectable.decorator.ts +1 -0
- package/src/core/decorators/injection.decorators.ts +64 -24
- package/src/core/decorators/repository.decorator.ts +1 -0
- package/src/core/decorators/service.decorator.ts +1 -0
- package/src/core/metadata/metadata-storage.ts +37 -37
- package/src/web/application.ts +129 -44
|
@@ -17,18 +17,21 @@ const metadata_storage_1 = require("../metadata/metadata-storage");
|
|
|
17
17
|
*/
|
|
18
18
|
function Autowired() {
|
|
19
19
|
return (target, propertyKey) => {
|
|
20
|
+
// Get the design type from TypeScript metadata
|
|
21
|
+
const type = Reflect.getMetadata("design:type", target, propertyKey);
|
|
22
|
+
if (!type || type === Object) {
|
|
23
|
+
console.warn(`⚠️ Could not determine type for ${target.constructor.name}.${String(propertyKey)}. ` +
|
|
24
|
+
`Ensure emitDecoratorMetadata is enabled in tsconfig.json`);
|
|
25
|
+
}
|
|
20
26
|
// Store metadata for property injection
|
|
21
27
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
22
28
|
storage.addPropertyInjection?.(target.constructor, propertyKey.toString(), {
|
|
23
29
|
type: "autowired",
|
|
24
30
|
key: propertyKey.toString(),
|
|
31
|
+
metadata: { type },
|
|
32
|
+
propertyKey: propertyKey.toString(),
|
|
25
33
|
});
|
|
26
34
|
// Also store in Reflect metadata for backward compatibility
|
|
27
|
-
const type = Reflect.getMetadata("design:type", target, propertyKey);
|
|
28
|
-
if (!type || type === Object) {
|
|
29
|
-
console.warn(`⚠️ Could not determine type for ${target.constructor.name}.${String(propertyKey)}. ` +
|
|
30
|
-
`Ensure emitDecoratorMetadata is enabled in tsconfig.json`);
|
|
31
|
-
}
|
|
32
35
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.AUTOWIRED, type, target, propertyKey);
|
|
33
36
|
};
|
|
34
37
|
}
|
|
@@ -39,6 +42,15 @@ function Autowired() {
|
|
|
39
42
|
*/
|
|
40
43
|
function Inject(token) {
|
|
41
44
|
return (target, propertyKey) => {
|
|
45
|
+
// Store metadata for property injection
|
|
46
|
+
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
47
|
+
storage.addPropertyInjection?.(target.constructor, propertyKey.toString(), {
|
|
48
|
+
type: "inject",
|
|
49
|
+
key: propertyKey.toString(),
|
|
50
|
+
metadata: { token },
|
|
51
|
+
propertyKey: propertyKey.toString(),
|
|
52
|
+
});
|
|
53
|
+
// Also store in Reflect metadata for backward compatibility
|
|
42
54
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.INJECT, token, target, propertyKey);
|
|
43
55
|
};
|
|
44
56
|
}
|
|
@@ -48,6 +60,15 @@ function Inject(token) {
|
|
|
48
60
|
*/
|
|
49
61
|
function InjectRepository(entity) {
|
|
50
62
|
return (target, propertyKey) => {
|
|
63
|
+
// Store metadata for property injection
|
|
64
|
+
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
65
|
+
storage.addPropertyInjection?.(target.constructor, propertyKey.toString(), {
|
|
66
|
+
type: "repository",
|
|
67
|
+
key: propertyKey.toString(),
|
|
68
|
+
metadata: { entity },
|
|
69
|
+
propertyKey: propertyKey.toString(),
|
|
70
|
+
});
|
|
71
|
+
// Also store in Reflect metadata for backward compatibility
|
|
51
72
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.INJECT_REPOSITORY, entity, target, propertyKey);
|
|
52
73
|
};
|
|
53
74
|
}
|
|
@@ -67,6 +88,15 @@ function Qualifier(name) {
|
|
|
67
88
|
*/
|
|
68
89
|
function Value(expression) {
|
|
69
90
|
return (target, propertyKey) => {
|
|
91
|
+
// Store metadata for property injection
|
|
92
|
+
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
93
|
+
storage.addPropertyInjection?.(target.constructor, propertyKey.toString(), {
|
|
94
|
+
type: "value",
|
|
95
|
+
key: propertyKey.toString(),
|
|
96
|
+
metadata: { expression },
|
|
97
|
+
propertyKey: propertyKey.toString(),
|
|
98
|
+
});
|
|
99
|
+
// Also store in Reflect metadata for backward compatibility
|
|
70
100
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.VALUE, expression, target, propertyKey);
|
|
71
101
|
};
|
|
72
102
|
}
|
|
@@ -85,24 +115,19 @@ function Optional() {
|
|
|
85
115
|
*/
|
|
86
116
|
function Lazy() {
|
|
87
117
|
return (target, propertyKey) => {
|
|
118
|
+
// Mark as lazy in metadata
|
|
88
119
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.LAZY, true, target, propertyKey);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (!resolved) {
|
|
96
|
-
const { DIContainer } = require("../container/di-container");
|
|
97
|
-
const container = DIContainer.getInstance();
|
|
98
|
-
cached = container.resolve(type);
|
|
99
|
-
resolved = true;
|
|
100
|
-
}
|
|
101
|
-
return cached;
|
|
102
|
-
},
|
|
103
|
-
enumerable: true,
|
|
104
|
-
configurable: true,
|
|
120
|
+
// Store metadata for property injection
|
|
121
|
+
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
122
|
+
storage.addPropertyInjection?.(target.constructor, propertyKey.toString(), {
|
|
123
|
+
type: "lazy",
|
|
124
|
+
key: propertyKey.toString(),
|
|
125
|
+
propertyKey: propertyKey.toString(),
|
|
105
126
|
});
|
|
127
|
+
// Get the type for later resolution
|
|
128
|
+
const type = Reflect.getMetadata("design:type", target, propertyKey);
|
|
129
|
+
// This will be handled by the container during injection
|
|
130
|
+
// (not directly creating the getter here to avoid container dependency)
|
|
106
131
|
};
|
|
107
132
|
}
|
|
108
133
|
/**
|
|
@@ -111,6 +136,8 @@ function Lazy() {
|
|
|
111
136
|
*/
|
|
112
137
|
function PostConstruct() {
|
|
113
138
|
return (target, propertyKey, descriptor) => {
|
|
139
|
+
const className = target.constructor.name;
|
|
140
|
+
console.log(` 🏗️ Registering @PostConstruct: ${className}.${String(propertyKey)}`);
|
|
114
141
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.POST_CONSTRUCT, propertyKey, target.constructor);
|
|
115
142
|
};
|
|
116
143
|
}
|
|
@@ -120,6 +147,8 @@ function PostConstruct() {
|
|
|
120
147
|
*/
|
|
121
148
|
function PreDestroy() {
|
|
122
149
|
return (target, propertyKey, descriptor) => {
|
|
150
|
+
const className = target.constructor.name;
|
|
151
|
+
console.log(` 🧹 Registering @PreDestroy: ${className}.${String(propertyKey)}`);
|
|
123
152
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.PRE_DESTROY, propertyKey, target.constructor);
|
|
124
153
|
};
|
|
125
154
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injection.decorators.js","sourceRoot":"","sources":["../../../src/core/decorators/injection.decorators.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"injection.decorators.js","sourceRoot":"","sources":["../../../src/core/decorators/injection.decorators.ts"],"names":[],"mappings":";;AAQA,8BAuBC;AAOD,wBAcC;AAMD,4CAmBC;AAMD,8BAIC;AAOD,sBAmBC;AAMD,4BAIC;AAMD,oBAmBC;AAMD,sCAiBC;AAMD,gCAiBC;AAlMD,6DAA0D;AAC1D,mEAA+D;AAG/D;;;GAGG;AACH,SAAgB,SAAS;IACvB,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAE,EAAE;QACnD,+CAA+C;QAC/C,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACrE,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YAC7B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Aa,CAAC,cAAc,EAC5B,WAAW,EACX,MAAM,CAAC,WAAW,CACnB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,UAAU;IACxB,OAAO,CACL,MAAW,EACX,WAA4B,EAC5B,UAA8B,EAC9B,EAAE;QACF,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QAC1C,OAAO,CAAC,GAAG,CACT,gCAAgC,SAAS,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,CACnE,CAAC;QAEF,OAAO,CAAC,cAAc,CACpB,6BAAa,CAAC,WAAW,EACzB,WAAW,EACX,MAAM,CAAC,WAAW,CACnB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/repository.decorator.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"repository.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/repository.decorator.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,IAAI,cAAc,CAa3C"}
|
|
@@ -6,6 +6,7 @@ const metadata_keys_1 = require("../metadata/metadata-keys");
|
|
|
6
6
|
const metadata_storage_1 = require("../metadata/metadata-storage");
|
|
7
7
|
function Repository() {
|
|
8
8
|
return (target) => {
|
|
9
|
+
console.log(`💾 Registering Repository: ${target.name}`);
|
|
9
10
|
(0, injectable_decorator_1.Injectable)('singleton')(target);
|
|
10
11
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.REPOSITORY, true, target);
|
|
11
12
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/repository.decorator.ts"],"names":[],"mappings":";;AAIA,
|
|
1
|
+
{"version":3,"file":"repository.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/repository.decorator.ts"],"names":[],"mappings":";;AAIA,gCAaC;AAjBD,iEAAoD;AACpD,6DAA0D;AAC1D,mEAA+D;AAE/D,SAAgB,UAAU;IACxB,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,8BAA8B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACzD,IAAA,iCAAU,EAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;QAChC,OAAO,CAAC,cAAc,CAAC,6BAAa,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAE/D,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;QAC9C,OAAO,CAAC,QAAQ,CAAC;YACf,MAAM;YACN,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,WAAW;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/service.decorator.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"service.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/decorators/service.decorator.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO,IAAI,cAAc,CAaxC"}
|
|
@@ -6,6 +6,7 @@ const metadata_keys_1 = require("../metadata/metadata-keys");
|
|
|
6
6
|
const metadata_storage_1 = require("../metadata/metadata-storage");
|
|
7
7
|
function Service() {
|
|
8
8
|
return (target) => {
|
|
9
|
+
console.log(`⚙️ Registering Service: ${target.name}`);
|
|
9
10
|
(0, injectable_decorator_1.Injectable)('singleton')(target);
|
|
10
11
|
Reflect.defineMetadata(metadata_keys_1.METADATA_KEYS.SERVICE, true, target);
|
|
11
12
|
const storage = metadata_storage_1.MetadataStorage.getInstance();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/service.decorator.ts"],"names":[],"mappings":";;AAIA,
|
|
1
|
+
{"version":3,"file":"service.decorator.js","sourceRoot":"","sources":["../../../src/core/decorators/service.decorator.ts"],"names":[],"mappings":";;AAIA,0BAaC;AAjBD,iEAAoD;AACpD,6DAA0D;AAC1D,mEAA+D;AAE/D,SAAgB,OAAO;IACrB,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,4BAA4B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACvD,IAAA,iCAAU,EAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;QAChC,OAAO,CAAC,cAAc,CAAC,6BAAa,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAE5D,MAAM,OAAO,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC;QAC9C,OAAO,CAAC,QAAQ,CAAC;YACf,MAAM;YACN,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,WAAW;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -18,6 +18,12 @@ export interface ParamMetadata {
|
|
|
18
18
|
type: "body" | "param" | "query" | "header" | "req" | "res";
|
|
19
19
|
paramName?: string;
|
|
20
20
|
}
|
|
21
|
+
export interface PropertyInjectionMetadata {
|
|
22
|
+
propertyKey: string;
|
|
23
|
+
type: "autowired" | "inject" | "repository" | "value" | "lazy";
|
|
24
|
+
key: string;
|
|
25
|
+
metadata?: any;
|
|
26
|
+
}
|
|
21
27
|
export declare class MetadataStorage {
|
|
22
28
|
private static instance;
|
|
23
29
|
private classes;
|
|
@@ -25,19 +31,6 @@ export declare class MetadataStorage {
|
|
|
25
31
|
private params;
|
|
26
32
|
private propertyInjections;
|
|
27
33
|
static getInstance(): MetadataStorage;
|
|
28
|
-
addPropertyInjection(target: any, propertyKey: string, injection: {
|
|
29
|
-
type: string;
|
|
30
|
-
key: string;
|
|
31
|
-
metadata?: any;
|
|
32
|
-
}): void;
|
|
33
|
-
getAllPropertyInjections(target: any): {
|
|
34
|
-
propertyKey: string;
|
|
35
|
-
injections: {
|
|
36
|
-
type: string;
|
|
37
|
-
key: string;
|
|
38
|
-
metadata?: any;
|
|
39
|
-
}[];
|
|
40
|
-
}[];
|
|
41
34
|
addClass(metadata: ClassMetadata): void;
|
|
42
35
|
getClass(target: any): ClassMetadata | undefined;
|
|
43
36
|
getAllClasses(): ClassMetadata[];
|
|
@@ -46,5 +39,7 @@ export declare class MetadataStorage {
|
|
|
46
39
|
getAllMethods(): MethodMetadata[];
|
|
47
40
|
addParam(metadata: ParamMetadata): void;
|
|
48
41
|
getParams(target: any, propertyKey: string): ParamMetadata[];
|
|
42
|
+
addPropertyInjection(target: any, propertyKey: string, injection: PropertyInjectionMetadata): void;
|
|
43
|
+
getPropertyInjections(target: any): PropertyInjectionMetadata[];
|
|
49
44
|
}
|
|
50
45
|
//# sourceMappingURL=metadata-storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-storage.d.ts","sourceRoot":"","sources":["../../../src/core/metadata/metadata-storage.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,GAAG,CAAC;IACZ,IAAI,EACA,YAAY,GACZ,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,oBAAoB,CAAC;IACzB,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,GAAG,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,aAAa,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,GA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AQ,CAAkB;IACzC,OAAO,CAAC,OAAO,CAAsC;IACrD,OAAO,CAAC,OAAO,CAA0C;IACzD,OAAO,CAAC,MAAM,CAA2C;IACzD,OAAO,CAAC,kBAAkB,CACd;IAEZ,MAAM,CAAC,WAAW,IAAI,eAAe;IAOrC,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAIvC,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,aAAa,GAAG,SAAS;IAIhD,aAAa,IAAI,aAAa,EAAE;IAIhC,SAAS,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAYzC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAKvE,aAAa,IAAI,cAAc,EAAE;IAIjC,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAOvC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,EAAE;IAQ5D,oBAAoB,CAClB,MAAM,EAAE,GAAG,EACX,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,yBAAyB,GACnC,IAAI;IASP,qBAAqB,CAAC,MAAM,EAAE,GAAG,GAAG,yBAAyB,EAAE;CAchE"}
|
|
@@ -14,24 +14,6 @@ class MetadataStorage {
|
|
|
14
14
|
}
|
|
15
15
|
return MetadataStorage.instance;
|
|
16
16
|
}
|
|
17
|
-
addPropertyInjection(target, propertyKey, injection) {
|
|
18
|
-
const className = target.name || target.constructor?.name;
|
|
19
|
-
const key = `${className}.${propertyKey}`;
|
|
20
|
-
const injections = this.propertyInjections.get(key) || [];
|
|
21
|
-
injections.push(injection);
|
|
22
|
-
this.propertyInjections.set(key, injections);
|
|
23
|
-
}
|
|
24
|
-
getAllPropertyInjections(target) {
|
|
25
|
-
const className = target.name || target.constructor?.name;
|
|
26
|
-
const injections = [];
|
|
27
|
-
this.propertyInjections.forEach((value, key) => {
|
|
28
|
-
if (key.startsWith(`${className}.`)) {
|
|
29
|
-
const propertyKey = key.split(".")[1];
|
|
30
|
-
injections.push({ propertyKey, injections: value });
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return injections;
|
|
34
|
-
}
|
|
35
17
|
addClass(metadata) {
|
|
36
18
|
this.classes.set(metadata.target, metadata);
|
|
37
19
|
}
|
|
@@ -67,6 +49,25 @@ class MetadataStorage {
|
|
|
67
49
|
const key = `${targetName}.${propertyKey}`;
|
|
68
50
|
return this.params.get(key) || [];
|
|
69
51
|
}
|
|
52
|
+
addPropertyInjection(target, propertyKey, injection) {
|
|
53
|
+
if (!this.propertyInjections.has(target)) {
|
|
54
|
+
this.propertyInjections.set(target, []);
|
|
55
|
+
}
|
|
56
|
+
const injections = this.propertyInjections.get(target);
|
|
57
|
+
injections.push(injection);
|
|
58
|
+
}
|
|
59
|
+
getPropertyInjections(target) {
|
|
60
|
+
// Get injections for this specific class
|
|
61
|
+
let injections = this.propertyInjections.get(target) || [];
|
|
62
|
+
// Also get injections from parent classes
|
|
63
|
+
let parent = Object.getPrototypeOf(target);
|
|
64
|
+
while (parent && parent !== Object && parent !== Function.prototype) {
|
|
65
|
+
const parentInjections = this.propertyInjections.get(parent) || [];
|
|
66
|
+
injections = [...injections, ...parentInjections];
|
|
67
|
+
parent = Object.getPrototypeOf(parent);
|
|
68
|
+
}
|
|
69
|
+
return injections;
|
|
70
|
+
}
|
|
70
71
|
}
|
|
71
72
|
exports.MetadataStorage = MetadataStorage;
|
|
72
73
|
//# sourceMappingURL=metadata-storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-storage.js","sourceRoot":"","sources":["../../../src/core/metadata/metadata-storage.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"metadata-storage.js","sourceRoot":"","sources":["../../../src/core/metadata/metadata-storage.ts"],"names":[],"mappings":";;;AAqCA,MAAa,eAAe;IAA5B;QAEU,YAAO,GAA4B,IAAI,GAAG,EAAE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,CAAC,CAAC;IAC7B,CAAC;IAED,qBAAqB,CAAC,MAAW;QAC/B,yCAAyC;QACzC,IAAI,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAE3D,0CAA0C;QAC1C,IAAI,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC3C,OAAO,MAAM,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,QAAQ,CAAC,SAAS,EAAE,CAAC;YACpE,MAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACnE,UAAU,GAAG,CAAC,GAAG,UAAU,EAAE,GAAG,gBAAgB,CAAC,CAAC;YAClD,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AA1FD,0CA0FC"}
|
|
@@ -6,13 +6,7 @@ export declare class FragmentWebApplication {
|
|
|
6
6
|
constructor();
|
|
7
7
|
private setupMiddleware;
|
|
8
8
|
bootstrap(appClass: any): Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* Detects environment and scans appropriate files
|
|
11
|
-
*/
|
|
12
9
|
private scanComponents;
|
|
13
|
-
/**
|
|
14
|
-
* Detects if we're running TypeScript directly (ts-node or similar)
|
|
15
|
-
*/
|
|
16
10
|
private isRunningTypeScript;
|
|
17
11
|
private discoverAndRegisterComponents;
|
|
18
12
|
private getTypeIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/web/application.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAmC,MAAM,SAAS,CAAC;AAY5E,qBAAa,sBAAsB;IACjC,OAAO,CAAC,GAAG,CAAU;IACrB,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,eAAe,CAAkB;;IAUzC,OAAO,CAAC,eAAe;
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../src/web/application.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAmC,MAAM,SAAS,CAAC;AAY5E,qBAAa,sBAAsB;IACjC,OAAO,CAAC,GAAG,CAAU;IACrB,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,eAAe,CAAkB;;IAUzC,OAAO,CAAC,eAAe;IASjB,SAAS,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;YA0C/B,cAAc;IA4B5B,OAAO,CAAC,mBAAmB;IAgC3B,OAAO,CAAC,6BAA6B;IA6DrC,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,cAAc;IAmDtB,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,cAAc;IAkFtB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,uBAAuB;IA+B/B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;IAcpB,aAAa,IAAI,OAAO;CAGzB"}
|
package/dist/web/application.js
CHANGED
|
@@ -50,13 +50,14 @@ const component_scanner_1 = require("../core/scanner/component-scanner");
|
|
|
50
50
|
const typeorm_module_1 = require("../typeorm/typeorm-module");
|
|
51
51
|
class FragmentWebApplication {
|
|
52
52
|
constructor() {
|
|
53
|
+
console.log("🌱 Initializing Fragment Framework");
|
|
53
54
|
this.app = (0, express_1.default)();
|
|
54
55
|
this.container = di_container_1.DIContainer.getInstance();
|
|
55
56
|
this.metadataStorage = metadata_storage_1.MetadataStorage.getInstance();
|
|
56
57
|
this.setupMiddleware();
|
|
57
|
-
this;
|
|
58
58
|
}
|
|
59
59
|
setupMiddleware() {
|
|
60
|
+
console.log("⚙️ Setting up middleware");
|
|
60
61
|
this.app.use((0, helmet_1.default)());
|
|
61
62
|
this.app.use((0, cors_1.default)());
|
|
62
63
|
this.app.use((0, compression_1.default)());
|
|
@@ -64,12 +65,21 @@ class FragmentWebApplication {
|
|
|
64
65
|
this.app.use(express_1.default.urlencoded({ extended: true }));
|
|
65
66
|
}
|
|
66
67
|
async bootstrap(appClass) {
|
|
67
|
-
|
|
68
|
+
console.log("\n🚀 Bootstrapping application");
|
|
69
|
+
try {
|
|
70
|
+
await typeorm_module_1.TypeORMModule.initialize();
|
|
71
|
+
console.log("✅ TypeORM initialized successfully");
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error("❌ Failed to initialize TypeORM:", error);
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
68
77
|
const appMetadata = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.APPLICATION, appClass);
|
|
78
|
+
console.log(`🎯 Application metadata:`, appMetadata);
|
|
69
79
|
// CRITICAL: Scan and load all component files first
|
|
70
80
|
// This triggers decorator execution
|
|
71
81
|
if (appMetadata?.autoScan !== false) {
|
|
72
|
-
console.log("🔍 Scanning for components...");
|
|
82
|
+
console.log("\n🔍 Scanning for components...");
|
|
73
83
|
await this.scanComponents();
|
|
74
84
|
}
|
|
75
85
|
// Now metadata storage will be populated
|
|
@@ -79,35 +89,34 @@ class FragmentWebApplication {
|
|
|
79
89
|
const host = appMetadata?.host || "0.0.0.0";
|
|
80
90
|
this.app.use(this.errorHandler.bind(this));
|
|
81
91
|
this.app.listen(port, host, () => {
|
|
82
|
-
console.log(
|
|
92
|
+
console.log(`\n✨ Fragment application running on http://${host}:${port}`);
|
|
93
|
+
console.log("========================================\n");
|
|
83
94
|
});
|
|
84
95
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Detects environment and scans appropriate files
|
|
87
|
-
*/
|
|
88
96
|
async scanComponents() {
|
|
89
97
|
const cwd = process.cwd();
|
|
90
98
|
const distExists = fs.existsSync(path.join(cwd, "dist"));
|
|
91
99
|
const srcExists = fs.existsSync(path.join(cwd, "src"));
|
|
100
|
+
console.log(`📁 Current working directory: ${cwd}`);
|
|
101
|
+
console.log(`📁 dist/ exists: ${distExists}`);
|
|
102
|
+
console.log(`📁 src/ exists: ${srcExists}`);
|
|
92
103
|
// Determine if we're running TypeScript directly (dev) or compiled JS (prod)
|
|
93
104
|
const isDevMode = this.isRunningTypeScript();
|
|
105
|
+
console.log(`💻 Running in ${isDevMode ? "development" : "production"} mode`);
|
|
94
106
|
if (isDevMode && srcExists) {
|
|
95
107
|
// Development mode: scan TypeScript source files
|
|
96
|
-
console.log("
|
|
108
|
+
console.log(" 📝 Development mode: scanning TypeScript files");
|
|
97
109
|
await component_scanner_1.ComponentScanner.scanSource();
|
|
98
110
|
}
|
|
99
111
|
else if (distExists) {
|
|
100
112
|
// Production mode: scan compiled JavaScript files
|
|
101
|
-
console.log("
|
|
113
|
+
console.log(" 📦 Production mode: scanning compiled files");
|
|
102
114
|
await component_scanner_1.ComponentScanner.scan();
|
|
103
115
|
}
|
|
104
116
|
else {
|
|
105
|
-
console.warn("
|
|
117
|
+
console.warn(" ⚠️ Warning: No src/ or dist/ directory found");
|
|
106
118
|
}
|
|
107
119
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Detects if we're running TypeScript directly (ts-node or similar)
|
|
110
|
-
*/
|
|
111
120
|
isRunningTypeScript() {
|
|
112
121
|
// Check if ts-node is in require.extensions
|
|
113
122
|
if (require.extensions[".ts"]) {
|
|
@@ -133,25 +142,53 @@ class FragmentWebApplication {
|
|
|
133
142
|
return false;
|
|
134
143
|
}
|
|
135
144
|
discoverAndRegisterComponents() {
|
|
136
|
-
// First, register all components with the container
|
|
137
145
|
const classes = this.metadataStorage.getAllClasses();
|
|
138
146
|
console.log(`\n📦 Discovered ${classes.length} component(s)`);
|
|
139
|
-
//
|
|
140
|
-
classes.
|
|
141
|
-
if (!
|
|
142
|
-
|
|
143
|
-
|
|
147
|
+
// Group by type for display
|
|
148
|
+
const grouped = classes.reduce((acc, cls) => {
|
|
149
|
+
if (!acc[cls.type])
|
|
150
|
+
acc[cls.type] = [];
|
|
151
|
+
acc[cls.type].push(cls);
|
|
152
|
+
return acc;
|
|
153
|
+
}, {});
|
|
154
|
+
Object.entries(grouped).forEach(([type, items]) => {
|
|
155
|
+
const icon = this.getTypeIcon(type);
|
|
156
|
+
console.log(` ${icon} ${items.length} ${type}(s)`);
|
|
157
|
+
items.forEach((item) => {
|
|
158
|
+
console.log(` • ${item.target.name}${item.path ? ` (${item.path})` : ""}`);
|
|
159
|
+
});
|
|
144
160
|
});
|
|
145
|
-
|
|
161
|
+
let registered = 0;
|
|
162
|
+
let skipped = 0;
|
|
146
163
|
classes.forEach((metadata) => {
|
|
147
164
|
if (this.shouldRegister(metadata.target)) {
|
|
148
|
-
|
|
149
|
-
|
|
165
|
+
// CRITICAL: Register with container
|
|
166
|
+
if (!this.container.has(metadata.target)) {
|
|
167
|
+
this.container.register(metadata.target);
|
|
168
|
+
registered++;
|
|
169
|
+
console.log(` ✓ Registered: ${metadata.target.name}`);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
console.log(` ✓ Already registered: ${metadata.target.name}`);
|
|
173
|
+
}
|
|
150
174
|
}
|
|
151
175
|
else {
|
|
176
|
+
skipped++;
|
|
152
177
|
console.log(` ⊘ Skipped: ${metadata.target.name} (conditional check failed)`);
|
|
153
178
|
}
|
|
154
179
|
});
|
|
180
|
+
console.log(`\n✓ Registered ${registered} component(s)`);
|
|
181
|
+
if (skipped > 0) {
|
|
182
|
+
console.log(`⊘ Skipped ${skipped} component(s) (conditions not met)`);
|
|
183
|
+
}
|
|
184
|
+
// Pre-resolve all singleton components to ensure dependencies are injected
|
|
185
|
+
console.log("\n🔧 Initializing components");
|
|
186
|
+
classes.forEach((metadata) => {
|
|
187
|
+
if (this.shouldRegister(metadata.target)) {
|
|
188
|
+
const instance = this.container.resolve(metadata.target);
|
|
189
|
+
console.log(` ✓ Initialized: ${metadata.target.name}`);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
155
192
|
}
|
|
156
193
|
getTypeIcon(type) {
|
|
157
194
|
const icons = {
|
|
@@ -166,20 +203,25 @@ class FragmentWebApplication {
|
|
|
166
203
|
shouldRegister(target) {
|
|
167
204
|
const conditionalClass = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.CONDITIONAL_ON_CLASS, target);
|
|
168
205
|
if (conditionalClass && !this.isClassAvailable(conditionalClass)) {
|
|
206
|
+
console.log(` 🚫 Conditional check failed for ${target.name}: Class not available`);
|
|
169
207
|
return false;
|
|
170
208
|
}
|
|
171
209
|
const conditionalMissingBean = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.CONDITIONAL_ON_MISSING_BEAN, target);
|
|
172
210
|
if (conditionalMissingBean && this.container.has(conditionalMissingBean)) {
|
|
211
|
+
console.log(` 🚫 Conditional check failed for ${target.name}: Bean already exists`);
|
|
173
212
|
return false;
|
|
174
213
|
}
|
|
175
214
|
const conditionalProperty = Reflect.getMetadata(metadata_keys_1.METADATA_KEYS.CONDITIONAL_ON_PROPERTY, target);
|
|
176
215
|
if (conditionalProperty) {
|
|
177
216
|
const value = process.env[conditionalProperty.key];
|
|
178
|
-
if (conditionalProperty.expectedValue !== undefined
|
|
179
|
-
value !== conditionalProperty.expectedValue) {
|
|
180
|
-
|
|
217
|
+
if (conditionalProperty.expectedValue !== undefined) {
|
|
218
|
+
if (value !== conditionalProperty.expectedValue) {
|
|
219
|
+
console.log(` 🚫 Conditional check failed for ${target.name}: Expected ${conditionalProperty.expectedValue}, got ${value}`);
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
181
222
|
}
|
|
182
|
-
if (!value) {
|
|
223
|
+
else if (!value) {
|
|
224
|
+
console.log(` 🚫 Conditional check failed for ${target.name}: Property not set`);
|
|
183
225
|
return false;
|
|
184
226
|
}
|
|
185
227
|
}
|
|
@@ -198,44 +240,53 @@ class FragmentWebApplication {
|
|
|
198
240
|
.getAllClasses()
|
|
199
241
|
.filter((c) => c.type === "controller");
|
|
200
242
|
if (controllers.length === 0) {
|
|
201
|
-
console.log("🛣️
|
|
243
|
+
console.log("\n🛣️ No routes to register");
|
|
202
244
|
return;
|
|
203
245
|
}
|
|
204
246
|
let totalRoutes = 0;
|
|
205
|
-
console.log(
|
|
247
|
+
console.log(`\n🛣️ Registering routes...`);
|
|
206
248
|
controllers.forEach((controllerMetadata) => {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
249
|
+
try {
|
|
250
|
+
console.log(`\n📍 Controller: ${controllerMetadata.target.name}`);
|
|
251
|
+
console.log(` Base path: ${controllerMetadata.path || "/"}`);
|
|
252
|
+
const controller = this.container.resolve(controllerMetadata.target);
|
|
253
|
+
const basePath = controllerMetadata.path || "";
|
|
254
|
+
const methods = this.metadataStorage
|
|
255
|
+
.getAllMethods()
|
|
256
|
+
.filter((m) => m.target === controllerMetadata.target);
|
|
257
|
+
if (methods.length === 0) {
|
|
258
|
+
console.log(` ⚠️ No routes defined for this controller`);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
215
261
|
methods.forEach((methodMetadata) => {
|
|
216
262
|
const fullPath = this.normalizePath(basePath + methodMetadata.path);
|
|
217
263
|
const httpMethod = methodMetadata.method.toLowerCase();
|
|
218
264
|
const methodColor = this.getMethodColor(httpMethod);
|
|
219
265
|
const methodIcon = this.getMethodIcon(httpMethod);
|
|
220
|
-
console.log(`
|
|
266
|
+
console.log(` ${methodIcon} ${methodColor}${httpMethod.toUpperCase().padEnd(7)}\x1b[0m ${fullPath}`);
|
|
221
267
|
totalRoutes++;
|
|
222
268
|
this.app[httpMethod](fullPath, async (req, res, next) => {
|
|
223
269
|
try {
|
|
224
270
|
const args = this.resolveMethodParameters(methodMetadata, req, res);
|
|
271
|
+
console.log(`\n🔍 Handling ${httpMethod.toUpperCase()} ${fullPath}`);
|
|
272
|
+
// console.log(` Parameters:`, args);
|
|
225
273
|
const result = await controller[methodMetadata.propertyKey](...args);
|
|
226
274
|
if (!res.headersSent) {
|
|
227
275
|
res.json(result);
|
|
228
276
|
}
|
|
229
277
|
}
|
|
230
278
|
catch (error) {
|
|
279
|
+
console.error(`❌ Error handling route ${fullPath}:`, error);
|
|
231
280
|
next(error);
|
|
232
281
|
}
|
|
233
282
|
});
|
|
234
283
|
});
|
|
235
|
-
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
console.error(`❌ Failed to register controller ${controllerMetadata.target.name}:`, error);
|
|
236
287
|
}
|
|
237
288
|
});
|
|
238
|
-
console.log(
|
|
289
|
+
console.log(`\n✓ Registered ${totalRoutes} route(s)`);
|
|
239
290
|
}
|
|
240
291
|
getMethodColor(method) {
|
|
241
292
|
const colors = {
|
|
@@ -258,7 +309,7 @@ class FragmentWebApplication {
|
|
|
258
309
|
return icons[method] || "•";
|
|
259
310
|
}
|
|
260
311
|
resolveMethodParameters(methodMetadata, req, res) {
|
|
261
|
-
const params = methodMetadata.paramMetadata.sort((a, b) => a.index - b.index);
|
|
312
|
+
const params = [...methodMetadata.paramMetadata].sort((a, b) => a.index - b.index);
|
|
262
313
|
return params.map((param) => {
|
|
263
314
|
switch (param.type) {
|
|
264
315
|
case "body":
|
|
@@ -284,10 +335,11 @@ class FragmentWebApplication {
|
|
|
284
335
|
return "/" + path.split("/").filter(Boolean).join("/");
|
|
285
336
|
}
|
|
286
337
|
errorHandler(err, req, res, next) {
|
|
287
|
-
console.error(err
|
|
338
|
+
console.error(`\n❌ Global error handler:`, err);
|
|
288
339
|
res.status(500).json({
|
|
289
340
|
error: "Internal Server Error",
|
|
290
341
|
message: err.message,
|
|
342
|
+
timestamp: new Date().toISOString(),
|
|
291
343
|
});
|
|
292
344
|
}
|
|
293
345
|
getExpressApp() {
|