@odata2ts/odata2ts 0.25.0 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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.25.1](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.25.0...@odata2ts/odata2ts@0.25.1) (2023-07-10)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **odata2ts:** duplicate output paths ([#184](https://github.com/odata2ts/odata2ts/issues/184)) ([b55366d](https://github.com/odata2ts/odata2ts/commit/b55366dab8d331ace3c766b4279b5b0cc575aa03))
|
|
11
|
+
|
|
6
12
|
# [0.25.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.24.0...@odata2ts/odata2ts@0.25.0) (2023-07-10)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
|
@@ -12,7 +18,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
12
18
|
### Features
|
|
13
19
|
|
|
14
20
|
* **odata2ts:** support for multiple namespaces by merging ([#175](https://github.com/odata2ts/odata2ts/issues/175)) ([db8fd61](https://github.com/odata2ts/odata2ts/commit/db8fd6165c57ceb9e04488789a62f2a5467ecc68))
|
|
21
|
+
|
|
15
22
|
* **odata2ts:** support schema alias ([#181](https://github.com/odata2ts/odata2ts/issues/181)) ([e0c04a8](https://github.com/odata2ts/odata2ts/commit/e0c04a83e32d99187652966bb9cc32f36ead3df2))
|
|
23
|
+
|
|
16
24
|
* **odata2ts:** support TypeDefinition elements ([#183](https://github.com/odata2ts/odata2ts/issues/183)) ([d77d2cb](https://github.com/odata2ts/odata2ts/commit/d77d2cbf17383dab50d35bb7374e08a83d264db2))
|
|
17
25
|
|
|
18
26
|
# [0.24.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.23.1...@odata2ts/odata2ts@0.24.0) (2023-06-14)
|
package/README.md
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
[](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
|
-
- 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.
|
|
21
|
-
|
|
22
|
-
## Installation
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
npm install --save-dev @odata2ts/odata2ts
|
|
26
|
-
```
|
|
27
|
-
|
|
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.
|
|
34
|
-
|
|
35
|
-
## Documentation
|
|
36
|
-
[Generator Documentation](https://odata2ts.github.io/docs/generator/setup-and-usage)
|
|
37
|
-
|
|
38
|
-
Main documentation for the odata2ts eco system:
|
|
39
|
-
[https://odata2ts.github.io](https://odata2ts.github.io/)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
## Examples
|
|
43
|
-
See [example packages](https://github.com/odata2ts/odata2ts/tree/main/examples) for examples of how to integrate `odata2ts`.
|
|
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
|
-
|
|
62
|
-
## Spirit
|
|
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
|
|
72
|
-
|
|
73
|
-
## License
|
|
74
|
-
MIT - see [License](./LICENSE).
|
|
1
|
+
[](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
|
+
- 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.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
npm install --save-dev @odata2ts/odata2ts
|
|
26
|
+
```
|
|
27
|
+
|
|
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.
|
|
34
|
+
|
|
35
|
+
## Documentation
|
|
36
|
+
[Generator Documentation](https://odata2ts.github.io/docs/generator/setup-and-usage)
|
|
37
|
+
|
|
38
|
+
Main documentation for the odata2ts eco system:
|
|
39
|
+
[https://odata2ts.github.io](https://odata2ts.github.io/)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## Examples
|
|
43
|
+
See [example packages](https://github.com/odata2ts/odata2ts/tree/main/examples) for examples of how to integrate `odata2ts`.
|
|
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
|
+
|
|
62
|
+
## Spirit
|
|
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
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
MIT - see [License](./LICENSE).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportContainer.js","sourceRoot":"","sources":["../../src/generator/ImportContainer.ts"],"names":[],"mappings":";;;;AAeA,MAAa,eAAe;IAuB1B,YAAY,SAAuB;QAtB3B,YAAO,GAEX;YACF,IAAI,EAAE,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,EAAE,KAAK,EAAE;YAC/D,QAAQ,EAAE,EAAE,UAAU,EAAE,+BAA+B,EAAE,UAAU,EAAE,KAAK,EAAE;YAC5E,SAAS,EAAE,EAAE,UAAU,EAAE,2BAA2B,EAAE,UAAU,EAAE,KAAK,EAAE;YACzE,OAAO,EAAE,EAAE,UAAU,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AG,EAAE,MAAM,CAAC,EAAE,EAAE;gBACnD,OAAO;oBACL,YAAY,EAAE,CAAC,GAAG,MAAM,CAAC;oBACzB,eAAe,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,GAAG;iBAC7B,CAAC;YAClC,CAAC,CAAC;SACH,CAAC;IACJ,CAAC;CACF;AAnGD,0CAmGC","sourcesContent":["import { ImportDeclarationStructure } from \"ts-morph\";\n\nimport { ProjectFiles } from \"../data-model/DataModel\";\n\ntype ImportContainerType = {\n core: Set<string>;\n qobjects: Set<string>;\n clientApi: Set<string>;\n service: Set<string>;\n genModel: Set<string>;\n genQObjects: Set<string>;\n genServices: { [key: string]: Set<string> };\n customTypes: Map<string, Set<string>>;\n};\n\nexport class ImportContainer {\n private mapping: {\n [K in keyof ImportContainerType as string]: { moduleName: string; isRelative: boolean; addName?: boolean };\n } = {\n core: { moduleName: \"@odata2ts/odata-core\", isRelative: false },\n qobjects: { moduleName: \"@odata2ts/odata-query-objects\", isRelative: false },\n clientApi: { moduleName: \"@odata2ts/http-client-api\", isRelative: false },\n service: { moduleName: \"@odata2ts/odata-service\", isRelative: false },\n genModel: { moduleName: \"\", isRelative: true },\n genQObjects: { moduleName: \"\", isRelative: true },\n };\n\n private container: ImportContainerType = {\n core: new Set(),\n qobjects: new Set(),\n clientApi: new Set(),\n service: new Set(),\n genModel: new Set(),\n genQObjects: new Set(),\n genServices: {},\n customTypes: new Map(),\n };\n\n constructor(fileNames: ProjectFiles) {\n this.mapping.genModel.moduleName = fileNames.model;\n this.mapping.genQObjects.moduleName = fileNames.qObject;\n }\n\n public addFromCore(...names: Array<string>) {\n names.forEach((n) => this.container.core.add(n));\n }\n\n public addFromQObject(...names: Array<string>) {\n names.forEach((n) => this.container.qobjects.add(n));\n }\n\n public addFromClientApi(...names: Array<string>) {\n names.forEach((n) => this.container.clientApi.add(n));\n }\n\n public addFromService(...names: Array<string>) {\n names.forEach((n) => this.container.service.add(n));\n }\n\n public addGeneratedModel(...names: Array<string>) {\n names.forEach((n) => this.container.genModel.add(n));\n }\n\n public addGeneratedQObject(...names: Array<string>) {\n names.forEach((n) => this.container.genQObjects.add(n));\n }\n\n public addCustomType(moduleName: string, typeName: string) {\n let importList = this.container.customTypes.get(moduleName);\n if (!importList) {\n importList = new Set();\n this.container.customTypes.set(moduleName, importList);\n }\n importList.add(typeName);\n }\n\n public addGeneratedService(key: string, ...names: Array<string>) {\n let serv = this.container.genServices[key];\n if (!serv) {\n serv = new Set();\n this.container.genServices[key] = serv;\n }\n names.forEach((n) => serv.add(n));\n }\n\n public getImportDeclarations(fromSubPath: boolean = false): Array<ImportDeclarationStructure> {\n const { genServices, customTypes, ...standardImports } = this.container;\n\n return [\n ...[...customTypes.keys()]\n .filter((key) => !!customTypes.get(key)?.size)\n .map((key) => {\n return {\n namedImports: [...customTypes.get(key)!],\n moduleSpecifier: key,\n } as ImportDeclarationStructure;\n }),\n ...Object.entries(standardImports)\n .filter(([key, values]) => !!values.size)\n .map(([key, values]) => {\n const mapping = this.mapping[key];\n return {\n namedImports: [...values],\n moduleSpecifier: `${mapping.isRelative ? `${fromSubPath ? \"..\" : \".\"}/` : \"\"}${mapping.moduleName}`,\n } as ImportDeclarationStructure;\n }),\n ...Object.entries(genServices).map(([key, values]) => {\n return {\n namedImports: [...values],\n moduleSpecifier: (fromSubPath ? \"./\" : \"./service/\") + key,\n } as ImportDeclarationStructure;\n }),\n ];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ImportContainer.js","sourceRoot":"","sources":["../../src/generator/ImportContainer.ts"],"names":[],"mappings":";;;;AAeA,MAAa,eAAe;IAuB1B,YAAY,SAAuB;QAtB3B,YAAO,GAEX;YACF,IAAI,EAAE,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,EAAE,KAAK,EAAE;YAC/D,QAAQ,EAAE,EAAE,UAAU,EAAE,+BAA+B,EAAE,UAAU,EAAE,KAAK,EAAE;YAC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AC;YAClC,CAAC,CAAC;YACJ,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE;gBACnD,OAAO;oBACL,YAAY,EAAE,CAAC,GAAG,MAAM,CAAC;oBACzB,eAAe,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,GAAG;iBAC7B,CAAC;YAClC,CAAC,CAAC;SACH,CAAC;IACJ,CAAC;CACF;AAnGD,0CAmGC","sourcesContent":["import { ImportDeclarationStructure } from \"ts-morph\";\r\n\r\nimport { ProjectFiles } from \"../data-model/DataModel\";\r\n\r\ntype ImportContainerType = {\r\n core: Set<string>;\r\n qobjects: Set<string>;\r\n clientApi: Set<string>;\r\n service: Set<string>;\r\n genModel: Set<string>;\r\n genQObjects: Set<string>;\r\n genServices: { [key: string]: Set<string> };\r\n customTypes: Map<string, Set<string>>;\r\n};\r\n\r\nexport class ImportContainer {\r\n private mapping: {\r\n [K in keyof ImportContainerType as string]: { moduleName: string; isRelative: boolean; addName?: boolean };\r\n } = {\r\n core: { moduleName: \"@odata2ts/odata-core\", isRelative: false },\r\n qobjects: { moduleName: \"@odata2ts/odata-query-objects\", isRelative: false },\r\n clientApi: { moduleName: \"@odata2ts/http-client-api\", isRelative: false },\r\n service: { moduleName: \"@odata2ts/odata-service\", isRelative: false },\r\n genModel: { moduleName: \"\", isRelative: true },\r\n genQObjects: { moduleName: \"\", isRelative: true },\r\n };\r\n\r\n private container: ImportContainerType = {\r\n core: new Set(),\r\n qobjects: new Set(),\r\n clientApi: new Set(),\r\n service: new Set(),\r\n genModel: new Set(),\r\n genQObjects: new Set(),\r\n genServices: {},\r\n customTypes: new Map(),\r\n };\r\n\r\n constructor(fileNames: ProjectFiles) {\r\n this.mapping.genModel.moduleName = fileNames.model;\r\n this.mapping.genQObjects.moduleName = fileNames.qObject;\r\n }\r\n\r\n public addFromCore(...names: Array<string>) {\r\n names.forEach((n) => this.container.core.add(n));\r\n }\r\n\r\n public addFromQObject(...names: Array<string>) {\r\n names.forEach((n) => this.container.qobjects.add(n));\r\n }\r\n\r\n public addFromClientApi(...names: Array<string>) {\r\n names.forEach((n) => this.container.clientApi.add(n));\r\n }\r\n\r\n public addFromService(...names: Array<string>) {\r\n names.forEach((n) => this.container.service.add(n));\r\n }\r\n\r\n public addGeneratedModel(...names: Array<string>) {\r\n names.forEach((n) => this.container.genModel.add(n));\r\n }\r\n\r\n public addGeneratedQObject(...names: Array<string>) {\r\n names.forEach((n) => this.container.genQObjects.add(n));\r\n }\r\n\r\n public addCustomType(moduleName: string, typeName: string) {\r\n let importList = this.container.customTypes.get(moduleName);\r\n if (!importList) {\r\n importList = new Set();\r\n this.container.customTypes.set(moduleName, importList);\r\n }\r\n importList.add(typeName);\r\n }\r\n\r\n public addGeneratedService(key: string, ...names: Array<string>) {\r\n let serv = this.container.genServices[key];\r\n if (!serv) {\r\n serv = new Set();\r\n this.container.genServices[key] = serv;\r\n }\r\n names.forEach((n) => serv.add(n));\r\n }\r\n\r\n public getImportDeclarations(fromSubPath: boolean = false): Array<ImportDeclarationStructure> {\r\n const { genServices, customTypes, ...standardImports } = this.container;\r\n\r\n return [\r\n ...[...customTypes.keys()]\r\n .filter((key) => !!customTypes.get(key)?.size)\r\n .map((key) => {\r\n return {\r\n namedImports: [...customTypes.get(key)!],\r\n moduleSpecifier: key,\r\n } as ImportDeclarationStructure;\r\n }),\r\n ...Object.entries(standardImports)\r\n .filter(([key, values]) => !!values.size)\r\n .map(([key, values]) => {\r\n const mapping = this.mapping[key];\r\n return {\r\n namedImports: [...values],\r\n moduleSpecifier: `${mapping.isRelative ? `${fromSubPath ? \"..\" : \".\"}/` : \"\"}${mapping.moduleName}`,\r\n } as ImportDeclarationStructure;\r\n }),\r\n ...Object.entries(genServices).map(([key, values]) => {\r\n return {\r\n namedImports: [...values],\r\n moduleSpecifier: (fromSubPath ? \"./\" : \"./service/\") + key,\r\n } as ImportDeclarationStructure;\r\n }),\r\n ];\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,kEAAkC;AAClC,uCAOkB;AAClB,uDAAkD;AAClD,sDAA2D;AAmB3D,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;AAIF,SAAsB,gBAAgB,CACpC,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B;;QAE1B,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAClF,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;CAAA;AARD,4CAQC;AAED,MAAM,gBAAgB;IACpB,YACU,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B;QAH1B,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAgB;QACvB,YAAO,GAAP,OAAO,CAAe;QACtB,iBAAY,GAAZ,YAAY,CAAc;QA6I5B,2BAAsB,GAAG,CAAC,SAAwB,EAAE,EAAE;YAC5D,OAAO;gBACL,KAAK,EAAE,gBAAK,CAAC,OAAO;gBACpB,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,SAAS,CAAC,KAAK,CAAC;gBAC3D,IAAI,EAAE,SAAS,CAAC,KAAK;gBACrB,gBAAgB,EAAE,IAAI;aACvB,CAAC;QACJ,CAAC,CAAC;IAnJC,CAAC;IAES,QAAQ;;YACnB,MAAM,UAAU,GAAG,MAAM,IAAI,CAA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\"@odata2ts/odata-core\";\nimport deepmerge from \"deepmerge\";\nimport {\n ClassDeclarationStructure,\n MethodDeclarationStructure,\n OptionalKind,\n PropertyDeclarationStructure,\n Scope,\n SourceFile,\n} 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 EntityContainerModel,\n EntitySetType,\n FunctionImportType,\n ModelType,\n OperationType,\n OperationTypes,\n PropertyModel,\n SingletonType,\n} from \"../data-model/DataTypeModel\";\nimport { EntityType } from \"../data-model/edmx/ODataEdmxModelBase\";\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 interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, \"properties\" | \"methods\">> {}\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(\"ODataHttpClient\");\n importContainer.addFromService(ROOT_SERVICE);\n\n const { properties, methods }: PropsAndOps = deepmerge(\n this.generateMainServiceProperties(container, importContainer),\n this.generateMainServiceOperations(unboundOperations, importContainer)\n );\n\n sourceFile.addClass({\n isExported: true,\n name: serviceName,\n typeParameters: [\"ClientType extends ODataHttpClient\"],\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 ]*/,\n methods,\n });\n\n sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\n }\n\n private generateMainServiceProperties(\n container: EntityContainerModel,\n importContainer: ImportContainer\n ): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n Object.values(container.entitySets).forEach(({ name, entityType }) => {\n result.methods.push(this.generateRelatedServiceGetter(name, entityType, importContainer));\n });\n\n Object.values(container.singletons).forEach((singleton) => {\n result.properties.push(this.generateSingletonProp(singleton, importContainer));\n result.methods.push(this.generateSingletonGetter(singleton));\n });\n\n return result;\n }\n\n private generateMainServiceOperations(\n ops: Array<FunctionImportType | ActionImportType>,\n importContainer: ImportContainer\n ): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n ops.forEach(({ operation, name }) => {\n result.properties.push(this.generateQOperationProp(operation));\n result.methods.push(this.generateMethod(name, operation, importContainer));\n });\n\n return result;\n }\n\n private generateRelatedServiceGetter(\n propName: string,\n entityType: ModelType,\n importContainer: ImportContainer,\n currentServiceName?: string\n ): OptionalKind<MethodDeclarationStructure> {\n const idName = entityType.idModelName;\n const idFunctionName = entityType.qIdFunctionName;\n const serviceName = this.namingHelper.getServiceName(entityType.name);\n const collectionName = this.namingHelper.getCollectionServiceName(entityType.name);\n\n importContainer.addFromClientApi(\"ODataHttpClient\");\n importContainer.addGeneratedModel(idName);\n importContainer.addGeneratedQObject(idFunctionName);\n // make sure to not falsely import self-referential stuff\n if (!currentServiceName || currentServiceName !== serviceName) {\n importContainer.addGeneratedService(serviceName, collectionName, serviceName);\n }\n\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(propName),\n parameters: [\n {\n name: \"id\",\n type: `${idName} | undefined`,\n hasQuestionToken: true,\n },\n ],\n overloads: [\n {\n parameters: [],\n returnType: `${collectionName}<ClientType>`,\n },\n {\n parameters: [\n {\n name: \"id\",\n type: idName,\n },\n ],\n returnType: `${serviceName}<ClientType>`,\n },\n ],\n statements: [\n `const fieldName = \"${propName}\";`,\n 'return typeof id === \"undefined\" || id === null',\n `? new ${collectionName}(this.client, this.getPath(), fieldName)`,\n `: new ${serviceName}(this.client, this.getPath(), new ${idFunctionName}(fieldName).buildUrl(id));`,\n ],\n };\n }\n\n private generateSingletonProp(\n singleton: SingletonType,\n importContainer: ImportContainer\n ): OptionalKind<PropertyDeclarationStructure> {\n const { name, entityType } = singleton;\n const type = this.namingHelper.getServiceName(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 private generateQOperationProp = (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 generateSingletonGetter(singleton: SingletonType): OptionalKind<MethodDeclarationStructure> {\n const { name, odataName, entityType } = singleton;\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\n const serviceType = this.namingHelper.getServiceName(entityType.name);\n\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 private getVersionSuffix() {\n return this.version === ODataVersions.V2 ? \"V2\" : \"V4\";\n }\n\n private async generateEntityTypeService(\n model: ComplexType,\n serviceName: string,\n serviceFile: SourceFile,\n importContainer: ImportContainer\n ) {\n const entityServiceType = \"EntityTypeService\" + this.getVersionSuffix();\n\n const editableModelName = model.editableName;\n const qObjectName = firstCharLowerCase(model.qName);\n const operations = this.dataModel.getOperationTypeByBinding(model.name);\n const props = [...model.baseProps, ...model.props];\n\n importContainer.addFromService(entityServiceType);\n importContainer.addFromClientApi(\"ODataHttpClient\");\n importContainer.addGeneratedModel(model.name, editableModelName);\n importContainer.addGeneratedQObject(model.qName, qObjectName);\n\n const { properties, methods }: PropsAndOps = deepmerge(\n this.generateServiceProperties(serviceName, props, importContainer),\n this.generateServiceOperations(operations, importContainer)\n );\n\n // generate EntityTypeService\n serviceFile.addClass({\n isExported: true,\n name: serviceName,\n typeParameters: [\"ClientType extends ODataHttpClient\"],\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, ${qObjectName});`],\n },\n ],\n properties,\n methods,\n });\n }\n\n private generateServiceProperties(\n serviceName: string,\n props: Array<PropertyModel>,\n importContainer: ImportContainer\n ): PropsAndOps {\n const collectionServiceType = \"CollectionService\" + this.getVersionSuffix();\n const result: PropsAndOps = { properties: [], methods: [] };\n\n props.forEach((prop) => {\n if ((prop.dataType === DataTypes.ModelType && !prop.isCollection) || prop.dataType === DataTypes.ComplexType) {\n result.properties.push(this.generateModelProp(prop, collectionServiceType, serviceName, importContainer));\n result.methods.push(this.generateModelPropGetter(prop, collectionServiceType));\n } else if (prop.isCollection) {\n // collection of entity types\n if (prop.dataType === DataTypes.ModelType) {\n const entityType = this.dataModel.getModel(prop.type);\n result.methods.push(this.generateRelatedServiceGetter(prop.name, entityType, importContainer, serviceName));\n }\n // collection of primitive or complex types\n else {\n result.properties.push(this.generatePrimitiveCollectionProp(prop, collectionServiceType, importContainer));\n result.methods.push(this.generatePrimitiveCollectionGetter(prop, collectionServiceType));\n }\n }\n });\n\n return result;\n }\n\n private generateServiceOperations(operations: Array<OperationType>, importContainer: ImportContainer): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n operations.forEach((operation) => {\n result.properties.push(this.generateQOperationProp(operation));\n result.methods.push(this.generateMethod(operation.name, operation, importContainer));\n });\n\n return result;\n }\n\n private generateModelProp(\n prop: PropertyModel,\n collectionServiceType: string,\n serviceName: string,\n importContainer: ImportContainer\n ): PropertyDeclarationStructure {\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 private generatePrimitiveCollectionProp(\n prop: PropertyModel,\n collectionServiceType: string,\n importContainer: ImportContainer\n ): OptionalKind<PropertyDeclarationStructure> {\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 };\n }\n\n private generateModelPropGetter(\n prop: PropertyModel,\n collectionServiceType: string\n ): OptionalKind<MethodDeclarationStructure> {\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 };\n }\n\n private generatePrimitiveCollectionGetter(\n prop: PropertyModel,\n collectionServiceType: string\n ): OptionalKind<MethodDeclarationStructure> {\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 };\n }\n\n private async generateEntityCollectionService(\n model: ModelType,\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 const { properties, methods } = this.generateServiceOperations(collectionOperations, importContainer);\n\n serviceFile.addClass({\n isExported: true,\n name: this.namingHelper.getCollectionServiceName(model.name),\n typeParameters: [\"ClientType extends ODataHttpClient\"],\n extends:\n entitySetServiceType +\n `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}, ${model.idModelName}>`,\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, ${qObjectName}, new ${model.qIdFunctionName}(name));`],\n },\n ],\n properties,\n methods,\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.generateEntityTypeService(model, serviceName, serviceFile, importContainer);\n\n // entity collection service\n await this.generateEntityCollectionService(model, 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.generateEntityTypeService(model, serviceName, serviceFile, importContainer);\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\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 = {\n name: \"requestConfig\",\n hasQuestionToken: true,\n type: \"ODataHttpClientConfig<ClientType>\",\n };\n const hasParams = operation.parameters.length > 0;\n\n // importing dependencies\n importContainer.addFromClientApi(\"ODataHttpClientConfig\", \"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"]}
|
|
1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CAAC,CAAC;QAEhF,OAAO;YACL,KAAK,EAAE,gBAAK,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI;YACb,IAAI;YACJ,UAAU,EAAE,SAAS;gBACnB,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,eAAe,EAAE,EAAE,kBAAkB,CAAC;gBAC3E,CAAC,CAAC,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\";\r\nimport deepmerge from \"deepmerge\";\r\nimport {\r\n ClassDeclarationStructure,\r\n MethodDeclarationStructure,\r\n OptionalKind,\r\n PropertyDeclarationStructure,\r\n Scope,\r\n SourceFile,\r\n} 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 EntityContainerModel,\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 { EntityType } from \"../data-model/edmx/ODataEdmxModelBase\";\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 interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, \"properties\" | \"methods\">> {}\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(\"ODataHttpClient\");\r\n importContainer.addFromService(ROOT_SERVICE);\r\n\r\n const { properties, methods }: PropsAndOps = deepmerge(\r\n this.generateMainServiceProperties(container, importContainer),\r\n this.generateMainServiceOperations(unboundOperations, importContainer)\r\n );\r\n\r\n sourceFile.addClass({\r\n isExported: true,\r\n name: serviceName,\r\n typeParameters: [\"ClientType extends ODataHttpClient\"],\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 ]*/,\r\n methods,\r\n });\r\n\r\n sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\r\n }\r\n\r\n private generateMainServiceProperties(\r\n container: EntityContainerModel,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n Object.values(container.entitySets).forEach(({ name, entityType }) => {\r\n result.methods.push(this.generateRelatedServiceGetter(name, entityType, importContainer));\r\n });\r\n\r\n Object.values(container.singletons).forEach((singleton) => {\r\n result.properties.push(this.generateSingletonProp(singleton, importContainer));\r\n result.methods.push(this.generateSingletonGetter(singleton));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateMainServiceOperations(\r\n ops: Array<FunctionImportType | ActionImportType>,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n ops.forEach(({ operation, name }) => {\r\n result.properties.push(this.generateQOperationProp(operation));\r\n result.methods.push(this.generateMethod(name, operation, importContainer));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateRelatedServiceGetter(\r\n propName: string,\r\n entityType: ModelType,\r\n importContainer: ImportContainer,\r\n currentServiceName?: string\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const idName = entityType.idModelName;\r\n const idFunctionName = entityType.qIdFunctionName;\r\n const serviceName = this.namingHelper.getServiceName(entityType.name);\r\n const collectionName = this.namingHelper.getCollectionServiceName(entityType.name);\r\n\r\n importContainer.addFromClientApi(\"ODataHttpClient\");\r\n importContainer.addGeneratedModel(idName);\r\n importContainer.addGeneratedQObject(idFunctionName);\r\n // make sure to not falsely import self-referential stuff\r\n if (!currentServiceName || currentServiceName !== serviceName) {\r\n importContainer.addGeneratedService(serviceName, collectionName, serviceName);\r\n }\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(propName),\r\n parameters: [\r\n {\r\n name: \"id\",\r\n type: `${idName} | undefined`,\r\n hasQuestionToken: true,\r\n },\r\n ],\r\n overloads: [\r\n {\r\n parameters: [],\r\n returnType: `${collectionName}<ClientType>`,\r\n },\r\n {\r\n parameters: [\r\n {\r\n name: \"id\",\r\n type: idName,\r\n },\r\n ],\r\n returnType: `${serviceName}<ClientType>`,\r\n },\r\n ],\r\n statements: [\r\n `const fieldName = \"${propName}\";`,\r\n 'return typeof id === \"undefined\" || id === null',\r\n `? new ${collectionName}(this.client, this.getPath(), fieldName)`,\r\n `: new ${serviceName}(this.client, this.getPath(), new ${idFunctionName}(fieldName).buildUrl(id));`,\r\n ],\r\n };\r\n }\r\n\r\n private generateSingletonProp(\r\n singleton: SingletonType,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const { name, entityType } = singleton;\r\n const type = this.namingHelper.getServiceName(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 private generateQOperationProp = (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 generateSingletonGetter(singleton: SingletonType): OptionalKind<MethodDeclarationStructure> {\r\n const { name, odataName, entityType } = singleton;\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\r\n const serviceType = this.namingHelper.getServiceName(entityType.name);\r\n\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 private getVersionSuffix() {\r\n return this.version === ODataVersions.V2 ? \"V2\" : \"V4\";\r\n }\r\n\r\n private async generateEntityTypeService(\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\r\n const editableModelName = model.editableName;\r\n const qObjectName = firstCharLowerCase(model.qName);\r\n const operations = this.dataModel.getOperationTypeByBinding(model.name);\r\n const props = [...model.baseProps, ...model.props];\r\n\r\n importContainer.addFromService(entityServiceType);\r\n importContainer.addFromClientApi(\"ODataHttpClient\");\r\n importContainer.addGeneratedModel(model.name, editableModelName);\r\n importContainer.addGeneratedQObject(model.qName, qObjectName);\r\n\r\n const { properties, methods }: PropsAndOps = deepmerge(\r\n this.generateServiceProperties(serviceName, props, importContainer),\r\n this.generateServiceOperations(operations, importContainer)\r\n );\r\n\r\n // generate EntityTypeService\r\n serviceFile.addClass({\r\n isExported: true,\r\n name: serviceName,\r\n typeParameters: [\"ClientType extends ODataHttpClient\"],\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, ${qObjectName});`],\r\n },\r\n ],\r\n properties,\r\n methods,\r\n });\r\n }\r\n\r\n private generateServiceProperties(\r\n serviceName: string,\r\n props: Array<PropertyModel>,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const collectionServiceType = \"CollectionService\" + this.getVersionSuffix();\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n props.forEach((prop) => {\r\n if ((prop.dataType === DataTypes.ModelType && !prop.isCollection) || prop.dataType === DataTypes.ComplexType) {\r\n result.properties.push(this.generateModelProp(prop, collectionServiceType, serviceName, importContainer));\r\n result.methods.push(this.generateModelPropGetter(prop, collectionServiceType));\r\n } else if (prop.isCollection) {\r\n // collection of entity types\r\n if (prop.dataType === DataTypes.ModelType) {\r\n const entityType = this.dataModel.getModel(prop.type);\r\n result.methods.push(this.generateRelatedServiceGetter(prop.name, entityType, importContainer, serviceName));\r\n }\r\n // collection of primitive or complex types\r\n else {\r\n result.properties.push(this.generatePrimitiveCollectionProp(prop, collectionServiceType, importContainer));\r\n result.methods.push(this.generatePrimitiveCollectionGetter(prop, collectionServiceType));\r\n }\r\n }\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateServiceOperations(operations: Array<OperationType>, importContainer: ImportContainer): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n operations.forEach((operation) => {\r\n result.properties.push(this.generateQOperationProp(operation));\r\n result.methods.push(this.generateMethod(operation.name, operation, importContainer));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateModelProp(\r\n prop: PropertyModel,\r\n collectionServiceType: string,\r\n serviceName: string,\r\n importContainer: ImportContainer\r\n ): PropertyDeclarationStructure {\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 private generatePrimitiveCollectionProp(\r\n prop: PropertyModel,\r\n collectionServiceType: string,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure> {\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 };\r\n }\r\n\r\n private generateModelPropGetter(\r\n prop: PropertyModel,\r\n collectionServiceType: string\r\n ): OptionalKind<MethodDeclarationStructure> {\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 };\r\n }\r\n\r\n private generatePrimitiveCollectionGetter(\r\n prop: PropertyModel,\r\n collectionServiceType: string\r\n ): OptionalKind<MethodDeclarationStructure> {\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 };\r\n }\r\n\r\n private async generateEntityCollectionService(\r\n model: ModelType,\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 const { properties, methods } = this.generateServiceOperations(collectionOperations, importContainer);\r\n\r\n serviceFile.addClass({\r\n isExported: true,\r\n name: this.namingHelper.getCollectionServiceName(model.name),\r\n typeParameters: [\"ClientType extends ODataHttpClient\"],\r\n extends:\r\n entitySetServiceType +\r\n `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}, ${model.idModelName}>`,\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, ${qObjectName}, new ${model.qIdFunctionName}(name));`],\r\n },\r\n ],\r\n properties,\r\n methods,\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.generateEntityTypeService(model, serviceName, serviceFile, importContainer);\r\n\r\n // entity collection service\r\n await this.generateEntityCollectionService(model, 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.generateEntityTypeService(model, serviceName, serviceFile, importContainer);\r\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\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 = {\r\n name: \"requestConfig\",\r\n hasQuestionToken: true,\r\n type: \"ODataHttpClientConfig<ClientType>\",\r\n };\r\n const hasParams = operation.parameters.length > 0;\r\n\r\n // importing dependencies\r\n importContainer.addFromClientApi(\"ODataHttpClientConfig\", \"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"]}
|
|
@@ -21,7 +21,7 @@ function createProjectManager(projectFiles, outputDir, emitMode, usePrettier, ts
|
|
|
21
21
|
importsNotUsedAsValues, // type is missing
|
|
22
22
|
jsx, plugins,
|
|
23
23
|
// mapped props
|
|
24
|
-
moduleResolution, lib, module, newLine, target } = _a, passThrough = tslib_1.__rest(_a, ["noEmit", "importsNotUsedAsValues", "jsx", "plugins", "moduleResolution", "lib", "module", "newLine", "target"]);
|
|
24
|
+
moduleResolution, lib, module, newLine, target, rootDir, rootDirs } = _a, passThrough = tslib_1.__rest(_a, ["noEmit", "importsNotUsedAsValues", "jsx", "plugins", "moduleResolution", "lib", "module", "newLine", "target", "rootDir", "rootDirs"]);
|
|
25
25
|
const compilerOpts = Object.assign(Object.assign({}, passThrough), { outDir: outputDir, declaration: generateDeclarations, moduleResolution: getModuleResolutionKind(moduleResolution), module: getModuleKind(module), target: getTarget(target), lib: lib, newLine: (newLine === null || newLine === void 0 ? void 0 : newLine.toLowerCase()) === "crlf"
|
|
26
26
|
? ts_morph_1.NewLineKind.CarriageReturnLineFeed
|
|
27
27
|
: (newLine === null || newLine === void 0 ? void 0 : newLine.toLowerCase()) === "lf"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectManager.js","sourceRoot":"","sources":["../../src/project/ProjectManager.ts"],"names":[],"mappings":";;;;AAAA,0CAAwC;AACxC,mDAA6B;AAE7B,uCAA4C;AAC5C,uCAQkB;AAClB,8EAAmC;AACnC,oEAA4B;AAG5B,gDAA2C;AAC3C,2CAA8C;AAG9C,SAAsB,oBAAoB,CACxC,YAA0B,EAC1B,SAAiB,EACjB,QAAmB,EACnB,WAAoB,EACpB,eAAuB,eAAe;;QAEtC,MAAM,oBAAoB,GAAG,uBAAS,CAAC,MAAM,KAAK,QAAQ,IAAI,uBAAS,CAAC,GAAG,KAAK,QAAQ,CAAC;QACzF,MAAM,IAAI,GAAG,IAAA,yBAAI,EAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CA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jE;;gBAEI;QACN,CAAC;KAAA;IAEa,WAAW;;YACvB,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,kBAAkB,EAAE,EAAE,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;YACjH,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,CAAC,MAAM,WAAW,CAAC,CAAC;YACjD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACvF,CAAC;KAAA;CAqBF;AAjID,wCAiIC","sourcesContent":["import { writeFile } from \"fs/promises\";\r\nimport * as path from \"path\";\r\n\r\nimport { emptyDir, remove } from \"fs-extra\";\r\nimport {\r\n CompilerOptions,\r\n ModuleKind,\r\n ModuleResolutionKind,\r\n NewLineKind,\r\n Project,\r\n ScriptTarget,\r\n SourceFile,\r\n} from \"ts-morph\";\r\nimport load from \"tsconfig-loader\";\r\nimport ts from \"typescript\";\r\n\r\nimport { ProjectFiles } from \"../data-model/DataModel\";\r\nimport { EmitModes } from \"../OptionModel\";\r\nimport { createFormatter } from \"./formatter\";\r\nimport { FileFormatter } from \"./formatter/FileFormatter\";\r\n\r\nexport async function createProjectManager(\r\n projectFiles: ProjectFiles,\r\n outputDir: string,\r\n emitMode: EmitModes,\r\n usePrettier: boolean,\r\n tsConfigPath: string = \"tsconfig.json\"\r\n): Promise<ProjectManager> {\r\n const generateDeclarations = EmitModes.js_dts === emitMode || EmitModes.dts === emitMode;\r\n const conf = load({ filename: tsConfigPath });\r\n const formatter = await createFormatter(outputDir, usePrettier);\r\n\r\n const {\r\n // ignored props\r\n noEmit, // we always want to emit\r\n importsNotUsedAsValues, // type is missing\r\n jsx,\r\n plugins,\r\n // mapped props\r\n moduleResolution,\r\n lib,\r\n module,\r\n newLine,\r\n target,\r\n ...passThrough\r\n } = conf?.tsConfig.compilerOptions || {};\r\n\r\n const compilerOpts: CompilerOptions = {\r\n ...passThrough,\r\n outDir: outputDir,\r\n declaration: generateDeclarations,\r\n moduleResolution: getModuleResolutionKind(moduleResolution),\r\n module: getModuleKind(module),\r\n target: getTarget(target),\r\n lib: lib as string[],\r\n newLine:\r\n newLine?.toLowerCase() === \"crlf\"\r\n ? NewLineKind.CarriageReturnLineFeed\r\n : newLine?.toLowerCase() === \"lf\"\r\n ? NewLineKind.LineFeed\r\n : undefined,\r\n };\r\n\r\n return new ProjectManager(projectFiles, outputDir, emitMode, formatter, compilerOpts);\r\n}\r\n\r\nfunction getModuleResolutionKind(\r\n moduleResolution: string | undefined | Record<string, any>\r\n): ModuleResolutionKind | undefined {\r\n const modRes =\r\n typeof moduleResolution === \"string\"\r\n ? moduleResolution.toLowerCase() === \"node\"\r\n ? \"nodejs\"\r\n : moduleResolution.toLowerCase()\r\n : undefined;\r\n const matchedKey = Object.keys(ts.ModuleResolutionKind).find(\r\n (mk): mk is keyof typeof ModuleResolutionKind => mk.toLowerCase() === modRes\r\n );\r\n return matchedKey ? (ts.ModuleResolutionKind[matchedKey] as ModuleResolutionKind) : undefined;\r\n}\r\n\r\nfunction getModuleKind(module: string | undefined | Record<string, any>): ModuleKind | undefined {\r\n const mod = typeof module === \"string\" ? module.toLowerCase() : undefined;\r\n const matchedKey = Object.keys(ts.ModuleKind).find((mk): mk is keyof typeof ModuleKind => mk.toLowerCase() === mod);\r\n return matchedKey ? (ts.ModuleKind[matchedKey] as ModuleKind) : undefined;\r\n}\r\n\r\nfunction getTarget(target: string | undefined | Record<string, any>): ScriptTarget | undefined {\r\n const t = typeof target === \"string\" ? target.toLowerCase() : undefined;\r\n const matchedKey = Object.keys(ts.ScriptTarget).find((st): st is keyof typeof ScriptTarget => st.toLowerCase() === t);\r\n return matchedKey ? (ts.ScriptTarget[matchedKey] as ScriptTarget) : undefined;\r\n}\r\n\r\nconst STATIC_SERVICE_DIR = \"service\";\r\n\r\nexport class ProjectManager {\r\n private project!: Project;\r\n\r\n private files: { [name: string]: SourceFile } = {};\r\n private serviceFiles: Array<SourceFile> = [];\r\n\r\n constructor(\r\n private projectFiles: ProjectFiles,\r\n private outputDir: string,\r\n private emitMode: EmitModes,\r\n private formatter: FileFormatter,\r\n compilerOptions: CompilerOptions | undefined\r\n ) {\r\n // Create ts-morph project\r\n this.project = new Project({\r\n manipulationSettings: this.formatter.getSettings(),\r\n skipAddingFilesFromTsConfig: true,\r\n compilerOptions,\r\n });\r\n }\r\n\r\n private async createFile(name: string) {\r\n const fileName = path.join(this.outputDir, `${name}.ts`);\r\n await remove(fileName);\r\n return this.project.createSourceFile(fileName);\r\n }\r\n\r\n public async createModelFile() {\r\n this.files.model = await this.createFile(this.projectFiles.model);\r\n return this.getModelFile();\r\n }\r\n\r\n public getModelFile() {\r\n return this.files.model;\r\n }\r\n\r\n public async createQObjectFile() {\r\n this.files.qobject = await this.createFile(this.projectFiles.qObject);\r\n return this.getQObjectFile();\r\n }\r\n\r\n public getQObjectFile() {\r\n return this.files.qobject;\r\n }\r\n\r\n public async createMainServiceFile() {\r\n this.files.mainService = await this.createFile(this.projectFiles.service);\r\n return this.getMainServiceFile();\r\n }\r\n\r\n public getMainServiceFile() {\r\n return this.files.mainService;\r\n }\r\n\r\n public getServiceDir() {\r\n return path.join(this.outputDir, STATIC_SERVICE_DIR);\r\n }\r\n\r\n public async cleanServiceDir() {\r\n return emptyDir(this.getServiceDir());\r\n }\r\n\r\n public async createServiceFile(name: string) {\r\n const file = await this.createFile(path.join(STATIC_SERVICE_DIR, name));\r\n this.serviceFiles.push(file);\r\n\r\n return file;\r\n }\r\n\r\n public getServiceFiles() {\r\n return this.serviceFiles;\r\n }\r\n\r\n public async writeFiles() {\r\n switch (this.emitMode) {\r\n case EmitModes.js:\r\n case EmitModes.js_dts:\r\n await this.emitJsFiles();\r\n break;\r\n case EmitModes.dts:\r\n await this.emitJsFiles(true);\r\n break;\r\n case EmitModes.ts:\r\n await this.emitTsFiles();\r\n break;\r\n default:\r\n throw new Error(`Emit mode \"${this.emitMode}\" is invalid!`);\r\n }\r\n }\r\n\r\n private async emitJsFiles(declarationOnly?: boolean) {\r\n console.log(\r\n declarationOnly\r\n ? \"Emitting declaration files\"\r\n : `Emitting JS files (${this.emitMode === EmitModes.js_dts ? \"including\" : \"without\"} declaration files)`\r\n );\r\n\r\n await this.project.emit({ emitOnlyDtsFiles: !!declarationOnly });\r\n\r\n /* for (const diagnostic of this.project.getPreEmitDiagnostics()) {\r\n console.log(diagnostic.getMessageText());\r\n } */\r\n }\r\n\r\n private async emitTsFiles() {\r\n const files = [this.getModelFile(), this.getQObjectFile(), this.getMainServiceFile(), ...this.getServiceFiles()];\r\n console.log(`Emitting ${files.length} TS files`);\r\n return Promise.all([...files.filter((file) => !!file).map(this.formatAndWriteFile)]);\r\n }\r\n\r\n private formatAndWriteFile = async (file: SourceFile) => {\r\n const fileName = file.getFilePath();\r\n const content = file.getFullText();\r\n\r\n try {\r\n const formatted = await this.formatter.format(content);\r\n\r\n try {\r\n return writeFile(fileName, formatted);\r\n } catch (writeError) {\r\n console.error(`Failed to write file [/${fileName}]`, writeError);\r\n process.exit(3);\r\n }\r\n } catch (formattingError) {\r\n console.error(\"Formatting failed\");\r\n await writeFile(\"error.log\", formattingError?.toString() || \"no error message!\");\r\n process.exit(99);\r\n }\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ProjectManager.js","sourceRoot":"","sources":["../../src/project/ProjectManager.ts"],"names":[],"mappings":";;;;AAAA,0CAAwC;AACxC,mDAA6B;AAE7B,uCAA4C;AAC5C,uCAQkB;AAClB,8EAAmC;AACnC,oEAA4B;AAG5B,gDAA2C;AAC3C,2CAA8C;AAG9C,SAAsB,oBAAoB,CACxC,YAA0B,EAC1B,SAAiB,EACjB,QAAmB,EACnB,WAAoB,EACpB,eAAu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AI,CAAC,QAAQ,KAAK,uBAAS,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,qBAAqB,CAC5G,CAAC;YAEF,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;YAEjE;;gBAEI;QACN,CAAC;KAAA;IAEa,WAAW;;YACvB,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,kBAAkB,EAAE,EAAE,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;YACjH,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,CAAC,MAAM,WAAW,CAAC,CAAC;YACjD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACvF,CAAC;KAAA;CAqBF;AAjID,wCAiIC","sourcesContent":["import { writeFile } from \"fs/promises\";\r\nimport * as path from \"path\";\r\n\r\nimport { emptyDir, remove } from \"fs-extra\";\r\nimport {\r\n CompilerOptions,\r\n ModuleKind,\r\n ModuleResolutionKind,\r\n NewLineKind,\r\n Project,\r\n ScriptTarget,\r\n SourceFile,\r\n} from \"ts-morph\";\r\nimport load from \"tsconfig-loader\";\r\nimport ts from \"typescript\";\r\n\r\nimport { ProjectFiles } from \"../data-model/DataModel\";\r\nimport { EmitModes } from \"../OptionModel\";\r\nimport { createFormatter } from \"./formatter\";\r\nimport { FileFormatter } from \"./formatter/FileFormatter\";\r\n\r\nexport async function createProjectManager(\r\n projectFiles: ProjectFiles,\r\n outputDir: string,\r\n emitMode: EmitModes,\r\n usePrettier: boolean,\r\n tsConfigPath: string = \"tsconfig.json\"\r\n): Promise<ProjectManager> {\r\n const generateDeclarations = EmitModes.js_dts === emitMode || EmitModes.dts === emitMode;\r\n const conf = load({ filename: tsConfigPath });\r\n const formatter = await createFormatter(outputDir, usePrettier);\r\n\r\n const {\r\n // ignored props\r\n noEmit, // we always want to emit\r\n importsNotUsedAsValues, // type is missing\r\n jsx,\r\n plugins,\r\n // mapped props\r\n moduleResolution,\r\n lib,\r\n module,\r\n newLine,\r\n target,\r\n rootDir,\r\n rootDirs,\r\n ...passThrough\r\n } = conf?.tsConfig.compilerOptions || {};\r\n\r\n const compilerOpts: CompilerOptions = {\r\n ...passThrough,\r\n outDir: outputDir,\r\n declaration: generateDeclarations,\r\n moduleResolution: getModuleResolutionKind(moduleResolution),\r\n module: getModuleKind(module),\r\n target: getTarget(target),\r\n lib: lib as string[],\r\n newLine:\r\n newLine?.toLowerCase() === \"crlf\"\r\n ? NewLineKind.CarriageReturnLineFeed\r\n : newLine?.toLowerCase() === \"lf\"\r\n ? NewLineKind.LineFeed\r\n : undefined,\r\n };\r\n\r\n return new ProjectManager(projectFiles, outputDir, emitMode, formatter, compilerOpts);\r\n}\r\n\r\nfunction getModuleResolutionKind(\r\n moduleResolution: string | undefined | Record<string, any>\r\n): ModuleResolutionKind | undefined {\r\n const modRes =\r\n typeof moduleResolution === \"string\"\r\n ? moduleResolution.toLowerCase() === \"node\"\r\n ? \"nodejs\"\r\n : moduleResolution.toLowerCase()\r\n : undefined;\r\n const matchedKey = Object.keys(ts.ModuleResolutionKind).find(\r\n (mk): mk is keyof typeof ModuleResolutionKind => mk.toLowerCase() === modRes\r\n );\r\n return matchedKey ? (ts.ModuleResolutionKind[matchedKey] as ModuleResolutionKind) : undefined;\r\n}\r\n\r\nfunction getModuleKind(module: string | undefined | Record<string, any>): ModuleKind | undefined {\r\n const mod = typeof module === \"string\" ? module.toLowerCase() : undefined;\r\n const matchedKey = Object.keys(ts.ModuleKind).find((mk): mk is keyof typeof ModuleKind => mk.toLowerCase() === mod);\r\n return matchedKey ? (ts.ModuleKind[matchedKey] as ModuleKind) : undefined;\r\n}\r\n\r\nfunction getTarget(target: string | undefined | Record<string, any>): ScriptTarget | undefined {\r\n const t = typeof target === \"string\" ? target.toLowerCase() : undefined;\r\n const matchedKey = Object.keys(ts.ScriptTarget).find((st): st is keyof typeof ScriptTarget => st.toLowerCase() === t);\r\n return matchedKey ? (ts.ScriptTarget[matchedKey] as ScriptTarget) : undefined;\r\n}\r\n\r\nconst STATIC_SERVICE_DIR = \"service\";\r\n\r\nexport class ProjectManager {\r\n private project!: Project;\r\n\r\n private files: { [name: string]: SourceFile } = {};\r\n private serviceFiles: Array<SourceFile> = [];\r\n\r\n constructor(\r\n private projectFiles: ProjectFiles,\r\n private outputDir: string,\r\n private emitMode: EmitModes,\r\n private formatter: FileFormatter,\r\n compilerOptions: CompilerOptions | undefined\r\n ) {\r\n // Create ts-morph project\r\n this.project = new Project({\r\n manipulationSettings: this.formatter.getSettings(),\r\n skipAddingFilesFromTsConfig: true,\r\n compilerOptions,\r\n });\r\n }\r\n\r\n private async createFile(name: string) {\r\n const fileName = path.join(this.outputDir, `${name}.ts`);\r\n await remove(fileName);\r\n return this.project.createSourceFile(fileName);\r\n }\r\n\r\n public async createModelFile() {\r\n this.files.model = await this.createFile(this.projectFiles.model);\r\n return this.getModelFile();\r\n }\r\n\r\n public getModelFile() {\r\n return this.files.model;\r\n }\r\n\r\n public async createQObjectFile() {\r\n this.files.qobject = await this.createFile(this.projectFiles.qObject);\r\n return this.getQObjectFile();\r\n }\r\n\r\n public getQObjectFile() {\r\n return this.files.qobject;\r\n }\r\n\r\n public async createMainServiceFile() {\r\n this.files.mainService = await this.createFile(this.projectFiles.service);\r\n return this.getMainServiceFile();\r\n }\r\n\r\n public getMainServiceFile() {\r\n return this.files.mainService;\r\n }\r\n\r\n public getServiceDir() {\r\n return path.join(this.outputDir, STATIC_SERVICE_DIR);\r\n }\r\n\r\n public async cleanServiceDir() {\r\n return emptyDir(this.getServiceDir());\r\n }\r\n\r\n public async createServiceFile(name: string) {\r\n const file = await this.createFile(path.join(STATIC_SERVICE_DIR, name));\r\n this.serviceFiles.push(file);\r\n\r\n return file;\r\n }\r\n\r\n public getServiceFiles() {\r\n return this.serviceFiles;\r\n }\r\n\r\n public async writeFiles() {\r\n switch (this.emitMode) {\r\n case EmitModes.js:\r\n case EmitModes.js_dts:\r\n await this.emitJsFiles();\r\n break;\r\n case EmitModes.dts:\r\n await this.emitJsFiles(true);\r\n break;\r\n case EmitModes.ts:\r\n await this.emitTsFiles();\r\n break;\r\n default:\r\n throw new Error(`Emit mode \"${this.emitMode}\" is invalid!`);\r\n }\r\n }\r\n\r\n private async emitJsFiles(declarationOnly?: boolean) {\r\n console.log(\r\n declarationOnly\r\n ? \"Emitting declaration files\"\r\n : `Emitting JS files (${this.emitMode === EmitModes.js_dts ? \"including\" : \"without\"} declaration files)`\r\n );\r\n\r\n await this.project.emit({ emitOnlyDtsFiles: !!declarationOnly });\r\n\r\n /* for (const diagnostic of this.project.getPreEmitDiagnostics()) {\r\n console.log(diagnostic.getMessageText());\r\n } */\r\n }\r\n\r\n private async emitTsFiles() {\r\n const files = [this.getModelFile(), this.getQObjectFile(), this.getMainServiceFile(), ...this.getServiceFiles()];\r\n console.log(`Emitting ${files.length} TS files`);\r\n return Promise.all([...files.filter((file) => !!file).map(this.formatAndWriteFile)]);\r\n }\r\n\r\n private formatAndWriteFile = async (file: SourceFile) => {\r\n const fileName = file.getFilePath();\r\n const content = file.getFullText();\r\n\r\n try {\r\n const formatted = await this.formatter.format(content);\r\n\r\n try {\r\n return writeFile(fileName, formatted);\r\n } catch (writeError) {\r\n console.error(`Failed to write file [/${fileName}]`, writeError);\r\n process.exit(3);\r\n }\r\n } catch (formattingError) {\r\n console.error(\"Formatting failed\");\r\n await writeFile(\"error.log\", formattingError?.toString() || \"no error message!\");\r\n process.exit(99);\r\n }\r\n };\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odata2ts/odata2ts",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -86,6 +86,6 @@
|
|
|
86
86
|
"typescript": "^5.1.3"
|
|
87
87
|
},
|
|
88
88
|
"types": "./lib/index.d.ts",
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "23f1b96efe6142a9ac8a291df80dd42f46368794",
|
|
90
90
|
"readme": "README.md"
|
|
91
91
|
}
|