@odata2ts/odata2ts 0.36.3 → 0.38.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 (133) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/lib/FactoryFunctionModel.d.ts +7 -7
  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 +7 -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 +27 -27
  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 +33 -37
  41. package/lib/data-model/DataModelDigestionV4.js.map +1 -1
  42. package/lib/data-model/DataTypeModel.d.ts +5 -2
  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 +5 -4
  59. package/lib/data-model/validation/NameClashValidator.js +16 -18
  60. package/lib/data-model/validation/NameClashValidator.js.map +1 -1
  61. package/lib/data-model/validation/NameValidator.d.ts +3 -2
  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 +4 -3
  65. package/lib/data-model/validation/NoopValidator.js +5 -9
  66. package/lib/data-model/validation/NoopValidator.js.map +1 -1
  67. package/lib/defaultConfig.d.ts +1 -1
  68. package/lib/defaultConfig.js +22 -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 +3 -3
  82. package/lib/generator/ImportContainer.js +40 -27
  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 +13 -13
  88. package/lib/generator/ModelGenerator.js.map +1 -1
  89. package/lib/generator/QueryObjectGenerator.d.ts +1 -1
  90. package/lib/generator/QueryObjectGenerator.js +41 -31
  91. package/lib/generator/QueryObjectGenerator.js.map +1 -1
  92. package/lib/generator/ServiceGenerator.d.ts +5 -5
  93. package/lib/generator/ServiceGenerator.js +62 -65
  94. package/lib/generator/ServiceGenerator.js.map +1 -1
  95. package/lib/generator/import/ImportObjects.d.ts +3 -1
  96. package/lib/generator/import/ImportObjects.js +14 -15
  97. package/lib/generator/import/ImportObjects.js.map +1 -1
  98. package/lib/generator/index.d.ts +3 -3
  99. package/lib/generator/index.js +3 -9
  100. package/lib/generator/index.js.map +1 -1
  101. package/lib/index.d.ts +4 -4
  102. package/lib/index.js +4 -7
  103. package/lib/index.js.map +1 -1
  104. package/lib/project/FileHandler.d.ts +3 -3
  105. package/lib/project/FileHandler.js +12 -16
  106. package/lib/project/FileHandler.js.map +1 -1
  107. package/lib/project/ProjectManager.d.ts +5 -5
  108. package/lib/project/ProjectManager.js +25 -32
  109. package/lib/project/ProjectManager.js.map +1 -1
  110. package/lib/project/TsMorphHelper.d.ts +1 -1
  111. package/lib/project/TsMorphHelper.js +21 -22
  112. package/lib/project/TsMorphHelper.js.map +1 -1
  113. package/lib/project/formatter/BaseFormatter.d.ts +1 -1
  114. package/lib/project/formatter/BaseFormatter.js +1 -5
  115. package/lib/project/formatter/BaseFormatter.js.map +1 -1
  116. package/lib/project/formatter/FileFormatter.js +1 -2
  117. package/lib/project/formatter/NoopFormatter.d.ts +1 -1
  118. package/lib/project/formatter/NoopFormatter.js +5 -9
  119. package/lib/project/formatter/NoopFormatter.js.map +1 -1
  120. package/lib/project/formatter/PrettierFormatter.d.ts +1 -1
  121. package/lib/project/formatter/PrettierFormatter.js +20 -25
  122. package/lib/project/formatter/PrettierFormatter.js.map +1 -1
  123. package/lib/project/formatter/index.d.ts +1 -1
  124. package/lib/project/formatter/index.js +6 -10
  125. package/lib/project/formatter/index.js.map +1 -1
  126. package/lib/project/logger/logFilePath.js +4 -9
  127. package/lib/project/logger/logFilePath.js.map +1 -1
  128. package/lib/run-cli.js +2 -4
  129. package/lib/run-cli.js.map +1 -1
  130. package/package.json +55 -64
  131. package/lib/cli.d.ts +0 -3
  132. package/lib/cli.js +0 -176
  133. package/lib/cli.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"NoopValidator.js","sourceRoot":"","sources":["../../../src/data-model/validation/NoopValidator.ts"],"names":[],"mappings":";;;AAGA,MAAa,aAAa;IACxB,qBAAqB,CAAC,WAAmB,EAAE,MAAc,EAAE,IAAY;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,MAAc,EAAE,IAAY;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,IAAY;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,MAAc,EAAE,IAAY;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,MAAc,EAAE,IAAY;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sBAAsB,CAAC,MAAc,EAAE,IAAY;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,IAAY;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uBAAuB,CAAC,MAAc,EAAE,IAAY;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;CACF;AApCD,sCAoCC","sourcesContent":["import { TypeModel } from \"../../TypeModel\";\r\nimport { NameValidator, ValidationError } from \"./NameValidator\";\r\n\r\nexport class NoopValidator implements NameValidator {\r\n addBoundOperationType(bindingName: string, fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addComplexType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addEntitySet(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addEntityType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addEnumType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addOperationImportType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addSingleton(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addUnboundOperationType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n validate(): Map<string, ValidationError[]> {\r\n return new Map();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"NoopValidator.js","sourceRoot":"","sources":["../../../src/data-model/validation/NoopValidator.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,aAAa;IACxB,cAAc,CAAC,MAAc,EAAE,IAAY;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,IAAY;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,MAAc,EAAE,IAAY;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,MAAc,EAAE,IAAY;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sBAAsB,CAAC,MAAc,EAAE,IAAY;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,IAAY;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qBAAqB,CAAC,WAAmB,EAAE,MAAc,EAAE,IAAY,EAAE,aAA6B;QACpG,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uBAAuB,CAAC,MAAc,EAAE,IAAY,EAAE,aAA6B;QACjF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { OperationTypes } from \"../DataTypeModel\";\r\nimport { NameValidator, ValidationError } from \"./NameValidator.js\";\r\n\r\nexport class NoopValidator implements NameValidator {\r\n addComplexType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addEntitySet(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addEntityType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addEnumType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addOperationImportType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addSingleton(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addBoundOperationType(bindingName: string, fqName: string, name: string, operationType: OperationTypes): string {\r\n return name;\r\n }\r\n\r\n addUnboundOperationType(fqName: string, name: string, operationType: OperationTypes): string {\r\n return name;\r\n }\r\n\r\n validate(): Map<string, ValidationError[]> {\r\n return new Map();\r\n }\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import { RunOptions } from "./OptionModel";
1
+ import { RunOptions } from "./OptionModel.js";
2
2
  export type DefaultConfiguration = Omit<RunOptions, "sourceUrl" | "source" | "output" | "serviceName">;
3
3
  /**
4
4
  * Creates a defensive copy of the default config.
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMinimalConfig = exports.getDefaultConfig = void 0;
4
- const tslib_1 = require("tslib");
5
- const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
6
- const NamingModel_1 = require("./NamingModel");
7
- const OptionModel_1 = require("./OptionModel");
1
+ import { __rest } from "tslib";
2
+ import deepmerge from "deepmerge";
3
+ import { NamingStrategies } from "./NamingModel.js";
4
+ import { EmitModes, Modes } from "./OptionModel.js";
8
5
  /**
9
6
  * The default configuration.
10
7
  */
11
8
  const defaultConfig = {
12
9
  sourceUrlConfig: {},
13
10
  refreshFile: false,
14
- mode: OptionModel_1.Modes.all,
15
- emitMode: OptionModel_1.EmitModes.js_dts,
11
+ mode: Modes.all,
12
+ emitMode: EmitModes.js_dts,
16
13
  debug: false,
17
14
  prettier: false,
18
15
  tsconfig: "tsconfig.json",
@@ -28,10 +25,11 @@ const defaultConfig = {
28
25
  v4BigNumberAsString: false,
29
26
  disableAutomaticNameClashResolution: false,
30
27
  bundledFileGeneration: true,
28
+ numericEnums: false,
31
29
  naming: {
32
30
  models: {
33
- namingStrategy: NamingModel_1.NamingStrategies.PASCAL_CASE,
34
- propNamingStrategy: NamingModel_1.NamingStrategies.CAMEL_CASE,
31
+ namingStrategy: NamingStrategies.PASCAL_CASE,
32
+ propNamingStrategy: NamingStrategies.CAMEL_CASE,
35
33
  editableModels: {
36
34
  prefix: "Editable",
37
35
  suffix: "",
@@ -48,14 +46,14 @@ const defaultConfig = {
48
46
  applyModelNaming: true,
49
47
  },
50
48
  fileName: {
51
- namingStrategy: NamingModel_1.NamingStrategies.PASCAL_CASE,
49
+ namingStrategy: NamingStrategies.PASCAL_CASE,
52
50
  prefix: "",
53
51
  suffix: "Model",
54
52
  },
55
53
  },
56
54
  queryObjects: {
57
- namingStrategy: NamingModel_1.NamingStrategies.PASCAL_CASE,
58
- propNamingStrategy: NamingModel_1.NamingStrategies.CAMEL_CASE,
55
+ namingStrategy: NamingStrategies.PASCAL_CASE,
56
+ propNamingStrategy: NamingStrategies.CAMEL_CASE,
59
57
  prefix: "Q",
60
58
  suffix: "",
61
59
  idFunctions: {
@@ -63,7 +61,7 @@ const defaultConfig = {
63
61
  suffix: "Id",
64
62
  },
65
63
  fileName: {
66
- namingStrategy: NamingModel_1.NamingStrategies.PASCAL_CASE,
64
+ namingStrategy: NamingStrategies.PASCAL_CASE,
67
65
  prefix: "Q",
68
66
  suffix: "",
69
67
  },
@@ -71,7 +69,7 @@ const defaultConfig = {
71
69
  services: {
72
70
  prefix: "",
73
71
  suffix: "Service",
74
- namingStrategy: NamingModel_1.NamingStrategies.PASCAL_CASE,
72
+ namingStrategy: NamingStrategies.PASCAL_CASE,
75
73
  main: {
76
74
  applyServiceNaming: true,
77
75
  },
@@ -81,15 +79,15 @@ const defaultConfig = {
81
79
  applyServiceNaming: true,
82
80
  },
83
81
  operations: {
84
- namingStrategy: NamingModel_1.NamingStrategies.CAMEL_CASE,
82
+ namingStrategy: NamingStrategies.CAMEL_CASE,
85
83
  },
86
84
  relatedServiceGetter: {
87
- namingStrategy: NamingModel_1.NamingStrategies.CAMEL_CASE,
85
+ namingStrategy: NamingStrategies.CAMEL_CASE,
88
86
  prefix: "",
89
87
  suffix: "",
90
88
  },
91
89
  privateProps: {
92
- namingStrategy: NamingModel_1.NamingStrategies.CAMEL_CASE,
90
+ namingStrategy: NamingStrategies.CAMEL_CASE,
93
91
  prefix: "_",
94
92
  suffix: "",
95
93
  },
@@ -157,16 +155,14 @@ const minimalNamingConfig = {
157
155
  /**
158
156
  * Creates a defensive copy of the default config.
159
157
  */
160
- function getDefaultConfig() {
161
- return (0, deepmerge_1.default)(defaultConfig, {});
158
+ export function getDefaultConfig() {
159
+ return deepmerge(defaultConfig, {});
162
160
  }
163
- exports.getDefaultConfig = getDefaultConfig;
164
161
  /**
165
162
  * Creates a defensive copy of the minimal config: minimal in respect to naming.
166
163
  */
167
- function getMinimalConfig() {
168
- const { naming } = defaultConfig, passThrough = tslib_1.__rest(defaultConfig, ["naming"]);
169
- return (0, deepmerge_1.default)(passThrough, { naming: minimalNamingConfig });
164
+ export function getMinimalConfig() {
165
+ const { naming } = defaultConfig, passThrough = __rest(defaultConfig, ["naming"]);
166
+ return deepmerge(passThrough, { naming: minimalNamingConfig });
170
167
  }
171
- exports.getMinimalConfig = getMinimalConfig;
172
168
  //# sourceMappingURL=defaultConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../src/defaultConfig.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAElC,+CAA+D;AAC/D,+CAA6D;AAG7D;;GAEG;AACH,MAAM,aAAa,GAAyB;IAC1C,eAAe,EAAE,EAAE;IACnB,WAAW,EAAE,KAAK;IAClB,IAAI,EAAE,mBAAK,CAAC,GAAG;IACf,QAAQ,EAAE,uBAAS,CAAC,MAAM;IAC1B,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,eAAe;IACzB,UAAU,EAAE,EAAE;IACd,kBAAkB,EAAE,KAAK;IACzB,YAAY,EAAE,KAAK;IACnB,cAAc,EAAE,KAAK;IACrB,YAAY,EAAE,KAAK;IACnB,+BAA+B,EAAE,KAAK;IACtC,qBAAqB,EAAE,KAAK;IAC5B,aAAa,EAAE,KAAK;IACpB,gCAAgC,EAAE,KAAK;IACvC,mBAAmB,EAAE,KAAK;IAC1B,mCAAmC,EAAE,KAAK;IAC1C,qBAAqB,EAAE,IAAI;IAC3B,MAAM,EAAE;QACN,MAAM,EAAE;YACN,cAAc,EAAE,8BAAgB,CAAC,WAAW;YAC5C,kBAAkB,EAAE,8BAAgB,CAAC,UAAU;YAC/C,cAAc,EAAE;gBACd,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,EAAE;gBACV,gBAAgB,EAAE,IAAI;aACvB;YACD,QAAQ,EAAE;gBACR,MAAM,EAAE,EAAE;gBACV,MAAM,EAAE,IAAI;gBACZ,gBAAgB,EAAE,IAAI;aACvB;YACD,oBAAoB,EAAE;gBACpB,MAAM,EAAE,EAAE;gBACV,MAAM,EAAE,QAAQ;gB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,QAAQ,CAAC,YAAY,CAAC,MAAM;YACpC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,MAAM;SACrC;QACD,oBAAoB,EAAE;YACpB,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM;YAC5C,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM;SAC7C;KACF;CACF,CAAC;AAEF;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,mBAAS,EAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAFD,4CAEC;AAED;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,MAAM,EAAE,MAAM,KAAqB,aAAa,EAA7B,WAAW,kBAAK,aAAa,EAA1C,UAA0B,CAAgB,CAAC;IACjD,OAAO,IAAA,mBAAS,EAAC,WAAW,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;AACjE,CAAC;AAHD,4CAGC","sourcesContent":["import deepmerge from \"deepmerge\";\r\n\r\nimport { NameSettings, NamingStrategies } from \"./NamingModel\";\r\nimport { EmitModes, Modes, RunOptions } from \"./OptionModel\";\r\n\r\nexport type DefaultConfiguration = Omit<RunOptions, \"sourceUrl\" | \"source\" | \"output\" | \"serviceName\">;\r\n/**\r\n * The default configuration.\r\n */\r\nconst defaultConfig: DefaultConfiguration = {\r\n sourceUrlConfig: {},\r\n refreshFile: false,\r\n mode: Modes.all,\r\n emitMode: EmitModes.js_dts,\r\n debug: false,\r\n prettier: false,\r\n tsconfig: \"tsconfig.json\",\r\n converters: [],\r\n skipEditableModels: false,\r\n skipIdModels: false,\r\n skipOperations: false,\r\n skipComments: false,\r\n enablePrimitivePropertyServices: false,\r\n disableAutoManagedKey: false,\r\n allowRenaming: false,\r\n v2ModelsWithExtraResultsWrapping: false,\r\n v4BigNumberAsString: false,\r\n disableAutomaticNameClashResolution: false,\r\n bundledFileGeneration: true,\r\n naming: {\r\n models: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n editableModels: {\r\n prefix: \"Editable\",\r\n suffix: \"\",\r\n applyModelNaming: true,\r\n },\r\n idModels: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n applyModelNaming: true,\r\n },\r\n operationParamModels: {\r\n prefix: \"\",\r\n suffix: \"Params\",\r\n applyModelNaming: true,\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"\",\r\n suffix: \"Model\",\r\n },\r\n },\r\n queryObjects: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n idFunctions: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n },\r\n },\r\n services: {\r\n prefix: \"\",\r\n suffix: \"Service\",\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n prefix: \"\",\r\n suffix: \"Collection\",\r\n applyServiceNaming: true,\r\n },\r\n operations: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n },\r\n relatedServiceGetter: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"\",\r\n suffix: \"\",\r\n },\r\n privateProps: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"_\",\r\n suffix: \"\",\r\n },\r\n },\r\n },\r\n propertiesByName: [],\r\n byTypeAndName: [],\r\n};\r\n\r\nconst { models, queryObjects, services } = defaultConfig.naming;\r\nconst minimalNamingConfig: NameSettings = {\r\n models: {\r\n fileName: {\r\n prefix: models.fileName.prefix,\r\n suffix: models.fileName.suffix,\r\n },\r\n idModels: {\r\n applyModelNaming: true,\r\n prefix: models.idModels.prefix,\r\n suffix: models.idModels.suffix,\r\n },\r\n editableModels: {\r\n applyModelNaming: true,\r\n prefix: models.editableModels.prefix,\r\n suffix: models.editableModels.suffix,\r\n },\r\n operationParamModels: {\r\n applyModelNaming: true,\r\n prefix: models.operationParamModels.prefix,\r\n suffix: models.operationParamModels.suffix,\r\n },\r\n },\r\n queryObjects: {\r\n prefix: queryObjects.prefix,\r\n suffix: queryObjects.suffix,\r\n fileName: {\r\n prefix: queryObjects.fileName.prefix,\r\n suffix: queryObjects.fileName.suffix,\r\n },\r\n idFunctions: {\r\n prefix: queryObjects.idFunctions.prefix,\r\n suffix: queryObjects.idFunctions.suffix,\r\n },\r\n },\r\n services: {\r\n prefix: services.prefix,\r\n suffix: services.suffix,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n applyServiceNaming: true,\r\n prefix: services.collection.prefix,\r\n suffix: services.collection.suffix,\r\n },\r\n privateProps: {\r\n prefix: services.privateProps.prefix,\r\n suffix: services.privateProps.suffix,\r\n },\r\n relatedServiceGetter: {\r\n prefix: services.relatedServiceGetter.prefix,\r\n suffix: services.relatedServiceGetter.suffix,\r\n },\r\n },\r\n};\r\n\r\n/**\r\n * Creates a defensive copy of the default config.\r\n */\r\nexport function getDefaultConfig(): DefaultConfiguration {\r\n return deepmerge(defaultConfig, {});\r\n}\r\n\r\n/**\r\n * Creates a defensive copy of the minimal config: minimal in respect to naming.\r\n */\r\nexport function getMinimalConfig(): DefaultConfiguration {\r\n const { naming, ...passThrough } = defaultConfig;\r\n return deepmerge(passThrough, { naming: minimalNamingConfig });\r\n}\r\n"]}
1
+ {"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../src/defaultConfig.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAgB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAc,MAAM,kBAAkB,CAAC;AAGhE;;GAEG;AACH,MAAM,aA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EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,EAAE,MAAM,KAAqB,aAAa,EAA7B,WAAW,UAAK,aAAa,EAA1C,UAA0B,CAAgB,CAAC;IACjD,OAAO,SAAS,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import deepmerge from \"deepmerge\";\r\nimport { NameSettings, NamingStrategies } from \"./NamingModel.js\";\r\nimport { EmitModes, Modes, RunOptions } from \"./OptionModel.js\";\r\n\r\nexport type DefaultConfiguration = Omit<RunOptions, \"sourceUrl\" | \"source\" | \"output\" | \"serviceName\">;\r\n/**\r\n * The default configuration.\r\n */\r\nconst defaultConfig: DefaultConfiguration = {\r\n sourceUrlConfig: {},\r\n refreshFile: false,\r\n mode: Modes.all,\r\n emitMode: EmitModes.js_dts,\r\n debug: false,\r\n prettier: false,\r\n tsconfig: \"tsconfig.json\",\r\n converters: [],\r\n skipEditableModels: false,\r\n skipIdModels: false,\r\n skipOperations: false,\r\n skipComments: false,\r\n enablePrimitivePropertyServices: false,\r\n disableAutoManagedKey: false,\r\n allowRenaming: false,\r\n v2ModelsWithExtraResultsWrapping: false,\r\n v4BigNumberAsString: false,\r\n disableAutomaticNameClashResolution: false,\r\n bundledFileGeneration: true,\r\n numericEnums: false,\r\n naming: {\r\n models: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n editableModels: {\r\n prefix: \"Editable\",\r\n suffix: \"\",\r\n applyModelNaming: true,\r\n },\r\n idModels: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n applyModelNaming: true,\r\n },\r\n operationParamModels: {\r\n prefix: \"\",\r\n suffix: \"Params\",\r\n applyModelNaming: true,\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"\",\r\n suffix: \"Model\",\r\n },\r\n },\r\n queryObjects: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n idFunctions: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n },\r\n },\r\n services: {\r\n prefix: \"\",\r\n suffix: \"Service\",\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n prefix: \"\",\r\n suffix: \"Collection\",\r\n applyServiceNaming: true,\r\n },\r\n operations: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n },\r\n relatedServiceGetter: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"\",\r\n suffix: \"\",\r\n },\r\n privateProps: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"_\",\r\n suffix: \"\",\r\n },\r\n },\r\n },\r\n propertiesByName: [],\r\n byTypeAndName: [],\r\n};\r\n\r\nconst { models, queryObjects, services } = defaultConfig.naming;\r\nconst minimalNamingConfig: NameSettings = {\r\n models: {\r\n fileName: {\r\n prefix: models.fileName.prefix,\r\n suffix: models.fileName.suffix,\r\n },\r\n idModels: {\r\n applyModelNaming: true,\r\n prefix: models.idModels.prefix,\r\n suffix: models.idModels.suffix,\r\n },\r\n editableModels: {\r\n applyModelNaming: true,\r\n prefix: models.editableModels.prefix,\r\n suffix: models.editableModels.suffix,\r\n },\r\n operationParamModels: {\r\n applyModelNaming: true,\r\n prefix: models.operationParamModels.prefix,\r\n suffix: models.operationParamModels.suffix,\r\n },\r\n },\r\n queryObjects: {\r\n prefix: queryObjects.prefix,\r\n suffix: queryObjects.suffix,\r\n fileName: {\r\n prefix: queryObjects.fileName.prefix,\r\n suffix: queryObjects.fileName.suffix,\r\n },\r\n idFunctions: {\r\n prefix: queryObjects.idFunctions.prefix,\r\n suffix: queryObjects.idFunctions.suffix,\r\n },\r\n },\r\n services: {\r\n prefix: services.prefix,\r\n suffix: services.suffix,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n applyServiceNaming: true,\r\n prefix: services.collection.prefix,\r\n suffix: services.collection.suffix,\r\n },\r\n privateProps: {\r\n prefix: services.privateProps.prefix,\r\n suffix: services.privateProps.suffix,\r\n },\r\n relatedServiceGetter: {\r\n prefix: services.relatedServiceGetter.prefix,\r\n suffix: services.relatedServiceGetter.suffix,\r\n },\r\n },\r\n};\r\n\r\n/**\r\n * Creates a defensive copy of the default config.\r\n */\r\nexport function getDefaultConfig(): DefaultConfiguration {\r\n return deepmerge(defaultConfig, {});\r\n}\r\n\r\n/**\r\n * Creates a defensive copy of the minimal config: minimal in respect to naming.\r\n */\r\nexport function getMinimalConfig(): DefaultConfiguration {\r\n const { naming, ...passThrough } = defaultConfig;\r\n return deepmerge(passThrough, { naming: minimalNamingConfig });\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import { UrlSourceConfiguration } from "../OptionModel";
1
+ import { UrlSourceConfiguration } from "../OptionModel.js";
2
2
  /**
3
3
  * Retrieves the metadata from the given URL using the given configuration.
4
4
  *
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.downloadMetadata = void 0;
4
- const tslib_1 = require("tslib");
5
- const axios_1 = tslib_1.__importDefault(require("axios"));
1
+ import { __awaiter, __rest } from "tslib";
2
+ import axios from "axios";
6
3
  const METADATA_PATH = "$metadata";
7
4
  const PWD_BLIND_TEXT = { password: "xxx hidden xxx" };
8
5
  function evaluateRequestConfig(url, config) {
@@ -24,8 +21,8 @@ function evaluateRequestConfig(url, config) {
24
21
  * @param sourceConfig
25
22
  * @param debug
26
23
  */
27
- function downloadMetadata(sourceUrl, sourceConfig = {}, debug = false) {
28
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
24
+ export function downloadMetadata(sourceUrl, sourceConfig = {}, debug = false) {
25
+ return __awaiter(this, void 0, void 0, function* () {
29
26
  // add the $metadata suffix
30
27
  const url = sourceUrl.endsWith(METADATA_PATH)
31
28
  ? sourceUrl
@@ -35,14 +32,13 @@ function downloadMetadata(sourceUrl, sourceConfig = {}, debug = false) {
35
32
  const config = evaluateRequestConfig(url, sourceConfig);
36
33
  // log request configuration without password
37
34
  if (debug) {
38
- const { auth } = config, loggable = tslib_1.__rest(config, ["auth"]);
35
+ const { auth } = config, loggable = __rest(config, ["auth"]);
39
36
  const safeConfig = auth ? Object.assign(Object.assign({}, loggable), { auth: Object.assign(Object.assign({}, auth), (auth.password ? PWD_BLIND_TEXT : {})) }) : loggable;
40
37
  console.log(`Request configuration:`, safeConfig);
41
38
  }
42
39
  // execute the request & return response data
43
- const response = yield axios_1.default.request(config);
40
+ const response = yield axios.request(config);
44
41
  return response.data;
45
42
  });
46
43
  }
47
- exports.downloadMetadata = downloadMetadata;
48
44
  //# sourceMappingURL=downloadMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"downloadMetadata.js","sourceRoot":"","sources":["../../src/download/downloadMetadata.ts"],"names":[],"mappings":";;;;AAAA,0DAAkD;AAIlD,MAAM,aAAa,GAAG,WAAW,CAAC;AAClC,MAAM,cAAc,GAAG,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;AAEtD,SAAS,qBAAqB,CAAC,GAAW,EAAE,MAA8B;IACxE,MAAM,gBAAgB,GAAuB,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACzE,MAAM,SAAS,GAAuB,MAAM,CAAC,MAAM;QACjD,CAAC,CAAC,MAAM,CAAC,MAAM;QACf,CAAC,CAAC,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,CAAA,KAAK,QAAQ;YAC7E,CAAC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,4CAwBC","sourcesContent":["import axios, { AxiosRequestConfig } from \"axios\";\r\n\r\nimport { UrlSourceConfiguration } from \"../OptionModel\";\r\n\r\nconst METADATA_PATH = \"$metadata\";\r\nconst PWD_BLIND_TEXT = { password: \"xxx hidden xxx\" };\r\n\r\nfunction evaluateRequestConfig(url: string, config: UrlSourceConfiguration): AxiosRequestConfig {\r\n const defaultReqConfig: AxiosRequestConfig = { url: url, method: \"GET\" };\r\n const reqConfig: AxiosRequestConfig = config.custom\r\n ? config.custom\r\n : typeof config.username === \"string\" && typeof config?.password === \"string\"\r\n ? { auth: { username: config.username, password: config.password } }\r\n : {};\r\n return { ...defaultReqConfig, ...reqConfig };\r\n}\r\n\r\n/**\r\n * Retrieves the metadata from the given URL using the given configuration.\r\n *\r\n * Failure handling must be implemented by consumer.\r\n * Exception is thrown for failed requests (400, 401, ...).\r\n *\r\n * @param sourceUrl\r\n * @param sourceConfig\r\n * @param debug\r\n */\r\nexport async function downloadMetadata(\r\n sourceUrl: string,\r\n sourceConfig: UrlSourceConfiguration = {},\r\n debug: boolean = false\r\n): Promise<string> {\r\n // add the $metadata suffix\r\n const url = sourceUrl.endsWith(METADATA_PATH)\r\n ? sourceUrl\r\n : sourceUrl + (sourceUrl.endsWith(\"/\") ? \"\" : \"/\") + METADATA_PATH;\r\n console.log(`Reading metadata from URL:`, url);\r\n\r\n // evaluate configured request config options\r\n const config = evaluateRequestConfig(url, sourceConfig);\r\n\r\n // log request configuration without password\r\n if (debug) {\r\n const { auth, ...loggable } = config;\r\n const safeConfig = auth ? { ...loggable, auth: { ...auth, ...(auth.password ? PWD_BLIND_TEXT : {}) } } : loggable;\r\n console.log(`Request configuration:`, safeConfig);\r\n }\r\n\r\n // execute the request & return response data\r\n const response = await axios.request(config);\r\n return response.data;\r\n}\r\n"]}
1
+ {"version":3,"file":"downloadMetadata.js","sourceRoot":"","sources":["../../src/download/downloadMetadata.ts"],"names":[],"mappings":";AAAA,OAAO,KAA6B,MAAM,OAAO,CAA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,EAAnB,QAAQ,UAAK,MAAM,EAA9B,QAAqB,CAAS,CAAC;YACrC,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,iCAAM,QAAQ,KAAE,IAAI,kCAAO,IAAI,GAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC;YAClH,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;SACnD;QAED,6CAA6C;QAC7C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7C,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CAAA","sourcesContent":["import axios, { AxiosRequestConfig } from \"axios\";\r\n\r\nimport { UrlSourceConfiguration } from \"../OptionModel.js\";\r\n\r\nconst METADATA_PATH = \"$metadata\";\r\nconst PWD_BLIND_TEXT = { password: \"xxx hidden xxx\" };\r\n\r\nfunction evaluateRequestConfig(url: string, config: UrlSourceConfiguration): AxiosRequestConfig {\r\n const defaultReqConfig: AxiosRequestConfig = { url: url, method: \"GET\" };\r\n const reqConfig: AxiosRequestConfig = config.custom\r\n ? config.custom\r\n : typeof config.username === \"string\" && typeof config?.password === \"string\"\r\n ? { auth: { username: config.username, password: config.password } }\r\n : {};\r\n return { ...defaultReqConfig, ...reqConfig };\r\n}\r\n\r\n/**\r\n * Retrieves the metadata from the given URL using the given configuration.\r\n *\r\n * Failure handling must be implemented by consumer.\r\n * Exception is thrown for failed requests (400, 401, ...).\r\n *\r\n * @param sourceUrl\r\n * @param sourceConfig\r\n * @param debug\r\n */\r\nexport async function downloadMetadata(\r\n sourceUrl: string,\r\n sourceConfig: UrlSourceConfiguration = {},\r\n debug: boolean = false\r\n): Promise<string> {\r\n // add the $metadata suffix\r\n const url = sourceUrl.endsWith(METADATA_PATH)\r\n ? sourceUrl\r\n : sourceUrl + (sourceUrl.endsWith(\"/\") ? \"\" : \"/\") + METADATA_PATH;\r\n console.log(`Reading metadata from URL:`, url);\r\n\r\n // evaluate configured request config options\r\n const config = evaluateRequestConfig(url, sourceConfig);\r\n\r\n // log request configuration without password\r\n if (debug) {\r\n const { auth, ...loggable } = config;\r\n const safeConfig = auth ? { ...loggable, auth: { ...auth, ...(auth.password ? PWD_BLIND_TEXT : {}) } } : loggable;\r\n console.log(`Request configuration:`, safeConfig);\r\n }\r\n\r\n // execute the request & return response data\r\n const response = await axios.request(config);\r\n return response.data;\r\n}\r\n"]}
@@ -1,2 +1,2 @@
1
- export { downloadMetadata } from "./downloadMetadata";
2
- export { storeMetadata } from "./storeMetadata";
1
+ export { downloadMetadata } from "./downloadMetadata.js";
2
+ export { storeMetadata } from "./storeMetadata.js";
@@ -1,8 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.storeMetadata = exports.downloadMetadata = void 0;
4
- var downloadMetadata_1 = require("./downloadMetadata");
5
- Object.defineProperty(exports, "downloadMetadata", { enumerable: true, get: function () { return downloadMetadata_1.downloadMetadata; } });
6
- var storeMetadata_1 = require("./storeMetadata");
7
- Object.defineProperty(exports, "storeMetadata", { enumerable: true, get: function () { return storeMetadata_1.storeMetadata; } });
1
+ export { downloadMetadata } from "./downloadMetadata.js";
2
+ export { storeMetadata } from "./storeMetadata.js";
8
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/download/index.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA","sourcesContent":["export { downloadMetadata } from \"./downloadMetadata\";\r\nexport { storeMetadata } from \"./storeMetadata\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/download/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { downloadMetadata } from \"./downloadMetadata.js\";\r\nexport { storeMetadata } from \"./storeMetadata.js\";\r\n"]}
@@ -1,10 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.storeMetadata = void 0;
4
- const tslib_1 = require("tslib");
5
- const path_1 = tslib_1.__importDefault(require("path"));
6
- const fs_extra_1 = require("fs-extra");
7
- const prettier_1 = tslib_1.__importDefault(require("prettier"));
1
+ import { __awaiter } from "tslib";
2
+ import { writeFile } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { mkdirp } from "mkdirp";
5
+ import { format, resolveConfig } from "prettier";
8
6
  /**
9
7
  * Write (prettified) data to disk.
10
8
  *
@@ -12,17 +10,17 @@ const prettier_1 = tslib_1.__importDefault(require("prettier"));
12
10
  * @param metadataXml
13
11
  * @param prettify
14
12
  */
15
- function storeMetadata(filePath, metadataXml, prettify) {
16
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
- const outDir = path_1.default.dirname(filePath);
18
- const prettierConfig = yield prettier_1.default.resolveConfig(outDir);
19
- const prettified = prettify
20
- ? prettier_1.default.format(metadataXml, Object.assign(Object.assign({ xmlWhitespaceSensitivity: "ignore" }, prettierConfig), { parser: "xml", plugins: ["@prettier/plugin-xml"] }))
21
- : metadataXml;
22
- yield (0, fs_extra_1.ensureDir)(outDir);
23
- yield (0, fs_extra_1.writeFile)(filePath, prettified);
13
+ export function storeMetadata(filePath, metadataXml, prettify) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ const outDir = path.dirname(filePath);
16
+ let prettified = metadataXml;
17
+ if (prettify) {
18
+ const prettierConfig = yield resolveConfig(outDir);
19
+ prettified = yield format(metadataXml, Object.assign(Object.assign({}, prettierConfig), { parser: "xml", plugins: ["@prettier/plugin-xml"] }));
20
+ }
21
+ yield mkdirp(outDir);
22
+ yield writeFile(filePath, prettified);
24
23
  return prettified;
25
24
  });
26
25
  }
27
- exports.storeMetadata = storeMetadata;
28
26
  //# sourceMappingURL=storeMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"storeMetadata.js","sourceRoot":"","sources":["../../src/download/storeMetadata.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AAExB,uCAAgD;AAChD,gEAAgC;AAEhC;;;;;;GAMG;AACH,SAAsB,aAAa,CAAC,QAAgB,EAAE,WAAmB,EAAE,QAAiB;;QAC1F,MAAM,MAAM,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEtC,MAAM,cAAc,GAAG,MAAM,kBAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAG,QAAQ;YACzB,CAAC,CAAC,kBAAQ,CAAC,MAAM,CACb,WAAW,gCAET,wBAAwB,EAAE,QAAQ,IAAK,cAAc,KAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,sBAAsB,CAAC,IAC1G;YACH,CAAC,CAAC,WAAW,CAAC;QAEhB,MAAM,IAAA,oBAAS,EAAC,MAAM,CAAC,CAAC;QACxB,MAAM,IAAA,oBAAS,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAEtC,OAAO,UAAU,CAAC;IACpB,CAAC;CAAA;AAhBD,sCAgBC","sourcesContent":["import path from \"path\";\r\n\r\nimport { ensureDir, writeFile } from \"fs-extra\";\r\nimport prettier from \"prettier\";\r\n\r\n/**\r\n * Write (prettified) data to disk.\r\n *\r\n * @param filePath\r\n * @param metadataXml\r\n * @param prettify\r\n */\r\nexport async function storeMetadata(filePath: string, metadataXml: string, prettify: boolean) {\r\n const outDir = path.dirname(filePath);\r\n\r\n const prettierConfig = await prettier.resolveConfig(outDir);\r\n const prettified = prettify\r\n ? prettier.format(\r\n metadataXml,\r\n // @ts-ignore: xmlWhitespaceSensitivity is an option of the plugin\r\n { xmlWhitespaceSensitivity: \"ignore\", ...prettierConfig, parser: \"xml\", plugins: [\"@prettier/plugin-xml\"] }\r\n )\r\n : metadataXml;\r\n\r\n await ensureDir(outDir);\r\n await writeFile(filePath, prettified);\r\n\r\n return prettified;\r\n}\r\n"]}
1
+ {"version":3,"file":"storeMetadata.js","sourceRoot":"","sources":["../../src/download/storeMetadata.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,UAAgB,aAAa,CAAC,QAAgB,EAAE,WAAmB,EAAE,QAAiB;;QAC1F,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEtC,IAAI,UAAU,GAAG,WAAW,CAAC;QAC7B,IAAI,QAAQ,EAAE;YACZ,MAAM,cAAc,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;YACnD,UAAU,GAAG,MAAM,MAAM,CACvB,WAAW,kCAEN,cAAc,KAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,sBAAsB,CAAC,IACtE,CAAC;SACH;QAED,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;QACrB,MAAM,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAEtC,OAAO,UAAU,CAAC;IACpB,CAAC;CAAA","sourcesContent":["import { writeFile } from \"node:fs/promises\";\r\nimport path from \"node:path\";\r\nimport { mkdirp } from \"mkdirp\";\r\nimport { format, resolveConfig } from \"prettier\";\r\n\r\n/**\r\n * Write (prettified) data to disk.\r\n *\r\n * @param filePath\r\n * @param metadataXml\r\n * @param prettify\r\n */\r\nexport async function storeMetadata(filePath: string, metadataXml: string, prettify: boolean) {\r\n const outDir = path.dirname(filePath);\r\n\r\n let prettified = metadataXml;\r\n if (prettify) {\r\n const prettierConfig = await resolveConfig(outDir);\r\n prettified = await format(\r\n metadataXml,\r\n // @ts-ignore: xmlWhitespaceSensitivity is an option of the plugin\r\n { ...prettierConfig, parser: \"xml\", plugins: [\"@prettier/plugin-xml\"] },\r\n );\r\n }\r\n\r\n await mkdirp(outDir);\r\n await writeFile(filePath, prettified);\r\n\r\n return prettified;\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import { CliOptions, ConfigFileOptions, RunOptions } from "./OptionModel";
1
+ import { CliOptions, ConfigFileOptions, RunOptions } from "./OptionModel.js";
2
2
  /**
3
3
  * Provides default values and evaluates the various config file and CLI options.
4
4
  * This function always returns a list of RunOptions,
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.evaluateConfigOptions = void 0;
4
- const tslib_1 = require("tslib");
5
- const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
6
- const defaultConfig_1 = require("./defaultConfig");
7
- const OptionModel_1 = require("./OptionModel");
1
+ import { __rest } from "tslib";
2
+ import deepmerge from "deepmerge";
3
+ import { getDefaultConfig, getMinimalConfig } from "./defaultConfig.js";
4
+ import { Modes } from "./OptionModel.js";
8
5
  /**
9
6
  * Provides default values and evaluates the various config file and CLI options.
10
7
  * This function always returns a list of RunOptions,
@@ -28,25 +25,25 @@ const OptionModel_1 = require("./OptionModel");
28
25
  * @param cliOpts CLI passed options
29
26
  * @param configOpts config file options
30
27
  */
31
- function evaluateConfigOptions(cliOpts, configOpts) {
28
+ export function evaluateConfigOptions(cliOpts, configOpts) {
32
29
  var _a;
33
- const defaultConfig = ((_a = configOpts === null || configOpts === void 0 ? void 0 : configOpts.naming) === null || _a === void 0 ? void 0 : _a.minimalDefaults) ? (0, defaultConfig_1.getMinimalConfig)() : (0, defaultConfig_1.getDefaultConfig)();
30
+ const defaultConfig = ((_a = configOpts === null || configOpts === void 0 ? void 0 : configOpts.naming) === null || _a === void 0 ? void 0 : _a.minimalDefaults) ? getMinimalConfig() : getDefaultConfig();
34
31
  // No config file
35
32
  if (!configOpts) {
36
33
  if (!cliOpts.source || !cliOpts.output) {
37
34
  throw new Error("Without any configuration file options --source and --output must be specified!");
38
35
  }
39
- return [(0, deepmerge_1.default)(defaultConfig, cliOpts)];
36
+ return [deepmerge(defaultConfig, cliOpts)];
40
37
  }
41
- const { services: cliServices, source, output } = cliOpts, cliBaseOpts = tslib_1.__rest(cliOpts, ["services", "source", "output"]);
42
- const { services: confServices } = configOpts, confBaseOpts = tslib_1.__rest(configOpts, ["services"]);
38
+ const { services: cliServices, source, output } = cliOpts, cliBaseOpts = __rest(cliOpts, ["services", "source", "output"]);
39
+ const { services: confServices } = configOpts, confBaseOpts = __rest(configOpts, ["services"]);
43
40
  // No configurations of services in config file
44
41
  // or CLI opts specify source and output => ignore service config
45
42
  if ((source && output) || !confServices) {
46
43
  if (!source || !output) {
47
44
  throw new Error("No services were configured in config file, so options --source and --output must be specified!");
48
45
  }
49
- const merged = deepmerge_1.default.all([defaultConfig, confBaseOpts, cliOpts]);
46
+ const merged = deepmerge.all([defaultConfig, confBaseOpts, cliOpts]);
50
47
  return [safeGuardOptions(merged)];
51
48
  }
52
49
  // Either services are specified or we use all configured services
@@ -57,25 +54,24 @@ function evaluateConfigOptions(cliOpts, configOpts) {
57
54
  if (!service) {
58
55
  throw new Error(`Specified service "${s}" doesn't exist in configuration!`);
59
56
  }
60
- const serviceDefault = ((_a = service.naming) === null || _a === void 0 ? void 0 : _a.minimalDefaults) && !((_b = configOpts.naming) === null || _b === void 0 ? void 0 : _b.minimalDefaults) ? (0, defaultConfig_1.getMinimalConfig)() : defaultConfig;
61
- const merged = deepmerge_1.default.all([serviceDefault, confBaseOpts, service, cliBaseOpts]);
57
+ const serviceDefault = ((_a = service.naming) === null || _a === void 0 ? void 0 : _a.minimalDefaults) && !((_b = configOpts.naming) === null || _b === void 0 ? void 0 : _b.minimalDefaults) ? getMinimalConfig() : defaultConfig;
58
+ const merged = deepmerge.all([serviceDefault, confBaseOpts, service, cliBaseOpts]);
62
59
  return safeGuardOptions(merged);
63
60
  });
64
61
  }
65
- exports.evaluateConfigOptions = evaluateConfigOptions;
66
62
  /**
67
63
  * Make sure that some options are only active if in correct mode.
68
64
  * @param options
69
65
  */
70
66
  function safeGuardOptions(options) {
71
67
  // skip options are not valid for service generation
72
- if (options.mode === OptionModel_1.Modes.service || options.mode === OptionModel_1.Modes.all) {
68
+ if (options.mode === Modes.service || options.mode === Modes.all) {
73
69
  options.skipEditableModels = false;
74
70
  options.skipIdModels = false;
75
71
  options.skipOperations = false;
76
72
  }
77
73
  // special option which is only valid for model generation
78
- if (options.mode !== OptionModel_1.Modes.models) {
74
+ if (options.mode !== Modes.models) {
79
75
  options.v2ModelsWithExtraResultsWrapping = false;
80
76
  }
81
77
  return options;
@@ -1 +1 @@
1
- {"version":3,"file":"evaluateConfig.js","sourceRoot":"","sources":["../src/evaluateConfig.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAElC,mDAAqE;AACrE,+CAAiF;AAEjF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,qBAAqB,CACnC,OAAmB,EACnB,UAAyC;;IAEzC,MAAM,aAAa,GAAG,CAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,0CAAE,eAAe,EAAC,CAAC,CAAC,IAAA,gCAAgB,GAAE,CAAC,CAAC,CAAC,IAAA,gCAAgB,GAAE,CAAC;IACpG,iBAAiB;IACjB,IAAI,CAAC,UAAU,EAAE;QACf,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;SACpG;QACD,OAAO,CAAC,IAAA,mBAAS,EAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;KAC5C;IAED,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,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,CAAC;QACjG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC;AAxCD,sDAwCC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CAAC,OAAmB;IAC3C,oDAAoD;IACpD,IAAI,OAAO,CAAC,IAAI,KAAK,mBAAK,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,mBAAK,CAAC,GAAG,EAAE;QAChE,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC;QACnC,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC;QAC7B,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC;KAChC;IACD,0DAA0D;IAC1D,IAAI,OAAO,CAAC,IAAI,KAAK,mBAAK,CAAC,MAAM,EAAE;QACjC,OAAO,CAAC,gCAAgC,GAAG,KAAK,CAAC;KAClD;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import deepmerge from \"deepmerge\";\r\n\r\nimport { getDefaultConfig, getMinimalConfig } from \"./defaultConfig\";\r\nimport { CliOptions, ConfigFileOptions, Modes, RunOptions } from \"./OptionModel\";\r\n\r\n/**\r\n * Provides default values and evaluates the various config file and CLI options.\r\n * This function always returns a list of RunOptions,\r\n * whereby each item represents one generation run / one service.\r\n *\r\n * Configurations are merged in the following order (last one wins):\r\n * - default values\r\n * - config file: base settings\r\n * - config file: service specific settings\r\n * - CLI options\r\n *\r\n * If the CLI options specify source and output, then the service config is completely ignored and only the\r\n * base settings are applied from the config file.\r\n *\r\n * If the CLI options do not specify source and output, but do specify services, then these services must\r\n * exist in the config file and each service must supply values for source and output as a minimum.\r\n *\r\n * If the CLI options neither entail source nor services, then at least one service must be configured in the\r\n * config file. All configured services are returned.\r\n *\r\n * @param cliOpts CLI passed options\r\n * @param configOpts config file options\r\n */\r\nexport function evaluateConfigOptions(\r\n cliOpts: CliOptions,\r\n configOpts: ConfigFileOptions | undefined\r\n): Array<RunOptions> {\r\n const defaultConfig = configOpts?.naming?.minimalDefaults ? getMinimalConfig() : getDefaultConfig();\r\n // No config file\r\n if (!configOpts) {\r\n if (!cliOpts.source || !cliOpts.output) {\r\n throw new Error(\"Without any configuration file options --source and --output must be specified!\");\r\n }\r\n return [deepmerge(defaultConfig, cliOpts)];\r\n }\r\n\r\n const { services: cliServices, source, output, ...cliBaseOpts } = cliOpts;\r\n const { services: confServices, ...confBaseOpts } = configOpts;\r\n\r\n // No configurations of services in config file\r\n // or CLI opts specify source and output => ignore service config\r\n if ((source && output) || !confServices) {\r\n if (!source || !output) {\r\n throw new Error(\r\n \"No services were configured in config file, so options --source and --output must be specified!\"\r\n );\r\n }\r\n const merged = deepmerge.all([defaultConfig, confBaseOpts, cliOpts]) as RunOptions;\r\n return [safeGuardOptions(merged)];\r\n }\r\n\r\n // Either services are specified or we use all configured services\r\n const servicesToUse = cliServices?.length ? cliServices : Object.keys(confServices);\r\n return servicesToUse.map((s) => {\r\n const service = confServices[s];\r\n if (!service) {\r\n throw new Error(`Specified service \"${s}\" doesn't exist in configuration!`);\r\n }\r\n const serviceDefault =\r\n service.naming?.minimalDefaults && !configOpts.naming?.minimalDefaults ? getMinimalConfig() : defaultConfig;\r\n const merged = deepmerge.all([serviceDefault, confBaseOpts, service, cliBaseOpts]) as RunOptions;\r\n return safeGuardOptions(merged);\r\n });\r\n}\r\n\r\n/**\r\n * Make sure that some options are only active if in correct mode.\r\n * @param options\r\n */\r\nfunction safeGuardOptions(options: RunOptions): RunOptions {\r\n // skip options are not valid for service generation\r\n if (options.mode === Modes.service || options.mode === Modes.all) {\r\n options.skipEditableModels = false;\r\n options.skipIdModels = false;\r\n options.skipOperations = false;\r\n }\r\n // special option which is only valid for model generation\r\n if (options.mode !== Modes.models) {\r\n options.v2ModelsWithExtraResultsWrapping = false;\r\n }\r\n\r\n return options;\r\n}\r\n"]}
1
+ {"version":3,"file":"evaluateConfig.js","sourceRoot":"","sources":["../src/evaluateConfig.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,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B,CAAC","sourcesContent":["import deepmerge from \"deepmerge\";\r\n\r\nimport { getDefaultConfig, getMinimalConfig } from \"./defaultConfig.js\";\r\nimport { CliOptions, ConfigFileOptions, Modes, RunOptions } from \"./OptionModel.js\";\r\n\r\n/**\r\n * Provides default values and evaluates the various config file and CLI options.\r\n * This function always returns a list of RunOptions,\r\n * whereby each item represents one generation run / one service.\r\n *\r\n * Configurations are merged in the following order (last one wins):\r\n * - default values\r\n * - config file: base settings\r\n * - config file: service specific settings\r\n * - CLI options\r\n *\r\n * If the CLI options specify source and output, then the service config is completely ignored and only the\r\n * base settings are applied from the config file.\r\n *\r\n * If the CLI options do not specify source and output, but do specify services, then these services must\r\n * exist in the config file and each service must supply values for source and output as a minimum.\r\n *\r\n * If the CLI options neither entail source nor services, then at least one service must be configured in the\r\n * config file. All configured services are returned.\r\n *\r\n * @param cliOpts CLI passed options\r\n * @param configOpts config file options\r\n */\r\nexport function evaluateConfigOptions(\r\n cliOpts: CliOptions,\r\n configOpts: ConfigFileOptions | undefined\r\n): Array<RunOptions> {\r\n const defaultConfig = configOpts?.naming?.minimalDefaults ? getMinimalConfig() : getDefaultConfig();\r\n // No config file\r\n if (!configOpts) {\r\n if (!cliOpts.source || !cliOpts.output) {\r\n throw new Error(\"Without any configuration file options --source and --output must be specified!\");\r\n }\r\n return [deepmerge(defaultConfig, cliOpts)];\r\n }\r\n\r\n const { services: cliServices, source, output, ...cliBaseOpts } = cliOpts;\r\n const { services: confServices, ...confBaseOpts } = configOpts;\r\n\r\n // No configurations of services in config file\r\n // or CLI opts specify source and output => ignore service config\r\n if ((source && output) || !confServices) {\r\n if (!source || !output) {\r\n throw new Error(\r\n \"No services were configured in config file, so options --source and --output must be specified!\"\r\n );\r\n }\r\n const merged = deepmerge.all([defaultConfig, confBaseOpts, cliOpts]) as RunOptions;\r\n return [safeGuardOptions(merged)];\r\n }\r\n\r\n // Either services are specified or we use all configured services\r\n const servicesToUse = cliServices?.length ? cliServices : Object.keys(confServices);\r\n return servicesToUse.map((s) => {\r\n const service = confServices[s];\r\n if (!service) {\r\n throw new Error(`Specified service \"${s}\" doesn't exist in configuration!`);\r\n }\r\n const serviceDefault =\r\n service.naming?.minimalDefaults && !configOpts.naming?.minimalDefaults ? getMinimalConfig() : defaultConfig;\r\n const merged = deepmerge.all([serviceDefault, confBaseOpts, service, cliBaseOpts]) as RunOptions;\r\n return safeGuardOptions(merged);\r\n });\r\n}\r\n\r\n/**\r\n * Make sure that some options are only active if in correct mode.\r\n * @param options\r\n */\r\nfunction safeGuardOptions(options: RunOptions): RunOptions {\r\n // skip options are not valid for service generation\r\n if (options.mode === Modes.service || options.mode === Modes.all) {\r\n options.skipEditableModels = false;\r\n options.skipIdModels = false;\r\n options.skipOperations = false;\r\n }\r\n // special option which is only valid for model generation\r\n if (options.mode !== Modes.models) {\r\n options.v2ModelsWithExtraResultsWrapping = false;\r\n }\r\n\r\n return options;\r\n}\r\n"]}
@@ -1,7 +1,7 @@
1
1
  import { ODataVersions } from "@odata2ts/odata-core";
2
2
  import { ImportDeclarationStructure, OptionalKind } from "ts-morph";
3
- import { DataModel } from "../data-model/DataModel";
4
- import { ClientApiImports, CoreImports, QueryObjectImports, ServiceImports } from "./import/ImportObjects";
3
+ import { DataModel } from "../data-model/DataModel.js";
4
+ import { ClientApiImports, CoreImports, QueryObjectImports, ServiceImports } from "./import/ImportObjects.js";
5
5
  /**
6
6
  * Handles all the import statements for a given file.
7
7
  *
@@ -40,7 +40,7 @@ export declare class ImportContainer {
40
40
  private pathAndFile;
41
41
  private isDifferentFile;
42
42
  private addGeneratedImport;
43
- addGeneratedModel(fqName: string, name: string): string;
43
+ addGeneratedModel(fqName: string, name: string, isTypeOnly?: boolean): string;
44
44
  addGeneratedQObject(fqName: string, name: string, isTypeOnly?: boolean): string;
45
45
  addGeneratedService(fqName: string, name: string): string;
46
46
  private createImportDecl;
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ImportContainer = void 0;
4
- const tslib_1 = require("tslib");
5
- const path_1 = tslib_1.__importDefault(require("path"));
6
- const odata_core_1 = require("@odata2ts/odata-core");
7
- const ImportObjects_1 = require("./import/ImportObjects");
8
- const ImportedNameValidator_1 = require("./ImportedNameValidator");
1
+ import path from "path";
2
+ import { ODataVersions } from "@odata2ts/odata-core";
3
+ import { ClientApiImports, CoreImports, LIB_MODULES, ServiceImports, VERSIONED_CORE_IMPORTS, VERSIONED_SERVICE_IMPORTS, } from "./import/ImportObjects.js";
4
+ import { ImportedNameValidator } from "./ImportedNameValidator.js";
9
5
  /**
10
6
  * Handles all the import statements for a given file.
11
7
  *
@@ -14,7 +10,7 @@ const ImportedNameValidator_1 = require("./ImportedNameValidator");
14
10
  *
15
11
  * Map<string,string>
16
12
  */
17
- class ImportContainer {
13
+ export class ImportContainer {
18
14
  constructor(path, fileName, dataModel, mainFileNames, bundledFileGeneration, reservedNames) {
19
15
  this.path = path;
20
16
  this.fileName = fileName;
@@ -38,20 +34,30 @@ class ImportContainer {
38
34
  clientApi: { regular: new Map(), typeOnly: new Map() },
39
35
  service: { regular: new Map(), typeOnly: new Map() },
40
36
  };
41
- this.importedNameValidator = new ImportedNameValidator_1.ImportedNameValidator(reservedNames);
37
+ this.importedNameValidator = new ImportedNameValidator(reservedNames);
42
38
  }
43
39
  addCoreLib(odataVersion, coreLib) {
44
- const isVersioned = ImportObjects_1.VERSIONED_CORE_IMPORTS.includes(coreLib);
45
- const name = ImportObjects_1.CoreImports[coreLib] + (isVersioned ? odata_core_1.ODataVersions[odataVersion] : "");
46
- const importName = this.importedNameValidator.validateName(ImportObjects_1.LIB_MODULES.core, name);
40
+ const isVersioned = VERSIONED_CORE_IMPORTS.includes(coreLib);
41
+ const name = CoreImports[coreLib] + (isVersioned ? ODataVersions[odataVersion] : "");
42
+ const importName = this.importedNameValidator.validateName(LIB_MODULES.core, name);
47
43
  // TODO: currently only types are imported, however enums could potentially be imported too
48
44
  this.libs.core.typeOnly.set(name, importName);
49
45
  return importName;
50
46
  }
51
47
  addFromQObject(name, typeOnlyImport = false) {
52
- const importName = this.importedNameValidator.validateName(ImportObjects_1.LIB_MODULES.qObject, name);
53
- const imports = typeOnlyImport ? this.libs.qObject.typeOnly : this.libs.qObject.regular;
54
- imports.set(name, importName);
48
+ const importName = this.importedNameValidator.validateName(LIB_MODULES.qObject, name);
49
+ const imports = this.libs.qObject;
50
+ if (typeOnlyImport) {
51
+ if (!imports.regular.has(name)) {
52
+ imports.typeOnly.set(name, importName);
53
+ }
54
+ }
55
+ else {
56
+ if (imports.typeOnly.has(name)) {
57
+ imports.typeOnly.delete(name);
58
+ }
59
+ imports.regular.set(name, importName);
60
+ }
55
61
  return importName;
56
62
  }
57
63
  addQObject(qObject) {
@@ -61,20 +67,21 @@ class ImportContainer {
61
67
  return this.addFromQObject(qObject, true);
62
68
  }
63
69
  addClientApi(clientApi) {
64
- const name = ImportObjects_1.ClientApiImports[clientApi];
65
- const importName = this.importedNameValidator.validateName(ImportObjects_1.LIB_MODULES.clientApi, name);
70
+ const name = ClientApiImports[clientApi];
71
+ const importName = this.importedNameValidator.validateName(LIB_MODULES.clientApi, name);
66
72
  // complete client api consists only of types
67
73
  this.libs.clientApi.typeOnly.set(name, importName);
68
74
  return importName;
69
75
  }
70
76
  addServiceObject(odataVersion, serviceObject) {
71
- const isVersioned = ImportObjects_1.VERSIONED_SERVICE_IMPORTS.includes(serviceObject);
72
- const name = ImportObjects_1.ServiceImports[serviceObject] + (isVersioned ? odata_core_1.ODataVersions[odataVersion] : "");
73
- const importName = this.importedNameValidator.validateName(ImportObjects_1.LIB_MODULES.service, name);
77
+ const isVersioned = VERSIONED_SERVICE_IMPORTS.includes(serviceObject);
78
+ const name = ServiceImports[serviceObject] + (isVersioned ? ODataVersions[odataVersion] : "");
79
+ const importName = this.importedNameValidator.validateName(LIB_MODULES.service, name);
74
80
  // only regular imports for the service package
75
81
  this.libs.service.regular.set(name, importName);
76
82
  return importName;
77
83
  }
84
+ // TODO: make sure that regular imports win over additional typeOnly imports
78
85
  addCustomType(moduleName, typeName, isTypeOnly = false) {
79
86
  const importName = this.importedNameValidator.validateName(moduleName, typeName);
80
87
  const imports = isTypeOnly ? this.customTypes.typeOnly : this.customTypes.regular;
@@ -93,6 +100,7 @@ class ImportContainer {
93
100
  return this.pathAndFile(this.path, this.fileName) !== this.pathAndFile(filePath, fileName);
94
101
  }
95
102
  addGeneratedImport(folderPath, fileName, name, isTypeOnly = false) {
103
+ var _a, _b, _c;
96
104
  // imports are only relevant for different files
97
105
  if (!this.isDifferentFile(folderPath, fileName)) {
98
106
  return name;
@@ -100,14 +108,20 @@ class ImportContainer {
100
108
  const moduleName = this.pathAndFile(folderPath, fileName);
101
109
  const importName = this.importedNameValidator.validateName(moduleName, name);
102
110
  const imports = isTypeOnly ? this.internalImports.typeOnly : this.internalImports.regular;
111
+ if (isTypeOnly && ((_a = this.internalImports.regular.get(moduleName)) === null || _a === void 0 ? void 0 : _a.has(name))) {
112
+ return importName;
113
+ }
114
+ if (!isTypeOnly && ((_b = this.internalImports.typeOnly.get(moduleName)) === null || _b === void 0 ? void 0 : _b.has(name))) {
115
+ (_c = this.internalImports.typeOnly.get(moduleName)) === null || _c === void 0 ? void 0 : _c.delete(name);
116
+ }
103
117
  const importList = imports.get(moduleName) || new Map();
104
118
  importList.set(name, importName);
105
119
  imports.set(moduleName, importList);
106
120
  return importName;
107
121
  }
108
- addGeneratedModel(fqName, name) {
122
+ addGeneratedModel(fqName, name, isTypeOnly = true) {
109
123
  if (this.bundledFileGeneration) {
110
- return this.addGeneratedImport("", this.mainFileNames.model, name, true);
124
+ return this.addGeneratedImport("", this.mainFileNames.model, name, isTypeOnly);
111
125
  }
112
126
  else {
113
127
  const model = this.dataModel.getModel(fqName);
@@ -116,7 +130,7 @@ class ImportContainer {
116
130
  }
117
131
  const folderPath = model ? model.folderPath : "";
118
132
  const modelName = model ? model.modelName : this.mainFileNames.model;
119
- return this.addGeneratedImport(folderPath, modelName, name, true);
133
+ return this.addGeneratedImport(folderPath, modelName, name, isTypeOnly);
120
134
  }
121
135
  }
122
136
  addGeneratedQObject(fqName, name, isTypeOnly = false) {
@@ -152,7 +166,7 @@ class ImportContainer {
152
166
  getImportDeclarations() {
153
167
  return [
154
168
  ...Object.entries(this.libs).reduce((result, [moduleName, toImport]) => {
155
- const module = ImportObjects_1.LIB_MODULES[moduleName];
169
+ const module = LIB_MODULES[moduleName];
156
170
  if (toImport.typeOnly.size) {
157
171
  result.push(this.createImportDecl(module, toImport.typeOnly, true));
158
172
  }
@@ -192,9 +206,8 @@ class ImportContainer {
192
206
  }));
193
207
  }
194
208
  getModuleSpecifier(filePath) {
195
- const relativePath = path_1.default.relative(this.path, filePath).replaceAll(path_1.default.sep, "/");
209
+ const relativePath = path.relative(this.path, filePath).replaceAll(path.sep, "/");
196
210
  return !relativePath.startsWith(".") ? "./" + relativePath : relativePath;
197
211
  }
198
212
  }
199
- exports.ImportContainer = ImportContainer;
200
213
  //# sourceMappingURL=ImportContainer.js.map