@odata2ts/odata2ts 0.33.2 → 0.35.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.
package/CHANGELOG.md CHANGED
@@ -3,15 +3,40 @@
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.35.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.34.0...@odata2ts/odata2ts@0.35.0) (2024-05-16)
7
+
8
+ ### Bug Fixes
9
+
10
+ * empty enum ([#270](https://github.com/odata2ts/odata2ts/issues/270)) ([32eeb1e](https://github.com/odata2ts/odata2ts/commit/32eeb1e587f507a138ca96d81c7ab3da4c0bdba8))
11
+
12
+ ### Features
13
+
14
+ * invariant client type ([#272](https://github.com/odata2ts/odata2ts/issues/272)) ([0ee3c94](https://github.com/odata2ts/odata2ts/commit/0ee3c94d3bf34e7774e1be8dad657ed5e64e597e))
15
+
16
+ # [0.34.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.33.2...@odata2ts/odata2ts@0.34.0) (2024-05-03)
17
+
18
+ ### Bug Fixes
19
+
20
+ * **odata2ts:** don't generate main model & q-object file in unbundled mode if empty ([#268](https://github.com/odata2ts/odata2ts/issues/268)) ([e5e69a5](https://github.com/odata2ts/odata2ts/commit/e5e69a5826814d3848f9eba0c4e808cd61dae580))
21
+
22
+ ### Features
23
+
24
+ * **odata2ts:** support binary params ([#267](https://github.com/odata2ts/odata2ts/issues/267)) ([483603f](https://github.com/odata2ts/odata2ts/commit/483603f267618c07a1ec3d39433ad2157a1854bd))
25
+
6
26
  ## [0.33.2](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.33.1...@odata2ts/odata2ts@0.33.2) (2024-04-22)
7
27
 
8
28
  ### Bug Fixes
9
29
 
10
30
  * **generator:** add special logic for bound operation name clas resolution (gets prefixed by bound entity) ([#259](https://github.com/odata2ts/odata2ts/issues/259)) ([2a0f9ff](https://github.com/odata2ts/odata2ts/commit/2a0f9ff4cf7222db86af396e00859ae47d426eac))
31
+
11
32
  * **generator:** await ensureDir calls ([99c679d](https://github.com/odata2ts/odata2ts/commit/99c679d8ad989dae65e9366b3018d86a867ecae8))
33
+
12
34
  * **generator:** in unbundled mode unbound action models should go into main files ([#264](https://github.com/odata2ts/odata2ts/issues/264)) ([5dd52ec](https://github.com/odata2ts/odata2ts/commit/5dd52eceae1982f5e48a57ea08649ada5e11d190))
35
+
13
36
  * **generator:** too many imports for services with entity nav props ([1cae569](https://github.com/odata2ts/odata2ts/commit/1cae5694a2794173d8ec31698dc1601f29322382))
37
+
14
38
  * **generator:** write main service file only once ([74e39a0](https://github.com/odata2ts/odata2ts/commit/74e39a0cafa584b06f1fdace41d6636fbbc59942))
39
+
15
40
  * **generator:** wrong namespace prefix calculated ([2ad5a56](https://github.com/odata2ts/odata2ts/commit/2ad5a568c8fa64bc5f3db0bf07f28c3cb25b815c))
16
41
 
17
42
  ## [0.33.1](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.33.0...@odata2ts/odata2ts@0.33.1) (2024-03-23)
@@ -27,7 +52,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
27
52
  ### Features
28
53
 
29
54
  * **generator:** auto detected service names are run through pascalCase to ensure valid class names ([#250](https://github.com/odata2ts/odata2ts/issues/250)) ([04fcf49](https://github.com/odata2ts/odata2ts/commit/04fcf490aee43dc1c2bc70af394fe9d1d8ce3249))
55
+
30
56
  * **generator:** no collection services for entity types without keys ([#248](https://github.com/odata2ts/odata2ts/issues/248)) ([56540b2](https://github.com/odata2ts/odata2ts/commit/56540b22aa92a7a8c929b4088c69d8af30b63364))
57
+
31
58
  * **generator:** support abstract entities ([#247](https://github.com/odata2ts/odata2ts/issues/247)) ([cbf5121](https://github.com/odata2ts/odata2ts/commit/cbf51214da0fdbccba7fff5a3c0b770f73ed06bd))
32
59
 
33
60
  # [0.32.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.31.1...@odata2ts/odata2ts@0.32.0) (2024-03-10)
package/README.md CHANGED
@@ -1,81 +1,81 @@
1
- [![npm (scoped)](https://img.shields.io/npm/v/@odata2ts/odata2ts?style=for-the-badge)](https://www.npmjs.com/package/@odata2ts/odata2ts)
2
-
3
- # odata2ts
4
-
5
- The basic idea of `odata2ts` is to leverage the readily available metadata of any OData service
6
- to generate different sorts of typed artefacts which you use in your TypeScript code.
7
- This package (`@odata2ts/odata2ts`) realizes the generation process.
8
-
9
- The generator is supposed to be used with a TypeScript based configuration file.
10
- Then it's able to handle the generation for multiple OData services.
11
-
12
- It comes with powerful configuration options. Some highlights:
13
-
14
- - generation of TypeScript files or compiled JS / DTS files
15
- - name or rename stuff
16
- - naming of pretty much any aspect of the generated artefacts
17
- - e.g. all types should be prefixed with an "I", Person => IPerson
18
- - consistent casing (as in "camelCase" or "PascalCase") even for property names of entity types
19
- - use type converters
20
-
21
- See the [generator documentation](https://odata2ts.github.io/docs/generator/setup-and-usage) for more information.
22
-
23
- ## Installation
24
-
25
- ```
26
- npm install --save-dev @odata2ts/odata2ts
27
- ```
28
-
29
- ### Implicit Dependencies
30
-
31
- Most of the generated artefacts depend on other libraries. `odata2ts` lists them as peer dependencies.
32
-
33
- Depending on your use case, you will need to add runtime dependencies matching the mentioned peer dependencies.
34
- See the [Getting Started Guide](https://odata2ts.github.io/docs/category/getting-started/) of the documentation
35
- for guidance.
36
-
37
- ## Documentation
38
-
39
- [Generator Documentation](https://odata2ts.github.io/docs/generator/setup-and-usage)
40
-
41
- Main documentation for the odata2ts eco system:
42
- [https://odata2ts.github.io](https://odata2ts.github.io/)
43
-
44
- ## Examples
45
-
46
- See [example packages](https://github.com/odata2ts/odata2ts/tree/main/examples) for examples of how to integrate `odata2ts`.
47
-
48
- ## Tests
49
-
50
- See folder [test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/test)
51
- for unit tests.
52
-
53
- See folder [int-test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/int-test) for integration
54
- tests of the CLI.
55
-
56
- Each example package serves as integration test of the generator.
57
-
58
- ## Support, Feedback, Contributing
59
-
60
- This project is open to feature requests, suggestions, bug reports, usage questions etc.
61
- via [GitHub issues](https://github.com/odata2ts/odata2ts/issues).
62
-
63
- Contributions and feedback are encouraged and always welcome.
64
-
65
- See the [contribution guidelines](https://github.com/odata2ts/odata2ts/blob/main/CONTRIBUTING.md) for further information.
66
-
67
- ## Spirit
68
-
69
- This project and this module have been created and are maintained in the following spirit:
70
-
71
- - adhere to the **OData specification** as much as possible
72
- - support any OData service implementation which conforms to the spec
73
- - allow to work around faulty implementations if possible
74
- - stability matters
75
- - exercise Test Driven Development
76
- - bomb the place with unit tests (code coverage > 95%)
77
- - ensure that assumptions & understanding are correct by creating integration tests
78
-
79
- ## License
80
-
81
- MIT - see [License](./LICENSE).
1
+ [![npm (scoped)](https://img.shields.io/npm/v/@odata2ts/odata2ts?style=for-the-badge)](https://www.npmjs.com/package/@odata2ts/odata2ts)
2
+
3
+ # odata2ts
4
+
5
+ The basic idea of `odata2ts` is to leverage the readily available metadata of any OData service
6
+ to generate different sorts of typed artefacts which you use in your TypeScript code.
7
+ This package (`@odata2ts/odata2ts`) realizes the generation process.
8
+
9
+ The generator is supposed to be used with a TypeScript based configuration file.
10
+ Then it's able to handle the generation for multiple OData services.
11
+
12
+ It comes with powerful configuration options. Some highlights:
13
+
14
+ - generation of TypeScript files or compiled JS / DTS files
15
+ - name or rename stuff
16
+ - naming of pretty much any aspect of the generated artefacts
17
+ - e.g. all types should be prefixed with an "I", Person => IPerson
18
+ - consistent casing (as in "camelCase" or "PascalCase") even for property names of entity types
19
+ - use type converters
20
+
21
+ See the [generator documentation](https://odata2ts.github.io/docs/generator/setup-and-usage) for more information.
22
+
23
+ ## Installation
24
+
25
+ ```
26
+ npm install --save-dev @odata2ts/odata2ts
27
+ ```
28
+
29
+ ### Implicit Dependencies
30
+
31
+ Most of the generated artefacts depend on other libraries. `odata2ts` lists them as peer dependencies.
32
+
33
+ Depending on your use case, you will need to add runtime dependencies matching the mentioned peer dependencies.
34
+ See the [Getting Started Guide](https://odata2ts.github.io/docs/category/getting-started/) of the documentation
35
+ for guidance.
36
+
37
+ ## Documentation
38
+
39
+ [Generator Documentation](https://odata2ts.github.io/docs/generator/setup-and-usage)
40
+
41
+ Main documentation for the odata2ts eco system:
42
+ [https://odata2ts.github.io](https://odata2ts.github.io/)
43
+
44
+ ## Examples
45
+
46
+ See [example packages](https://github.com/odata2ts/odata2ts/tree/main/examples) for examples of how to integrate `odata2ts`.
47
+
48
+ ## Tests
49
+
50
+ See folder [test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/test)
51
+ for unit tests.
52
+
53
+ See folder [int-test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/int-test) for integration
54
+ tests of the CLI.
55
+
56
+ Each example package serves as integration test of the generator.
57
+
58
+ ## Support, Feedback, Contributing
59
+
60
+ This project is open to feature requests, suggestions, bug reports, usage questions etc.
61
+ via [GitHub issues](https://github.com/odata2ts/odata2ts/issues).
62
+
63
+ Contributions and feedback are encouraged and always welcome.
64
+
65
+ See the [contribution guidelines](https://github.com/odata2ts/odata2ts/blob/main/CONTRIBUTING.md) for further information.
66
+
67
+ ## Spirit
68
+
69
+ This project and this module have been created and are maintained in the following spirit:
70
+
71
+ - adhere to the **OData specification** as much as possible
72
+ - support any OData service implementation which conforms to the spec
73
+ - allow to work around faulty implementations if possible
74
+ - stability matters
75
+ - exercise Test Driven Development
76
+ - bomb the place with unit tests (code coverage > 95%)
77
+ - ensure that assumptions & understanding are correct by creating integration tests
78
+
79
+ ## License
80
+
81
+ MIT - see [License](./LICENSE).
@@ -1 +1 @@
1
- {"version":3,"file":"FactoryFunctionModel.js","sourceRoot":"","sources":["../src/FactoryFunctionModel.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport { SourceFile } from \"ts-morph\";\n\nimport { DataModel } from \"./data-model/DataModel\";\nimport { Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\nimport { NamingHelper } from \"./data-model/NamingHelper\";\nimport { RunOptions } from \"./OptionModel\";\nimport { ProjectManager } from \"./project/ProjectManager\";\n\nexport type DigestionOptions = Pick<\n RunOptions,\n | \"converters\"\n | \"disableAutoManagedKey\"\n | \"propertiesByName\"\n | \"byTypeAndName\"\n | \"v2ModelsWithExtraResultsWrapping\"\n | \"v4BigNumberAsString\"\n | \"skipEditableModels\"\n | \"skipComments\"\n | \"disableAutomaticNameClashResolution\"\n | \"bundledFileGeneration\"\n>;\n\n/**\n * Takes an EdmxSchema plus the run options and creates a DataModel.\n */\nexport type DigesterFunction<S extends Schema<any, any>> = (\n schema: Array<S>,\n options: DigestionOptions,\n namingHelper: NamingHelper\n) => Promise<DataModel>;\n\nexport type GeneratorFunctionOptions = Pick<\n RunOptions,\n \"skipEditableModels\" | \"skipIdModels\" | \"skipOperations\" | \"skipComments\" | \"v2ModelsWithExtraResultsWrapping\"\n>;\n\nexport type EntityBasedGeneratorFunction = (\n project: ProjectManager,\n dataModel: DataModel,\n version: ODataVersions,\n options: GeneratorFunctionOptions,\n namingHelper: NamingHelper\n) => Promise<void>;\n"]}
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 +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 {\n Any = \"Any\",\n EntitySet = \"EntitySet\",\n Singleton = \"Singleton\",\n EntityType = \"EntityType\",\n ComplexType = \"ComplexType\",\n EnumType = \"EnumType\",\n // Bundle Function and Action (bound or unbound; v4 only)\n OperationType = \"OperationType\",\n // Bundles ActionImport and FunctionImport elements\n OperationImportType = \"OperationImportType\",\n}\n"]}
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"]}
package/lib/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,6CAAyC;AAGzC,4EAAuE;AACvE,4EAAuE;AAIvE,4DAAyD;AACzD,2CAAqF;AACrF,+CAAkD;AAClD,6DAAgE;AAEhE,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,QAAQ,EAAE,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,OAAO,EAAE,mBAAK,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,CAAC;KAC5B;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AE,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,IAAA,gCAAoB,EAAC,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,IAAA,4BAAgB,EAAC,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;AAtED,wBAsEC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport { pascalCase } from \"pascal-case\";\n\nimport { NamespaceWithAlias } from \"./data-model/DataModel\";\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2\";\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\nimport { ODataEdmxModelBase } from \"./data-model/edmx/ODataEdmxModelBase\";\nimport { SchemaV3 } from \"./data-model/edmx/ODataEdmxModelV3\";\nimport { SchemaV4 } from \"./data-model/edmx/ODataEdmxModelV4\";\nimport { NamingHelper } from \"./data-model/NamingHelper\";\nimport { generateModels, generateQueryObjects, generateServices } from \"./generator\";\nimport { Modes, RunOptions } from \"./OptionModel\";\nimport { createProjectManager } from \"./project/ProjectManager\";\n\nfunction isQObjectGen(mode: Modes) {\n return [Modes.qobjects, Modes.service, Modes.all].includes(mode);\n}\n\nfunction isServiceGen(mode: Modes) {\n return [Modes.service, Modes.all].includes(mode);\n}\n\nfunction getServiceName(options: RunOptions, schemas: Array<SchemaV3 | SchemaV4>) {\n if (options.serviceName) {\n return options.serviceName;\n }\n\n // auto-detection of first namespace with defined EntityTypes\n // NOTE: we make use of PascalCase here to enforce valid class names\n const detectedSchema = schemas.find((schema) => schema.$.Namespace && schema.EntityType?.length) || schemas[0];\n const serviceName = detectedSchema.$.Namespace;\n return pascalCase(serviceName);\n}\n\n/**\n *\n * @param metadataJson metadata of a given OData service already parsed as JSON\n * @param options further options\n */\nexport async function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void> {\n // determine edmx edmxVersion attribute\n const edmxVersion = metadataJson[\"edmx:Edmx\"].$.Version;\n const version = edmxVersion === \"1.0\" ? ODataVersions.V2 : ODataVersions.V4;\n\n const dataService = metadataJson[\"edmx:Edmx\"][\"edmx:DataServices\"][0];\n const schemas = dataService.Schema as Array<SchemaV3 | SchemaV4>;\n\n const serviceName = getServiceName(options, schemas);\n\n const namespaces = schemas.map<NamespaceWithAlias>((schema) => [schema.$.Namespace, schema.$.Alias]);\n\n // encapsulate the whole naming logic\n const namingHelper = new NamingHelper(options, serviceName, namespaces);\n // parse model information from edmx into something we can really work with\n // => that stuff is called dataModel!\n const dataModel =\n version === ODataVersions.V2\n ? await digestV2(dataService.Schema as Array<SchemaV3>, options, namingHelper)\n : await digestV4(dataService.Schema as Array<SchemaV4>, options, namingHelper);\n\n // Validation of entity names: the same name might be used across different namespaces\n const validationErrors = dataModel.getNameValidation();\n if (validationErrors.size) {\n console.log(\"---\");\n validationErrors.forEach((errors, name) => {\n console.log(\n `Duplicate name: ${name} - Fully Qualified Names: ${errors\n .map((error) => error.fqName + (error.renamedTo ? ` (renamed to: ${error.renamedTo})` : \"\"))\n .join(\", \")}`\n );\n });\n\n if (options.disableAutomaticNameClashResolution) {\n throw new Error(\"Name validation failed: Multiple entities have the same name across different namespaces!\");\n }\n }\n\n // handling the overall generation project\n const project = await createProjectManager(options.output, options.emitMode, namingHelper, dataModel, {\n usePrettier: options.prettier,\n tsConfigPath: options.tsconfig,\n bundledFileGeneration: options.bundledFileGeneration,\n });\n\n // const promises: Array<Promise<void>> = [\n // Generate Model Interfaces\n // generateModels(project, dataModel, version, options, namingHelper),\n // ];\n await generateModels(project, dataModel, version, options, namingHelper);\n console.log(\"Successfully generated models!\");\n\n // Generate Query Objects\n // supported edmx types: EntityType, ComplexType\n // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object\n if (isQObjectGen(options.mode)) {\n // promises.push(generateQueryObjects(project, dataModel, version, options, namingHelper));\n await generateQueryObjects(project, dataModel, version, options, namingHelper);\n console.log(\"Successfully generated q-objects!\");\n }\n\n // Generate Individual OData-Service\n if (isServiceGen(options.mode)) {\n // promises.push(generateServices(project, dataModel, version, namingHelper, options));\n await generateServices(project, dataModel, version, namingHelper, options);\n console.log(\"Successfully generated services!\");\n }\n\n // await Promise.all(promises);\n console.log(\"Successfully finished!\");\n}\n"]}
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,6CAAyC;AAGzC,4EAAuE;AACvE,4EAAuE;AAIvE,4DAAyD;AACzD,2CAAqF;AACrF,+CAAkD;AAClD,6DAAgE;AAEhE,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,QAAQ,EAAE,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,cAAc,CAAC,OAAmB,EAAE,OAAmC;IAC9E,IAAI,OAAO,CAAC,WAAW,EAAE;QACv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,EAAE,SAAS,EAAE,OAAO,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,IAAA,gCAAoB,EAAC,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,IAAA,4BAAgB,EAAC,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;AAtED,wBAsEC","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 });\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"]}
package/lib/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;AAAA,+DAA8C;AAC9C,6CAA0C;AAC1C,iFAAiE;AACjE,uCAA0D;AAC1D,mCAA4C;AAE5C,+BAA+B;AAE/B,0CAA8D;AAC9D,qDAAyD;AACzD,+CAAoH;AACpH,8DAA2D;AAE3D,SAAS,SAAS,CAAC,KAAa,EAA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AAE,MAAM,CAAC,CAAC;YACnD,WAAW,GAAG,MAAM,IAAA,mBAAQ,EAAC,MAAM,CAAC,CAAC;SACtC;QAED,MAAM,YAAY,GAAG,CAAC,MAAM,IAAA,2BAAkB,EAAC,WAAW,CAAC,CAA4B,CAAC;QACxF,sDAAsD;QACtD,iEAAiE;QACjE,iFAAiF;QAEjF,sCAAsC;QACtC,IAAI;YACF,MAAM,IAAA,mBAAQ,EAAC,MAAM,CAAC,CAAC;SACxB;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,gBAAgB,MAAM,wBAAwB,EAAE,KAAK,CAAC,CAAC;YACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;QAED,cAAc;QACd,IAAI;YACF,MAAM,IAAA,YAAM,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC;SACrC;QAAC,OAAO,GAAQ,EAAE;YACjB,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,GAAG,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAClB;IACH,CAAC;CAAA","sourcesContent":["import commander, { Option } from \"commander\";\nimport { cosmiconfig } from \"cosmiconfig\";\nimport { TypeScriptLoader } from \"cosmiconfig-typescript-loader\";\nimport { emptyDir, pathExists, readFile } from \"fs-extra\";\nimport { parseStringPromise } from \"xml2js\";\n\nimport { runApp } from \"./app\";\nimport { ODataEdmxModelBase } from \"./data-model/edmx/ODataEdmxModelBase\";\nimport { downloadMetadata, storeMetadata } from \"./download/\";\nimport { evaluateConfigOptions } from \"./evaluateConfig\";\nimport { CliOptions, ConfigFileOptions, EmitModes, Modes, RunOptions, UrlSourceConfiguration } from \"./OptionModel\";\nimport { logFilePath } from \"./project/logger/logFilePath\";\n\nfunction parseMode(value: string, dummyPrevious: Modes | undefined) {\n switch (value) {\n case \"models\":\n return Modes.models;\n case \"qobjects\":\n return Modes.qobjects;\n case \"service\":\n return Modes.service;\n case \"all\":\n return Modes.all;\n default:\n throw new Error(`Not a valid Mode: ${value}`);\n }\n}\n\nfunction parseEmitMode(value: string, dummyPrevious: EmitModes) {\n switch (value) {\n case \"dts\":\n return EmitModes.dts;\n case \"js\":\n return EmitModes.js;\n case \"ts\":\n return EmitModes.ts;\n case \"js_dts\":\n return EmitModes.js_dts;\n default:\n throw new Error(`Not a valid EmitMode: ${value}`);\n }\n}\n\nfunction processCliArgs() {\n const cli = new commander.Command()\n .version(\"0.3.0\")\n .description(\"CLI to generate Typescript Interfaces for models of a given OData service.\")\n .argument(\"[services...]\", \"Run the generation process only for certain services specified in config file\", [])\n .option(\"-s, --source <url or metadata.xml>\", \"Path to metadata file\")\n .option(\"-o, --output <path>\", \"Output location for generated files\")\n .option(\"-u, --source-url <sourceUrl>\", \"URL to the root of the OData service\")\n .option(\n \"-f, --refresh-file\",\n \"Download metadata again and overwrite existing file (only applies if sourceUrl is specified)\"\n )\n .addOption(\n new Option(\"-m, --mode <mode>\", \"What kind of stuff gets generated\")\n .choices(Object.values(Modes).filter((t): t is string => isNaN(Number(t))))\n .argParser<Modes>(parseMode)\n )\n .addOption(\n new Option(\n \"-e, --emit-mode <mode>\",\n \"Output TS source files, compiled JS files with/wihthout generated d.ts files\"\n )\n .choices(Object.values(EmitModes))\n .argParser<EmitModes>(parseEmitMode)\n )\n .option(\"-p, --prettier\", \"Format result with prettier (only applies if emitMode=ts)\")\n .option(\n \"-t, --tsconfig <path>\",\n \"Specify alternative to 'tsconfig.json' to use specific compilerOptions (applies if emitMode is not ts)\"\n )\n .option(\"-d, --debug\", \"Verbose debug infos\")\n .option(\"-name, --service-name <serviceName>\", \"Give the service your own name\")\n .option(\n \"-n, --disable-auto-managed-key\",\n \"Don't mark single key props as managed by the server side (not editable)\"\n )\n .option(\"-r, --allow-renaming\", \"Allow that property and entity names may be changed by configured casing\")\n .parse(process.argv);\n\n const args = cli.args?.length ? { services: cli.args } : {};\n return {\n ...cli.opts(),\n ...args,\n } as CliOptions;\n}\n\nasync function processConfigFile() {\n const moduleName = \"odata2ts\";\n const explorer = cosmiconfig(moduleName, {\n searchPlaces: [`${moduleName}.config.js`, `${moduleName}.config.ts`, `${moduleName}.config.cjs`],\n loaders: {\n \".ts\": TypeScriptLoader(),\n },\n });\n const discoveredConfig = await explorer.search();\n\n if (discoveredConfig?.config) {\n console.log(\"Loaded config file: \", logFilePath(discoveredConfig.filepath));\n } else {\n console.log(\"No config file found.\");\n }\n\n return discoveredConfig?.config as ConfigFileOptions;\n}\n\nexport class Cli {\n async run(): Promise<void> {\n let runs;\n try {\n const cliOpts = processCliArgs();\n if (cliOpts.debug) {\n console.log(\"CLI opts:\", cliOpts);\n }\n const fileOpts = await processConfigFile();\n\n runs = evaluateConfigOptions(cliOpts, fileOpts);\n } catch (error: any) {\n console.error(\"Bad arguments!\", error?.message);\n process.exit(1);\n }\n\n for (let run of runs) {\n await startServiceGenerationRun(run);\n }\n }\n}\n\nasync function startServiceGenerationRun(options: RunOptions) {\n const { source, output, sourceUrl, refreshFile, sourceUrlConfig, debug, mode, emitMode, prettier, serviceName } =\n options;\n console.log(\"---------------------------\");\n console.log(\n `Starting generation process. Service name ${serviceName ? `\"${serviceName}\"` : \"will be detected automatically!\"}`\n );\n\n if (debug) {\n console.log(\"Resolved config:\", {\n source,\n output,\n sourceUrl,\n refreshFile,\n debug,\n mode: Modes[mode],\n emitMode,\n prettier,\n serviceName,\n });\n }\n\n // evaluate source\n const exists = await pathExists(source);\n console.log(`${exists ? \"Found\" : \"Didn't find\"} metadata file at: `, source);\n\n let metadataXml;\n // download metadata and store on disk\n if (sourceUrl && (!exists || refreshFile)) {\n try {\n metadataXml = await downloadMetadata(sourceUrl, sourceUrlConfig, debug);\n } catch (e) {\n console.error(`Failed to load metadata! Message: ${(e as Error)?.message}`);\n process.exit(10);\n }\n metadataXml = await storeMetadata(source, metadataXml, prettier);\n }\n // otherwise file must exist\n else if (!exists) {\n console.error(`Input source [${source}] doesn't exist!`);\n process.exit(2);\n }\n // read the metadata from file\n else {\n console.log(\"Reading metadata from file:\", source);\n metadataXml = await readFile(source);\n }\n\n const metadataJson = (await parseStringPromise(metadataXml)) as ODataEdmxModelBase<any>;\n // TODO find out if \"1.0\" and \"4.0\" are really correct\n // TODO exit here if no version not suitable version was detected\n // console.log(`OData version detected: ${metadataJson[\"edmx:Edmx\"].$.Version}`);\n\n // ensure that output directory exists\n try {\n await emptyDir(output);\n } catch (error) {\n console.error(`Output path [${output}] couldn't be created!`, error);\n process.exit(3);\n }\n\n // run the app\n try {\n await runApp(metadataJson, options);\n } catch (err: any) {\n console.error(\"Error while running the program\", err);\n process.exit(99);\n }\n}\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;AAAA,+DAA8C;AAC9C,6CAA0C;AAC1C,iFAAiE;AACjE,uCAA0D;AAC1D,mCAA4C;AAE5C,+BAA+B;AAE/B,0CAA8D;AAC9D,qDAAyD;AACzD,+CAAoH;AACpH,8DAA2D;AAE3D,SAAS,SAAS,CAAC,KAAa,EAAE,aAAgC;IAChE,QAAQ,KAAK,EAAE;QACb,KAAK,QAAQ;YACX,OAAO,mBAAK,CAAC,MAAM,CAAC;QACtB,KAAK,UAAU;YACb,OAAO,mBAAK,CAAC,QAAQ,CAAC;QACxB,KAAK,SAAS;YACZ,OAAO,mBAAK,CAAC,OAAO,CAAC;QACvB,KAAK,KAAK;YACR,OAAO,mBAAK,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,uBAAS,CAAC,GAAG,CAAC;QACvB,KAAK,IAAI;YACP,OAAO,uBAAS,CAAC,EAAE,CAAC;QACtB,KAAK,IAAI;YACP,OAAO,uBAAS,CAAC,EAAE,CAAC;QACtB,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O,CAAC,KAAK,CAAC,iCAAiC,EAAE,GAAG,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAClB;IACH,CAAC;CAAA","sourcesContent":["import commander, { Option } from \"commander\";\r\nimport { cosmiconfig } from \"cosmiconfig\";\r\nimport { TypeScriptLoader } from \"cosmiconfig-typescript-loader\";\r\nimport { emptyDir, pathExists, readFile } from \"fs-extra\";\r\nimport { parseStringPromise } from \"xml2js\";\r\n\r\nimport { runApp } from \"./app\";\r\nimport { ODataEdmxModelBase } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { downloadMetadata, storeMetadata } from \"./download/\";\r\nimport { evaluateConfigOptions } from \"./evaluateConfig\";\r\nimport { CliOptions, ConfigFileOptions, EmitModes, Modes, RunOptions, UrlSourceConfiguration } from \"./OptionModel\";\r\nimport { logFilePath } from \"./project/logger/logFilePath\";\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\nfunction processCliArgs() {\r\n const cli = new commander.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(process.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\r\nasync 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\r\nexport class Cli {\r\n async run(): Promise<void> {\r\n let runs;\r\n try {\r\n const cliOpts = processCliArgs();\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}\r\n\r\nasync function startServiceGenerationRun(options: RunOptions) {\r\n const { source, output, sourceUrl, refreshFile, sourceUrlConfig, debug, mode, emitMode, prettier, serviceName } =\r\n options;\r\n console.log(\"---------------------------\");\r\n console.log(\r\n `Starting generation process. Service name ${serviceName ? `\"${serviceName}\"` : \"will be detected automatically!\"}`\r\n );\r\n\r\n if (debug) {\r\n console.log(\"Resolved config:\", {\r\n source,\r\n output,\r\n sourceUrl,\r\n refreshFile,\r\n debug,\r\n mode: Modes[mode],\r\n emitMode,\r\n prettier,\r\n serviceName,\r\n });\r\n }\r\n\r\n // evaluate source\r\n const exists = await pathExists(source);\r\n console.log(`${exists ? \"Found\" : \"Didn't find\"} metadata file at: `, source);\r\n\r\n let metadataXml;\r\n // download metadata and store on disk\r\n if (sourceUrl && (!exists || refreshFile)) {\r\n try {\r\n metadataXml = await downloadMetadata(sourceUrl, sourceUrlConfig, debug);\r\n } catch (e) {\r\n console.error(`Failed to load metadata! Message: ${(e as Error)?.message}`);\r\n process.exit(10);\r\n }\r\n metadataXml = await storeMetadata(source, metadataXml, prettier);\r\n }\r\n // otherwise file must exist\r\n else if (!exists) {\r\n console.error(`Input source [${source}] doesn't exist!`);\r\n process.exit(2);\r\n }\r\n // read the metadata from file\r\n else {\r\n console.log(\"Reading metadata from file:\", source);\r\n metadataXml = await readFile(source);\r\n }\r\n\r\n const metadataJson = (await parseStringPromise(metadataXml)) as ODataEdmxModelBase<any>;\r\n // TODO find out if \"1.0\" and \"4.0\" are really correct\r\n // TODO exit here if no version not suitable version was detected\r\n // console.log(`OData version detected: ${metadataJson[\"edmx:Edmx\"].$.Version}`);\r\n\r\n // ensure that output directory exists\r\n try {\r\n await emptyDir(output);\r\n } catch (error) {\r\n console.error(`Output path [${output}] couldn't be created!`, error);\r\n process.exit(3);\r\n }\r\n\r\n // run the app\r\n try {\r\n await runApp(metadataJson, options);\r\n } catch (err: any) {\r\n console.error(\"Error while running the program\", err);\r\n process.exit(99);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DataModel.js","sourceRoot":"","sources":["../../src/data-model/DataModel.ts"],"names":[],"mappings":";;;AAGA,mDAcyB;AAczB,SAAgB,aAAa,CAAC,EAAU,EAAE,IAAY;IACpD,oHAAoH;IACpH,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACrC,CAAC;AAHD,sCAGC;AAED,MAAa,SAAS;IA+BpB,YACE,UAAqC,EAC7B,OAAqB,EAC7B,aAAoC,IAAI,GAAG,EAAE;QADrC,YAAO,GAAP,OAAO,CAAc;QA7BvB,WAAM,GAAG,IAAI,GAAG,EAA+C,CAAC;QACxE;;;WAGG;QACK,0BAAqB,GAAG,IAAI,GAAG,EAAyB,CAAC;QACjE;;;;WAIG;QACK,8BAAyB,GAAG,IAAI,GAAG,EAAgC,CAAC;QAC5E;;;;WAIG;QACK,wCAAmC,GAAG,IAAI,GAAG,EAAgC,CAAC;QACtF;;;WAGG;QACK,oBAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;QAE5C,YAAO,GAA2B,EAAE,CAAC;QACrC,cAAS,GAAyB,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAOvG,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,UAAU,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,KAAK,aAAa,CAAC,CAAC;oBACjE,IAAI,SAAS,EAAE;wBACb,KAAK,CAAC,SAAS,CAAC,CAAC;qBAClB;iBACF;gBACD,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAC1B,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAChC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpB;QACH,CAAC;QAED,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,KAAK,CAAC,KAAK,CAAC,CAAC;SACd;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,iBAAiB,CAAC,GAAmC;QAC1D,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC;IAC5B,CAAC;IAEM,iBAAiB;QACtB,OAAO,IAAI,CAAC,cAAe,CAAC;IAC9B,CAAC;CACF;AAvQD,8BAuQC","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\nimport { ODataTypesV2, ODataTypesV4 } from \"@odata2ts/odata-core\";\n\nimport {\n ActionImportType,\n ComplexType,\n DataTypes,\n EntityContainerModel,\n EntitySetType,\n EntityType,\n EnumType,\n FunctionImportType,\n ModelType,\n ODataVersion,\n OperationType,\n PropertyModel,\n SingletonType,\n} from \"./DataTypeModel\";\nimport { ValidationError } from \"./validation/NameValidator\";\n\nexport interface ProjectFiles {\n model: string;\n qObject: string;\n service: string;\n}\n\n/**\n * Each namespace is represented as tuple: 1. the namespace 2. the alias, if any.\n */\nexport type NamespaceWithAlias = [string, string?];\n\nexport function withNamespace(ns: string, name: string) {\n // this supports the edge case of an empty string as namespace which isn't really valid according to spec (see CSDL)\n return ns ? `${ns}.${name}` : name;\n}\n\nexport class DataModel {\n private readonly converters: MappedConverterChains;\n private nameValidation: Map<string, ValidationError[]> | undefined;\n\n private models = new Map<string, EntityType | ComplexType | EnumType>();\n /**\n * Stores unbound operations by their fully qualified name.\n * @private\n */\n private unboundOperationTypes = new Map<string, OperationType>();\n /**\n * Stores operations bound to an entity type by the fully qualified name of the binding entity, e.g.\n * \"Trippin.Person\".\n * @private\n */\n private entityBoundOperationTypes = new Map<string, Array<OperationType>>();\n /**\n * Stores operations bound to an entity collection by the fully qualified name of the binding entity, e.g.\n * \"Trippin.Person\".\n * @private\n */\n private entityCollectionBoundOperationTypes = new Map<string, Array<OperationType>>();\n /**\n * Stores own type definitions which map to primitive types.\n * @private\n */\n private typeDefinitions = new Map<string, string>();\n private readonly namespace2Alias: { [ns: string]: string };\n private aliases: Record<string, string> = {};\n private container: EntityContainerModel = { entitySets: {}, singletons: {}, functions: {}, actions: {} };\n\n constructor(\n namespaces: Array<NamespaceWithAlias>,\n private version: ODataVersion,\n converters: MappedConverterChains = new Map()\n ) {\n this.converters = converters;\n this.namespace2Alias = namespaces.reduce<Record<string, string>>((col, [ns, alias]) => {\n if (alias) {\n col[ns] = alias;\n }\n return col;\n }, {});\n }\n\n /**\n * OData version: 2.0 or 4.0.\n * @returns\n */\n public getODataVersion() {\n return this.version;\n }\n\n public isV2() {\n return this.version === ODataVersion.V2;\n }\n\n public isV4() {\n return this.version === ODataVersion.V4;\n }\n\n private retrieveType<T>(fqName: string, haystack: Map<string, T>): T | undefined {\n return haystack.get(fqName) || (this.aliases[fqName] ? haystack.get(this.aliases[fqName]) : undefined);\n }\n\n private addAlias(namespace: string, name: string) {\n const alias = this.namespace2Alias[namespace];\n if (alias) {\n this.aliases[withNamespace(alias, name)] = withNamespace(namespace, name);\n }\n }\n\n public addTypeDefinition(namespace: string, name: string, type: string) {\n const fqName = withNamespace(namespace, name);\n this.typeDefinitions.set(fqName, type);\n this.addAlias(namespace, name);\n }\n\n public getPrimitiveType(fqName: string): string | undefined {\n return this.retrieveType(fqName, this.typeDefinitions);\n }\n\n public getModel(fqName: string) {\n return this.retrieveType(fqName, this.models);\n }\n\n public getModelTypes(): Array<ModelType> {\n return [...this.models.values()];\n }\n\n public addEntityType(namespace: string, name: string, model: Omit<EntityType, \"dataType\">) {\n const fqName = withNamespace(namespace, name);\n\n this.models.set(fqName, { ...model, dataType: DataTypes.ModelType });\n this.addAlias(namespace, name);\n }\n\n /**\n * Get a specific model by its fully qualified name.\n *\n * @param fqName the fully qualified name of the entity\n * @returns the model type\n */\n public getEntityType(fqName: string) {\n return this.retrieveType(fqName, this.models) as EntityType;\n }\n\n /**\n * Retrieve all known EntityType models from the EDMX model.\n *\n * @returns list of model types\n */\n public getEntityTypes() {\n const ets = [...this.models.values()].filter((m): m is EntityType => m.dataType === DataTypes.ModelType);\n return this.sortModelsByInheritance(ets);\n }\n\n public addComplexType(namespace: string, name: string, model: Omit<ComplexType, \"dataType\">) {\n const fqName = withNamespace(namespace, name);\n\n this.models.set(fqName, { ...model, dataType: DataTypes.ComplexType });\n this.addAlias(namespace, name);\n }\n\n /**\n * Get a specific model by its fully qualified name.\n *\n * @param fqName the final model name that is generated\n * @returns the model type\n */\n public getComplexType(fqName: string) {\n return this.retrieveType(fqName, this.models) as ComplexType;\n }\n\n /**\n * Retrieve all known ComplexType models from the EDMX model.\n *\n * @returns list of model types\n */\n public getComplexTypes() {\n const types = [...this.models.values()].filter((m): m is ComplexType => m.dataType === DataTypes.ComplexType);\n return this.sortModelsByInheritance(types);\n }\n\n public addEnum(namespace: string, name: string, type: Omit<EnumType, \"dataType\">) {\n const fqName = withNamespace(namespace, name);\n\n this.models.set(fqName, { ...type, dataType: DataTypes.EnumType });\n this.addAlias(namespace, name);\n }\n\n /**\n * Get list of all known enums, i.e. EnumType nodes from the EDMX model.\n * @returns list of enum types\n */\n public getEnums() {\n return [...this.models.values()].filter((m): m is EnumType => m.dataType === DataTypes.EnumType);\n }\n\n public addUnboundOperationType(namespace: string, operationType: OperationType) {\n this.unboundOperationTypes.set(operationType.fqName, operationType);\n this.addAlias(namespace, operationType.odataName);\n }\n\n public getUnboundOperationTypes(): Array<OperationType> {\n return [...this.unboundOperationTypes.values()];\n }\n\n public getUnboundOperationType(fqOpName: string): OperationType | undefined {\n return this.retrieveType(fqOpName, this.unboundOperationTypes);\n }\n\n public addBoundOperationType(namespace: string, bindingProp: PropertyModel, operationType: OperationType) {\n const fqEntityType = bindingProp.fqType;\n\n const store = bindingProp.isCollection ? this.entityCollectionBoundOperationTypes : this.entityBoundOperationTypes;\n const list = store.get(fqEntityType);\n if (list) {\n list.push(operationType);\n } else {\n store.set(fqEntityType, [operationType]);\n }\n }\n\n public getEntityTypeOperations(fqEntityName: string): Array<OperationType> {\n const operations = this.retrieveType(fqEntityName, this.entityBoundOperationTypes);\n return operations || [];\n }\n\n public getEntitySetOperations(fqEntityName: string): Array<OperationType> {\n const operations = this.retrieveType(fqEntityName, this.entityCollectionBoundOperationTypes);\n return operations || [];\n }\n\n public getAllEntityOperations(fqEntityName: string): Array<OperationType> {\n return [...this.getEntityTypeOperations(fqEntityName), ...this.getEntitySetOperations(fqEntityName)];\n }\n\n public addAction(fqName: string, action: ActionImportType) {\n this.container.actions[fqName] = action;\n }\n\n public addFunction(fqName: string, func: FunctionImportType) {\n this.container.functions[fqName] = func;\n }\n\n public addSingleton(fqName: string, singleton: SingletonType) {\n this.container.singletons[fqName] = singleton;\n }\n\n public addEntitySet(fqName: string, entitySet: EntitySetType) {\n this.container.entitySets[fqName] = entitySet;\n }\n\n public getEntityContainer() {\n return this.container;\n }\n\n public getConverter(dataType: ODataTypesV2 | ODataTypesV4 | string) {\n return this.converters.get(dataType);\n }\n\n private sortModelsByInheritance<Type extends Omit<ComplexType, \"dataType\">>(models: Array<Type>): Array<Type> {\n // recursively visit all models and sort them by inheritance such that base classes\n // are always before derived classes\n const sorted: Array<Type> = [];\n const visitedModels = new Set<string>();\n const inProgressModels = new Set<string>();\n\n function visit(model: Type) {\n const fqName = model.fqName;\n if (inProgressModels.has(fqName)) {\n throw new Error(`Cyclic inheritance detected for model \"${fqName}\"!`);\n }\n\n if (!visitedModels.has(fqName)) {\n inProgressModels.add(fqName);\n\n for (const baseClassName of model.baseClasses) {\n const baseClass = models.find((e) => e.fqName === baseClassName);\n if (baseClass) {\n visit(baseClass);\n }\n }\n visitedModels.add(fqName);\n inProgressModels.delete(fqName);\n sorted.push(model);\n }\n }\n\n for (const model of models) {\n visit(model);\n }\n return sorted;\n }\n\n public setNameValidation(map: Map<string, ValidationError[]>) {\n this.nameValidation = map;\n }\n\n public getNameValidation() {\n return this.nameValidation!;\n }\n}\n"]}
1
+ {"version":3,"file":"DataModel.js","sourceRoot":"","sources":["../../src/data-model/DataModel.ts"],"names":[],"mappings":";;;AAGA,mDAcyB;AAczB,SAAgB,aAAa,CAAC,EAAU,EAAE,IAAY;IACpD,oHAAoH;IACpH,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACrC,CAAC;AAHD,sCAGC;AAED,MAAa,SAAS;IA+BpB,YACE,UAAqC,EAC7B,OAAqB,EAC7B,aAAoC,IAAI,GAAG,EAAE;QADrC,YAAO,GAAP,OAAO,CAAc;QA7BvB,WAAM,GAAG,IAAI,GAAG,EAA+C,CAAC;QACxE;;;WAGG;QACK,0BAAqB,GAAG,IAAI,GAAG,EAAyB,CAAC;QACjE;;;;WAIG;QACK,8BAAyB,GAAG,IAAI,GAAG,EAAgC,CAAC;QAC5E;;;;WAIG;QACK,wCAAmC,GAAG,IAAI,GAAG,EAAgC,CAAC;QACtF;;;WAGG;QACK,oBAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;QAE5C,YAAO,GAA2B,EAAE,CAAC;QACrC,cAAS,GAAyB,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAOvG,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,UAAU,CAAC,MAAM,CAAyB,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE;YACpF,IAAI,KAAK,EAAE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ACD,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAC1B,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAChC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpB;QACH,CAAC;QAED,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,KAAK,CAAC,KAAK,CAAC,CAAC;SACd;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,iBAAiB,CAAC,GAAmC;QAC1D,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC;IAC5B,CAAC;IAEM,iBAAiB;QACtB,OAAO,IAAI,CAAC,cAAe,CAAC;IAC9B,CAAC;CACF;AAvQD,8BAuQC","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\nimport { ODataTypesV2, ODataTypesV4 } from \"@odata2ts/odata-core\";\r\n\r\nimport {\r\n ActionImportType,\r\n ComplexType,\r\n DataTypes,\r\n EntityContainerModel,\r\n EntitySetType,\r\n EntityType,\r\n EnumType,\r\n FunctionImportType,\r\n ModelType,\r\n ODataVersion,\r\n OperationType,\r\n PropertyModel,\r\n SingletonType,\r\n} from \"./DataTypeModel\";\r\nimport { ValidationError } from \"./validation/NameValidator\";\r\n\r\nexport interface ProjectFiles {\r\n model: string;\r\n qObject: string;\r\n service: string;\r\n}\r\n\r\n/**\r\n * Each namespace is represented as tuple: 1. the namespace 2. the alias, if any.\r\n */\r\nexport type NamespaceWithAlias = [string, string?];\r\n\r\nexport function withNamespace(ns: string, name: string) {\r\n // this supports the edge case of an empty string as namespace which isn't really valid according to spec (see CSDL)\r\n return ns ? `${ns}.${name}` : name;\r\n}\r\n\r\nexport class DataModel {\r\n private readonly converters: MappedConverterChains;\r\n private nameValidation: Map<string, ValidationError[]> | undefined;\r\n\r\n private models = new Map<string, EntityType | ComplexType | EnumType>();\r\n /**\r\n * Stores unbound operations by their fully qualified name.\r\n * @private\r\n */\r\n private unboundOperationTypes = new Map<string, OperationType>();\r\n /**\r\n * Stores operations bound to an entity type by the fully qualified name of the binding entity, e.g.\r\n * \"Trippin.Person\".\r\n * @private\r\n */\r\n private entityBoundOperationTypes = new Map<string, Array<OperationType>>();\r\n /**\r\n * Stores operations bound to an entity collection by the fully qualified name of the binding entity, e.g.\r\n * \"Trippin.Person\".\r\n * @private\r\n */\r\n private entityCollectionBoundOperationTypes = new Map<string, Array<OperationType>>();\r\n /**\r\n * Stores own type definitions which map to primitive types.\r\n * @private\r\n */\r\n private typeDefinitions = new Map<string, string>();\r\n private readonly namespace2Alias: { [ns: string]: string };\r\n private aliases: Record<string, string> = {};\r\n private container: EntityContainerModel = { entitySets: {}, singletons: {}, functions: {}, actions: {} };\r\n\r\n constructor(\r\n namespaces: Array<NamespaceWithAlias>,\r\n private version: ODataVersion,\r\n converters: MappedConverterChains = new Map()\r\n ) {\r\n this.converters = converters;\r\n this.namespace2Alias = namespaces.reduce<Record<string, string>>((col, [ns, alias]) => {\r\n if (alias) {\r\n col[ns] = alias;\r\n }\r\n return col;\r\n }, {});\r\n }\r\n\r\n /**\r\n * OData version: 2.0 or 4.0.\r\n * @returns\r\n */\r\n public getODataVersion() {\r\n return this.version;\r\n }\r\n\r\n public isV2() {\r\n return this.version === ODataVersion.V2;\r\n }\r\n\r\n public isV4() {\r\n return this.version === ODataVersion.V4;\r\n }\r\n\r\n private retrieveType<T>(fqName: string, haystack: Map<string, T>): T | undefined {\r\n return haystack.get(fqName) || (this.aliases[fqName] ? haystack.get(this.aliases[fqName]) : undefined);\r\n }\r\n\r\n private addAlias(namespace: string, name: string) {\r\n const alias = this.namespace2Alias[namespace];\r\n if (alias) {\r\n this.aliases[withNamespace(alias, name)] = withNamespace(namespace, name);\r\n }\r\n }\r\n\r\n public addTypeDefinition(namespace: string, name: string, type: string) {\r\n const fqName = withNamespace(namespace, name);\r\n this.typeDefinitions.set(fqName, type);\r\n this.addAlias(namespace, name);\r\n }\r\n\r\n public getPrimitiveType(fqName: string): string | undefined {\r\n return this.retrieveType(fqName, this.typeDefinitions);\r\n }\r\n\r\n public getModel(fqName: string) {\r\n return this.retrieveType(fqName, this.models);\r\n }\r\n\r\n public getModelTypes(): Array<ModelType> {\r\n return [...this.models.values()];\r\n }\r\n\r\n public addEntityType(namespace: string, name: string, model: Omit<EntityType, \"dataType\">) {\r\n const fqName = withNamespace(namespace, name);\r\n\r\n this.models.set(fqName, { ...model, dataType: DataTypes.ModelType });\r\n this.addAlias(namespace, name);\r\n }\r\n\r\n /**\r\n * Get a specific model by its fully qualified name.\r\n *\r\n * @param fqName the fully qualified name of the entity\r\n * @returns the model type\r\n */\r\n public getEntityType(fqName: string) {\r\n return this.retrieveType(fqName, this.models) as EntityType;\r\n }\r\n\r\n /**\r\n * Retrieve all known EntityType models from the EDMX model.\r\n *\r\n * @returns list of model types\r\n */\r\n public getEntityTypes() {\r\n const ets = [...this.models.values()].filter((m): m is EntityType => m.dataType === DataTypes.ModelType);\r\n return this.sortModelsByInheritance(ets);\r\n }\r\n\r\n public addComplexType(namespace: string, name: string, model: Omit<ComplexType, \"dataType\">) {\r\n const fqName = withNamespace(namespace, name);\r\n\r\n this.models.set(fqName, { ...model, dataType: DataTypes.ComplexType });\r\n this.addAlias(namespace, name);\r\n }\r\n\r\n /**\r\n * Get a specific model by its fully qualified name.\r\n *\r\n * @param fqName the final model name that is generated\r\n * @returns the model type\r\n */\r\n public getComplexType(fqName: string) {\r\n return this.retrieveType(fqName, this.models) as ComplexType;\r\n }\r\n\r\n /**\r\n * Retrieve all known ComplexType models from the EDMX model.\r\n *\r\n * @returns list of model types\r\n */\r\n public getComplexTypes() {\r\n const types = [...this.models.values()].filter((m): m is ComplexType => m.dataType === DataTypes.ComplexType);\r\n return this.sortModelsByInheritance(types);\r\n }\r\n\r\n public addEnum(namespace: string, name: string, type: Omit<EnumType, \"dataType\">) {\r\n const fqName = withNamespace(namespace, name);\r\n\r\n this.models.set(fqName, { ...type, dataType: DataTypes.EnumType });\r\n this.addAlias(namespace, name);\r\n }\r\n\r\n /**\r\n * Get list of all known enums, i.e. EnumType nodes from the EDMX model.\r\n * @returns list of enum types\r\n */\r\n public getEnums() {\r\n return [...this.models.values()].filter((m): m is EnumType => m.dataType === DataTypes.EnumType);\r\n }\r\n\r\n public addUnboundOperationType(namespace: string, operationType: OperationType) {\r\n this.unboundOperationTypes.set(operationType.fqName, operationType);\r\n this.addAlias(namespace, operationType.odataName);\r\n }\r\n\r\n public getUnboundOperationTypes(): Array<OperationType> {\r\n return [...this.unboundOperationTypes.values()];\r\n }\r\n\r\n public getUnboundOperationType(fqOpName: string): OperationType | undefined {\r\n return this.retrieveType(fqOpName, this.unboundOperationTypes);\r\n }\r\n\r\n public addBoundOperationType(namespace: string, bindingProp: PropertyModel, operationType: OperationType) {\r\n const fqEntityType = bindingProp.fqType;\r\n\r\n const store = bindingProp.isCollection ? this.entityCollectionBoundOperationTypes : this.entityBoundOperationTypes;\r\n const list = store.get(fqEntityType);\r\n if (list) {\r\n list.push(operationType);\r\n } else {\r\n store.set(fqEntityType, [operationType]);\r\n }\r\n }\r\n\r\n public getEntityTypeOperations(fqEntityName: string): Array<OperationType> {\r\n const operations = this.retrieveType(fqEntityName, this.entityBoundOperationTypes);\r\n return operations || [];\r\n }\r\n\r\n public getEntitySetOperations(fqEntityName: string): Array<OperationType> {\r\n const operations = this.retrieveType(fqEntityName, this.entityCollectionBoundOperationTypes);\r\n return operations || [];\r\n }\r\n\r\n public getAllEntityOperations(fqEntityName: string): Array<OperationType> {\r\n return [...this.getEntityTypeOperations(fqEntityName), ...this.getEntitySetOperations(fqEntityName)];\r\n }\r\n\r\n public addAction(fqName: string, action: ActionImportType) {\r\n this.container.actions[fqName] = action;\r\n }\r\n\r\n public addFunction(fqName: string, func: FunctionImportType) {\r\n this.container.functions[fqName] = func;\r\n }\r\n\r\n public addSingleton(fqName: string, singleton: SingletonType) {\r\n this.container.singletons[fqName] = singleton;\r\n }\r\n\r\n public addEntitySet(fqName: string, entitySet: EntitySetType) {\r\n this.container.entitySets[fqName] = entitySet;\r\n }\r\n\r\n public getEntityContainer() {\r\n return this.container;\r\n }\r\n\r\n public getConverter(dataType: ODataTypesV2 | ODataTypesV4 | string) {\r\n return this.converters.get(dataType);\r\n }\r\n\r\n private sortModelsByInheritance<Type extends Omit<ComplexType, \"dataType\">>(models: Array<Type>): Array<Type> {\r\n // recursively visit all models and sort them by inheritance such that base classes\r\n // are always before derived classes\r\n const sorted: Array<Type> = [];\r\n const visitedModels = new Set<string>();\r\n const inProgressModels = new Set<string>();\r\n\r\n function visit(model: Type) {\r\n const fqName = model.fqName;\r\n if (inProgressModels.has(fqName)) {\r\n throw new Error(`Cyclic inheritance detected for model \"${fqName}\"!`);\r\n }\r\n\r\n if (!visitedModels.has(fqName)) {\r\n inProgressModels.add(fqName);\r\n\r\n for (const baseClassName of model.baseClasses) {\r\n const baseClass = models.find((e) => e.fqName === baseClassName);\r\n if (baseClass) {\r\n visit(baseClass);\r\n }\r\n }\r\n visitedModels.add(fqName);\r\n inProgressModels.delete(fqName);\r\n sorted.push(model);\r\n }\r\n }\r\n\r\n for (const model of models) {\r\n visit(model);\r\n }\r\n return sorted;\r\n }\r\n\r\n public setNameValidation(map: Map<string, ValidationError[]>) {\r\n this.nameValidation = map;\r\n }\r\n\r\n public getNameValidation() {\r\n return this.nameValidation!;\r\n }\r\n}\r\n"]}
@@ -190,6 +190,7 @@ class Digester {
190
190
  }
191
191
  }
192
192
  addEnum(namespace, models) {
193
+ var _a;
193
194
  if (!models || !models.length) {
194
195
  return;
195
196
  }
@@ -205,7 +206,7 @@ class Digester {
205
206
  name: enumName,
206
207
  modelName: this.namingHelper.getEnumName(enumName),
207
208
  folderPath: filePath,
208
- members: et.Member.map((m) => m.$.Name),
209
+ members: ((_a = et.Member) === null || _a === void 0 ? void 0 : _a.length) ? et.Member.map((m) => m.$.Name) : [],
209
210
  });
210
211
  }
211
212
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DataModelDigestion.js","sourceRoot":"","sources":["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AS,CAAC;gBAClC,OAAO,GAAG,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC;aAChC;YACD,IAAI,SAAS,CAAC,IAAI,EAAE;gBAClB,IAAI,GAAG,IAAI,CAAC;aACb;YACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC,EACD,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAmB,CACnF,CAAC;IACJ,CAAC;;AAvUH,4BAuaC;AAtakB,mBAAU,GAAG,MAAM,AAAT,CAAU","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { ComplexTypeGenerationOptions, EntityTypeGenerationOptions, PropertyGenerationOptions } from \"../OptionModel\";\r\nimport { DataModel, NamespaceWithAlias, withNamespace } from \"./DataModel\";\r\nimport {\r\n ComplexType as ComplexModelType,\r\n DataTypes,\r\n EntityType as EntityModelType,\r\n ODataVersion,\r\n PropertyModel,\r\n} from \"./DataTypeModel\";\r\nimport { ComplexType, EntityType, EnumType, Property, Schema, TypeDefinition } from \"./edmx/ODataEdmxModelBase\";\r\nimport { SchemaV3 } from \"./edmx/ODataEdmxModelV3\";\r\nimport { SchemaV4 } from \"./edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\nimport { ServiceConfigHelper, WithoutName } from \"./ServiceConfigHelper\";\r\nimport { NameClashValidator } from \"./validation/NameClashValidator\";\r\nimport { NameValidator } from \"./validation/NameValidator\";\r\nimport { NoopValidator } from \"./validation/NoopValidator\";\r\n\r\ntype CollectorTuple = [\r\n Array<PropertyModel>,\r\n Array<string>,\r\n { fqIdName: string; idName: string; qIdName: string; open: boolean }\r\n];\r\n\r\nfunction ifTrue(value: string | undefined): boolean {\r\n return value === \"true\";\r\n}\r\n\r\nfunction ifFalse(value: string | undefined): boolean {\r\n return value === \"false\";\r\n}\r\n\r\nexport interface TypeModel {\r\n outputType: string;\r\n qPath: string;\r\n qCollection: string;\r\n qParam: string | undefined;\r\n}\r\n\r\nexport abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {\r\n protected static EDM_PREFIX = \"Edm.\";\r\n\r\n protected readonly dataModel: DataModel;\r\n protected readonly serviceConfigHelper: ServiceConfigHelper;\r\n protected readonly nameValidator: NameValidator;\r\n\r\n private model2Type = new Map<string, DataTypes>();\r\n\r\n protected constructor(\r\n protected version: ODataVersion,\r\n protected schemas: Array<S>,\r\n protected options: DigestionOptions,\r\n protected namingHelper: NamingHelper,\r\n converters?: MappedConverterChains\r\n ) {\r\n const namespaces = schemas.map<NamespaceWithAlias>((s) => [s.$.Namespace, s.$.Alias]);\r\n this.dataModel = new DataModel(namespaces, version, converters);\r\n this.serviceConfigHelper = new ServiceConfigHelper(options);\r\n this.nameValidator = this.options.bundledFileGeneration ? new NameClashValidator(options) : new NoopValidator();\r\n\r\n this.collectModelTypes(schemas);\r\n }\r\n\r\n private collectModelTypes(schemas: Array<S>) {\r\n schemas.forEach((schema) => {\r\n const { Namespace: ns, Alias: alias } = schema.$;\r\n\r\n schema.EnumType?.forEach((et) => {\r\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.EnumType);\r\n });\r\n schema.ComplexType?.forEach((ct) => {\r\n this.addModel2Type(ns, alias, ct.$.Name, DataTypes.ComplexType);\r\n });\r\n schema.EntityType?.forEach((et) => {\r\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.ModelType);\r\n });\r\n });\r\n }\r\n\r\n private addModel2Type(ns: string, alias: string | undefined, name: string, dt: DataTypes) {\r\n this.model2Type.set(withNamespace(ns, name), dt);\r\n if (alias) {\r\n this.model2Type.set(withNamespace(alias, name), dt);\r\n }\r\n }\r\n\r\n protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;\r\n\r\n protected abstract digestOperations(schema: SchemaV3 | SchemaV4): void;\r\n\r\n protected abstract digestEntityContainer(schema: SchemaV3 | SchemaV4): void;\r\n\r\n /**\r\n * Get essential infos about a given odata type from the version specific service variants.\r\n *\r\n * @param type\r\n * @return tuple of return type, query object, query collection object\r\n */\r\n protected abstract mapODataType(type: string): TypeModel;\r\n\r\n public async digest(): Promise<DataModel> {\r\n this.digestEntityTypesAndOperations();\r\n\r\n // delegate to version specific entity container digestion\r\n this.schemas.forEach((schema) => this.digestEntityContainer(schema));\r\n\r\n this.dataModel.setNameValidation(this.nameValidator.validate());\r\n return this.dataModel;\r\n }\r\n\r\n private digestEntityTypesAndOperations() {\r\n this.schemas.forEach((schema) => {\r\n const ns: NamespaceWithAlias = [schema.$.Namespace, schema.$.Alias];\r\n\r\n // type definitions: alias for primitive types\r\n this.addTypeDefinition(schema.$.Namespace, schema.TypeDefinition);\r\n\r\n // enums\r\n this.addEnum(ns, schema.EnumType);\r\n\r\n // complex types\r\n this.addComplexType(ns, schema.ComplexType);\r\n\r\n // entity types\r\n this.addEntityType(ns, schema.EntityType);\r\n\r\n // V4 only: function & action types\r\n this.digestOperations(schema);\r\n });\r\n\r\n this.postProcessModel();\r\n this.postProcessKeys();\r\n }\r\n\r\n private getBaseModel(\r\n entityConfig: WithoutName<EntityTypeGenerationOptions | ComplexTypeGenerationOptions> | undefined,\r\n model: ComplexType,\r\n namespace: string,\r\n name: string,\r\n fqName: string\r\n ) {\r\n const odataName = model.$.Name;\r\n\r\n // map properties respecting the config\r\n const props = [...(model.Property ?? []), ...this.getNavigationProps(model)].map((p) => {\r\n const epConfig = entityConfig?.properties?.find((ep) => ep.name === p.$.Name);\r\n return this.mapProp(p, epConfig);\r\n });\r\n\r\n // support for base types, i.e. extends clause of interfaces\r\n const baseClasses = [];\r\n let finalBaseClass: string | undefined = undefined;\r\n if (model.$.BaseType) {\r\n baseClasses.push(model.$.BaseType);\r\n const [baseName, basePrefix] = this.namingHelper.getNameAndServicePrefix(model.$.BaseType);\r\n const baseConfig =\r\n this.serviceConfigHelper.findEntityTypeConfig([basePrefix!], baseName) ||\r\n this.serviceConfigHelper.findComplexTypeConfig([basePrefix!], baseName);\r\n finalBaseClass = baseConfig?.mappedName ?? baseName;\r\n }\r\n\r\n return {\r\n fqName,\r\n odataName,\r\n name,\r\n modelName: this.namingHelper.getModelName(name),\r\n qName: this.namingHelper.getQName(name),\r\n editableName: this.namingHelper.getEditableModelName(name),\r\n serviceName: this.namingHelper.getServiceName(name),\r\n serviceCollectionName: this.namingHelper.getCollectionServiceName(name),\r\n folderPath: this.namingHelper.getFolderPath(namespace, name),\r\n baseClasses,\r\n finalBaseClass,\r\n props,\r\n baseProps: [], // postprocess required\r\n abstract: ifTrue(model.$.Abstract),\r\n open: ifTrue(model.$.OpenType),\r\n };\r\n }\r\n\r\n private addTypeDefinition(ns: string, types: Array<TypeDefinition> | undefined) {\r\n if (!types || !types.length) {\r\n return;\r\n }\r\n\r\n for (const t of types) {\r\n this.dataModel.addTypeDefinition(ns, t.$.Name, t.$.UnderlyingType);\r\n }\r\n }\r\n\r\n private addEnum(namespace: NamespaceWithAlias, models: Array<EnumType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const et of models) {\r\n const odataName = et.$.Name;\r\n const fqName = withNamespace(namespace[0], odataName);\r\n const config = this.serviceConfigHelper.findEnumTypeConfig(namespace, odataName);\r\n const enumName = this.nameValidator.addEnumType(fqName, config?.mappedName || odataName);\r\n const filePath = this.namingHelper.getFolderPath(namespace[0], enumName);\r\n this.dataModel.addEnum(namespace[0], odataName, {\r\n fqName,\r\n odataName,\r\n name: enumName,\r\n modelName: this.namingHelper.getEnumName(enumName),\r\n folderPath: filePath,\r\n members: et.Member.map((m) => m.$.Name),\r\n });\r\n }\r\n }\r\n\r\n private addComplexType(namespace: NamespaceWithAlias, models: Array<ComplexType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const config = this.serviceConfigHelper.findComplexTypeConfig(namespace, model.$.Name);\r\n const fqName = withNamespace(namespace[0], model.$.Name);\r\n const name = this.nameValidator.addComplexType(fqName, config?.mappedName || model.$.Name);\r\n const baseModel = this.getBaseModel(config, model, namespace[0], name, fqName);\r\n this.dataModel.addComplexType(namespace[0], baseModel.odataName, baseModel);\r\n }\r\n }\r\n\r\n private addEntityType(namespace: NamespaceWithAlias, models: Array<ET> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const entityConfig = this.serviceConfigHelper.findEntityTypeConfig(namespace, model.$.Name);\r\n const fqName = withNamespace(namespace[0], model.$.Name);\r\n const name = this.nameValidator.addEntityType(fqName, entityConfig?.mappedName || model.$.Name);\r\n const baseModel = this.getBaseModel(entityConfig, model, namespace[0], name, fqName);\r\n\r\n // key support: we add keys from this entity,\r\n // but not keys stemming from base classes (postprocess required)\r\n const keyNames: Array<string> = [];\r\n if (entityConfig?.keys?.length) {\r\n keyNames.push(...entityConfig.keys);\r\n } else {\r\n const entity = model as EntityType;\r\n if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {\r\n const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);\r\n keyNames.push(...propNames);\r\n }\r\n }\r\n\r\n this.dataModel.addEntityType(namespace[0], baseModel.odataName, {\r\n ...baseModel,\r\n id: {\r\n fqName: baseModel.fqName,\r\n modelName: this.namingHelper.getIdModelName(name),\r\n qName: this.namingHelper.getQIdFunctionName(name),\r\n },\r\n generateId: !!keyNames.length,\r\n keyNames: keyNames, // postprocess required to include key specs from base classes\r\n keys: [], // postprocess required to include props from base classes\r\n getKeyUnion: () => keyNames.join(\" | \"),\r\n });\r\n }\r\n }\r\n\r\n private postProcessModel() {\r\n // complex types\r\n const complexTypes = this.dataModel.getComplexTypes();\r\n complexTypes.forEach((ct) => {\r\n const [baseProps, _, baseAttributes] = this.collectBaseClassPropsAndKeys(ct, []);\r\n const { open } = baseAttributes;\r\n ct.baseProps = baseProps.map((bp) => ({ ...bp }));\r\n if (open) {\r\n ct.open = true;\r\n }\r\n });\r\n // entity types\r\n const entityTypes = this.dataModel.getEntityTypes();\r\n entityTypes.forEach((et) => {\r\n const [baseProps, baseKeys, baseAttributes] = this.collectBaseClassPropsAndKeys(et, []);\r\n const { fqIdName, idName, qIdName, open } = baseAttributes;\r\n et.baseProps = baseProps.map((bp) => ({ ...bp }));\r\n\r\n if (!et.keyNames.length && idName) {\r\n et.id = {\r\n fqName: fqIdName,\r\n modelName: idName,\r\n qName: qIdName,\r\n };\r\n et.generateId = false;\r\n }\r\n if (open) {\r\n et.open = open;\r\n }\r\n et.keyNames.unshift(...baseKeys.filter((bk) => !et.keyNames.includes(bk)));\r\n });\r\n }\r\n\r\n private postProcessKeys() {\r\n const entityTypes = this.dataModel.getEntityTypes();\r\n entityTypes.forEach((et) => {\r\n const isSingleKey = et.keyNames.length === 1;\r\n const props = [...et.baseProps, ...et.props];\r\n et.keys = et.keyNames.map((keyName) => {\r\n const prop = props.find((p) => p.odataName === keyName);\r\n if (!prop) {\r\n throw new Error(`Key with name [${keyName}] not found in props!`);\r\n }\r\n\r\n // automatically set key prop to managed, if this is the only key of the given entity\r\n if (prop.managed === undefined) {\r\n prop.managed = !this.options.disableAutoManagedKey && isSingleKey;\r\n }\r\n\r\n return prop;\r\n });\r\n });\r\n }\r\n\r\n private collectBaseClassPropsAndKeys(model: ComplexModelType, visitedModels: string[]): CollectorTuple {\r\n if (visitedModels.includes(model.fqName)) {\r\n throw new Error(`Cyclic inheritance detected for model ${model.fqName}!`);\r\n }\r\n visitedModels.push(model.fqName);\r\n return model.baseClasses.reduce(\r\n ([props, keys, attributes], bc) => {\r\n const baseModel = this.dataModel.getEntityType(bc) || this.dataModel.getComplexType(bc);\r\n if (!baseModel) {\r\n throw new Error(`BaseModel \"${bc}\" doesn't exist!`);\r\n }\r\n\r\n let { fqIdName, idName, qIdName, open } = attributes;\r\n\r\n // recursive\r\n if (baseModel.baseClasses.length) {\r\n const [parentProps, parentKeys, parentAttributes] = this.collectBaseClassPropsAndKeys(\r\n baseModel,\r\n visitedModels\r\n );\r\n props.unshift(...parentProps);\r\n keys.unshift(...parentKeys);\r\n if (parentAttributes?.idName) {\r\n fqIdName = parentAttributes.fqIdName;\r\n idName = parentAttributes.idName;\r\n qIdName = parentAttributes.qIdName;\r\n }\r\n if (parentAttributes?.open) {\r\n open = true;\r\n }\r\n }\r\n\r\n props.push(...baseModel.props);\r\n const entityModel = baseModel as EntityModelType;\r\n if (entityModel.keyNames?.length) {\r\n keys.push(...entityModel.keyNames.filter((kn) => !keys.includes(kn)));\r\n fqIdName = entityModel.id.fqName;\r\n idName = entityModel.id.modelName;\r\n qIdName = entityModel.id.qName;\r\n }\r\n if (baseModel.open) {\r\n open = true;\r\n }\r\n return [props, keys, { fqIdName, idName, qIdName, open }];\r\n },\r\n [[], [], { fqIdName: \"\", idName: \"\", qIdName: \"\", open: false }] as CollectorTuple\r\n );\r\n }\r\n\r\n protected mapProp = (p: Property, entityPropConfig?: PropertyGenerationOptions | undefined): PropertyModel => {\r\n if (!p.$.Type) {\r\n throw new Error(`No type information given for property [${p.$.Name}]!`);\r\n }\r\n\r\n const configProp = this.serviceConfigHelper.findPropConfigByName(p.$.Name);\r\n const modelName = this.namingHelper.getModelPropName(\r\n entityPropConfig?.mappedName || configProp?.mappedName || p.$.Name\r\n );\r\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\r\n let dataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\r\n\r\n // support for primitive type mapping\r\n if (this.namingHelper.includesServicePrefix(dataType)) {\r\n const dt = this.dataModel.getPrimitiveType(dataType);\r\n if (dt !== undefined) {\r\n dataType = dt;\r\n }\r\n }\r\n\r\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\r\n\r\n // domain object known from service:\r\n // EntityType, ComplexType, EnumType\r\n if (this.namingHelper.includesServicePrefix(dataType)) {\r\n const resultDt = this.model2Type.get(dataType)!;\r\n const [dataTypeName, dataTypePrefix] = this.namingHelper.getNameAndServicePrefix(dataType);\r\n const dataTypeNamespace: NamespaceWithAlias = [dataTypePrefix!];\r\n if (!resultDt) {\r\n throw new Error(\r\n `Couldn't determine model data type for property \"${p.$.Name}\"! Given data type: \"${dataType}\".`\r\n );\r\n }\r\n\r\n // special handling for enums\r\n if (resultDt === DataTypes.EnumType) {\r\n const enumConfig = this.serviceConfigHelper.findEnumTypeConfig(dataTypeNamespace, dataTypeName);\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getEnumName(enumConfig?.mappedName ?? dataType),\r\n qPath: \"QEnumPath\",\r\n qObject: isCollection ? \"QEnumCollection\" : undefined,\r\n qParam: \"QEnumParam\",\r\n };\r\n }\r\n // handling of complex & entity types\r\n else {\r\n const entityConfig =\r\n resultDt === DataTypes.ComplexType\r\n ? this.serviceConfigHelper.findComplexTypeConfig(dataTypeNamespace, dataTypeName)\r\n : this.serviceConfigHelper.findEntityTypeConfig(dataTypeNamespace, dataTypeName);\r\n const resultDataType = entityConfig?.mappedName ?? dataType;\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getModelName(resultDataType),\r\n qPath: \"QEntityPath\",\r\n qObject: this.namingHelper.getQName(resultDataType),\r\n qParam: \"QComplexParam\",\r\n };\r\n }\r\n }\r\n // OData built-in data types\r\n else if (dataType.startsWith(Digester.EDM_PREFIX)) {\r\n const { outputType, qPath, qParam, qCollection } = this.mapODataType(dataType);\r\n const { to, toModule: typeModule, converters } = this.dataModel.getConverter(dataType) || {};\r\n\r\n const type = !to ? outputType : to.startsWith(Digester.EDM_PREFIX) ? this.mapODataType(to).outputType : to;\r\n\r\n result = {\r\n dataType: DataTypes.PrimitiveType,\r\n type,\r\n typeModule,\r\n qPath,\r\n qParam,\r\n qObject: isCollection ? qCollection : undefined,\r\n converters,\r\n };\r\n } else {\r\n throw new Error(\r\n `Unknown type [${dataType}]: Not 'Collection(...)', not OData type 'Edm.*', not starting with one of the namespaces!`\r\n );\r\n }\r\n\r\n return {\r\n odataName: p.$.Name,\r\n name: modelName,\r\n odataType: p.$.Type,\r\n fqType: dataType,\r\n required: ifFalse(p.$.Nullable),\r\n isCollection: isCollection,\r\n managed: typeof entityPropConfig?.managed !== \"undefined\" ? entityPropConfig.managed : configProp?.managed,\r\n ...result,\r\n };\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"DataModelDigestion.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestion.ts"],"names":[],"mappings":";;;;AAIA,2CAA2E;AAY3E,+DAAyE;AACzE,wEAAqE;AAErE,8DAA2D;AAQ3D,SAAS,MAAM,CAAC,KAAyB;IACvC,OAAO,KAAK,KAAK,MAAM,CAAC;AAC1B,CAAC;AAED,SAAS,OAAO,CAAC,KAAyB;IACxC,OAAO,KAAK,KAAK,OAAO,CAAC;AAC3B,CAAC;AASD,MAAsB,QAAQ;IAS5B,YACY,OAAqB,EACrB,OAAiB,EACjB,OAAyB,EACzB,YAA0B,EACpC,UAAkC;QAJxB,YAAO,GAAP,OAAO,CAAc;QACrB,YAAO,GAAP,OAAO,CAAU;QACjB,YAAO,GAAP,OAAO,CAAkB;QACzB,iBAAY,GAAZ,YAAY,CAAc;QAN9B,eAAU,GAAG,IAAI,GAAG,EAAqB,CAAC;QAkUxC,YAAO,GAAG,CAAC,CAAW,EAAE,gBAAwD,EAAiB,EAAE;;YAC3G,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;aAC1E;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;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EAAE;oBAC1B,IAAI,GAAG,IAAI,CAAC;iBACb;aACF;YAED,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;YAC/B,MAAM,WAAW,GAAG,SAA4B,CAAC;YACjD,IAAI,MAAA,WAAW,CAAC,QAAQ,0CAAE,MAAM,EAAE;gBAChC,IAAI,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACtE,QAAQ,GAAG,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC;gBACjC,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC,SAAS,CAAC;gBAClC,OAAO,GAAG,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC;aAChC;YACD,IAAI,SAAS,CAAC,IAAI,EAAE;gBAClB,IAAI,GAAG,IAAI,CAAC;aACb;YACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC,EACD,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAmB,CACnF,CAAC;IACJ,CAAC;;AAvUH,4BAuaC;AAtakB,mBAAU,GAAG,MAAM,AAAT,CAAU","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { ComplexTypeGenerationOptions, EntityTypeGenerationOptions, PropertyGenerationOptions } from \"../OptionModel\";\r\nimport { DataModel, NamespaceWithAlias, withNamespace } from \"./DataModel\";\r\nimport {\r\n ComplexType as ComplexModelType,\r\n DataTypes,\r\n EntityType as EntityModelType,\r\n ODataVersion,\r\n PropertyModel,\r\n} from \"./DataTypeModel\";\r\nimport { ComplexType, EntityType, EnumType, Property, Schema, TypeDefinition } from \"./edmx/ODataEdmxModelBase\";\r\nimport { SchemaV3 } from \"./edmx/ODataEdmxModelV3\";\r\nimport { SchemaV4 } from \"./edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\nimport { ServiceConfigHelper, WithoutName } from \"./ServiceConfigHelper\";\r\nimport { NameClashValidator } from \"./validation/NameClashValidator\";\r\nimport { NameValidator } from \"./validation/NameValidator\";\r\nimport { NoopValidator } from \"./validation/NoopValidator\";\r\n\r\ntype CollectorTuple = [\r\n Array<PropertyModel>,\r\n Array<string>,\r\n { fqIdName: string; idName: string; qIdName: string; open: boolean }\r\n];\r\n\r\nfunction ifTrue(value: string | undefined): boolean {\r\n return value === \"true\";\r\n}\r\n\r\nfunction ifFalse(value: string | undefined): boolean {\r\n return value === \"false\";\r\n}\r\n\r\nexport interface TypeModel {\r\n outputType: string;\r\n qPath: string;\r\n qCollection: string;\r\n qParam: string | undefined;\r\n}\r\n\r\nexport abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {\r\n protected static EDM_PREFIX = \"Edm.\";\r\n\r\n protected readonly dataModel: DataModel;\r\n protected readonly serviceConfigHelper: ServiceConfigHelper;\r\n protected readonly nameValidator: NameValidator;\r\n\r\n private model2Type = new Map<string, DataTypes>();\r\n\r\n protected constructor(\r\n protected version: ODataVersion,\r\n protected schemas: Array<S>,\r\n protected options: DigestionOptions,\r\n protected namingHelper: NamingHelper,\r\n converters?: MappedConverterChains\r\n ) {\r\n const namespaces = schemas.map<NamespaceWithAlias>((s) => [s.$.Namespace, s.$.Alias]);\r\n this.dataModel = new DataModel(namespaces, version, converters);\r\n this.serviceConfigHelper = new ServiceConfigHelper(options);\r\n this.nameValidator = this.options.bundledFileGeneration ? new NameClashValidator(options) : new NoopValidator();\r\n\r\n this.collectModelTypes(schemas);\r\n }\r\n\r\n private collectModelTypes(schemas: Array<S>) {\r\n schemas.forEach((schema) => {\r\n const { Namespace: ns, Alias: alias } = schema.$;\r\n\r\n schema.EnumType?.forEach((et) => {\r\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.EnumType);\r\n });\r\n schema.ComplexType?.forEach((ct) => {\r\n this.addModel2Type(ns, alias, ct.$.Name, DataTypes.ComplexType);\r\n });\r\n schema.EntityType?.forEach((et) => {\r\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.ModelType);\r\n });\r\n });\r\n }\r\n\r\n private addModel2Type(ns: string, alias: string | undefined, name: string, dt: DataTypes) {\r\n this.model2Type.set(withNamespace(ns, name), dt);\r\n if (alias) {\r\n this.model2Type.set(withNamespace(alias, name), dt);\r\n }\r\n }\r\n\r\n protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;\r\n\r\n protected abstract digestOperations(schema: SchemaV3 | SchemaV4): void;\r\n\r\n protected abstract digestEntityContainer(schema: SchemaV3 | SchemaV4): void;\r\n\r\n /**\r\n * Get essential infos about a given odata type from the version specific service variants.\r\n *\r\n * @param type\r\n * @return tuple of return type, query object, query collection object\r\n */\r\n protected abstract mapODataType(type: string): TypeModel;\r\n\r\n public async digest(): Promise<DataModel> {\r\n this.digestEntityTypesAndOperations();\r\n\r\n // delegate to version specific entity container digestion\r\n this.schemas.forEach((schema) => this.digestEntityContainer(schema));\r\n\r\n this.dataModel.setNameValidation(this.nameValidator.validate());\r\n return this.dataModel;\r\n }\r\n\r\n private digestEntityTypesAndOperations() {\r\n this.schemas.forEach((schema) => {\r\n const ns: NamespaceWithAlias = [schema.$.Namespace, schema.$.Alias];\r\n\r\n // type definitions: alias for primitive types\r\n this.addTypeDefinition(schema.$.Namespace, schema.TypeDefinition);\r\n\r\n // enums\r\n this.addEnum(ns, schema.EnumType);\r\n\r\n // complex types\r\n this.addComplexType(ns, schema.ComplexType);\r\n\r\n // entity types\r\n this.addEntityType(ns, schema.EntityType);\r\n\r\n // V4 only: function & action types\r\n this.digestOperations(schema);\r\n });\r\n\r\n this.postProcessModel();\r\n this.postProcessKeys();\r\n }\r\n\r\n private getBaseModel(\r\n entityConfig: WithoutName<EntityTypeGenerationOptions | ComplexTypeGenerationOptions> | undefined,\r\n model: ComplexType,\r\n namespace: string,\r\n name: string,\r\n fqName: string\r\n ) {\r\n const odataName = model.$.Name;\r\n\r\n // map properties respecting the config\r\n const props = [...(model.Property ?? []), ...this.getNavigationProps(model)].map((p) => {\r\n const epConfig = entityConfig?.properties?.find((ep) => ep.name === p.$.Name);\r\n return this.mapProp(p, epConfig);\r\n });\r\n\r\n // support for base types, i.e. extends clause of interfaces\r\n const baseClasses = [];\r\n let finalBaseClass: string | undefined = undefined;\r\n if (model.$.BaseType) {\r\n baseClasses.push(model.$.BaseType);\r\n const [baseName, basePrefix] = this.namingHelper.getNameAndServicePrefix(model.$.BaseType);\r\n const baseConfig =\r\n this.serviceConfigHelper.findEntityTypeConfig([basePrefix!], baseName) ||\r\n this.serviceConfigHelper.findComplexTypeConfig([basePrefix!], baseName);\r\n finalBaseClass = baseConfig?.mappedName ?? baseName;\r\n }\r\n\r\n return {\r\n fqName,\r\n odataName,\r\n name,\r\n modelName: this.namingHelper.getModelName(name),\r\n qName: this.namingHelper.getQName(name),\r\n editableName: this.namingHelper.getEditableModelName(name),\r\n serviceName: this.namingHelper.getServiceName(name),\r\n serviceCollectionName: this.namingHelper.getCollectionServiceName(name),\r\n folderPath: this.namingHelper.getFolderPath(namespace, name),\r\n baseClasses,\r\n finalBaseClass,\r\n props,\r\n baseProps: [], // postprocess required\r\n abstract: ifTrue(model.$.Abstract),\r\n open: ifTrue(model.$.OpenType),\r\n };\r\n }\r\n\r\n private addTypeDefinition(ns: string, types: Array<TypeDefinition> | undefined) {\r\n if (!types || !types.length) {\r\n return;\r\n }\r\n\r\n for (const t of types) {\r\n this.dataModel.addTypeDefinition(ns, t.$.Name, t.$.UnderlyingType);\r\n }\r\n }\r\n\r\n private addEnum(namespace: NamespaceWithAlias, models: Array<EnumType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const et of models) {\r\n const odataName = et.$.Name;\r\n const fqName = withNamespace(namespace[0], odataName);\r\n const config = this.serviceConfigHelper.findEnumTypeConfig(namespace, odataName);\r\n const enumName = this.nameValidator.addEnumType(fqName, config?.mappedName || odataName);\r\n const filePath = this.namingHelper.getFolderPath(namespace[0], enumName);\r\n this.dataModel.addEnum(namespace[0], odataName, {\r\n fqName,\r\n odataName,\r\n name: enumName,\r\n modelName: this.namingHelper.getEnumName(enumName),\r\n folderPath: filePath,\r\n members: et.Member?.length ? et.Member.map((m) => m.$.Name) : [],\r\n });\r\n }\r\n }\r\n\r\n private addComplexType(namespace: NamespaceWithAlias, models: Array<ComplexType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const config = this.serviceConfigHelper.findComplexTypeConfig(namespace, model.$.Name);\r\n const fqName = withNamespace(namespace[0], model.$.Name);\r\n const name = this.nameValidator.addComplexType(fqName, config?.mappedName || model.$.Name);\r\n const baseModel = this.getBaseModel(config, model, namespace[0], name, fqName);\r\n this.dataModel.addComplexType(namespace[0], baseModel.odataName, baseModel);\r\n }\r\n }\r\n\r\n private addEntityType(namespace: NamespaceWithAlias, models: Array<ET> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const entityConfig = this.serviceConfigHelper.findEntityTypeConfig(namespace, model.$.Name);\r\n const fqName = withNamespace(namespace[0], model.$.Name);\r\n const name = this.nameValidator.addEntityType(fqName, entityConfig?.mappedName || model.$.Name);\r\n const baseModel = this.getBaseModel(entityConfig, model, namespace[0], name, fqName);\r\n\r\n // key support: we add keys from this entity,\r\n // but not keys stemming from base classes (postprocess required)\r\n const keyNames: Array<string> = [];\r\n if (entityConfig?.keys?.length) {\r\n keyNames.push(...entityConfig.keys);\r\n } else {\r\n const entity = model as EntityType;\r\n if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {\r\n const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);\r\n keyNames.push(...propNames);\r\n }\r\n }\r\n\r\n this.dataModel.addEntityType(namespace[0], baseModel.odataName, {\r\n ...baseModel,\r\n id: {\r\n fqName: baseModel.fqName,\r\n modelName: this.namingHelper.getIdModelName(name),\r\n qName: this.namingHelper.getQIdFunctionName(name),\r\n },\r\n generateId: !!keyNames.length,\r\n keyNames: keyNames, // postprocess required to include key specs from base classes\r\n keys: [], // postprocess required to include props from base classes\r\n getKeyUnion: () => keyNames.join(\" | \"),\r\n });\r\n }\r\n }\r\n\r\n private postProcessModel() {\r\n // complex types\r\n const complexTypes = this.dataModel.getComplexTypes();\r\n complexTypes.forEach((ct) => {\r\n const [baseProps, _, baseAttributes] = this.collectBaseClassPropsAndKeys(ct, []);\r\n const { open } = baseAttributes;\r\n ct.baseProps = baseProps.map((bp) => ({ ...bp }));\r\n if (open) {\r\n ct.open = true;\r\n }\r\n });\r\n // entity types\r\n const entityTypes = this.dataModel.getEntityTypes();\r\n entityTypes.forEach((et) => {\r\n const [baseProps, baseKeys, baseAttributes] = this.collectBaseClassPropsAndKeys(et, []);\r\n const { fqIdName, idName, qIdName, open } = baseAttributes;\r\n et.baseProps = baseProps.map((bp) => ({ ...bp }));\r\n\r\n if (!et.keyNames.length && idName) {\r\n et.id = {\r\n fqName: fqIdName,\r\n modelName: idName,\r\n qName: qIdName,\r\n };\r\n et.generateId = false;\r\n }\r\n if (open) {\r\n et.open = open;\r\n }\r\n et.keyNames.unshift(...baseKeys.filter((bk) => !et.keyNames.includes(bk)));\r\n });\r\n }\r\n\r\n private postProcessKeys() {\r\n const entityTypes = this.dataModel.getEntityTypes();\r\n entityTypes.forEach((et) => {\r\n const isSingleKey = et.keyNames.length === 1;\r\n const props = [...et.baseProps, ...et.props];\r\n et.keys = et.keyNames.map((keyName) => {\r\n const prop = props.find((p) => p.odataName === keyName);\r\n if (!prop) {\r\n throw new Error(`Key with name [${keyName}] not found in props!`);\r\n }\r\n\r\n // automatically set key prop to managed, if this is the only key of the given entity\r\n if (prop.managed === undefined) {\r\n prop.managed = !this.options.disableAutoManagedKey && isSingleKey;\r\n }\r\n\r\n return prop;\r\n });\r\n });\r\n }\r\n\r\n private collectBaseClassPropsAndKeys(model: ComplexModelType, visitedModels: string[]): CollectorTuple {\r\n if (visitedModels.includes(model.fqName)) {\r\n throw new Error(`Cyclic inheritance detected for model ${model.fqName}!`);\r\n }\r\n visitedModels.push(model.fqName);\r\n return model.baseClasses.reduce(\r\n ([props, keys, attributes], bc) => {\r\n const baseModel = this.dataModel.getEntityType(bc) || this.dataModel.getComplexType(bc);\r\n if (!baseModel) {\r\n throw new Error(`BaseModel \"${bc}\" doesn't exist!`);\r\n }\r\n\r\n let { fqIdName, idName, qIdName, open } = attributes;\r\n\r\n // recursive\r\n if (baseModel.baseClasses.length) {\r\n const [parentProps, parentKeys, parentAttributes] = this.collectBaseClassPropsAndKeys(\r\n baseModel,\r\n visitedModels\r\n );\r\n props.unshift(...parentProps);\r\n keys.unshift(...parentKeys);\r\n if (parentAttributes?.idName) {\r\n fqIdName = parentAttributes.fqIdName;\r\n idName = parentAttributes.idName;\r\n qIdName = parentAttributes.qIdName;\r\n }\r\n if (parentAttributes?.open) {\r\n open = true;\r\n }\r\n }\r\n\r\n props.push(...baseModel.props);\r\n const entityModel = baseModel as EntityModelType;\r\n if (entityModel.keyNames?.length) {\r\n keys.push(...entityModel.keyNames.filter((kn) => !keys.includes(kn)));\r\n fqIdName = entityModel.id.fqName;\r\n idName = entityModel.id.modelName;\r\n qIdName = entityModel.id.qName;\r\n }\r\n if (baseModel.open) {\r\n open = true;\r\n }\r\n return [props, keys, { fqIdName, idName, qIdName, open }];\r\n },\r\n [[], [], { fqIdName: \"\", idName: \"\", qIdName: \"\", open: false }] as CollectorTuple\r\n );\r\n }\r\n\r\n protected mapProp = (p: Property, entityPropConfig?: PropertyGenerationOptions | undefined): PropertyModel => {\r\n if (!p.$.Type) {\r\n throw new Error(`No type information given for property [${p.$.Name}]!`);\r\n }\r\n\r\n const configProp = this.serviceConfigHelper.findPropConfigByName(p.$.Name);\r\n const modelName = this.namingHelper.getModelPropName(\r\n entityPropConfig?.mappedName || configProp?.mappedName || p.$.Name\r\n );\r\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\r\n let dataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\r\n\r\n // support for primitive type mapping\r\n if (this.namingHelper.includesServicePrefix(dataType)) {\r\n const dt = this.dataModel.getPrimitiveType(dataType);\r\n if (dt !== undefined) {\r\n dataType = dt;\r\n }\r\n }\r\n\r\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\r\n\r\n // domain object known from service:\r\n // EntityType, ComplexType, EnumType\r\n if (this.namingHelper.includesServicePrefix(dataType)) {\r\n const resultDt = this.model2Type.get(dataType)!;\r\n const [dataTypeName, dataTypePrefix] = this.namingHelper.getNameAndServicePrefix(dataType);\r\n const dataTypeNamespace: NamespaceWithAlias = [dataTypePrefix!];\r\n if (!resultDt) {\r\n throw new Error(\r\n `Couldn't determine model data type for property \"${p.$.Name}\"! Given data type: \"${dataType}\".`\r\n );\r\n }\r\n\r\n // special handling for enums\r\n if (resultDt === DataTypes.EnumType) {\r\n const enumConfig = this.serviceConfigHelper.findEnumTypeConfig(dataTypeNamespace, dataTypeName);\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getEnumName(enumConfig?.mappedName ?? dataType),\r\n qPath: \"QEnumPath\",\r\n qObject: isCollection ? \"QEnumCollection\" : undefined,\r\n qParam: \"QEnumParam\",\r\n };\r\n }\r\n // handling of complex & entity types\r\n else {\r\n const entityConfig =\r\n resultDt === DataTypes.ComplexType\r\n ? this.serviceConfigHelper.findComplexTypeConfig(dataTypeNamespace, dataTypeName)\r\n : this.serviceConfigHelper.findEntityTypeConfig(dataTypeNamespace, dataTypeName);\r\n const resultDataType = entityConfig?.mappedName ?? dataType;\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getModelName(resultDataType),\r\n qPath: \"QEntityPath\",\r\n qObject: this.namingHelper.getQName(resultDataType),\r\n qParam: \"QComplexParam\",\r\n };\r\n }\r\n }\r\n // OData built-in data types\r\n else if (dataType.startsWith(Digester.EDM_PREFIX)) {\r\n const { outputType, qPath, qParam, qCollection } = this.mapODataType(dataType);\r\n const { to, toModule: typeModule, converters } = this.dataModel.getConverter(dataType) || {};\r\n\r\n const type = !to ? outputType : to.startsWith(Digester.EDM_PREFIX) ? this.mapODataType(to).outputType : to;\r\n\r\n result = {\r\n dataType: DataTypes.PrimitiveType,\r\n type,\r\n typeModule,\r\n qPath,\r\n qParam,\r\n qObject: isCollection ? qCollection : undefined,\r\n converters,\r\n };\r\n } else {\r\n throw new Error(\r\n `Unknown type [${dataType}]: Not 'Collection(...)', not OData type 'Edm.*', not starting with one of the namespaces!`\r\n );\r\n }\r\n\r\n return {\r\n odataName: p.$.Name,\r\n name: modelName,\r\n odataType: p.$.Type,\r\n fqType: dataType,\r\n required: ifFalse(p.$.Nullable),\r\n isCollection: isCollection,\r\n managed: typeof entityPropConfig?.managed !== \"undefined\" ? entityPropConfig.managed : configProp?.managed,\r\n ...result,\r\n };\r\n };\r\n}\r\n"]}