@odata2ts/odata2ts 0.36.2 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/lib/FactoryFunctionModel.d.ts +5 -5
  3. package/lib/FactoryFunctionModel.js +1 -2
  4. package/lib/FactoryFunctionModel.js.map +1 -1
  5. package/lib/NamingModel.js +2 -5
  6. package/lib/NamingModel.js.map +1 -1
  7. package/lib/OptionModel.d.ts +2 -2
  8. package/lib/OptionModel.js +4 -7
  9. package/lib/OptionModel.js.map +1 -1
  10. package/lib/TypeModel.js +2 -5
  11. package/lib/TypeModel.js.map +1 -1
  12. package/lib/app.d.ts +2 -2
  13. package/lib/app.js +23 -27
  14. package/lib/app.js.map +1 -1
  15. package/lib/cli/cli.d.ts +1 -0
  16. package/lib/cli/cli.js +27 -0
  17. package/lib/cli/cli.js.map +1 -0
  18. package/lib/cli/index.d.ts +4 -0
  19. package/lib/cli/index.js +5 -0
  20. package/lib/cli/index.js.map +1 -0
  21. package/lib/cli/processCliArgs.d.ts +2 -0
  22. package/lib/cli/processCliArgs.js +57 -0
  23. package/lib/cli/processCliArgs.js.map +1 -0
  24. package/lib/cli/processConfigFile.d.ts +2 -0
  25. package/lib/cli/processConfigFile.js +24 -0
  26. package/lib/cli/processConfigFile.js.map +1 -0
  27. package/lib/cli/serviceGenerationRun.d.ts +2 -0
  28. package/lib/cli/serviceGenerationRun.js +77 -0
  29. package/lib/cli/serviceGenerationRun.js.map +1 -0
  30. package/lib/data-model/DataModel.d.ts +2 -2
  31. package/lib/data-model/DataModel.js +5 -10
  32. package/lib/data-model/DataModel.js.map +1 -1
  33. package/lib/data-model/DataModelDigestion.d.ts +10 -10
  34. package/lib/data-model/DataModelDigestion.js +19 -23
  35. package/lib/data-model/DataModelDigestion.js.map +1 -1
  36. package/lib/data-model/DataModelDigestionV2.d.ts +2 -2
  37. package/lib/data-model/DataModelDigestionV2.js +27 -31
  38. package/lib/data-model/DataModelDigestionV2.js.map +1 -1
  39. package/lib/data-model/DataModelDigestionV4.d.ts +2 -2
  40. package/lib/data-model/DataModelDigestionV4.js +38 -35
  41. package/lib/data-model/DataModelDigestionV4.js.map +1 -1
  42. package/lib/data-model/DataTypeModel.d.ts +1 -1
  43. package/lib/data-model/DataTypeModel.js +2 -5
  44. package/lib/data-model/DataTypeModel.js.map +1 -1
  45. package/lib/data-model/NamingHelper.d.ts +2 -2
  46. package/lib/data-model/NamingHelper.js +12 -19
  47. package/lib/data-model/NamingHelper.js.map +1 -1
  48. package/lib/data-model/ServiceConfigHelper.d.ts +3 -3
  49. package/lib/data-model/ServiceConfigHelper.js +18 -22
  50. package/lib/data-model/ServiceConfigHelper.js.map +1 -1
  51. package/lib/data-model/edmx/ODataEdmxModelBase.js +1 -2
  52. package/lib/data-model/edmx/ODataEdmxModelV3.d.ts +1 -1
  53. package/lib/data-model/edmx/ODataEdmxModelV3.js +1 -2
  54. package/lib/data-model/edmx/ODataEdmxModelV3.js.map +1 -1
  55. package/lib/data-model/edmx/ODataEdmxModelV4.d.ts +1 -1
  56. package/lib/data-model/edmx/ODataEdmxModelV4.js +1 -2
  57. package/lib/data-model/edmx/ODataEdmxModelV4.js.map +1 -1
  58. package/lib/data-model/validation/NameClashValidator.d.ts +2 -2
  59. package/lib/data-model/validation/NameClashValidator.js +10 -14
  60. package/lib/data-model/validation/NameClashValidator.js.map +1 -1
  61. package/lib/data-model/validation/NameValidator.d.ts +1 -1
  62. package/lib/data-model/validation/NameValidator.js +1 -2
  63. package/lib/data-model/validation/NameValidator.js.map +1 -1
  64. package/lib/data-model/validation/NoopValidator.d.ts +1 -1
  65. package/lib/data-model/validation/NoopValidator.js +1 -5
  66. package/lib/data-model/validation/NoopValidator.js.map +1 -1
  67. package/lib/defaultConfig.d.ts +1 -1
  68. package/lib/defaultConfig.js +21 -26
  69. package/lib/defaultConfig.js.map +1 -1
  70. package/lib/download/downloadMetadata.d.ts +1 -1
  71. package/lib/download/downloadMetadata.js +6 -10
  72. package/lib/download/downloadMetadata.js.map +1 -1
  73. package/lib/download/index.d.ts +2 -2
  74. package/lib/download/index.js +2 -7
  75. package/lib/download/index.js.map +1 -1
  76. package/lib/download/storeMetadata.js +15 -17
  77. package/lib/download/storeMetadata.js.map +1 -1
  78. package/lib/evaluateConfig.d.ts +1 -1
  79. package/lib/evaluateConfig.js +14 -18
  80. package/lib/evaluateConfig.js.map +1 -1
  81. package/lib/generator/ImportContainer.d.ts +2 -2
  82. package/lib/generator/ImportContainer.js +17 -22
  83. package/lib/generator/ImportContainer.js.map +1 -1
  84. package/lib/generator/ImportedNameValidator.js +1 -5
  85. package/lib/generator/ImportedNameValidator.js.map +1 -1
  86. package/lib/generator/ModelGenerator.d.ts +1 -1
  87. package/lib/generator/ModelGenerator.js +8 -12
  88. package/lib/generator/ModelGenerator.js.map +1 -1
  89. package/lib/generator/QueryObjectGenerator.d.ts +1 -1
  90. package/lib/generator/QueryObjectGenerator.js +25 -29
  91. package/lib/generator/QueryObjectGenerator.js.map +1 -1
  92. package/lib/generator/ServiceGenerator.d.ts +4 -4
  93. package/lib/generator/ServiceGenerator.js +52 -56
  94. package/lib/generator/ServiceGenerator.js.map +1 -1
  95. package/lib/generator/import/ImportObjects.js +11 -14
  96. package/lib/generator/import/ImportObjects.js.map +1 -1
  97. package/lib/generator/index.d.ts +3 -3
  98. package/lib/generator/index.js +3 -9
  99. package/lib/generator/index.js.map +1 -1
  100. package/lib/index.d.ts +4 -4
  101. package/lib/index.js +4 -7
  102. package/lib/index.js.map +1 -1
  103. package/lib/project/FileHandler.d.ts +3 -3
  104. package/lib/project/FileHandler.js +12 -16
  105. package/lib/project/FileHandler.js.map +1 -1
  106. package/lib/project/ProjectManager.d.ts +5 -5
  107. package/lib/project/ProjectManager.js +25 -32
  108. package/lib/project/ProjectManager.js.map +1 -1
  109. package/lib/project/TsMorphHelper.d.ts +1 -1
  110. package/lib/project/TsMorphHelper.js +21 -22
  111. package/lib/project/TsMorphHelper.js.map +1 -1
  112. package/lib/project/formatter/BaseFormatter.d.ts +1 -1
  113. package/lib/project/formatter/BaseFormatter.js +1 -5
  114. package/lib/project/formatter/BaseFormatter.js.map +1 -1
  115. package/lib/project/formatter/FileFormatter.js +1 -2
  116. package/lib/project/formatter/NoopFormatter.d.ts +1 -1
  117. package/lib/project/formatter/NoopFormatter.js +5 -9
  118. package/lib/project/formatter/NoopFormatter.js.map +1 -1
  119. package/lib/project/formatter/PrettierFormatter.d.ts +1 -1
  120. package/lib/project/formatter/PrettierFormatter.js +20 -25
  121. package/lib/project/formatter/PrettierFormatter.js.map +1 -1
  122. package/lib/project/formatter/index.d.ts +1 -1
  123. package/lib/project/formatter/index.js +6 -10
  124. package/lib/project/formatter/index.js.map +1 -1
  125. package/lib/project/logger/logFilePath.js +4 -9
  126. package/lib/project/logger/logFilePath.js.map +1 -1
  127. package/lib/run-cli.js +2 -4
  128. package/lib/run-cli.js.map +1 -1
  129. package/package.json +53 -63
  130. package/lib/cli.d.ts +0 -3
  131. package/lib/cli.js +0 -176
  132. package/lib/cli.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,27 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.37.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.36.3...@odata2ts/odata2ts@0.37.0) (2024-08-25)
