@rxap/ts-morph 0.1.0-dev.0
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/CHANGELOG.md +21 -0
- package/GETSTARTED.md +0 -0
- package/GUIDES.md +0 -0
- package/LICENSE.md +621 -0
- package/README.md +21 -0
- package/package.json +47 -0
- package/src/index.d.ts +41 -0
- package/src/index.js +49 -0
- package/src/index.js.map +1 -0
- package/src/lib/coerce-class-constructor.d.ts +2 -0
- package/src/lib/coerce-class-constructor.js +14 -0
- package/src/lib/coerce-class-constructor.js.map +1 -0
- package/src/lib/coerce-class-method.d.ts +2 -0
- package/src/lib/coerce-class-method.js +13 -0
- package/src/lib/coerce-class-method.js.map +1 -0
- package/src/lib/coerce-class.d.ts +2 -0
- package/src/lib/coerce-class.js +12 -0
- package/src/lib/coerce-class.js.map +1 -0
- package/src/lib/coerce-decorator.d.ts +5 -0
- package/src/lib/coerce-decorator.js +14 -0
- package/src/lib/coerce-decorator.js.map +1 -0
- package/src/lib/coerce-dependency-injection.d.ts +14 -0
- package/src/lib/coerce-dependency-injection.js +57 -0
- package/src/lib/coerce-dependency-injection.js.map +1 -0
- package/src/lib/coerce-imports.d.ts +21 -0
- package/src/lib/coerce-imports.js +235 -0
- package/src/lib/coerce-imports.js.map +1 -0
- package/src/lib/coerce-source-file.d.ts +2 -0
- package/src/lib/coerce-source-file.js +12 -0
- package/src/lib/coerce-source-file.js.map +1 -0
- package/src/lib/coerce-statements.d.ts +2 -0
- package/src/lib/coerce-statements.js +11 -0
- package/src/lib/coerce-statements.js.map +1 -0
- package/src/lib/coerce-variable-declaration.d.ts +2 -0
- package/src/lib/coerce-variable-declaration.js +25 -0
- package/src/lib/coerce-variable-declaration.js.map +1 -0
- package/src/lib/find-function.d.ts +7 -0
- package/src/lib/find-function.js +8 -0
- package/src/lib/find-function.js.map +1 -0
- package/src/lib/get-class-decorator-arguments.d.ts +3 -0
- package/src/lib/get-class-decorator-arguments.js +16 -0
- package/src/lib/get-class-decorator-arguments.js.map +1 -0
- package/src/lib/get-class.d.ts +3 -0
- package/src/lib/get-class.js +26 -0
- package/src/lib/get-class.js.map +1 -0
- package/src/lib/get-coerce-array-literal-form-object-literal.d.ts +2 -0
- package/src/lib/get-coerce-array-literal-form-object-literal.js +26 -0
- package/src/lib/get-coerce-array-literal-form-object-literal.js.map +1 -0
- package/src/lib/nest/add-health-endpoint.d.ts +2 -0
- package/src/lib/nest/add-health-endpoint.js +57 -0
- package/src/lib/nest/add-health-endpoint.js.map +1 -0
- package/src/lib/nest/add-health-indicator.d.ts +2 -0
- package/src/lib/nest/add-health-indicator.js +48 -0
- package/src/lib/nest/add-health-indicator.js.map +1 -0
- package/src/lib/nest/add-to-global-health-endpoint.d.ts +2 -0
- package/src/lib/nest/add-to-global-health-endpoint.js +53 -0
- package/src/lib/nest/add-to-global-health-endpoint.js.map +1 -0
- package/src/lib/nest/coerce-app-guard-provider.d.ts +2 -0
- package/src/lib/nest/coerce-app-guard-provider.js +24 -0
- package/src/lib/nest/coerce-app-guard-provider.js.map +1 -0
- package/src/lib/nest/coerce-health-controller.d.ts +2 -0
- package/src/lib/nest/coerce-health-controller.js +23 -0
- package/src/lib/nest/coerce-health-controller.js.map +1 -0
- package/src/lib/nest/coerce-health-module.d.ts +2 -0
- package/src/lib/nest/coerce-health-module.js +36 -0
- package/src/lib/nest/coerce-health-module.js.map +1 -0
- package/src/lib/nest/coerce-nest-app-config.d.ts +11 -0
- package/src/lib/nest/coerce-nest-app-config.js +77 -0
- package/src/lib/nest/coerce-nest-app-config.js.map +1 -0
- package/src/lib/nest/coerce-nest-app-controller.d.ts +5 -0
- package/src/lib/nest/coerce-nest-app-controller.js +49 -0
- package/src/lib/nest/coerce-nest-app-controller.js.map +1 -0
- package/src/lib/nest/coerce-nest-app-module.d.ts +5 -0
- package/src/lib/nest/coerce-nest-app-module.js +13 -0
- package/src/lib/nest/coerce-nest-app-module.js.map +1 -0
- package/src/lib/nest/coerce-nest-config-module-import.d.ts +4 -0
- package/src/lib/nest/coerce-nest-config-module-import.js +26 -0
- package/src/lib/nest/coerce-nest-config-module-import.js.map +1 -0
- package/src/lib/nest/coerce-nest-controller.d.ts +6 -0
- package/src/lib/nest/coerce-nest-controller.js +26 -0
- package/src/lib/nest/coerce-nest-controller.js.map +1 -0
- package/src/lib/nest/coerce-nest-environment-provider.d.ts +2 -0
- package/src/lib/nest/coerce-nest-environment-provider.js +24 -0
- package/src/lib/nest/coerce-nest-environment-provider.js.map +1 -0
- package/src/lib/nest/coerce-nest-logger-provider.d.ts +2 -0
- package/src/lib/nest/coerce-nest-logger-provider.js +24 -0
- package/src/lib/nest/coerce-nest-logger-provider.js.map +1 -0
- package/src/lib/nest/coerce-nest-module-controller.d.ts +8 -0
- package/src/lib/nest/coerce-nest-module-controller.js +24 -0
- package/src/lib/nest/coerce-nest-module-controller.js.map +1 -0
- package/src/lib/nest/coerce-nest-module-import.d.ts +9 -0
- package/src/lib/nest/coerce-nest-module-import.js +29 -0
- package/src/lib/nest/coerce-nest-module-import.js.map +1 -0
- package/src/lib/nest/coerce-nest-module-provider.d.ts +9 -0
- package/src/lib/nest/coerce-nest-module-provider.js +24 -0
- package/src/lib/nest/coerce-nest-module-provider.js.map +1 -0
- package/src/lib/nest/coerce-nest-module.d.ts +6 -0
- package/src/lib/nest/coerce-nest-module.js +31 -0
- package/src/lib/nest/coerce-nest-module.js.map +1 -0
- package/src/lib/nest/coerce-nest-operation.d.ts +40 -0
- package/src/lib/nest/coerce-nest-operation.js +253 -0
- package/src/lib/nest/coerce-nest-operation.js.map +1 -0
- package/src/lib/nest/coerce-nest-provider-to-array.d.ts +3 -0
- package/src/lib/nest/coerce-nest-provider-to-array.js +42 -0
- package/src/lib/nest/coerce-nest-provider-to-array.js.map +1 -0
- package/src/lib/nest/coerce-nest-throttler-module-import.d.ts +4 -0
- package/src/lib/nest/coerce-nest-throttler-module-import.js +34 -0
- package/src/lib/nest/coerce-nest-throttler-module-import.js.map +1 -0
- package/src/lib/nest/find-nest-module-source-file.d.ts +2 -0
- package/src/lib/nest/find-nest-module-source-file.js +10 -0
- package/src/lib/nest/find-nest-module-source-file.js.map +1 -0
- package/src/lib/nest/get-controller-class.d.ts +2 -0
- package/src/lib/nest/get-controller-class.js +18 -0
- package/src/lib/nest/get-controller-class.js.map +1 -0
- package/src/lib/nest/get-nest-module-metadata.d.ts +2 -0
- package/src/lib/nest/get-nest-module-metadata.js +19 -0
- package/src/lib/nest/get-nest-module-metadata.js.map +1 -0
- package/src/lib/nest/has-nest-module-class.d.ts +2 -0
- package/src/lib/nest/has-nest-module-class.js +11 -0
- package/src/lib/nest/has-nest-module-class.js.map +1 -0
- package/src/lib/nest/is-nest-module-class.d.ts +2 -0
- package/src/lib/nest/is-nest-module-class.js +8 -0
- package/src/lib/nest/is-nest-module-class.js.map +1 -0
- package/src/lib/nest/nest-provider-object.d.ts +10 -0
- package/src/lib/nest/nest-provider-object.js +3 -0
- package/src/lib/nest/nest-provider-object.js.map +1 -0
- package/src/lib/nest/remove-nest-module-provider.d.ts +3 -0
- package/src/lib/nest/remove-nest-module-provider.js +13 -0
- package/src/lib/nest/remove-nest-module-provider.js.map +1 -0
- package/src/lib/nest/remove-nest-provider-to-array.d.ts +3 -0
- package/src/lib/nest/remove-nest-provider-to-array.js +29 -0
- package/src/lib/nest/remove-nest-provider-to-array.js.map +1 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceVariableDeclaration = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
function CoerceVariableDeclaration(sourceFile, name, defaultDeclaration = {}, variableStatementStructure) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const declaration = Object.assign(Object.assign({}, defaultDeclaration), { name });
|
|
8
|
+
let variableStatement = sourceFile.getVariableStatement(name);
|
|
9
|
+
if (!variableStatement) {
|
|
10
|
+
variableStatementStructure !== null && variableStatementStructure !== void 0 ? variableStatementStructure : (variableStatementStructure = {
|
|
11
|
+
isExported: true,
|
|
12
|
+
declarationKind: ts_morph_1.VariableDeclarationKind.Const,
|
|
13
|
+
});
|
|
14
|
+
(_a = variableStatementStructure.isExported) !== null && _a !== void 0 ? _a : (variableStatementStructure.isExported = true);
|
|
15
|
+
(_b = variableStatementStructure.declarationKind) !== null && _b !== void 0 ? _b : (variableStatementStructure.declarationKind = ts_morph_1.VariableDeclarationKind.Const);
|
|
16
|
+
variableStatement = sourceFile.addVariableStatement(Object.assign(Object.assign({}, variableStatementStructure), { declarations: [declaration] }));
|
|
17
|
+
}
|
|
18
|
+
let variableDeclaration = variableStatement.getDeclarations()[0];
|
|
19
|
+
if (!variableDeclaration) {
|
|
20
|
+
variableDeclaration = variableStatement.addDeclaration(declaration);
|
|
21
|
+
}
|
|
22
|
+
return variableDeclaration;
|
|
23
|
+
}
|
|
24
|
+
exports.CoerceVariableDeclaration = CoerceVariableDeclaration;
|
|
25
|
+
//# sourceMappingURL=coerce-variable-declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-variable-declaration.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-variable-declaration.ts"],"names":[],"mappings":";;;AAAA,uCAOkB;AAElB,SAAgB,yBAAyB,CACvC,UAAsB,EACtB,IAAY,EACZ,qBAA+E,EAAE,EACjF,0BAAoG;;IAGpG,MAAM,WAAW,mCACZ,kBAAkB,KACrB,IAAI,GACL,CAAC;IAEF,IAAI,iBAAiB,GAAG,UAAU,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC9D,IAAI,CAAC,iBAAiB,EAAE;QACtB,0BAA0B,aAA1B,0BAA0B,cAA1B,0BAA0B,IAA1B,0BAA0B,GAAK;YAC7B,UAAU,EAAE,IAAI;YAChB,eAAe,EAAE,kCAAuB,CAAC,KAAK;SAC/C,EAAC;QACF,MAAA,0BAA0B,CAAC,UAAU,oCAArC,0BAA0B,CAAC,UAAU,GAAK,IAAI,EAAC;QAC/C,MAAA,0BAA0B,CAAC,eAAe,oCAA1C,0BAA0B,CAAC,eAAe,GAAK,kCAAuB,CAAC,KAAK,EAAC;QAC7E,iBAAiB,GAAG,UAAU,CAAC,oBAAoB,iCAC9C,0BAA0B,KAC7B,YAAY,EAAE,CAAE,WAAW,CAAE,IAC7B,CAAC;KACJ;IAED,IAAI,mBAAmB,GAAG,iBAAiB,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC;IAEjE,IAAI,CAAC,mBAAmB,EAAE;QACxB,mBAAmB,GAAG,iBAAiB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;KACrE;IAED,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAjCD,8DAiCC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type FindFunction<Node> = (node: Node) => boolean;
|
|
2
|
+
export type FindFunctionFactory<CompareTo, Node> = (compareTo: CompareTo) => FindFunction<Node>;
|
|
3
|
+
export declare function FindByNameFunction<CompareTo extends {
|
|
4
|
+
name: string;
|
|
5
|
+
}, Node extends {
|
|
6
|
+
getName(): string | undefined;
|
|
7
|
+
}>(compareTo: CompareTo): (node: Node) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindByNameFunction = void 0;
|
|
4
|
+
function FindByNameFunction(compareTo) {
|
|
5
|
+
return node => node.getName() === compareTo.name;
|
|
6
|
+
}
|
|
7
|
+
exports.FindByNameFunction = FindByNameFunction;
|
|
8
|
+
//# sourceMappingURL=find-function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-function.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/find-function.ts"],"names":[],"mappings":";;;AAIA,SAAgB,kBAAkB,CAGhC,SAAoB;IACpB,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,SAAS,CAAC,IAAI,CAAC;AACnD,CAAC;AALD,gDAKC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ClassDeclaration, Decorator, Node } from 'ts-morph';
|
|
2
|
+
export declare function GetClassDecoratorArguments(classDeclaration: ClassDeclaration, findFunction: (declaration: Decorator) => boolean): Node[];
|
|
3
|
+
export declare function GetClassDecoratorArguments(classDeclaration: ClassDeclaration, name: string): Node[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetClassDecoratorArguments = void 0;
|
|
4
|
+
function GetClassDecoratorArguments(classDeclaration, nameOrFindFunction) {
|
|
5
|
+
var _a;
|
|
6
|
+
let decorator;
|
|
7
|
+
if (typeof nameOrFindFunction === 'string') {
|
|
8
|
+
decorator = classDeclaration.getDecorator(nameOrFindFunction);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
decorator = classDeclaration.getDecorator(nameOrFindFunction);
|
|
12
|
+
}
|
|
13
|
+
return (_a = decorator === null || decorator === void 0 ? void 0 : decorator.getArguments()) !== null && _a !== void 0 ? _a : [];
|
|
14
|
+
}
|
|
15
|
+
exports.GetClassDecoratorArguments = GetClassDecoratorArguments;
|
|
16
|
+
//# sourceMappingURL=get-class-decorator-arguments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-class-decorator-arguments.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/get-class-decorator-arguments.ts"],"names":[],"mappings":";;;AAcA,SAAgB,0BAA0B,CACxC,gBAAkC,EAClC,kBAAkE;;IAGlE,IAAI,SAAgC,CAAC;IAErC,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE;QAC1C,SAAS,GAAG,gBAAgB,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;KAC/D;SAAM;QACL,SAAS,GAAG,gBAAgB,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;KAC/D;IAED,OAAO,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,YAAY,EAAE,mCAAI,EAAE,CAAC;AAEzC,CAAC;AAfD,gEAeC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetClass = void 0;
|
|
4
|
+
const find_function_1 = require("./find-function");
|
|
5
|
+
function GetClass(sourceFile, nameOrFindFunction) {
|
|
6
|
+
if (nameOrFindFunction) {
|
|
7
|
+
let findFunction;
|
|
8
|
+
if (typeof nameOrFindFunction === 'string') {
|
|
9
|
+
findFunction = (0, find_function_1.FindByNameFunction)({ name: nameOrFindFunction });
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
findFunction = nameOrFindFunction;
|
|
13
|
+
}
|
|
14
|
+
return sourceFile.getClassOrThrow(findFunction);
|
|
15
|
+
}
|
|
16
|
+
const classDeclarationList = sourceFile.getClasses();
|
|
17
|
+
if (classDeclarationList.length === 0) {
|
|
18
|
+
throw new Error(`No class declaration found in file: ${sourceFile.getFilePath()}`);
|
|
19
|
+
}
|
|
20
|
+
if (classDeclarationList.length !== 1) {
|
|
21
|
+
throw new Error(`Multiple class declarations found in file: ${sourceFile.getFilePath()}`);
|
|
22
|
+
}
|
|
23
|
+
return classDeclarationList[0];
|
|
24
|
+
}
|
|
25
|
+
exports.GetClass = GetClass;
|
|
26
|
+
//# sourceMappingURL=get-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-class.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/get-class.ts"],"names":[],"mappings":";;;AAIA,mDAGyB;AAEzB,SAAgB,QAAQ,CAAC,UAAsB,EAAE,kBAA4D;IAE3G,IAAI,kBAAkB,EAAE;QACtB,IAAI,YAA4C,CAAC;QAEjD,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE;YAC1C,YAAY,GAAG,IAAA,kCAAkB,EAAwB,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAC;SACxF;aAAM;YACL,YAAY,GAAG,kBAAkB,CAAC;SACnC;QAED,OAAO,UAAU,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;KACjD;IAED,MAAM,oBAAoB,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC;IAErD,IAAI,oBAAoB,CAAC,MAAM,KAAK,CAAC,EAAE;QACrC,MAAM,IAAI,KAAK,CAAC,uCAAwC,UAAU,CAAC,WAAW,EAAG,EAAE,CAAC,CAAC;KACtF;IAED,IAAI,oBAAoB,CAAC,MAAM,KAAK,CAAC,EAAE;QACrC,MAAM,IAAI,KAAK,CAAC,8CAA+C,UAAU,CAAC,WAAW,EAAG,EAAE,CAAC,CAAC;KAC7F;IAED,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;AAEjC,CAAC;AA1BD,4BA0BC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetCoerceArrayLiteralFromObjectLiteral = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
function GetCoerceArrayLiteralFromObjectLiteral(objectLiteral, propertyKey) {
|
|
6
|
+
let arrayLiteralAssignment = objectLiteral.getProperty(propertyKey);
|
|
7
|
+
if (!arrayLiteralAssignment) {
|
|
8
|
+
arrayLiteralAssignment = objectLiteral.addPropertyAssignment({
|
|
9
|
+
name: propertyKey,
|
|
10
|
+
initializer: '[]',
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
if (!(arrayLiteralAssignment instanceof ts_morph_1.PropertyAssignment)) {
|
|
14
|
+
throw new Error('The imports property is not type of Property Assignment!');
|
|
15
|
+
}
|
|
16
|
+
const arrayLiteral = arrayLiteralAssignment.getInitializer();
|
|
17
|
+
if (!arrayLiteral) {
|
|
18
|
+
throw new Error('The imports property a not a initializer');
|
|
19
|
+
}
|
|
20
|
+
if (!(arrayLiteral instanceof ts_morph_1.ArrayLiteralExpression)) {
|
|
21
|
+
throw new Error('The imports property initializer is not an array');
|
|
22
|
+
}
|
|
23
|
+
return arrayLiteral;
|
|
24
|
+
}
|
|
25
|
+
exports.GetCoerceArrayLiteralFromObjectLiteral = GetCoerceArrayLiteralFromObjectLiteral;
|
|
26
|
+
//# sourceMappingURL=get-coerce-array-literal-form-object-literal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-coerce-array-literal-form-object-literal.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/get-coerce-array-literal-form-object-literal.ts"],"names":[],"mappings":";;;AAAA,uCAIkB;AAElB,SAAgB,sCAAsC,CACpD,aAAsC,EACtC,WAAmB;IAGnB,IAAI,sBAAsB,GAAG,aAAa,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAEpE,IAAI,CAAC,sBAAsB,EAAE;QAC3B,sBAAsB,GAAG,aAAa,CAAC,qBAAqB,CAAC;YAC3D,IAAI,EAAE,WAAW;YACjB,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;KACJ;IAED,IAAI,CAAC,CAAC,sBAAsB,YAAY,6BAAkB,CAAC,EAAE;QAC3D,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;KAC7E;IAED,MAAM,YAAY,GAAG,sBAAsB,CAAC,cAAc,EAAE,CAAC;IAE7D,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;KAC7D;IAED,IAAI,CAAC,CAAC,YAAY,YAAY,iCAAsB,CAAC,EAAE;QACrD,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;KACrE;IAED,OAAO,YAAY,CAAC;AAEtB,CAAC;AA9BD,wFA8BC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddHealthEndpoint = void 0;
|
|
4
|
+
const utilities_1 = require("@rxap/utilities");
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
const coerce_dependency_injection_1 = require("../coerce-dependency-injection");
|
|
7
|
+
function AddHealthEndpoint(sourceFile, name) {
|
|
8
|
+
const classDeclaration = sourceFile.getClass('HealthController');
|
|
9
|
+
if (!classDeclaration) {
|
|
10
|
+
throw new Error('FATAL: could not find the HealthController class!');
|
|
11
|
+
}
|
|
12
|
+
const healthIndicatorClass = `${(0, utilities_1.classify)(name)}HealthIndicator`;
|
|
13
|
+
classDeclaration.addMethod({
|
|
14
|
+
name: (0, utilities_1.camelize)(name),
|
|
15
|
+
returnType: 'Promise<HealthCheckResult>',
|
|
16
|
+
statements: [
|
|
17
|
+
w => {
|
|
18
|
+
w.writeLine('return this.health.check([');
|
|
19
|
+
w.writeLine(`async () => this.${(0, utilities_1.camelize)(healthIndicatorClass)}.isHealthy(),`);
|
|
20
|
+
w.write(']);');
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
scope: ts_morph_1.Scope.Public,
|
|
24
|
+
decorators: [
|
|
25
|
+
{
|
|
26
|
+
name: 'Get',
|
|
27
|
+
arguments: [w => w.quote((0, utilities_1.dasherize)(name))],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'HealthCheck',
|
|
31
|
+
arguments: [],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
sourceFile.addImportDeclarations([
|
|
36
|
+
{
|
|
37
|
+
moduleSpecifier: '@nestjs/terminus',
|
|
38
|
+
namedImports: ['HealthCheck', 'HealthCheckResult'],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
moduleSpecifier: '@nestjs/common',
|
|
42
|
+
namedImports: ['Get'],
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
(0, coerce_dependency_injection_1.CoerceDependencyInjection)(sourceFile, {
|
|
46
|
+
parameterName: (0, utilities_1.camelize)(healthIndicatorClass),
|
|
47
|
+
injectionToken: healthIndicatorClass,
|
|
48
|
+
scope: ts_morph_1.Scope.Private,
|
|
49
|
+
}, [
|
|
50
|
+
{
|
|
51
|
+
moduleSpecifier: `./${(0, utilities_1.dasherize)(name)}.health-indicator`,
|
|
52
|
+
namedImports: [healthIndicatorClass],
|
|
53
|
+
},
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
exports.AddHealthEndpoint = AddHealthEndpoint;
|
|
57
|
+
//# sourceMappingURL=add-health-endpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-health-endpoint.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/nest/add-health-endpoint.ts"],"names":[],"mappings":";;;AAAA,+CAIyB;AACzB,uCAGkB;AAClB,gFAA2E;AAE3E,SAAgB,iBAAiB,CAC/B,UAAsB,EACtB,IAAY;IAGZ,MAAM,gBAAgB,GAAG,UAAU,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAEjE,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;KACtE;IAED,MAAM,oBAAoB,GAAG,GAAI,IAAA,oBAAQ,EAAC,IAAI,CAAE,iBAAiB,CAAC;IAElE,gBAAgB,CAAC,SAAS,CAAC;QACzB,IAAI,EAAE,IAAA,oBAAQ,EAAC,IAAI,CAAC;QACpB,UAAU,EAAE,4BAA4B;QACxC,UAAU,EAAE;YACV,CAAC,CAAC,EAAE;gBACF,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;gBAC1C,CAAC,CAAC,SAAS,CAAC,oBAAqB,IAAA,oBAAQ,EAAC,oBAAoB,CAAE,eAAe,CAAC,CAAC;gBACjF,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;SACF;QACD,KAAK,EAAE,gBAAK,CAAC,MAAM;QACnB,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,KAAK;gBACX,SAAS,EAAE,CAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAA,qBAAS,EAAC,IAAI,CAAC,CAAC,CAAE;aAC7C;YACD;gBACE,IAAI,EAAE,aAAa;gBACnB,SAAS,EAAE,EAAE;aACd;SACF;KACF,CAAC,CAAC;IAEH,UAAU,CAAC,qBAAqB,CAAC;QAC/B;YACE,eAAe,EAAE,kBAAkB;YACnC,YAAY,EAAE,CAAE,aAAa,EAAE,mBAAmB,CAAE;SACrD;QACD;YACE,eAAe,EAAE,gBAAgB;YACjC,YAAY,EAAE,CAAE,KAAK,CAAE;SACxB;KACF,CAAC,CAAC;IAEH,IAAA,uDAAyB,EACvB,UAAU,EACV;QACE,aAAa,EAAE,IAAA,oBAAQ,EAAC,oBAAoB,CAAC;QAC7C,cAAc,EAAE,oBAAoB;QACpC,KAAK,EAAE,gBAAK,CAAC,OAAO;KACrB,EACD;QACE;YACE,eAAe,EAAE,KAAM,IAAA,qBAAS,EAAC,IAAI,CAAE,mBAAmB;YAC1D,YAAY,EAAE,CAAE,oBAAoB,CAAE;SACvC;KACF,CACF,CAAC;AAEJ,CAAC;AA9DD,8CA8DC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddHealthIndicator = void 0;
|
|
4
|
+
const utilities_1 = require("@rxap/utilities");
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
function AddHealthIndicator(indicatorSourceFile, name) {
|
|
7
|
+
const indicatorClassName = (0, utilities_1.CoerceSuffix)((0, utilities_1.classify)(name), 'HealthIndicator');
|
|
8
|
+
indicatorSourceFile.addClass({
|
|
9
|
+
name: indicatorClassName,
|
|
10
|
+
isExported: true,
|
|
11
|
+
decorators: [
|
|
12
|
+
{
|
|
13
|
+
name: 'Injectable',
|
|
14
|
+
arguments: [],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
extends: 'HealthIndicator',
|
|
18
|
+
ctors: [
|
|
19
|
+
{
|
|
20
|
+
parameters: [],
|
|
21
|
+
statements: 'super();',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
methods: [
|
|
25
|
+
{
|
|
26
|
+
name: 'isHealthy',
|
|
27
|
+
isAsync: true,
|
|
28
|
+
scope: ts_morph_1.Scope.Public,
|
|
29
|
+
returnType: 'Promise<HealthIndicatorResult>',
|
|
30
|
+
statements: [
|
|
31
|
+
`throw new HealthCheckError('Not yet implemented!', this.getStatus('${(0, utilities_1.dasherize)(name)}', false))`,
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
});
|
|
36
|
+
indicatorSourceFile.addImportDeclarations([
|
|
37
|
+
{
|
|
38
|
+
namedImports: ['Injectable'],
|
|
39
|
+
moduleSpecifier: '@nestjs/common',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
namedImports: ['HealthCheckError', 'HealthIndicator', 'HealthIndicatorResult'],
|
|
43
|
+
moduleSpecifier: '@nestjs/terminus',
|
|
44
|
+
},
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
exports.AddHealthIndicator = AddHealthIndicator;
|
|
48
|
+
//# sourceMappingURL=add-health-indicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-health-indicator.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/nest/add-health-indicator.ts"],"names":[],"mappings":";;;AAAA,+CAIyB;AACzB,uCAGkB;AAElB,SAAgB,kBAAkB,CAAC,mBAA+B,EAAE,IAAY;IAE9E,MAAM,kBAAkB,GAAG,IAAA,wBAAY,EAAC,IAAA,oBAAQ,EAAC,IAAI,CAAC,EAAE,iBAAiB,CAAC,CAAC;IAE3E,mBAAmB,CAAC,QAAQ,CAAC;QAC3B,IAAI,EAAE,kBAAkB;QACxB,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,YAAY;gBAClB,SAAS,EAAE,EAAE;aACd;SACF;QACD,OAAO,EAAE,iBAAiB;QAC1B,KAAK,EAAE;YACL;gBACE,UAAU,EAAE,EAAE;gBACd,UAAU,EAAE,UAAU;aACvB;SACF;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,IAAI;gBACb,KAAK,EAAE,gBAAK,CAAC,MAAM;gBACnB,UAAU,EAAE,gCAAgC;gBAC5C,UAAU,EAAE;oBACV,sEAAuE,IAAA,qBAAS,EAAC,IAAI,CAAE,YAAY;iBACpG;aACF;SACF;KACF,CAAC,CAAC;IAEH,mBAAmB,CAAC,qBAAqB,CAAC;QACxC;YACE,YAAY,EAAE,CAAE,YAAY,CAAE;YAC9B,eAAe,EAAE,gBAAgB;SAClC;QACD;YACE,YAAY,EAAE,CAAE,kBAAkB,EAAE,iBAAiB,EAAE,uBAAuB,CAAE;YAChF,eAAe,EAAE,kBAAkB;SACpC;KACF,CAAC,CAAC;AAEL,CAAC;AA5CD,gDA4CC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddToGlobalHealthEndpoint = void 0;
|
|
4
|
+
const utilities_1 = require("@rxap/utilities");
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
const coerce_class_method_1 = require("../coerce-class-method");
|
|
7
|
+
function AddToGlobalHealthEndpoint(sourceFile, name) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const classDeclaration = sourceFile.getClass('HealthController');
|
|
10
|
+
if (!classDeclaration) {
|
|
11
|
+
throw new Error('FATAL: could not find the HealthController class!');
|
|
12
|
+
}
|
|
13
|
+
const healthIndicatorClass = `${(0, utilities_1.classify)(name)}HealthIndicator`;
|
|
14
|
+
const methodDeclaration = (0, coerce_class_method_1.CoerceClassMethod)(classDeclaration, 'healthCheck', {
|
|
15
|
+
scope: ts_morph_1.Scope.Public,
|
|
16
|
+
returnType: 'Promise<HealthCheckResult>',
|
|
17
|
+
statements: [
|
|
18
|
+
w => {
|
|
19
|
+
w.writeLine('return this.health.check([');
|
|
20
|
+
w.write(']);');
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
decorators: [
|
|
24
|
+
{
|
|
25
|
+
name: 'Get',
|
|
26
|
+
arguments: [],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'HealthCheck',
|
|
30
|
+
arguments: [],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
sourceFile.addImportDeclarations([
|
|
35
|
+
{
|
|
36
|
+
moduleSpecifier: '@nestjs/terminus',
|
|
37
|
+
namedImports: ['HealthCheck', 'HealthCheckResult'],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
moduleSpecifier: '@nestjs/common',
|
|
41
|
+
namedImports: ['Get'],
|
|
42
|
+
},
|
|
43
|
+
]);
|
|
44
|
+
const statement = methodDeclaration.getStatements().find(e => e.getFullText().match(/return this\.health\.check/));
|
|
45
|
+
const array = (_b = (_a = statement === null || statement === void 0 ? void 0 : statement.getChildAtIndex(1)) === null || _a === void 0 ? void 0 : _a.getChildAtIndex(2)) === null || _b === void 0 ? void 0 : _b.getFirstChild();
|
|
46
|
+
if (array instanceof ts_morph_1.ArrayLiteralExpression) {
|
|
47
|
+
array.addElement(w => {
|
|
48
|
+
w.write(`async () => this.${(0, utilities_1.camelize)(healthIndicatorClass)}.isHealthy()`);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.AddToGlobalHealthEndpoint = AddToGlobalHealthEndpoint;
|
|
53
|
+
//# sourceMappingURL=add-to-global-health-endpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-to-global-health-endpoint.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/nest/add-to-global-health-endpoint.ts"],"names":[],"mappings":";;;AAAA,+CAGyB;AACzB,uCAKkB;AAClB,gEAA2D;AAG3D,SAAgB,yBAAyB,CACvC,UAAsB,EACtB,IAAY;;IAGZ,MAAM,gBAAgB,GAAG,UAAU,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAEjE,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;KACtE;IAED,MAAM,oBAAoB,GAAG,GAAI,IAAA,oBAAQ,EAAC,IAAI,CAAE,iBAAiB,CAAC;IAElE,MAAM,iBAAiB,GAAsB,IAAA,uCAAiB,EAC5D,gBAAgB,EAChB,aAAa,EACb;QACE,KAAK,EAAE,gBAAK,CAAC,MAAM;QACnB,UAAU,EAAE,4BAA4B;QACxC,UAAU,EAAE;YACV,CAAC,CAAC,EAAE;gBACF,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;gBAC1C,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;SACF;QACD,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,KAAK;gBACX,SAAS,EAAE,EAAE;aACd;YACD;gBACE,IAAI,EAAE,aAAa;gBACnB,SAAS,EAAE,EAAE;aACd;SACF;KACF,CACF,CAAC;IAEF,UAAU,CAAC,qBAAqB,CAAC;QAC/B;YACE,eAAe,EAAE,kBAAkB;YACnC,YAAY,EAAE,CAAE,aAAa,EAAE,mBAAmB,CAAE;SACrD;QACD;YACE,eAAe,EAAE,gBAAgB;YACjC,YAAY,EAAE,CAAE,KAAK,CAAE;SACxB;KACF,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,iBAAiB,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC;IAEnH,MAAM,KAAK,GAAG,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,eAAe,CAAC,CAAC,CAAC,0CAAE,eAAe,CAAC,CAAC,CAAC,0CAAE,aAAa,EAAE,CAAC;IAEjF,IAAI,KAAK,YAAY,iCAAsB,EAAE;QAC3C,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;YACnB,CAAC,CAAC,KAAK,CAAC,oBAAqB,IAAA,oBAAQ,EAAC,oBAAoB,CAAE,cAAc,CAAC,CAAC;QAC9E,CAAC,CAAC,CAAC;KACJ;AAEH,CAAC;AA3DD,8DA2DC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceAppGuardProvider = void 0;
|
|
4
|
+
const coerce_nest_module_provider_1 = require("./coerce-nest-module-provider");
|
|
5
|
+
function CoerceAppGuardProvider(sourceFile) {
|
|
6
|
+
(0, coerce_nest_module_provider_1.CoerceNestModuleProvider)(sourceFile, {
|
|
7
|
+
providerObject: {
|
|
8
|
+
provide: 'APP_GUARD',
|
|
9
|
+
useClass: 'ThrottlerGuard',
|
|
10
|
+
},
|
|
11
|
+
structures: [
|
|
12
|
+
{
|
|
13
|
+
namedImports: ['APP_GUARD'],
|
|
14
|
+
moduleSpecifier: '@nestjs/core',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
namedImports: ['ThrottlerGuard'],
|
|
18
|
+
moduleSpecifier: '@nestjs/throttler',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.CoerceAppGuardProvider = CoerceAppGuardProvider;
|
|
24
|
+
//# sourceMappingURL=coerce-app-guard-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-app-guard-provider.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/nest/coerce-app-guard-provider.ts"],"names":[],"mappings":";;;AACA,+EAAyE;AAEzE,SAAgB,sBAAsB,CAAC,UAAsB;IAC3D,IAAA,sDAAwB,EACtB,UAAU,EACV;QACE,cAAc,EAAE;YACd,OAAO,EAAE,WAAW;YACpB,QAAQ,EAAE,gBAAgB;SAC3B;QACD,UAAU,EAAE;YACV;gBACE,YAAY,EAAE,CAAE,WAAW,CAAE;gBAC7B,eAAe,EAAE,cAAc;aAChC;YACD;gBACE,YAAY,EAAE,CAAE,gBAAgB,CAAE;gBAClC,eAAe,EAAE,mBAAmB;aACrC;SACF;KACF,CACF,CAAC;AACJ,CAAC;AApBD,wDAoBC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceHealthController = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const coerce_dependency_injection_1 = require("../coerce-dependency-injection");
|
|
6
|
+
const coerce_nest_controller_1 = require("./coerce-nest-controller");
|
|
7
|
+
function CoerceHealthController(sourceFile) {
|
|
8
|
+
(0, coerce_nest_controller_1.CoerceNestController)(sourceFile, { name: 'health', path: 'health' });
|
|
9
|
+
(0, coerce_dependency_injection_1.CoerceDependencyInjection)(sourceFile, {
|
|
10
|
+
injectionToken: 'HealthCheckService',
|
|
11
|
+
parameterName: 'health',
|
|
12
|
+
scope: ts_morph_1.Scope.Private,
|
|
13
|
+
module: coerce_dependency_injection_1.Module.NEST,
|
|
14
|
+
}, [
|
|
15
|
+
{
|
|
16
|
+
namedImports: ['HealthCheckService'],
|
|
17
|
+
moduleSpecifier: '@nestjs/terminus',
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
20
|
+
return sourceFile;
|
|
21
|
+
}
|
|
22
|
+
exports.CoerceHealthController = CoerceHealthController;
|
|
23
|
+
//# sourceMappingURL=coerce-health-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-health-controller.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/nest/coerce-health-controller.ts"],"names":[],"mappings":";;;AAAA,uCAGkB;AAClB,gFAGwC;AACxC,qEAAgE;AAEhE,SAAgB,sBAAsB,CAAC,UAAsB;IAE3D,IAAA,6CAAoB,EAAC,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAErE,IAAA,uDAAyB,EAAC,UAAU,EAAE;QACpC,cAAc,EAAE,oBAAoB;QACpC,aAAa,EAAE,QAAQ;QACvB,KAAK,EAAE,gBAAK,CAAC,OAAO;QACpB,MAAM,EAAE,oCAAM,CAAC,IAAI;KACpB,EAAE;QACD;YACE,YAAY,EAAE,CAAE,oBAAoB,CAAE;YACtC,eAAe,EAAE,kBAAkB;SACpC;KACF,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AAEpB,CAAC;AAlBD,wDAkBC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceHealthModule = void 0;
|
|
4
|
+
const coerce_imports_1 = require("../coerce-imports");
|
|
5
|
+
const coerce_nest_module_1 = require("./coerce-nest-module");
|
|
6
|
+
const coerce_nest_module_import_1 = require("./coerce-nest-module-import");
|
|
7
|
+
const coerce_nest_module_provider_1 = require("./coerce-nest-module-provider");
|
|
8
|
+
function CoerceHealthModule(sourceFile) {
|
|
9
|
+
(0, coerce_nest_module_1.CoerceNestModule)(sourceFile, {
|
|
10
|
+
name: 'Health',
|
|
11
|
+
});
|
|
12
|
+
(0, coerce_nest_module_import_1.CoerceNestModuleImport)(sourceFile, {
|
|
13
|
+
moduleName: 'TerminusModule',
|
|
14
|
+
structures: [
|
|
15
|
+
{
|
|
16
|
+
moduleSpecifier: '@nestjs/terminus',
|
|
17
|
+
namedImports: ['TerminusModule'],
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
(0, coerce_nest_module_provider_1.CoerceNestModuleProvider)(sourceFile, {
|
|
22
|
+
providerObject: 'Logger',
|
|
23
|
+
structures: [
|
|
24
|
+
{
|
|
25
|
+
moduleSpecifier: '@nestjs/common',
|
|
26
|
+
namedImports: ['Logger'],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
31
|
+
moduleSpecifier: '@nestjs/common',
|
|
32
|
+
namedImports: ['Module'],
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.CoerceHealthModule = CoerceHealthModule;
|
|
36
|
+
//# sourceMappingURL=coerce-health-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-health-module.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/nest/coerce-health-module.ts"],"names":[],"mappings":";;;AACA,sDAAkD;AAClD,6DAAwD;AACxD,2EAAqE;AACrE,+EAAyE;AAEzE,SAAgB,kBAAkB,CAAC,UAAsB;IAEvD,IAAA,qCAAgB,EAAC,UAAU,EAAE;QAC3B,IAAI,EAAE,QAAQ;KACf,CAAC,CAAC;IAEH,IAAA,kDAAsB,EAAC,UAAU,EAAE;QACjC,UAAU,EAAE,gBAAgB;QAC5B,UAAU,EAAE;YACV;gBACE,eAAe,EAAE,kBAAkB;gBACnC,YAAY,EAAE,CAAE,gBAAgB,CAAE;aACnC;SACF;KACF,CAAC,CAAC;IAEH,IAAA,sDAAwB,EAAC,UAAU,EAAE;QACnC,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE;YACV;gBACE,eAAe,EAAE,gBAAgB;gBACjC,YAAY,EAAE,CAAE,QAAQ,CAAE;aAC3B;SACF;KACF,CAAC,CAAC;IAEH,IAAA,8BAAa,EAAC,UAAU,EAAE;QACxB,eAAe,EAAE,gBAAgB;QACjC,YAAY,EAAE,CAAE,QAAQ,CAAE;KAC3B,CAAC,CAAC;AAEL,CAAC;AA/BD,gDA+BC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SourceFile, WriterFunction } from 'ts-morph';
|
|
2
|
+
export interface CoerceNestAppConfigOptionsItem {
|
|
3
|
+
name: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
defaultValue?: string | WriterFunction;
|
|
6
|
+
builder?: (item: Omit<CoerceNestAppConfigOptionsItem, 'builder'>) => string | WriterFunction;
|
|
7
|
+
}
|
|
8
|
+
export interface CoerceNestAppConfigOptions {
|
|
9
|
+
itemList: Array<CoerceNestAppConfigOptionsItem>;
|
|
10
|
+
}
|
|
11
|
+
export declare function CoerceNestAppConfig(sourceFile: SourceFile, options: CoerceNestAppConfigOptions): void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceNestAppConfig = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const coerce_imports_1 = require("../coerce-imports");
|
|
6
|
+
const coerce_variable_declaration_1 = require("../coerce-variable-declaration");
|
|
7
|
+
function CoerceNestAppConfig(sourceFile, options) {
|
|
8
|
+
const { itemList } = options;
|
|
9
|
+
const objVariableDeclaration = (0, coerce_variable_declaration_1.CoerceVariableDeclaration)(sourceFile, 'validationSchema', {
|
|
10
|
+
type: 'SchemaMap',
|
|
11
|
+
initializer: '{}',
|
|
12
|
+
}, { isExported: false });
|
|
13
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, [
|
|
14
|
+
{
|
|
15
|
+
namedImports: [
|
|
16
|
+
'SchemaMap',
|
|
17
|
+
],
|
|
18
|
+
moduleSpecifier: 'joi',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
moduleSpecifier: 'joi',
|
|
22
|
+
namespaceImport: 'Joi',
|
|
23
|
+
},
|
|
24
|
+
]);
|
|
25
|
+
const schemaVariableDeclaration = (0, coerce_variable_declaration_1.CoerceVariableDeclaration)(sourceFile, 'VALIDATION_SCHEMA', {
|
|
26
|
+
initializer: 'Joi.object(validationSchema)',
|
|
27
|
+
});
|
|
28
|
+
const objIndex = objVariableDeclaration.getVariableStatement().getChildIndex();
|
|
29
|
+
const schemaIndex = schemaVariableDeclaration.getVariableStatement().getChildIndex();
|
|
30
|
+
const existingNodes = [];
|
|
31
|
+
for (let index = objIndex + 1; index < schemaIndex; index++) {
|
|
32
|
+
existingNodes.push(sourceFile.getStatements()[index]);
|
|
33
|
+
}
|
|
34
|
+
const existingExpressions = existingNodes.filter(node => node.getKind() === ts_morph_1.SyntaxKind.ExpressionStatement);
|
|
35
|
+
const validationSchemaExpressions = existingExpressions.filter(node => node.getText().startsWith('validationSchema'));
|
|
36
|
+
for (const item of itemList) {
|
|
37
|
+
const existing = validationSchemaExpressions.find(node => node.getText()
|
|
38
|
+
.startsWith(`validationSchema['${item.name}']`));
|
|
39
|
+
if (existing) {
|
|
40
|
+
existing.replaceWithText(writeValidationSchemaExpression(item));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
sourceFile.insertStatements(schemaIndex, writeValidationSchemaExpression(item));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.CoerceNestAppConfig = CoerceNestAppConfig;
|
|
48
|
+
function writeValidationSchemaExpression(item) {
|
|
49
|
+
return w => {
|
|
50
|
+
w.write(`validationSchema['${item.name}'] = `);
|
|
51
|
+
const value = item.builder ? item.builder(item) : buildValidationSchemaExpressionValue(item);
|
|
52
|
+
if (typeof value === 'string') {
|
|
53
|
+
w.write(value);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
value(w);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function buildValidationSchemaExpressionValue(item) {
|
|
61
|
+
return w => {
|
|
62
|
+
var _a;
|
|
63
|
+
w.write(`Joi.${(_a = item.type) !== null && _a !== void 0 ? _a : 'string'}()`);
|
|
64
|
+
if (item.defaultValue) {
|
|
65
|
+
if (typeof item.defaultValue === 'string') {
|
|
66
|
+
w.write(`.default(${item.defaultValue})`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
w.write('.default(');
|
|
70
|
+
item.defaultValue(w);
|
|
71
|
+
w.write(')');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
w.write(';');
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=coerce-nest-app-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-nest-app-config.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/nest/coerce-nest-app-config.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SourceFile } from 'ts-morph';
|
|
2
|
+
import { CoerceNestControllerOptions } from './coerce-nest-controller';
|
|
3
|
+
export interface CoerceNestAppControllerOptions extends Omit<CoerceNestControllerOptions, 'name'> {
|
|
4
|
+
}
|
|
5
|
+
export declare function CoerceNestAppController(sourceFile: SourceFile, options?: CoerceNestAppControllerOptions): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceNestAppController = void 0;
|
|
4
|
+
const coerce_decorator_1 = require("../coerce-decorator");
|
|
5
|
+
const coerce_imports_1 = require("../coerce-imports");
|
|
6
|
+
const coerce_nest_controller_1 = require("./coerce-nest-controller");
|
|
7
|
+
const coerce_nest_operation_1 = require("./coerce-nest-operation");
|
|
8
|
+
function CoerceNestAppController(sourceFile, options = {}) {
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
const classDeclaration = (0, coerce_nest_controller_1.CoerceNestController)(sourceFile, Object.assign(Object.assign({}, options), { name: 'app' }));
|
|
11
|
+
(0, coerce_decorator_1.CoerceDecorator)(classDeclaration, 'Public', { arguments: [] });
|
|
12
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
13
|
+
moduleSpecifier: '@rxap/nest-utilities',
|
|
14
|
+
namedImports: ['Public'],
|
|
15
|
+
});
|
|
16
|
+
// region remove the default implementation from the nest generator
|
|
17
|
+
(_a = classDeclaration.getMethod('getData')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
18
|
+
const [constructorDeclaration] = classDeclaration.getConstructors();
|
|
19
|
+
if (constructorDeclaration) {
|
|
20
|
+
(_b = constructorDeclaration.getParameter('appService')) === null || _b === void 0 ? void 0 : _b.remove();
|
|
21
|
+
if (constructorDeclaration.getParameters().length === 0) {
|
|
22
|
+
constructorDeclaration.remove();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
(_c = sourceFile.getImportDeclaration('./app.service')) === null || _c === void 0 ? void 0 : _c.remove();
|
|
26
|
+
// endregion
|
|
27
|
+
(0, coerce_nest_operation_1.CoerceNestOperation)(sourceFile, {
|
|
28
|
+
operationName: 'name',
|
|
29
|
+
returnType: 'string',
|
|
30
|
+
statements: ['return environment.app;'],
|
|
31
|
+
});
|
|
32
|
+
(0, coerce_nest_operation_1.CoerceNestOperation)(sourceFile, {
|
|
33
|
+
operationName: 'environment',
|
|
34
|
+
returnType: 'Environment',
|
|
35
|
+
statements: ['return environment'],
|
|
36
|
+
path: 'info',
|
|
37
|
+
});
|
|
38
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, [
|
|
39
|
+
{
|
|
40
|
+
moduleSpecifier: '../environments/environment',
|
|
41
|
+
namedImports: ['environment'],
|
|
42
|
+
}, {
|
|
43
|
+
moduleSpecifier: '@rxap/nest-utilities',
|
|
44
|
+
namedImports: ['Environment'],
|
|
45
|
+
},
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
exports.CoerceNestAppController = CoerceNestAppController;
|
|
49
|
+
//# sourceMappingURL=coerce-nest-app-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-nest-app-controller.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/nest/coerce-nest-app-controller.ts"],"names":[],"mappings":";;;AACA,0DAAsD;AACtD,sDAAkD;AAClD,qEAGkC;AAClC,mEAA8D;AAM9D,SAAgB,uBAAuB,CAAC,UAAsB,EAAE,UAA0C,EAAE;;IAE1G,MAAM,gBAAgB,GAAG,IAAA,6CAAoB,EAAC,UAAU,kCACnD,OAAO,KACV,IAAI,EAAE,KAAK,IACX,CAAC;IAEH,IAAA,kCAAe,EAAC,gBAAgB,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;IAE/D,IAAA,8BAAa,EAAC,UAAU,EAAE;QACxB,eAAe,EAAE,sBAAsB;QACvC,YAAY,EAAE,CAAE,QAAQ,CAAE;KAC3B,CAAC,CAAC;IAEH,mEAAmE;IACnE,MAAA,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,0CAAE,MAAM,EAAE,CAAC;IAChD,MAAM,CAAE,sBAAsB,CAAE,GAAG,gBAAgB,CAAC,eAAe,EAAE,CAAC;IACtE,IAAI,sBAAsB,EAAE;QAC1B,MAAA,sBAAsB,CAAC,YAAY,CAAC,YAAY,CAAC,0CAAE,MAAM,EAAE,CAAC;QAC5D,IAAI,sBAAsB,CAAC,aAAa,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;YACvD,sBAAsB,CAAC,MAAM,EAAE,CAAC;SACjC;KACF;IACD,MAAA,UAAU,CAAC,oBAAoB,CAAC,eAAe,CAAC,0CAAE,MAAM,EAAE,CAAC;IAC3D,YAAY;IAEZ,IAAA,2CAAmB,EAAC,UAAU,EAAE;QAC9B,aAAa,EAAE,MAAM;QACrB,UAAU,EAAE,QAAQ;QACpB,UAAU,EAAE,CAAE,yBAAyB,CAAE;KAC1C,CAAC,CAAC;IAEH,IAAA,2CAAmB,EAAC,UAAU,EAAE;QAC9B,aAAa,EAAE,aAAa;QAC5B,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,CAAE,oBAAoB,CAAE;QACpC,IAAI,EAAE,MAAM;KACb,CAAC,CAAC;IAEH,IAAA,8BAAa,EAAC,UAAU,EAAE;QACxB;YACE,eAAe,EAAE,6BAA6B;YAC9C,YAAY,EAAE,CAAE,aAAa,CAAE;SAChC,EAAE;YACD,eAAe,EAAE,sBAAsB;YACvC,YAAY,EAAE,CAAE,aAAa,CAAE;SAChC;KACF,CAAC,CAAC;AAEL,CAAC;AAjDD,0DAiDC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SourceFile } from 'ts-morph';
|
|
2
|
+
import { CoerceNestModuleOptions } from './coerce-nest-module';
|
|
3
|
+
export interface CoerceNestAppModuleOptions extends Omit<CoerceNestModuleOptions, 'name'> {
|
|
4
|
+
}
|
|
5
|
+
export declare function CoerceNestAppModule(sourceFile: SourceFile, options?: CoerceNestAppModuleOptions): void;
|