@odata2ts/odata2ts 0.20.0 → 0.20.2
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,6 +3,14 @@
|
|
|
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.20.2](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.20.1...@odata2ts/odata2ts@0.20.2) (2023-04-13)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @odata2ts/odata2ts
|
|
9
|
+
|
|
10
|
+
## [0.20.1](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.20.0...@odata2ts/odata2ts@0.20.1) (2023-04-08)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @odata2ts/odata2ts
|
|
13
|
+
|
|
6
14
|
# [0.20.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.19.2...@odata2ts/odata2ts@0.20.0) (2023-04-04)
|
|
7
15
|
|
|
8
16
|
### Features
|
package/README.md
CHANGED
|
@@ -2,34 +2,74 @@
|
|
|
2
2
|
|
|
3
3
|
# odata2ts
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
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
|
+
- generation of TypeScript files or compiled JS / DTS files
|
|
14
|
+
- name or rename stuff
|
|
15
|
+
- naming of pretty much any aspect of the generated artefacts
|
|
16
|
+
- e.g. all types should be prefixed with an "I", Person => IPerson
|
|
17
|
+
- consistent casing (as in "camelCase" or "PascalCase") even for property names of entity types
|
|
18
|
+
- use type converters
|
|
19
|
+
|
|
20
|
+
See the [generator documentation](https://odata2ts.github.io/docs/generator/setup-and-usage) for more information.
|
|
7
21
|
|
|
8
22
|
## Installation
|
|
9
23
|
|
|
10
24
|
```
|
|
11
25
|
npm install --save-dev @odata2ts/odata2ts
|
|
12
|
-
|
|
13
|
-
yarn add --dev @odata2ts/odata2ts
|
|
14
26
|
```
|
|
15
27
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
### Implicit Dependencies
|
|
29
|
+
Most of the generated artefacts depend on other libraries. `odata2ts` lists them as peer dependencies.
|
|
30
|
+
|
|
31
|
+
Depending on your use case, you will need to add runtime dependencies matching the mentioned peer dependencies.
|
|
32
|
+
See the [Getting Started Guide](https://odata2ts.github.io/docs/category/getting-started/) of the documentation
|
|
33
|
+
for guidance.
|
|
20
34
|
|
|
21
35
|
## Documentation
|
|
36
|
+
[Generator Documentation](https://odata2ts.github.io/docs/generator/setup-and-usage)
|
|
37
|
+
|
|
22
38
|
Main documentation for the odata2ts eco system:
|
|
23
39
|
[https://odata2ts.github.io](https://odata2ts.github.io/)
|
|
24
40
|
|
|
41
|
+
|
|
25
42
|
## Examples
|
|
26
43
|
See [example packages](https://github.com/odata2ts/odata2ts/tree/main/examples) for examples of how to integrate `odata2ts`.
|
|
27
44
|
|
|
45
|
+
## Tests
|
|
46
|
+
See folder [test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/test)
|
|
47
|
+
for unit tests.
|
|
48
|
+
|
|
49
|
+
See folder [int-test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/int-test) for integration
|
|
50
|
+
tests of the CLI.
|
|
51
|
+
|
|
52
|
+
Each example package serves as integration test of the generator.
|
|
53
|
+
|
|
54
|
+
## Support, Feedback, Contributing
|
|
55
|
+
This project is open to feature requests, suggestions, bug reports, usage questions etc.
|
|
56
|
+
via [GitHub issues](https://github.com/odata2ts/odata2ts/issues).
|
|
57
|
+
|
|
58
|
+
Contributions and feedback are encouraged and always welcome.
|
|
59
|
+
|
|
60
|
+
See the [contribution guidelines](https://github.com/odata2ts/odata2ts/blob/main/CONTRIBUTING.md) for further information.
|
|
61
|
+
|
|
28
62
|
## Spirit
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
63
|
+
This project and this module have been created and are maintained in the following spirit:
|
|
64
|
+
|
|
65
|
+
* adhere to the **OData specification** as much as possible
|
|
66
|
+
* support any OData service implementation which conforms to the spec
|
|
67
|
+
* allow to work around faulty implementations if possible
|
|
68
|
+
* stability matters
|
|
69
|
+
* exercise Test Driven Development
|
|
70
|
+
* bomb the place with unit tests (code coverage > 95%)
|
|
71
|
+
* ensure that assumptions & understanding are correct by creating integration tests
|
|
32
72
|
|
|
33
73
|
## License
|
|
34
|
-
MIT
|
|
74
|
+
MIT - see [License](./LICENSE).
|
|
35
75
|
|
package/lib/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AAErD,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;;;;GAIG;AACH,SAAsB,MAAM,CAAC,YAAqC,EAAE,OAAmB;;;QACrF,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AAE,EAC3B,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,QAAQ,CACjB,CAAC;QAEF,4BAA4B;QAC5B,0DAA0D;QAC1D,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;QACnD,IAAA,0BAAc,EAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAEtE,yBAAyB;QACzB,gDAAgD;QAChD,mJAAmJ;QACnJ,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAChD,IAAA,gCAAoB,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACxE;QAED,oCAAoC;QACpC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;YAChC,MAAM,IAAA,4BAAgB,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACnE;QAED,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;;CAC5B;AAzDD,wBAyDC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\n\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2\";\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\nimport { ODataEdmxModelBase, Schema } 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\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\n // handling multiple schemas => merge them\n const schemaRaw = dataService.Schema.reduce(\n (collector, schema) => ({\n ...schema,\n ...collector,\n }),\n {} as Schema<any, any>\n );\n const detectedServiceName =\n dataService.Schema.length === 1\n ? dataService.Schema[0].$.Namespace\n : dataService.Schema.find((schema) => !schema.EntityContainer)?.$.Namespace;\n\n // encapsulate the whole naming logic\n const namingHelper = new NamingHelper(options, detectedServiceName, options.serviceName);\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(schemaRaw as SchemaV3, options, namingHelper)\n : await digestV4(schemaRaw as SchemaV4, options, namingHelper);\n // handling the overall generation project\n const project = await createProjectManager(\n namingHelper.getFileNames(),\n options.output,\n options.emitMode,\n options.prettier,\n options.tsconfig\n );\n\n // Generate Model Interfaces\n // supported edmx types: EntityType, ComplexType, EnumType\n const modelsFile = await project.createModelFile();\n generateModels(dataModel, modelsFile, version, options, namingHelper);\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 const qFile = await project.createQObjectFile();\n generateQueryObjects(dataModel, qFile, version, options, namingHelper);\n }\n\n // Generate Individual OData-Service\n if (isServiceGen(options.mode)) {\n await project.cleanServiceDir();\n await generateServices(dataModel, project, version, namingHelper);\n }\n\n await project.writeFiles();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AAErD,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;;;;GAIG;AACH,SAAsB,MAAM,CAAC,YAAqC,EAAE,OAAmB;;;QACrF,uCAAuC;QACvC,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACxD,MAAM,OAAO,GAAG,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,0BAAa,CAAC,EAAE,CAAC,CAAC,CAAC,0BAAa,CAAC,EAAE,CAAC;QAE5E,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtE,0CAA0C;QAC1C,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,CACzC,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC,iCAClB,MAAM,GACN,SAAS,EACZ,EACF,EAAsB,CACvB,CAAC;QACF,MAAM,mBAAmB,GACvB,WAAW,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAC7B,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAA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AO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;YAChC,MAAM,IAAA,4BAAgB,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACnE;QAED,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;;CAC5B;AAzDD,wBAyDC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\n\r\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2\";\r\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\r\nimport { ODataEdmxModelBase, Schema } 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\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\r\n // handling multiple schemas => merge them\r\n const schemaRaw = dataService.Schema.reduce(\r\n (collector, schema) => ({\r\n ...schema,\r\n ...collector,\r\n }),\r\n {} as Schema<any, any>\r\n );\r\n const detectedServiceName =\r\n dataService.Schema.length === 1\r\n ? dataService.Schema[0].$.Namespace\r\n : dataService.Schema.find((schema) => !schema.EntityContainer)?.$.Namespace;\r\n\r\n // encapsulate the whole naming logic\r\n const namingHelper = new NamingHelper(options, detectedServiceName, options.serviceName);\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(schemaRaw as SchemaV3, options, namingHelper)\r\n : await digestV4(schemaRaw as SchemaV4, options, namingHelper);\r\n // handling the overall generation project\r\n const project = await createProjectManager(\r\n namingHelper.getFileNames(),\r\n options.output,\r\n options.emitMode,\r\n options.prettier,\r\n options.tsconfig\r\n );\r\n\r\n // Generate Model Interfaces\r\n // supported edmx types: EntityType, ComplexType, EnumType\r\n const modelsFile = await project.createModelFile();\r\n generateModels(dataModel, modelsFile, version, options, namingHelper);\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 const qFile = await project.createQObjectFile();\r\n generateQueryObjects(dataModel, qFile, version, options, namingHelper);\r\n }\r\n\r\n // Generate Individual OData-Service\r\n if (isServiceGen(options.mode)) {\r\n await project.cleanServiceDir();\r\n await generateServices(dataModel, project, version, namingHelper);\r\n }\r\n\r\n await project.writeFiles();\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ODataEdmxModelBase.js","sourceRoot":"","sources":["../../../src/data-model/edmx/ODataEdmxModelBase.ts"],"names":[],"mappings":"","sourcesContent":["export interface ODataEdmxModelBase<VersionedSchema> {\n \"edmx:Edmx\": {\n $: {\n Version: string;\n \"xmlns:edmx\": string;\n };\n // \"edmx:Reference\": Array<any>;\n \"edmx:DataServices\": Array<DataService<VersionedSchema>>;\n };\n}\n\nexport interface DataService<VersionedSchema> {\n Schema: Array<VersionedSchema>;\n}\n\nexport interface Schema<ET extends EntityType, CT extends ComplexType> {\n $: {\n Namespace: string;\n xmlns: string;\n };\n EntityType?: Array<ET>;\n ComplexType?: Array<CT>;\n EnumType?: Array<EnumType>;\n EntityContainer?: Array<any>;\n}\n\nexport interface EntityContainer<ES = EntitySet> {\n $: {\n Name: string;\n };\n EntitySet?: Array<ES>;\n}\n\nexport interface EntitySet {\n $: {\n Name: string;\n EntityType: string;\n };\n}\n\nexport interface EntityType {\n $: {\n Name: string;\n BaseType?: string;\n };\n Key: Array<PropertyRef>;\n Property: Array<Property>;\n}\n\nexport interface ComplexType extends Omit<EntityType, \"Key\"> {}\n\nexport interface PropertyRef {\n PropertyRef: Array<{ $: { Name: string } }>;\n}\n\nexport interface Property {\n $: {\n Name: string;\n Type: string;\n MaxLength?: number;\n Nullable?: \"true\" | \"false\";\n Precision?: number;\n };\n}\n\nexport interface EnumType {\n $: {\n Name: string;\n };\n Member: Array<Member>;\n}\n\nexport interface Member {\n $: {\n Name: string;\n Value: number;\n };\n}\n\nexport interface Parameter extends Property {\n Unicode?: boolean;\n}\n\nexport interface ReturnType {\n $: {\n Type: string;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ODataEdmxModelBase.js","sourceRoot":"","sources":["../../../src/data-model/edmx/ODataEdmxModelBase.ts"],"names":[],"mappings":"","sourcesContent":["export interface ODataEdmxModelBase<VersionedSchema> {\r\n \"edmx:Edmx\": {\r\n $: {\r\n Version: string;\r\n \"xmlns:edmx\": string;\r\n };\r\n // \"edmx:Reference\": Array<any>;\r\n \"edmx:DataServices\": Array<DataService<VersionedSchema>>;\r\n };\r\n}\r\n\r\nexport interface DataService<VersionedSchema> {\r\n Schema: Array<VersionedSchema>;\r\n}\r\n\r\nexport interface Schema<ET extends EntityType, CT extends ComplexType> {\r\n $: {\r\n Namespace: string;\r\n xmlns: string;\r\n };\r\n EntityType?: Array<ET>;\r\n ComplexType?: Array<CT>;\r\n EnumType?: Array<EnumType>;\r\n EntityContainer?: Array<any>;\r\n}\r\n\r\nexport interface EntityContainer<ES = EntitySet> {\r\n $: {\r\n Name: string;\r\n };\r\n EntitySet?: Array<ES>;\r\n}\r\n\r\nexport interface EntitySet {\r\n $: {\r\n Name: string;\r\n EntityType: string;\r\n };\r\n}\r\n\r\nexport interface EntityType {\r\n $: {\r\n Name: string;\r\n BaseType?: string;\r\n };\r\n Key: Array<PropertyRef>;\r\n Property: Array<Property>;\r\n}\r\n\r\nexport interface ComplexType extends Omit<EntityType, \"Key\"> {}\r\n\r\nexport interface PropertyRef {\r\n PropertyRef: Array<{ $: { Name: string } }>;\r\n}\r\n\r\nexport interface Property {\r\n $: {\r\n Name: string;\r\n Type: string;\r\n MaxLength?: number;\r\n Nullable?: \"true\" | \"false\";\r\n Precision?: number;\r\n };\r\n}\r\n\r\nexport interface EnumType {\r\n $: {\r\n Name: string;\r\n };\r\n Member: Array<Member>;\r\n}\r\n\r\nexport interface Member {\r\n $: {\r\n Name: string;\r\n Value: number;\r\n };\r\n}\r\n\r\nexport interface Parameter extends Property {\r\n Unicode?: boolean;\r\n}\r\n\r\nexport interface ReturnType {\r\n $: {\r\n Type: string;\r\n };\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,uCAAqH;AACrH,uDAAkD;AAClD,sDAA2D;AAiB3D,uDAAoD;AAEpD,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,cAAc,GAAG;IACrB,UAAU,EAAE,yBAAyB;IACrC,KAAK,EAAE,oBAAoB;IAC3B,KAAK,EAAE,oBAAoB;CAC5B,CAAC;AAEF,SAAsB,gBAAgB,CACpC,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B;;QAE1B,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,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EAAE,iBAAiB,SAAS,IAAI,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,KAAI,MAAM,IAAI;YACxE,UAAU,EAAE;gBACV,OAAO,OAAO,KAAK;gBACnB,KAAK,OAAO,UAAU,SAAS,CAAC,KAAK,IAAI;gBACzC,GAAG;gBAEH,gCAAgC,OAAO,aAAa,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK;gBAC5F,GAAG,UAAU,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,QAAQ,gBAClD,CAAC,MAAM;oBACL,CAAC,CAAC,oBAAoB;wBACpB,aAAa,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,4BAA4B,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,GAAG;oBACvG,CAAC,CAAC,SAAS,CAAC,OAAO;wBACnB,CAAC,CAAC,sFAAsF;4BACtF,wBAAwB,kBAAkB,CAAC,IAAI,GAAG;wBACpD,CAAC,CAAC,sBAAsB;4BACtB,YAAY,kBAAkB,CAAC,IAAI,GACzC,GAAG;gBACH,UAAU,CAAC,CAAC,CAAC,UAAU,OAAO,6BAA6B,CAAC,CAAC,CAAC,EAAE;aACjE;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { MethodDeclarationStructure, OptionalKind, PropertyDeclarationStructure, Scope, SourceFile } from \"ts-morph\";\r\nimport { upperCaseFirst } from \"upper-case-first\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport {\r\n ActionImportType,\r\n ComplexType,\r\n DataTypes,\r\n EntitySetType,\r\n FunctionImportType,\r\n ModelType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n SingletonType,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { ProjectManager } from \"../project/ProjectManager\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nconst ROOT_SERVICE = \"ODataService\";\r\n\r\nconst RESPONSE_TYPES = {\r\n collection: \"ODataCollectionResponse\",\r\n model: \"ODataModelResponse\",\r\n value: \"ODataValueResponse\",\r\n};\r\n\r\nexport async function generateServices(\r\n dataModel: DataModel,\r\n project: ProjectManager,\r\n version: ODataVersions,\r\n namingHelper: NamingHelper\r\n) {\r\n const generator = new ServiceGenerator(dataModel, project, version, namingHelper);\r\n return generator.generate();\r\n}\r\n\r\nclass ServiceGenerator {\r\n constructor(\r\n private dataModel: DataModel,\r\n private project: ProjectManager,\r\n private version: ODataVersions,\r\n private namingHelper: NamingHelper\r\n ) {}\r\n\r\n public async generate(): Promise<void> {\r\n const sourceFile = await this.project.createMainServiceFile();\r\n const serviceName = this.namingHelper.getMainServiceName();\r\n const container = this.dataModel.getEntityContainer();\r\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\r\n\r\n await this.generateModelServices();\r\n\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n importContainer.addFromClientApi(\"ODataClient\");\r\n importContainer.addFromService(ROOT_SERVICE);\r\n\r\n sourceFile.addClass({\r\n isExported: true,\r\n name: serviceName,\r\n typeParameters: [\"ClientType extends ODataClient\"],\r\n extends: `${ROOT_SERVICE}<ClientType>`,\r\n properties: [\r\n {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(\"name\"),\r\n type: \"string\",\r\n initializer: `\"${this.namingHelper.getODataServiceName()}\"`,\r\n },\r\n ...this.generateEntityServiceResolverProp(container.entitySets, importContainer),\r\n ...this.generateServiceGettersByAssignment(container.entitySets),\r\n ...this.generateServiceTypeProps(container.singletons, this.namingHelper.getServiceName, importContainer),\r\n ...Object.values(unboundOperations).map(({ operation }) => this.generateQOperationProps(operation)),\r\n ],\r\n methods: [\r\n ...this.generateServiceTypeGetters(container.singletons, this.namingHelper.getServiceName),\r\n ...this.generateUnboundOperations(unboundOperations, importContainer),\r\n ],\r\n });\r\n\r\n sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\r\n }\r\n\r\n private generateEntityServiceResolverProp(\r\n services: Record<string, EntitySetType>,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure>[] {\r\n return Object.values(services).map(({ name, entityType }) => {\r\n const resolverName = this.namingHelper.getServiceResolverName(entityType.name);\r\n\r\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), resolverName);\r\n\r\n return {\r\n name: this.namingHelper.getPublicPropNameForService(name),\r\n scope: Scope.Public,\r\n initializer: `${resolverName}(this.client, this.getPath(), \"${name}\")`,\r\n };\r\n });\r\n }\r\n\r\n private generateServiceGettersByAssignment(\r\n services: Record<string, EntitySetType>\r\n ): OptionalKind<PropertyDeclarationStructure>[] {\r\n return Object.values(services).map(({ name, odataName, entityType }) => {\r\n const propName = this.namingHelper.getPublicPropNameForService(name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(name),\r\n initializer: `this.${propName}.get.bind(this.${propName})`,\r\n };\r\n });\r\n }\r\n\r\n private generateServiceTypeProps(\r\n services: Record<string, SingletonType | EntitySetType>,\r\n typeRetriever: (name: string) => string,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure>[] {\r\n return Object.values(services).map(({ name, entityType }) => {\r\n const type = typeRetriever(entityType.name);\r\n\r\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), type);\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(name),\r\n type: `${type}<ClientType>`,\r\n hasQuestionToken: true,\r\n };\r\n });\r\n }\r\n\r\n private generateQOperationProps = (operation: OperationType) => {\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(operation.qName),\r\n type: operation.qName,\r\n hasQuestionToken: true,\r\n };\r\n };\r\n\r\n private generateServiceTypeGetters(\r\n services: Record<string, SingletonType | EntitySetType>,\r\n typeRetriever: (name: string) => string\r\n ): OptionalKind<MethodDeclarationStructure>[] {\r\n return Object.values(services).map(({ name, odataName, entityType }) => {\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\r\n const serviceType = typeRetriever(entityType.name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n // prettier-ignore\r\n ` ${propName} = new ${serviceType}(this.client, this.getPath(), \"${odataName}\")`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n });\r\n }\r\n\r\n private getVersionSuffix() {\r\n return this.version === ODataVersions.V2 ? \"V2\" : \"V4\";\r\n }\r\n\r\n private async generateModelService(\r\n model: ComplexType,\r\n serviceName: string,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const entityServiceType = \"EntityTypeService\" + this.getVersionSuffix();\r\n const collectionServiceType = \"CollectionService\" + this.getVersionSuffix();\r\n\r\n const editableModelName = model.editableName;\r\n const operations = this.dataModel.getOperationTypeByBinding(model.name);\r\n const props = [...model.baseProps, ...model.props];\r\n const modelProps = props.filter(\r\n (prop) => prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType\r\n );\r\n const primColProps = props.filter(\r\n (prop) => prop.isCollection && prop.dataType !== DataTypes.ModelType && prop.dataType !== DataTypes.ComplexType\r\n );\r\n\r\n importContainer.addFromService(entityServiceType);\r\n importContainer.addFromClientApi(\"ODataClient\");\r\n importContainer.addGeneratedModel(model.name, editableModelName);\r\n importContainer.addGeneratedQObject(model.qName, firstCharLowerCase(model.qName));\r\n\r\n // generate EntityTypeService\r\n serviceFile.addClass({\r\n isExported: true,\r\n name: serviceName,\r\n typeParameters: [\"ClientType extends ODataClient\"],\r\n extends: entityServiceType + `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [`super(client, basePath, name, ${firstCharLowerCase(model.qName)});`],\r\n },\r\n ],\r\n properties: [\r\n ...this.generateModelProps(modelProps, collectionServiceType, serviceName, importContainer),\r\n ...this.generatePrimitiveCollectionProps(primColProps, collectionServiceType, importContainer),\r\n ...operations.map(this.generateQOperationProps),\r\n ],\r\n methods: [\r\n ...this.generateModelPropGetters(modelProps, collectionServiceType),\r\n ...this.generatePrimitiveCollectionGetters(primColProps, collectionServiceType),\r\n ...this.generateBoundOperations(operations, importContainer),\r\n ],\r\n });\r\n }\r\n\r\n private generateModelProps(\r\n modelProps: Array<PropertyModel>,\r\n collectionServiceType: string,\r\n serviceName: string,\r\n importContainer: ImportContainer\r\n ): Array<PropertyDeclarationStructure> {\r\n return modelProps.map((prop) => {\r\n const complexType = this.dataModel.getComplexType(prop.type);\r\n const key = this.namingHelper.getServiceName(prop.type);\r\n let propModelType = prop.isCollection ? this.namingHelper.getCollectionServiceName(prop.type) : key;\r\n\r\n if (prop.isCollection && complexType) {\r\n const editableName = complexType.editableName;\r\n importContainer.addFromService(collectionServiceType);\r\n importContainer.addGeneratedModel(complexType.name, editableName);\r\n importContainer.addGeneratedQObject(complexType.qName, firstCharLowerCase(complexType.qName));\r\n propModelType = `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${editableName}>`;\r\n } else {\r\n // don't include imports for this type\r\n if (serviceName !== key) {\r\n importContainer.addGeneratedService(key, propModelType);\r\n }\r\n\r\n propModelType = `${propModelType}<ClientType>`;\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: propModelType,\r\n hasQuestionToken: true,\r\n } as PropertyDeclarationStructure;\r\n });\r\n }\r\n\r\n private generatePrimitiveCollectionProps(\r\n primColProps: Array<PropertyModel>,\r\n collectionServiceType: string,\r\n importContainer: ImportContainer\r\n ): Array<PropertyDeclarationStructure> {\r\n return primColProps.map((prop) => {\r\n const isEnum = prop.dataType === DataTypes.EnumType;\r\n const type = isEnum ? `EnumCollection<${prop.type}>` : `${upperCaseFirst(prop.type)}Collection`;\r\n const qType = isEnum ? \"QEnumCollection\" : `Q${type}`;\r\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\r\n\r\n if (!prop.qObject) {\r\n throw new Error(\"Illegal State: [qObject] must be provided for Collection types!\");\r\n }\r\n\r\n importContainer.addFromService(collectionServiceType);\r\n importContainer.addFromQObject(prop.qObject, firstCharLowerCase(prop.qObject));\r\n if (isEnum) {\r\n importContainer.addGeneratedModel(prop.type);\r\n importContainer.addFromQObject(\"EnumCollection\");\r\n } else {\r\n importContainer.addFromQObject(type);\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: `${collectionType}`,\r\n hasQuestionToken: true,\r\n } as PropertyDeclarationStructure;\r\n });\r\n }\r\n\r\n private generateModelPropGetters(\r\n modelProps: Array<PropertyModel>,\r\n collectionServiceType: string\r\n ): Array<MethodDeclarationStructure> {\r\n return modelProps.map((prop) => {\r\n const complexType = this.dataModel.getComplexType(prop.type);\r\n const isComplexCollection = prop.isCollection && complexType;\r\n const type = isComplexCollection\r\n ? collectionServiceType\r\n : prop.isCollection\r\n ? this.namingHelper.getCollectionServiceName(prop.type)\r\n : this.namingHelper.getServiceName(prop.type);\r\n const typeWithGenerics = isComplexCollection\r\n ? `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${complexType.editableName}>`\r\n : `${type}<ClientType>`;\r\n\r\n const privateSrvProp = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n returnType: typeWithGenerics,\r\n statements: [\r\n `if(!${privateSrvProp}) {`,\r\n // prettier-ignore\r\n ` ${privateSrvProp} = new ${type}(this.client, this.getPath(), \"${prop.odataName}\"${isComplexCollection ? `, ${firstCharLowerCase(complexType.qName)}`: \"\"})`,\r\n \"}\",\r\n `return ${privateSrvProp}`,\r\n ],\r\n } as MethodDeclarationStructure;\r\n });\r\n }\r\n\r\n private generatePrimitiveCollectionGetters(\r\n primColProps: Array<PropertyModel>,\r\n collectionServiceType: string\r\n ): Array<MethodDeclarationStructure> {\r\n return primColProps.map((prop) => {\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n // prettier-ignore\r\n ` ${propName} = new ${collectionServiceType}(this.client, this.getPath(), \"${prop.odataName}\", ${firstCharLowerCase(prop.qObject!)})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n } as MethodDeclarationStructure;\r\n });\r\n }\r\n\r\n private async generateEntityCollectionService(\r\n model: ModelType,\r\n serviceName: string,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const entitySetServiceType = \"EntitySetService\" + this.getVersionSuffix();\r\n const editableModelName = model.editableName;\r\n const qObjectName = firstCharLowerCase(model.qName);\r\n\r\n importContainer.addFromService(entitySetServiceType);\r\n importContainer.addGeneratedModel(model.idModelName);\r\n importContainer.addGeneratedQObject(model.qIdFunctionName);\r\n\r\n const collectionOperations = this.dataModel.getOperationTypeByBinding(`Collection(${model.name})`);\r\n\r\n serviceFile.addClass({\r\n isExported: true,\r\n name: this.namingHelper.getCollectionServiceName(model.name),\r\n typeParameters: [\"ClientType extends ODataClient\"],\r\n extends:\r\n entitySetServiceType +\r\n `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}, ${model.idModelName}, ${serviceName}<ClientType>>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [\r\n `super(client, basePath, name, ${qObjectName}, ${serviceName}, new ${model.qIdFunctionName}(name));`,\r\n ],\r\n },\r\n ],\r\n properties: [...collectionOperations.map(this.generateQOperationProps)],\r\n methods: [...this.generateBoundOperations(collectionOperations, importContainer)],\r\n });\r\n }\r\n\r\n private generateEntityServiceResolver(\r\n model: ModelType,\r\n serviceName: string,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const idFunctionName = model.qIdFunctionName;\r\n const collectionName = this.namingHelper.getCollectionServiceName(model.name);\r\n\r\n importContainer.addFromClientApi(\"ODataClient\");\r\n importContainer.addFromService(\"EntityServiceResolver\");\r\n importContainer.addGeneratedQObject(idFunctionName);\r\n\r\n serviceFile.addFunction({\r\n name: this.namingHelper.getServiceResolverName(model.name),\r\n isExported: true,\r\n parameters: [\r\n {\r\n name: \"client\",\r\n type: \"ODataClient\",\r\n },\r\n {\r\n name: \"basePath\",\r\n type: \"string\",\r\n },\r\n {\r\n name: \"entityName\",\r\n type: \"string\",\r\n },\r\n ],\r\n statements: [\r\n `return new EntityServiceResolver(client, basePath, entityName, ${idFunctionName}, ${serviceName}, ${collectionName});`,\r\n ],\r\n });\r\n }\r\n\r\n private async generateModelServices() {\r\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\r\n for (const model of this.dataModel.getModels()) {\r\n const serviceName = this.namingHelper.getServiceName(model.name);\r\n const serviceFile = await this.project.createServiceFile(serviceName);\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n // entity type service\r\n await this.generateModelService(model, serviceName, serviceFile, importContainer);\r\n\r\n // entity collection service\r\n await this.generateEntityCollectionService(model, serviceName, serviceFile, importContainer);\r\n\r\n // the resolver function\r\n await this.generateEntityServiceResolver(model, serviceName, serviceFile, importContainer);\r\n\r\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\r\n }\r\n\r\n // build service file for complex types\r\n for (const model of this.dataModel.getComplexTypes()) {\r\n const serviceName = this.namingHelper.getServiceName(model.name);\r\n const serviceFile = await this.project.createServiceFile(serviceName);\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n // entity type service\r\n await this.generateModelService(model, serviceName, serviceFile, importContainer);\r\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\r\n }\r\n }\r\n\r\n private generateBoundOperations(operations: Array<OperationType>, importContainer: ImportContainer) {\r\n return operations.reduce<Array<OptionalKind<MethodDeclarationStructure>>>((collector, operation) => {\r\n collector.push(this.generateMethod(operation.name, operation, importContainer));\r\n\r\n return collector;\r\n }, []);\r\n }\r\n\r\n private generateUnboundOperations(\r\n operations: Array<FunctionImportType | ActionImportType>,\r\n importContainer: ImportContainer\r\n ) {\r\n return Object.values(operations).reduce<Array<OptionalKind<MethodDeclarationStructure>>>(\r\n (collector, { name, operation }) => {\r\n collector.push(this.generateMethod(name, operation, importContainer));\r\n\r\n return collector;\r\n },\r\n []\r\n );\r\n }\r\n\r\n private generateMethod(\r\n name: string,\r\n operation: OperationType,\r\n importContainer: ImportContainer\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const isFunc = operation.type === OperationTypes.Function;\r\n const odataType = operation.returnType?.isCollection\r\n ? RESPONSE_TYPES.collection + this.getVersionSuffix()\r\n : operation.returnType?.dataType === DataTypes.PrimitiveType\r\n ? RESPONSE_TYPES.value + this.getVersionSuffix()\r\n : RESPONSE_TYPES.model + this.getVersionSuffix();\r\n const returnType = operation.returnType;\r\n const requestConfigParam = { name: \"requestConfig\", hasQuestionToken: true, type: \"ODataClientConfig<ClientType>\" };\r\n const hasParams = operation.parameters.length > 0;\r\n\r\n // importing dependencies\r\n importContainer.addFromClientApi(\"ODataClientConfig\", \"ODataResponse\");\r\n importContainer.addFromCore(odataType);\r\n if (returnType?.type) {\r\n if ([DataTypes.EnumType, DataTypes.ModelType, DataTypes.ComplexType].includes(returnType.dataType)) {\r\n importContainer.addGeneratedModel(returnType.type);\r\n }\r\n }\r\n importContainer.addGeneratedQObject(operation.qName);\r\n if (hasParams) {\r\n importContainer.addGeneratedModel(operation.paramsModelName);\r\n }\r\n\r\n const qOpProp = \"this.\" + this.namingHelper.getPrivatePropName(operation.qName);\r\n\r\n return {\r\n scope: Scope.Public,\r\n isAsync: true,\r\n name,\r\n parameters: hasParams\r\n ? [{ name: \"params\", type: operation.paramsModelName }, requestConfigParam]\r\n : [requestConfigParam],\r\n returnType: `ODataResponse<${odataType}<${returnType?.type || \"void\"}>>`,\r\n statements: [\r\n `if(!${qOpProp}) {`,\r\n ` ${qOpProp} = new ${operation.qName}()`,\r\n \"}\",\r\n\r\n `const url = this.addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params\" : \"\"}));`,\r\n `${returnType ? \"const response = await \" : \"return\"} this.client.${\r\n !isFunc\r\n ? // actions: since V4\r\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${requestConfigParam.name})`\r\n : operation.usePost\r\n ? // V2 POST => BUT values are still query params, they are not part of the request body\r\n `post(url, undefined, ${requestConfigParam.name})`\r\n : // functions: since V2\r\n `get(url, ${requestConfigParam.name})`\r\n };`,\r\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\r\n ],\r\n };\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,uCAAqH;AACrH,uDAAkD;AAClD,sDAA2D;AAiB3D,uDAAoD;AAEpD,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,cAAc,GAAG;IACrB,UAAU,EAAE,yBAAyB;IACrC,KAAK,EAAE,oBAAoB;IAC3B,KAAK,EAAE,oBAAoB;CAC5B,CAAC;AAEF,SAAsB,gBAAgB,CACpC,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B;;QAE1B,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,S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C,CAAC,kBAAkB,CAAC;YACxB,UAAU,EAAE,iBAAiB,SAAS,IAAI,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,KAAI,MAAM,IAAI;YACxE,UAAU,EAAE;gBACV,OAAO,OAAO,KAAK;gBACnB,KAAK,OAAO,UAAU,SAAS,CAAC,KAAK,IAAI;gBACzC,GAAG;gBAEH,gCAAgC,OAAO,aAAa,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK;gBAC5F,GAAG,UAAU,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,QAAQ,gBAClD,CAAC,MAAM;oBACL,CAAC,CAAC,oBAAoB;wBACpB,aAAa,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,4BAA4B,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,GAAG;oBACvG,CAAC,CAAC,SAAS,CAAC,OAAO;wBACnB,CAAC,CAAC,sFAAsF;4BACtF,wBAAwB,kBAAkB,CAAC,IAAI,GAAG;wBACpD,CAAC,CAAC,sBAAsB;4BACtB,YAAY,kBAAkB,CAAC,IAAI,GACzC,GAAG;gBACH,UAAU,CAAC,CAAC,CAAC,UAAU,OAAO,6BAA6B,CAAC,CAAC,CAAC,EAAE;aACjE;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport { MethodDeclarationStructure, OptionalKind, PropertyDeclarationStructure, Scope, SourceFile } from \"ts-morph\";\nimport { upperCaseFirst } from \"upper-case-first\";\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\n\nimport { DataModel } from \"../data-model/DataModel\";\nimport {\n ActionImportType,\n ComplexType,\n DataTypes,\n EntitySetType,\n FunctionImportType,\n ModelType,\n OperationType,\n OperationTypes,\n PropertyModel,\n SingletonType,\n} from \"../data-model/DataTypeModel\";\nimport { NamingHelper } from \"../data-model/NamingHelper\";\nimport { ProjectManager } from \"../project/ProjectManager\";\nimport { ImportContainer } from \"./ImportContainer\";\n\nconst ROOT_SERVICE = \"ODataService\";\n\nconst RESPONSE_TYPES = {\n collection: \"ODataCollectionResponse\",\n model: \"ODataModelResponse\",\n value: \"ODataValueResponse\",\n};\n\nexport async function generateServices(\n dataModel: DataModel,\n project: ProjectManager,\n version: ODataVersions,\n namingHelper: NamingHelper\n) {\n const generator = new ServiceGenerator(dataModel, project, version, namingHelper);\n return generator.generate();\n}\n\nclass ServiceGenerator {\n constructor(\n private dataModel: DataModel,\n private project: ProjectManager,\n private version: ODataVersions,\n private namingHelper: NamingHelper\n ) {}\n\n public async generate(): Promise<void> {\n const sourceFile = await this.project.createMainServiceFile();\n const serviceName = this.namingHelper.getMainServiceName();\n const container = this.dataModel.getEntityContainer();\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\n\n await this.generateModelServices();\n\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\n importContainer.addFromClientApi(\"ODataClient\");\n importContainer.addFromService(ROOT_SERVICE);\n\n sourceFile.addClass({\n isExported: true,\n name: serviceName,\n typeParameters: [\"ClientType extends ODataClient\"],\n extends: `${ROOT_SERVICE}<ClientType>`,\n properties: [\n {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(\"name\"),\n type: \"string\",\n initializer: `\"${this.namingHelper.getODataServiceName()}\"`,\n },\n ...this.generateEntityServiceResolverProp(container.entitySets, importContainer),\n ...this.generateServiceGettersByAssignment(container.entitySets),\n ...this.generateServiceTypeProps(container.singletons, this.namingHelper.getServiceName, importContainer),\n ...Object.values(unboundOperations).map(({ operation }) => this.generateQOperationProps(operation)),\n ],\n methods: [\n ...this.generateServiceTypeGetters(container.singletons, this.namingHelper.getServiceName),\n ...this.generateUnboundOperations(unboundOperations, importContainer),\n ],\n });\n\n sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\n }\n\n private generateEntityServiceResolverProp(\n services: Record<string, EntitySetType>,\n importContainer: ImportContainer\n ): OptionalKind<PropertyDeclarationStructure>[] {\n return Object.values(services).map(({ name, entityType }) => {\n const resolverName = this.namingHelper.getServiceResolverName(entityType.name);\n\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), resolverName);\n\n return {\n name: this.namingHelper.getPublicPropNameForService(name),\n scope: Scope.Public,\n initializer: `${resolverName}(this.client, this.getPath(), \"${name}\")`,\n };\n });\n }\n\n private generateServiceGettersByAssignment(\n services: Record<string, EntitySetType>\n ): OptionalKind<PropertyDeclarationStructure>[] {\n return Object.values(services).map(({ name, odataName, entityType }) => {\n const propName = this.namingHelper.getPublicPropNameForService(name);\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(name),\n initializer: `this.${propName}.get.bind(this.${propName})`,\n };\n });\n }\n\n private generateServiceTypeProps(\n services: Record<string, SingletonType | EntitySetType>,\n typeRetriever: (name: string) => string,\n importContainer: ImportContainer\n ): OptionalKind<PropertyDeclarationStructure>[] {\n return Object.values(services).map(({ name, entityType }) => {\n const type = typeRetriever(entityType.name);\n\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), type);\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(name),\n type: `${type}<ClientType>`,\n hasQuestionToken: true,\n };\n });\n }\n\n private generateQOperationProps = (operation: OperationType) => {\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(operation.qName),\n type: operation.qName,\n hasQuestionToken: true,\n };\n };\n\n private generateServiceTypeGetters(\n services: Record<string, SingletonType | EntitySetType>,\n typeRetriever: (name: string) => string\n ): OptionalKind<MethodDeclarationStructure>[] {\n return Object.values(services).map(({ name, odataName, entityType }) => {\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\n const serviceType = typeRetriever(entityType.name);\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(name),\n statements: [\n `if(!${propName}) {`,\n // prettier-ignore\n ` ${propName} = new ${serviceType}(this.client, this.getPath(), \"${odataName}\")`,\n \"}\",\n `return ${propName}`,\n ],\n };\n });\n }\n\n private getVersionSuffix() {\n return this.version === ODataVersions.V2 ? \"V2\" : \"V4\";\n }\n\n private async generateModelService(\n model: ComplexType,\n serviceName: string,\n serviceFile: SourceFile,\n importContainer: ImportContainer\n ) {\n const entityServiceType = \"EntityTypeService\" + this.getVersionSuffix();\n const collectionServiceType = \"CollectionService\" + this.getVersionSuffix();\n\n const editableModelName = model.editableName;\n const operations = this.dataModel.getOperationTypeByBinding(model.name);\n const props = [...model.baseProps, ...model.props];\n const modelProps = props.filter(\n (prop) => prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType\n );\n const primColProps = props.filter(\n (prop) => prop.isCollection && prop.dataType !== DataTypes.ModelType && prop.dataType !== DataTypes.ComplexType\n );\n\n importContainer.addFromService(entityServiceType);\n importContainer.addFromClientApi(\"ODataClient\");\n importContainer.addGeneratedModel(model.name, editableModelName);\n importContainer.addGeneratedQObject(model.qName, firstCharLowerCase(model.qName));\n\n // generate EntityTypeService\n serviceFile.addClass({\n isExported: true,\n name: serviceName,\n typeParameters: [\"ClientType extends ODataClient\"],\n extends: entityServiceType + `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}>`,\n ctors: [\n {\n parameters: [\n { name: \"client\", type: \"ClientType\" },\n { name: \"basePath\", type: \"string\" },\n { name: \"name\", type: \"string\" },\n ],\n statements: [`super(client, basePath, name, ${firstCharLowerCase(model.qName)});`],\n },\n ],\n properties: [\n ...this.generateModelProps(modelProps, collectionServiceType, serviceName, importContainer),\n ...this.generatePrimitiveCollectionProps(primColProps, collectionServiceType, importContainer),\n ...operations.map(this.generateQOperationProps),\n ],\n methods: [\n ...this.generateModelPropGetters(modelProps, collectionServiceType),\n ...this.generatePrimitiveCollectionGetters(primColProps, collectionServiceType),\n ...this.generateBoundOperations(operations, importContainer),\n ],\n });\n }\n\n private generateModelProps(\n modelProps: Array<PropertyModel>,\n collectionServiceType: string,\n serviceName: string,\n importContainer: ImportContainer\n ): Array<PropertyDeclarationStructure> {\n return modelProps.map((prop) => {\n const complexType = this.dataModel.getComplexType(prop.type);\n const key = this.namingHelper.getServiceName(prop.type);\n let propModelType = prop.isCollection ? this.namingHelper.getCollectionServiceName(prop.type) : key;\n\n if (prop.isCollection && complexType) {\n const editableName = complexType.editableName;\n importContainer.addFromService(collectionServiceType);\n importContainer.addGeneratedModel(complexType.name, editableName);\n importContainer.addGeneratedQObject(complexType.qName, firstCharLowerCase(complexType.qName));\n propModelType = `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${editableName}>`;\n } else {\n // don't include imports for this type\n if (serviceName !== key) {\n importContainer.addGeneratedService(key, propModelType);\n }\n\n propModelType = `${propModelType}<ClientType>`;\n }\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(prop.name),\n type: propModelType,\n hasQuestionToken: true,\n } as PropertyDeclarationStructure;\n });\n }\n\n private generatePrimitiveCollectionProps(\n primColProps: Array<PropertyModel>,\n collectionServiceType: string,\n importContainer: ImportContainer\n ): Array<PropertyDeclarationStructure> {\n return primColProps.map((prop) => {\n const isEnum = prop.dataType === DataTypes.EnumType;\n const type = isEnum ? `EnumCollection<${prop.type}>` : `${upperCaseFirst(prop.type)}Collection`;\n const qType = isEnum ? \"QEnumCollection\" : `Q${type}`;\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\n\n if (!prop.qObject) {\n throw new Error(\"Illegal State: [qObject] must be provided for Collection types!\");\n }\n\n importContainer.addFromService(collectionServiceType);\n importContainer.addFromQObject(prop.qObject, firstCharLowerCase(prop.qObject));\n if (isEnum) {\n importContainer.addGeneratedModel(prop.type);\n importContainer.addFromQObject(\"EnumCollection\");\n } else {\n importContainer.addFromQObject(type);\n }\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(prop.name),\n type: `${collectionType}`,\n hasQuestionToken: true,\n } as PropertyDeclarationStructure;\n });\n }\n\n private generateModelPropGetters(\n modelProps: Array<PropertyModel>,\n collectionServiceType: string\n ): Array<MethodDeclarationStructure> {\n return modelProps.map((prop) => {\n const complexType = this.dataModel.getComplexType(prop.type);\n const isComplexCollection = prop.isCollection && complexType;\n const type = isComplexCollection\n ? collectionServiceType\n : prop.isCollection\n ? this.namingHelper.getCollectionServiceName(prop.type)\n : this.namingHelper.getServiceName(prop.type);\n const typeWithGenerics = isComplexCollection\n ? `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${complexType.editableName}>`\n : `${type}<ClientType>`;\n\n const privateSrvProp = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\n\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\n returnType: typeWithGenerics,\n statements: [\n `if(!${privateSrvProp}) {`,\n // prettier-ignore\n ` ${privateSrvProp} = new ${type}(this.client, this.getPath(), \"${prop.odataName}\"${isComplexCollection ? `, ${firstCharLowerCase(complexType.qName)}`: \"\"})`,\n \"}\",\n `return ${privateSrvProp}`,\n ],\n } as MethodDeclarationStructure;\n });\n }\n\n private generatePrimitiveCollectionGetters(\n primColProps: Array<PropertyModel>,\n collectionServiceType: string\n ): Array<MethodDeclarationStructure> {\n return primColProps.map((prop) => {\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\n statements: [\n `if(!${propName}) {`,\n // prettier-ignore\n ` ${propName} = new ${collectionServiceType}(this.client, this.getPath(), \"${prop.odataName}\", ${firstCharLowerCase(prop.qObject!)})`,\n \"}\",\n `return ${propName}`,\n ],\n } as MethodDeclarationStructure;\n });\n }\n\n private async generateEntityCollectionService(\n model: ModelType,\n serviceName: string,\n serviceFile: SourceFile,\n importContainer: ImportContainer\n ) {\n const entitySetServiceType = \"EntitySetService\" + this.getVersionSuffix();\n const editableModelName = model.editableName;\n const qObjectName = firstCharLowerCase(model.qName);\n\n importContainer.addFromService(entitySetServiceType);\n importContainer.addGeneratedModel(model.idModelName);\n importContainer.addGeneratedQObject(model.qIdFunctionName);\n\n const collectionOperations = this.dataModel.getOperationTypeByBinding(`Collection(${model.name})`);\n\n serviceFile.addClass({\n isExported: true,\n name: this.namingHelper.getCollectionServiceName(model.name),\n typeParameters: [\"ClientType extends ODataClient\"],\n extends:\n entitySetServiceType +\n `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}, ${model.idModelName}, ${serviceName}<ClientType>>`,\n ctors: [\n {\n parameters: [\n { name: \"client\", type: \"ClientType\" },\n { name: \"basePath\", type: \"string\" },\n { name: \"name\", type: \"string\" },\n ],\n statements: [\n `super(client, basePath, name, ${qObjectName}, ${serviceName}, new ${model.qIdFunctionName}(name));`,\n ],\n },\n ],\n properties: [...collectionOperations.map(this.generateQOperationProps)],\n methods: [...this.generateBoundOperations(collectionOperations, importContainer)],\n });\n }\n\n private generateEntityServiceResolver(\n model: ModelType,\n serviceName: string,\n serviceFile: SourceFile,\n importContainer: ImportContainer\n ) {\n const idFunctionName = model.qIdFunctionName;\n const collectionName = this.namingHelper.getCollectionServiceName(model.name);\n\n importContainer.addFromClientApi(\"ODataClient\");\n importContainer.addFromService(\"EntityServiceResolver\");\n importContainer.addGeneratedQObject(idFunctionName);\n\n serviceFile.addFunction({\n name: this.namingHelper.getServiceResolverName(model.name),\n isExported: true,\n parameters: [\n {\n name: \"client\",\n type: \"ODataClient\",\n },\n {\n name: \"basePath\",\n type: \"string\",\n },\n {\n name: \"entityName\",\n type: \"string\",\n },\n ],\n statements: [\n `return new EntityServiceResolver(client, basePath, entityName, ${idFunctionName}, ${serviceName}, ${collectionName});`,\n ],\n });\n }\n\n private async generateModelServices() {\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\n for (const model of this.dataModel.getModels()) {\n const serviceName = this.namingHelper.getServiceName(model.name);\n const serviceFile = await this.project.createServiceFile(serviceName);\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\n\n // entity type service\n await this.generateModelService(model, serviceName, serviceFile, importContainer);\n\n // entity collection service\n await this.generateEntityCollectionService(model, serviceName, serviceFile, importContainer);\n\n // the resolver function\n await this.generateEntityServiceResolver(model, serviceName, serviceFile, importContainer);\n\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\n }\n\n // build service file for complex types\n for (const model of this.dataModel.getComplexTypes()) {\n const serviceName = this.namingHelper.getServiceName(model.name);\n const serviceFile = await this.project.createServiceFile(serviceName);\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\n\n // entity type service\n await this.generateModelService(model, serviceName, serviceFile, importContainer);\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\n }\n }\n\n private generateBoundOperations(operations: Array<OperationType>, importContainer: ImportContainer) {\n return operations.reduce<Array<OptionalKind<MethodDeclarationStructure>>>((collector, operation) => {\n collector.push(this.generateMethod(operation.name, operation, importContainer));\n\n return collector;\n }, []);\n }\n\n private generateUnboundOperations(\n operations: Array<FunctionImportType | ActionImportType>,\n importContainer: ImportContainer\n ) {\n return Object.values(operations).reduce<Array<OptionalKind<MethodDeclarationStructure>>>(\n (collector, { name, operation }) => {\n collector.push(this.generateMethod(name, operation, importContainer));\n\n return collector;\n },\n []\n );\n }\n\n private generateMethod(\n name: string,\n operation: OperationType,\n importContainer: ImportContainer\n ): OptionalKind<MethodDeclarationStructure> {\n const isFunc = operation.type === OperationTypes.Function;\n const odataType = operation.returnType?.isCollection\n ? RESPONSE_TYPES.collection + this.getVersionSuffix()\n : operation.returnType?.dataType === DataTypes.PrimitiveType\n ? RESPONSE_TYPES.value + this.getVersionSuffix()\n : RESPONSE_TYPES.model + this.getVersionSuffix();\n const returnType = operation.returnType;\n const requestConfigParam = { name: \"requestConfig\", hasQuestionToken: true, type: \"ODataClientConfig<ClientType>\" };\n const hasParams = operation.parameters.length > 0;\n\n // importing dependencies\n importContainer.addFromClientApi(\"ODataClientConfig\", \"ODataResponse\");\n importContainer.addFromCore(odataType);\n if (returnType?.type) {\n if ([DataTypes.EnumType, DataTypes.ModelType, DataTypes.ComplexType].includes(returnType.dataType)) {\n importContainer.addGeneratedModel(returnType.type);\n }\n }\n importContainer.addGeneratedQObject(operation.qName);\n if (hasParams) {\n importContainer.addGeneratedModel(operation.paramsModelName);\n }\n\n const qOpProp = \"this.\" + this.namingHelper.getPrivatePropName(operation.qName);\n\n return {\n scope: Scope.Public,\n isAsync: true,\n name,\n parameters: hasParams\n ? [{ name: \"params\", type: operation.paramsModelName }, requestConfigParam]\n : [requestConfigParam],\n returnType: `ODataResponse<${odataType}<${returnType?.type || \"void\"}>>`,\n statements: [\n `if(!${qOpProp}) {`,\n ` ${qOpProp} = new ${operation.qName}()`,\n \"}\",\n\n `const url = this.addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params\" : \"\"}));`,\n `${returnType ? \"const response = await \" : \"return\"} this.client.${\n !isFunc\n ? // actions: since V4\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${requestConfigParam.name})`\n : operation.usePost\n ? // V2 POST => BUT values are still query params, they are not part of the request body\n `post(url, undefined, ${requestConfigParam.name})`\n : // functions: since V2\n `get(url, ${requestConfigParam.name})`\n };`,\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\n ],\n };\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odata2ts/odata2ts",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"js"
|
|
47
47
|
],
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@odata2ts/odata-client-api": "^0.6.
|
|
50
|
-
"@odata2ts/odata-query-objects": "^0.17.
|
|
51
|
-
"@odata2ts/odata-service": "^0.13.
|
|
49
|
+
"@odata2ts/odata-client-api": "^0.6.3",
|
|
50
|
+
"@odata2ts/odata-query-objects": "^0.17.2",
|
|
51
|
+
"@odata2ts/odata-service": "^0.13.8"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@odata2ts/converter-api": "^0.1.1",
|
|
55
55
|
"@odata2ts/converter-runtime": "^0.1.2",
|
|
56
|
-
"@odata2ts/odata-core": "^0.3.
|
|
56
|
+
"@odata2ts/odata-core": "^0.3.7",
|
|
57
57
|
"camel-case": "^4.1.2",
|
|
58
58
|
"commander": "^9.1.0",
|
|
59
59
|
"constant-case": "^3.0.4",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@odata2ts/converter-v2-to-v4": "^0.1.2",
|
|
75
|
-
"@odata2ts/odata-client-api": "^0.6.
|
|
76
|
-
"@odata2ts/odata-query-objects": "^0.17.
|
|
77
|
-
"@odata2ts/odata-service": "^0.13.
|
|
75
|
+
"@odata2ts/odata-client-api": "^0.6.3",
|
|
76
|
+
"@odata2ts/odata-query-objects": "^0.17.2",
|
|
77
|
+
"@odata2ts/odata-service": "^0.13.8",
|
|
78
78
|
"@types/fs-extra": "^9.0.13",
|
|
79
79
|
"@types/jest": "^27.4.1",
|
|
80
80
|
"@types/node": "^17.0.23",
|
|
@@ -88,6 +88,6 @@
|
|
|
88
88
|
"typescript": "^4.9.4"
|
|
89
89
|
},
|
|
90
90
|
"types": "./lib/index.d.ts",
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "720e487f95e86f33ca37ab776949048a6e789db8",
|
|
92
92
|
"readme": "README.md"
|
|
93
93
|
}
|