7
+
8
+ ### Code Refactoring
9
+
10
+ * vitest instead of jest & switch to ESM ([#300](https://github.com/odata2ts/odata2ts/issues/300)) ([7bc8888](https://github.com/odata2ts/odata2ts/commit/7bc88884317b6fc269729cf4eb08602571b69a2d))
11
+
12
+ ### Features
13
+
14
+ * use kebap-case for folder names (unbundledFileGeneration) ([9f26e1f](https://github.com/odata2ts/odata2ts/commit/9f26e1f2e49fbe32a61a43ba2dd29be85a3561c3))
15
+
16
+ ### BREAKING CHANGES
17
+
18
+ * as there is no generated index file all file paths must be fixed.
19
+ * ESM tends to break stuff
20
+
21
+ ## [0.36.3](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.36.2...@odata2ts/odata2ts@0.36.3) (2024-08-12)
22
+
23
+ ### Bug Fixes
24
+
25
+ * **generator:** v4 types like Edm.Date, Edm.TimeOfDay and Emd.Duration are not recognized ([#295](https://github.com/odata2ts/odata2ts/issues/295)) ([3b63969](https://github.com/odata2ts/odata2ts/commit/3b639699217ba234cf9e5508f24a64c4d6f3d3dd))
26
+
6
27
  ## [0.36.2](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.36.1...@odata2ts/odata2ts@0.36.2) (2024-08-01)
7
28
 
8
29
  ### Bug Fixes
@@ -1,9 +1,9 @@
1
1
  import { ODataVersions } from "@odata2ts/odata-core";
2
- import { DataModel } from "./data-model/DataModel";
3
- import { Schema } from "./data-model/edmx/ODataEdmxModelBase";
4
- import { NamingHelper } from "./data-model/NamingHelper";
5
- import { RunOptions } from "./OptionModel";
6
- import { ProjectManager } from "./project/ProjectManager";
2
+ import { DataModel } from "./data-model/DataModel.js";
3
+ import { Schema } from "./data-model/edmx/ODataEdmxModelBase.js";
4
+ import { NamingHelper } from "./data-model/NamingHelper.js";
5
+ import { RunOptions } from "./OptionModel.js";
6
+ import { ProjectManager } from "./project/ProjectManager.js";
7
7
  export type DigestionOptions = Pick<RunOptions, "converters" | "disableAutoManagedKey" | "propertiesByName" | "byTypeAndName" | "v2ModelsWithExtraResultsWrapping" | "v4BigNumberAsString" | "skipEditableModels" | "skipComments" | "disableAutomaticNameClashResolution" | "bundledFileGeneration">;
8
8
  /**
9
9
  * Takes an EdmxSchema plus the run options and creates a DataModel.
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=FactoryFunctionModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FactoryFunctionModel.js","sourceRoot":"","sources":["../src/FactoryFunctionModel.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { SourceFile } from \"ts-morph\";\r\n\r\nimport { DataModel } from \"./data-model/DataModel\";\r\nimport { Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper\";\r\nimport { RunOptions } from \"./OptionModel\";\r\nimport { ProjectManager } from \"./project/ProjectManager\";\r\n\r\nexport type DigestionOptions = Pick<\r\n RunOptions,\r\n | \"converters\"\r\n | \"disableAutoManagedKey\"\r\n | \"propertiesByName\"\r\n | \"byTypeAndName\"\r\n | \"v2ModelsWithExtraResultsWrapping\"\r\n | \"v4BigNumberAsString\"\r\n | \"skipEditableModels\"\r\n | \"skipComments\"\r\n | \"disableAutomaticNameClashResolution\"\r\n | \"bundledFileGeneration\"\r\n>;\r\n\r\n/**\r\n * Takes an EdmxSchema plus the run options and creates a DataModel.\r\n */\r\nexport type DigesterFunction<S extends Schema<any, any>> = (\r\n schema: Array<S>,\r\n options: DigestionOptions,\r\n namingHelper: NamingHelper\r\n) => Promise<DataModel>;\r\n\r\nexport type GeneratorFunctionOptions = Pick<\r\n RunOptions,\r\n \"skipEditableModels\" | \"skipIdModels\" | \"skipOperations\" | \"skipComments\" | \"v2ModelsWithExtraResultsWrapping\"\r\n>;\r\n\r\nexport type EntityBasedGeneratorFunction = (\r\n project: ProjectManager,\r\n dataModel: DataModel,\r\n version: ODataVersions,\r\n options: GeneratorFunctionOptions,\r\n namingHelper: NamingHelper\r\n) => Promise<void>;\r\n"]}
1
+ {"version":3,"file":"FactoryFunctionModel.js","sourceRoot":"","sources":["../src/FactoryFunctionModel.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\n\r\nimport { DataModel } from \"./data-model/DataModel.js\";\r\nimport { Schema } from \"./data-model/edmx/ODataEdmxModelBase.js\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper.js\";\r\nimport { RunOptions } from \"./OptionModel.js\";\r\nimport { ProjectManager } from \"./project/ProjectManager.js\";\r\n\r\nexport type DigestionOptions = Pick<\r\n RunOptions,\r\n | \"converters\"\r\n | \"disableAutoManagedKey\"\r\n | \"propertiesByName\"\r\n | \"byTypeAndName\"\r\n | \"v2ModelsWithExtraResultsWrapping\"\r\n | \"v4BigNumberAsString\"\r\n | \"skipEditableModels\"\r\n | \"skipComments\"\r\n | \"disableAutomaticNameClashResolution\"\r\n | \"bundledFileGeneration\"\r\n>;\r\n\r\n/**\r\n * Takes an EdmxSchema plus the run options and creates a DataModel.\r\n */\r\nexport type DigesterFunction<S extends Schema<any, any>> = (\r\n schema: Array<S>,\r\n options: DigestionOptions,\r\n namingHelper: NamingHelper\r\n) => Promise<DataModel>;\r\n\r\nexport type GeneratorFunctionOptions = Pick<\r\n RunOptions,\r\n \"skipEditableModels\" | \"skipIdModels\" | \"skipOperations\" | \"skipComments\" | \"v2ModelsWithExtraResultsWrapping\"\r\n>;\r\n\r\nexport type EntityBasedGeneratorFunction = (\r\n project: ProjectManager,\r\n dataModel: DataModel,\r\n version: ODataVersions,\r\n options: GeneratorFunctionOptions,\r\n namingHelper: NamingHelper\r\n) => Promise<void>;\r\n"]}
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NamingStrategies = void 0;
4
- var NamingStrategies;
1
+ export var NamingStrategies;
5
2
  (function (NamingStrategies) {
6
3
  NamingStrategies["NONE"] = "";
7
4
  NamingStrategies["PASCAL_CASE"] = "pascalCase";
8
5
  NamingStrategies["CAMEL_CASE"] = "camelCase";
9
6
  NamingStrategies["CONSTANT_CASE"] = "constantCase";
10
7
  NamingStrategies["SNAKE_CASE"] = "snakeCase";
11
- })(NamingStrategies || (exports.NamingStrategies = NamingStrategies = {}));
8
+ })(NamingStrategies || (NamingStrategies = {}));
12
9
  //# sourceMappingURL=NamingModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NamingModel.js","sourceRoot":"","sources":["../src/NamingModel.ts"],"names":[],"mappings":";;;AAKA,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,6BAAS,CAAA;IACT,8CAA0B,CAAA;IAC1B,4CAAwB,CAAA;IACxB,kDAA8B,CAAA;IAC9B,4CAAwB,CAAA;AAC1B,CAAC,EANW,gBAAgB,gCAAhB,gBAAgB,QAM3B","sourcesContent":["/**\r\n * The available naming strategies.\r\n */\r\nimport { PartialDeep } from \"type-fest\";\r\n\r\nexport enum NamingStrategies {\r\n NONE = \"\",\r\n PASCAL_CASE = \"pascalCase\",\r\n CAMEL_CASE = \"camelCase\",\r\n CONSTANT_CASE = \"constantCase\",\r\n SNAKE_CASE = \"snakeCase\",\r\n}\r\n\r\n/**\r\n * Based on an existing configuration (for example default settings) the user only specifies what needs\r\n * to be changed. Hence, all options are completely optional.\r\n */\r\nexport interface OverridableNamingOptions extends PartialDeep<NameSettings> {}\r\n\r\n/**\r\n * The required and optional name settings for the generator.\r\n */\r\nexport interface NameSettings {\r\n /**\r\n * Because multiple artefacts are generated out of the same entity, some name settings are required in order\r\n * to differentiate those artefacts. Out-of-the-box odata2ts provides you with sensible default settings,\r\n * so that you only need to override those settings you want to change.\r\n *\r\n * However, sometimes it makes more sense to start from scratch, so that the defaults don't interfere with\r\n * your own configuration. In this scenario this switch should be enabled to only have default values for\r\n * the required name settings.\r\n */\r\n minimalDefaults?: boolean;\r\n\r\n /**\r\n * Generation options for models, i.e. interfaces representing entity or complex types.\r\n */\r\n models: ModelNamingOptions;\r\n\r\n /**\r\n * Generation options for Query Objects.\r\n *\r\n * By default, prefix = \"Q\"\r\n */\r\n queryObjects: QueryObjectNamingOptions;\r\n\r\n services: ServiceNamingOptions;\r\n}\r\n\r\nexport interface ModelNamingOptions extends NamingStrategyOption, StandardNamingOptions {\r\n /**\r\n * All generated models are bundled into one file.\r\n * This option specifies the formatting of the file name.\r\n */\r\n fileName: FileNamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Choose a specific strategy to format property names of models: pascal-case, camel-case, etc.\r\n * By default, camel-case.\r\n */\r\n propNamingStrategy?: NamingStrategies;\r\n\r\n /**\r\n * For each model an editable version is generated which represents the model definition for\r\n * create, update and patch actions.\r\n *\r\n * You can override the naming options here.\r\n * By default, prefix = \"Editable\"\r\n */\r\n editableModels: EntityDerivedNamingOptions;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n *\r\n * You can configure the naming options here.\r\n * By default, suffix = \"Id\"\r\n */\r\n idModels: EntityDerivedNamingOptions;\r\n\r\n /**\r\n * Operation parameter models are generated from function or action signatures.\r\n *\r\n * You can configure the naming options here.\r\n * By default, suffix = \"Params\"\r\n */\r\n operationParamModels: EntityDerivedNamingOptions;\r\n}\r\n\r\nexport interface EntityDerivedNamingOptions extends RequiredNamingOptions {\r\n applyModelNaming?: boolean;\r\n}\r\n\r\nexport interface QueryObjectNamingOptions extends NamingStrategyOption, RequiredNamingOptions {\r\n /**\r\n * All generated models are bundled into one file.\r\n * This option specifies the formatting of the file name.\r\n */\r\n fileName: FileNamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Choose a specific strategy to format property names of query objects: pascal-case, camel-case, etc.\r\n * By default, camel-case.\r\n */\r\n propNamingStrategy?: NamingStrategies;\r\n\r\n idFunctions: RequiredNamingOptions;\r\n\r\n operations?: OperationNamingOptions;\r\n}\r\n\r\nexport interface OperationNamingOptions extends StandardNamingOptions {\r\n /**\r\n * Naming options for actions only.\r\n * When this configuration is provided, the parent configuration regarding suffix and prefix is ignored.\r\n */\r\n action?: StandardNamingOptions;\r\n /**\r\n * Naming options for functions only.\r\n * When this configuration is provided, the parent configuration regarding suffix and prefix is ignored.\r\n */\r\n function?: StandardNamingOptions;\r\n}\r\n\r\nexport interface NamingStrategyOption {\r\n /**\r\n * Choose a specific strategy to format names: pascal-case, camel-case, etc.\r\n * Defaults to pascal-case.\r\n */\r\n namingStrategy?: NamingStrategies;\r\n}\r\n\r\nexport interface FileNamingStrategyOption {\r\n /**\r\n * Choose a specific strategy to format names: pascal-case, camel-case, etc.\r\n * Defaults to pascal-case.\r\n */\r\n namingStrategy?: NamingStrategies;\r\n}\r\n\r\nexport interface StandardNamingOptions {\r\n /**\r\n * Prefix all names, e.g. \"I\" => \"ITest\"\r\n */\r\n prefix?: string;\r\n /**\r\n * Suffix all names, e.g. \"model\" => \"TestModel\"\r\n */\r\n suffix?: string;\r\n}\r\n\r\nexport interface RequiredNamingOptions extends Required<StandardNamingOptions> {}\r\n\r\n/**\r\n * Naming options for generated service classes.\r\n * These options affect the main service as well as all services generated for each entity, complex and collection type.\r\n *\r\n * There exists one specialty about services: The file names are not configurable.\r\n * File names are determined by the name of their corresponding classes, so that service file name\r\n * and service class name always correspond.\r\n *\r\n * By default, suffix = Service and namingStrategy = PascalCase\r\n */\r\nexport interface ServiceNamingOptions extends NamingStrategyOption, RequiredNamingOptions {\r\n /**\r\n * Controls the naming options for the main odata service.\r\n * By default, the base service naming options are applied.\r\n * But since this is the main entry point for users, it can be configured individually here.\r\n *\r\n * By default, applyServiceNaming = true\r\n */\r\n main?: NamingStrategyOption & StandardNamingOptions & { applyServiceNaming?: boolean };\r\n\r\n /**\r\n * Name of the service responsible for entity collections.\r\n *\r\n * By default, suffix = Collection and applyServiceNaming = true\r\n */\r\n collection: RequiredNamingOptions & { applyServiceNaming?: boolean };\r\n\r\n /**\r\n * Naming for getter method of another service.\r\n *\r\n * By default, namingStrategy = camelCase\r\n */\r\n relatedServiceGetter: NamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Operations are functions and actions of the OData service and are represented as methods\r\n * of the generated service class. This setting controls the naming of the corresponding\r\n * function.\r\n *\r\n * By default, namingStrategy = camelCase\r\n */\r\n operations?: NamingStrategyOption & OperationNamingOptions;\r\n\r\n /**\r\n * Naming options for private properties of service classes.\r\n *\r\n * By default, prefix = _\r\n */\r\n privateProps: NamingStrategyOption & RequiredNamingOptions;\r\n}\r\n"]}
1
+ {"version":3,"file":"NamingModel.js","sourceRoot":"","sources":["../src/NamingModel.ts"],"names":[],"mappings":"AAKA,MAAM,CAAN,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,6BAAS,CAAA;IACT,8CAA0B,CAAA;IAC1B,4CAAwB,CAAA;IACxB,kDAA8B,CAAA;IAC9B,4CAAwB,CAAA;AAC1B,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B","sourcesContent":["/**\r\n * The available naming strategies.\r\n */\r\nimport { PartialDeep } from \"type-fest\";\r\n\r\nexport enum NamingStrategies {\r\n NONE = \"\",\r\n PASCAL_CASE = \"pascalCase\",\r\n CAMEL_CASE = \"camelCase\",\r\n CONSTANT_CASE = \"constantCase\",\r\n SNAKE_CASE = \"snakeCase\",\r\n}\r\n\r\n/**\r\n * Based on an existing configuration (for example default settings) the user only specifies what needs\r\n * to be changed. Hence, all options are completely optional.\r\n */\r\nexport interface OverridableNamingOptions extends PartialDeep<NameSettings> {}\r\n\r\n/**\r\n * The required and optional name settings for the generator.\r\n */\r\nexport interface NameSettings {\r\n /**\r\n * Because multiple artefacts are generated out of the same entity, some name settings are required in order\r\n * to differentiate those artefacts. Out-of-the-box odata2ts provides you with sensible default settings,\r\n * so that you only need to override those settings you want to change.\r\n *\r\n * However, sometimes it makes more sense to start from scratch, so that the defaults don't interfere with\r\n * your own configuration. In this scenario this switch should be enabled to only have default values for\r\n * the required name settings.\r\n */\r\n minimalDefaults?: boolean;\r\n\r\n /**\r\n * Generation options for models, i.e. interfaces representing entity or complex types.\r\n */\r\n models: ModelNamingOptions;\r\n\r\n /**\r\n * Generation options for Query Objects.\r\n *\r\n * By default, prefix = \"Q\"\r\n */\r\n queryObjects: QueryObjectNamingOptions;\r\n\r\n services: ServiceNamingOptions;\r\n}\r\n\r\nexport interface ModelNamingOptions extends NamingStrategyOption, StandardNamingOptions {\r\n /**\r\n * All generated models are bundled into one file.\r\n * This option specifies the formatting of the file name.\r\n */\r\n fileName: FileNamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Choose a specific strategy to format property names of models: pascal-case, camel-case, etc.\r\n * By default, camel-case.\r\n */\r\n propNamingStrategy?: NamingStrategies;\r\n\r\n /**\r\n * For each model an editable version is generated which represents the model definition for\r\n * create, update and patch actions.\r\n *\r\n * You can override the naming options here.\r\n * By default, prefix = \"Editable\"\r\n */\r\n editableModels: EntityDerivedNamingOptions;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n *\r\n * You can configure the naming options here.\r\n * By default, suffix = \"Id\"\r\n */\r\n idModels: EntityDerivedNamingOptions;\r\n\r\n /**\r\n * Operation parameter models are generated from function or action signatures.\r\n *\r\n * You can configure the naming options here.\r\n * By default, suffix = \"Params\"\r\n */\r\n operationParamModels: EntityDerivedNamingOptions;\r\n}\r\n\r\nexport interface EntityDerivedNamingOptions extends RequiredNamingOptions {\r\n applyModelNaming?: boolean;\r\n}\r\n\r\nexport interface QueryObjectNamingOptions extends NamingStrategyOption, RequiredNamingOptions {\r\n /**\r\n * All generated models are bundled into one file.\r\n * This option specifies the formatting of the file name.\r\n */\r\n fileName: FileNamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Choose a specific strategy to format property names of query objects: pascal-case, camel-case, etc.\r\n * By default, camel-case.\r\n */\r\n propNamingStrategy?: NamingStrategies;\r\n\r\n idFunctions: RequiredNamingOptions;\r\n\r\n operations?: OperationNamingOptions;\r\n}\r\n\r\nexport interface OperationNamingOptions extends StandardNamingOptions {\r\n /**\r\n * Naming options for actions only.\r\n * When this configuration is provided, the parent configuration regarding suffix and prefix is ignored.\r\n */\r\n action?: StandardNamingOptions;\r\n /**\r\n * Naming options for functions only.\r\n * When this configuration is provided, the parent configuration regarding suffix and prefix is ignored.\r\n */\r\n function?: StandardNamingOptions;\r\n}\r\n\r\nexport interface NamingStrategyOption {\r\n /**\r\n * Choose a specific strategy to format names: pascal-case, camel-case, etc.\r\n * Defaults to pascal-case.\r\n */\r\n namingStrategy?: NamingStrategies;\r\n}\r\n\r\nexport interface FileNamingStrategyOption {\r\n /**\r\n * Choose a specific strategy to format names: pascal-case, camel-case, etc.\r\n * Defaults to pascal-case.\r\n */\r\n namingStrategy?: NamingStrategies;\r\n}\r\n\r\nexport interface StandardNamingOptions {\r\n /**\r\n * Prefix all names, e.g. \"I\" => \"ITest\"\r\n */\r\n prefix?: string;\r\n /**\r\n * Suffix all names, e.g. \"model\" => \"TestModel\"\r\n */\r\n suffix?: string;\r\n}\r\n\r\nexport interface RequiredNamingOptions extends Required<StandardNamingOptions> {}\r\n\r\n/**\r\n * Naming options for generated service classes.\r\n * These options affect the main service as well as all services generated for each entity, complex and collection type.\r\n *\r\n * There exists one specialty about services: The file names are not configurable.\r\n * File names are determined by the name of their corresponding classes, so that service file name\r\n * and service class name always correspond.\r\n *\r\n * By default, suffix = Service and namingStrategy = PascalCase\r\n */\r\nexport interface ServiceNamingOptions extends NamingStrategyOption, RequiredNamingOptions {\r\n /**\r\n * Controls the naming options for the main odata service.\r\n * By default, the base service naming options are applied.\r\n * But since this is the main entry point for users, it can be configured individually here.\r\n *\r\n * By default, applyServiceNaming = true\r\n */\r\n main?: NamingStrategyOption & StandardNamingOptions & { applyServiceNaming?: boolean };\r\n\r\n /**\r\n * Name of the service responsible for entity collections.\r\n *\r\n * By default, suffix = Collection and applyServiceNaming = true\r\n */\r\n collection: RequiredNamingOptions & { applyServiceNaming?: boolean };\r\n\r\n /**\r\n * Naming for getter method of another service.\r\n *\r\n * By default, namingStrategy = camelCase\r\n */\r\n relatedServiceGetter: NamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Operations are functions and actions of the OData service and are represented as methods\r\n * of the generated service class. This setting controls the naming of the corresponding\r\n * function.\r\n *\r\n * By default, namingStrategy = camelCase\r\n */\r\n operations?: NamingStrategyOption & OperationNamingOptions;\r\n\r\n /**\r\n * Naming options for private properties of service classes.\r\n *\r\n * By default, prefix = _\r\n */\r\n privateProps: NamingStrategyOption & RequiredNamingOptions;\r\n}\r\n"]}
@@ -1,7 +1,7 @@
1
1
  import { TypeConverterConfig } from "@odata2ts/converter-runtime";
2
2
  import { AxiosRequestConfig } from "axios";
3
- import { NameSettings, OverridableNamingOptions } from "./NamingModel";
4
- import { TypeModel } from "./TypeModel";
3
+ import { NameSettings, OverridableNamingOptions } from "./NamingModel.js";
4
+ import { TypeModel } from "./TypeModel.js";
5
5
  /**
6
6
  * Generation mode, by default "all".
7
7
  */
@@ -1,24 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmitModes = exports.Modes = void 0;
4
1
  /**
5
2
  * Generation mode, by default "all".
6
3
  */
7
- var Modes;
4
+ export var Modes;
8
5
  (function (Modes) {
9
6
  Modes[Modes["models"] = 0] = "models";
10
7
  Modes[Modes["qobjects"] = 1] = "qobjects";
11
8
  Modes[Modes["service"] = 2] = "service";
12
9
  Modes[Modes["all"] = 3] = "all";
13
- })(Modes || (exports.Modes = Modes = {}));
10
+ })(Modes || (Modes = {}));
14
11
  /**
15
12
  * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.
16
13
  */
