@odata2ts/odata2ts 0.36.2 → 0.37.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.
Files changed (132) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/lib/FactoryFunctionModel.d.ts +5 -5
  3. package/lib/FactoryFunctionModel.js +1 -2
  4. package/lib/FactoryFunctionModel.js.map +1 -1
  5. package/lib/NamingModel.js +2 -5
  6. package/lib/NamingModel.js.map +1 -1
  7. package/lib/OptionModel.d.ts +2 -2
  8. package/lib/OptionModel.js +4 -7
  9. package/lib/OptionModel.js.map +1 -1
  10. package/lib/TypeModel.js +2 -5
  11. package/lib/TypeModel.js.map +1 -1
  12. package/lib/app.d.ts +2 -2
  13. package/lib/app.js +23 -27
  14. package/lib/app.js.map +1 -1
  15. package/lib/cli/cli.d.ts +1 -0
  16. package/lib/cli/cli.js +27 -0
  17. package/lib/cli/cli.js.map +1 -0
  18. package/lib/cli/index.d.ts +4 -0
  19. package/lib/cli/index.js +5 -0
  20. package/lib/cli/index.js.map +1 -0
  21. package/lib/cli/processCliArgs.d.ts +2 -0
  22. package/lib/cli/processCliArgs.js +57 -0
  23. package/lib/cli/processCliArgs.js.map +1 -0
  24. package/lib/cli/processConfigFile.d.ts +2 -0
  25. package/lib/cli/processConfigFile.js +24 -0
  26. package/lib/cli/processConfigFile.js.map +1 -0
  27. package/lib/cli/serviceGenerationRun.d.ts +2 -0
  28. package/lib/cli/serviceGenerationRun.js +77 -0
  29. package/lib/cli/serviceGenerationRun.js.map +1 -0
  30. package/lib/data-model/DataModel.d.ts +2 -2
  31. package/lib/data-model/DataModel.js +5 -10
  32. package/lib/data-model/DataModel.js.map +1 -1
  33. package/lib/data-model/DataModelDigestion.d.ts +10 -10
  34. package/lib/data-model/DataModelDigestion.js +19 -23
  35. package/lib/data-model/DataModelDigestion.js.map +1 -1
  36. package/lib/data-model/DataModelDigestionV2.d.ts +2 -2
  37. package/lib/data-model/DataModelDigestionV2.js +27 -31
  38. package/lib/data-model/DataModelDigestionV2.js.map +1 -1
  39. package/lib/data-model/DataModelDigestionV4.d.ts +2 -2
  40. package/lib/data-model/DataModelDigestionV4.js +38 -35
  41. package/lib/data-model/DataModelDigestionV4.js.map +1 -1
  42. package/lib/data-model/DataTypeModel.d.ts +1 -1
  43. package/lib/data-model/DataTypeModel.js +2 -5
  44. package/lib/data-model/DataTypeModel.js.map +1 -1
  45. package/lib/data-model/NamingHelper.d.ts +2 -2
  46. package/lib/data-model/NamingHelper.js +12 -19
  47. package/lib/data-model/NamingHelper.js.map +1 -1
  48. package/lib/data-model/ServiceConfigHelper.d.ts +3 -3
  49. package/lib/data-model/ServiceConfigHelper.js +18 -22
  50. package/lib/data-model/ServiceConfigHelper.js.map +1 -1
  51. package/lib/data-model/edmx/ODataEdmxModelBase.js +1 -2
  52. package/lib/data-model/edmx/ODataEdmxModelV3.d.ts +1 -1
  53. package/lib/data-model/edmx/ODataEdmxModelV3.js +1 -2
  54. package/lib/data-model/edmx/ODataEdmxModelV3.js.map +1 -1
  55. package/lib/data-model/edmx/ODataEdmxModelV4.d.ts +1 -1
  56. package/lib/data-model/edmx/ODataEdmxModelV4.js +1 -2
  57. package/lib/data-model/edmx/ODataEdmxModelV4.js.map +1 -1
  58. package/lib/data-model/validation/NameClashValidator.d.ts +2 -2
  59. package/lib/data-model/validation/NameClashValidator.js +10 -14
  60. package/lib/data-model/validation/NameClashValidator.js.map +1 -1
  61. package/lib/data-model/validation/NameValidator.d.ts +1 -1
  62. package/lib/data-model/validation/NameValidator.js +1 -2
  63. package/lib/data-model/validation/NameValidator.js.map +1 -1
  64. package/lib/data-model/validation/NoopValidator.d.ts +1 -1
  65. package/lib/data-model/validation/NoopValidator.js +1 -5
  66. package/lib/data-model/validation/NoopValidator.js.map +1 -1
  67. package/lib/defaultConfig.d.ts +1 -1
  68. package/lib/defaultConfig.js +21 -26
  69. package/lib/defaultConfig.js.map +1 -1
  70. package/lib/download/downloadMetadata.d.ts +1 -1
  71. package/lib/download/downloadMetadata.js +6 -10
  72. package/lib/download/downloadMetadata.js.map +1 -1
  73. package/lib/download/index.d.ts +2 -2
  74. package/lib/download/index.js +2 -7
  75. package/lib/download/index.js.map +1 -1
  76. package/lib/download/storeMetadata.js +15 -17
  77. package/lib/download/storeMetadata.js.map +1 -1
  78. package/lib/evaluateConfig.d.ts +1 -1
  79. package/lib/evaluateConfig.js +14 -18
  80. package/lib/evaluateConfig.js.map +1 -1
  81. package/lib/generator/ImportContainer.d.ts +2 -2
  82. package/lib/generator/ImportContainer.js +17 -22
  83. package/lib/generator/ImportContainer.js.map +1 -1
  84. package/lib/generator/ImportedNameValidator.js +1 -5
  85. package/lib/generator/ImportedNameValidator.js.map +1 -1
  86. package/lib/generator/ModelGenerator.d.ts +1 -1
  87. package/lib/generator/ModelGenerator.js +8 -12
  88. package/lib/generator/ModelGenerator.js.map +1 -1
  89. package/lib/generator/QueryObjectGenerator.d.ts +1 -1
  90. package/lib/generator/QueryObjectGenerator.js +25 -29
  91. package/lib/generator/QueryObjectGenerator.js.map +1 -1
  92. package/lib/generator/ServiceGenerator.d.ts +4 -4
  93. package/lib/generator/ServiceGenerator.js +52 -56
  94. package/lib/generator/ServiceGenerator.js.map +1 -1
  95. package/lib/generator/import/ImportObjects.js +11 -14
  96. package/lib/generator/import/ImportObjects.js.map +1 -1
  97. package/lib/generator/index.d.ts +3 -3
  98. package/lib/generator/index.js +3 -9
  99. package/lib/generator/index.js.map +1 -1
  100. package/lib/index.d.ts +4 -4
  101. package/lib/index.js +4 -7
  102. package/lib/index.js.map +1 -1
  103. package/lib/project/FileHandler.d.ts +3 -3
  104. package/lib/project/FileHandler.js +12 -16
  105. package/lib/project/FileHandler.js.map +1 -1
  106. package/lib/project/ProjectManager.d.ts +5 -5
  107. package/lib/project/ProjectManager.js +25 -32
  108. package/lib/project/ProjectManager.js.map +1 -1
  109. package/lib/project/TsMorphHelper.d.ts +1 -1
  110. package/lib/project/TsMorphHelper.js +21 -22
  111. package/lib/project/TsMorphHelper.js.map +1 -1
  112. package/lib/project/formatter/BaseFormatter.d.ts +1 -1
  113. package/lib/project/formatter/BaseFormatter.js +1 -5
  114. package/lib/project/formatter/BaseFormatter.js.map +1 -1
  115. package/lib/project/formatter/FileFormatter.js +1 -2
  116. package/lib/project/formatter/NoopFormatter.d.ts +1 -1
  117. package/lib/project/formatter/NoopFormatter.js +5 -9
  118. package/lib/project/formatter/NoopFormatter.js.map +1 -1
  119. package/lib/project/formatter/PrettierFormatter.d.ts +1 -1
  120. package/lib/project/formatter/PrettierFormatter.js +20 -25
  121. package/lib/project/formatter/PrettierFormatter.js.map +1 -1
  122. package/lib/project/formatter/index.d.ts +1 -1
  123. package/lib/project/formatter/index.js +6 -10
  124. package/lib/project/formatter/index.js.map +1 -1
  125. package/lib/project/logger/logFilePath.js +4 -9
  126. package/lib/project/logger/logFilePath.js.map +1 -1
  127. package/lib/run-cli.js +2 -4
  128. package/lib/run-cli.js.map +1 -1
  129. package/package.json +53 -63
  130. package/lib/cli.d.ts +0 -3
  131. package/lib/cli.js +0 -176
  132. package/lib/cli.js.map +0 -1
