@trapi/metadata 1.0.0-alpha.7 → 1.0.0-alpha.8
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/cache/driver.d.ts +13 -13
- package/dist/cache/driver.js +83 -83
- package/dist/cache/index.d.ts +3 -3
- package/dist/cache/index.js +25 -25
- package/dist/cache/type.d.ts +32 -32
- package/dist/cache/type.js +8 -8
- package/dist/cache/utils.d.ts +3 -3
- package/dist/cache/utils.js +52 -52
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +23 -23
- package/dist/config/type.d.ts +36 -36
- package/dist/config/type.js +8 -8
- package/dist/decorator/constants.d.ts +40 -40
- package/dist/decorator/constants.js +52 -52
- package/dist/decorator/index.d.ts +6 -6
- package/dist/decorator/index.js +28 -28
- package/dist/decorator/preset/index.d.ts +2 -2
- package/dist/decorator/preset/index.js +24 -24
- package/dist/decorator/preset/type.d.ts +5 -5
- package/dist/decorator/preset/type.js +8 -8
- package/dist/decorator/preset/utils/check.d.ts +2 -2
- package/dist/decorator/preset/utils/check.js +17 -17
- package/dist/decorator/preset/utils/index.d.ts +3 -3
- package/dist/decorator/preset/utils/index.js +25 -25
- package/dist/decorator/preset/utils/load.d.ts +2 -2
- package/dist/decorator/preset/utils/load.js +44 -44
- package/dist/decorator/preset/utils/normalize.d.ts +1 -1
- package/dist/decorator/preset/utils/normalize.js +26 -26
- package/dist/decorator/property-manager/index.d.ts +2 -2
- package/dist/decorator/property-manager/index.js +24 -24
- package/dist/decorator/property-manager/module.d.ts +16 -16
- package/dist/decorator/property-manager/module.js +58 -58
- package/dist/decorator/property-manager/utils.d.ts +5 -5
- package/dist/decorator/property-manager/utils.js +91 -91
- package/dist/decorator/resolver/index.d.ts +2 -2
- package/dist/decorator/resolver/index.js +24 -24
- package/dist/decorator/resolver/module.d.ts +26 -26
- package/dist/decorator/resolver/module.js +71 -71
- package/dist/decorator/resolver/type.d.ts +9 -9
- package/dist/decorator/resolver/type.js +2 -2
- package/dist/decorator/sets/class.d.ts +6 -6
- package/dist/decorator/sets/class.js +8 -8
- package/dist/decorator/sets/index.d.ts +7 -7
- package/dist/decorator/sets/index.js +28 -28
- package/dist/decorator/sets/method.d.ts +13 -13
- package/dist/decorator/sets/method.js +8 -8
- package/dist/decorator/sets/mixed.d.ts +11 -11
- package/dist/decorator/sets/mixed.js +8 -8
- package/dist/decorator/sets/parameter.d.ts +20 -20
- package/dist/decorator/sets/parameter.js +8 -8
- package/dist/decorator/sets/request.d.ts +5 -5
- package/dist/decorator/sets/request.js +8 -8
- package/dist/decorator/sets/response.d.ts +16 -16
- package/dist/decorator/sets/response.js +8 -8
- package/dist/decorator/sets/type.d.ts +3 -3
- package/dist/decorator/sets/type.js +2 -2
- package/dist/decorator/type.d.ts +31 -31
- package/dist/decorator/type.js +8 -8
- package/dist/error/base.d.ts +2 -2
- package/dist/error/base.js +12 -12
- package/dist/error/index.d.ts +1 -1
- package/dist/error/index.js +23 -23
- package/dist/generator/abstract.d.ts +18 -18
- package/dist/generator/abstract.js +150 -150
- package/dist/generator/abstract.js.map +1 -1
- package/dist/generator/controller/index.d.ts +2 -2
- package/dist/generator/controller/index.js +24 -24
- package/dist/generator/controller/module.d.ts +12 -12
- package/dist/generator/controller/module.js +67 -67
- package/dist/generator/controller/type.d.ts +46 -46
- package/dist/generator/controller/type.js +2 -2
- package/dist/generator/index.d.ts +6 -6
- package/dist/generator/index.js +28 -28
- package/dist/generator/metadata/index.d.ts +3 -3
- package/dist/generator/metadata/index.js +25 -25
- package/dist/generator/metadata/module.d.ts +38 -38
- package/dist/generator/metadata/module.js +142 -142
- package/dist/generator/metadata/type.d.ts +24 -24
- package/dist/generator/metadata/type.js +2 -2
- package/dist/generator/metadata/utils.d.ts +2 -2
- package/dist/generator/metadata/utils.js +18 -18
- package/dist/generator/method/constants.d.ts +10 -10
- package/dist/generator/method/constants.js +20 -20
- package/dist/generator/method/index.d.ts +3 -3
- package/dist/generator/method/index.js +25 -25
- package/dist/generator/method/module.d.ts +18 -18
- package/dist/generator/method/module.js +187 -187
- package/dist/generator/method/type.d.ts +22 -22
- package/dist/generator/method/type.js +8 -8
- package/dist/generator/parameter/constants.d.ts +18 -18
- package/dist/generator/parameter/constants.js +29 -29
- package/dist/generator/parameter/error.d.ts +34 -34
- package/dist/generator/parameter/error.js +67 -67
- package/dist/generator/parameter/index.d.ts +4 -4
- package/dist/generator/parameter/index.js +26 -26
- package/dist/generator/parameter/module.d.ts +28 -28
- package/dist/generator/parameter/module.js +555 -555
- package/dist/generator/parameter/type.d.ts +24 -24
- package/dist/generator/parameter/type.js +8 -8
- package/dist/generator/type.d.ts +19 -19
- package/dist/generator/type.js +8 -8
- package/dist/index.d.ts +9 -9
- package/dist/index.js +31 -31
- package/dist/module.d.ts +4 -4
- package/dist/module.js +40 -40
- package/dist/resolver/constants.d.ts +26 -26
- package/dist/resolver/constants.js +36 -36
- package/dist/resolver/error.d.ts +7 -7
- package/dist/resolver/error.js +40 -40
- package/dist/resolver/extension/index.d.ts +2 -2
- package/dist/resolver/extension/index.js +24 -24
- package/dist/resolver/extension/module.d.ts +4 -4
- package/dist/resolver/extension/module.js +26 -26
- package/dist/resolver/extension/type.d.ts +7 -7
- package/dist/resolver/extension/type.js +8 -8
- package/dist/resolver/index.d.ts +5 -5
- package/dist/resolver/index.js +27 -27
- package/dist/resolver/module.d.ts +53 -53
- package/dist/resolver/module.js +1102 -1102
- package/dist/resolver/type.d.ts +138 -138
- package/dist/resolver/type.js +129 -129
- package/dist/type.d.ts +1 -1
- package/dist/type.js +8 -8
- package/dist/utils/array.d.ts +2 -0
- package/dist/utils/array.d.ts.map +1 -0
- package/dist/utils/array.js +22 -0
- package/dist/utils/array.js.map +1 -0
- package/dist/utils/index.d.ts +9 -8
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +31 -30
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/initializer.d.ts +4 -4
- package/dist/utils/initializer.js +130 -130
- package/dist/utils/js-doc/constants.d.ts +18 -18
- package/dist/utils/js-doc/constants.js +29 -29
- package/dist/utils/js-doc/index.d.ts +3 -3
- package/dist/utils/js-doc/index.js +25 -25
- package/dist/utils/js-doc/module.d.ts +8 -8
- package/dist/utils/js-doc/module.js +97 -97
- package/dist/utils/js-doc/utils.d.ts +2 -2
- package/dist/utils/js-doc/utils.js +28 -28
- package/dist/utils/node/index.d.ts +2 -2
- package/dist/utils/node/index.js +24 -24
- package/dist/utils/node/module.d.ts +9 -9
- package/dist/utils/node/module.js +51 -51
- package/dist/utils/node/type.d.ts +5 -5
- package/dist/utils/node/type.js +8 -8
- package/dist/utils/object.d.ts +1 -1
- package/dist/utils/object.js +14 -14
- package/dist/utils/path-normalize.d.ts +1 -1
- package/dist/utils/path-normalize.js +16 -16
- package/dist/utils/source-files.d.ts +2 -2
- package/dist/utils/source-files.js +31 -31
- package/dist/utils/tsconfig/index.d.ts +2 -2
- package/dist/utils/tsconfig/index.js +24 -24
- package/dist/utils/tsconfig/module.d.ts +3 -3
- package/dist/utils/tsconfig/module.js +53 -53
- package/dist/utils/tsconfig/type.d.ts +10 -10
- package/dist/utils/tsconfig/type.js +8 -8
- package/dist/utils/validator/constants.d.ts +12 -12
- package/dist/utils/validator/constants.js +22 -22
- package/dist/utils/validator/index.d.ts +3 -3
- package/dist/utils/validator/index.js +25 -25
- package/dist/utils/validator/module.d.ts +3 -3
- package/dist/utils/validator/module.js +141 -141
- package/dist/utils/validator/type.d.ts +5 -5
- package/dist/utils/validator/type.js +8 -8
- package/package.json +5 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './abstract';
|
|
2
|
-
export * from './controller';
|
|
3
|
-
export * from './method';
|
|
4
|
-
export * from './metadata';
|
|
5
|
-
export * from './parameter';
|
|
6
|
-
export * from './type';
|
|
1
|
+
export * from './abstract';
|
|
2
|
+
export * from './controller';
|
|
3
|
+
export * from './method';
|
|
4
|
+
export * from './metadata';
|
|
5
|
+
export * from './parameter';
|
|
6
|
+
export * from './type';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/generator/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2021.
|
|
4
|
-
* Author Peter Placzek (tada5hi)
|
|
5
|
-
* For the full copyright and license information,
|
|
6
|
-
* view the LICENSE file that was distributed with this source code.
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
__exportStar(require("./abstract"), exports);
|
|
24
|
-
__exportStar(require("./controller"), exports);
|
|
25
|
-
__exportStar(require("./method"), exports);
|
|
26
|
-
__exportStar(require("./metadata"), exports);
|
|
27
|
-
__exportStar(require("./parameter"), exports);
|
|
28
|
-
__exportStar(require("./type"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./abstract"), exports);
|
|
24
|
+
__exportStar(require("./controller"), exports);
|
|
25
|
+
__exportStar(require("./method"), exports);
|
|
26
|
+
__exportStar(require("./metadata"), exports);
|
|
27
|
+
__exportStar(require("./parameter"), exports);
|
|
28
|
+
__exportStar(require("./type"), exports);
|
|
29
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './module';
|
|
2
|
-
export * from './type';
|
|
3
|
-
export * from './utils';
|
|
1
|
+
export * from './module';
|
|
2
|
+
export * from './type';
|
|
3
|
+
export * from './utils';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023.
|
|
4
|
-
* Author Peter Placzek (tada5hi)
|
|
5
|
-
* For the full copyright and license information,
|
|
6
|
-
* view the LICENSE file that was distributed with this source code.
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
__exportStar(require("./module"), exports);
|
|
24
|
-
__exportStar(require("./type"), exports);
|
|
25
|
-
__exportStar(require("./utils"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./module"), exports);
|
|
24
|
+
__exportStar(require("./type"), exports);
|
|
25
|
+
__exportStar(require("./utils"), exports);
|
|
26
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import type { Node, TypeChecker } from 'typescript';
|
|
2
|
-
import type { Options } from '../../config';
|
|
3
|
-
import { DecoratorResolver } from '../../decorator';
|
|
4
|
-
import type { DependencyResolver, ReferenceType } from '../../resolver';
|
|
5
|
-
import type { Metadata, MetadataGeneratorContext } from './type';
|
|
6
|
-
export declare class MetadataGenerator {
|
|
7
|
-
readonly nodes: Node[];
|
|
8
|
-
readonly typeChecker: TypeChecker;
|
|
9
|
-
readonly decoratorResolver: DecoratorResolver;
|
|
10
|
-
readonly config: Options;
|
|
11
|
-
private readonly program;
|
|
12
|
-
private cache;
|
|
13
|
-
private controllers;
|
|
14
|
-
private referenceTypes;
|
|
15
|
-
private circularDependencyResolvers;
|
|
16
|
-
constructor(context: MetadataGeneratorContext);
|
|
17
|
-
generate(): Promise<Metadata>;
|
|
18
|
-
protected buildNodesFromSourceFiles(): number;
|
|
19
|
-
/**
|
|
20
|
-
* Check if the source file path is in the ignored path list.
|
|
21
|
-
*
|
|
22
|
-
* @param filePath
|
|
23
|
-
* @protected
|
|
24
|
-
*/
|
|
25
|
-
protected isIgnoredPath(filePath: string): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Check if the source file path is in the ignored path list.
|
|
28
|
-
*
|
|
29
|
-
* @param filePath
|
|
30
|
-
* @protected
|
|
31
|
-
*/
|
|
32
|
-
protected isAllowedPath(filePath: string): boolean;
|
|
33
|
-
isExportedNode(node: Node): boolean;
|
|
34
|
-
addReferenceType(referenceType: ReferenceType): void;
|
|
35
|
-
getReferenceType(refName: string): ReferenceType;
|
|
36
|
-
registerDependencyResolver(callback: DependencyResolver): void;
|
|
37
|
-
private buildControllers;
|
|
38
|
-
}
|
|
1
|
+
import type { Node, TypeChecker } from 'typescript';
|
|
2
|
+
import type { Options } from '../../config';
|
|
3
|
+
import { DecoratorResolver } from '../../decorator';
|
|
4
|
+
import type { DependencyResolver, ReferenceType } from '../../resolver';
|
|
5
|
+
import type { Metadata, MetadataGeneratorContext } from './type';
|
|
6
|
+
export declare class MetadataGenerator {
|
|
7
|
+
readonly nodes: Node[];
|
|
8
|
+
readonly typeChecker: TypeChecker;
|
|
9
|
+
readonly decoratorResolver: DecoratorResolver;
|
|
10
|
+
readonly config: Options;
|
|
11
|
+
private readonly program;
|
|
12
|
+
private cache;
|
|
13
|
+
private controllers;
|
|
14
|
+
private referenceTypes;
|
|
15
|
+
private circularDependencyResolvers;
|
|
16
|
+
constructor(context: MetadataGeneratorContext);
|
|
17
|
+
generate(): Promise<Metadata>;
|
|
18
|
+
protected buildNodesFromSourceFiles(): number;
|
|
19
|
+
/**
|
|
20
|
+
* Check if the source file path is in the ignored path list.
|
|
21
|
+
*
|
|
22
|
+
* @param filePath
|
|
23
|
+
* @protected
|
|
24
|
+
*/
|
|
25
|
+
protected isIgnoredPath(filePath: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Check if the source file path is in the ignored path list.
|
|
28
|
+
*
|
|
29
|
+
* @param filePath
|
|
30
|
+
* @protected
|
|
31
|
+
*/
|
|
32
|
+
protected isAllowedPath(filePath: string): boolean;
|
|
33
|
+
isExportedNode(node: Node): boolean;
|
|
34
|
+
addReferenceType(referenceType: ReferenceType): void;
|
|
35
|
+
getReferenceType(refName: string): ReferenceType;
|
|
36
|
+
registerDependencyResolver(callback: DependencyResolver): void;
|
|
37
|
+
private buildControllers;
|
|
38
|
+
}
|
|
39
39
|
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2022-2023.
|
|
4
|
-
* Author Peter Placzek (tada5hi)
|
|
5
|
-
* For the full copyright and license information,
|
|
6
|
-
* view the LICENSE file that was distributed with this source code.
|
|
7
|
-
*/
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MetadataGenerator = void 0;
|
|
13
|
-
const minimatch_1 = __importDefault(require("minimatch"));
|
|
14
|
-
const typescript_1 = require("typescript");
|
|
15
|
-
const cache_1 = require("../../cache");
|
|
16
|
-
const decorator_1 = require("../../decorator");
|
|
17
|
-
const resolver_1 = require("../../resolver");
|
|
18
|
-
const controller_1 = require("../controller");
|
|
19
|
-
class MetadataGenerator {
|
|
20
|
-
// -------------------------------------------------------------------------
|
|
21
|
-
constructor(context) {
|
|
22
|
-
this.referenceTypes = {};
|
|
23
|
-
this.circularDependencyResolvers = new Array();
|
|
24
|
-
this.nodes = [];
|
|
25
|
-
this.config = context.options;
|
|
26
|
-
this.cache = new cache_1.CacheDriver(context.options.cache);
|
|
27
|
-
this.decoratorResolver = new decorator_1.DecoratorResolver();
|
|
28
|
-
this.program = (0, typescript_1.createProgram)(context.sourceFiles, context.compilerOptions || {});
|
|
29
|
-
this.typeChecker = this.program.getTypeChecker();
|
|
30
|
-
resolver_1.TypeNodeResolver.clearCache();
|
|
31
|
-
}
|
|
32
|
-
// -------------------------------------------------------------------------
|
|
33
|
-
async generate() {
|
|
34
|
-
const sourceFileSize = this.buildNodesFromSourceFiles();
|
|
35
|
-
let cache = await this.cache.get(sourceFileSize);
|
|
36
|
-
if (!cache) {
|
|
37
|
-
if (this.config.decorators) {
|
|
38
|
-
this.decoratorResolver.apply(this.config.decorators);
|
|
39
|
-
}
|
|
40
|
-
if (this.config.preset) {
|
|
41
|
-
await this.decoratorResolver.applyPreset(this.config.preset);
|
|
42
|
-
}
|
|
43
|
-
this.buildControllers();
|
|
44
|
-
this.circularDependencyResolvers.forEach((resolve) => resolve(this.referenceTypes));
|
|
45
|
-
cache = {
|
|
46
|
-
controllers: this.controllers,
|
|
47
|
-
referenceTypes: this.referenceTypes,
|
|
48
|
-
sourceFilesSize: sourceFileSize,
|
|
49
|
-
};
|
|
50
|
-
await this.cache.save(cache);
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
controllers: cache.controllers,
|
|
54
|
-
referenceTypes: cache.referenceTypes,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
buildNodesFromSourceFiles() {
|
|
58
|
-
let endSize = 0;
|
|
59
|
-
this.program.getSourceFiles().forEach((sf) => {
|
|
60
|
-
if (this.isIgnoredPath(sf.fileName) &&
|
|
61
|
-
!this.isAllowedPath(sf.fileName)) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
endSize += sf.end;
|
|
65
|
-
(0, typescript_1.forEachChild)(sf, (node) => {
|
|
66
|
-
if ((0, typescript_1.isModuleDeclaration)(node)) {
|
|
67
|
-
/**
|
|
68
|
-
* For some reason unknown to me, TS resolves both `declare module` and `namespace` to
|
|
69
|
-
* the same kind (`ModuleDeclaration`). In order to figure out whether it's one or the other,
|
|
70
|
-
* we check the node flags. They tell us whether it is a namespace or not.
|
|
71
|
-
*/
|
|
72
|
-
// tslint:disable-next-line:no-bitwise
|
|
73
|
-
if ((node.flags & typescript_1.NodeFlags.Namespace) === 0 && node.body && (0, typescript_1.isModuleBlock)(node.body)) {
|
|
74
|
-
node.body.statements.forEach((statement) => {
|
|
75
|
-
this.nodes.push(statement);
|
|
76
|
-
});
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
this.nodes.push(node);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
return endSize;
|
|
84
|
-
}
|
|
85
|
-
// -------------------------------------------------------------------------
|
|
86
|
-
/**
|
|
87
|
-
* Check if the source file path is in the ignored path list.
|
|
88
|
-
*
|
|
89
|
-
* @param filePath
|
|
90
|
-
* @protected
|
|
91
|
-
*/
|
|
92
|
-
isIgnoredPath(filePath) {
|
|
93
|
-
if (typeof this.config.ignore === 'undefined') {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
return this.config.ignore.some((item) => (0, minimatch_1.default)(filePath, item));
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Check if the source file path is in the ignored path list.
|
|
100
|
-
*
|
|
101
|
-
* @param filePath
|
|
102
|
-
* @protected
|
|
103
|
-
*/
|
|
104
|
-
isAllowedPath(filePath) {
|
|
105
|
-
if (typeof this.config.allow === 'undefined') {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
return this.config.allow.some((item) => (0, minimatch_1.default)(filePath, item));
|
|
109
|
-
}
|
|
110
|
-
// -------------------------------------------------------------------------
|
|
111
|
-
isExportedNode(node) {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
// -------------------------------------------------------------------------
|
|
115
|
-
addReferenceType(referenceType) {
|
|
116
|
-
if (!referenceType.refName) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
this.referenceTypes[referenceType.refName] = referenceType;
|
|
120
|
-
}
|
|
121
|
-
getReferenceType(refName) {
|
|
122
|
-
return this.referenceTypes[refName];
|
|
123
|
-
}
|
|
124
|
-
registerDependencyResolver(callback) {
|
|
125
|
-
this.circularDependencyResolvers.push(callback);
|
|
126
|
-
}
|
|
127
|
-
buildControllers() {
|
|
128
|
-
this.controllers = [];
|
|
129
|
-
for (let i = 0; i < this.nodes.length; i++) {
|
|
130
|
-
const node = this.nodes[i];
|
|
131
|
-
if (!(0, typescript_1.isClassDeclaration)(node)) {
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
const generator = new controller_1.ControllerGenerator(node, this);
|
|
135
|
-
if (!generator.isValid()) {
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
this.controllers.push(generator.generate());
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
exports.MetadataGenerator = MetadataGenerator;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022-2023.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MetadataGenerator = void 0;
|
|
13
|
+
const minimatch_1 = __importDefault(require("minimatch"));
|
|
14
|
+
const typescript_1 = require("typescript");
|
|
15
|
+
const cache_1 = require("../../cache");
|
|
16
|
+
const decorator_1 = require("../../decorator");
|
|
17
|
+
const resolver_1 = require("../../resolver");
|
|
18
|
+
const controller_1 = require("../controller");
|
|
19
|
+
class MetadataGenerator {
|
|
20
|
+
// -------------------------------------------------------------------------
|
|
21
|
+
constructor(context) {
|
|
22
|
+
this.referenceTypes = {};
|
|
23
|
+
this.circularDependencyResolvers = new Array();
|
|
24
|
+
this.nodes = [];
|
|
25
|
+
this.config = context.options;
|
|
26
|
+
this.cache = new cache_1.CacheDriver(context.options.cache);
|
|
27
|
+
this.decoratorResolver = new decorator_1.DecoratorResolver();
|
|
28
|
+
this.program = (0, typescript_1.createProgram)(context.sourceFiles, context.compilerOptions || {});
|
|
29
|
+
this.typeChecker = this.program.getTypeChecker();
|
|
30
|
+
resolver_1.TypeNodeResolver.clearCache();
|
|
31
|
+
}
|
|
32
|
+
// -------------------------------------------------------------------------
|
|
33
|
+
async generate() {
|
|
34
|
+
const sourceFileSize = this.buildNodesFromSourceFiles();
|
|
35
|
+
let cache = await this.cache.get(sourceFileSize);
|
|
36
|
+
if (!cache) {
|
|
37
|
+
if (this.config.decorators) {
|
|
38
|
+
this.decoratorResolver.apply(this.config.decorators);
|
|
39
|
+
}
|
|
40
|
+
if (this.config.preset) {
|
|
41
|
+
await this.decoratorResolver.applyPreset(this.config.preset);
|
|
42
|
+
}
|
|
43
|
+
this.buildControllers();
|
|
44
|
+
this.circularDependencyResolvers.forEach((resolve) => resolve(this.referenceTypes));
|
|
45
|
+
cache = {
|
|
46
|
+
controllers: this.controllers,
|
|
47
|
+
referenceTypes: this.referenceTypes,
|
|
48
|
+
sourceFilesSize: sourceFileSize,
|
|
49
|
+
};
|
|
50
|
+
await this.cache.save(cache);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
controllers: cache.controllers,
|
|
54
|
+
referenceTypes: cache.referenceTypes,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
buildNodesFromSourceFiles() {
|
|
58
|
+
let endSize = 0;
|
|
59
|
+
this.program.getSourceFiles().forEach((sf) => {
|
|
60
|
+
if (this.isIgnoredPath(sf.fileName) &&
|
|
61
|
+
!this.isAllowedPath(sf.fileName)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
endSize += sf.end;
|
|
65
|
+
(0, typescript_1.forEachChild)(sf, (node) => {
|
|
66
|
+
if ((0, typescript_1.isModuleDeclaration)(node)) {
|
|
67
|
+
/**
|
|
68
|
+
* For some reason unknown to me, TS resolves both `declare module` and `namespace` to
|
|
69
|
+
* the same kind (`ModuleDeclaration`). In order to figure out whether it's one or the other,
|
|
70
|
+
* we check the node flags. They tell us whether it is a namespace or not.
|
|
71
|
+
*/
|
|
72
|
+
// tslint:disable-next-line:no-bitwise
|
|
73
|
+
if ((node.flags & typescript_1.NodeFlags.Namespace) === 0 && node.body && (0, typescript_1.isModuleBlock)(node.body)) {
|
|
74
|
+
node.body.statements.forEach((statement) => {
|
|
75
|
+
this.nodes.push(statement);
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
this.nodes.push(node);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
return endSize;
|
|
84
|
+
}
|
|
85
|
+
// -------------------------------------------------------------------------
|
|
86
|
+
/**
|
|
87
|
+
* Check if the source file path is in the ignored path list.
|
|
88
|
+
*
|
|
89
|
+
* @param filePath
|
|
90
|
+
* @protected
|
|
91
|
+
*/
|
|
92
|
+
isIgnoredPath(filePath) {
|
|
93
|
+
if (typeof this.config.ignore === 'undefined') {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return this.config.ignore.some((item) => (0, minimatch_1.default)(filePath, item));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check if the source file path is in the ignored path list.
|
|
100
|
+
*
|
|
101
|
+
* @param filePath
|
|
102
|
+
* @protected
|
|
103
|
+
*/
|
|
104
|
+
isAllowedPath(filePath) {
|
|
105
|
+
if (typeof this.config.allow === 'undefined') {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return this.config.allow.some((item) => (0, minimatch_1.default)(filePath, item));
|
|
109
|
+
}
|
|
110
|
+
// -------------------------------------------------------------------------
|
|
111
|
+
isExportedNode(node) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
// -------------------------------------------------------------------------
|
|
115
|
+
addReferenceType(referenceType) {
|
|
116
|
+
if (!referenceType.refName) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.referenceTypes[referenceType.refName] = referenceType;
|
|
120
|
+
}
|
|
121
|
+
getReferenceType(refName) {
|
|
122
|
+
return this.referenceTypes[refName];
|
|
123
|
+
}
|
|
124
|
+
registerDependencyResolver(callback) {
|
|
125
|
+
this.circularDependencyResolvers.push(callback);
|
|
126
|
+
}
|
|
127
|
+
buildControllers() {
|
|
128
|
+
this.controllers = [];
|
|
129
|
+
for (let i = 0; i < this.nodes.length; i++) {
|
|
130
|
+
const node = this.nodes[i];
|
|
131
|
+
if (!(0, typescript_1.isClassDeclaration)(node)) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const generator = new controller_1.ControllerGenerator(node, this);
|
|
135
|
+
if (!generator.isValid()) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
this.controllers.push(generator.generate());
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.MetadataGenerator = MetadataGenerator;
|
|
143
143
|
//# sourceMappingURL=module.js.map
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type { CompilerOptions } from 'typescript';
|
|
2
|
-
import type { Options } from '../../config';
|
|
3
|
-
import type { ReferenceTypes } from '../../resolver';
|
|
4
|
-
import type { Controller } from '../controller';
|
|
5
|
-
export type MetadataGeneratorContext = {
|
|
6
|
-
options: Options;
|
|
7
|
-
sourceFiles: string[];
|
|
8
|
-
compilerOptions?: CompilerOptions;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* The output specification for metadata generation.
|
|
12
|
-
*/
|
|
13
|
-
export interface Metadata {
|
|
14
|
-
/**
|
|
15
|
-
* A Controller is a collection of grouped methods (GET, POST, ...)
|
|
16
|
-
* for a common URL path (i.e /users) or an more explicit URL path (i.e. /users/:id).
|
|
17
|
-
*/
|
|
18
|
-
controllers: Controller[];
|
|
19
|
-
/**
|
|
20
|
-
* ReferenceTypes is an object of found types (interfaces, type, ...),
|
|
21
|
-
* and classes which were detected during code analysis.
|
|
22
|
-
*/
|
|
23
|
-
referenceTypes: ReferenceTypes;
|
|
24
|
-
}
|
|
1
|
+
import type { CompilerOptions } from 'typescript';
|
|
2
|
+
import type { Options } from '../../config';
|
|
3
|
+
import type { ReferenceTypes } from '../../resolver';
|
|
4
|
+
import type { Controller } from '../controller';
|
|
5
|
+
export type MetadataGeneratorContext = {
|
|
6
|
+
options: Options;
|
|
7
|
+
sourceFiles: string[];
|
|
8
|
+
compilerOptions?: CompilerOptions;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The output specification for metadata generation.
|
|
12
|
+
*/
|
|
13
|
+
export interface Metadata {
|
|
14
|
+
/**
|
|
15
|
+
* A Controller is a collection of grouped methods (GET, POST, ...)
|
|
16
|
+
* for a common URL path (i.e /users) or an more explicit URL path (i.e. /users/:id).
|
|
17
|
+
*/
|
|
18
|
+
controllers: Controller[];
|
|
19
|
+
/**
|
|
20
|
+
* ReferenceTypes is an object of found types (interfaces, type, ...),
|
|
21
|
+
* and classes which were detected during code analysis.
|
|
22
|
+
*/
|
|
23
|
+
referenceTypes: ReferenceTypes;
|
|
24
|
+
}
|
|
25
25
|
//# sourceMappingURL=type.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=type.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Metadata } from './type';
|
|
2
|
-
export declare function isMetadata(input: unknown): input is Metadata;
|
|
1
|
+
import type { Metadata } from './type';
|
|
2
|
+
export declare function isMetadata(input: unknown): input is Metadata;
|
|
3
3
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023.
|
|
4
|
-
* Author Peter Placzek (tada5hi)
|
|
5
|
-
* For the full copyright and license information,
|
|
6
|
-
* view the LICENSE file that was distributed with this source code.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.isMetadata = void 0;
|
|
10
|
-
const locter_1 = require("locter");
|
|
11
|
-
function isMetadata(input) {
|
|
12
|
-
return (0, locter_1.isObject)(input) &&
|
|
13
|
-
(0, locter_1.hasOwnProperty)(input, 'controllers') &&
|
|
14
|
-
Array.isArray(input.controllers) &&
|
|
15
|
-
(0, locter_1.hasOwnProperty)(input, 'referenceTypes') &&
|
|
16
|
-
(0, locter_1.isObject)(input.referenceTypes);
|
|
17
|
-
}
|
|
18
|
-
exports.isMetadata = isMetadata;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.isMetadata = void 0;
|
|
10
|
+
const locter_1 = require("locter");
|
|
11
|
+
function isMetadata(input) {
|
|
12
|
+
return (0, locter_1.isObject)(input) &&
|
|
13
|
+
(0, locter_1.hasOwnProperty)(input, 'controllers') &&
|
|
14
|
+
Array.isArray(input.controllers) &&
|
|
15
|
+
(0, locter_1.hasOwnProperty)(input, 'referenceTypes') &&
|
|
16
|
+
(0, locter_1.isObject)(input.referenceTypes);
|
|
17
|
+
}
|
|
18
|
+
exports.isMetadata = isMetadata;
|
|
19
19
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export declare enum MethodName {
|
|
2
|
-
ALL = "ALL",
|
|
3
|
-
GET = "GET",
|
|
4
|
-
POST = "POST",
|
|
5
|
-
PUT = "PUT",
|
|
6
|
-
DELETE = "DELETE",
|
|
7
|
-
PATCH = "PATCH",
|
|
8
|
-
OPTIONS = "OPTIONS",
|
|
9
|
-
HEAD = "HEAD"
|
|
10
|
-
}
|
|
1
|
+
export declare enum MethodName {
|
|
2
|
+
ALL = "ALL",
|
|
3
|
+
GET = "GET",
|
|
4
|
+
POST = "POST",
|
|
5
|
+
PUT = "PUT",
|
|
6
|
+
DELETE = "DELETE",
|
|
7
|
+
PATCH = "PATCH",
|
|
8
|
+
OPTIONS = "OPTIONS",
|
|
9
|
+
HEAD = "HEAD"
|
|
10
|
+
}
|
|
11
11
|
//# sourceMappingURL=constants.d.ts.map
|