17
- var EmitModes;
14
+ export var EmitModes;
18
15
  (function (EmitModes) {
19
16
  EmitModes["ts"] = "ts";
20
17
  EmitModes["js"] = "js";
21
18
  EmitModes["dts"] = "dts";
22
19
  EmitModes["js_dts"] = "js_dts";
23
- })(EmitModes || (exports.EmitModes = EmitModes = {}));
20
+ })(EmitModes || (EmitModes = {}));
24
21
  //# sourceMappingURL=OptionModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OptionModel.js","sourceRoot":"","sources":["../src/OptionModel.ts"],"names":[],"mappings":";;;AAMA;;GAEG;AACH,IAAY,KAKX;AALD,WAAY,KAAK;IACf,qCAAM,CAAA;IACN,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,+BAAG,CAAA;AACL,CAAC,EALW,KAAK,qBAAL,KAAK,QAKhB;AAED;;GAEG;AACH,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,yBAAT,SAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\r\nimport { AxiosRequestConfig } from \"axios\";\r\n\r\nimport { NameSettings, OverridableNamingOptions } from \"./NamingModel\";\r\nimport { TypeModel } from \"./TypeModel\";\r\n\r\n/**\r\n * Generation mode, by default \"all\".\r\n */\r\nexport enum Modes {\r\n models,\r\n qobjects,\r\n service,\r\n all,\r\n}\r\n\r\n/**\r\n * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.\r\n */\r\nexport enum EmitModes {\r\n ts = \"ts\",\r\n js = \"js\",\r\n dts = \"dts\",\r\n js_dts = \"js_dts\",\r\n}\r\n\r\n/**\r\n * Config options for CLI.\r\n */\r\nexport interface CliOptions {\r\n /**\r\n * The URL to the root of your OData service. The URL might end in a slash or not, it might also end\r\n * in $metadata, but we usually add this for you.\r\n *\r\n * Specifying the URL is a convenience feature to download the metadata file from the given URL.\r\n * You can configure this request via `sourceConfig` option.\r\n *\r\n * The `source` option must still be specified as it is used to store the downloaded file on your disk.\r\n * By default, the file is used once it has been downloaded.\r\n */\r\n sourceUrl?: string;\r\n /**\r\n * Downloads the metadata file and overwrites the existing one, if any.\r\n *\r\n * Only takes effect, if option `sourceUrl` is specified.\r\n */\r\n refreshFile?: boolean;\r\n /**\r\n * The source is the file to use (must be an EDMX compliant XML file) or the URL to the\r\n * metadata (ROOT_SERVICE/$metadata).\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n source?: string;\r\n /**\r\n * Specifies the output directory for the generated stuff.\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n output?: string;\r\n /**\r\n * Only generates the specified services.\r\n * Relies on an existing config file where these service names are maintained.\r\n */\r\n services?: Array<string>;\r\n /**\r\n * Specifies what to generate:\r\n * - {@code Modes.models} will only generate TS interfaces\r\n * - {@code Modes.qobjects} will generate functional units used in QueryBuilder and for functions and actions\r\n * - {@code Modes.service} will generate one main OData service client and one per each entity\r\n * - {@code Modes.all} the same as {@code Modes.service}\r\n *\r\n * QObjects will also generate models, and generating the service client will also generate models and QObjects.\r\n * Defaults to {@code Modes.all}\r\n */\r\n mode?: Modes;\r\n /**\r\n * Specifies the type of the output files: TypeScript, JS, DTS only, JS with DTS.\r\n * Defaults to {@code EmitModes.js_dts}\r\n */\r\n emitMode?: EmitModes;\r\n /**\r\n * Uses prettier with your local configuration to pretty print TypeScript files.\r\n * Only applies if mode is set to {@code EmitModes.ts}.\r\n */\r\n prettier?: boolean;\r\n /**\r\n * When compiling TypeScript to JS, \"tsconfig.json\" is used by default to add compilerOptions.\r\n * This option allows to specify an alternative file.\r\n *\r\n * Only takes effect, when mode is set to anything else than {@code EmitModes.ts}.\r\n */\r\n tsconfig?: string;\r\n /**\r\n * Verbose debugging information.\r\n */\r\n debug?: boolean;\r\n /**\r\n * Overrides the service name found in the source file.\r\n *\r\n * The service name is the basis for all file names and the name of the main OData client service\r\n * that serves as entry point for the user.\r\n */\r\n serviceName?: string;\r\n /**\r\n * odata2ts will automatically decide if a key prop is managed on the server side.\r\n * If managed, the property will not be editable (create, update, patch).\r\n * The following rule applies:\r\n * If a property is the only key prop of an entity, then the prop is deemed to be managed;\r\n * in ony other case the prop is unmanaged.\r\n */\r\n disableAutoManagedKey?: boolean;\r\n /**\r\n * By default, odata2ts doesn't change param, operation, property or model names.\r\n * The generated models and their properties are named exactly as advertised by the server.\r\n *\r\n * By allowing odata2ts to change these names, certain predefined formatting strategies are used:\r\n * Model / class names are formatted with PascalCase; property, param, and operation names with camelCase.\r\n *\r\n * The naming configuration allows to control this and other naming related settings.\r\n * Note: Even if renaming is disabled, model prefixing / suffixing still applies.\r\n */\r\n allowRenaming?: boolean;\r\n}\r\n\r\n/**\r\n * Configuration options of the request to retrieve the metadata.\r\n * Only takes effect if `source` is a URL.\r\n */\r\nexport interface UrlSourceConfiguration {\r\n /**\r\n * Basic auth credentials: the username.\r\n * Only takes effect if `password` has also been set.\r\n */\r\n username?: string;\r\n /**\r\n * Basic auth credentials: the password.\r\n * Only takes effect if `username` has also been set.\r\n */\r\n password?: string;\r\n /**\r\n * Custom request configuration.\r\n * URL and method `GET` are set by default, but can be overwritten.\r\n */\r\n custom?: AxiosRequestConfig;\r\n}\r\n\r\n/**\r\n * Available options for configuration files, i.e. odata2ts.config.ts.\r\n */\r\nexport interface ConfigFileOptions extends Omit<CliOptions, \"sourceUrl\" | \"source\" | \"output\" | \"services\"> {\r\n /**\r\n * Configuration options of the request to retrieve the metadata.\r\n * Only takes effect if `sourceUrl` is a URL.\r\n */\r\n sourceUrlConfig?: UrlSourceConfiguration;\r\n\r\n /**\r\n * Configuration of each service.\r\n *\r\n * @example { services: { trippin: { source: \"...\", ... } }}\r\n */\r\n services?: { [serviceName: string]: ServiceGenerationOptions };\r\n\r\n /**\r\n * Specify which converters to use by their package name, e.g. \"@odata2ts/converter-v2-to-v4\".\r\n * Each converter knows which data type to map.\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n converters?: Array<string | TypeConverterConfig>;\r\n\r\n /**\r\n * For each model an editable version is generated which represents the model definition for\r\n * create, update and patch actions.\r\n *\r\n * You can skip the generation altogether, not generating editable model variants,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipEditableModels?: boolean;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n * The generation for one entity entails one model interface representing the id parameters and\r\n * one QId function which allows to format the parameters for URL usage and to parse parameters\r\n * from a URL string.\r\n *\r\n * You can skip the generation altogether, not generating models and QId objects, if the\r\n * generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipIdModels?: boolean;\r\n /**\r\n * Operations are functions and actions of the OData service.\r\n * The generation for one operation entails one parameter model interface\r\n * and one QFunction / QAction class.\r\n *\r\n * You can skip the generation altogether, neither generating model nor query object,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipOperations?: boolean;\r\n /**\r\n * Model properties have explaining comments by default.\r\n * With this option you can turn that off.\r\n */\r\n skipComments?: boolean;\r\n /**\r\n * With OData you can read, update and delete data on a primitive property (`Edm.*`).\r\n * Usually, you wouldn't do that, but go for a bigger request, fetching more relevant information in one go.\r\n *\r\n * There's one exception: Handling `Edm.Stream´ properties and Media entities. Services for stream / media\r\n * stuff are generated regardless of this setting.\r\n */\r\n enablePrimitivePropertyServices?: boolean;\r\n\r\n /**\r\n * The naming options regarding the generated artefacts.\r\n */\r\n naming?: OverridableNamingOptions;\r\n\r\n /**\r\n * Some OData V2 services generate an extra wrapping for entity collection attributes:\r\n * <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities\r\n * an object with the property \"results\" is wrapped around the entity collection.\r\n *\r\n * If you're using the odata client then there's a build-in workaround in place which transforms\r\n * the results to remove this extra mapping. However, if you're only interested in the types, then\r\n * the generated models will not match that extra wrapping.\r\n *\r\n * Setting this configuration option to <code>true</code> (default: false) will add this extra\r\n * wrapping to the generated models. But this option is only valid if the generation mode is set\r\n * to <code>models</code>; it is ignored otherwise.\r\n */\r\n v2ModelsWithExtraResultsWrapping?: boolean;\r\n /**\r\n * Numbers of type `Edm.Int64` and `Edm.Decimal` are represented as `number` in V4.\r\n * However, these numbers might not fit into JS' number type, which might result in precision loss.\r\n *\r\n * OData offers a special IEEE754 format option to get those types as `string` instead to prevent any\r\n * precision loss. So if you're handling very large or very small numbers (JS roughly supports 15 digits),\r\n * then you should use this option and, probably, also an appropriate converter (see available converters).\r\n *\r\n * Activating this option affects the type generation and will use `string` for both mentioned types.\r\n * All requests are executed with the \"accept\" header set to \"application/json;IEEE754Compatible=true\".\r\n * Additionally, when sending data the very same value will be set for the \"content-type\" header.\r\n */\r\n v4BigNumberAsString?: boolean;\r\n /**\r\n * OData allows for namespaces so any entity is unique by virtue of it's name within a namespace.\r\n * odata2ts works with these fully qualified names internally, but only uses the plain name when generating\r\n * stuff. This might lead to name clashes (same name in different namespaces).\r\n *\r\n * odata2ts employs a simple, automatic resolution strategy: Adding a counter at the end of the name.\r\n * Set this property to true in order to disable this automatism.\r\n */\r\n disableAutomaticNameClashResolution?: boolean;\r\n /**\r\n * By default, odata2ts generates a folder structure with individual files per entity.\r\n * This allows for handling and scaling the generation process for large data structures.\r\n *\r\n * However, especially UI5 has problems with recursive structures, which are absolutely valid within\r\n * OData. Here the solution is to generate only one file per type to circumvent cyclic imports.\r\n * To enable this behaviour set this option to true.\r\n */\r\n bundledFileGeneration?: boolean;\r\n}\r\n\r\n/**\r\n * Custom generation options which are dependent on a specific odata service.\r\n */\r\nexport interface ServiceGenerationOptions\r\n extends Required<Pick<CliOptions, \"source\" | \"output\">>,\r\n Pick<CliOptions, \"sourceUrl\" | \"refreshFile\">,\r\n Omit<ConfigFileOptions, \"services\"> {\r\n /**\r\n * Configure generation process for individual properties based on their name.\r\n */\r\n propertiesByName?: Array<PropertyGenerationOptions>;\r\n /**\r\n * Rename any EntityType, ComplexType, EnumType, Function or Action.\r\n *\r\n * You must match the simple name (e.g. \"Person\") or the fully qualified name\r\n * (e.g. \"Trippin.Person\") exactly. Alternatively, you can rename a bunch of types\r\n * by using regular expressions.\r\n *\r\n * By providing additional type information via the \"type\" attribute you get even more options which only apply\r\n * to the given type.\r\n */\r\n byTypeAndName?: Array<ComplexTypeGenerationOptions | EntityTypeGenerationOptions | GenericTypeGenerationOptions>;\r\n}\r\n\r\n/**\r\n * Available options for the actual generation run.\r\n * Every property is required, except the overriding service name.\r\n */\r\nexport interface RunOptions\r\n extends Required<Omit<ServiceGenerationOptions, \"serviceName\" | \"sourceUrl\" | \"sourceUrlConfig\" | \"refreshFile\">>,\r\n Pick<ServiceGenerationOptions, \"serviceName\" | \"sourceUrl\" | \"sourceUrlConfig\" | \"refreshFile\"> {\r\n naming: NameSettings;\r\n}\r\n\r\nexport interface RenameOptions {\r\n /**\r\n * Matcher for the name of any EntityType, ComplexType, EnumType, Function or Action\r\n * as it is stated in the EDMX model, e.g. \"Person\". As OData supports namespaces\r\n * you can also use the fully qualified name (including the namespace) to address any model,\r\n * e.g. \"Trippin.Person\". You can also match properties by their name.\r\n *\r\n * If the name is specified as plain string, it must match either the name or the fully qualified name\r\n * exactly (case-sensitive).\r\n *\r\n * Alternatively, a regular expression can be used which is always applied to the fully qualified name\r\n * (e.g. Trippin.Person). The regular expression must match the whole string\r\n * (e.g. `/Person/` won't do, `/.*\\.Person/` would work).\r\n *\r\n * To make regular expressions useful, captured groups are also supported in combination with\r\n * the `mappedName` attribute.\r\n */\r\n name: string | RegExp;\r\n\r\n /**\r\n * If specified, this attribute value is used as final name for the matched name as it will\r\n * appear in the generated typescript.\r\n *\r\n * When using a regular expression for matching the name, then captured groups can be referenced\r\n * as usual via $1, $2, etc. For example:\r\n * - name: /Trippin\\.(.+)/\r\n * - mappedName: \"T_$1\"\r\n * The result would be \"T_Person\".\r\n */\r\n mappedName?: string;\r\n}\r\n\r\nexport type TypeBasedGenerationOptions =\r\n | GenericTypeGenerationOptions\r\n | ComplexTypeGenerationOptions\r\n | EntityTypeGenerationOptions;\r\n\r\nexport interface GenericTypeGenerationOptions extends RenameOptions {\r\n type:\r\n | TypeModel.Any\r\n | TypeModel.EnumType\r\n | TypeModel.OperationType\r\n | TypeModel.OperationImportType\r\n | TypeModel.Singleton\r\n | TypeModel.EntitySet;\r\n}\r\n\r\nexport interface ComplexTypeGenerationOptions extends RenameOptions {\r\n type: TypeModel.ComplexType;\r\n\r\n /**\r\n * Configuration of individual properties.\r\n */\r\n properties?: Array<PropertyGenerationOptions>;\r\n\r\n // converter: string | Array<string>\r\n}\r\n\r\n/**\r\n * Configuration options for EntityTypes and ComplexTypes.\r\n * This config applies if the name matches the name of an EntityType or ComplexType as it is specified\r\n * in the metadata (e.g. in EDMX <EntityType name=\"Test\" ...)\r\n */\r\nexport interface EntityTypeGenerationOptions extends Omit<ComplexTypeGenerationOptions, \"type\"> {\r\n type: TypeModel.EntityType;\r\n\r\n /**\r\n * Overwrite the key specification by naming the props by their EDMX name.\r\n */\r\n keys?: Array<string>;\r\n\r\n /**\r\n * Whether the generated service should allow for querying this model.\r\n * True by default.\r\n */\r\n // queryable?: boolean;\r\n /**\r\n * Whether the generated service should allow for creating new models (POST).\r\n * True by default.\r\n */\r\n // creatable?: boolean;\r\n /**\r\n * Whether the generated service should allow for updates (PUT).\r\n * True by default.\r\n */\r\n // updatable?: boolean;\r\n /**\r\n * Whether the generated service should allow for partial updates (PATCH).\r\n * True by default.\r\n */\r\n // patchable?: boolean;\r\n /**\r\n * Whether the generated service should allow for deletion.\r\n * True by default.\r\n */\r\n // deletable?: boolean;\r\n}\r\n\r\n/**\r\n * All configuration options for properties of models.\r\n */\r\nexport interface PropertyGenerationOptions extends RenameOptions {\r\n /**\r\n * Managed attributes - i.e. managed by the server - cannot be created or updated.\r\n * Hence, they are left out of the editable model versions.\r\n */\r\n managed?: boolean;\r\n\r\n /**\r\n * TODO\r\n *\r\n * Each converter must specify its package name, e.g. \"@odata2ts/converter-v2-to-v4\",\r\n * as well it's i\r\n * and their ids, e.g. \"timeToDurationConverter\".\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n // converters?: Array<Required<TypeConverterConfig>>;\r\n}\r\n"]}
