@buildvision/nest-sdk-generator 1.1.3

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.
Files changed (69) hide show
  1. package/.prettierrc +6 -0
  2. package/LICENSE.md +9 -0
  3. package/README.md +353 -0
  4. package/build/analyzer/builtin.d.ts +2 -0
  5. package/build/analyzer/builtin.js +11 -0
  6. package/build/analyzer/classdeps.d.ts +6 -0
  7. package/build/analyzer/classdeps.js +27 -0
  8. package/build/analyzer/controller.d.ts +26 -0
  9. package/build/analyzer/controller.js +103 -0
  10. package/build/analyzer/controllers.d.ts +7 -0
  11. package/build/analyzer/controllers.js +79 -0
  12. package/build/analyzer/decorator.d.ts +10 -0
  13. package/build/analyzer/decorator.js +29 -0
  14. package/build/analyzer/extractor.d.ts +107 -0
  15. package/build/analyzer/extractor.js +349 -0
  16. package/build/analyzer/index.d.ts +16 -0
  17. package/build/analyzer/index.js +101 -0
  18. package/build/analyzer/methods.d.ts +42 -0
  19. package/build/analyzer/methods.js +115 -0
  20. package/build/analyzer/module.d.ts +11 -0
  21. package/build/analyzer/module.js +41 -0
  22. package/build/analyzer/params.d.ts +38 -0
  23. package/build/analyzer/params.js +163 -0
  24. package/build/analyzer/route.d.ts +53 -0
  25. package/build/analyzer/route.js +131 -0
  26. package/build/analyzer/typedeps.d.ts +49 -0
  27. package/build/analyzer/typedeps.js +86 -0
  28. package/build/bin.d.ts +2 -0
  29. package/build/bin.js +39 -0
  30. package/build/config.d.ts +44 -0
  31. package/build/config.js +31 -0
  32. package/build/generator/genmodules.d.ts +24 -0
  33. package/build/generator/genmodules.js +134 -0
  34. package/build/generator/gentypes.d.ts +10 -0
  35. package/build/generator/gentypes.js +62 -0
  36. package/build/generator/index.d.ts +6 -0
  37. package/build/generator/index.js +83 -0
  38. package/build/generator/prettier.d.ts +16 -0
  39. package/build/generator/prettier.js +43 -0
  40. package/build/generator/sdk-interface.d.ts +1 -0
  41. package/build/generator/sdk-interface.js +36 -0
  42. package/build/logging.d.ts +6 -0
  43. package/build/logging.js +37 -0
  44. package/build/tsconfig.tsbuildinfo +1 -0
  45. package/build/utils.d.ts +9 -0
  46. package/build/utils.js +56 -0
  47. package/package.json +34 -0
  48. package/src/analyzer/builtin.ts +9 -0
  49. package/src/analyzer/classdeps.ts +37 -0
  50. package/src/analyzer/controller.ts +135 -0
  51. package/src/analyzer/controllers.ts +117 -0
  52. package/src/analyzer/decorator.ts +29 -0
  53. package/src/analyzer/extractor.ts +491 -0
  54. package/src/analyzer/index.ts +136 -0
  55. package/src/analyzer/methods.ts +166 -0
  56. package/src/analyzer/module.ts +56 -0
  57. package/src/analyzer/params.ts +241 -0
  58. package/src/analyzer/route.ts +156 -0
  59. package/src/analyzer/typedeps.ts +130 -0
  60. package/src/bin.ts +33 -0
  61. package/src/config.ts +89 -0
  62. package/src/generator/genmodules.ts +163 -0
  63. package/src/generator/gentypes.ts +73 -0
  64. package/src/generator/index.ts +92 -0
  65. package/src/generator/prettier.ts +46 -0
  66. package/src/generator/sdk-interface.ts +32 -0
  67. package/src/logging.ts +35 -0
  68. package/src/utils.ts +61 -0
  69. package/tsconfig.json +26 -0
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ /**
3
+ * @file Entrypoint of the SDK generator
4
+ */
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const fs = require("fs");
16
+ const path = require("path");
17
+ const typedeps_1 = require("../analyzer/typedeps");
18
+ const logging_1 = require("../logging");
19
+ const genmodules_1 = require("./genmodules");
20
+ const gentypes_1 = require("./gentypes");
21
+ const prettier_1 = require("./prettier");
22
+ const sdk_interface_1 = require("./sdk-interface");
23
+ function generatorCli(config, sdkContent) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const prettifyOutput = config.prettify !== false;
26
+ if (!prettifyOutput) {
27
+ (0, logging_1.debug)('NOTE: files will not be prettified with Prettier');
28
+ }
29
+ const output = path.resolve(process.cwd(), config.sdkOutput);
30
+ if (fs.existsSync(output)) {
31
+ if (config.overwriteOldOutputDir === false) {
32
+ (0, logging_1.panic)("Please provide an output directory that doesn't exist yet");
33
+ }
34
+ else {
35
+ if (!fs.existsSync(path.join(output, 'central.ts'))) {
36
+ (0, logging_1.panic)("Provided output path exists but doesn't seem to contain an SDK output. Please check the output directory.");
37
+ }
38
+ else {
39
+ fs.rmSync(output, { recursive: true });
40
+ }
41
+ }
42
+ }
43
+ const outputParentDir = path.dirname(output);
44
+ if (!fs.existsSync(outputParentDir)) {
45
+ (0, logging_1.panic)("Output directory's parent {magentaBright} does not exist.", outputParentDir);
46
+ }
47
+ fs.mkdirSync(output);
48
+ const prettierConfig = prettifyOutput ? (0, prettier_1.findPrettierConfig)(config) : {};
49
+ const writeScriptTo = (parentDir, file, utf8Content) => {
50
+ if (file.endsWith('.ts')) {
51
+ utf8Content =
52
+ '/// Auto-generated file (nest-sdk-generator)\n' +
53
+ '/// Please do not edit this file - re-generate the SDK using the generator instead.\n' +
54
+ (config.generateTimestamps !== false ? '/// Generated on: ' + new Date().toUTCString() + '\n' : '') +
55
+ '///\n' +
56
+ utf8Content;
57
+ }
58
+ const fullPath = path.resolve(output, parentDir !== null && parentDir !== void 0 ? parentDir : '', file);
59
+ fs.mkdirSync(path.dirname(fullPath), { recursive: true });
60
+ fs.writeFileSync(fullPath, prettifyOutput ? (0, prettier_1.prettify)(utf8Content, prettierConfig, file.endsWith('.json') ? 'json' : 'typescript') : utf8Content, 'utf8');
61
+ };
62
+ (0, logging_1.println)('> Generating type files...');
63
+ for (const [file, content] of (0, gentypes_1.generateSdkTypeFiles)(sdkContent.types)) {
64
+ writeScriptTo('_types', (0, typedeps_1.normalizeExternalFilePath)(file), content);
65
+ }
66
+ (0, logging_1.println)('> Generating modules...');
67
+ for (const [file, content] of (0, genmodules_1.generateSdkModules)(sdkContent.modules)) {
68
+ writeScriptTo(null, file, content);
69
+ }
70
+ const sdkInterfacePath = path.resolve(process.cwd(), config.sdkInterfacePath);
71
+ const relativeSdkInterfacePath = path
72
+ .relative(output, sdkInterfacePath)
73
+ .replace(/\\/g, '/')
74
+ .replace(/\.([jt]sx?)$/, '');
75
+ writeScriptTo(null, 'central.ts', `export { request } from "${relativeSdkInterfacePath}"`);
76
+ if (!fs.existsSync(sdkInterfacePath) && config.generateDefaultSdkInterface !== false) {
77
+ (0, logging_1.println)('├─ Generating default SDK interface...');
78
+ fs.writeFileSync(sdkInterfacePath, sdk_interface_1.defaultSdkInterface, 'utf8');
79
+ }
80
+ });
81
+ }
82
+ exports.default = generatorCli;
83
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZ2VuZXJhdG9yL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7R0FFRzs7Ozs7Ozs7Ozs7QUFFSCx5QkFBd0I7QUFDeEIsNkJBQTRCO0FBRTVCLG1EQUFnRTtBQUVoRSx3Q0FBa0Q7QUFDbEQsNkNBQWlEO0FBQ2pELHlDQUFpRDtBQUNqRCx5Q0FBeUQ7QUFDekQsbURBQXFEO0FBRXJELFNBQThCLFlBQVksQ0FBQyxNQUFjLEVBQUUsVUFBc0I7O1FBQy9FLE1BQU0sY0FBYyxHQUFHLE1BQU0sQ0FBQyxRQUFRLEtBQUssS0FBSyxDQUFBO1FBRWhELElBQUksQ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LHdDQUF3QyxDQUFDLENBQUE7WUFFakQsRUFBRSxDQUFDLGFBQWEsQ0FBQyxnQkFBZ0IsRUFBRSxtQ0FBbUIsRUFBRSxNQUFNLENBQUMsQ0FBQTtTQUNoRTtJQUNILENBQUM7Q0FBQTtBQTVFRCwrQkE0RUMifQ==
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file Interface for prettifying generated files
3
+ */
4
+ import { Config } from '../config';
5
+ /**
6
+ * Find a .prettierrc configuration file in the current directory or above
7
+ */
8
+ export declare function findPrettierConfig(config: Config): object;
9
+ /**
10
+ * Prettify a TypeScript or JSON input
11
+ * @param source
12
+ * @param config
13
+ * @param parser
14
+ * @returns
15
+ */
16
+ export declare function prettify(source: string, config: object, parser: 'typescript' | 'json'): string;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * @file Interface for prettifying generated files
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.prettify = exports.findPrettierConfig = void 0;
7
+ const fs = require("fs");
8
+ const prettier = require("prettier");
9
+ const logging_1 = require("../logging");
10
+ const utils_1 = require("../utils");
11
+ /**
12
+ * Find a .prettierrc configuration file in the current directory or above
13
+ */
14
+ function findPrettierConfig(config) {
15
+ var _a;
16
+ let prettierConfigPath = (_a = config.prettierConfig) !== null && _a !== void 0 ? _a : (0, utils_1.findFileAbove)('.prettierrc', config.sdkOutput);
17
+ if (!prettierConfigPath) {
18
+ return {};
19
+ }
20
+ if (!fs.existsSync(prettierConfigPath)) {
21
+ (0, logging_1.panic)('Prettier configuration was not found at specified path {magenta}', prettierConfigPath);
22
+ }
23
+ const text = fs.readFileSync(prettierConfigPath, 'utf8');
24
+ try {
25
+ return JSON.parse(text);
26
+ }
27
+ catch (e) {
28
+ throw new Error('Failed to parse Prettier configuration: ' + e);
29
+ }
30
+ }
31
+ exports.findPrettierConfig = findPrettierConfig;
32
+ /**
33
+ * Prettify a TypeScript or JSON input
34
+ * @param source
35
+ * @param config
36
+ * @param parser
37
+ * @returns
38
+ */
39
+ function prettify(source, config, parser) {
40
+ return prettier.format(source, Object.assign({ parser }, config));
41
+ }
42
+ exports.prettify = prettify;
43
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJldHRpZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZ2VuZXJhdG9yL3ByZXR0aWVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7R0FFRzs7O0FBRUgseUJBQXdCO0FBQ3hCLHFDQUFvQztBQUVwQyx3Q0FBa0M7QUFDbEMsb0NBQXdDO0FBRXhDOztHQUVHO0FBQ0gsU0FBZ0Isa0JBQWtCLENBQUMsTUFBYzs7SUFDL0MsSUFBSSxrQkFBa0IsR0FBRyxNQUFBLE1BQU0sQ0FBQyxjQUFjLG1DQUFJLElBQUEscUJBQWEsRUFBQyxhQUFhLEVBQUUsTUFBTSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBRWhHLElBQUksQ0FBQyxrQkFBa0IsRUFBRTtRQUN2QixPQUFPLEVBQUUsQ0FBQTtLQUNWO0lBRUQsSUFBSSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsa0JBQWtCLENBQUMsRUFBRTtRQUN0QyxJQUFBLGVBQUssRUFBQyxrRUFBa0UsRUFBRSxrQkFBa0IsQ0FBQyxDQUFBO0tBQzlGO0lBRUQsTUFBTSxJQUFJLEdBQUcsRUFBRSxDQUFDLFlBQVksQ0FBQyxrQkFBa0IsRUFBRSxNQUFNLENBQUMsQ0FBQTtJQUV4RCxJQUFJO1FBQ0YsT0FBTyxJQUFJLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFBO0tBQ3hCO0lBQUMsT0FBTyxDQUFDLEVBQUU7UUFDVixNQUFNLElBQUksS0FBSyxDQUFDLDBDQUEwQyxHQUFHLENBQUMsQ0FBQyxDQUFBO0tBQ2hFO0FBQ0gsQ0FBQztBQWxCRCxnREFrQkM7QUFFRDs7Ozs7O0dBTUc7QUFDSCxTQUFnQixRQUFRLENBQUMsTUFBYyxFQUFFLE1BQWMsRUFBRSxNQUE2QjtJQUNwRixPQUFPLFFBQVEsQ0FBQyxNQUFNLENBQUMsTUFBTSxrQkFDM0IsTUFBTSxJQUNILE1BQU0sRUFDVCxDQUFBO0FBQ0osQ0FBQztBQUxELDRCQUtDIn0=
@@ -0,0 +1 @@
1
+ export declare const defaultSdkInterface: string;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultSdkInterface = void 0;
4
+ exports.defaultSdkInterface = `
5
+ export async function request(
6
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
7
+ uri: string,
8
+ body: unknown,
9
+ query: Record<string, string>
10
+ ): Promise<unknown> {
11
+ const url = new URL('http://localhost:3000' + uri)
12
+ url.search = new URLSearchParams(query).toString()
13
+
14
+ const params: RequestInit = {
15
+ method,
16
+ // Required for content to be correctly parsed by NestJS
17
+ headers: { 'Content-Type': 'application/json' },
18
+ }
19
+
20
+ // Setting a body is forbidden on GET requests
21
+ if (method !== 'GET') {
22
+ params.body = JSON.stringify(body)
23
+ }
24
+
25
+ return fetch(url.toString(), params).then((res) => {
26
+ // Handle failed requests
27
+ if (!res.ok) {
28
+ throw Error(res.statusText)
29
+ }
30
+
31
+ return res.json()
32
+ })
33
+ }
34
+
35
+ `.trim();
36
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2RrLWludGVyZmFjZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9nZW5lcmF0b3Ivc2RrLWludGVyZmFjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBYSxRQUFBLG1CQUFtQixHQUFHOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0NBK0JsQyxDQUFDLElBQUksRUFBRSxDQUFBIn0=
@@ -0,0 +1,6 @@
1
+ export declare function format(message: string, ...params: Array<number | string>): string;
2
+ export declare function panic(message: string, ...params: Array<number | string>): never;
3
+ export declare function unreachable(message: string, ...params: Array<number | string>): never;
4
+ export declare function warn(message: string, ...params: Array<number | string>): void;
5
+ export declare function println(message: string, ...params: Array<number | string>): void;
6
+ export declare function debug(message: string, ...params: Array<number | string>): void;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debug = exports.println = exports.warn = exports.unreachable = exports.panic = exports.format = void 0;
4
+ const chalk = require("chalk");
5
+ const config_1 = require("./config");
6
+ function format(message, ...params) {
7
+ return message.replace(/\{(black|red|green|yellow|blue|magenta|cyan|white|gray|grey|blackBright|redBright|greenBright|yellowBright|blueBright|magentaBright|cyanBright|whiteBright|)\}/g, (match, color) => {
8
+ var _a;
9
+ const param = (_a = params.shift()) !== null && _a !== void 0 ? _a : panic(`In message:\n> {}\nMissing parameter:\n> {}`, message, match);
10
+ return color && config_1.config.noColor !== false ? chalk[color](param) : param;
11
+ });
12
+ }
13
+ exports.format = format;
14
+ function panic(message, ...params) {
15
+ console.error(chalk.redBright('ERROR: ' + format(message, ...params)));
16
+ process.exit(1);
17
+ }
18
+ exports.panic = panic;
19
+ function unreachable(message, ...params) {
20
+ panic(message, ...params);
21
+ }
22
+ exports.unreachable = unreachable;
23
+ function warn(message, ...params) {
24
+ console.warn(chalk.yellow(format(message, ...params)));
25
+ }
26
+ exports.warn = warn;
27
+ function println(message, ...params) {
28
+ console.log(format(message, ...params));
29
+ }
30
+ exports.println = println;
31
+ function debug(message, ...params) {
32
+ if (config_1.config.verbose) {
33
+ console.warn(chalk.cyan(format(message, ...params)));
34
+ }
35
+ }
36
+ exports.debug = debug;
37
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9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0FBQyxDQUFBO0FBQzNCLENBQUM7QUFGRCxrQ0FFQztBQUVELFNBQWdCLElBQUksQ0FBQyxPQUFlLEVBQUUsR0FBRyxNQUE4QjtJQUNyRSxPQUFPLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLE9BQU8sRUFBRSxHQUFHLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQTtBQUN4RCxDQUFDO0FBRkQsb0JBRUM7QUFFRCxTQUFnQixPQUFPLENBQUMsT0FBZSxFQUFFLEdBQUcsTUFBOEI7SUFDeEUsT0FBTyxDQUFDLEdBQUcsQ0FBQyxNQUFNLENBQUMsT0FBTyxFQUFFLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQTtBQUN6QyxDQUFDO0FBRkQsMEJBRUM7QUFFRCxTQUFnQixLQUFLLENBQUMsT0FBZSxFQUFFLEdBQUcsTUFBOEI7SUFDdEUsSUFBSSxlQUFNLENBQUMsT0FBTyxFQUFFO1FBQ2xCLE9BQU8sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsT0FBTyxFQUFFLEdBQUcsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFBO0tBQ3JEO0FBQ0gsQ0FBQztBQUpELHNCQUlDIn0=
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/typescript/lib/lib.es2021.d.ts","../node_modules/typescript/lib/lib.es2022.d.ts","../node_modules/typescript/lib/lib.esnext.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/typescript/lib/lib.es2021.promise.d.ts","../node_modules/typescript/lib/lib.es2021.string.d.ts","../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../node_modules/typescript/lib/lib.es2021.intl.d.ts","../node_modules/typescript/lib/lib.es2022.array.d.ts","../node_modules/typescript/lib/lib.es2022.error.d.ts","../node_modules/typescript/lib/lib.es2022.intl.d.ts","../node_modules/typescript/lib/lib.es2022.object.d.ts","../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2022.string.d.ts","../node_modules/typescript/lib/lib.esnext.intl.d.ts","../node_modules/@ts-morph/common/lib/typescript.d.ts","../node_modules/@ts-morph/common/lib/ts-morph-common.d.ts","../node_modules/ts-morph/lib/ts-morph.d.ts","../node_modules/chalk/index.d.ts","../src/config.ts","../src/logging.ts","../src/analyzer/builtin.ts","../src/utils.ts","../src/analyzer/decorator.ts","../src/analyzer/route.ts","../src/analyzer/typedeps.ts","../src/analyzer/params.ts","../src/analyzer/methods.ts","../src/analyzer/controller.ts","../src/analyzer/module.ts","../src/analyzer/controllers.ts","../src/analyzer/classdeps.ts","../src/analyzer/extractor.ts","../src/analyzer/index.ts","../src/generator/genmodules.ts","../src/generator/gentypes.ts","../node_modules/@types/prettier/index.d.ts","../src/generator/prettier.ts","../src/generator/sdk-interface.ts","../src/generator/index.ts","../src/bin.ts","../node_modules/@types/minimist/index.d.ts","../node_modules/@types/node/ts4.8/assert.d.ts","../node_modules/@types/node/ts4.8/assert/strict.d.ts","../node_modules/@types/node/ts4.8/globals.d.ts","../node_modules/@types/node/ts4.8/async_hooks.d.ts","../node_modules/@types/node/ts4.8/buffer.d.ts","../node_modules/@types/node/ts4.8/child_process.d.ts","../node_modules/@types/node/ts4.8/cluster.d.ts","../node_modules/@types/node/ts4.8/console.d.ts","../node_modules/@types/node/ts4.8/constants.d.ts","../node_modules/@types/node/ts4.8/crypto.d.ts","../node_modules/@types/node/ts4.8/dgram.d.ts","../node_modules/@types/node/ts4.8/diagnostics_channel.d.ts","../node_modules/@types/node/ts4.8/dns.d.ts","../node_modules/@types/node/ts4.8/dns/promises.d.ts","../node_modules/@types/node/ts4.8/domain.d.ts","../node_modules/@types/node/ts4.8/dom-events.d.ts","../node_modules/@types/node/ts4.8/events.d.ts","../node_modules/@types/node/ts4.8/fs.d.ts","../node_modules/@types/node/ts4.8/fs/promises.d.ts","../node_modules/@types/node/ts4.8/http.d.ts","../node_modules/@types/node/ts4.8/http2.d.ts","../node_modules/@types/node/ts4.8/https.d.ts","../node_modules/@types/node/ts4.8/inspector.d.ts","../node_modules/@types/node/ts4.8/module.d.ts","../node_modules/@types/node/ts4.8/net.d.ts","../node_modules/@types/node/ts4.8/os.d.ts","../node_modules/@types/node/ts4.8/path.d.ts","../node_modules/@types/node/ts4.8/perf_hooks.d.ts","../node_modules/@types/node/ts4.8/process.d.ts","../node_modules/@types/node/ts4.8/punycode.d.ts","../node_modules/@types/node/ts4.8/querystring.d.ts","../node_modules/@types/node/ts4.8/readline.d.ts","../node_modules/@types/node/ts4.8/readline/promises.d.ts","../node_modules/@types/node/ts4.8/repl.d.ts","../node_modules/@types/node/ts4.8/stream.d.ts","../node_modules/@types/node/ts4.8/stream/promises.d.ts","../node_modules/@types/node/ts4.8/stream/consumers.d.ts","../node_modules/@types/node/ts4.8/stream/web.d.ts","../node_modules/@types/node/ts4.8/string_decoder.d.ts","../node_modules/@types/node/ts4.8/test.d.ts","../node_modules/@types/node/ts4.8/timers.d.ts","../node_modules/@types/node/ts4.8/timers/promises.d.ts","../node_modules/@types/node/ts4.8/tls.d.ts","../node_modules/@types/node/ts4.8/trace_events.d.ts","../node_modules/@types/node/ts4.8/tty.d.ts","../node_modules/@types/node/ts4.8/url.d.ts","../node_modules/@types/node/ts4.8/util.d.ts","../node_modules/@types/node/ts4.8/v8.d.ts","../node_modules/@types/node/ts4.8/vm.d.ts","../node_modules/@types/node/ts4.8/wasi.d.ts","../node_modules/@types/node/ts4.8/worker_threads.d.ts","../node_modules/@types/node/ts4.8/zlib.d.ts","../node_modules/@types/node/ts4.8/globals.global.d.ts","../node_modules/@types/node/ts4.8/index.d.ts"],"fileInfos":[{"version":"f20c05dbfe50a208301d2a1da37b9931bce0466eb5a1f4fe240971b4ecc82b67","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","1fc5ab7a764205c68fa10d381b08417795fc73111d6dd16b5b1ed36badb743d9","746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f","d11a03592451da2d1065e09e61f4e2a9bf68f780f4f6623c18b57816a9679d17","aea179452def8a6152f98f63b191b84e7cbd69b0e248c91e61fb2e52328abe8c",{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true},{"version":"8cc8c5a3bac513368b0157f3d8b31cfdcfe78b56d3724f30f80ed9715e404af8","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"55f400eec64d17e888e278f4def2f254b41b89515d3b88ad75d5e05f019daddd","affectsGlobalScope":true},{"version":"181f1784c6c10b751631b24ce60c7f78b20665db4550b335be179217bacc0d5f","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"81cac4cbc92c0c839c70f8ffb94eb61e2d32dc1c3cf6d95844ca099463cf37ea","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"09aa50414b80c023553090e2f53827f007a301bc34b0495bfb2c3c08ab9ad1eb","affectsGlobalScope":true},{"version":"d7f680a43f8cd12a6b6122c07c54ba40952b0c8aa140dcfcf32eb9e6cb028596","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"775d9c9fd150d5de79e0450f35bc8b8f94ae64e3eb5da12725ff2a649dccc777","affectsGlobalScope":true},{"version":"b248e32ca52e8f5571390a4142558ae4f203ae2f94d5bac38a3084d529ef4e58","affectsGlobalScope":true},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"34c839eaaa6d78c8674ae2c37af2236dee6831b13db7b4ef4df3ec889a04d4f2","affectsGlobalScope":true},{"version":"34478567f8a80171f88f2f30808beb7da15eac0538ae91282dd33dce928d98ed","affectsGlobalScope":true},{"version":"ab7d58e6161a550ff92e5aff755dc37fe896245348332cd5f1e1203479fe0ed1","affectsGlobalScope":true},{"version":"6bda95ea27a59a276e46043b7065b55bd4b316c25e70e29b572958fa77565d43","affectsGlobalScope":true},{"version":"aedb8de1abb2ff1095c153854a6df7deae4a5709c37297f9d6e9948b6806fa66","affectsGlobalScope":true},{"version":"a4da0551fd39b90ca7ce5f68fb55d4dc0c1396d589b612e1902f68ee090aaada","affectsGlobalScope":true},{"version":"11ffe3c281f375fff9ffdde8bbec7669b4dd671905509079f866f2354a788064","affectsGlobalScope":true},{"version":"52d1bb7ab7a3306fd0375c8bff560feed26ed676a5b0457fa8027b563aecb9a4","affectsGlobalScope":true},"f84c28802d5c44429c86180eed9bb73826f2efd559205632ecb23d904b0a1a8c","5b62cb32ae66c8d1d420f2a807cd81dd1e5e68547eeacd738d41c39b64b6687c","01d183dc38180ca94b2751133213800c337e78d759498bc150adcda54271265e","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2",{"version":"c57015012f9720cebf36a538c82d990d793c2c70a30116fe29f9c286abcff7c3","signature":"bd1e2c77be9c95b240f47bc1a79102bb776253ef47f7e3708acb96f55c3e4911"},{"version":"040a645e9aa561becc6455beea2d16dfd89e7fb4a9d420be61eec838ed5ed42f","signature":"97289946dcfb289cfd3d02cba6d6ae3f19774cce5b662d50d8143dc32f2da4e3"},{"version":"8157e1133662959c7ddbcc92699c54e4fae658ef1110502f9b9a2b8153d768a9","signature":"c4801fef282d23bc99a3f07370b514ec11b83d1535e45c26eaa602933c791c43"},{"version":"1dd6493cd596960db56a1f49a51dbd11a5de9b3c10094e87358fc11126b671f7","signature":"4582dd61b218dc2fcf29ff6c2d7afaa8e4253d3c7c0300e42bba51e8f44325de"},{"version":"5f9cea65ce84950d7eaef20c93be89ef921c66715b2f186164fb6ada7b490644","signature":"44bef93c3e68048419b7c7953f470c5ba93812aaaa631c3db9290127d7ffbb1b"},{"version":"86d87a3ed7a7979485a61ee5a3ae3ce199b4ae67d0351570c76b54ceef7fac89","signature":"c41b8d6b4dc5220715c6f3bd7ffc8a4e6ec719a82b3d43e5ebe897ffbc74db94"},{"version":"8abd878edf3529a6ba9c4332d0574ef9eb4f7e024982c402aff517c9e8eb3377","signature":"692fa4feb19415d8f97cc48cc1156242259554cd2b76f71ac2f31a5643d9edae"},{"version":"b7526e02aa67018089c89ca3a874906be2544c9184a438367454f313c4541530","signature":"c0dd1588452e9ececf521b9f90f0694ff589be4c0c282660a0e09ad218e671a4"},{"version":"c0d1aa0482f61569e6bb4ccea948b22e0551812d21047a32770c2ecb4842e970","signature":"6b04076217e270b79065e1e1254dd6a36aed91477a89c33ec1e910d2366ccc64"},{"version":"412b29eac99c4fb5b9cdde05fbf313da9d78854f724b5039353c0478bdde3c4a","signature":"eea8ea594c95db2f51b41b63f5e1c26b0bae113ab681b2c45b66e6040ca66077"},{"version":"f9a8251a8fadffcd321da1db6de4351a68f6483c15bd4b351decfe6e0baaa742","signature":"90a8b386427c346a328c73e30d7ef5c48a76830598998e2a3115c60494d7fe2c"},{"version":"09d0411532006cd12b5138b6e81478271cc3348af59f54f74551178b073346f5","signature":"108f5d9b78ee3274deff2a67c838a9b55f7cce7531e00efcd06dafc9714a293b"},{"version":"b81692ed3cf6ea0d72b8783799a23da975abd7b0420a157dd1ffd9c11d4c00ce","signature":"ec5fed8b863bf1cca1310ae7eca191903f6bcd5825b2a5b5fcaee6dcfb806c59"},{"version":"686ceecb1e79fa4c4c1ea63a5211fe39933fb34abb8a36c121ff2e721b313a4c","signature":"71f5382a1b32738eadad057a07be724af646952edebe353440741310af89732b"},{"version":"65f1347c65f686439265e15fd964e5bd3ab37b709392056fffb5503e78aa7a76","signature":"6eb904a7b2b46ea6d96dc3e107cbb0310f3fe6933a2e56aad70cc58af40d18ae"},{"version":"6cb6c5d9b907270f533819bd21f1d12bca74402f242b5ccc66f71fa51876e683","signature":"d1f031dbab92fad6f1ce846d3fc93e14811a36fd1d31c5bae5fe2dd69dfdfa75"},{"version":"46f72b19c34a476fc472d965fe3f6a714e1c111bd048e55c666ad44b41ed0a6a","signature":"69d47da2a10388566f354505bc8d8bc658ed7354b5ebb092a8ae9e181af5d6ca"},"d88a5e779faf033be3d52142a04fbe1cb96009868e3bbdd296b2bc6c59e06c0e",{"version":"e7c44a15049b101c892b8a0c37ec3d4295f2cc0afe196fe0d9a8e90bb0d607a9","signature":"91205f8af5cac50a6b8afb1775a76218b7b36d87463c9434474a9f02d8035839"},{"version":"6b3ae16e022e27554be5262b22915d1ffd452fc97499276a909ba9e5bf009095","signature":"8f36da2c06a62c7c14b4a18eb2a0c97ab8ff3fed355c0eaf1cf62129faf8e67f"},{"version":"d907e4427ec084b74dabb167b5000016b06d3afd8621a842f2f1f8cab0154155","signature":"fc42ade730e2ce07d81d0581eb49139f1d236aabce2a7cfc6441e7685a314599"},{"version":"ed03ccc8b8e87e538f0c71a0a73ebabfc0e2035df3c166f274a3628433f4879a","signature":"43e818adf60173644896298637f47b01d5819b17eda46eaa32d0c7d64724d012"},"fbca5ffaebf282ec3cdac47b0d1d4a138a8b0bb32105251a38acb235087d3318","7e771891adaa85b690266bc37bd6eb43bc57eecc4b54693ead36467e7369952a","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"02873d070f9cb79f50833fbf4a9a27ac578a2edf8ddb8421eba1b37faba83bfb","affectsGlobalScope":true},"21a167fec8f933752fb8157f06d28fab6817af3ad9b0bdb1908a10762391eab9",{"version":"c0db280fa6b09d7b8d6720a19a47f485956a41ee0e6914f1b704033eb69c6058","affectsGlobalScope":true},"374ca798f244e464346f14301dc2a8b4b111af1a83b49fffef5906c338a1f922","5a94487653355b56018122d92392beb2e5f4a6c63ba5cef83bbe1c99775ef713",{"version":"d5135ad93b33adcce80b18f8065087934cdc1730d63db58562edcf017e1aad9b","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","dab86d9604fe40854ef3c0a6f9e8948873dc3509213418e5e457f410fd11200f","bb9c4ffa5e6290c6980b63c815cdd1625876dadb2efaf77edbe82984be93e55e","489532ff54b714f0e0939947a1c560e516d3ae93d51d639ab02e907a0e950114","f30bb836526d930a74593f7b0f5c1c46d10856415a8f69e5e2fc3db80371e362","14b5aa23c5d0ae1907bc696ac7b6915d88f7d85799cc0dc2dcf98fbce2c5a67c","5c439dafdc09abe4d6c260a96b822fa0ba5be7203c71a63ab1f1423cd9e838ea",{"version":"6b526a5ec4a401ca7c26cfe6a48e641d8f30af76673bad3b06a1b4504594a960","affectsGlobalScope":true},{"version":"816ad2e607a96de5bcac7d437f843f5afd8957f1fa5eefa6bba8e4ed7ca8fd84","affectsGlobalScope":true},"cec36af22f514322f870e81d30675c78df82ae8bf4863f5fd4e4424c040c678d","d903fafe96674bc0b2ac38a5be4a8fc07b14c2548d1cdb165a80ea24c44c0c54","5eec82ac21f84d83586c59a16b9b8502d34505d1393393556682fe7e7fde9ef2","04eb6578a588d6a46f50299b55f30e3a04ef27d0c5a46c57d8fcc211cd530faa","8d3c583a07e0c37e876908c2d5da575019f689df8d9fa4c081d99119d53dba22","2c828a5405191d006115ab34e191b8474bc6c86ffdc401d1a9864b1b6e088a58",{"version":"e630e5528e899219ae319e83bef54bf3bcb91b01d76861ecf881e8e614b167f0","affectsGlobalScope":true},"d4ac44f01d42f541631c5fc88d0ed8efac29a3a3ad9a745d9fd58f8b61ed132e","7c013aa892414a7fdcfd861ae524a668eaa3ede8c7c0acafaf611948122c8d93","b0973c3cbcdc59b37bf477731d468696ecaf442593ec51bab497a613a580fe30",{"version":"4989e92ba5b69b182d2caaea6295af52b7dc73a4f7a2e336a676722884e7139d","affectsGlobalScope":true},{"version":"b3624aed92dab6da8484280d3cb3e2f4130ec3f4ef3f8201c95144ae9e898bb6","affectsGlobalScope":true},"5153a2fd150e46ce57bb3f8db1318d33f6ad3261ed70ceeff92281c0608c74a3","210d54cd652ec0fec8c8916e4af59bb341065576ecda039842f9ffb2e908507c","36b03690b628eab08703d63f04eaa89c5df202e5f1edf3989f13ad389cd2c091","0effadd232a20498b11308058e334d3339cc5bf8c4c858393e38d9d4c0013dcf","25846d43937c672bab7e8195f3d881f93495df712ee901860effc109918938cc","3163f47436da41706c6e2b3c1511f3b7cce9f9f3905b2f3e01246c48b4ba7d14","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff","69ee23dd0d215b09907ad30d23f88b7790c93329d1faf31d7835552a10cf7cbf","44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","23b89798789dffbd437c0c423f5d02d11f9736aea73d6abf16db4f812ff36eda","223c37f62ce09a3d99e77498acdee7b2705a4ae14552fbdb4093600cd9164f3f",{"version":"970a90f76d4d219ad60819d61f5994514087ba94c985647a3474a5a3d12714ed","affectsGlobalScope":true},"e10177274a35a9d07c825615340b2fcde2f610f53f3fb40269fd196b4288dda6","4c8525f256873c7ba3135338c647eaf0ca7115a1a2805ae2d0056629461186ce","3c13ef48634e7b5012fcf7e8fce7496352c2d779a7201389ca96a2a81ee4314d","5d0a25ec910fa36595f85a67ac992d7a53dd4064a1ba6aea1c9f14ab73a023f2",{"version":"f0900cd5d00fe1263ff41201fb8073dbeb984397e4af3b8002a5c207a30bdc33","affectsGlobalScope":true},{"version":"4c50342e1b65d3bee2ed4ab18f84842d5724ad11083bd666d8705dc7a6079d80","affectsGlobalScope":true},"06d7c42d256f0ce6afe1b2b6cfbc97ab391f29dadb00dd0ae8e8f23f5bc916c3","ec4bd1b200670fb567920db572d6701ed42a9641d09c4ff6869768c8f81b404c","e59a892d87e72733e2a9ca21611b9beb52977be2696c7ba4b216cbbb9a48f5aa",{"version":"da26af7362f53d122283bc69fed862b9a9fe27e01bc6a69d1d682e0e5a4df3e6","affectsGlobalScope":true},"8a300fa9b698845a1f9c41ecbe2c5966634582a8e2020d51abcace9b55aa959e",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"652ee9c5103e89102d87bc20d167a02a0e3e5e53665674466c8cfea8a9e418c7"],"options":{"declaration":true,"downlevelIteration":true,"experimentalDecorators":true,"inlineSourceMap":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitAny":true,"noImplicitOverride":true,"noImplicitReturns":true,"noImplicitThis":true,"noPropertyAccessFromIndexSignature":true,"outDir":"./","strict":true,"target":2,"useUnknownInCatchVariables":true},"fileIdsList":[[54,127],[127],[81,127],[84,127],[85,90,118,127],[86,97,98,105,115,126,127],[86,87,97,105,127],[88,127],[89,90,98,106,127],[90,115,123,127],[91,93,97,105,127],[92,127],[93,94,127],[97,127],[95,97,127],[97,98,99,115,126,127],[97,98,99,112,115,118,127],[127,131],[93,100,105,115,126,127],[97,98,100,101,105,115,123,126,127],[100,102,115,123,126,127],[81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133],[97,103,127],[104,126,127],[93,97,105,115,127],[106,127],[107,127],[84,108,127],[109,125,127,131],[110,127],[111,127],[97,112,113,127],[112,114,127,129],[85,97,115,116,117,118,127],[85,115,117,127],[115,116,127],[118,127],[119,127],[97,121,122,127],[121,122,127],[90,105,115,123,127],[124,127],[105,125,127],[85,100,111,126,127],[90,127],[115,127,128],[127,129],[127,130],[85,90,97,99,108,115,126,127,129,131],[115,127,132],[55,127],[58,127],[56,59,64,107,127],[56,59,66,107,127],[56,59,61,67,68,106,107,127],[56,59,127],[56,58,59,64,69,70,107,127],[56,58,59,60,69,71,98,107,127],[56,57,59,63,64,65,127],[56,59,107,127],[56,59,62,63,64,66,127],[58,59,72,78,107,127],[57,98,107,127],[59,63,64,65,66,69,107,127],[64,71,107,127],[58,59,64,72,73,74,76,77,98,107,127],[58,59,61,75,98,127],[57,58,127],[98,107,127],[58],[56,64],[56,66],[56,67],[56],[56,58,64,69],[58,69,71],[56,63,64,65],[56,63,64,66],[65,66,69],[71],[58,72]],"referencedMap":[[55,1],[54,2],[80,2],[81,3],[82,3],[84,4],[85,5],[86,6],[87,7],[88,8],[89,9],[90,10],[91,11],[92,12],[93,13],[94,13],[96,14],[95,15],[97,14],[98,16],[99,17],[83,18],[133,2],[100,19],[101,20],[102,21],[134,22],[103,23],[104,24],[105,25],[106,26],[107,27],[108,28],[109,29],[110,30],[111,31],[112,32],[113,32],[114,33],[115,34],[117,35],[116,36],[118,37],[119,38],[120,2],[121,39],[122,40],[123,41],[124,42],[125,43],[126,44],[127,45],[128,46],[129,47],[130,48],[131,49],[132,50],[75,2],[57,2],[56,51],[12,2],[11,2],[2,2],[13,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[20,2],[3,2],[4,2],[24,2],[21,2],[22,2],[23,2],[25,2],[26,2],[27,2],[5,2],[28,2],[29,2],[30,2],[31,2],[6,2],[32,2],[33,2],[34,2],[35,2],[7,2],[36,2],[41,2],[42,2],[37,2],[38,2],[39,2],[40,2],[8,2],[46,2],[43,2],[44,2],[45,2],[47,2],[9,2],[48,2],[49,2],[50,2],[51,2],[52,2],[1,2],[10,2],[53,2],[60,52],[70,53],[67,54],[69,55],[62,56],[71,57],[72,58],[66,59],[68,60],[65,61],[63,2],[64,60],[79,62],[58,63],[73,64],[74,65],[78,66],[76,67],[77,2],[59,68],[61,69]],"exportedModulesMap":[[55,1],[54,2],[80,2],[81,3],[82,3],[84,4],[85,5],[86,6],[87,7],[88,8],[89,9],[90,10],[91,11],[92,12],[93,13],[94,13],[96,14],[95,15],[97,14],[98,16],[99,17],[83,18],[133,2],[100,19],[101,20],[102,21],[134,22],[103,23],[104,24],[105,25],[106,26],[107,27],[108,28],[109,29],[110,30],[111,31],[112,32],[113,32],[114,33],[115,34],[117,35],[116,36],[118,37],[119,38],[120,2],[121,39],[122,40],[123,41],[124,42],[125,43],[126,44],[127,45],[128,46],[129,47],[130,48],[131,49],[132,50],[75,2],[57,2],[56,51],[12,2],[11,2],[2,2],[13,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[20,2],[3,2],[4,2],[24,2],[21,2],[22,2],[23,2],[25,2],[26,2],[27,2],[5,2],[28,2],[29,2],[30,2],[31,2],[6,2],[32,2],[33,2],[34,2],[35,2],[7,2],[36,2],[41,2],[42,2],[37,2],[38,2],[39,2],[40,2],[8,2],[46,2],[43,2],[44,2],[45,2],[47,2],[9,2],[48,2],[49,2],[50,2],[51,2],[52,2],[1,2],[10,2],[53,2],[60,70],[70,71],[67,72],[69,73],[62,74],[71,75],[72,76],[66,77],[68,74],[65,78],[64,74],[73,79],[74,80],[78,81],[76,70]],"semanticDiagnosticsPerFile":[55,54,80,81,82,84,85,86,87,88,89,90,91,92,93,94,96,95,97,98,99,83,133,100,101,102,134,103,104,105,106,107,108,109,110,111,112,113,114,115,117,116,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,75,57,56,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,36,41,42,37,38,39,40,8,46,43,44,45,47,9,48,49,50,51,52,1,10,53,60,70,67,69,62,71,72,66,68,65,63,64,79,58,73,74,78,76,77,59,61]},"version":"4.8.4"}
@@ -0,0 +1,9 @@
1
+ export declare function findFileAbove(pattern: string | RegExp, dir: string): string | null;
2
+ /**
3
+ * Find all files matching a pattern, recursively
4
+ * @param pattern The pattern to look for
5
+ * @param dir The root directory to start searching from
6
+ * @param relative Get relative paths instead of absolute paths (default: true)
7
+ * @returns A list of paths
8
+ */
9
+ export declare function findFilesRecursive(pattern: string | RegExp, dir: string, relative?: boolean): string[];
package/build/utils.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findFilesRecursive = exports.findFileAbove = void 0;
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ function findFileAbove(pattern, dir) {
7
+ if (!path.isAbsolute(dir)) {
8
+ // Get an absolute path to allow getting its parent using path.dirname()
9
+ dir = path.resolve(process.cwd(), dir);
10
+ }
11
+ // The previous directory
12
+ // This is used to check if we reached the top-level directory ; for instance on Linux:
13
+ // > path.dirname('/') === '/'
14
+ // So if the previous directory and the current one are equal, this means we reached the top-level directory
15
+ let prevDir = dir;
16
+ let items = [];
17
+ // Search until we find the desired file
18
+ while ((items = fs.readdirSync(dir).filter((item) => (pattern instanceof RegExp ? pattern.exec(item) : pattern === item))).length === 0) {
19
+ // Get path to the parent directory
20
+ dir = path.dirname(dir);
21
+ // If the path is empty or equal to the previous path, we reached the top-level directory
22
+ if (!dir || prevDir === dir) {
23
+ return null;
24
+ }
25
+ prevDir = dir;
26
+ }
27
+ // Success!
28
+ return path.resolve(dir, items[0]);
29
+ }
30
+ exports.findFileAbove = findFileAbove;
31
+ /**
32
+ * Find all files matching a pattern, recursively
33
+ * @param pattern The pattern to look for
34
+ * @param dir The root directory to start searching from
35
+ * @param relative Get relative paths instead of absolute paths (default: true)
36
+ * @returns A list of paths
37
+ */
38
+ function findFilesRecursive(pattern, dir, relative = true) {
39
+ const cwd = process.cwd();
40
+ function find(pattern, rootDir, currDir) {
41
+ return fs
42
+ .readdirSync(currDir)
43
+ .map((item) => {
44
+ const fullPath = path.resolve(currDir, item);
45
+ return fs.lstatSync(fullPath).isDirectory()
46
+ ? find(pattern, rootDir, fullPath)
47
+ : (typeof pattern === 'string' ? item === pattern : pattern.exec(item))
48
+ ? [relative ? path.relative(rootDir, fullPath) : path.resolve(cwd, currDir, item)]
49
+ : [];
50
+ })
51
+ .flat();
52
+ }
53
+ return find(pattern, dir, dir);
54
+ }
55
+ exports.findFilesRecursive = findFilesRecursive;
56
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEseUJBQXdCO0FBQ3hCLDZCQUE0QjtBQUU1QixTQUFnQixhQUFhLENBQUMsT0FBd0IsRUFBRSxHQUFXO0lBQ2pFLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLEdBQUcsQ0FBQyxFQUFFO1FBQ3pCLHdFQUF3RTtRQUN4RSxHQUFHLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLEVBQUUsR0FBRyxDQUFDLENBQUE7S0FDdkM7SUFFRCx5QkFBeUI7SUFDekIsdUZBQXVGO0lBQ3ZGLDhCQUE4QjtJQUM5Qiw0R0FBNEc7SUFDNUcsSUFBSSxPQUFPLEdBQUcsR0FBRyxDQUFBO0lBRWpCLElBQUksS0FBSyxHQUFHLEVBQUUsQ0FBQTtJQUVkLHdDQUF3QztJQUN4QyxPQUFPLENBQUMsS0FBSyxHQU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EVBQUUsSUFBSSxDQUFDLENBQUE7WUFFNUMsT0FBTyxFQUFFLENBQUMsU0FBUyxDQUFDLFFBQVEsQ0FBQyxDQUFDLFdBQVcsRUFBRTtnQkFDekMsQ0FBQyxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUUsT0FBTyxFQUFFLFFBQVEsQ0FBQztnQkFDbEMsQ0FBQyxDQUFDLENBQUMsT0FBTyxPQUFPLEtBQUssUUFBUSxDQUFDLENBQUMsQ0FBQyxJQUFJLEtBQUssT0FBTyxDQUFDLENBQUMsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO29CQUN2RSxDQUFDLENBQUMsQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsT0FBTyxFQUFFLFFBQVEsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxPQUFPLEVBQUUsSUFBSSxDQUFDLENBQUM7b0JBQ2xGLENBQUMsQ0FBQyxFQUFFLENBQUE7UUFDUixDQUFDLENBQUM7YUFDRCxJQUFJLEVBQUUsQ0FBQTtJQUNYLENBQUM7SUFFRCxPQUFPLElBQUksQ0FBQyxPQUFPLEVBQUUsR0FBRyxFQUFFLEdBQUcsQ0FBQyxDQUFBO0FBQ2hDLENBQUM7QUFuQkQsZ0RBbUJDIn0=
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@buildvision/nest-sdk-generator",
3
+ "author": "BuildVision <christophe@buildvision.io>",
4
+ "version": "1.1.3",
5
+ "description": "A full-powered SDK generator for NestJS",
6
+ "keywords": [
7
+ "nest",
8
+ "nestjs",
9
+ "sdk",
10
+ "generator",
11
+ "typescript",
12
+ "frontend",
13
+ "api"
14
+ ],
15
+ "main": "build/bin.js",
16
+ "scripts": {
17
+ "prepare": "npm run build",
18
+ "build": "tsc -p tsconfig.json --outDir build",
19
+ "start": "npm run build && node build/bin.js"
20
+ },
21
+ "bin": "build/bin.js",
22
+ "dependencies": {
23
+ "chalk": "~4.1.2",
24
+ "minimist": "~1.2.7",
25
+ "prettier": "^2.7.1",
26
+ "ts-morph": "~16.0.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/minimist": "^1.2.2",
30
+ "@types/node": "~18.11.9",
31
+ "@types/prettier": "^2.7.1",
32
+ "typescript": "~4.8.4"
33
+ }
34
+ }
@@ -0,0 +1,9 @@
1
+ import { MagicType } from '../config'
2
+
3
+ export const builtinMagicTypes: MagicType[] = [
4
+ {
5
+ nodeModuleFilePath: '@mikro-orm/core/entity/Collection.d.ts',
6
+ typeName: 'Collection',
7
+ placeholderContent: 'export type Collection<T, _> = Array<T>;',
8
+ },
9
+ ]
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @file Analyze the dependencies of a class analyzed by the TypeScript compiler
3
+ */
4
+
5
+ import * as path from 'path'
6
+ import { ClassDeclaration, InterfaceDeclaration, ts, Type } from 'ts-morph'
7
+ import { unreachable } from '../logging'
8
+ import { ResolvedTypeDeps, resolveTypeDependencies } from './typedeps'
9
+
10
+ export function analyzeClassDeps(
11
+ decl: ClassDeclaration | InterfaceDeclaration,
12
+ relativeFilePath: string,
13
+ absoluteSrcPath: string
14
+ ): ResolvedTypeDeps[] {
15
+ if (path.isAbsolute(relativeFilePath)) {
16
+ unreachable(
17
+ 'Internal error: got absolute file path in class dependencies analyzer, when expecting a relative one (got {magentaBright})',
18
+ relativeFilePath
19
+ )
20
+ }
21
+
22
+ const toLookup = new Array<Type<ts.Type>>()
23
+
24
+ const superClasses = decl.getExtends()
25
+
26
+ if (superClasses) {
27
+ for (const sup of Array.isArray(superClasses) ? superClasses : [superClasses]) {
28
+ toLookup.push(sup.getType())
29
+ }
30
+ }
31
+
32
+ for (const prop of decl.getProperties()) {
33
+ toLookup.push(prop.getType())
34
+ }
35
+
36
+ return toLookup.map((typeText) => resolveTypeDependencies(typeText, relativeFilePath, absoluteSrcPath))
37
+ }
@@ -0,0 +1,135 @@
1
+ /**
2
+ * @file Analyzer for the source API's controllers (singles)
3
+ */
4
+
5
+ import * as path from 'path'
6
+ import { Node, Project } from 'ts-morph'
7
+ import { debug, warn } from '../logging'
8
+ import { analyzeMethods, SdkMethod } from './methods'
9
+
10
+ /**
11
+ * Convert a string to camel case
12
+ * @param str
13
+ */
14
+ function camelcase(str: string): string {
15
+ return str
16
+ .split(/[^a-zA-Z0-9_]/g)
17
+ .map((p, i) => {
18
+ const f = p.substr(0, 1)
19
+ return (i === 0 ? f.toLocaleLowerCase() : f.toLocaleUpperCase()) + p.substr(1)
20
+ })
21
+ .join('')
22
+ }
23
+
24
+ /**
25
+ * SDK interface of a controller
26
+ */
27
+ export interface SdkController {
28
+ /** Original controller file's path */
29
+ readonly path: string
30
+ /** Name of the controller's class, camel cased */
31
+ readonly camelClassName: string
32
+ /** Name the controller is registered under */
33
+ readonly registrationName: string
34
+ /** Controller's methods */
35
+ readonly methods: SdkMethod[]
36
+ }
37
+
38
+ /**
39
+ * Generate a SDK interface for a controller
40
+ * @param project TS-Morph project the controller is contained in
41
+ * @param controllerPath Path to the controller's file
42
+ * @param absoluteSrcPath Absolute path to the source directory
43
+ * @returns The SDK interface of the provided controller
44
+ */
45
+ export function analyzeController(project: Project, controllerPath: string, absoluteSrcPath: string): SdkController | null | Error {
46
+ debug('Analyzing: {yellow}', controllerPath)
47
+
48
+ // Prepare the source file to analyze
49
+ const file = project.getSourceFileOrThrow(path.resolve(absoluteSrcPath, controllerPath))
50
+
51
+ // Find the controller class declaration
52
+ const classDecl = file.forEachChildAsArray().find((node) => Node.isClassDeclaration(node))
53
+
54
+ if (!classDecl) {
55
+ warn('No controller found in this file.')
56
+ return null
57
+ }
58
+
59
+ if (!Node.isClassDeclaration(classDecl))
60
+ return new Error('Internal error: found class declaration statement which is not an instance of ClassDeclaration')
61
+
62
+ const className = classDecl.getName()
63
+
64
+ if (className === undefined) {
65
+ return new Error('Internal error: failed to retrieve name of declared class')
66
+ }
67
+
68
+ // By default, a controller is registered under its class name
69
+ // This is unless it provides an argument to its @Controller() decorator
70
+ let registrationName = camelcase(className)
71
+ let controllerUriPrefix: string | null = null
72
+
73
+ debug('Found class declaration: {yellow}', className)
74
+
75
+ // Get the @Controller() decorator
76
+ const decorator = classDecl.getDecorators().find((dec) => dec.getName() === 'Controller')
77
+
78
+ if (!decorator) {
79
+ warn('Skipping this controller as it does not have a @Controller() decorator')
80
+ return null
81
+ }
82
+
83
+ // Get the decorator's call expression
84
+ const decCallExpr = decorator.getCallExpression()
85
+
86
+ if (!decCallExpr) {
87
+ warn('Skipping this controller as its @Controller() decorator is not called')
88
+ return null
89
+ }
90
+
91
+ // Get the decorator's arguments
92
+ const decExpr = decCallExpr.getArguments()
93
+
94
+ if (decExpr.length > 1) {
95
+ warn('Skipping this controller as its @Controller() decorator is called with more than 1 argument')
96
+ return null
97
+ }
98
+
99
+ // Get the first argument, which is expected to be the controller's registration name
100
+ // Example: `@Controller("SuperName")` will register the controller under the name "SuperName"
101
+ if (decExpr[0]) {
102
+ const nameArg = decExpr[0]
103
+
104
+ // Variables are not supported
105
+ if (!Node.isStringLiteral(nameArg)) {
106
+ warn("Skipping this controller as its @Controller() decorator's argument is not a string literal")
107
+ return null
108
+ }
109
+
110
+ // Update the registration name
111
+ registrationName = camelcase(nameArg.getLiteralText())
112
+ controllerUriPrefix = registrationName
113
+ debug('Registering controller {yellow} as {yellow} (as specified in @Controller())', className, registrationName)
114
+ } else {
115
+ // No argument was provided to the @Controller() decorator, so we stick with the original controller's name
116
+ debug('@Controller() was called without argument, registering controller under name {yellow}', registrationName)
117
+ }
118
+
119
+ // Generate a SDK interface for the controller's methods
120
+ const methods = analyzeMethods(classDecl, controllerUriPrefix, controllerPath, absoluteSrcPath)
121
+
122
+ if (methods instanceof Error) {
123
+ return methods
124
+ }
125
+
126
+ // Success!
127
+ debug(`└─ Done for controller {yellow}`, controllerPath)
128
+
129
+ return {
130
+ path: controllerPath,
131
+ camelClassName: camelcase(className),
132
+ registrationName,
133
+ methods,
134
+ }
135
+ }