@odata2ts/odata2ts 0.39.1 → 0.40.1

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 (61) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/LICENSE +21 -21
  3. package/README.md +81 -81
  4. package/lib/FactoryFunctionModel.d.ts +2 -2
  5. package/lib/FactoryFunctionModel.js.map +1 -1
  6. package/lib/NamingModel.js.map +1 -1
  7. package/lib/OptionModel.d.ts +3 -3
  8. package/lib/OptionModel.js.map +1 -1
  9. package/lib/TypeModel.js.map +1 -1
  10. package/lib/app.js.map +1 -1
  11. package/lib/cli/cli.js.map +1 -1
  12. package/lib/cli/index.js.map +1 -1
  13. package/lib/cli/processCliArgs.js.map +1 -1
  14. package/lib/cli/processConfigFile.js.map +1 -1
  15. package/lib/cli/serviceGenerationRun.js.map +1 -1
  16. package/lib/data-model/DataModel.js.map +1 -1
  17. package/lib/data-model/DataModelDigestion.js +4 -7
  18. package/lib/data-model/DataModelDigestion.js.map +1 -1
  19. package/lib/data-model/DataModelDigestionV2.js.map +1 -1
  20. package/lib/data-model/DataModelDigestionV4.js.map +1 -1
  21. package/lib/data-model/DataTypeModel.js.map +1 -1
  22. package/lib/data-model/NamingHelper.js.map +1 -1
  23. package/lib/data-model/ServiceConfigHelper.js.map +1 -1
  24. package/lib/data-model/edmx/ODataEdmxModelBase.js.map +1 -1
  25. package/lib/data-model/edmx/ODataEdmxModelV3.js.map +1 -1
  26. package/lib/data-model/edmx/ODataEdmxModelV4.js.map +1 -1
  27. package/lib/data-model/validation/NameClashValidator.js.map +1 -1
  28. package/lib/data-model/validation/NameValidator.js.map +1 -1
  29. package/lib/data-model/validation/NoopValidator.js.map +1 -1
  30. package/lib/defaultConfig.js +1 -1
  31. package/lib/defaultConfig.js.map +1 -1
  32. package/lib/download/downloadMetadata.js.map +1 -1
  33. package/lib/download/index.js.map +1 -1
  34. package/lib/download/storeMetadata.js.map +1 -1
  35. package/lib/evaluateConfig.js.map +1 -1
  36. package/lib/generator/ImportContainer.js.map +1 -1
  37. package/lib/generator/ImportedNameValidator.js.map +1 -1
  38. package/lib/generator/ModelGenerator.js +18 -9
  39. package/lib/generator/ModelGenerator.js.map +1 -1
  40. package/lib/generator/QueryObjectGenerator.js +9 -5
  41. package/lib/generator/QueryObjectGenerator.js.map +1 -1
  42. package/lib/generator/ServiceGenerator.d.ts +1 -1
  43. package/lib/generator/ServiceGenerator.js +9 -5
  44. package/lib/generator/ServiceGenerator.js.map +1 -1
  45. package/lib/generator/import/ImportObjects.d.ts +6 -3
  46. package/lib/generator/import/ImportObjects.js +6 -6
  47. package/lib/generator/import/ImportObjects.js.map +1 -1
  48. package/lib/generator/index.js.map +1 -1
  49. package/lib/index.js.map +1 -1
  50. package/lib/project/FileHandler.js.map +1 -1
  51. package/lib/project/ProjectManager.js.map +1 -1
  52. package/lib/project/TsMorphHelper.js.map +1 -1
  53. package/lib/project/formatter/BaseFormatter.js.map +1 -1
  54. package/lib/project/formatter/FileFormatter.js.map +1 -1
  55. package/lib/project/formatter/NoopFormatter.js.map +1 -1
  56. package/lib/project/formatter/PrettierFormatter.js.map +1 -1
  57. package/lib/project/formatter/index.js.map +1 -1
  58. package/lib/project/logger/logFilePath.js.map +1 -1
  59. package/lib/run-cli.js +0 -0
  60. package/lib/run-cli.js.map +1 -1
  61. package/package.json +10 -11
@@ -14,8 +14,10 @@ export declare const LIB_MODULES: {
14
14
  export declare enum CoreImports {
15
15
  DeferredContent = 0,
16
16
  ODataCollectionResponse = 1,
17
- ODataModelResponse = 2,
18
- ODataValueResponse = 3
17
+ ODataModelResponseV4 = 2,
18
+ ODataValueResponse = 3,
19
+ ODataEntityModelResponseV2 = 4,
20
+ ODataComplexModelResponseV2 = 5
19
21
  }
20
22
  /**
21
23
  * For all core imports that are versioned two files exist, one for V2, one for V4.
@@ -62,7 +64,8 @@ export declare enum ServiceImports {
62
64
  EntityTypeService = 3,
63
65
  PrimitiveTypeService = 4,
64
66
  CollectionService = 5,
65
- EntitySetService = 6
67
+ EntitySetService = 6,
68
+ ComplexTypeService = 7
66
69
  }
67
70
  /**
68
71
  * For all versioned imports two files exist, one for V2, one for V4.
@@ -15,19 +15,17 @@ export var CoreImports;
15
15
  (function (CoreImports) {
16
16
  CoreImports[CoreImports["DeferredContent"] = 0] = "DeferredContent";
17
17
  CoreImports[CoreImports["ODataCollectionResponse"] = 1] = "ODataCollectionResponse";
18
- CoreImports[CoreImports["ODataModelResponse"] = 2] = "ODataModelResponse";
18
+ CoreImports[CoreImports["ODataModelResponseV4"] = 2] = "ODataModelResponseV4";
19
19
  CoreImports[CoreImports["ODataValueResponse"] = 3] = "ODataValueResponse";
20
+ CoreImports[CoreImports["ODataEntityModelResponseV2"] = 4] = "ODataEntityModelResponseV2";
21
+ CoreImports[CoreImports["ODataComplexModelResponseV2"] = 5] = "ODataComplexModelResponseV2";
20
22
  })(CoreImports || (CoreImports = {}));
21
23
  /**
22
24
  * For all core imports that are versioned two files exist, one for V2, one for V4.
23
25
  * ODataCollectionResponse = ODataCollectionResponseV2 + ODataCollectionResponseV4
24
26
  *
25
27
  */
26
- export const VERSIONED_CORE_IMPORTS = [
27
- CoreImports.ODataCollectionResponse,
28
- CoreImports.ODataValueResponse,
29
- CoreImports.ODataModelResponse,
30
- ];
28
+ export const VERSIONED_CORE_IMPORTS = [CoreImports.ODataCollectionResponse, CoreImports.ODataValueResponse];
31
29
  /**
32
30
  * Most relevant, but not all imports from query objects library
33
31
  */
@@ -71,6 +69,7 @@ export var ServiceImports;
71
69
  ServiceImports[ServiceImports["PrimitiveTypeService"] = 4] = "PrimitiveTypeService";
72
70
  ServiceImports[ServiceImports["CollectionService"] = 5] = "CollectionService";
73
71
  ServiceImports[ServiceImports["EntitySetService"] = 6] = "EntitySetService";
72
+ ServiceImports[ServiceImports["ComplexTypeService"] = 7] = "ComplexTypeService";
74
73
  })(ServiceImports || (ServiceImports = {}));