1
+ {"version":3,"file":"OptionModel.js","sourceRoot":"","sources":["../src/OptionModel.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,CAAN,IAAY,KAKX;AALD,WAAY,KAAK;IACf,qCAAM,CAAA;IACN,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,+BAAG,CAAA;AACL,CAAC,EALW,KAAK,KAAL,KAAK,QAKhB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\r\nimport { AxiosRequestConfig } from \"axios\";\r\nimport { NameSettings, OverridableNamingOptions } from \"./NamingModel.js\";\r\nimport { TypeModel } from \"./TypeModel.js\";\r\n\r\n/**\r\n * Generation mode, by default \"all\".\r\n */\r\nexport enum Modes {\r\n models,\r\n qobjects,\r\n service,\r\n all,\r\n}\r\n\r\n/**\r\n * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.\r\n */\r\nexport enum EmitModes {\r\n ts = \"ts\",\r\n js = \"js\",\r\n dts = \"dts\",\r\n js_dts = \"js_dts\",\r\n}\r\n\r\n/**\r\n * Config options for CLI.\r\n */\r\nexport interface CliOptions {\r\n /**\r\n * The URL to the root of your OData service. The URL might end in a slash or not, it might also end\r\n * in $metadata, but we usually add this for you.\r\n *\r\n * Specifying the URL is a convenience feature to download the metadata file from the given URL.\r\n * You can configure this request via `sourceConfig` option.\r\n *\r\n * The `source` option must still be specified as it is used to store the downloaded file on your disk.\r\n * By default, the file is used once it has been downloaded.\r\n */\r\n sourceUrl?: string;\r\n /**\r\n * Downloads the metadata file and overwrites the existing one, if any.\r\n *\r\n * Only takes effect, if option `sourceUrl` is specified.\r\n */\r\n refreshFile?: boolean;\r\n /**\r\n * The source is the file to use (must be an EDMX compliant XML file) or the URL to the\r\n * metadata (ROOT_SERVICE/$metadata).\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n source?: string;\r\n /**\r\n * Specifies the output directory for the generated stuff.\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n output?: string;\r\n /**\r\n * Only generates the specified services.\r\n * Relies on an existing config file where these service names are maintained.\r\n */\r\n services?: Array<string>;\r\n /**\r\n * Specifies what to generate:\r\n * - {@code Modes.models} will only generate TS interfaces\r\n * - {@code Modes.qobjects} will generate functional units used in QueryBuilder and for functions and actions\r\n * - {@code Modes.service} will generate one main OData service client and one per each entity\r\n * - {@code Modes.all} the same as {@code Modes.service}\r\n *\r\n * QObjects will also generate models, and generating the service client will also generate models and QObjects.\r\n * Defaults to {@code Modes.all}\r\n */\r\n mode?: Modes;\r\n /**\r\n * Specifies the type of the output files: TypeScript, JS, DTS only, JS with DTS.\r\n * Defaults to {@code EmitModes.js_dts}\r\n */\r\n emitMode?: EmitModes;\r\n /**\r\n * Uses prettier with your local configuration to pretty print TypeScript files.\r\n * Only applies if mode is set to {@code EmitModes.ts}.\r\n */\r\n prettier?: boolean;\r\n /**\r\n * When compiling TypeScript to JS, \"tsconfig.json\" is used by default to add compilerOptions.\r\n * This option allows to specify an alternative file.\r\n *\r\n * Only takes effect, when mode is set to anything else than {@code EmitModes.ts}.\r\n */\r\n tsconfig?: string;\r\n /**\r\n * Verbose debugging information.\r\n */\r\n debug?: boolean;\r\n /**\r\n * Overrides the service name found in the source file.\r\n *\r\n * The service name is the basis for all file names and the name of the main OData client service\r\n * that serves as entry point for the user.\r\n */\r\n serviceName?: string;\r\n /**\r\n * odata2ts will automatically decide if a key prop is managed on the server side.\r\n * If managed, the property will not be editable (create, update, patch).\r\n * The following rule applies:\r\n * If a property is the only key prop of an entity, then the prop is deemed to be managed;\r\n * in ony other case the prop is unmanaged.\r\n */\r\n disableAutoManagedKey?: boolean;\r\n /**\r\n * By default, odata2ts doesn't change param, operation, property or model names.\r\n * The generated models and their properties are named exactly as advertised by the server.\r\n *\r\n * By allowing odata2ts to change these names, certain predefined formatting strategies are used:\r\n * Model / class names are formatted with PascalCase; property, param, and operation names with camelCase.\r\n *\r\n * The naming configuration allows to control this and other naming related settings.\r\n * Note: Even if renaming is disabled, model prefixing / suffixing still applies.\r\n */\r\n allowRenaming?: boolean;\r\n}\r\n\r\n/**\r\n * Configuration options of the request to retrieve the metadata.\r\n * Only takes effect if `source` is a URL.\r\n */\r\nexport interface UrlSourceConfiguration {\r\n /**\r\n * Basic auth credentials: the username.\r\n * Only takes effect if `password` has also been set.\r\n */\r\n username?: string;\r\n /**\r\n * Basic auth credentials: the password.\r\n * Only takes effect if `username` has also been set.\r\n */\r\n password?: string;\r\n /**\r\n * Custom request configuration.\r\n * URL and method `GET` are set by default, but can be overwritten.\r\n */\r\n custom?: AxiosRequestConfig;\r\n}\r\n\r\n/**\r\n * Available options for configuration files, i.e. odata2ts.config.ts.\r\n */\r\nexport interface ConfigFileOptions extends Omit<CliOptions, \"sourceUrl\" | \"source\" | \"output\" | \"services\"> {\r\n /**\r\n * Configuration options of the request to retrieve the metadata.\r\n * Only takes effect if `sourceUrl` is a URL.\r\n */\r\n sourceUrlConfig?: UrlSourceConfiguration;\r\n\r\n /**\r\n * Configuration of each service.\r\n *\r\n * @example { services: { trippin: { source: \"...\", ... } }}\r\n */\r\n services?: { [serviceName: string]: ServiceGenerationOptions };\r\n\r\n /**\r\n * Specify which converters to use by their package name, e.g. \"@odata2ts/converter-v2-to-v4\".\r\n * Each converter knows which data type to map.\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n converters?: Array<string | TypeConverterConfig>;\r\n\r\n /**\r\n * For each model an editable version is generated which represents the model definition for\r\n * create, update and patch actions.\r\n *\r\n * You can skip the generation altogether, not generating editable model variants,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipEditableModels?: boolean;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n * The generation for one entity entails one model interface representing the id parameters and\r\n * one QId function which allows to format the parameters for URL usage and to parse parameters\r\n * from a URL string.\r\n *\r\n * You can skip the generation altogether, not generating models and QId objects, if the\r\n * generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipIdModels?: boolean;\r\n /**\r\n * Operations are functions and actions of the OData service.\r\n * The generation for one operation entails one parameter model interface\r\n * and one QFunction / QAction class.\r\n *\r\n * You can skip the generation altogether, neither generating model nor query object,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipOperations?: boolean;\r\n /**\r\n * Model properties have explaining comments by default.\r\n * With this option you can turn that off.\r\n */\r\n skipComments?: boolean;\r\n /**\r\n * With OData you can read, update and delete data on a primitive property (`Edm.*`).\r\n * Usually, you wouldn't do that, but go for a bigger request, fetching more relevant information in one go.\r\n *\r\n * There's one exception: Handling `Edm.Stream´ properties and Media entities. Services for stream / media\r\n * stuff are generated regardless of this setting.\r\n */\r\n enablePrimitivePropertyServices?: boolean;\r\n\r\n /**\r\n * The naming options regarding the generated artefacts.\r\n */\r\n naming?: OverridableNamingOptions;\r\n\r\n /**\r\n * Some OData V2 services generate an extra wrapping for entity collection attributes:\r\n * <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities\r\n * an object with the property \"results\" is wrapped around the entity collection.\r\n *\r\n * If you're using the odata client then there's a build-in workaround in place which transforms\r\n * the results to remove this extra mapping. However, if you're only interested in the types, then\r\n * the generated models will not match that extra wrapping.\r\n *\r\n * Setting this configuration option to <code>true</code> (default: false) will add this extra\r\n * wrapping to the generated models. But this option is only valid if the generation mode is set\r\n * to <code>models</code>; it is ignored otherwise.\r\n */\r\n v2ModelsWithExtraResultsWrapping?: boolean;\r\n /**\r\n * Numbers of type `Edm.Int64` and `Edm.Decimal` are represented as `number` in V4.\r\n * However, these numbers might not fit into JS' number type, which might result in precision loss.\r\n *\r\n * OData offers a special IEEE754 format option to get those types as `string` instead to prevent any\r\n * precision loss. So if you're handling very large or very small numbers (JS roughly supports 15 digits),\r\n * then you should use this option and, probably, also an appropriate converter (see available converters).\r\n *\r\n * Activating this option affects the type generation and will use `string` for both mentioned types.\r\n * All requests are executed with the \"accept\" header set to \"application/json;IEEE754Compatible=true\".\r\n * Additionally, when sending data the very same value will be set for the \"content-type\" header.\r\n */\r\n v4BigNumberAsString?: boolean;\r\n /**\r\n * OData allows for namespaces so any entity is unique by virtue of it's name within a namespace.\r\n * odata2ts works with these fully qualified names internally, but only uses the plain name when generating\r\n * stuff. This might lead to name clashes (same name in different namespaces).\r\n *\r\n * odata2ts employs a simple, automatic resolution strategy: Adding a counter at the end of the name.\r\n * Set this property to true in order to disable this automatism.\r\n */\r\n disableAutomaticNameClashResolution?: boolean;\r\n /**\r\n * By default, odata2ts generates a folder structure with individual files per entity.\r\n * This allows for handling and scaling the generation process for large data structures.\r\n *\r\n * However, especially UI5 has problems with recursive structures, which are absolutely valid within\r\n * OData. Here the solution is to generate only one file per type to circumvent cyclic imports.\r\n * To enable this behaviour set this option to true.\r\n */\r\n bundledFileGeneration?: boolean;\r\n}\r\n\r\n/**\r\n * Custom generation options which are dependent on a specific odata service.\r\n */\r\nexport interface ServiceGenerationOptions\r\n extends Required<Pick<CliOptions, \"source\" | \"output\">>,\r\n Pick<CliOptions, \"sourceUrl\" | \"refreshFile\">,\r\n Omit<ConfigFileOptions, \"services\"> {\r\n /**\r\n * Configure generation process for individual properties based on their name.\r\n */\r\n propertiesByName?: Array<PropertyGenerationOptions>;\r\n /**\r\n * Rename any EntityType, ComplexType, EnumType, Function or Action.\r\n *\r\n * You must match the simple name (e.g. \"Person\") or the fully qualified name\r\n * (e.g. \"Trippin.Person\") exactly. Alternatively, you can rename a bunch of types\r\n * by using regular expressions.\r\n *\r\n * By providing additional type information via the \"type\" attribute you get even more options which only apply\r\n * to the given type.\r\n */\r\n byTypeAndName?: Array<ComplexTypeGenerationOptions | EntityTypeGenerationOptions | GenericTypeGenerationOptions>;\r\n}\r\n\r\n/**\r\n * Available options for the actual generation run.\r\n * Every property is required, except the overriding service name.\r\n */\r\nexport interface RunOptions\r\n extends Required<Omit<ServiceGenerationOptions, \"serviceName\" | \"sourceUrl\" | \"sourceUrlConfig\" | \"refreshFile\">>,\r\n Pick<ServiceGenerationOptions, \"serviceName\" | \"sourceUrl\" | \"sourceUrlConfig\" | \"refreshFile\"> {\r\n naming: NameSettings;\r\n}\r\n\r\nexport interface RenameOptions {\r\n /**\r\n * Matcher for the name of any EntityType, ComplexType, EnumType, Function or Action\r\n * as it is stated in the EDMX model, e.g. \"Person\". As OData supports namespaces\r\n * you can also use the fully qualified name (including the namespace) to address any model,\r\n * e.g. \"Trippin.Person\". You can also match properties by their name.\r\n *\r\n * If the name is specified as plain string, it must match either the name or the fully qualified name\r\n * exactly (case-sensitive).\r\n *\r\n * Alternatively, a regular expression can be used which is always applied to the fully qualified name\r\n * (e.g. Trippin.Person). The regular expression must match the whole string\r\n * (e.g. `/Person/` won't do, `/.*\\.Person/` would work).\r\n *\r\n * To make regular expressions useful, captured groups are also supported in combination with\r\n * the `mappedName` attribute.\r\n */\r\n name: string | RegExp;\r\n\r\n /**\r\n * If specified, this attribute value is used as final name for the matched name as it will\r\n * appear in the generated typescript.\r\n *\r\n * When using a regular expression for matching the name, then captured groups can be referenced\r\n * as usual via $1, $2, etc. For example:\r\n * - name: /Trippin\\.(.+)/\r\n * - mappedName: \"T_$1\"\r\n * The result would be \"T_Person\".\r\n */\r\n mappedName?: string;\r\n}\r\n\r\nexport type TypeBasedGenerationOptions =\r\n | GenericTypeGenerationOptions\r\n | ComplexTypeGenerationOptions\r\n | EntityTypeGenerationOptions;\r\n\r\nexport interface GenericTypeGenerationOptions extends RenameOptions {\r\n type:\r\n | TypeModel.Any\r\n | TypeModel.EnumType\r\n | TypeModel.OperationType\r\n | TypeModel.OperationImportType\r\n | TypeModel.Singleton\r\n | TypeModel.EntitySet;\r\n}\r\n\r\nexport interface ComplexTypeGenerationOptions extends RenameOptions {\r\n type: TypeModel.ComplexType;\r\n\r\n /**\r\n * Configuration of individual properties.\r\n */\r\n properties?: Array<PropertyGenerationOptions>;\r\n\r\n // converter: string | Array<string>\r\n}\r\n\r\n/**\r\n * Configuration options for EntityTypes and ComplexTypes.\r\n * This config applies if the name matches the name of an EntityType or ComplexType as it is specified\r\n * in the metadata (e.g. in EDMX <EntityType name=\"Test\" ...)\r\n */\r\nexport interface EntityTypeGenerationOptions extends Omit<ComplexTypeGenerationOptions, \"type\"> {\r\n type: TypeModel.EntityType;\r\n\r\n /**\r\n * Overwrite the key specification by naming the props by their EDMX name.\r\n */\r\n keys?: Array<string>;\r\n\r\n /**\r\n * Whether the generated service should allow for querying this model.\r\n * True by default.\r\n */\r\n // queryable?: boolean;\r\n /**\r\n * Whether the generated service should allow for creating new models (POST).\r\n * True by default.\r\n */\r\n // creatable?: boolean;\r\n /**\r\n * Whether the generated service should allow for updates (PUT).\r\n * True by default.\r\n */\r\n // updatable?: boolean;\r\n /**\r\n * Whether the generated service should allow for partial updates (PATCH).\r\n * True by default.\r\n */\r\n // patchable?: boolean;\r\n /**\r\n * Whether the generated service should allow for deletion.\r\n * True by default.\r\n */\r\n // deletable?: boolean;\r\n}\r\n\r\n/**\r\n * All configuration options for properties of models.\r\n */\r\nexport interface PropertyGenerationOptions extends RenameOptions {\r\n /**\r\n * Managed attributes - i.e. managed by the server - cannot be created or updated.\r\n * Hence, they are left out of the editable model versions.\r\n */\r\n managed?: boolean;\r\n\r\n /**\r\n * TODO\r\n *\r\n * Each converter must specify its package name, e.g. \"@odata2ts/converter-v2-to-v4\",\r\n * as well it's i\r\n * and their ids, e.g. \"timeToDurationConverter\".\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n // converters?: Array<Required<TypeConverterConfig>>;\r\n}\r\n"]}
package/lib/TypeModel.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeModel = void 0;
4
- var TypeModel;
1
+ export var TypeModel;
5
2
  (function (TypeModel) {
6
3
  TypeModel["Any"] = "Any";
7
4
  TypeModel["EntitySet"] = "EntitySet";
@@ -13,5 +10,5 @@ var TypeModel;
13
10
  TypeModel["OperationType"] = "OperationType";
14
11
  // Bundles ActionImport and FunctionImport elements
15
12
  TypeModel["OperationImportType"] = "OperationImportType";
16
- })(TypeModel || (exports.TypeModel = TypeModel = {}));
13
+ })(TypeModel || (TypeModel = {}));
17
14
  //# sourceMappingURL=TypeModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TypeModel.js","sourceRoot":"","sources":["../src/TypeModel.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,oCAAuB,CAAA;IACvB,oCAAuB,CAAA;IACvB,sCAAyB,CAAA;IACzB,wCAA2B,CAAA;IAC3B,kCAAqB,CAAA;IACrB,yDAAyD;IACzD,4CAA+B,CAAA;IAC/B,mDAAmD;IACnD,wDAA2C,CAAA;AAC7C,CAAC,EAXW,SAAS,yBAAT,SAAS,QAWpB","sourcesContent":["export enum TypeModel {\r\n Any = \"Any\",\r\n EntitySet = \"EntitySet\",\r\n Singleton = \"Singleton\",\r\n EntityType = \"EntityType\",\r\n ComplexType = \"ComplexType\",\r\n EnumType = \"EnumType\",\r\n // Bundle Function and Action (bound or unbound; v4 only)\r\n OperationType = \"OperationType\",\r\n // Bundles ActionImport and FunctionImport elements\r\n OperationImportType = \"OperationImportType\",\r\n}\r\n"]}