@@ -1,3 +1,3 @@
1
- export { generateModels } from "./ModelGenerator";
2
- export { generateQueryObjects } from "./QueryObjectGenerator";
3
- export { generateServices } from "./ServiceGenerator";
1
+ export { generateModels } from "./ModelGenerator.js";
2
+ export { generateQueryObjects } from "./QueryObjectGenerator.js";
3
+ export { generateServices } from "./ServiceGenerator.js";
@@ -1,10 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateServices = exports.generateQueryObjects = exports.generateModels = void 0;
4
- var ModelGenerator_1 = require("./ModelGenerator");
5
- Object.defineProperty(exports, "generateModels", { enumerable: true, get: function () { return ModelGenerator_1.generateModels; } });
6
- var QueryObjectGenerator_1 = require("./QueryObjectGenerator");
7
- Object.defineProperty(exports, "generateQueryObjects", { enumerable: true, get: function () { return QueryObjectGenerator_1.generateQueryObjects; } });
8
- var ServiceGenerator_1 = require("./ServiceGenerator");
9
- Object.defineProperty(exports, "generateServices", { enumerable: true, get: function () { return ServiceGenerator_1.generateServices; } });
1
+ export { generateModels } from "./ModelGenerator.js";
2
+ export { generateQueryObjects } from "./QueryObjectGenerator.js";
3
+ export { generateServices } from "./ServiceGenerator.js";
10
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA","sourcesContent":["export { generateModels } from \"./ModelGenerator\";\r\nexport { generateQueryObjects } from \"./QueryObjectGenerator\";\r\nexport { generateServices } from \"./ServiceGenerator\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["export { generateModels } from \"./ModelGenerator.js\";\r\nexport { generateQueryObjects } from \"./QueryObjectGenerator.js\";\r\nexport { generateServices } from \"./ServiceGenerator.js\";\r\n"]}
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from "./OptionModel";
2
- export * from "./NamingModel";
3
- export * from "./defaultConfig";
4
- export * from "./TypeModel";
1
+ export * from "./OptionModel.js";
2
+ export * from "./NamingModel.js";
3
+ export * from "./defaultConfig.js";
4
+ export * from "./TypeModel.js";
package/lib/index.js CHANGED
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./OptionModel"), exports);
5
- tslib_1.__exportStar(require("./NamingModel"), exports);
6
- tslib_1.__exportStar(require("./defaultConfig"), exports);
7
- tslib_1.__exportStar(require("./TypeModel"), exports);
1
+ export * from "./OptionModel.js";
2
+ export * from "./NamingModel.js";
3
+ export * from "./defaultConfig.js";
4
+ export * from "./TypeModel.js";
8
5
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,wDAA8B;AAC9B,0DAAgC;AAChC,sDAA4B","sourcesContent":["export * from \"./OptionModel\";\r\nexport * from \"./NamingModel\";\r\nexport * from \"./defaultConfig\";\r\nexport * from \"./TypeModel\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC","sourcesContent":["export * from \"./OptionModel.js\";\r\nexport * from \"./NamingModel.js\";\r\nexport * from \"./defaultConfig.js\";\r\nexport * from \"./TypeModel.js\";\r\n"]}
@@ -1,7 +1,7 @@
1
1
  import { SourceFile } from "ts-morph";
