ts-morph-extensions 2.24.0-alpha.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 (70) hide show
  1. package/README.md +49 -0
  2. package/dist/dto/decorator.d.ts +8 -0
  3. package/dist/dto/decorator.d.ts.map +1 -0
  4. package/dist/dto/decorator.js +36 -0
  5. package/dist/dto/decorator.js.map +1 -0
  6. package/dist/dto/graph.d.ts +20 -0
  7. package/dist/dto/graph.d.ts.map +1 -0
  8. package/dist/dto/graph.js +66 -0
  9. package/dist/dto/graph.js.map +1 -0
  10. package/dist/dto/identifier.d.ts +9 -0
  11. package/dist/dto/identifier.d.ts.map +1 -0
  12. package/dist/dto/identifier.js +23 -0
  13. package/dist/dto/identifier.js.map +1 -0
  14. package/dist/dto/parameter.d.ts +10 -0
  15. package/dist/dto/parameter.d.ts.map +1 -0
  16. package/dist/dto/parameter.js +19 -0
  17. package/dist/dto/parameter.js.map +1 -0
  18. package/dist/dto/provider.d.ts +28 -0
  19. package/dist/dto/provider.d.ts.map +1 -0
  20. package/dist/dto/provider.js +62 -0
  21. package/dist/dto/provider.js.map +1 -0
  22. package/dist/index.d.ts +12 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +32 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/logger.d.ts +15 -0
  27. package/dist/logger.d.ts.map +1 -0
  28. package/dist/logger.js +28 -0
  29. package/dist/logger.js.map +1 -0
  30. package/dist/project/projectRegistry.d.ts +26 -0
  31. package/dist/project/projectRegistry.d.ts.map +1 -0
  32. package/dist/project/projectRegistry.js +130 -0
  33. package/dist/project/projectRegistry.js.map +1 -0
  34. package/dist/tsConfig/relativeToAbsolutePathConverter.d.ts +7 -0
  35. package/dist/tsConfig/relativeToAbsolutePathConverter.d.ts.map +1 -0
  36. package/dist/tsConfig/relativeToAbsolutePathConverter.js +72 -0
  37. package/dist/tsConfig/relativeToAbsolutePathConverter.js.map +1 -0
  38. package/dist/tsConfig/tsconfigParser.d.ts +35 -0
  39. package/dist/tsConfig/tsconfigParser.d.ts.map +1 -0
  40. package/dist/tsConfig/tsconfigParser.js +156 -0
  41. package/dist/tsConfig/tsconfigParser.js.map +1 -0
  42. package/dist/utils/dedupeSet.d.ts +5 -0
  43. package/dist/utils/dedupeSet.d.ts.map +1 -0
  44. package/dist/utils/dedupeSet.js +17 -0
  45. package/dist/utils/dedupeSet.js.map +1 -0
  46. package/dist/utils/fileSystem.d.ts +12 -0
  47. package/dist/utils/fileSystem.d.ts.map +1 -0
  48. package/dist/utils/fileSystem.js +73 -0
  49. package/dist/utils/fileSystem.js.map +1 -0
  50. package/dist/utils/objects.d.ts +2 -0
  51. package/dist/utils/objects.d.ts.map +1 -0
  52. package/dist/utils/objects.js +7 -0
  53. package/dist/utils/objects.js.map +1 -0
  54. package/dist/utils/ts/assertions.d.ts +3 -0
  55. package/dist/utils/ts/assertions.d.ts.map +1 -0
  56. package/dist/utils/ts/assertions.js +9 -0
  57. package/dist/utils/ts/assertions.js.map +1 -0
  58. package/dist/utils/ts/decorators.d.ts +8 -0
  59. package/dist/utils/ts/decorators.d.ts.map +1 -0
  60. package/dist/utils/ts/decorators.js +42 -0
  61. package/dist/utils/ts/decorators.js.map +1 -0
  62. package/dist/utils/ts/identifier.d.ts +3 -0
  63. package/dist/utils/ts/identifier.d.ts.map +1 -0
  64. package/dist/utils/ts/identifier.js +14 -0
  65. package/dist/utils/ts/identifier.js.map +1 -0
  66. package/dist/utils/ts/providers.d.ts +6 -0
  67. package/dist/utils/ts/providers.d.ts.map +1 -0
  68. package/dist/utils/ts/providers.js +29 -0
  69. package/dist/utils/ts/providers.js.map +1 -0
  70. package/package.json +25 -0
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ProjectRegistry = void 0;
37
+ const ts_morph_1 = require("ts-morph");
38
+ const path = __importStar(require("path"));
39
+ const fs = __importStar(require("fs"));
40
+ const logger_1 = require("../logger");
41
+ const tsconfigParser_1 = require("../tsConfig/tsconfigParser");
42
+ const os = __importStar(require("os"));
43
+ const fileSystem_1 = require("../utils/fileSystem");
44
+ class ProjectRegistry {
45
+ constructor(logger = new logger_1.NoOpLogger(), tsconfigParser = new tsconfigParser_1.TsConfigParser(), options) {
46
+ this.logger = logger;
47
+ this.tsconfigParser = tsconfigParser;
48
+ this.options = options;
49
+ this.projects = new Map();
50
+ this.tempFiles = new Set();
51
+ }
52
+ get(filePathOrUri) {
53
+ const filePath = this.normalizeFilePath(filePathOrUri);
54
+ const tsConfigPath = this.resolveTsConfigPath(filePath);
55
+ this.ensureProject(tsConfigPath);
56
+ return this.projects.get(tsConfigPath);
57
+ }
58
+ getSourceFile(filePathOrUri) {
59
+ const filePath = this.normalizeFilePath(filePathOrUri);
60
+ const project = this.get(filePathOrUri);
61
+ return project.getSourceFile(filePath);
62
+ }
63
+ getSourceFileOrThrow(filePathOrUri) {
64
+ const filePath = this.normalizeFilePath(filePathOrUri);
65
+ const project = this.get(filePathOrUri);
66
+ return project.getSourceFileOrThrow(filePath);
67
+ }
68
+ normalizeFilePath(filePathOrUri) {
69
+ return filePathOrUri.startsWith('file://') ? filePathOrUri.slice(7) : filePathOrUri;
70
+ }
71
+ ensureProject(tsConfigPath) {
72
+ if (!this.projects.has(tsConfigPath)) {
73
+ const tsConfig = this.tsconfigParser.parse(tsConfigPath);
74
+ this.logger.debug(`Parsed tsconfig: ${tsConfigPath}`);
75
+ const tempTsConfigPath = this.saveConfigToTempFile(tsConfig);
76
+ const project = new ts_morph_1.Project({ tsConfigFilePath: tempTsConfigPath });
77
+ this.projects.set(tsConfigPath, project);
78
+ }
79
+ }
80
+ saveConfigToTempFile(tsConfig) {
81
+ const tempDir = path.join(os.tmpdir(), 'obsidian-language-server');
82
+ const tempTsConfigPath = path.join(tempDir, `tsconfig-${Date.now()}.json`);
83
+ try {
84
+ (0, fileSystem_1.ensureDir)(tempDir);
85
+ (0, fileSystem_1.writeFile)(tempTsConfigPath, tsConfig);
86
+ this.tempFiles.add(tempTsConfigPath);
87
+ return tempTsConfigPath;
88
+ }
89
+ catch (error) {
90
+ this.logger.error(`Error writing tsconfig to temp file: ${error}`);
91
+ throw error;
92
+ }
93
+ }
94
+ resolveTsConfigPath(filePath) {
95
+ if (this.options?.overrideTsConfigPath)
96
+ return this.options.overrideTsConfigPath;
97
+ return this.findClosestTsConfig(filePath);
98
+ }
99
+ findClosestTsConfig(filePath) {
100
+ let dir = path.dirname(filePath);
101
+ while (dir !== path.parse(dir).root) {
102
+ const maybeTsConfigPath = path.join(dir, 'tsconfig.json');
103
+ if (fs.existsSync(maybeTsConfigPath)) {
104
+ return path.resolve(dir, maybeTsConfigPath);
105
+ }
106
+ dir = path.dirname(dir);
107
+ }
108
+ throw new Error(`Could not find tsconfig.json for file: ${filePath}`);
109
+ }
110
+ dispose() {
111
+ for (const tempFile of this.tempFiles) {
112
+ this.clearTempTsConfigFiles(tempFile);
113
+ }
114
+ this.tempFiles.clear();
115
+ this.projects.clear();
116
+ }
117
+ clearTempTsConfigFiles(tempFile) {
118
+ try {
119
+ if (fs.existsSync(tempFile)) {
120
+ fs.unlinkSync(tempFile);
121
+ this.logger.debug(`Cleaned up temporary tsconfig: ${tempFile}`);
122
+ }
123
+ }
124
+ catch (error) {
125
+ this.logger.error(`Error cleaning up temporary tsconfig ${tempFile}: ${error}`);
126
+ }
127
+ }
128
+ }
129
+ exports.ProjectRegistry = ProjectRegistry;
130
+ //# sourceMappingURL=projectRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectRegistry.js","sourceRoot":"","sources":["../../src/project/projectRegistry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAmC;AACnC,2CAA6B;AAC7B,uCAAyB;AACzB,sCAA+C;AAC/C,+DAAsE;AACtE,uCAAyB;AACzB,oDAA2D;AAM3D,MAAa,eAAe;IAI1B,YACmB,SAAiB,IAAI,mBAAU,EAAE,EACjC,iBAAiC,IAAI,+BAAc,EAAE,EACrD,OAAiB;QAFjB,WAAM,GAAN,MAAM,CAA2B;QACjC,mBAAc,GAAd,cAAc,CAAuC;QACrD,YAAO,GAAP,OAAO,CAAU;QANnB,aAAQ,GAAyB,IAAI,GAAG,EAAE,CAAC;QAC3C,cAAS,GAAgB,IAAI,GAAG,EAAE,CAAC;IAMhD,CAAC;IAEE,GAAG,CAAC,aAAqB;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACvD,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,QA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AAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;YAC9C,CAAC;YACD,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,0CAA0C,QAAQ,EAAE,CAAC,CAAC;IACxE,CAAC;IAEM,OAAO;QACZ,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEO,sBAAsB,CAAC,QAAgB;QAC7C,IAAI,CAAC;YACH,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC5B,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;gBACxB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,QAAQ,EAAE,CAAC,CAAC;YAClE,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wCAAwC,QAAQ,KAAK,KAAK,EAAE,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;CACF;AA5FD,0CA4FC"}
@@ -0,0 +1,7 @@
1
+ import { TsConfig } from "./tsconfigParser";
2
+ export declare class RelativeToAbsoluteConverter {
3
+ convert(config: TsConfig, baseDir: string): void;
4
+ private convertCompilerOptions;
5
+ private convertArrayProperties;
6
+ }
7
+ //# sourceMappingURL=relativeToAbsolutePathConverter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relativeToAbsolutePathConverter.d.ts","sourceRoot":"","sources":["../../src/tsConfig/relativeToAbsolutePathConverter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,qBAAa,2BAA2B;IAC/B,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM;IAKhD,OAAO,CAAC,sBAAsB;IAsB9B,OAAO,CAAC,sBAAsB;CAO/B"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.RelativeToAbsoluteConverter = void 0;
37
+ const path = __importStar(require("path"));
38
+ class RelativeToAbsoluteConverter {
39
+ convert(config, baseDir) {
40
+ this.convertArrayProperties(config, baseDir);
41
+ this.convertCompilerOptions(config, baseDir);
42
+ }
43
+ convertCompilerOptions(config, baseDir) {
44
+ const compilerOptions = config.compilerOptions;
45
+ if (compilerOptions) {
46
+ const pathOptions = ['baseUrl', 'outDir', 'rootDir'];
47
+ pathOptions.forEach(opt => {
48
+ if (typeof compilerOptions[opt] === 'string') {
49
+ compilerOptions[opt] = path.resolve(baseDir, compilerOptions[opt]);
50
+ }
51
+ });
52
+ // Handle paths mapping in compilerOptions
53
+ if (compilerOptions.paths) {
54
+ const paths = compilerOptions.paths;
55
+ for (const key in paths) {
56
+ if (Array.isArray(paths[key])) {
57
+ paths[key] = paths[key].map((p) => path.resolve(baseDir, p));
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ convertArrayProperties(config, baseDir) {
64
+ ['include', 'exclude', 'files'].forEach(key => {
65
+ if (Array.isArray(config[key])) {
66
+ config[key] = config[key].map(p => path.resolve(baseDir, p));
67
+ }
68
+ });
69
+ }
70
+ }
71
+ exports.RelativeToAbsoluteConverter = RelativeToAbsoluteConverter;
72
+ //# sourceMappingURL=relativeToAbsolutePathConverter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relativeToAbsolutePathConverter.js","sourceRoot":"","sources":["../../src/tsConfig/relativeToAbsolutePathConverter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAE7B,MAAa,2BAA2B;IAC/B,OAAO,CAAC,MAAgB,EAAE,OAAe;QAC9C,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAEO,sBAAsB,CAAC,MAAgB,EAAE,OAAe;QAC9D,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;QAC/C,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;YACrD,WAAW,CAAC,OAAO,CAAC,GAAG,C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string, any>;
4
+ include?: string[];
5
+ exclude?: string[];
6
+ files?: string[];
7
+ references?: {
8
+ path: string;
9
+ }[];
10
+ extends?: string;
11
+ [key: string]: any;
12
+ };
13
+ /**
14
+ * Parses a tsconfig file and returns a normalized tsconfig object.
15
+ *
16
+ * This class is responsible for:
17
+ * - Reading a tsconfig file
18
+ * - Converting relative paths to absolute paths
19
+ * - Merging composite tsconfig files (motivation: https://github.com/dsherret/ts-morph/issues/876)
20
+ * - Returning a normalized tsconfig object
21
+ */
22
+ export declare class TsConfigParser {
23
+ private readonly relativeToAbsoluteConverter;
24
+ constructor(relativeToAbsoluteConverter?: RelativeToAbsoluteConverter);
25
+ parse(configPath: string): TsConfig;
26
+ private handleConfigExtends;
27
+ private parseCompositeConfigFile;
28
+ private createEmptyConfig;
29
+ private isCompositeConfigFile;
30
+ private readJsonFile;
31
+ private mergeConfig;
32
+ private mergeArrayProperties;
33
+ private mergeConfigs;
34
+ }
35
+ //# sourceMappingURL=tsconfigParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfigParser.d.ts","sourceRoot":"","sources":["../../src/tsConfig/tsconfigParser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,MAAM,MAAM,QAAQ,GAAG;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;KAAE,EAAE,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAMF;;;;;;;;GAQG;AACH,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,2BAA2B;gBAA3B,2BAA2B,GAAE,2BAA+D;IAGxG,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ;IAa1C,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,wBAAwB;IAUhC,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,YAAY;CA0CrB"}
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.TsConfigParser = void 0;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const jsonc = __importStar(require("jsonc-parser"));
40
+ const relativeToAbsolutePathConverter_1 = require("./relativeToAbsolutePathConverter");
41
+ /**
42
+ * Parses a tsconfig file and returns a normalized tsconfig object.
43
+ *
44
+ * This class is responsible for:
45
+ * - Reading a tsconfig file
46
+ * - Converting relative paths to absolute paths
47
+ * - Merging composite tsconfig files (motivation: https://github.com/dsherret/ts-morph/issues/876)
48
+ * - Returning a normalized tsconfig object
49
+ */
50
+ class TsConfigParser {
51
+ constructor(relativeToAbsoluteConverter = new relativeToAbsolutePathConverter_1.RelativeToAbsoluteConverter()) {
52
+ this.relativeToAbsoluteConverter = relativeToAbsoluteConverter;
53
+ }
54
+ parse(configPath) {
55
+ const rootConfig = this.readJsonFile(configPath);
56
+ const baseDir = path.dirname(configPath);
57
+ const configWithoutExtends = this.handleConfigExtends(rootConfig, baseDir);
58
+ const tsConfig = this.isCompositeConfigFile(configWithoutExtends)
59
+ ? this.parseCompositeConfigFile(configWithoutExtends, baseDir)
60
+ : configWithoutExtends;
61
+ this.relativeToAbsoluteConverter.convert(tsConfig, baseDir);
62
+ return tsConfig;
63
+ }
64
+ handleConfigExtends(config, baseDir) {
65
+ if (!config.extends) {
66
+ return config;
67
+ }
68
+ const baseConfigPath = path.resolve(baseDir, config.extends);
69
+ const baseConfigDir = path.dirname(baseConfigPath);
70
+ const baseConfig = this.readJsonFile(baseConfigPath);
71
+ // Recursively handle extends in the base config
72
+ const resolvedBaseConfig = this.handleConfigExtends(baseConfig, baseConfigDir);
73
+ // Remove the extends property to prevent infinite loops
74
+ const { extends: _, ...configWithoutExtends } = config;
75
+ return this.mergeConfigs(resolvedBaseConfig, configWithoutExtends);
76
+ }
77
+ parseCompositeConfigFile(rootConfig, baseDir) {
78
+ let mergedConfig = this.createEmptyConfig();
79
+ for (const reference of rootConfig.references) {
80
+ const referencePath = path.resolve(baseDir, reference.path);
81
+ const referenceConfig = this.readJsonFile(referencePath);
82
+ this.mergeConfig(mergedConfig, referenceConfig);
83
+ }
84
+ return mergedConfig;
85
+ }
86
+ createEmptyConfig() {
87
+ return {
88
+ compilerOptions: {},
89
+ include: [],
90
+ exclude: [],
91
+ files: [],
92
+ };
93
+ }
94
+ isCompositeConfigFile(rootConfig) {
95
+ return Boolean(rootConfig.references && Array.isArray(rootConfig.references));
96
+ }
97
+ readJsonFile(filePath) {
98
+ const raw = fs.readFileSync(filePath, 'utf-8');
99
+ return jsonc.parse(raw);
100
+ }
101
+ mergeConfig(target, source) {
102
+ target.compilerOptions = {
103
+ ...target.compilerOptions,
104
+ ...source.compilerOptions,
105
+ };
106
+ this.mergeArrayProperties(target, source);
107
+ }
108
+ mergeArrayProperties(target, source) {
109
+ for (const key of ['include', 'exclude', 'files']) {
110
+ if (Array.isArray(source[key])) {
111
+ target[key] = Array.isArray(target[key])
112
+ ? [...new Set([...target[key], ...source[key]])]
113
+ : [...source[key]];
114
+ }
115
+ }
116
+ }
117
+ mergeConfigs(baseConfig, extendingConfig) {
118
+ // Create a new config object
119
+ const mergedConfig = { ...this.createEmptyConfig() };
120
+ // Merge compiler options
121
+ mergedConfig.compilerOptions = {
122
+ ...baseConfig.compilerOptions,
123
+ ...extendingConfig.compilerOptions,
124
+ };
125
+ // Merge array properties
126
+ for (const key of ['include', 'exclude', 'files']) {
127
+ mergedConfig[key] = [];
128
+ if (Array.isArray(baseConfig[key])) {
129
+ mergedConfig[key].push(...baseConfig[key]);
130
+ }
131
+ if (Array.isArray(extendingConfig[key])) {
132
+ mergedConfig[key].push(...extendingConfig[key]);
133
+ }
134
+ // Remove duplicates
135
+ if (mergedConfig[key].length > 0) {
136
+ mergedConfig[key] = [...new Set(mergedConfig[key])];
137
+ }
138
+ }
139
+ // Merge references
140
+ if (baseConfig.references || extendingConfig.references) {
141
+ mergedConfig.references = [
142
+ ...(baseConfig.references || []),
143
+ ...(extendingConfig.references || []),
144
+ ];
145
+ }
146
+ // Copy any other properties from the extending config
147
+ for (const key in extendingConfig) {
148
+ if (!['compilerOptions', 'include', 'exclude', 'files', 'references'].includes(key)) {
149
+ mergedConfig[key] = extendingConfig[key];
150
+ }
151
+ }
152
+ return mergedConfig;
153
+ }
154
+ }
155
+ exports.TsConfigParser = TsConfigParser;
156
+ //# sourceMappingURL=tsconfigParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfigParser.js","sourceRoot":"","sources":["../../src/tsConfig/tsconfigParser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,oDAAsC;AACtC,uFAAgF;AAgBhF;;;;;;;;GAQG;AACH,MAAa,cAAc;IACzB,YACmB,8BAA2D,IAAI,6DAA2B,EAAE;QAA5F,gCAA2B,GAA3B,2BAA2B,CAAiE;IAC3G,CAAC;IAEE,KAAK,CAAC,UAAkB;QAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAEzC,MAAM,oBAAoB,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAE3E,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,oBAAoB,CAAC;YAC/D,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,oBAAoB,EAAE,OAAO,CAAC;YAC9D,CAAC,CAAC,oBAAoB,CAAC;QACzB,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC5D,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,mBAAmB,CAAC,MAAgB,EAAE,OAAe;QAC3D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,cAAc,GAAG,I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@@
1
+ export declare class DedupeSet<T = string> {
2
+ private set;
3
+ dedupe: (item: T) => boolean;
4
+ }
5
+ //# sourceMappingURL=dedupeSet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedupeSet.d.ts","sourceRoot":"","sources":["../../src/utils/dedupeSet.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAS,CAAC,CAAC,GAAG,MAAM;IAC/B,OAAO,CAAC,GAAG,CAAgB;IAEpB,MAAM,GAAI,MAAM,CAAC,aAMtB;CACH"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DedupeSet = void 0;
4
+ class DedupeSet {
5
+ constructor() {
6
+ this.set = new Set();
7
+ this.dedupe = (item) => {
8
+ if (this.set.has(item)) {
9
+ return false;
10
+ }
11
+ this.set.add(item);
12
+ return true;
13
+ };
14
+ }
15
+ }
16
+ exports.DedupeSet = DedupeSet;
17
+ //# sourceMappingURL=dedupeSet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedupeSet.js","sourceRoot":"","sources":["../../src/utils/dedupeSet.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAS;IAAtB;QACU,QAAG,GAAG,IAAI,GAAG,EAAK,CAAC;QAEpB,WAAM,GAAG,CAAC,IAAO,EAAE,EAAE;YAC1B,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IACJ,CAAC;CAAA;AAVD,8BAUC"}
@@ -0,0 +1,12 @@
1
+ export declare const EXTENSIONS: string[];
2
+ export declare function ensureDir(dir: string): void;
3
+ export declare function writeFile(filePath: string, content: any): void;
4
+ /**
5
+ * Resolves a file path by checking if it exists with any of the common TypeScript/JavaScript extensions.
6
+ * If no file is found with any extension, returns the path with .ts extension as fallback.
7
+ * If the path already ends with a valid extension, returns it as is.
8
+ * @param basePath The path to resolve
9
+ * @returns The resolved path with the correct extension
10
+ */
11
+ export declare function resolveFileExtension(basePath: string): string;
12
+ //# sourceMappingURL=fileSystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSystem.d.ts","sourceRoot":"","sources":["../../src/utils/fileSystem.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,UAAiD,CAAC;AAEzE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,QAIpC;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,QAGvD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgB7D"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.EXTENSIONS = void 0;
37
+ exports.ensureDir = ensureDir;
38
+ exports.writeFile = writeFile;
39
+ exports.resolveFileExtension = resolveFileExtension;
40
+ const fs = __importStar(require("fs"));
41
+ exports.EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'];
42
+ function ensureDir(dir) {
43
+ if (!fs.existsSync(dir)) {
44
+ fs.mkdirSync(dir, { recursive: true });
45
+ }
46
+ }
47
+ function writeFile(filePath, content) {
48
+ const stringContent = typeof content === 'string' ? content : JSON.stringify(content);
49
+ fs.writeFileSync(filePath, stringContent);
50
+ }
51
+ /**
52
+ * Resolves a file path by checking if it exists with any of the common TypeScript/JavaScript extensions.
53
+ * If no file is found with any extension, returns the path with .ts extension as fallback.
54
+ * If the path already ends with a valid extension, returns it as is.
55
+ * @param basePath The path to resolve
56
+ * @returns The resolved path with the correct extension
57
+ */
58
+ function resolveFileExtension(basePath) {
59
+ // Check if the path already ends with a valid extension
60
+ if (exports.EXTENSIONS.some(ext => basePath.endsWith(ext))) {
61
+ return basePath;
62
+ }
63
+ // Try to find the file with any of the extensions
64
+ for (const ext of exports.EXTENSIONS) {
65
+ const fullPath = `${basePath}${ext}`;
66
+ if (fs.existsSync(fullPath)) {
67
+ return fullPath;
68
+ }
69
+ }
70
+ // If no file found with any extension, return with .ts as fallback
71
+ return `${basePath}.ts`;
72
+ }
73
+ //# sourceMappingURL=fileSystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSystem.js","sourceRoot":"","sources":["../../src/utils/fileSystem.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,8BAIC;AAED,8BAGC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version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../src/utils/objects.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAE9D"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDefined = isDefined;
4
+ function isDefined(value) {
5
+ return value !== undefined && value !== null;
6
+ }
7
+ //# sourceMappingURL=objects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objects.js","sourceRoot":"","sources":["../../src/utils/objects.ts"],"names":[],"mappings":";;AAAA,8BAEC;AAFD,SAAgB,SAAS,CAAI,KAAQ;IACnC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Identifier, Node } from "ts-morph";
2
+ export declare function assertIdentifier(node: Node): asserts node is Identifier;
3
+ //# sourceMappingURL=assertions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../../src/utils/ts/assertions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAE5C,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,UAAU,CAEvE"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertIdentifier = assertIdentifier;
4
+ const ts_morph_1 = require("ts-morph");
5
+ function assertIdentifier(node) {
6
+ if (!ts_morph_1.Node.isIdentifier(node))
7
+ throw new Error(`Expected identifier, got ${node.getKindName()} (${node.getText()})`);
8
+ }
9
+ //# sourceMappingURL=assertions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../../src/utils/ts/assertions.ts"],"names":[],"mappings":";;AAEA,4CAEC;AAJD,uCAA4C;AAE5C,SAAgB,gBAAgB,CAAC,IAAU;IACzC,IAAI,CAAC,eAAI,CAAC,YAAY,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AACtH,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Decorator } from '../../dto/decorator';
2
+ import { Node, MethodDeclaration, ClassDeclaration } from 'ts-morph';
3
+ export declare function hasDecorator(node: MethodDeclaration | undefined, decoratorNames: string[]): boolean;
4
+ export declare function getDecorator(node: MethodDeclaration | ClassDeclaration | undefined, decoratorNames: string[]): Decorator | undefined;
5
+ export declare function hasParentWithDecorator(node: Node | undefined, decoratorNames: string[]): boolean;
6
+ export declare function hasGraphDecorator(node: Node | undefined): boolean;
7
+ export declare function getDecoratedMethods(node: Node, decoratorNames: string[]): MethodDeclaration[];
8
+ //# sourceMappingURL=decorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/utils/ts/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAc,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjF,wBAAgB,YAAY,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,OAAO,CAEnG;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,SAAS,CAQpI;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,OAAO,CAKhG;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAGjE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,iBAAiB,EAAE,CAK7F"}