1
+ {"version":3,"file":"TypeModel.js","sourceRoot":"","sources":["../src/TypeModel.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,oCAAuB,CAAA;IACvB,oCAAuB,CAAA;IACvB,sCAAyB,CAAA;IACzB,wCAA2B,CAAA;IAC3B,kCAAqB,CAAA;IACrB,yDAAyD;IACzD,4CAA+B,CAAA;IAC/B,mDAAmD;IACnD,wDAA2C,CAAA;AAC7C,CAAC,EAXW,SAAS,KAAT,SAAS,QAWpB","sourcesContent":["export enum TypeModel {\r\n Any = \"Any\",\r\n EntitySet = \"EntitySet\",\r\n Singleton = \"Singleton\",\r\n EntityType = \"EntityType\",\r\n ComplexType = \"ComplexType\",\r\n EnumType = \"EnumType\",\r\n // Bundle Function and Action (bound or unbound; v4 only)\r\n OperationType = \"OperationType\",\r\n // Bundles ActionImport and FunctionImport elements\r\n OperationImportType = \"OperationImportType\",\r\n}\r\n"]}
package/lib/app.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ODataEdmxModelBase } from "./data-model/edmx/ODataEdmxModelBase";
2
- import { RunOptions } from "./OptionModel";
1
+ import { ODataEdmxModelBase } from "./data-model/edmx/ODataEdmxModelBase.js";
2
+ import { RunOptions } from "./OptionModel.js";
3
3
  /**
4
4
  *
5
5
  * @param metadataJson metadata of a given OData service already parsed as JSON
package/lib/app.js CHANGED
@@ -1,20 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runApp = void 0;
4
- const tslib_1 = require("tslib");
5
- const odata_core_1 = require("@odata2ts/odata-core");
6
- const pascal_case_1 = require("pascal-case");
7
- const DataModelDigestionV2_1 = require("./data-model/DataModelDigestionV2");
8
- const DataModelDigestionV4_1 = require("./data-model/DataModelDigestionV4");
9
- const NamingHelper_1 = require("./data-model/NamingHelper");
10
- const generator_1 = require("./generator");
11
- const OptionModel_1 = require("./OptionModel");
12
- const ProjectManager_1 = require("./project/ProjectManager");
1
+ import { __awaiter } from "tslib";
2
+ import { ODataVersions } from "@odata2ts/odata-core";
3
+ import { pascalCase } from "change-case";
4
+ import { digest as digestV2 } from "./data-model/DataModelDigestionV2.js";
5
+ import { digest as digestV4 } from "./data-model/DataModelDigestionV4.js";
6
+ import { NamingHelper } from "./data-model/NamingHelper.js";
7
+ import { generateModels, generateQueryObjects, generateServices } from "./generator/index.js";
8
+ import { Modes } from "./OptionModel.js";
9
+ import { createProjectManager } from "./project/ProjectManager.js";
13
10
  function isQObjectGen(mode) {
14
- return [OptionModel_1.Modes.qobjects, OptionModel_1.Modes.service, OptionModel_1.Modes.all].includes(mode);
11
+ return [Modes.qobjects, Modes.service, Modes.all].includes(mode);
15
12
  }
16
13
  function isServiceGen(mode) {
17
- return [OptionModel_1.Modes.service, OptionModel_1.Modes.all].includes(mode);
14
+ return [Modes.service, Modes.all].includes(mode);
18
15
  }
19
16
  function getServiceName(options, schemas) {
20
17
  if (options.serviceName) {
@@ -24,29 +21,29 @@ function getServiceName(options, schemas) {
24
21
  // NOTE: we make use of PascalCase here to enforce valid class names
25
22
  const detectedSchema = schemas.find((schema) => { var _a; return schema.$.Namespace && ((_a = schema.EntityType) === null || _a === void 0 ? void 0 : _a.length); }) || schemas[0];
26
23
  const serviceName = detectedSchema.$.Namespace;
27
- return (0, pascal_case_1.pascalCase)(serviceName);
24
+ return pascalCase(serviceName);
28
25
  }
29
26
  /**
30
27
  *
31
28
  * @param metadataJson metadata of a given OData service already parsed as JSON
32
29
  * @param options further options
33
30
  */