75
74
  /**
76
75
  * For all versioned imports two files exist, one for V2, one for V4.
@@ -81,5 +80,6 @@ export const VERSIONED_SERVICE_IMPORTS = [
81
80
  ServiceImports.PrimitiveTypeService,
82
81
  ServiceImports.CollectionService,
83
82
  ServiceImports.EntitySetService,
83
+ ServiceImports.ComplexTypeService,
84
84
  ];
85
85
  //# sourceMappingURL=ImportObjects.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ImportObjects.js","sourceRoot":"","sources":["../../../src/generator/import/ImportObjects.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,+BAA+B;IACxC,SAAS,EAAE,2BAA2B;IACtC,OAAO,EAAE,yBAAyB;CACnC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,mEAAe,CAAA;IACf,mFAAuB,CAAA;IACvB,yEAAkB,CAAA;IAClB,yEAAkB,CAAA;AACpB,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,WAAW,CAAC,uBAAuB;IACnC,WAAW,CAAC,kBAAkB;IAC9B,WAAW,CAAC,kBAAkB;CAC/B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAN,IAAY,kBAgBX;AAhBD,WAAY,kBAAkB;IAC5B,iDAA2B,CAAA;IAC3B,+EAAyD,CAAA;IACzD,iCAAW,CAAA;IACX,6CAAuB,CAAA;IACvB,yCAAmB,CAAA;IACnB,uDAAiC,CAAA;IACjC,yDAAmC,CAAA;IACnC,uEAAiD,CAAA;IACjD,iEAA2C,CAAA;IAC3C,+EAAyD,CAAA;IACzD,yDAAmC,CAAA;IACnC,qEAA+C,CAAA;IAC/C,iEAA2C,CAAA;IAC3C,iDAA2B,CAAA;IAC3B,qDAA+B,CAAA;AACjC,CAAC,EAhBW,kBAAkB,KAAlB,kBAAkB,QAgB7B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,6EAAe,CAAA;IACf,yFAAqB,CAAA;IACrB,iFAAiB,CAAA;AACnB,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,cAQX;AARD,WAAY,cAAc;IACxB,mEAAY,CAAA;IACZ,iFAAmB,CAAA;IACnB,iGAA2B,CAAA;IAC3B,6EAAiB,CAAA;IACjB,mFAAoB,CAAA;IACpB,6EAAiB,CAAA;IACjB,2EAAgB,CAAA;AAClB,CAAC,EARW,cAAc,KAAd,cAAc,QAQzB;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,cAAc,CAAC,iBAAiB;IAChC,cAAc,CAAC,oBAAoB;IACnC,cAAc,CAAC,iBAAiB;IAChC,cAAc,CAAC,gBAAgB;CAChC,CAAC","sourcesContent":["/**\n * All module names of the main dependencies.\n */\nexport const LIB_MODULES = {\n core: \"@odata2ts/odata-core\",\n qObject: \"@odata2ts/odata-query-objects\",\n clientApi: \"@odata2ts/http-client-api\",\n service: \"@odata2ts/odata-service\",\n};\n\n/**\n * All imported entity names from the core API.\n * Includes versioned file names, i.e. according to OData version.\n */\nexport enum CoreImports {\n DeferredContent,\n ODataCollectionResponse, // versioned\n ODataModelResponse, // versioned\n ODataValueResponse, // versioned\n}\n\n/**\n * For all core imports that are versioned two files exist, one for V2, one for V4.\n * ODataCollectionResponse = ODataCollectionResponseV2 + ODataCollectionResponseV4\n *\n */\nexport const VERSIONED_CORE_IMPORTS = [\n CoreImports.ODataCollectionResponse,\n CoreImports.ODataValueResponse,\n CoreImports.ODataModelResponse,\n];\n\n/**\n * Most relevant, but not all imports from query objects library\n */\nexport enum QueryObjectImports {\n QueryObject = \"QueryObject\",\n ENUMERABLE_PROP_DEFINITION = \"ENUMERABLE_PROP_DEFINITION\",\n QId = \"QId\",\n QFunction = \"QFunction\",\n QAction = \"QAction\",\n EnumCollection = \"EnumCollection\",\n QEnumCollection = \"QEnumCollection\",\n QNumericEnumCollection = \"QNumericEnumCollection\",\n QEnumCollectionPath = \"QEnumCollectionPath\",\n QNumericEnumCollectionPath = \"QNumericEnumCollectionPath\",\n QCollectionPath = \"QCollectionPath\",\n QEntityCollectionPath = \"QEntityCollectionPath\",\n OperationReturnType = \"OperationReturnType\",\n ReturnTypes = \"ReturnTypes\",\n QComplexParam = \"QComplexParam\",\n}\n\n/**\n * All imports from HTTP client API.\n */\nexport enum ClientApiImports {\n ODataHttpClient,\n ODataHttpClientConfig,\n HttpResponseModel,\n}\n\n/**\n * All imports from service library.\n * Includes versioned file names, i.e. according to OData version.\n */\nexport enum ServiceImports {\n ODataService,\n ODataServiceOptions,\n ODataServiceOptionsInternal,\n EntityTypeService,\n PrimitiveTypeService,\n CollectionService,\n EntitySetService,\n}\n\n/**\n * For all versioned imports two files exist, one for V2, one for V4.\n * EntityTypeService = EntityTypeServiceV2 + EntityTypeServiceV4\n */\nexport const VERSIONED_SERVICE_IMPORTS = [\n ServiceImports.EntityTypeService,\n ServiceImports.PrimitiveTypeService,\n ServiceImports.CollectionService,\n ServiceImports.EntitySetService,\n];\n"]}