2
- import { ImportContainer } from "../generator/ImportContainer";
3
- import { EmitModes } from "../OptionModel";
4
- import { FileFormatter } from "./formatter/FileFormatter";
2
+ import { ImportContainer } from "../generator/ImportContainer.js";
3
+ import { EmitModes } from "../OptionModel.js";
4
+ import { FileFormatter } from "./formatter/FileFormatter.js";
5
5
  export declare class FileHandler {
6
6
  readonly path: string;
7
7
  readonly fileName: string;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileHandler = void 0;
4
- const tslib_1 = require("tslib");
5
- const promises_1 = require("fs/promises");
6
- const OptionModel_1 = require("../OptionModel");
7
- class FileHandler {
1
+ import { __awaiter } from "tslib";
2
+ import { writeFile } from "fs/promises";
3
+ import { EmitModes } from "../OptionModel.js";
4
+ export class FileHandler {
8
5
  constructor(path, fileName, file, importContainer, formatter, allowTypeChecking) {
9
6
  this.path = path;
10
7
  this.fileName = fileName;
@@ -23,7 +20,7 @@ class FileHandler {
23
20
  return this.importContainer;
24
21
  }
25
22
  write(emitMode, noOutput = false) {
26
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ return __awaiter(this, void 0, void 0, function* () {
27
24
  this.file.addImportDeclarations(this.importContainer.getImportDeclarations());
28
25
  // add ts-nocheck to beginning of each file
29
26
  if (!this.allowTypeChecking) {
@@ -36,12 +33,12 @@ class FileHandler {
36
33
  return;
37
34
  }
38
35
  switch (emitMode) {
39
- case OptionModel_1.EmitModes.js:
40
- case OptionModel_1.EmitModes.js_dts:
36
+ case EmitModes.js:
37
+ case EmitModes.js_dts:
41
38
  return this.file.emit();
42
- case OptionModel_1.EmitModes.dts:
39
+ case EmitModes.dts:
43
40
  return this.file.emit({ emitOnlyDtsFiles: true });
44
- case OptionModel_1.EmitModes.ts:
41
+ case EmitModes.ts:
45
42
  return this.formatAndWriteFile();
46
43
  default:
47
44
  throw new Error(`Emit mode "${emitMode}" is invalid!`);
@@ -49,13 +46,13 @@ class FileHandler {
49
46
  });
50
47
  }
51
48
  formatAndWriteFile() {
52
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
49
+ return __awaiter(this, void 0, void 0, function* () {
53
50
  const fileName = this.file.getFilePath();
54
51
  const content = this.file.getFullText();
55
52
  try {
56
53
  const formatted = this.formatter ? yield this.formatter.format(content) : content;
57
54
  try {
58
- return (0, promises_1.writeFile)(fileName, formatted);
55
+ return writeFile(fileName, formatted);
59
56
  }
60
57
  catch (writeError) {
61
58
  console.error(`Failed to write file [/${fileName}]`, writeError);
@@ -64,11 +61,10 @@ class FileHandler {
64
61
  }
65
62
  catch (formattingError) {
66
63
  console.error("Formatting failed", formattingError);
67
- yield (0, promises_1.writeFile)("error.log", (formattingError === null || formattingError === void 0 ? void 0 : formattingError.toString()) || "no error message!");
64
+ yield writeFile("error.log", (formattingError === null || formattingError === void 0 ? void 0 : formattingError.toString()) || "no error message!");
68
65
  process.exit(99);
69
66
  }
70
67
  });
71
68
  }
72
69
  }
73
- exports.FileHandler = FileHandler;
74
70
  //# sourceMappingURL=FileHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileHandler.js","sourceRoot":"","sources":["../../src/project/FileHandler.ts"],"names":[],"mappings":";;;;AAAA,0CAAwC;AAKxC,gDAA2C;AAG3C,MAAa,WAAW;IACtB,YACkB,IAAY,EACZ,QAAgB,EACb,IAAgB,EAChB,eAAgC,EACzC,SAAoC,EAC9B,iBAA0B;QAL1B,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAY;QAChB,oBAAe,GAAf,eAAe,CAAiB;QACzC,cAAS,GAAT,SAAS,CAA2B;QAC9B,sBAAiB,GAAjB,iBAAiB,CAAS;IACzC,CAAC;IAEG,eAAe;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IACrE,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEM,UAAU;QACf,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAEY,KAAK,CAAC,QAAmB,EAAE,QAAQ,GAAG,KAAK;;YACtD,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,eAAe,CAAC,qBAAqB,EAAE,CAAC,CAAC;YAC9E,2CAA2C;YAC3C,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;gBAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,EAAE,EAAE;oB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AAC,KAAK,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;gBACpD,MAAM,IAAA,oBAAS,EAAC,WAAW,EAAE,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,EAAE,KAAI,mBAAmB,CAAC,CAAC;gBACjF,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;aAClB;QACH,CAAC;KAAA;CACF;AApED,kCAoEC","sourcesContent":["import { writeFile } from \"fs/promises\";\r\n\r\nimport { SourceFile } from \"ts-morph\";\r\n\r\nimport { ImportContainer } from \"../generator/ImportContainer\";\r\nimport { EmitModes } from \"../OptionModel\";\r\nimport { FileFormatter } from \"./formatter/FileFormatter\";\r\n\r\nexport class FileHandler {\r\n constructor(\r\n public readonly path: string,\r\n public readonly fileName: string,\r\n protected readonly file: SourceFile,\r\n protected readonly importContainer: ImportContainer,\r\n protected formatter: FileFormatter | undefined,\r\n public readonly allowTypeChecking: boolean\r\n ) {}\r\n\r\n public getFullFilePath() {\r\n return this.path ? `${this.path}/${this.fileName}` : this.fileName;\r\n }\r\n\r\n public getFile() {\r\n return this.file;\r\n }\r\n\r\n public getImports() {\r\n return this.importContainer;\r\n }\r\n\r\n public async write(emitMode: EmitModes, noOutput = false) {\r\n this.file.addImportDeclarations(this.importContainer.getImportDeclarations());\r\n // add ts-nocheck to beginning of each file\r\n if (!this.allowTypeChecking) {\r\n const stmts = this.file.addStatements((writer) => {\r\n writer.writeLine(\"// @ts-nocheck\");\r\n });\r\n stmts[0].setOrder(0);\r\n }\r\n\r\n if (noOutput) {\r\n return;\r\n }\r\n\r\n switch (emitMode) {\r\n case EmitModes.js:\r\n case EmitModes.js_dts:\r\n return this.file.emit();\r\n case EmitModes.dts:\r\n return this.file.emit({ emitOnlyDtsFiles: true });\r\n case EmitModes.ts:\r\n return this.formatAndWriteFile();\r\n default:\r\n throw new Error(`Emit mode \"${emitMode}\" is invalid!`);\r\n }\r\n }\r\n\r\n private async formatAndWriteFile() {\r\n const fileName = this.file.getFilePath();\r\n const content = this.file.getFullText();\r\n\r\n try {\r\n const formatted = this.formatter ? await this.formatter.format(content) : content;\r\n\r\n try {\r\n return writeFile(fileName, formatted);\r\n } catch (writeError) {\r\n console.error(`Failed to write file [/${fileName}]`, writeError);\r\n process.exit(3);\r\n }\r\n } catch (formattingError) {\r\n console.error(\"Formatting failed\", formattingError);\r\n await writeFile(\"error.log\", formattingError?.toString() || \"no error message!\");\r\n process.exit(99);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"FileHandler.js","sourceRoot":"","sources":["../../src/project/FileHandler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAKxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,MAAM,OAAO,WAAW;IACtB,YACkB,IAAY,EACZ,QAAgB,EACb,IAAgB,EAChB,eAAgC,EACzC,SAAoC,EAC9B,iBAA0B;QAL1B,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAY;QAChB,oBAAe,GAAf,eAAe,CAAiB;QACzC,cAAS,GAAT,SAAS,CAA2B;QAC9B,sBAAiB,GAAjB,iBAAiB,CAAS;IACzC,CAAC;IAEG,eAAe;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IACrE,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEM,UAAU;QACf,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAEY,KAAK,CAAC,QAAmB,EAAE,QAAQ,GAAG,KAAK;;YACtD,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,eAAe,CAAC,qBAAqB,E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AK,CAAC,0BAA0B,QAAQ,GAAG,EAAE,UAAU,CAAC,CAAC;oBACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBACjB;aACF;YAAC,OAAO,eAAe,EAAE;gBACxB,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;gBACpD,MAAM,SAAS,CAAC,WAAW,EAAE,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,EAAE,KAAI,mBAAmB,CAAC,CAAC;gBACjF,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;aAClB;QACH,CAAC;KAAA;CACF","sourcesContent":["import { writeFile } from \"fs/promises\";\r\n\r\nimport { SourceFile } from \"ts-morph\";\r\n\r\nimport { ImportContainer } from \"../generator/ImportContainer.js\";\r\nimport { EmitModes } from \"../OptionModel.js\";\r\nimport { FileFormatter } from \"./formatter/FileFormatter.js\";\r\n\r\nexport class FileHandler {\r\n constructor(\r\n public readonly path: string,\r\n public readonly fileName: string,\r\n protected readonly file: SourceFile,\r\n protected readonly importContainer: ImportContainer,\r\n protected formatter: FileFormatter | undefined,\r\n public readonly allowTypeChecking: boolean\r\n ) {}\r\n\r\n public getFullFilePath() {\r\n return this.path ? `${this.path}/${this.fileName}` : this.fileName;\r\n }\r\n\r\n public getFile() {\r\n return this.file;\r\n }\r\n\r\n public getImports() {\r\n return this.importContainer;\r\n }\r\n\r\n public async write(emitMode: EmitModes, noOutput = false) {\r\n this.file.addImportDeclarations(this.importContainer.getImportDeclarations());\r\n // add ts-nocheck to beginning of each file\r\n if (!this.allowTypeChecking) {\r\n const stmts = this.file.addStatements((writer) => {\r\n writer.writeLine(\"// @ts-nocheck\");\r\n });\r\n stmts[0].setOrder(0);\r\n }\r\n\r\n if (noOutput) {\r\n return;\r\n }\r\n\r\n switch (emitMode) {\r\n case EmitModes.js:\r\n case EmitModes.js_dts:\r\n return this.file.emit();\r\n case EmitModes.dts:\r\n return this.file.emit({ emitOnlyDtsFiles: true });\r\n case EmitModes.ts:\r\n return this.formatAndWriteFile();\r\n default:\r\n throw new Error(`Emit mode \"${emitMode}\" is invalid!`);\r\n }\r\n }\r\n\r\n private async formatAndWriteFile() {\r\n const fileName = this.file.getFilePath();\r\n const content = this.file.getFullText();\r\n\r\n try {\r\n const formatted = this.formatter ? await this.formatter.format(content) : content;\r\n\r\n try {\r\n return writeFile(fileName, formatted);\r\n } catch (writeError) {\r\n console.error(`Failed to write file [/${fileName}]`, writeError);\r\n process.exit(3);\r\n }\r\n } catch (formattingError) {\r\n console.error(\"Formatting failed\", formattingError);\r\n await writeFile(\"error.log\", formattingError?.toString() || \"no error message!\");\r\n process.exit(99);\r\n }\r\n }\r\n}\r\n"]}
@@ -1,9 +1,9 @@
1
1
  import { CompilerOptions, SourceFile } from "ts-morph";
2
- import { DataModel } from "../data-model/DataModel";
3
- import { NamingHelper } from "../data-model/NamingHelper";
4
- import { EmitModes } from "../OptionModel";
5
- import { FileHandler } from "./FileHandler";
6
- import { FileFormatter } from "./formatter/FileFormatter";
2
+ import { DataModel } from "../data-model/DataModel.js";
3
+ import { NamingHelper } from "../data-model/NamingHelper.js";
4
+ import { EmitModes } from "../OptionModel.js";
5
+ import { FileHandler } from "./FileHandler.js";
6
+ import { FileFormatter } from "./formatter/FileFormatter.js";
7
7
  export interface ProjectManagerOptions {
8
8
  usePrettier?: boolean;
9
9
  tsConfigPath?: string;
@@ -1,28 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProjectManager = exports.createProjectManager = void 0;
4
- const tslib_1 = require("tslib");
5
- const path = tslib_1.__importStar(require("path"));
6
- const fs_extra_1 = require("fs-extra");
7
- const ts_morph_1 = require("ts-morph");
8
- const processors_1 = require("xml2js/lib/processors");
9
- const ImportContainer_1 = require("../generator/ImportContainer");
10
- const FileHandler_1 = require("./FileHandler");
11
- const formatter_1 = require("./formatter");
12
- const TsMorphHelper_1 = require("./TsMorphHelper");
13
- function createProjectManager(outputDir, emitMode, namingHelper, dataModel, options) {
14
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
1
+ import { __awaiter } from "tslib";
2
+ import * as path from "path";
3
+ import { mkdirp } from "mkdirp";
4
+ import { Project } from "ts-morph";
5
+ import { firstCharLowerCase } from "xml2js/lib/processors.js";
6
+ import { ImportContainer } from "../generator/ImportContainer.js";
7
+ import { FileHandler } from "./FileHandler.js";
8
+ import { createFormatter } from "./formatter/index.js";
9
+ import { loadTsMorphCompilerOptions } from "./TsMorphHelper.js";
10
+ export function createProjectManager(outputDir, emitMode, namingHelper, dataModel, options) {
11
+ return __awaiter(this, void 0, void 0, function* () {
15
12
  const { usePrettier = false, tsConfigPath = "tsconfig.json" } = options;
16
- const formatter = usePrettier ? yield (0, formatter_1.createFormatter)(outputDir, usePrettier) : undefined;
17
- const compilerOpts = yield (0, TsMorphHelper_1.loadTsMorphCompilerOptions)(tsConfigPath, emitMode, outputDir);
13
+ const formatter = usePrettier ? yield createFormatter(outputDir, usePrettier) : undefined;
14
+ const compilerOpts = yield loadTsMorphCompilerOptions(tsConfigPath, emitMode, outputDir);
18
15
  const pm = new ProjectManager(outputDir, emitMode, namingHelper, dataModel, formatter, compilerOpts, Object.assign({ usePrettier,
19
16
  tsConfigPath }, options));
20
17
  yield pm.init();
21
18
  return pm;
22
19
  });
23
20
  }
24
- exports.createProjectManager = createProjectManager;
25
- class ProjectManager {
21
+ export class ProjectManager {
26
22
  constructor(outputDir, emitMode, namingHelper, dataModel, formatter, compilerOptions, options) {
27
23
  this.outputDir = outputDir;
28
24
  this.emitMode = emitMode;
@@ -31,7 +27,7 @@ class ProjectManager {
31
27
  this.formatter = formatter;
32
28
  this.options = options;
33
29
  // Create ts-morph project
34
- this.project = new ts_morph_1.Project({
30
+ this.project = new Project({
35
31
  // manipulationSettings: this.formatter.getSettings(),
36
32
  skipAddingFilesFromTsConfig: true,
37
33
  compilerOptions,
@@ -50,7 +46,7 @@ class ProjectManager {
50
46
  return this.cachedFiles;
51
47
  }
52
48
  writeFile(fileHandler) {
53
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
49
+ return __awaiter(this, void 0, void 0, function* () {
54
50
  if (this.options.noOutput) {
55
51
  yield fileHandler.write(this.emitMode, true);
56
52
  this.cachedFiles.set(fileHandler.getFullFilePath(), fileHandler.getFile());
@@ -61,17 +57,15 @@ class ProjectManager {
61
57
  }
62
58
  createFile(name, reservedNames, additionalPath = "", forceTypeChecking = false) {
63
59
  const fileName = path.join(this.outputDir, additionalPath, `${name}.ts`);
64
- const imports = new ImportContainer_1.ImportContainer(additionalPath, name, this.dataModel, this.namingHelper.getFileNames(), !!this.options.bundledFileGeneration, reservedNames);
65
- return new FileHandler_1.FileHandler(additionalPath, name, this.project.createSourceFile(fileName), imports, this.formatter, forceTypeChecking || !!this.options.allowTypeChecking);
60
+ const imports = new ImportContainer(additionalPath, name, this.dataModel, this.namingHelper.getFileNames(), !!this.options.bundledFileGeneration, reservedNames);
61
+ return new FileHandler(additionalPath, name, this.project.createSourceFile(fileName), imports, this.formatter, forceTypeChecking || !!this.options.allowTypeChecking);
66
62
  }
67
63
  init() {
68
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
64
+ return __awaiter(this, void 0, void 0, function* () {
69
65
  if (!this.options.bundledFileGeneration) {
70
66
  // ensure folder for each model: we do this at this point for performance reasons
71
- yield Promise.all(this.dataModel.getModelTypes().map((mt) => (0, fs_extra_1.ensureDir)(path.join(this.outputDir, mt.folderPath))));
67
+ yield Promise.all(this.dataModel.getModelTypes().map((mt) => mkdirp(path.join(this.outputDir, mt.folderPath))));
72
68
  }
73
- const typePart = this.emitMode.toUpperCase().replace("_", " & ");
74
- console.log(`Prepared to emit ${typePart} files.`);
75
69
  });
76
70
  }
77
71
  initModels() {
@@ -103,7 +97,7 @@ class ProjectManager {
103
97
  }
104
98
  }
105
99
  finalizeModels() {
106
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
100
+ return __awaiter(this, void 0, void 0, function* () {
107
101
  if (this.mainModelFile &&
108
102
  (this.options.bundledFileGeneration || this.mainModelFile.getFile().getFullText().length)) {
109
103
  yield this.writeFile(this.mainModelFile);
@@ -117,7 +111,7 @@ class ProjectManager {
117
111
  var _a;
118
112
  const asEntityType = model;
119
113
  if (asEntityType.qName) {
120
- collector.push(asEntityType.qName, (0, processors_1.firstCharLowerCase)(asEntityType.qName));
114
+ collector.push(asEntityType.qName, firstCharLowerCase(asEntityType.qName));
121
115
  }
122
116
  if ((_a = asEntityType.id) === null || _a === void 0 ? void 0 : _a.qName) {
123
117
  collector.push(asEntityType.id.qName);
@@ -134,7 +128,7 @@ class ProjectManager {
134
128
  }
135
129
  }
136
130
  finalizeQObjects() {
137
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
131
+ return __awaiter(this, void 0, void 0, function* () {
138
132
  if (this.mainQFile && (this.options.bundledFileGeneration || this.mainQFile.getFile().getFullText().length)) {
139
133
  yield this.writeFile(this.mainQFile);
140
134
  }
@@ -152,7 +146,7 @@ class ProjectManager {
152
146
  this.mainServiceFile = this.createFile(mainServiceName, reservedNames);
153
147
  }
154
148
  finalizeServices() {
155
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
149
+ return __awaiter(this, void 0, void 0, function* () {
156
150
  if (this.mainServiceFile) {
157
151
  yield this.writeFile(this.mainServiceFile);
158
152
  }
@@ -193,7 +187,7 @@ class ProjectManager {
193
187
  return this.createFile(name, reservedNames, folderPath);
194
188
  }
195
189
  finalizeFile(file) {
196
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
190
+ return __awaiter(this, void 0, void 0, function* () {
197
191
  // write individual files in unbundled mode & if this is not one of the main files on root level
198
192
  if (!this.options.bundledFileGeneration &&
199
193
  file.path !== "" &&
@@ -203,5 +197,4 @@ class ProjectManager {
203
197
  });
204
198
  }
205
199
  }
206
- exports.ProjectManager = ProjectManager;
207
200
  //# sourceMappingURL=ProjectManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectManager.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,CAAC,UAAU,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAChE,CAAC;IACM,sBAAsB,CAAC,UAAkB,EAAE,IAAY,EAAE,aAAyC;QACvG,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,OAAO,IAAI,CAAC,SAAS,CAAC;SACvB;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IACM,sBAAsB,CAAC,UAAkB,EAAE,IAAY,EAAE,aAAyC;QACvG,IAAI,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE;YACtC,OAAO,IAAI,CAAC,eAAgB,CAAC;SAC9B;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IAEY,YAAY,CAAC,IAAiB;;YACzC,gGAAgG;YAChG,IACE,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB;gBACnC,IAAI,CAAC,IAAI,KAAK,EAAE;gBAChB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EACxE;gBACA,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;aAC5B;QACH,CAAC;KAAA;CACF;AAvOD,wCAuOC","sourcesContent":["import * as path from \"path\";\r\n\r\nimport { ensureDir } from \"fs-extra\";\r\nimport { CompilerOptions, Project, SourceFile } from \"ts-morph\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport { EntityType } from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { ImportContainer } from \"../generator/ImportContainer\";\r\nimport { EmitModes } from \"../OptionModel\";\r\nimport { FileHandler } from \"./FileHandler\";\r\nimport { createFormatter } from \"./formatter\";\r\nimport { FileFormatter } from \"./formatter/FileFormatter\";\r\nimport { loadTsMorphCompilerOptions } from \"./TsMorphHelper\";\r\n\r\nexport interface ProjectManagerOptions {\r\n usePrettier?: boolean;\r\n tsConfigPath?: string;\r\n bundledFileGeneration?: boolean;\r\n /**\r\n * for testing purposes, turn this on and retrieve all generated files via getCachedFiles\r\n */\r\n noOutput?: boolean;\r\n allowTypeChecking?: boolean;\r\n}\r\n\r\nexport async function createProjectManager(\r\n outputDir: string,\r\n emitMode: EmitModes,\r\n namingHelper: NamingHelper,\r\n dataModel: DataModel,\r\n options: ProjectManagerOptions\r\n): Promise<ProjectManager> {\r\n const { usePrettier = false, tsConfigPath = \"tsconfig.json\" } = options;\r\n const formatter = usePrettier ? await createFormatter(outputDir, usePrettier) : undefined;\r\n\r\n const compilerOpts: CompilerOptions = await loadTsMorphCompilerOptions(tsConfigPath, emitMode, outputDir);\r\n\r\n const pm = new ProjectManager(outputDir, emitMode, namingHelper, dataModel, formatter, compilerOpts, {\r\n usePrettier,\r\n tsConfigPath,\r\n ...options,\r\n });\r\n\r\n await pm.init();\r\n\r\n return pm;\r\n}\r\n\r\nexport class ProjectManager {\r\n private project!: Project;\r\n\r\n private mainServiceFile: FileHandler | undefined;\r\n private mainModelFile: FileHandler | undefined;\r\n private mainQFile: FileHandler | undefined;\r\n\r\n private readonly cachedFiles: Map<string, SourceFile> | undefined;\r\n\r\n constructor(\r\n protected outputDir: string,\r\n protected emitMode: EmitModes,\r\n protected namingHelper: NamingHelper,\r\n protected dataModel: DataModel,\r\n protected formatter: FileFormatter | undefined,\r\n compilerOptions: CompilerOptions | undefined,\r\n protected options: ProjectManagerOptions\r\n ) {\r\n // Create ts-morph project\r\n this.project = new Project({\r\n // manipulationSettings: this.formatter.getSettings(),\r\n skipAddingFilesFromTsConfig: true,\r\n compilerOptions,\r\n });\r\n\r\n if (options.noOutput) {\r\n this.cachedFiles = new Map();\r\n }\r\n }\r\n\r\n public getDataModel() {\r\n return this.dataModel;\r\n }\r\n\r\n /**\r\n * Only filled when noOutput=true\r\n */\r\n public getCachedFiles() {\r\n return this.cachedFiles!;\r\n }\r\n\r\n private async writeFile(fileHandler: FileHandler) {\r\n if (this.options.noOutput) {\r\n await fileHandler.write(this.emitMode, true);\r\n this.cachedFiles!.set(fileHandler.getFullFilePath(), fileHandler.getFile());\r\n\r\n return;\r\n }\r\n\r\n return fileHandler.write(this.emitMode);\r\n }\r\n\r\n private createFile(\r\n name: string,\r\n reservedNames?: Array<string> | undefined,\r\n additionalPath: string = \"\",\r\n forceTypeChecking = false\r\n ): FileHandler {\r\n const fileName = path.join(this.outputDir, additionalPath, `${name}.ts`);\r\n const imports = new ImportContainer(\r\n additionalPath,\r\n name,\r\n this.dataModel,\r\n this.namingHelper.getFileNames(),\r\n !!this.options.bundledFileGeneration,\r\n reservedNames\r\n );\r\n\r\n return new FileHandler(\r\n additionalPath,\r\n name,\r\n this.project.createSourceFile(fileName),\r\n imports,\r\n this.formatter,\r\n forceTypeChecking || !!this.options.allowTypeChecking\r\n );\r\n }\r\n\r\n public async init() {\r\n if (!this.options.bundledFileGeneration) {\r\n // ensure folder for each model: we do this at this point for performance reasons\r\n await Promise.all(\r\n this.dataModel.getModelTypes().map((mt) => ensureDir(path.join(this.outputDir, mt.folderPath)))\r\n );\r\n }\r\n\r\n const typePart = this.emitMode.toUpperCase().replace(\"_\", \" & \");\r\n console.log(`Prepared to emit ${typePart} files.`);\r\n }\r\n\r\n public initModels() {\r\n if (this.options.bundledFileGeneration) {\r\n // collect reserved names, that is names of classes we're going to create => imports must take them into account\r\n const reservedWords = this.dataModel.getModelTypes().reduce<Array<string>>((collector, model) => {\r\n const asEntityType = model as EntityType;\r\n collector.push(model.modelName);\r\n if (asEntityType.editableName) {\r\n collector.push(asEntityType.editableName);\r\n }\r\n if (asEntityType.id?.modelName) {\r\n collector.push(asEntityType.id.modelName);\r\n }\r\n this.dataModel.getAllEntityOperations(model.fqName).forEach((op) => {\r\n if (op.parameters.length) {\r\n collector.push(op.paramsModelName);\r\n }\r\n });\r\n\r\n return collector;\r\n }, []);\r\n this.dataModel.getUnboundOperationTypes().forEach((op) => {\r\n if (op.parameters.length) {\r\n reservedWords.push(op.paramsModelName);\r\n }\r\n });\r\n\r\n this.mainModelFile = this.createFile(this.namingHelper.getFileNames().model, reservedWords);\r\n }\r\n }\r\n\r\n public async finalizeModels() {\r\n if (\r\n this.mainModelFile &&\r\n (this.options.bundledFileGeneration || this.mainModelFile.getFile().getFullText().length)\r\n ) {\r\n await this.writeFile(this.mainModelFile);\r\n }\r\n }\r\n\r\n public initQObjects() {\r\n if (this.options.bundledFileGeneration) {\r\n // collect reserved names, that is names of classes we're going to create => imports must take them into account\r\n const reservedWords = this.dataModel.getModelTypes().reduce<Array<string>>((collector, model) => {\r\n const asEntityType = model as EntityType;\r\n if (asEntityType.qName) {\r\n collector.push(asEntityType.qName, firstCharLowerCase(asEntityType.qName));\r\n }\r\n if (asEntityType.id?.qName) {\r\n collector.push(asEntityType.id.qName);\r\n }\r\n this.dataModel.getAllEntityOperations(model.fqName).forEach((op) => {\r\n collector.push(op.qName);\r\n });\r\n\r\n return collector;\r\n }, []);\r\n this.dataModel.getUnboundOperationTypes().forEach((op) => {\r\n reservedWords.push(op.qName);\r\n });\r\n\r\n this.mainQFile = this.createFile(this.namingHelper.getFileNames().qObject, reservedWords);\r\n }\r\n }\r\n\r\n public async finalizeQObjects() {\r\n if (this.mainQFile && (this.options.bundledFileGeneration || this.mainQFile.getFile().getFullText().length)) {\r\n await this.writeFile(this.mainQFile);\r\n }\r\n }\r\n\r\n public initServices() {\r\n const mainServiceName = this.namingHelper.getMainServiceName();\r\n const reservedNames = [mainServiceName];\r\n\r\n if (this.options.bundledFileGeneration) {\r\n [...this.dataModel.getEntityTypes(), ...this.dataModel.getComplexTypes()].reduce((collector, model) => {\r\n collector.push(model.serviceName, model.serviceCollectionName);\r\n return collector;\r\n }, reservedNames);\r\n }\r\n\r\n this.mainServiceFile = this.createFile(mainServiceName, reservedNames);\r\n }\r\n\r\n public async finalizeServices() {\r\n if (this.mainServiceFile) {\r\n await this.writeFile(this.mainServiceFile);\r\n }\r\n }\r\n\r\n public getMainServiceFile() {\r\n return this.mainServiceFile!;\r\n }\r\n\r\n public createOrGetMainModelFile(reservedNames?: Array<string>) {\r\n if (!this.mainModelFile) {\r\n this.mainModelFile = this.createFile(this.namingHelper.getFileNames().model, reservedNames, \"\", true);\r\n }\r\n return this.mainModelFile;\r\n }\r\n\r\n public createOrGetMainQObjectFile(reservedNames?: Array<string>) {\r\n if (!this.mainQFile) {\r\n this.mainQFile = this.createFile(this.namingHelper.getFileNames().qObject, reservedNames);\r\n }\r\n return this.mainQFile;\r\n }\r\n\r\n public createOrGetModelFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\r\n if (this.mainModelFile) {\r\n return this.mainModelFile;\r\n }\r\n\r\n // model files always allow for type checking\r\n return this.createFile(name, reservedNames, folderPath, true);\r\n }\r\n public createOrGetQObjectFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\r\n if (this.mainQFile) {\r\n return this.mainQFile;\r\n }\r\n\r\n return this.createFile(name, reservedNames, folderPath);\r\n }\r\n public createOrGetServiceFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\r\n if (this.options.bundledFileGeneration) {\r\n return this.mainServiceFile!;\r\n }\r\n\r\n return this.createFile(name, reservedNames, folderPath);\r\n }\r\n\r\n public async finalizeFile(file: FileHandler) {\r\n // write individual files in unbundled mode & if this is not one of the main files on root level\r\n if (\r\n !this.options.bundledFileGeneration &&\r\n file.path !== \"\" &&\r\n !Object.values(this.namingHelper.getFileNames()).includes(file.fileName)\r\n ) {\r\n await this.writeFile(file);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ProjectManager.js","sourceRoot":"","sources":["../../src/project/ProjectManager.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7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AE,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAChE,CAAC;IACM,sBAAsB,CAAC,UAAkB,EAAE,IAAY,EAAE,aAAyC;QACvG,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,OAAO,IAAI,CAAC,SAAS,CAAC;SACvB;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IACM,sBAAsB,CAAC,UAAkB,EAAE,IAAY,EAAE,aAAyC;QACvG,IAAI,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE;YACtC,OAAO,IAAI,CAAC,eAAgB,CAAC;SAC9B;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IAEY,YAAY,CAAC,IAAiB;;YACzC,gGAAgG;YAChG,IACE,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB;gBACnC,IAAI,CAAC,IAAI,KAAK,EAAE;gBAChB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EACxE;gBACA,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;aAC5B;QACH,CAAC;KAAA;CACF","sourcesContent":["import * as path from \"path\";\r\nimport { mkdirp } from \"mkdirp\";\r\nimport { CompilerOptions, Project, SourceFile } from \"ts-morph\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors.js\";\r\nimport { DataModel } from \"../data-model/DataModel.js\";\r\nimport { EntityType } from \"../data-model/DataTypeModel.js\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper.js\";\r\nimport { ImportContainer } from \"../generator/ImportContainer.js\";\r\nimport { EmitModes } from \"../OptionModel.js\";\r\nimport { FileHandler } from \"./FileHandler.js\";\r\nimport { FileFormatter } from \"./formatter/FileFormatter.js\";\r\nimport { createFormatter } from \"./formatter/index.js\";\r\nimport { loadTsMorphCompilerOptions } from \"./TsMorphHelper.js\";\r\n\r\nexport interface ProjectManagerOptions {\r\n usePrettier?: boolean;\r\n tsConfigPath?: string;\r\n bundledFileGeneration?: boolean;\r\n /**\r\n * for testing purposes, turn this on and retrieve all generated files via getCachedFiles\r\n */\r\n noOutput?: boolean;\r\n allowTypeChecking?: boolean;\r\n}\r\n\r\nexport async function createProjectManager(\r\n outputDir: string,\r\n emitMode: EmitModes,\r\n namingHelper: NamingHelper,\r\n dataModel: DataModel,\r\n options: ProjectManagerOptions,\r\n): Promise<ProjectManager> {\r\n const { usePrettier = false, tsConfigPath = \"tsconfig.json\" } = options;\r\n const formatter = usePrettier ? await createFormatter(outputDir, usePrettier) : undefined;\r\n\r\n const compilerOpts: CompilerOptions = await loadTsMorphCompilerOptions(tsConfigPath, emitMode, outputDir);\r\n\r\n const pm = new ProjectManager(outputDir, emitMode, namingHelper, dataModel, formatter, compilerOpts, {\r\n usePrettier,\r\n tsConfigPath,\r\n ...options,\r\n });\r\n\r\n await pm.init();\r\n\r\n return pm;\r\n}\r\n\r\nexport class ProjectManager {\r\n private project!: Project;\r\n\r\n private mainServiceFile: FileHandler | undefined;\r\n private mainModelFile: FileHandler | undefined;\r\n private mainQFile: FileHandler | undefined;\r\n\r\n private readonly cachedFiles: Map<string, SourceFile> | undefined;\r\n\r\n constructor(\r\n protected outputDir: string,\r\n protected emitMode: EmitModes,\r\n protected namingHelper: NamingHelper,\r\n protected dataModel: DataModel,\r\n protected formatter: FileFormatter | undefined,\r\n compilerOptions: CompilerOptions | undefined,\r\n protected options: ProjectManagerOptions,\r\n ) {\r\n // Create ts-morph project\r\n this.project = new Project({\r\n // manipulationSettings: this.formatter.getSettings(),\r\n skipAddingFilesFromTsConfig: true,\r\n compilerOptions,\r\n });\r\n\r\n if (options.noOutput) {\r\n this.cachedFiles = new Map();\r\n }\r\n }\r\n\r\n public getDataModel() {\r\n return this.dataModel;\r\n }\r\n\r\n /**\r\n * Only filled when noOutput=true\r\n */\r\n public getCachedFiles() {\r\n return this.cachedFiles!;\r\n }\r\n\r\n private async writeFile(fileHandler: FileHandler) {\r\n if (this.options.noOutput) {\r\n await fileHandler.write(this.emitMode, true);\r\n this.cachedFiles!.set(fileHandler.getFullFilePath(), fileHandler.getFile());\r\n\r\n return;\r\n }\r\n\r\n return fileHandler.write(this.emitMode);\r\n }\r\n\r\n private createFile(\r\n name: string,\r\n reservedNames?: Array<string> | undefined,\r\n additionalPath: string = \"\",\r\n forceTypeChecking = false,\r\n ): FileHandler {\r\n const fileName = path.join(this.outputDir, additionalPath, `${name}.ts`);\r\n const imports = new ImportContainer(\r\n additionalPath,\r\n name,\r\n this.dataModel,\r\n this.namingHelper.getFileNames(),\r\n !!this.options.bundledFileGeneration,\r\n reservedNames,\r\n );\r\n\r\n return new FileHandler(\r\n additionalPath,\r\n name,\r\n this.project.createSourceFile(fileName),\r\n imports,\r\n this.formatter,\r\n forceTypeChecking || !!this.options.allowTypeChecking,\r\n );\r\n }\r\n\r\n public async init() {\r\n if (!this.options.bundledFileGeneration) {\r\n // ensure folder for each model: we do this at this point for performance reasons\r\n await Promise.all(this.dataModel.getModelTypes().map((mt) => mkdirp(path.join(this.outputDir, mt.folderPath))));\r\n }\r\n }\r\n\r\n public initModels() {\r\n if (this.options.bundledFileGeneration) {\r\n // collect reserved names, that is names of classes we're going to create => imports must take them into account\r\n const reservedWords = this.dataModel.getModelTypes().reduce<Array<string>>((collector, model) => {\r\n const asEntityType = model as EntityType;\r\n collector.push(model.modelName);\r\n if (asEntityType.editableName) {\r\n collector.push(asEntityType.editableName);\r\n }\r\n if (asEntityType.id?.modelName) {\r\n collector.push(asEntityType.id.modelName);\r\n }\r\n this.dataModel.getAllEntityOperations(model.fqName).forEach((op) => {\r\n if (op.parameters.length) {\r\n collector.push(op.paramsModelName);\r\n }\r\n });\r\n\r\n return collector;\r\n }, []);\r\n this.dataModel.getUnboundOperationTypes().forEach((op) => {\r\n if (op.parameters.length) {\r\n reservedWords.push(op.paramsModelName);\r\n }\r\n });\r\n\r\n this.mainModelFile = this.createFile(this.namingHelper.getFileNames().model, reservedWords);\r\n }\r\n }\r\n\r\n public async finalizeModels() {\r\n if (\r\n this.mainModelFile &&\r\n (this.options.bundledFileGeneration || this.mainModelFile.getFile().getFullText().length)\r\n ) {\r\n await this.writeFile(this.mainModelFile);\r\n }\r\n }\r\n\r\n public initQObjects() {\r\n if (this.options.bundledFileGeneration) {\r\n // collect reserved names, that is names of classes we're going to create => imports must take them into account\r\n const reservedWords = this.dataModel.getModelTypes().reduce<Array<string>>((collector, model) => {\r\n const asEntityType = model as EntityType;\r\n if (asEntityType.qName) {\r\n collector.push(asEntityType.qName, firstCharLowerCase(asEntityType.qName));\r\n }\r\n if (asEntityType.id?.qName) {\r\n collector.push(asEntityType.id.qName);\r\n }\r\n this.dataModel.getAllEntityOperations(model.fqName).forEach((op) => {\r\n collector.push(op.qName);\r\n });\r\n\r\n return collector;\r\n }, []);\r\n this.dataModel.getUnboundOperationTypes().forEach((op) => {\r\n reservedWords.push(op.qName);\r\n });\r\n\r\n this.mainQFile = this.createFile(this.namingHelper.getFileNames().qObject, reservedWords);\r\n }\r\n }\r\n\r\n public async finalizeQObjects() {\r\n if (this.mainQFile && (this.options.bundledFileGeneration || this.mainQFile.getFile().getFullText().length)) {\r\n await this.writeFile(this.mainQFile);\r\n }\r\n }\r\n\r\n public initServices() {\r\n const mainServiceName = this.namingHelper.getMainServiceName();\r\n const reservedNames = [mainServiceName];\r\n\r\n if (this.options.bundledFileGeneration) {\r\n [...this.dataModel.getEntityTypes(), ...this.dataModel.getComplexTypes()].reduce((collector, model) => {\r\n collector.push(model.serviceName, model.serviceCollectionName);\r\n return collector;\r\n }, reservedNames);\r\n }\r\n\r\n this.mainServiceFile = this.createFile(mainServiceName, reservedNames);\r\n }\r\n\r\n public async finalizeServices() {\r\n if (this.mainServiceFile) {\r\n await this.writeFile(this.mainServiceFile);\r\n }\r\n }\r\n\r\n public getMainServiceFile() {\r\n return this.mainServiceFile!;\r\n }\r\n\r\n public createOrGetMainModelFile(reservedNames?: Array<string>) {\r\n if (!this.mainModelFile) {\r\n this.mainModelFile = this.createFile(this.namingHelper.getFileNames().model, reservedNames, \"\", true);\r\n }\r\n return this.mainModelFile;\r\n }\r\n\r\n public createOrGetMainQObjectFile(reservedNames?: Array<string>) {\r\n if (!this.mainQFile) {\r\n this.mainQFile = this.createFile(this.namingHelper.getFileNames().qObject, reservedNames);\r\n }\r\n return this.mainQFile;\r\n }\r\n\r\n public createOrGetModelFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\r\n if (this.mainModelFile) {\r\n return this.mainModelFile;\r\n }\r\n\r\n // model files always allow for type checking\r\n return this.createFile(name, reservedNames, folderPath, true);\r\n }\r\n public createOrGetQObjectFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\r\n if (this.mainQFile) {\r\n return this.mainQFile;\r\n }\r\n\r\n return this.createFile(name, reservedNames, folderPath);\r\n }\r\n public createOrGetServiceFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\r\n if (this.options.bundledFileGeneration) {\r\n return this.mainServiceFile!;\r\n }\r\n\r\n return this.createFile(name, reservedNames, folderPath);\r\n }\r\n\r\n public async finalizeFile(file: FileHandler) {\r\n // write individual files in unbundled mode & if this is not one of the main files on root level\r\n if (\r\n !this.options.bundledFileGeneration &&\r\n file.path !== \"\" &&\r\n !Object.values(this.namingHelper.getFileNames()).includes(file.fileName)\r\n ) {\r\n await this.writeFile(file);\r\n }\r\n }\r\n}\r\n"]}
@@ -1,5 +1,5 @@
1
1
  import { CompilerOptions } from "ts-morph";
2
- import { EmitModes } from "../OptionModel";
2
+ import { EmitModes } from "../OptionModel.js";
3
3
  /**
4
4
  * Loads the TS configuration from the specified path.
5
5
  * Then maps the appropriate options to ts-morph compiler options.
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadTsMorphCompilerOptions = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@ts-morph/common");
6
- const tsconfig_loader_1 = tslib_1.__importDefault(require("tsconfig-loader"));
7
- const typescript_1 = tslib_1.__importDefault(require("typescript"));
8
- const OptionModel_1 = require("../OptionModel");
1
+ import { __awaiter, __rest } from "tslib";
2
+ import { NewLineKind } from "@ts-morph/common";
3
+ import load from "tsconfig-loader";
4
+ import ts from "typescript";
5
+ import { EmitModes } from "../OptionModel.js";
9
6
  /**
10
7
  * Loads the TS configuration from the specified path.
11
8
  * Then maps the appropriate options to ts-morph compiler options.
@@ -14,30 +11,32 @@ const OptionModel_1 = require("../OptionModel");
14
11
  * @param emitMode the used emit mode
15
12
  * @param outputDir the used output dir
16
13
  */
17
- function loadTsMorphCompilerOptions(tsConfigPath, emitMode, outputDir) {
18
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
- const generateDeclarations = OptionModel_1.EmitModes.js_dts === emitMode || OptionModel_1.EmitModes.dts === emitMode;
14
+ export function loadTsMorphCompilerOptions(tsConfigPath, emitMode, outputDir) {
15
+ var _a;
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const generateDeclarations = EmitModes.js_dts === emitMode || EmitModes.dts === emitMode;
20
18
  // load config file
21
19
  // NOTE: not async...
22
- const conf = (0, tsconfig_loader_1.default)({ filename: tsConfigPath });
23
- const _a = (conf === null || conf === void 0 ? void 0 : conf.tsConfig.compilerOptions) || {}, {
20
+ // @ts-ignore
21
+ const doLoad = (_a = load === null || load === void 0 ? void 0 : load.default) !== null && _a !== void 0 ? _a : load;
22
+ const conf = doLoad({ filename: tsConfigPath });
23
+ const _b = (conf === null || conf === void 0 ? void 0 : conf.tsConfig.compilerOptions) || {}, {
24
24
  // ignored props
25
25
  noEmit, // we always want to emit
26
26
  importsNotUsedAsValues, // type is missing
27
27
  jsx, plugins,
28
28
  // mapped props
29
- moduleResolution, lib, module, newLine, target, rootDir, rootDirs } = _a, passThrough = tslib_1.__rest(_a, ["noEmit", "importsNotUsedAsValues", "jsx", "plugins", "moduleResolution", "lib", "module", "newLine", "target", "rootDir", "rootDirs"]);
29
+ moduleResolution, lib, module, newLine, target, rootDir, rootDirs } = _b, passThrough = __rest(_b, ["noEmit", "importsNotUsedAsValues", "jsx", "plugins", "moduleResolution", "lib", "module", "newLine", "target", "rootDir", "rootDirs"]);
30
30
  const compilerOpts = Object.assign(Object.assign({}, passThrough), { outDir: outputDir, declaration: generateDeclarations, moduleResolution: getModuleResolutionKind(moduleResolution), module: getModuleKind(module), target: getTarget(target) });
31
31
  if (lib) {
32
32
  compilerOpts.lib = lib;
33
33
  }
34
34
  if (newLine) {
35
- compilerOpts.newLine = (newLine === null || newLine === void 0 ? void 0 : newLine.toLowerCase()) === "lf" ? common_1.NewLineKind.LineFeed : common_1.NewLineKind.CarriageReturnLineFeed;
35
+ compilerOpts.newLine = (newLine === null || newLine === void 0 ? void 0 : newLine.toLowerCase()) === "lf" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed;
36
36
  }
37
37
  return compilerOpts;
38
38
  });
39
39
  }
40
- exports.loadTsMorphCompilerOptions = loadTsMorphCompilerOptions;
41
40
  /**
42
41
  * Maps to lower case.
43
42
  * Also translates "node" to "nodejs".
@@ -50,17 +49,17 @@ function getModuleResolutionKind(moduleResolution) {
50
49
  ? "nodejs"
51
50
  : moduleResolution.toLowerCase()
52
51
  : undefined;
53
- const matchedKey = Object.keys(typescript_1.default.ModuleResolutionKind).find((mk) => mk.toLowerCase() === modRes);
54
- return matchedKey ? typescript_1.default.ModuleResolutionKind[matchedKey] : undefined;
52
+ const matchedKey = Object.keys(ts.ModuleResolutionKind).find((mk) => mk.toLowerCase() === modRes);
53
+ return matchedKey ? ts.ModuleResolutionKind[matchedKey] : undefined;
55
54
  }
56
55
  function getModuleKind(module) {
57
56
  const mod = typeof module === "string" ? module.toLowerCase() : undefined;
58
- const matchedKey = Object.keys(typescript_1.default.ModuleKind).find((mk) => mk.toLowerCase() === mod);
59
- return matchedKey ? typescript_1.default.ModuleKind[matchedKey] : undefined;
57
+ const matchedKey = Object.keys(ts.ModuleKind).find((mk) => mk.toLowerCase() === mod);
58
+ return matchedKey ? ts.ModuleKind[matchedKey] : undefined;
60
59
  }
61
60
  function getTarget(target) {
62
61
  const t = typeof target === "string" ? target.toLowerCase() : undefined;
63
- const matchedKey = Object.keys(typescript_1.default.ScriptTarget).find((st) => st.toLowerCase() === t);
64
- return matchedKey ? typescript_1.default.ScriptTarget[matchedKey] : undefined;
62
+ const matchedKey = Object.keys(ts.ScriptTarget).find((st) => st.toLowerCase() === t);
63
+ return matchedKey ? ts.ScriptTarget[matchedKey] : undefined;
65
64
  }
66
65
  //# sourceMappingURL=TsMorphHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TsMorphHelper.js","sourceRoot":"","sources":["../../src/project/TsMorphHelper.ts"],"names":[],"mappings":";;;;AAAA,6CAA+C;AAE/C,8EAAmC;AACnC,oEAA4B;AAE5B,gDAA2C;AAE3C;;;;;;;GAOG;AACH,SAAsB,0BAA0B,CAAC,YAAoB,EAAE,QAAmB,EAAE,SAAiB;;QAC3G,MAAM,oBAAoB,GAAG,uBAAS,CAAC,MAAM,KAAK,QAAQ,IAAI,uBAAS,CAAC,GAAG,KAAK,QAAQ,CAAC;QAEzF,mBAAmB;QACnB,qBAAqB;QACrB,MAAM,IAAI,GAAG,IAAA,yBAAI,EAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC;QAE9C,MAAM,KAeF,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAC,eAAe,KAAI,EAAE,EAflC;QACJ,gBAAgB;QAChB,MAAM,EAAE,yBAAyB;QACjC,sBAAsB,EAAE,kBAAkB;QAC1C,GAAG,EACH,OAAO;QACP,eAAe;QACf,gBAAgB,EAChB,GAAG,EACH,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,QAAQ,OAE8B,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Q,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1E,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAE,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAiC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC;IACpH,OAAO,UAAU,CAAC,CAAC,CAAE,oBAAE,CAAC,UAAU,CAAC,UAAU,CAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E,CAAC;AAED,SAAS,SAAS,CAAC,MAAgD;IACjE,MAAM,CAAC,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAE,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAmC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IACtH,OAAO,UAAU,CAAC,CAAC,CAAE,oBAAE,CAAC,YAAY,CAAC,UAAU,CAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC","sourcesContent":["import { NewLineKind } from \"@ts-morph/common\";\r\nimport { CompilerOptions, ModuleKind, ModuleResolutionKind, ScriptTarget } from \"ts-morph\";\r\nimport load from \"tsconfig-loader\";\r\nimport ts from \"typescript\";\r\n\r\nimport { EmitModes } from \"../OptionModel\";\r\n\r\n/**\r\n * Loads the TS configuration from the specified path.\r\n * Then maps the appropriate options to ts-morph compiler options.\r\n *\r\n * @param tsConfigPath path to tsconfig.json\r\n * @param emitMode the used emit mode\r\n * @param outputDir the used output dir\r\n */\r\nexport async function loadTsMorphCompilerOptions(tsConfigPath: string, emitMode: EmitModes, outputDir: string) {\r\n const generateDeclarations = EmitModes.js_dts === emitMode || EmitModes.dts === emitMode;\r\n\r\n // load config file\r\n // NOTE: not async...\r\n const conf = load({ filename: tsConfigPath });\r\n\r\n const {\r\n // ignored props\r\n noEmit, // we always want to emit\r\n importsNotUsedAsValues, // type is missing\r\n jsx,\r\n plugins,\r\n // mapped props\r\n moduleResolution,\r\n lib,\r\n module,\r\n newLine,\r\n target,\r\n rootDir,\r\n rootDirs,\r\n ...passThrough\r\n } = conf?.tsConfig.compilerOptions || {};\r\n\r\n const compilerOpts: CompilerOptions = {\r\n ...passThrough,\r\n outDir: outputDir,\r\n declaration: generateDeclarations,\r\n moduleResolution: getModuleResolutionKind(moduleResolution),\r\n module: getModuleKind(module),\r\n target: getTarget(target),\r\n };\r\n if (lib) {\r\n compilerOpts.lib = lib as string[];\r\n }\r\n if (newLine) {\r\n compilerOpts.newLine = newLine?.toLowerCase() === \"lf\" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed;\r\n }\r\n\r\n return compilerOpts;\r\n}\r\n\r\n/**\r\n * Maps to lower case.\r\n * Also translates \"node\" to \"nodejs\".\r\n *\r\n * @param moduleResolution\r\n */\r\nfunction getModuleResolutionKind(\r\n moduleResolution: string | undefined | Record<string, any>\r\n): ModuleResolutionKind | undefined {\r\n const modRes =\r\n typeof moduleResolution === \"string\"\r\n ? moduleResolution.toLowerCase() === \"node\"\r\n ? \"nodejs\"\r\n : moduleResolution.toLowerCase()\r\n : undefined;\r\n const matchedKey = Object.keys(ts.ModuleResolutionKind).find(\r\n (mk): mk is keyof typeof ModuleResolutionKind => mk.toLowerCase() === modRes\r\n );\r\n return matchedKey ? (ts.ModuleResolutionKind[matchedKey] as ModuleResolutionKind) : undefined;\r\n}\r\n\r\nfunction getModuleKind(module: string | undefined | Record<string, any>): ModuleKind | undefined {\r\n const mod = typeof module === \"string\" ? module.toLowerCase() : undefined;\r\n const matchedKey = Object.keys(ts.ModuleKind).find((mk): mk is keyof typeof ModuleKind => mk.toLowerCase() === mod);\r\n return matchedKey ? (ts.ModuleKind[matchedKey] as ModuleKind) : undefined;\r\n}\r\n\r\nfunction getTarget(target: string | undefined | Record<string, any>): ScriptTarget | undefined {\r\n const t = typeof target === \"string\" ? target.toLowerCase() : undefined;\r\n const matchedKey = Object.keys(ts.ScriptTarget).find((st): st is keyof typeof ScriptTarget => st.toLowerCase() === t);\r\n return matchedKey ? (ts.ScriptTarget[matchedKey] as ScriptTarget) : undefined;\r\n}\r\n"]}
1
+ {"version":3,"file":"TsMorphHelper.js","sourceRoot":"","sources":["../../src/project/TsMorphHelper.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,IAAoD,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,UAAgB,0BAA0B,CAAC,YAAoB,EAAE,QAAmB,EAAE,SAAiB;;;QAC3G,MAAM,oBAAoB,GAAG,SAAS,CAAC,MAAM,KAAK,QAAQ,IAAI,SAAS,CAAC,GAAG,KAAK,QAAQ,CAAC;QAEzF,mBAAmB;QACnB,qBAAqB;QACrB,aAAa;QACb,MAAM,MAAM,GAAmF,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,mCAAI,IAAI,CAAC;QACrH,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC;QAEhD,MAAM,KAeF,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAC,eAAe,KAAI,EAAE,EAflC;QACJ,gBAAgB;QAChB,MAAM,EAAE,yBAAyB;QACjC,sBAAsB,EAAE,kBAAkB;QAC1C,GAAG,EACH,OAAO;QACP,eAAe;QACf,gBAAgB,EAChB,GAAG,EACH,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,QAAQ,OAE8B,EADnC,WAA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AE,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1E,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAiC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC;IACpH,OAAO,UAAU,CAAC,CAAC,CAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E,CAAC;AAED,SAAS,SAAS,CAAC,MAAgD;IACjE,MAAM,CAAC,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAmC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IACtH,OAAO,UAAU,CAAC,CAAC,CAAE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC","sourcesContent":["import { NewLineKind } from \"@ts-morph/common\";\r\nimport { CompilerOptions, ModuleKind, ModuleResolutionKind, ScriptTarget } from \"ts-morph\";\r\nimport load, { TsConfigLoaderParams, TsConfigLoaderResult } from \"tsconfig-loader\";\r\nimport ts from \"typescript\";\r\nimport { EmitModes } from \"../OptionModel.js\";\r\n\r\n/**\r\n * Loads the TS configuration from the specified path.\r\n * Then maps the appropriate options to ts-morph compiler options.\r\n *\r\n * @param tsConfigPath path to tsconfig.json\r\n * @param emitMode the used emit mode\r\n * @param outputDir the used output dir\r\n */\r\nexport async function loadTsMorphCompilerOptions(tsConfigPath: string, emitMode: EmitModes, outputDir: string) {\r\n const generateDeclarations = EmitModes.js_dts === emitMode || EmitModes.dts === emitMode;\r\n\r\n // load config file\r\n // NOTE: not async...\r\n // @ts-ignore\r\n const doLoad: ({ filename, cwd }?: TsConfigLoaderParams) => TsConfigLoaderResult | undefined = load?.default ?? load;\r\n const conf = doLoad({ filename: tsConfigPath });\r\n\r\n const {\r\n // ignored props\r\n noEmit, // we always want to emit\r\n importsNotUsedAsValues, // type is missing\r\n jsx,\r\n plugins,\r\n // mapped props\r\n moduleResolution,\r\n lib,\r\n module,\r\n newLine,\r\n target,\r\n rootDir,\r\n rootDirs,\r\n ...passThrough\r\n } = conf?.tsConfig.compilerOptions || {};\r\n\r\n const compilerOpts: CompilerOptions = {\r\n ...passThrough,\r\n outDir: outputDir,\r\n declaration: generateDeclarations,\r\n moduleResolution: getModuleResolutionKind(moduleResolution),\r\n module: getModuleKind(module),\r\n target: getTarget(target),\r\n };\r\n if (lib) {\r\n compilerOpts.lib = lib as string[];\r\n }\r\n if (newLine) {\r\n compilerOpts.newLine = newLine?.toLowerCase() === \"lf\" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed;\r\n }\r\n\r\n return compilerOpts;\r\n}\r\n\r\n/**\r\n * Maps to lower case.\r\n * Also translates \"node\" to \"nodejs\".\r\n *\r\n * @param moduleResolution\r\n */\r\nfunction getModuleResolutionKind(\r\n moduleResolution: string | undefined | Record<string, any>,\r\n): ModuleResolutionKind | undefined {\r\n const modRes =\r\n typeof moduleResolution === \"string\"\r\n ? moduleResolution.toLowerCase() === \"node\"\r\n ? \"nodejs\"\r\n : moduleResolution.toLowerCase()\r\n : undefined;\r\n const matchedKey = Object.keys(ts.ModuleResolutionKind).find(\r\n (mk): mk is keyof typeof ModuleResolutionKind => mk.toLowerCase() === modRes,\r\n );\r\n return matchedKey ? (ts.ModuleResolutionKind[matchedKey] as ModuleResolutionKind) : undefined;\r\n}\r\n\r\nfunction getModuleKind(module: string | undefined | Record<string, any>): ModuleKind | undefined {\r\n const mod = typeof module === \"string\" ? module.toLowerCase() : undefined;\r\n const matchedKey = Object.keys(ts.ModuleKind).find((mk): mk is keyof typeof ModuleKind => mk.toLowerCase() === mod);\r\n return matchedKey ? (ts.ModuleKind[matchedKey] as ModuleKind) : undefined;\r\n}\r\n\r\nfunction getTarget(target: string | undefined | Record<string, any>): ScriptTarget | undefined {\r\n const t = typeof target === \"string\" ? target.toLowerCase() : undefined;\r\n const matchedKey = Object.keys(ts.ScriptTarget).find((st): st is keyof typeof ScriptTarget => st.toLowerCase() === t);\r\n return matchedKey ? (ts.ScriptTarget[matchedKey] as ScriptTarget) : undefined;\r\n}\r\n"]}
@@ -1,5 +1,5 @@
1
1
  import { ManipulationSettings } from "ts-morph";
2
- import { FileFormatter } from "./FileFormatter";
2
+ import { FileFormatter } from "./FileFormatter.js";
3
3
  /**
4
4
  * Abstract formatter.
5
5
  *
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseFormatter = void 0;
4
1
  /**
5
2
  * Abstract formatter.
6
3
  *
@@ -8,7 +5,7 @@ exports.BaseFormatter = void 0;
8
5
  * @abstract
9
6
  * @class Formatter
10
7
  */
11
- class BaseFormatter {
8
+ export class BaseFormatter {
12
9
  /**
13
10
  * Default constructor
14
11
  * @param {string} output Path of the output file
@@ -27,5 +24,4 @@ class BaseFormatter {
27
24
  return this.settings;
28
25
  }
29
26
  }
30
- exports.BaseFormatter = BaseFormatter;
31
27
  //# sourceMappingURL=BaseFormatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseFormatter.js","sourceRoot":"","sources":["../../../src/project/formatter/BaseFormatter.ts"],"names":[],"mappings":";;;AAGA;;;;;;GAMG;AACH,MAAsB,aAAa;IAmBjC;;;;OAIG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAWD;;;;;OAKG;IACI,WAAW;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CAGF;AAhDD,sCAgDC","sourcesContent":["import { ManipulationSettings } from \"ts-morph\";\r\nimport { FileFormatter } from \"./FileFormatter\";\r\n\r\n/**\r\n * Abstract formatter.\r\n *\r\n * @export\r\n * @abstract\r\n * @class Formatter\r\n */\r\nexport abstract class BaseFormatter implements FileFormatter {\r\n /**\r\n * Path of the output file.\r\n *\r\n * @protected\r\n * @type {string}\r\n * @memberof Formatter\r\n */\r\n protected output: string;\r\n\r\n /**\r\n * Initialized ts-morph manipulation settings for project creation.\r\n *\r\n * @protected\r\n * @type {Partial<ManipulationSettings>}\r\n * @memberof Formatter\r\n */\r\n protected settings!: Partial<ManipulationSettings>;\r\n\r\n /**\r\n * Default constructor\r\n * @param {string} output Path of the output file\r\n * @memberof Formatter\r\n */\r\n constructor(output: string) {\r\n this.output = output;\r\n }\r\n\r\n /**\r\n * Initializes the formatter.\r\n *\r\n * @abstract\r\n * @returns {Promise<BaseFormatter>} Initialized formatter\r\n * @memberof Formatter\r\n */\r\n public abstract init(): Promise<BaseFormatter>;\r\n\r\n /**\r\n * Returns initialized ts-morph manipuation settings.\r\n *\r\n * @returns {Promise<Partial<ManipulationSettings>>} ts-morph manipulation settings\r\n * @memberof Formatter\r\n */\r\n public getSettings(): Partial<ManipulationSettings> {\r\n return this.settings;\r\n }\r\n\r\n public abstract format(source: string): Promise<string>;\r\n}\r\n"]}
1
+ {"version":3,"file":"BaseFormatter.js","sourceRoot":"","sources":["../../../src/project/formatter/BaseFormatter.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,OAAgB,aAAa;IAmBjC;;;;OAIG;IACH,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAWD;;;;;OAKG;IACI,WAAW;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CAGF","sourcesContent":["import { ManipulationSettings } from \"ts-morph\";\r\n\r\nimport { FileFormatter } from \"./FileFormatter.js\";\r\n\r\n/**\r\n * Abstract formatter.\r\n *\r\n * @export\r\n * @abstract\r\n * @class Formatter\r\n */\r\nexport abstract class BaseFormatter implements FileFormatter {\r\n /**\r\n * Path of the output file.\r\n *\r\n * @protected\r\n * @type {string}\r\n * @memberof Formatter\r\n */\r\n protected output: string;\r\n\r\n /**\r\n * Initialized ts-morph manipulation settings for project creation.\r\n *\r\n * @protected\r\n * @type {Partial<ManipulationSettings>}\r\n * @memberof Formatter\r\n */\r\n protected settings!: Partial<ManipulationSettings>;\r\n\r\n /**\r\n * Default constructor\r\n * @param {string} output Path of the output file\r\n * @memberof Formatter\r\n */\r\n constructor(output: string) {\r\n this.output = output;\r\n }\r\n\r\n /**\r\n * Initializes the formatter.\r\n *\r\n * @abstract\r\n * @returns {Promise<BaseFormatter>} Initialized formatter\r\n * @memberof Formatter\r\n */\r\n public abstract init(): Promise<BaseFormatter>;\r\n\r\n /**\r\n * Returns initialized ts-morph manipuation settings.\r\n *\r\n * @returns {Promise<Partial<ManipulationSettings>>} ts-morph manipulation settings\r\n * @memberof Formatter\r\n */\r\n public getSettings(): Partial<ManipulationSettings> {\r\n return this.settings;\r\n }\r\n\r\n public abstract format(source: string): Promise<string>;\r\n}\r\n"]}
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=FileFormatter.js.map
@@ -1,4 +1,4 @@
1
- import { BaseFormatter } from "./BaseFormatter";
1
+ import { BaseFormatter } from "./BaseFormatter.js";
2
2
  /**
3
3
  * Prettier formatter.
4
4
  *