34
- function runApp(metadataJson, options) {
35
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
31
+ export function runApp(metadataJson, options) {
32
+ return __awaiter(this, void 0, void 0, function* () {
36
33
  // determine edmx edmxVersion attribute
37
34
  const edmxVersion = metadataJson["edmx:Edmx"].$.Version;
38
- const version = edmxVersion === "1.0" ? odata_core_1.ODataVersions.V2 : odata_core_1.ODataVersions.V4;
35
+ const version = edmxVersion === "1.0" ? ODataVersions.V2 : ODataVersions.V4;
39
36
  const dataService = metadataJson["edmx:Edmx"]["edmx:DataServices"][0];
40
37
  const schemas = dataService.Schema;
41
38
  const serviceName = getServiceName(options, schemas);
42
39
  const namespaces = schemas.map((schema) => [schema.$.Namespace, schema.$.Alias]);
43
40
  // encapsulate the whole naming logic
44
- const namingHelper = new NamingHelper_1.NamingHelper(options, serviceName, namespaces);
41
+ const namingHelper = new NamingHelper(options, serviceName, namespaces);
45
42
  // parse model information from edmx into something we can really work with
46
43
  // => that stuff is called dataModel!
47
- const dataModel = version === odata_core_1.ODataVersions.V2
48
- ? yield (0, DataModelDigestionV2_1.digest)(dataService.Schema, options, namingHelper)
49
- : yield (0, DataModelDigestionV4_1.digest)(dataService.Schema, options, namingHelper);
44
+ const dataModel = version === ODataVersions.V2
45
+ ? yield digestV2(dataService.Schema, options, namingHelper)
46
+ : yield digestV4(dataService.Schema, options, namingHelper);
50
47
  // Validation of entity names: the same name might be used across different namespaces
51
48
  const validationErrors = dataModel.getNameValidation();
52
49
  if (validationErrors.size) {
@@ -61,7 +58,7 @@ function runApp(metadataJson, options) {
61
58
  }
62
59
  }
63
60
  // handling the overall generation project
64
- const project = yield (0, ProjectManager_1.createProjectManager)(options.output, options.emitMode, namingHelper, dataModel, {
61
+ const project = yield createProjectManager(options.output, options.emitMode, namingHelper, dataModel, {
65
62
  usePrettier: options.prettier,
66
63
  tsConfigPath: options.tsconfig,
67
64
  bundledFileGeneration: options.bundledFileGeneration,
@@ -71,25 +68,24 @@ function runApp(metadataJson, options) {
71
68
  // Generate Model Interfaces
72
69
  // generateModels(project, dataModel, version, options, namingHelper),
73
70
  // ];
74
- yield (0, generator_1.generateModels)(project, dataModel, version, options, namingHelper);
71
+ yield generateModels(project, dataModel, version, options, namingHelper);
75
72
  console.log("Successfully generated models!");
76
73
  // Generate Query Objects
77
74
  // supported edmx types: EntityType, ComplexType
78
75
  // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object
79
76
  if (isQObjectGen(options.mode)) {
80
77
  // promises.push(generateQueryObjects(project, dataModel, version, options, namingHelper));
81
- yield (0, generator_1.generateQueryObjects)(project, dataModel, version, options, namingHelper);
78
+ yield generateQueryObjects(project, dataModel, version, options, namingHelper);
82
79
  console.log("Successfully generated q-objects!");
83
80
  }
84
81
  // Generate Individual OData-Service
85
82
  if (isServiceGen(options.mode)) {
86
83
  // promises.push(generateServices(project, dataModel, version, namingHelper, options));
87
- yield (0, generator_1.generateServices)(project, dataModel, version, namingHelper, options);
84
+ yield generateServices(project, dataModel, version, namingHelper, options);
88
85
  console.log("Successfully generated services!");
89
86
  }
90
87
  // await Promise.all(promises);
91
88
  console.log("Successfully finished!");
92
89
  });
93
90
  }
94
- exports.runApp = runApp;
95
91
  //# sourceMappingURL=app.js.map
package/lib/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,6CAAy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xC,CAAC;CAAA;AAvED,wBAuEC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { pascalCase } from \"pascal-case\";\r\n\r\nimport { NamespaceWithAlias } from \"./data-model/DataModel\";\r\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2\";\r\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\r\nimport { ODataEdmxModelBase } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { SchemaV3 } from \"./data-model/edmx/ODataEdmxModelV3\";\r\nimport { SchemaV4 } from \"./data-model/edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper\";\r\nimport { generateModels, generateQueryObjects, generateServices } from \"./generator\";\r\nimport { Modes, RunOptions } from \"./OptionModel\";\r\nimport { createProjectManager } from \"./project/ProjectManager\";\r\n\r\nfunction isQObjectGen(mode: Modes) {\r\n return [Modes.qobjects, Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\nfunction isServiceGen(mode: Modes) {\r\n return [Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\nfunction getServiceName(options: RunOptions, schemas: Array<SchemaV3 | SchemaV4>) {\r\n if (options.serviceName) {\r\n return options.serviceName;\r\n }\r\n\r\n // auto-detection of first namespace with defined EntityTypes\r\n // NOTE: we make use of PascalCase here to enforce valid class names\r\n const detectedSchema = schemas.find((schema) => schema.$.Namespace && schema.EntityType?.length) || schemas[0];\r\n const serviceName = detectedSchema.$.Namespace;\r\n return pascalCase(serviceName);\r\n}\r\n\r\n/**\r\n *\r\n * @param metadataJson metadata of a given OData service already parsed as JSON\r\n * @param options further options\r\n */\r\nexport async function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void> {\r\n // determine edmx edmxVersion attribute\r\n const edmxVersion = metadataJson[\"edmx:Edmx\"].$.Version;\r\n const version = edmxVersion === \"1.0\" ? ODataVersions.V2 : ODataVersions.V4;\r\n\r\n const dataService = metadataJson[\"edmx:Edmx\"][\"edmx:DataServices\"][0];\r\n const schemas = dataService.Schema as Array<SchemaV3 | SchemaV4>;\r\n\r\n const serviceName = getServiceName(options, schemas);\r\n\r\n const namespaces = schemas.map<NamespaceWithAlias>((schema) => [schema.$.Namespace, schema.$.Alias]);\r\n\r\n // encapsulate the whole naming logic\r\n const namingHelper = new NamingHelper(options, serviceName, namespaces);\r\n // parse model information from edmx into something we can really work with\r\n // => that stuff is called dataModel!\r\n const dataModel =\r\n version === ODataVersions.V2\r\n ? await digestV2(dataService.Schema as Array<SchemaV3>, options, namingHelper)\r\n : await digestV4(dataService.Schema as Array<SchemaV4>, options, namingHelper);\r\n\r\n // Validation of entity names: the same name might be used across different namespaces\r\n const validationErrors = dataModel.getNameValidation();\r\n if (validationErrors.size) {\r\n console.log(\"---\");\r\n validationErrors.forEach((errors, name) => {\r\n console.log(\r\n `Duplicate name: ${name} - Fully Qualified Names: ${errors\r\n .map((error) => error.fqName + (error.renamedTo ? ` (renamed to: ${error.renamedTo})` : \"\"))\r\n .join(\", \")}`\r\n );\r\n });\r\n\r\n if (options.disableAutomaticNameClashResolution) {\r\n throw new Error(\"Name validation failed: Multiple entities have the same name across different namespaces!\");\r\n }\r\n }\r\n\r\n // handling the overall generation project\r\n const project = await createProjectManager(options.output, options.emitMode, namingHelper, dataModel, {\r\n usePrettier: options.prettier,\r\n tsConfigPath: options.tsconfig,\r\n bundledFileGeneration: options.bundledFileGeneration,\r\n allowTypeChecking: options.debug,\r\n });\r\n\r\n // const promises: Array<Promise<void>> = [\r\n // Generate Model Interfaces\r\n // generateModels(project, dataModel, version, options, namingHelper),\r\n // ];\r\n await generateModels(project, dataModel, version, options, namingHelper);\r\n console.log(\"Successfully generated models!\");\r\n\r\n // Generate Query Objects\r\n // supported edmx types: EntityType, ComplexType\r\n // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object\r\n if (isQObjectGen(options.mode)) {\r\n // promises.push(generateQueryObjects(project, dataModel, version, options, namingHelper));\r\n await generateQueryObjects(project, dataModel, version, options, namingHelper);\r\n console.log(\"Successfully generated q-objects!\");\r\n }\r\n\r\n // Generate Individual OData-Service\r\n if (isServiceGen(options.mode)) {\r\n // promises.push(generateServices(project, dataModel, version, namingHelper, options));\r\n await generateServices(project, dataModel, version, namingHelper, options);\r\n console.log(\"Successfully generated services!\");\r\n }\r\n\r\n // await Promise.all(promises);\r\n console.log(\"Successfully finished!\");\r\n}\r\n"]}
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAI1E,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,KAAK,EAAc,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,cAAc,CAAC,OAAmB,EAAE,OAAmC;IAC9E,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,OAAO,OAAO,CAAC,WAAW,CA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,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QACzE,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAE9C,yBAAyB;QACzB,gDAAgD;QAChD,mJAAmJ;QACnJ,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,2FAA2F;YAC3F,MAAM,oBAAoB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;YAC/E,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;SAClD;QAED,oCAAoC;QACpC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,uFAAuF;YACvF,MAAM,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;YAC3E,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;SACjD;QAED,+BAA+B;QAC/B,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACxC,CAAC;CAAA","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { pascalCase } from \"change-case\";\r\nimport { NamespaceWithAlias } from \"./data-model/DataModel.js\";\r\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2.js\";\r\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4.js\";\r\nimport { ODataEdmxModelBase } from \"./data-model/edmx/ODataEdmxModelBase.js\";\r\nimport { SchemaV3 } from \"./data-model/edmx/ODataEdmxModelV3.js\";\r\nimport { SchemaV4 } from \"./data-model/edmx/ODataEdmxModelV4.js\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper.js\";\r\nimport { generateModels, generateQueryObjects, generateServices } from \"./generator/index.js\";\r\nimport { Modes, RunOptions } from \"./OptionModel.js\";\r\nimport { createProjectManager } from \"./project/ProjectManager.js\";\r\n\r\nfunction isQObjectGen(mode: Modes) {\r\n return [Modes.qobjects, Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\nfunction isServiceGen(mode: Modes) {\r\n return [Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\nfunction getServiceName(options: RunOptions, schemas: Array<SchemaV3 | SchemaV4>) {\r\n if (options.serviceName) {\r\n return options.serviceName;\r\n }\r\n\r\n // auto-detection of first namespace with defined EntityTypes\r\n // NOTE: we make use of PascalCase here to enforce valid class names\r\n const detectedSchema = schemas.find((schema) => schema.$.Namespace && schema.EntityType?.length) || schemas[0];\r\n const serviceName = detectedSchema.$.Namespace;\r\n return pascalCase(serviceName);\r\n}\r\n\r\n/**\r\n *\r\n * @param metadataJson metadata of a given OData service already parsed as JSON\r\n * @param options further options\r\n */\r\nexport async function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void> {\r\n // determine edmx edmxVersion attribute\r\n const edmxVersion = metadataJson[\"edmx:Edmx\"].$.Version;\r\n const version = edmxVersion === \"1.0\" ? ODataVersions.V2 : ODataVersions.V4;\r\n\r\n const dataService = metadataJson[\"edmx:Edmx\"][\"edmx:DataServices\"][0];\r\n const schemas = dataService.Schema as Array<SchemaV3 | SchemaV4>;\r\n\r\n const serviceName = getServiceName(options, schemas);\r\n\r\n const namespaces = schemas.map<NamespaceWithAlias>((schema) => [schema.$.Namespace, schema.$.Alias]);\r\n\r\n // encapsulate the whole naming logic\r\n const namingHelper = new NamingHelper(options, serviceName, namespaces);\r\n // parse model information from edmx into something we can really work with\r\n // => that stuff is called dataModel!\r\n const dataModel =\r\n version === ODataVersions.V2\r\n ? await digestV2(dataService.Schema as Array<SchemaV3>, options, namingHelper)\r\n : await digestV4(dataService.Schema as Array<SchemaV4>, options, namingHelper);\r\n\r\n // Validation of entity names: the same name might be used across different namespaces\r\n const validationErrors = dataModel.getNameValidation();\r\n if (validationErrors.size) {\r\n console.log(\"---\");\r\n validationErrors.forEach((errors, name) => {\r\n console.log(\r\n `Duplicate name: ${name} - Fully Qualified Names: ${errors\r\n .map((error) => error.fqName + (error.renamedTo ? ` (renamed to: ${error.renamedTo})` : \"\"))\r\n .join(\", \")}`,\r\n );\r\n });\r\n\r\n if (options.disableAutomaticNameClashResolution) {\r\n throw new Error(\"Name validation failed: Multiple entities have the same name across different namespaces!\");\r\n }\r\n }\r\n\r\n // handling the overall generation project\r\n const project = await createProjectManager(options.output, options.emitMode, namingHelper, dataModel, {\r\n usePrettier: options.prettier,\r\n tsConfigPath: options.tsconfig,\r\n bundledFileGeneration: options.bundledFileGeneration,\r\n allowTypeChecking: options.debug,\r\n });\r\n\r\n // const promises: Array<Promise<void>> = [\r\n // Generate Model Interfaces\r\n // generateModels(project, dataModel, version, options, namingHelper),\r\n // ];\r\n await generateModels(project, dataModel, version, options, namingHelper);\r\n console.log(\"Successfully generated models!\");\r\n\r\n // Generate Query Objects\r\n // supported edmx types: EntityType, ComplexType\r\n // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object\r\n if (isQObjectGen(options.mode)) {\r\n // promises.push(generateQueryObjects(project, dataModel, version, options, namingHelper));\r\n await generateQueryObjects(project, dataModel, version, options, namingHelper);\r\n console.log(\"Successfully generated q-objects!\");\r\n }\r\n\r\n // Generate Individual OData-Service\r\n if (isServiceGen(options.mode)) {\r\n // promises.push(generateServices(project, dataModel, version, namingHelper, options));\r\n await generateServices(project, dataModel, version, namingHelper, options);\r\n console.log(\"Successfully generated services!\");\r\n }\r\n\r\n // await Promise.all(promises);\r\n console.log(\"Successfully finished!\");\r\n}\r\n"]}
@@ -0,0 +1 @@
1
+ export declare function run(): Promise<void>;
package/lib/cli/cli.js ADDED
@@ -0,0 +1,27 @@
1
+ import { __awaiter } from "tslib";
2
+ import { evaluateConfigOptions } from "../evaluateConfig.js";
3
+ import { processCliArgs } from "./processCliArgs.js";
4
+ import { processConfigFile } from "./processConfigFile.js";
5
+ import { startServiceGenerationRun } from "./serviceGenerationRun.js";
6
+ export function run() {
7
+ return __awaiter(this, void 0, void 0, function* () {
8
+ let runs;
9
+ const argv = process.argv;
10
+ try {
11
+ const cliOpts = processCliArgs(argv);
12
+ if (cliOpts.debug) {
13
+ console.log("CLI opts:", cliOpts);
14
+ }
15
+ const fileOpts = yield processConfigFile();
16
+ runs = evaluateConfigOptions(cliOpts, fileOpts);
17
+ }
18
+ catch (error) {
19
+ console.error("Bad arguments!", error === null || error === void 0 ? void 0 : error.message);
20
+ process.exit(1);
21
+ }
22
+ for (let run of runs) {
23
+ yield startServiceGenerationRun(run);
24
+ }
25
+ });
26
+ }
27
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,MAAM,UAAgB,GAAG;;QACvB,IAAI,IAAI,CAAC;QACT,MAAM,IAAI,GAAkB,OAAO,CAAC,IAAI,CAAC;QACzC,IAAI;YACF,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;YACrC,IAAI,OAAO,CAAC,KAAK,EAAE;gBACjB,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;aACnC;YACD,MAAM,QAAQ,GAAG,MAAM,iBAAiB,EAAE,CAAC;YAE3C,IAAI,GAAG,qBAAqB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;SACjD;QAAC,OAAO,KAAU,EAAE;YACnB,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAC,CAAC;YAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;QAED,KAAK,IAAI,GAAG,IAAI,IAAI,EAAE;YACpB,MAAM,yBAAyB,CAAC,GAAG,CAAC,CAAC;SACtC;IACH,CAAC;CAAA","sourcesContent":["import { evaluateConfigOptions } from \"../evaluateConfig.js\";\r\nimport { processCliArgs } from \"./processCliArgs.js\";\r\nimport { processConfigFile } from \"./processConfigFile.js\";\r\nimport { startServiceGenerationRun } from \"./serviceGenerationRun.js\";\r\n\r\nexport async function run(): Promise<void> {\r\n let runs;\r\n const argv: Array<string> = process.argv;\r\n try {\r\n const cliOpts = processCliArgs(argv);\r\n if (cliOpts.debug) {\r\n console.log(\"CLI opts:\", cliOpts);\r\n }\r\n const fileOpts = await processConfigFile();\r\n\r\n runs = evaluateConfigOptions(cliOpts, fileOpts);\r\n } catch (error: any) {\r\n console.error(\"Bad arguments!\", error?.message);\r\n process.exit(1);\r\n }\r\n\r\n for (let run of runs) {\r\n await startServiceGenerationRun(run);\r\n }\r\n}\r\n"]}
@@ -0,0 +1,4 @@
1
+ export { run } from "./cli.js";
2
+ export * from "./processCliArgs.js";
3
+ export * from "./processConfigFile.js";
4
+ export * from "./serviceGenerationRun.js";
@@ -0,0 +1,5 @@
1
+ export { run } from "./cli.js";
2
+ export * from "./processCliArgs.js";
3
+ export * from "./processConfigFile.js";
4
+ export * from "./serviceGenerationRun.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC","sourcesContent":["export { run } from \"./cli.js\";\r\nexport * from \"./processCliArgs.js\";\r\nexport * from \"./processConfigFile.js\";\r\nexport * from \"./serviceGenerationRun.js\";\r\n"]}
@@ -0,0 +1,2 @@
1
+ import { CliOptions } from "../OptionModel.js";
2
+ export declare function processCliArgs(argv: Array<string>): CliOptions;
@@ -0,0 +1,57 @@
1
+ import { Command, Option } from "commander";
2
+ import { EmitModes, Modes } from "../OptionModel.js";
3
+ function parseMode(value, dummyPrevious) {
4
+ switch (value) {
5
+ case "models":
6
+ return Modes.models;
7
+ case "qobjects":
8
+ return Modes.qobjects;
9
+ case "service":
10
+ return Modes.service;
11
+ case "all":
12
+ return Modes.all;
13
+ default:
14
+ throw new Error(`Not a valid Mode: ${value}`);
15
+ }
16
+ }
17
+ function parseEmitMode(value, dummyPrevious) {
18
+ switch (value) {
19
+ case "dts":
20
+ return EmitModes.dts;
21
+ case "js":
22
+ return EmitModes.js;
23
+ case "ts":
24
+ return EmitModes.ts;
25
+ case "js_dts":
26
+ return EmitModes.js_dts;
27
+ default:
28
+ throw new Error(`Not a valid EmitMode: ${value}`);
29
+ }
30
+ }
31
+ export function processCliArgs(argv) {
32
+ var _a;
33
+ const cli = new Command()
34
+ .version("0.3.0")
35
+ .description("CLI to generate Typescript Interfaces for models of a given OData service.")
36
+ .argument("[services...]", "Run the generation process only for certain services specified in config file", [])
37
+ .option("-s, --source <url or metadata.xml>", "Path to metadata file")
38
+ .option("-o, --output <path>", "Output location for generated files")
39
+ .option("-u, --source-url <sourceUrl>", "URL to the root of the OData service")
40
+ .option("-f, --refresh-file", "Download metadata again and overwrite existing file (only applies if sourceUrl is specified)")
41
+ .addOption(new Option("-m, --mode <mode>", "What kind of stuff gets generated")
42
+ .choices(Object.values(Modes).filter((t) => isNaN(Number(t))))
43
+ .argParser(parseMode))
44
+ .addOption(new Option("-e, --emit-mode <mode>", "Output TS source files, compiled JS files with/wihthout generated d.ts files")
45
+ .choices(Object.values(EmitModes))
46
+ .argParser(parseEmitMode))
47
+ .option("-p, --prettier", "Format result with prettier (only applies if emitMode=ts)")
48
+ .option("-t, --tsconfig <path>", "Specify alternative to 'tsconfig.json' to use specific compilerOptions (applies if emitMode is not ts)")
49
+ .option("-d, --debug", "Verbose debug infos")
50
+ .option("-name, --service-name <serviceName>", "Give the service your own name")
51
+ .option("-n, --disable-auto-managed-key", "Don't mark single key props as managed by the server side (not editable)")
52
+ .option("-r, --allow-renaming", "Allow that property and entity names may be changed by configured casing")
53
+ .parse(argv);
54
+ const args = ((_a = cli.args) === null || _a === void 0 ? void 0 : _a.length) ? { services: cli.args } : {};
55
+ return Object.assign(Object.assign({}, cli.opts()), args);
56
+ }
57
+ //# sourceMappingURL=processCliArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processCliArgs.js","sourceRoot":"","sources":["../../src/cli/processCliArgs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAc,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEjE,SAAS,SAAS,CAAC,KAAa,EAAE,aAAgC;IAChE,QAAQ,KAAK,EAAE;QACb,KAAK,QAAQ;YACX,OAAO,KAAK,CAAC,MAAM,CAAC;QACtB,KAAK,UAAU;YACb,OAAO,KAAK,CAAC,QAAQ,CAAC;QACxB,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC,OAAO,CAAC;QACvB,KAAK,KAAK;YACR,OAAO,KAAK,CAAC,GAAG,CAAC;QACnB;YACE,MAAM,IAAI,KAAK,CAAC,qBAAqB,KAAK,EAAE,CAAC,CAAC;KACjD;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAa,EAAE,aAAwB;IAC5D,QAAQ,KAAK,EAAE;QACb,KAAK,KAAK;YACR,OAAO,SAAS,CAAC,GAAG,CAAC;QACvB,KAAK,IAAI;YACP,OAAO,SAAS,CAAC,EAAE,CAAC;QACtB,KAAK,IAAI;YACP,OAAO,SAAS,CAAC,EAAE,CAAC;QACtB,KAAK,QAAQ;YACX,OAAO,SAAS,CAAC,MAAM,CAAC;QAC1B;YACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,EAAE,CAAC,CAAC;KACrD;AACH,CAAC;AAED,MAAM,UAAU,cAAc,C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AAC,CAAC,EAAE,CAAC;IAC5D,OAAO,gCACF,GAAG,CAAC,IAAI,EAAE,GACV,IAAI,CACM,CAAC;AAClB,CAAC","sourcesContent":["import { Command, Option } from \"commander\";\r\n\r\nimport { CliOptions, EmitModes, Modes } from \"../OptionModel.js\";\r\n\r\nfunction parseMode(value: string, dummyPrevious: Modes | undefined) {\r\n switch (value) {\r\n case \"models\":\r\n return Modes.models;\r\n case \"qobjects\":\r\n return Modes.qobjects;\r\n case \"service\":\r\n return Modes.service;\r\n case \"all\":\r\n return Modes.all;\r\n default:\r\n throw new Error(`Not a valid Mode: ${value}`);\r\n }\r\n}\r\n\r\nfunction parseEmitMode(value: string, dummyPrevious: EmitModes) {\r\n switch (value) {\r\n case \"dts\":\r\n return EmitModes.dts;\r\n case \"js\":\r\n return EmitModes.js;\r\n case \"ts\":\r\n return EmitModes.ts;\r\n case \"js_dts\":\r\n return EmitModes.js_dts;\r\n default:\r\n throw new Error(`Not a valid EmitMode: ${value}`);\r\n }\r\n}\r\n\r\nexport function processCliArgs(argv: Array<string>) {\r\n const cli = new Command()\r\n .version(\"0.3.0\")\r\n .description(\"CLI to generate Typescript Interfaces for models of a given OData service.\")\r\n .argument(\"[services...]\", \"Run the generation process only for certain services specified in config file\", [])\r\n .option(\"-s, --source <url or metadata.xml>\", \"Path to metadata file\")\r\n .option(\"-o, --output <path>\", \"Output location for generated files\")\r\n .option(\"-u, --source-url <sourceUrl>\", \"URL to the root of the OData service\")\r\n .option(\r\n \"-f, --refresh-file\",\r\n \"Download metadata again and overwrite existing file (only applies if sourceUrl is specified)\"\r\n )\r\n .addOption(\r\n new Option(\"-m, --mode <mode>\", \"What kind of stuff gets generated\")\r\n .choices(Object.values(Modes).filter((t): t is string => isNaN(Number(t))))\r\n .argParser<Modes>(parseMode)\r\n )\r\n .addOption(\r\n new Option(\r\n \"-e, --emit-mode <mode>\",\r\n \"Output TS source files, compiled JS files with/wihthout generated d.ts files\"\r\n )\r\n .choices(Object.values(EmitModes))\r\n .argParser<EmitModes>(parseEmitMode)\r\n )\r\n .option(\"-p, --prettier\", \"Format result with prettier (only applies if emitMode=ts)\")\r\n .option(\r\n \"-t, --tsconfig <path>\",\r\n \"Specify alternative to 'tsconfig.json' to use specific compilerOptions (applies if emitMode is not ts)\"\r\n )\r\n .option(\"-d, --debug\", \"Verbose debug infos\")\r\n .option(\"-name, --service-name <serviceName>\", \"Give the service your own name\")\r\n .option(\r\n \"-n, --disable-auto-managed-key\",\r\n \"Don't mark single key props as managed by the server side (not editable)\"\r\n )\r\n .option(\"-r, --allow-renaming\", \"Allow that property and entity names may be changed by configured casing\")\r\n .parse(argv);\r\n\r\n const args = cli.args?.length ? { services: cli.args } : {};\r\n return {\r\n ...cli.opts(),\r\n ...args,\r\n } as CliOptions;\r\n}\r\n"]}
@@ -0,0 +1,2 @@
1
+ import { ConfigFileOptions } from "../OptionModel.js";
2
+ export declare function processConfigFile(): Promise<ConfigFileOptions>;
@@ -0,0 +1,24 @@
1
+ import { __awaiter } from "tslib";
2
+ import { cosmiconfig } from "cosmiconfig";
3
+ import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
4
+ import { logFilePath } from "../project/logger/logFilePath.js";
5
+ export function processConfigFile() {
6
+ return __awaiter(this, void 0, void 0, function* () {
7
+ const moduleName = "odata2ts";
8
+ const explorer = cosmiconfig(moduleName, {
9
+ searchPlaces: [`${moduleName}.config.js`, `${moduleName}.config.ts`, `${moduleName}.config.cjs`],
10
+ loaders: {
11
+ ".ts": TypeScriptLoader(),
12
+ },
13
+ });
14
+ const discoveredConfig = yield explorer.search();
15
+ if (discoveredConfig === null || discoveredConfig === void 0 ? void 0 : discoveredConfig.config) {
16
+ console.log("Loaded config file: ", logFilePath(discoveredConfig.filepath));
17
+ }
18
+ else {
19
+ console.log("No config file found.");
20
+ }
21
+ return discoveredConfig === null || discoveredConfig === void 0 ? void 0 : discoveredConfig.config;
22
+ });
23
+ }
24
+ //# sourceMappingURL=processConfigFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processConfigFile.js","sourceRoot":"","sources":["../../src/cli/processConfigFile.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAE/D,MAAM,UAAgB,iBAAiB;;QACrC,MAAM,UAAU,GAAG,UAAU,CAAC;QAC9B,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,EAAE;YACvC,YAAY,EAAE,CAAC,GAAG,UAAU,YAAY,EAAE,GAAG,UAAU,YAAY,EAAE,GAAG,UAAU,aAAa,CAAC;YAChG,OAAO,EAAE;gBACP,KAAK,EAAE,gBAAgB,EAAE;aAC1B;SACF,CAAC,CAAC;QACH,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC;QAEjD,IAAI,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,MAAM,EAAE;YAC5B,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;SAC7E;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;SACtC;QAED,OAAO,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,MAA2B,CAAC;IACvD,CAAC;CAAA","sourcesContent":["import { cosmiconfig } from \"cosmiconfig\";\r\nimport { TypeScriptLoader } from \"cosmiconfig-typescript-loader\";\r\n\r\nimport { ConfigFileOptions } from \"../OptionModel.js\";\r\nimport { logFilePath } from \"../project/logger/logFilePath.js\";\r\n\r\nexport async function processConfigFile() {\r\n const moduleName = \"odata2ts\";\r\n const explorer = cosmiconfig(moduleName, {\r\n searchPlaces: [`${moduleName}.config.js`, `${moduleName}.config.ts`, `${moduleName}.config.cjs`],\r\n loaders: {\r\n \".ts\": TypeScriptLoader(),\r\n },\r\n });\r\n const discoveredConfig = await explorer.search();\r\n\r\n if (discoveredConfig?.config) {\r\n console.log(\"Loaded config file: \", logFilePath(discoveredConfig.filepath));\r\n } else {\r\n console.log(\"No config file found.\");\r\n }\r\n\r\n return discoveredConfig?.config as ConfigFileOptions;\r\n}\r\n"]}