1
+ {"version":3,"file":"ImportObjects.js","sourceRoot":"","sources":["../../../src/generator/import/ImportObjects.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,+BAA+B;IACxC,SAAS,EAAE,2BAA2B;IACtC,OAAO,EAAE,yBAAyB;CACnC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAN,IAAY,WAOX;AAPD,WAAY,WAAW;IACrB,mEAAe,CAAA;IACf,mFAAuB,CAAA;IACvB,6EAAoB,CAAA;IACpB,yEAAkB,CAAA;IAClB,yFAA0B,CAAA;IAC1B,2FAA2B,CAAA;AAC7B,CAAC,EAPW,WAAW,KAAX,WAAW,QAOtB;AAED;;;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-core\";\n\n/**\n * All module names of the main dependencies.\n */\nexport const LIB_MODULES = {\n core: \"@odata2ts/odata-core\",\n qObject: \"@odata2ts/odata-query-objects\",\n clientApi: \"@odata2ts/http-client-api\",\n service: \"@odata2ts/odata-service\",\n};\n\n/**\n * All imported entity names from the core API.\n * Includes versioned file names, i.e. according to OData version.\n */\nexport enum CoreImports {\n DeferredContent,\n ODataCollectionResponse, // versioned\n ODataModelResponseV4,\n ODataValueResponse, // versioned\n ODataEntityModelResponseV2,\n ODataComplexModelResponseV2,\n}\n\n/**\n * For all core imports that are versioned two files exist, one for V2, one for V4.\n * ODataCollectionResponse = ODataCollectionResponseV2 + ODataCollectionResponseV4\n *\n */\nexport const VERSIONED_CORE_IMPORTS = [CoreImports.ODataCollectionResponse, CoreImports.ODataValueResponse];\n\n/**\n * Most relevant, but not all imports from query objects library\n */\nexport enum QueryObjectImports {\n QueryObject = \"QueryObject\",\n ENUMERABLE_PROP_DEFINITION = \"ENUMERABLE_PROP_DEFINITION\",\n QId = \"QId\",\n QFunction = \"QFunction\",\n QAction = \"QAction\",\n EnumCollection = \"EnumCollection\",\n QEnumCollection = \"QEnumCollection\",\n QNumericEnumCollection = \"QNumericEnumCollection\",\n QEnumCollectionPath = \"QEnumCollectionPath\",\n QNumericEnumCollectionPath = \"QNumericEnumCollectionPath\",\n QCollectionPath = \"QCollectionPath\",\n QEntityCollectionPath = \"QEntityCollectionPath\",\n OperationReturnType = \"OperationReturnType\",\n ReturnTypes = \"ReturnTypes\",\n QComplexParam = \"QComplexParam\",\n}\n\n/**\n * All imports from HTTP client API.\n */\nexport enum ClientApiImports {\n ODataHttpClient,\n ODataHttpClientConfig,\n HttpResponseModel,\n}\n\n/**\n * All imports from service library.\n * Includes versioned file names, i.e. according to OData version.\n */\nexport enum ServiceImports {\n ODataService,\n ODataServiceOptions,\n ODataServiceOptionsInternal,\n EntityTypeService,\n PrimitiveTypeService,\n CollectionService,\n EntitySetService,\n ComplexTypeService,\n}\n\n/**\n * For all versioned imports two files exist, one for V2, one for V4.\n * EntityTypeService = EntityTypeServiceV2 + EntityTypeServiceV4\n */\nexport const VERSIONED_SERVICE_IMPORTS = [\n ServiceImports.EntityTypeService,\n ServiceImports.PrimitiveTypeService,\n ServiceImports.CollectionService,\n ServiceImports.EntitySetService,\n ServiceImports.ComplexTypeService,\n];\n"]}
@@ -1 +1 @@
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"]}
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\";\nexport { generateQueryObjects } from \"./QueryObjectGenerator.js\";\nexport { generateServices } from \"./ServiceGenerator.js\";\n"]}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
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
+ {"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\";\nexport * from \"./NamingModel.js\";\nexport * from \"./defaultConfig.js\";\nexport * from \"./TypeModel.js\";\n"]}
@@ -1 +1 @@
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,EAAE,CAAC,CAAC;YAC9E,2CAA2C;YAC3C,IAAI,C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C,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
+ {"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,QAA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AS,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;iBACvC;gBAAC,OAAO,UAAU,EAAE;oBACnB,OAAO,CAAC,KAAK,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\";\n\nimport { SourceFile } from \"ts-morph\";\n\nimport { ImportContainer } from \"../generator/ImportContainer.js\";\nimport { EmitModes } from \"../OptionModel.js\";\nimport { FileFormatter } from \"./formatter/FileFormatter.js\";\n\nexport class FileHandler {\n constructor(\n public readonly path: string,\n public readonly fileName: string,\n protected readonly file: SourceFile,\n protected readonly importContainer: ImportContainer,\n protected formatter: FileFormatter | undefined,\n public readonly allowTypeChecking: boolean\n ) {}\n\n public getFullFilePath() {\n return this.path ? `${this.path}/${this.fileName}` : this.fileName;\n }\n\n public getFile() {\n return this.file;\n }\n\n public getImports() {\n return this.importContainer;\n }\n\n public async write(emitMode: EmitModes, noOutput = false) {\n this.file.addImportDeclarations(this.importContainer.getImportDeclarations());\n // add ts-nocheck to beginning of each file\n if (!this.allowTypeChecking) {\n const stmts = this.file.addStatements((writer) => {\n writer.writeLine(\"// @ts-nocheck\");\n });\n stmts[0].setOrder(0);\n }\n\n if (noOutput) {\n return;\n }\n\n switch (emitMode) {\n case EmitModes.js:\n case EmitModes.js_dts:\n return this.file.emit();\n case EmitModes.dts:\n return this.file.emit({ emitOnlyDtsFiles: true });\n case EmitModes.ts:\n return this.formatAndWriteFile();\n default:\n throw new Error(`Emit mode \"${emitMode}\" is invalid!`);\n }\n }\n\n private async formatAndWriteFile() {\n const fileName = this.file.getFilePath();\n const content = this.file.getFullText();\n\n try {\n const formatted = this.formatter ? await this.formatter.format(content) : content;\n\n try {\n return writeFile(fileName, formatted);\n } catch (writeError) {\n console.error(`Failed to write file [/${fileName}]`, writeError);\n process.exit(3);\n }\n } catch (formattingError) {\n console.error(\"Formatting failed\", formattingError);\n await writeFile(\"error.log\", formattingError?.toString() || \"no error message!\");\n process.exit(99);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectManager.js","sourceRoot":"","sources":["../../src/project/ProjectManager.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAmB,OAAO,EAAc,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAI9D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAahE,MAAM,UAAgB,oBAAoB,CACxC,SAAiB,EACjB,QAAmB,EACnB,YAA0B,EAC1B,SAAoB,EACpB,OAA8B;;QAE9B,MAAM,EAAE,WAAW,GAAG,KAAK,EAAE,YAAY,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC;QACxE,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,eAAe,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE1F,MAAM,YAAY,GAAoB,MAAM,0BAA0B,CAAC,YAAY,EAAE,QAAQ,EAAE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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
+ {"version":3,"file":"ProjectManager.js","sourceRoot":"","sources":["../../src/project/ProjectManager.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAmB,OAAO,EAAc,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAI9D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAahE,MAAM,UAAgB,oBAAoB,CACxC,SAAiB,EACjB,QAAmB,EACnB,YAA0B,EAC1B,SAAoB,EACpB,OAA8B;;QAE9B,MAAM,EAAE,WAAW,GAAG,KAAK,EAAE,YAAY,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC;QACxE,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,eAAe,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE1F,MAAM,YAAY,GAAoB,MAAM,0BAA0B,CAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAE1G,MAAM,EAAE,GAAG,IAAI,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE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CAAC;KAAA;CACF","sourcesContent":["import * as path from \"path\";\nimport { mkdirp } from \"mkdirp\";\nimport { CompilerOptions, Project, SourceFile } from \"ts-morph\";\nimport { firstCharLowerCase } from \"xml2js/lib/processors.js\";\nimport { DataModel } from \"../data-model/DataModel.js\";\nimport { EntityType } from \"../data-model/DataTypeModel.js\";\nimport { NamingHelper } from \"../data-model/NamingHelper.js\";\nimport { ImportContainer } from \"../generator/ImportContainer.js\";\nimport { EmitModes } from \"../OptionModel.js\";\nimport { FileHandler } from \"./FileHandler.js\";\nimport { FileFormatter } from \"./formatter/FileFormatter.js\";\nimport { createFormatter } from \"./formatter/index.js\";\nimport { loadTsMorphCompilerOptions } from \"./TsMorphHelper.js\";\n\nexport interface ProjectManagerOptions {\n usePrettier?: boolean;\n tsConfigPath?: string;\n bundledFileGeneration?: boolean;\n /**\n * for testing purposes, turn this on and retrieve all generated files via getCachedFiles\n */\n noOutput?: boolean;\n allowTypeChecking?: boolean;\n}\n\nexport async function createProjectManager(\n outputDir: string,\n emitMode: EmitModes,\n namingHelper: NamingHelper,\n dataModel: DataModel,\n options: ProjectManagerOptions,\n): Promise<ProjectManager> {\n const { usePrettier = false, tsConfigPath = \"tsconfig.json\" } = options;\n const formatter = usePrettier ? await createFormatter(outputDir, usePrettier) : undefined;\n\n const compilerOpts: CompilerOptions = await loadTsMorphCompilerOptions(tsConfigPath, emitMode, outputDir);\n\n const pm = new ProjectManager(outputDir, emitMode, namingHelper, dataModel, formatter, compilerOpts, {\n usePrettier,\n tsConfigPath,\n ...options,\n });\n\n await pm.init();\n\n return pm;\n}\n\nexport class ProjectManager {\n private project!: Project;\n\n private mainServiceFile: FileHandler | undefined;\n private mainModelFile: FileHandler | undefined;\n private mainQFile: FileHandler | undefined;\n\n private readonly cachedFiles: Map<string, SourceFile> | undefined;\n\n constructor(\n protected outputDir: string,\n protected emitMode: EmitModes,\n protected namingHelper: NamingHelper,\n protected dataModel: DataModel,\n protected formatter: FileFormatter | undefined,\n compilerOptions: CompilerOptions | undefined,\n protected options: ProjectManagerOptions,\n ) {\n // Create ts-morph project\n this.project = new Project({\n // manipulationSettings: this.formatter.getSettings(),\n skipAddingFilesFromTsConfig: true,\n compilerOptions,\n });\n\n if (options.noOutput) {\n this.cachedFiles = new Map();\n }\n }\n\n public getDataModel() {\n return this.dataModel;\n }\n\n /**\n * Only filled when noOutput=true\n */\n public getCachedFiles() {\n return this.cachedFiles!;\n }\n\n private async writeFile(fileHandler: FileHandler) {\n if (this.options.noOutput) {\n await fileHandler.write(this.emitMode, true);\n this.cachedFiles!.set(fileHandler.getFullFilePath(), fileHandler.getFile());\n\n return;\n }\n\n return fileHandler.write(this.emitMode);\n }\n\n private createFile(\n name: string,\n reservedNames?: Array<string> | undefined,\n additionalPath: string = \"\",\n forceTypeChecking = false,\n ): FileHandler {\n const fileName = path.join(this.outputDir, additionalPath, `${name}.ts`);\n const imports = new ImportContainer(\n additionalPath,\n name,\n this.dataModel,\n this.namingHelper.getFileNames(),\n !!this.options.bundledFileGeneration,\n reservedNames,\n );\n\n return new FileHandler(\n additionalPath,\n name,\n this.project.createSourceFile(fileName),\n imports,\n this.formatter,\n forceTypeChecking || !!this.options.allowTypeChecking,\n );\n }\n\n public async init() {\n if (!this.options.bundledFileGeneration) {\n // ensure folder for each model: we do this at this point for performance reasons\n await Promise.all(this.dataModel.getModelTypes().map((mt) => mkdirp(path.join(this.outputDir, mt.folderPath))));\n }\n }\n\n public initModels() {\n if (this.options.bundledFileGeneration) {\n // collect reserved names, that is names of classes we're going to create => imports must take them into account\n const reservedWords = this.dataModel.getModelTypes().reduce<Array<string>>((collector, model) => {\n const asEntityType = model as EntityType;\n collector.push(model.modelName);\n if (asEntityType.editableName) {\n collector.push(asEntityType.editableName);\n }\n if (asEntityType.id?.modelName) {\n collector.push(asEntityType.id.modelName);\n }\n this.dataModel.getAllEntityOperations(model.fqName).forEach((op) => {\n if (op.parameters.length) {\n collector.push(op.paramsModelName);\n }\n });\n\n return collector;\n }, []);\n this.dataModel.getUnboundOperationTypes().forEach((op) => {\n if (op.parameters.length) {\n reservedWords.push(op.paramsModelName);\n }\n });\n\n this.mainModelFile = this.createFile(this.namingHelper.getFileNames().model, reservedWords);\n }\n }\n\n public async finalizeModels() {\n if (\n this.mainModelFile &&\n (this.options.bundledFileGeneration || this.mainModelFile.getFile().getFullText().length)\n ) {\n await this.writeFile(this.mainModelFile);\n }\n }\n\n public initQObjects() {\n if (this.options.bundledFileGeneration) {\n // collect reserved names, that is names of classes we're going to create => imports must take them into account\n const reservedWords = this.dataModel.getModelTypes().reduce<Array<string>>((collector, model) => {\n const asEntityType = model as EntityType;\n if (asEntityType.qName) {\n collector.push(asEntityType.qName, firstCharLowerCase(asEntityType.qName));\n }\n if (asEntityType.id?.qName) {\n collector.push(asEntityType.id.qName);\n }\n this.dataModel.getAllEntityOperations(model.fqName).forEach((op) => {\n collector.push(op.qName);\n });\n\n return collector;\n }, []);\n this.dataModel.getUnboundOperationTypes().forEach((op) => {\n reservedWords.push(op.qName);\n });\n\n this.mainQFile = this.createFile(this.namingHelper.getFileNames().qObject, reservedWords);\n }\n }\n\n public async finalizeQObjects() {\n if (this.mainQFile && (this.options.bundledFileGeneration || this.mainQFile.getFile().getFullText().length)) {\n await this.writeFile(this.mainQFile);\n }\n }\n\n public initServices() {\n const mainServiceName = this.namingHelper.getMainServiceName();\n const reservedNames = [mainServiceName];\n\n if (this.options.bundledFileGeneration) {\n [...this.dataModel.getEntityTypes(), ...this.dataModel.getComplexTypes()].reduce((collector, model) => {\n collector.push(model.serviceName, model.serviceCollectionName);\n return collector;\n }, reservedNames);\n }\n\n this.mainServiceFile = this.createFile(mainServiceName, reservedNames);\n }\n\n public async finalizeServices() {\n if (this.mainServiceFile) {\n await this.writeFile(this.mainServiceFile);\n }\n }\n\n public getMainServiceFile() {\n return this.mainServiceFile!;\n }\n\n public createOrGetMainModelFile(reservedNames?: Array<string>) {\n if (!this.mainModelFile) {\n this.mainModelFile = this.createFile(this.namingHelper.getFileNames().model, reservedNames, \"\", true);\n }\n return this.mainModelFile;\n }\n\n public createOrGetMainQObjectFile(reservedNames?: Array<string>) {\n if (!this.mainQFile) {\n this.mainQFile = this.createFile(this.namingHelper.getFileNames().qObject, reservedNames);\n }\n return this.mainQFile;\n }\n\n public createOrGetModelFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\n if (this.mainModelFile) {\n return this.mainModelFile;\n }\n\n // model files always allow for type checking\n return this.createFile(name, reservedNames, folderPath, true);\n }\n public createOrGetQObjectFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\n if (this.mainQFile) {\n return this.mainQFile;\n }\n\n return this.createFile(name, reservedNames, folderPath);\n }\n public createOrGetServiceFile(folderPath: string, name: string, reservedNames?: Array<string> | undefined) {\n if (this.options.bundledFileGeneration) {\n return this.mainServiceFile!;\n }\n\n return this.createFile(name, reservedNames, folderPath);\n }\n\n public async finalizeFile(file: FileHandler) {\n // write individual files in unbundled mode & if this is not one of the main files on root level\n if (\n !this.options.bundledFileGeneration &&\n file.path !== \"\" &&\n !Object.values(this.namingHelper.getFileNames()).includes(file.fileName)\n ) {\n await this.writeFile(file);\n }\n }\n}\n"]}
@@ -1 +1 @@
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,a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ChF,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
+ {"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,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AAE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC","sourcesContent":["import { NewLineKind } from \"@ts-morph/common\";\nimport { CompilerOptions, ModuleKind, ModuleResolutionKind, ScriptTarget } from \"ts-morph\";\nimport load, { TsConfigLoaderParams, TsConfigLoaderResult } from \"tsconfig-loader\";\nimport ts from \"typescript\";\nimport { EmitModes } from \"../OptionModel.js\";\n\n/**\n * Loads the TS configuration from the specified path.\n * Then maps the appropriate options to ts-morph compiler options.\n *\n * @param tsConfigPath path to tsconfig.json\n * @param emitMode the used emit mode\n * @param outputDir the used output dir\n */\nexport async function loadTsMorphCompilerOptions(tsConfigPath: string, emitMode: EmitModes, outputDir: string) {\n const generateDeclarations = EmitModes.js_dts === emitMode || EmitModes.dts === emitMode;\n\n // load config file\n // NOTE: not async...\n // @ts-ignore\n const doLoad: ({ filename, cwd }?: TsConfigLoaderParams) => TsConfigLoaderResult | undefined = load?.default ?? load;\n const conf = doLoad({ filename: tsConfigPath });\n\n const {\n // ignored props\n noEmit, // we always want to emit\n importsNotUsedAsValues, // type is missing\n jsx,\n plugins,\n // mapped props\n moduleResolution,\n lib,\n module,\n newLine,\n target,\n rootDir,\n rootDirs,\n ...passThrough\n } = conf?.tsConfig.compilerOptions || {};\n\n const compilerOpts: CompilerOptions = {\n ...passThrough,\n outDir: outputDir,\n declaration: generateDeclarations,\n moduleResolution: getModuleResolutionKind(moduleResolution),\n module: getModuleKind(module),\n target: getTarget(target),\n };\n if (lib) {\n compilerOpts.lib = lib as string[];\n }\n if (newLine) {\n compilerOpts.newLine = newLine?.toLowerCase() === \"lf\" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed;\n }\n\n return compilerOpts;\n}\n\n/**\n * Maps to lower case.\n * Also translates \"node\" to \"nodejs\".\n *\n * @param moduleResolution\n */\nfunction getModuleResolutionKind(\n moduleResolution: string | undefined | Record<string, any>,\n): ModuleResolutionKind | undefined {\n const modRes =\n typeof moduleResolution === \"string\"\n ? moduleResolution.toLowerCase() === \"node\"\n ? \"nodejs\"\n : moduleResolution.toLowerCase()\n : undefined;\n const matchedKey = Object.keys(ts.ModuleResolutionKind).find(\n (mk): mk is keyof typeof ModuleResolutionKind => mk.toLowerCase() === modRes,\n );\n return matchedKey ? (ts.ModuleResolutionKind[matchedKey] as ModuleResolutionKind) : undefined;\n}\n\nfunction getModuleKind(module: string | undefined | Record<string, any>): ModuleKind | undefined {\n const mod = typeof module === \"string\" ? module.toLowerCase() : undefined;\n const matchedKey = Object.keys(ts.ModuleKind).find((mk): mk is keyof typeof ModuleKind => mk.toLowerCase() === mod);\n return matchedKey ? (ts.ModuleKind[matchedKey] as ModuleKind) : undefined;\n}\n\nfunction getTarget(target: string | undefined | Record<string, any>): ScriptTarget | undefined {\n const t = typeof target === \"string\" ? target.toLowerCase() : undefined;\n const matchedKey = Object.keys(ts.ScriptTarget).find((st): st is keyof typeof ScriptTarget => st.toLowerCase() === t);\n return matchedKey ? (ts.ScriptTarget[matchedKey] as ScriptTarget) : undefined;\n}\n"]}
@@ -1 +1 @@
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
+ {"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\";\n\nimport { FileFormatter } from \"./FileFormatter.js\";\n\n/**\n * Abstract formatter.\n *\n * @export\n * @abstract\n * @class Formatter\n */\nexport abstract class BaseFormatter implements FileFormatter {\n /**\n * Path of the output file.\n *\n * @protected\n * @type {string}\n * @memberof Formatter\n */\n protected output: string;\n\n /**\n * Initialized ts-morph manipulation settings for project creation.\n *\n * @protected\n * @type {Partial<ManipulationSettings>}\n * @memberof Formatter\n */\n protected settings!: Partial<ManipulationSettings>;\n\n /**\n * Default constructor\n * @param {string} output Path of the output file\n * @memberof Formatter\n */\n constructor(output: string) {\n this.output = output;\n }\n\n /**\n * Initializes the formatter.\n *\n * @abstract\n * @returns {Promise<BaseFormatter>} Initialized formatter\n * @memberof Formatter\n */\n public abstract init(): Promise<BaseFormatter>;\n\n /**\n * Returns initialized ts-morph manipuation settings.\n *\n * @returns {Promise<Partial<ManipulationSettings>>} ts-morph manipulation settings\n * @memberof Formatter\n */\n public getSettings(): Partial<ManipulationSettings> {\n return this.settings;\n }\n\n public abstract format(source: string): Promise<string>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FileFormatter.js","sourceRoot":"","sources":["../../../src/project/formatter/FileFormatter.ts"],"names":[],"mappings":"","sourcesContent":["import { ManipulationSettings } from \"ts-morph\";\r\n\r\nexport interface FileFormatter {\r\n /**\r\n * Returns initialized ts-morph manipulation settings.\r\n *\r\n * @returns {Partial<ManipulationSettings>} ts-morph manipulation settings\r\n */\r\n getSettings(): Partial<ManipulationSettings>;\r\n\r\n /**\r\n * Formats a given source code.\r\n *\r\n * @param {string} source Source code to format\r\n * @returns {string} Formatted source code\r\n */\r\n format(source: string): Promise<string>;\r\n}\r\n"]}
1
+ {"version":3,"file":"FileFormatter.js","sourceRoot":"","sources":["../../../src/project/formatter/FileFormatter.ts"],"names":[],"mappings":"","sourcesContent":["import { ManipulationSettings } from \"ts-morph\";\n\nexport interface FileFormatter {\n /**\n * Returns initialized ts-morph manipulation settings.\n *\n * @returns {Partial<ManipulationSettings>} ts-morph manipulation settings\n */\n getSettings(): Partial<ManipulationSettings>;\n\n /**\n * Formats a given source code.\n *\n * @param {string} source Source code to format\n * @returns {string} Formatted source code\n */\n format(source: string): Promise<string>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"NoopFormatter.js","sourceRoot":"","sources":["../../../src/project/formatter/NoopFormatter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C;;;;;;OAMG;IACU,IAAI;;YACf,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAED;;;;;;;OAOG;IACU,MAAM,CAAC,MAAc;;YAChC,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF","sourcesContent":["import { BaseFormatter } from \"./BaseFormatter.js\";\r\n\r\n/**\r\n * Prettier formatter.\r\n *\r\n * NOTE: Should be created like this => const formatter = await new NoopFormatter(\"./test.ts\").init();\r\n *\r\n * @export\r\n * @class NoopFormatter\r\n * @extends {Formatter}\r\n */\r\nexport class NoopFormatter extends BaseFormatter {\r\n /**\r\n * Initializes the formatter.\r\n *\r\n * @abstract\r\n * @returns {Promise<Formatter>} Initialized formatter\r\n * @memberof Formatter\r\n */\r\n public async init(): Promise<BaseFormatter> {\r\n return this;\r\n }\r\n\r\n /**\r\n * Formats a given source code.\r\n *\r\n * @abstract\r\n * @param {string} source Source code to format\r\n * @returns {string} Formatted source code\r\n * @memberof Formatter\r\n */\r\n public async format(source: string): Promise<string> {\r\n return source;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"NoopFormatter.js","sourceRoot":"","sources":["../../../src/project/formatter/NoopFormatter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C;;;;;;OAMG;IACU,IAAI;;YACf,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAED;;;;;;;OAOG;IACU,MAAM,CAAC,MAAc;;YAChC,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF","sourcesContent":["import { BaseFormatter } from \"./BaseFormatter.js\";\n\n/**\n * Prettier formatter.\n *\n * NOTE: Should be created like this => const formatter = await new NoopFormatter(\"./test.ts\").init();\n *\n * @export\n * @class NoopFormatter\n * @extends {Formatter}\n */\nexport class NoopFormatter extends BaseFormatter {\n /**\n * Initializes the formatter.\n *\n * @abstract\n * @returns {Promise<Formatter>} Initialized formatter\n * @memberof Formatter\n */\n public async init(): Promise<BaseFormatter> {\n return this;\n }\n\n /**\n * Formats a given source code.\n *\n * @abstract\n * @param {string} source Source code to format\n * @returns {string} Formatted source code\n * @memberof Formatter\n */\n public async format(source: string): Promise<string> {\n return source;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PrettierFormatter.js","sourceRoot":"","sources":["../../../src/project/formatter/PrettierFormatter.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,OAAO,iBAAkB,SAAQ,aAAa;IAUlD;;;;;OAKG;IACU,IAAI;;YACf,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAE1D,IAAI,OAAO,EAAE;gBACX,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;gBACvB,IAAI,CAAC,QAAQ,GAAG;oBACd,eAAe,EAAE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;oBACrF,qDAAqD,EACnD,IAAI,CAAC,OAAO,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI;oBAChF,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;oBACxD,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM;oBACzE,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;iBACxE,CAAC;aACH;iBAAM;gBACL,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;aACpB;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAED;;;;;;;OAOG;IACU,MAAM,CAAC,MAAc;;YAChC,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,kBAC3B,MAAM,EAAE,YAAY,IACjB,IAAI,CAAC,OAAO,EACf,CAAC;QACL,CAAC;KAAA;IAED;;;;;;;;OAQG;IACK,kBAAkB,CAAC,OAA4B,EAAE,QAA4B;QACnF,IAAI,OAAO;YAAE,OAAO,eAAe,CAAC,GAAG,CAAC;QAExC,QAAQ,QAAQ,EAAE;YAChB,KAAK,CAAC;gBACJ,OAAO,eAAe,CAAC,SAAS,CAAC;YACnC,KAAK,CAAC;gBACJ,OAAO,eAAe,CAAC,UAAU,CAAC;YACpC,KAAK,CAAC;gBACJ,OAAO,eAAe,CAAC,WAAW,CAAC;YACrC;gBACE,OAAO,eAAe,CAAC,SAAS,CAAC;SACpC;IACH,CAAC;IAED;;;;;;;OAOG;IACK,cAAc,CAAC,GAAuB;QAC5C,QAAQ,GAAG,EAAE;YACX,KAAK,IAAI;gBACP,OAAO,WAAW,CAAC,QAAQ,CAAC;YAC9B,KAAK,MAAM;gBACT,OAAO,WAAW,CAAC,sBAAsB,CAAC;YAC5C,KAAK,IAAI;gBACP,OAAO,WAAW,CAAC,sBAAsB,CAAC;YAC5C,KAAK,MAAM;gBACT,OAAO,WAAW,CAAC,QAAQ,CAAC;YAC9B;gBACE,OAAO,WAAW,CAAC,QAAQ,CAAC;SAC/B;IACH,CAAC;CACF","sourcesContent":["import prettier from \"prettier\";\r\nimport { IndentationText, NewLineKind, QuoteKind } from \"ts-morph\";\r\n\r\nimport { BaseFormatter } from \"./BaseFormatter.js\";\r\n\r\nexport class PrettierFormatter extends BaseFormatter {\r\n /**\r\n * Prettier options found in the project.\r\n *\r\n * @private\r\n * @type {prettier.Options}\r\n * @memberof PrettierFormatter\r\n */\r\n private options!: prettier.Options;\r\n\r\n /**\r\n * Initializes the formatter.\r\n *\r\n * @returns {Promise<PrettierFormatter>} Initialized formatter\r\n * @memberof PrettierFormatter\r\n */\r\n public async init(): Promise<PrettierFormatter> {\r\n const options = await prettier.resolveConfig(this.output);\r\n\r\n if (options) {\r\n this.options = options;\r\n this.settings = {\r\n indentationText: this.convertIndentation(this.options.useTabs, this.options.tabWidth),\r\n insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces:\r\n this.options.bracketSpacing !== undefined ? this.options.bracketSpacing : true,\r\n newLineKind: this.convertNewline(this.options.endOfLine),\r\n quoteKind: this.options.singleQuote ? QuoteKind.Single : QuoteKind.Double,\r\n useTrailingCommas: this.options.trailingComma === \"none\" ? false : true,\r\n };\r\n } else {\r\n this.settings = {};\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Formats a given source code.\r\n *\r\n * @abstract\r\n * @param {string} source Source code to format\r\n * @returns {string} Formatted source code\r\n * @memberof Formatter\r\n */\r\n public async format(source: string): Promise<string> {\r\n return prettier.format(source, {\r\n parser: \"typescript\",\r\n ...this.options,\r\n });\r\n }\r\n\r\n /**\r\n * Converts prettier indentation config to ts-morph settings.\r\n *\r\n * @private\r\n * @param {boolean | undefined} useTabs Flag, whether to use tabs or not\r\n * @param {number | undefined} tabWidth Width of a simulated tab, each number represents a space\r\n * @returns {IndentationText} Converted indentation text\r\n * @memberof PrettierFormatter\r\n */\r\n private convertIndentation(useTabs: boolean | undefined, tabWidth: number | undefined): IndentationText {\r\n if (useTabs) return IndentationText.Tab;\r\n\r\n switch (tabWidth) {\r\n case 2:\r\n return IndentationText.TwoSpaces;\r\n case 4:\r\n return IndentationText.FourSpaces;\r\n case 8:\r\n return IndentationText.EightSpaces;\r\n default:\r\n return IndentationText.TwoSpaces;\r\n }\r\n }\r\n\r\n /**\r\n * Converts prettier newline config to ts-morph settings.\r\n *\r\n * @private\r\n * @param {string | undefined} eol prettier end-of-line config\r\n * @returns {NewLineKind | undefined} Converted new line kind\r\n * @memberof PrettierFormatter\r\n */\r\n private convertNewline(eol: string | undefined): NewLineKind | undefined {\r\n switch (eol) {\r\n case \"lf\":\r\n return NewLineKind.LineFeed;\r\n case \"crlf\":\r\n return NewLineKind.CarriageReturnLineFeed;\r\n case \"cr\":\r\n return NewLineKind.CarriageReturnLineFeed;\r\n case \"auto\":\r\n return NewLineKind.LineFeed;\r\n default:\r\n return NewLineKind.LineFeed;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PrettierFormatter.js","sourceRoot":"","sources":["../../../src/project/formatter/PrettierFormatter.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,OAAO,iBAAkB,SAAQ,aAAa;IAUlD;;;;;OAKG;IACU,IAAI;;YACf,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAE1D,IAAI,OAAO,EAAE;gBACX,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;gBACvB,IAAI,CAAC,QAAQ,GAAG;oBACd,eAAe,EAAE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;oBACrF,qDAAqD,EACnD,IAAI,CAAC,OAAO,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI;oBAChF,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,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,CAAC;CACF","sourcesContent":["import prettier from \"prettier\";\nimport { IndentationText, NewLineKind, QuoteKind } from \"ts-morph\";\n\nimport { BaseFormatter } from \"./BaseFormatter.js\";\n\nexport class PrettierFormatter extends BaseFormatter {\n /**\n * Prettier options found in the project.\n *\n * @private\n * @type {prettier.Options}\n * @memberof PrettierFormatter\n */\n private options!: prettier.Options;\n\n /**\n * Initializes the formatter.\n *\n * @returns {Promise<PrettierFormatter>} Initialized formatter\n * @memberof PrettierFormatter\n */\n public async init(): Promise<PrettierFormatter> {\n const options = await prettier.resolveConfig(this.output);\n\n if (options) {\n this.options = options;\n this.settings = {\n indentationText: this.convertIndentation(this.options.useTabs, this.options.tabWidth),\n insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces:\n this.options.bracketSpacing !== undefined ? this.options.bracketSpacing : true,\n newLineKind: this.convertNewline(this.options.endOfLine),\n quoteKind: this.options.singleQuote ? QuoteKind.Single : QuoteKind.Double,\n useTrailingCommas: this.options.trailingComma === \"none\" ? false : true,\n };\n } else {\n this.settings = {};\n }\n\n return this;\n }\n\n /**\n * Formats a given source code.\n *\n * @abstract\n * @param {string} source Source code to format\n * @returns {string} Formatted source code\n * @memberof Formatter\n */\n public async format(source: string): Promise<string> {\n return prettier.format(source, {\n parser: \"typescript\",\n ...this.options,\n });\n }\n\n /**\n * Converts prettier indentation config to ts-morph settings.\n *\n * @private\n * @param {boolean | undefined} useTabs Flag, whether to use tabs or not\n * @param {number | undefined} tabWidth Width of a simulated tab, each number represents a space\n * @returns {IndentationText} Converted indentation text\n * @memberof PrettierFormatter\n */\n private convertIndentation(useTabs: boolean | undefined, tabWidth: number | undefined): IndentationText {\n if (useTabs) return IndentationText.Tab;\n\n switch (tabWidth) {\n case 2:\n return IndentationText.TwoSpaces;\n case 4:\n return IndentationText.FourSpaces;\n case 8:\n return IndentationText.EightSpaces;\n default:\n return IndentationText.TwoSpaces;\n }\n }\n\n /**\n * Converts prettier newline config to ts-morph settings.\n *\n * @private\n * @param {string | undefined} eol prettier end-of-line config\n * @returns {NewLineKind | undefined} Converted new line kind\n * @memberof PrettierFormatter\n */\n private convertNewline(eol: string | undefined): NewLineKind | undefined {\n switch (eol) {\n case \"lf\":\n return NewLineKind.LineFeed;\n case \"crlf\":\n return NewLineKind.CarriageReturnLineFeed;\n case \"cr\":\n return NewLineKind.CarriageReturnLineFeed;\n case \"auto\":\n return NewLineKind.LineFeed;\n default:\n return NewLineKind.LineFeed;\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/project/formatter/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,UAAgB,eAAe,CAAC,SAAiB,EAAE,WAAoB;;QAC3E,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;QAChG,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;QAEvB,OAAO,SAAS,CAAC;IACnB,CAAC;CAAA","sourcesContent":["import type { FileFormatter } from \"./FileFormatter.js\";\r\nimport { NoopFormatter } from \"./NoopFormatter.js\";\r\nimport { PrettierFormatter } from \"./PrettierFormatter.js\";\r\n\r\nexport async function createFormatter(outputDir: string, usePrettier: boolean): Promise<FileFormatter> {\r\n const formatter = usePrettier ? new PrettierFormatter(outputDir) : new NoopFormatter(outputDir);\r\n await formatter.init();\r\n\r\n return formatter;\r\n}\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/project/formatter/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,UAAgB,eAAe,CAAC,SAAiB,EAAE,WAAoB;;QAC3E,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;QAChG,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;QAEvB,OAAO,SAAS,CAAC;IACnB,CAAC;CAAA","sourcesContent":["import type { FileFormatter } from \"./FileFormatter.js\";\nimport { NoopFormatter } from \"./NoopFormatter.js\";\nimport { PrettierFormatter } from \"./PrettierFormatter.js\";\n\nexport async function createFormatter(outputDir: string, usePrettier: boolean): Promise<FileFormatter> {\n const formatter = usePrettier ? new PrettierFormatter(outputDir) : new NoopFormatter(outputDir);\n await formatter.init();\n\n return formatter;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"logFilePath.js","sourceRoot":"","sources":["../../../src/project/logger/logFilePath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,kEAAkE;IAClE,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC5D,+BAA+B;IAC/B,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import path from \"path\";\r\n\r\nexport function logFilePath(filePath: string) {\r\n // we only show file paths relative to work dir of running process\r\n const relativePath = path.relative(process.cwd(), filePath);\r\n // beautify slashes for windows\r\n return relativePath.split(path.sep).join(\"/\");\r\n}\r\n"]}
1
+ {"version":3,"file":"logFilePath.js","sourceRoot":"","sources":["../../../src/project/logger/logFilePath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,kEAAkE;IAClE,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC5D,+BAA+B;IAC/B,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import path from \"path\";\n\nexport function logFilePath(filePath: string) {\n // we only show file paths relative to work dir of running process\n const relativePath = path.relative(process.cwd(), filePath);\n // beautify slashes for windows\n return relativePath.split(path.sep).join(\"/\");\n}\n"]}
package/lib/run-cli.js CHANGED
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"run-cli.js","sourceRoot":"","sources":["../src/run-cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,wCAAwC;AACxC,GAAG,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\r\nimport { run } from \"./cli/cli.js\";\r\n\r\n// noinspection JSIgnoredPromiseFromCall\r\nrun();\r\n"]}
1
+ {"version":3,"file":"run-cli.js","sourceRoot":"","sources":["../src/run-cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,wCAAwC;AACxC,GAAG,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { run } from \"./cli/cli.js\";\n\n// noinspection JSIgnoredPromiseFromCall\nrun();\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odata2ts/odata2ts",
3
- "version": "0.39.1",
3
+ "version": "0.40.1",
4
4
  "description": "Flexible generator to produce various TypeScript artefacts (from simple model interfaces to complete odata clients) from OData metadata files",
5
5
  "keywords": [
6
6
  "odata2ts",
@@ -39,17 +39,16 @@
39
39
  "dev": "yarn generate trippin odata",
40
40
  "generate": "npx tsx src/run-cli.ts",
41
41
  "int-test": "yarn clean && vitest run --dir int-test",
42
- "prepublish": "yarn build",
43
42
  "test": "yarn test-compile && vitest run --dir test",
44
43
  "test-compile": "tsc -p tsconfig.compile.json",
45
44
  "test-compile-large": "npx --node-options=\"--max-old-space-size=14000\" tsc -p tsconfig.compile.json",
46
45
  "testing": "vitest --dir test"
47
46
  },
48
47
  "dependencies": {
49
- "@odata2ts/converter-api": "^0.2.2",
50
- "@odata2ts/converter-runtime": "^0.5.0",
48
+ "@odata2ts/converter-api": "^0.2.5",
49
+ "@odata2ts/converter-runtime": "^0.5.5",
51
50
  "@odata2ts/http-client-api": "^0.6.2",
52
- "@odata2ts/odata-core": "^0.6.0",
51
+ "@odata2ts/odata-core": "^0.6.1",
53
52
  "@prettier/plugin-xml": "^3.4.1",
54
53
  "@types/xml2js": "^0.4.11",
55
54
  "axios": "^1.4.0",
@@ -69,19 +68,19 @@
69
68
  },
70
69
  "devDependencies": {
71
70
  "@odata2ts/converter-v2-to-v4": "^0.5.1",
72
- "@odata2ts/odata-query-objects": "^0.27.0",
73
- "@odata2ts/odata-service": "^0.22.1",
71
+ "@odata2ts/odata-query-objects": "^0.28.1",
72
+ "@odata2ts/odata-service": "^0.23.1",
74
73
  "@odata2ts/test-converters": "^0.5.0",
75
74
  "@types/node": "^22.4.0"
76
75
  },
77
76
  "peerDependencies": {
78
- "@odata2ts/odata-query-objects": "^0.27.0",
79
- "@odata2ts/odata-service": "^0.22.1",
77
+ "@odata2ts/odata-query-objects": "^0.28.1",
78
+ "@odata2ts/odata-service": "^0.23.1",
80
79
  "typescript": ">= 4.7"
81
80
  },
82
81
  "publishConfig": {
83
82
  "access": "public"
84
83
  },
85
- "gitHead": "49e2baafde845055e04903c7b0fcd42787d9441e",
84
+ "gitHead": "b88f1a6e7ce84d26d1d7efa5a61dfc66a4626ec3",
86
85
  "readme": "README.md"
87
- }
86
+ }