@odata2ts/odata2ts 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +81 -81
- package/lib/FactoryFunctionModel.js.map +1 -1
- package/lib/TypeModel.js.map +1 -1
- package/lib/app.js.map +1 -1
- package/lib/cli.js.map +1 -1
- package/lib/data-model/DataModelDigestion.js +2 -1
- package/lib/data-model/DataModelDigestion.js.map +1 -1
- package/lib/data-model/edmx/ODataEdmxModelBase.d.ts +1 -1
- package/lib/data-model/edmx/ODataEdmxModelBase.js.map +1 -1
- package/lib/data-model/validation/NameValidator.js.map +1 -1
- package/lib/data-model/validation/NoopValidator.js.map +1 -1
- package/lib/generator/ImportedNameValidator.js.map +1 -1
- package/lib/generator/ServiceGenerator.js +3 -3
- package/lib/generator/ServiceGenerator.js.map +1 -1
- package/lib/generator/import/ImportObjects.js.map +1 -1
- package/lib/project/TsMorphHelper.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.35.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.34.0...@odata2ts/odata2ts@0.35.0) (2024-05-16)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* empty enum ([#270](https://github.com/odata2ts/odata2ts/issues/270)) ([32eeb1e](https://github.com/odata2ts/odata2ts/commit/32eeb1e587f507a138ca96d81c7ab3da4c0bdba8))
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* invariant client type ([#272](https://github.com/odata2ts/odata2ts/issues/272)) ([0ee3c94](https://github.com/odata2ts/odata2ts/commit/0ee3c94d3bf34e7774e1be8dad657ed5e64e597e))
|
|
15
|
+
|
|
6
16
|
# [0.34.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.33.2...@odata2ts/odata2ts@0.34.0) (2024-05-03)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
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
|
-
|
|
14
|
-
- generation of TypeScript files or compiled JS / DTS files
|
|
15
|
-
- name or rename stuff
|
|
16
|
-
- naming of pretty much any aspect of the generated artefacts
|
|
17
|
-
- e.g. all types should be prefixed with an "I", Person => IPerson
|
|
18
|
-
- consistent casing (as in "camelCase" or "PascalCase") even for property names of entity types
|
|
19
|
-
- use type converters
|
|
20
|
-
|
|
21
|
-
See the [generator documentation](https://odata2ts.github.io/docs/generator/setup-and-usage) for more information.
|
|
22
|
-
|
|
23
|
-
## Installation
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
npm install --save-dev @odata2ts/odata2ts
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Implicit Dependencies
|
|
30
|
-
|
|
31
|
-
Most of the generated artefacts depend on other libraries. `odata2ts` lists them as peer dependencies.
|
|
32
|
-
|
|
33
|
-
Depending on your use case, you will need to add runtime dependencies matching the mentioned peer dependencies.
|
|
34
|
-
See the [Getting Started Guide](https://odata2ts.github.io/docs/category/getting-started/) of the documentation
|
|
35
|
-
for guidance.
|
|
36
|
-
|
|
37
|
-
## Documentation
|
|
38
|
-
|
|
39
|
-
[Generator Documentation](https://odata2ts.github.io/docs/generator/setup-and-usage)
|
|
40
|
-
|
|
41
|
-
Main documentation for the odata2ts eco system:
|
|
42
|
-
[https://odata2ts.github.io](https://odata2ts.github.io/)
|
|
43
|
-
|
|
44
|
-
## Examples
|
|
45
|
-
|
|
46
|
-
See [example packages](https://github.com/odata2ts/odata2ts/tree/main/examples) for examples of how to integrate `odata2ts`.
|
|
47
|
-
|
|
48
|
-
## Tests
|
|
49
|
-
|
|
50
|
-
See folder [test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/test)
|
|
51
|
-
for unit tests.
|
|
52
|
-
|
|
53
|
-
See folder [int-test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/int-test) for integration
|
|
54
|
-
tests of the CLI.
|
|
55
|
-
|
|
56
|
-
Each example package serves as integration test of the generator.
|
|
57
|
-
|
|
58
|
-
## Support, Feedback, Contributing
|
|
59
|
-
|
|
60
|
-
This project is open to feature requests, suggestions, bug reports, usage questions etc.
|
|
61
|
-
via [GitHub issues](https://github.com/odata2ts/odata2ts/issues).
|
|
62
|
-
|
|
63
|
-
Contributions and feedback are encouraged and always welcome.
|
|
64
|
-
|
|
65
|
-
See the [contribution guidelines](https://github.com/odata2ts/odata2ts/blob/main/CONTRIBUTING.md) for further information.
|
|
66
|
-
|
|
67
|
-
## Spirit
|
|
68
|
-
|
|
69
|
-
This project and this module have been created and are maintained in the following spirit:
|
|
70
|
-
|
|
71
|
-
- adhere to the **OData specification** as much as possible
|
|
72
|
-
- support any OData service implementation which conforms to the spec
|
|
73
|
-
- allow to work around faulty implementations if possible
|
|
74
|
-
- stability matters
|
|
75
|
-
- exercise Test Driven Development
|
|
76
|
-
- bomb the place with unit tests (code coverage > 95%)
|
|
77
|
-
- ensure that assumptions & understanding are correct by creating integration tests
|
|
78
|
-
|
|
79
|
-
## License
|
|
80
|
-
|
|
81
|
-
MIT - see [License](./LICENSE).
|
|
1
|
+
[](https://www.npmjs.com/package/@odata2ts/odata2ts)
|
|
2
|
+
|
|
3
|
+
# odata2ts
|
|
4
|
+
|
|
5
|
+
The basic idea of `odata2ts` is to leverage the readily available metadata of any OData service
|
|
6
|
+
to generate different sorts of typed artefacts which you use in your TypeScript code.
|
|
7
|
+
This package (`@odata2ts/odata2ts`) realizes the generation process.
|
|
8
|
+
|
|
9
|
+
The generator is supposed to be used with a TypeScript based configuration file.
|
|
10
|
+
Then it's able to handle the generation for multiple OData services.
|
|
11
|
+
|
|
12
|
+
It comes with powerful configuration options. Some highlights:
|
|
13
|
+
|
|
14
|
+
- generation of TypeScript files or compiled JS / DTS files
|
|
15
|
+
- name or rename stuff
|
|
16
|
+
- naming of pretty much any aspect of the generated artefacts
|
|
17
|
+
- e.g. all types should be prefixed with an "I", Person => IPerson
|
|
18
|
+
- consistent casing (as in "camelCase" or "PascalCase") even for property names of entity types
|
|
19
|
+
- use type converters
|
|
20
|
+
|
|
21
|
+
See the [generator documentation](https://odata2ts.github.io/docs/generator/setup-and-usage) for more information.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
npm install --save-dev @odata2ts/odata2ts
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Implicit Dependencies
|
|
30
|
+
|
|
31
|
+
Most of the generated artefacts depend on other libraries. `odata2ts` lists them as peer dependencies.
|
|
32
|
+
|
|
33
|
+
Depending on your use case, you will need to add runtime dependencies matching the mentioned peer dependencies.
|
|
34
|
+
See the [Getting Started Guide](https://odata2ts.github.io/docs/category/getting-started/) of the documentation
|
|
35
|
+
for guidance.
|
|
36
|
+
|
|
37
|
+
## Documentation
|
|
38
|
+
|
|
39
|
+
[Generator Documentation](https://odata2ts.github.io/docs/generator/setup-and-usage)
|
|
40
|
+
|
|
41
|
+
Main documentation for the odata2ts eco system:
|
|
42
|
+
[https://odata2ts.github.io](https://odata2ts.github.io/)
|
|
43
|
+
|
|
44
|
+
## Examples
|
|
45
|
+
|
|
46
|
+
See [example packages](https://github.com/odata2ts/odata2ts/tree/main/examples) for examples of how to integrate `odata2ts`.
|
|
47
|
+
|
|
48
|
+
## Tests
|
|
49
|
+
|
|
50
|
+
See folder [test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/test)
|
|
51
|
+
for unit tests.
|
|
52
|
+
|
|
53
|
+
See folder [int-test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/int-test) for integration
|
|
54
|
+
tests of the CLI.
|
|
55
|
+
|
|
56
|
+
Each example package serves as integration test of the generator.
|
|
57
|
+
|
|
58
|
+
## Support, Feedback, Contributing
|
|
59
|
+
|
|
60
|
+
This project is open to feature requests, suggestions, bug reports, usage questions etc.
|
|
61
|
+
via [GitHub issues](https://github.com/odata2ts/odata2ts/issues).
|
|
62
|
+
|
|
63
|
+
Contributions and feedback are encouraged and always welcome.
|
|
64
|
+
|
|
65
|
+
See the [contribution guidelines](https://github.com/odata2ts/odata2ts/blob/main/CONTRIBUTING.md) for further information.
|
|
66
|
+
|
|
67
|
+
## Spirit
|
|
68
|
+
|
|
69
|
+
This project and this module have been created and are maintained in the following spirit:
|
|
70
|
+
|
|
71
|
+
- adhere to the **OData specification** as much as possible
|
|
72
|
+
- support any OData service implementation which conforms to the spec
|
|
73
|
+
- allow to work around faulty implementations if possible
|
|
74
|
+
- stability matters
|
|
75
|
+
- exercise Test Driven Development
|
|
76
|
+
- bomb the place with unit tests (code coverage > 95%)
|
|
77
|
+
- ensure that assumptions & understanding are correct by creating integration tests
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT - see [License](./LICENSE).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FactoryFunctionModel.js","sourceRoot":"","sources":["../src/FactoryFunctionModel.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport { SourceFile } from \"ts-morph\";\n\nimport { DataModel } from \"./data-model/DataModel\";\nimport { Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\nimport { NamingHelper } from \"./data-model/NamingHelper\";\nimport { RunOptions } from \"./OptionModel\";\nimport { ProjectManager } from \"./project/ProjectManager\";\n\nexport type DigestionOptions = Pick<\n RunOptions,\n | \"converters\"\n | \"disableAutoManagedKey\"\n | \"propertiesByName\"\n | \"byTypeAndName\"\n | \"v2ModelsWithExtraResultsWrapping\"\n | \"v4BigNumberAsString\"\n | \"skipEditableModels\"\n | \"skipComments\"\n | \"disableAutomaticNameClashResolution\"\n | \"bundledFileGeneration\"\n>;\n\n/**\n * Takes an EdmxSchema plus the run options and creates a DataModel.\n */\nexport type DigesterFunction<S extends Schema<any, any>> = (\n schema: Array<S>,\n options: DigestionOptions,\n namingHelper: NamingHelper\n) => Promise<DataModel>;\n\nexport type GeneratorFunctionOptions = Pick<\n RunOptions,\n \"skipEditableModels\" | \"skipIdModels\" | \"skipOperations\" | \"skipComments\" | \"v2ModelsWithExtraResultsWrapping\"\n>;\n\nexport type EntityBasedGeneratorFunction = (\n project: ProjectManager,\n dataModel: DataModel,\n version: ODataVersions,\n options: GeneratorFunctionOptions,\n namingHelper: NamingHelper\n) => Promise<void>;\n"]}
|
|
1
|
+
{"version":3,"file":"FactoryFunctionModel.js","sourceRoot":"","sources":["../src/FactoryFunctionModel.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { SourceFile } from \"ts-morph\";\r\n\r\nimport { DataModel } from \"./data-model/DataModel\";\r\nimport { Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper\";\r\nimport { RunOptions } from \"./OptionModel\";\r\nimport { ProjectManager } from \"./project/ProjectManager\";\r\n\r\nexport type DigestionOptions = Pick<\r\n RunOptions,\r\n | \"converters\"\r\n | \"disableAutoManagedKey\"\r\n | \"propertiesByName\"\r\n | \"byTypeAndName\"\r\n | \"v2ModelsWithExtraResultsWrapping\"\r\n | \"v4BigNumberAsString\"\r\n | \"skipEditableModels\"\r\n | \"skipComments\"\r\n | \"disableAutomaticNameClashResolution\"\r\n | \"bundledFileGeneration\"\r\n>;\r\n\r\n/**\r\n * Takes an EdmxSchema plus the run options and creates a DataModel.\r\n */\r\nexport type DigesterFunction<S extends Schema<any, any>> = (\r\n schema: Array<S>,\r\n options: DigestionOptions,\r\n namingHelper: NamingHelper\r\n) => Promise<DataModel>;\r\n\r\nexport type GeneratorFunctionOptions = Pick<\r\n RunOptions,\r\n \"skipEditableModels\" | \"skipIdModels\" | \"skipOperations\" | \"skipComments\" | \"v2ModelsWithExtraResultsWrapping\"\r\n>;\r\n\r\nexport type EntityBasedGeneratorFunction = (\r\n project: ProjectManager,\r\n dataModel: DataModel,\r\n version: ODataVersions,\r\n options: GeneratorFunctionOptions,\r\n namingHelper: NamingHelper\r\n) => Promise<void>;\r\n"]}
|
package/lib/TypeModel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeModel.js","sourceRoot":"","sources":["../src/TypeModel.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,oCAAuB,CAAA;IACvB,oCAAuB,CAAA;IACvB,sCAAyB,CAAA;IACzB,wCAA2B,CAAA;IAC3B,kCAAqB,CAAA;IACrB,yDAAyD;IACzD,4CAA+B,CAAA;IAC/B,mDAAmD;IACnD,wDAA2C,CAAA;AAC7C,CAAC,EAXW,SAAS,yBAAT,SAAS,QAWpB","sourcesContent":["export enum TypeModel {\n Any = \"Any\",\n EntitySet = \"EntitySet\",\n Singleton = \"Singleton\",\n EntityType = \"EntityType\",\n ComplexType = \"ComplexType\",\n EnumType = \"EnumType\",\n // Bundle Function and Action (bound or unbound; v4 only)\n OperationType = \"OperationType\",\n // Bundles ActionImport and FunctionImport elements\n OperationImportType = \"OperationImportType\",\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TypeModel.js","sourceRoot":"","sources":["../src/TypeModel.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,oCAAuB,CAAA;IACvB,oCAAuB,CAAA;IACvB,sCAAyB,CAAA;IACzB,wCAA2B,CAAA;IAC3B,kCAAqB,CAAA;IACrB,yDAAyD;IACzD,4CAA+B,CAAA;IAC/B,mDAAmD;IACnD,wDAA2C,CAAA;AAC7C,CAAC,EAXW,SAAS,yBAAT,SAAS,QAWpB","sourcesContent":["export enum TypeModel {\r\n Any = \"Any\",\r\n EntitySet = \"EntitySet\",\r\n Singleton = \"Singleton\",\r\n EntityType = \"EntityType\",\r\n ComplexType = \"ComplexType\",\r\n EnumType = \"EnumType\",\r\n // Bundle Function and Action (bound or unbound; v4 only)\r\n OperationType = \"OperationType\",\r\n // Bundles ActionImport and FunctionImport elements\r\n OperationImportType = \"OperationImportType\",\r\n}\r\n"]}
|
package/lib/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,6CAAyC;AAGzC,4EAAuE;AACvE,4EAAuE;AAIvE,4DAAyD;AACzD,2CAAqF;AACrF,+CAAkD;AAClD,6DAAgE;AAEhE,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,QAAQ,EAAE,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,cAAc,CAAC,OAAmB,EAAE,OAAmC;IAC9E,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,OAAO,OAA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,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QACzE,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAE9C,yBAAyB;QACzB,gDAAgD;QAChD,mJAAmJ;QACnJ,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,2FAA2F;YAC3F,MAAM,IAAA,gCAAoB,EAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;YAC/E,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;SAClD;QAED,oCAAoC;QACpC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,uFAAuF;YACvF,MAAM,IAAA,4BAAgB,EAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;YAC3E,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;SACjD;QAED,+BAA+B;QAC/B,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACxC,CAAC;CAAA;AAtED,wBAsEC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport { pascalCase } from \"pascal-case\";\n\nimport { NamespaceWithAlias } from \"./data-model/DataModel\";\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2\";\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\nimport { ODataEdmxModelBase } from \"./data-model/edmx/ODataEdmxModelBase\";\nimport { SchemaV3 } from \"./data-model/edmx/ODataEdmxModelV3\";\nimport { SchemaV4 } from \"./data-model/edmx/ODataEdmxModelV4\";\nimport { NamingHelper } from \"./data-model/NamingHelper\";\nimport { generateModels, generateQueryObjects, generateServices } from \"./generator\";\nimport { Modes, RunOptions } from \"./OptionModel\";\nimport { createProjectManager } from \"./project/ProjectManager\";\n\nfunction isQObjectGen(mode: Modes) {\n return [Modes.qobjects, Modes.service, Modes.all].includes(mode);\n}\n\nfunction isServiceGen(mode: Modes) {\n return [Modes.service, Modes.all].includes(mode);\n}\n\nfunction getServiceName(options: RunOptions, schemas: Array<SchemaV3 | SchemaV4>) {\n if (options.serviceName) {\n return options.serviceName;\n }\n\n // auto-detection of first namespace with defined EntityTypes\n // NOTE: we make use of PascalCase here to enforce valid class names\n const detectedSchema = schemas.find((schema) => schema.$.Namespace && schema.EntityType?.length) || schemas[0];\n const serviceName = detectedSchema.$.Namespace;\n return pascalCase(serviceName);\n}\n\n/**\n *\n * @param metadataJson metadata of a given OData service already parsed as JSON\n * @param options further options\n */\nexport async function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void> {\n // determine edmx edmxVersion attribute\n const edmxVersion = metadataJson[\"edmx:Edmx\"].$.Version;\n const version = edmxVersion === \"1.0\" ? ODataVersions.V2 : ODataVersions.V4;\n\n const dataService = metadataJson[\"edmx:Edmx\"][\"edmx:DataServices\"][0];\n const schemas = dataService.Schema as Array<SchemaV3 | SchemaV4>;\n\n const serviceName = getServiceName(options, schemas);\n\n const namespaces = schemas.map<NamespaceWithAlias>((schema) => [schema.$.Namespace, schema.$.Alias]);\n\n // encapsulate the whole naming logic\n const namingHelper = new NamingHelper(options, serviceName, namespaces);\n // parse model information from edmx into something we can really work with\n // => that stuff is called dataModel!\n const dataModel =\n version === ODataVersions.V2\n ? await digestV2(dataService.Schema as Array<SchemaV3>, options, namingHelper)\n : await digestV4(dataService.Schema as Array<SchemaV4>, options, namingHelper);\n\n // Validation of entity names: the same name might be used across different namespaces\n const validationErrors = dataModel.getNameValidation();\n if (validationErrors.size) {\n console.log(\"---\");\n validationErrors.forEach((errors, name) => {\n console.log(\n `Duplicate name: ${name} - Fully Qualified Names: ${errors\n .map((error) => error.fqName + (error.renamedTo ? ` (renamed to: ${error.renamedTo})` : \"\"))\n .join(\", \")}`\n );\n });\n\n if (options.disableAutomaticNameClashResolution) {\n throw new Error(\"Name validation failed: Multiple entities have the same name across different namespaces!\");\n }\n }\n\n // handling the overall generation project\n const project = await createProjectManager(options.output, options.emitMode, namingHelper, dataModel, {\n usePrettier: options.prettier,\n tsConfigPath: options.tsconfig,\n bundledFileGeneration: options.bundledFileGeneration,\n });\n\n // const promises: Array<Promise<void>> = [\n // Generate Model Interfaces\n // generateModels(project, dataModel, version, options, namingHelper),\n // ];\n await generateModels(project, dataModel, version, options, namingHelper);\n console.log(\"Successfully generated models!\");\n\n // Generate Query Objects\n // supported edmx types: EntityType, ComplexType\n // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object\n if (isQObjectGen(options.mode)) {\n // promises.push(generateQueryObjects(project, dataModel, version, options, namingHelper));\n await generateQueryObjects(project, dataModel, version, options, namingHelper);\n console.log(\"Successfully generated q-objects!\");\n }\n\n // Generate Individual OData-Service\n if (isServiceGen(options.mode)) {\n // promises.push(generateServices(project, dataModel, version, namingHelper, options));\n await generateServices(project, dataModel, version, namingHelper, options);\n console.log(\"Successfully generated services!\");\n }\n\n // await Promise.all(promises);\n console.log(\"Successfully finished!\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,6CAAyC;AAGzC,4EAAuE;AACvE,4EAAuE;AAIvE,4DAAyD;AACzD,2CAAqF;AACrF,+CAAkD;AAClD,6DAAgE;AAEhE,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,QAAQ,EAAE,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,cAAc,CAAC,OAAmB,EAAE,OAAmC;IAC9E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QACL,MAAM,IAAA,0BAAc,EAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QACzE,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAE9C,yBAAyB;QACzB,gDAAgD;QAChD,mJAAmJ;QACnJ,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,2FAA2F;YAC3F,MAAM,IAAA,gCAAoB,EAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;YAC/E,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;SAClD;QAED,oCAAoC;QACpC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,uFAAuF;YACvF,MAAM,IAAA,4BAAgB,EAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;YAC3E,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;SACjD;QAED,+BAA+B;QAC/B,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACxC,CAAC;CAAA;AAtED,wBAsEC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { pascalCase } from \"pascal-case\";\r\n\r\nimport { NamespaceWithAlias } from \"./data-model/DataModel\";\r\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2\";\r\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\r\nimport { ODataEdmxModelBase } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { SchemaV3 } from \"./data-model/edmx/ODataEdmxModelV3\";\r\nimport { SchemaV4 } from \"./data-model/edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper\";\r\nimport { generateModels, generateQueryObjects, generateServices } from \"./generator\";\r\nimport { Modes, RunOptions } from \"./OptionModel\";\r\nimport { createProjectManager } from \"./project/ProjectManager\";\r\n\r\nfunction isQObjectGen(mode: Modes) {\r\n return [Modes.qobjects, Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\nfunction isServiceGen(mode: Modes) {\r\n return [Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\nfunction getServiceName(options: RunOptions, schemas: Array<SchemaV3 | SchemaV4>) {\r\n if (options.serviceName) {\r\n return options.serviceName;\r\n }\r\n\r\n // auto-detection of first namespace with defined EntityTypes\r\n // NOTE: we make use of PascalCase here to enforce valid class names\r\n const detectedSchema = schemas.find((schema) => schema.$.Namespace && schema.EntityType?.length) || schemas[0];\r\n const serviceName = detectedSchema.$.Namespace;\r\n return pascalCase(serviceName);\r\n}\r\n\r\n/**\r\n *\r\n * @param metadataJson metadata of a given OData service already parsed as JSON\r\n * @param options further options\r\n */\r\nexport async function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void> {\r\n // determine edmx edmxVersion attribute\r\n const edmxVersion = metadataJson[\"edmx:Edmx\"].$.Version;\r\n const version = edmxVersion === \"1.0\" ? ODataVersions.V2 : ODataVersions.V4;\r\n\r\n const dataService = metadataJson[\"edmx:Edmx\"][\"edmx:DataServices\"][0];\r\n const schemas = dataService.Schema as Array<SchemaV3 | SchemaV4>;\r\n\r\n const serviceName = getServiceName(options, schemas);\r\n\r\n const namespaces = schemas.map<NamespaceWithAlias>((schema) => [schema.$.Namespace, schema.$.Alias]);\r\n\r\n // encapsulate the whole naming logic\r\n const namingHelper = new NamingHelper(options, serviceName, namespaces);\r\n // parse model information from edmx into something we can really work with\r\n // => that stuff is called dataModel!\r\n const dataModel =\r\n version === ODataVersions.V2\r\n ? await digestV2(dataService.Schema as Array<SchemaV3>, options, namingHelper)\r\n : await digestV4(dataService.Schema as Array<SchemaV4>, options, namingHelper);\r\n\r\n // Validation of entity names: the same name might be used across different namespaces\r\n const validationErrors = dataModel.getNameValidation();\r\n if (validationErrors.size) {\r\n console.log(\"---\");\r\n validationErrors.forEach((errors, name) => {\r\n console.log(\r\n `Duplicate name: ${name} - Fully Qualified Names: ${errors\r\n .map((error) => error.fqName + (error.renamedTo ? ` (renamed to: ${error.renamedTo})` : \"\"))\r\n .join(\", \")}`\r\n );\r\n });\r\n\r\n if (options.disableAutomaticNameClashResolution) {\r\n throw new Error(\"Name validation failed: Multiple entities have the same name across different namespaces!\");\r\n }\r\n }\r\n\r\n // handling the overall generation project\r\n const project = await createProjectManager(options.output, options.emitMode, namingHelper, dataModel, {\r\n usePrettier: options.prettier,\r\n tsConfigPath: options.tsconfig,\r\n bundledFileGeneration: options.bundledFileGeneration,\r\n });\r\n\r\n // const promises: Array<Promise<void>> = [\r\n // Generate Model Interfaces\r\n // generateModels(project, dataModel, version, options, namingHelper),\r\n // ];\r\n await generateModels(project, dataModel, version, options, namingHelper);\r\n console.log(\"Successfully generated models!\");\r\n\r\n // Generate Query Objects\r\n // supported edmx types: EntityType, ComplexType\r\n // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object\r\n if (isQObjectGen(options.mode)) {\r\n // promises.push(generateQueryObjects(project, dataModel, version, options, namingHelper));\r\n await generateQueryObjects(project, dataModel, version, options, namingHelper);\r\n console.log(\"Successfully generated q-objects!\");\r\n }\r\n\r\n // Generate Individual OData-Service\r\n if (isServiceGen(options.mode)) {\r\n // promises.push(generateServices(project, dataModel, version, namingHelper, options));\r\n await generateServices(project, dataModel, version, namingHelper, options);\r\n console.log(\"Successfully generated services!\");\r\n }\r\n\r\n // await Promise.all(promises);\r\n console.log(\"Successfully finished!\");\r\n}\r\n"]}
|
package/lib/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;AAAA,+DAA8C;AAC9C,6CAA0C;AAC1C,iFAAiE;AACjE,uCAA0D;AAC1D,mCAA4C;AAE5C,+BAA+B;AAE/B,0CAA8D;AAC9D,qDAAyD;AACzD,+CAAo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BAA8B;aACzB;YACH,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;YACnD,WAAW,GAAG,MAAM,IAAA,mBAAQ,EAAC,MAAM,CAAC,CAAC;SACtC;QAED,MAAM,YAAY,GAAG,CAAC,MAAM,IAAA,2BAAkB,EAAC,WAAW,CAAC,CAA4B,CAAC;QACxF,sDAAsD;QACtD,iEAAiE;QACjE,iFAAiF;QAEjF,sCAAsC;QACtC,IAAI;YACF,MAAM,IAAA,mBAAQ,EAAC,MAAM,CAAC,CAAC;SACxB;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,gBAAgB,MAAM,wBAAwB,EAAE,KAAK,CAAC,CAAC;YACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;QAED,cAAc;QACd,IAAI;YACF,MAAM,IAAA,YAAM,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC;SACrC;QAAC,OAAO,GAAQ,EAAE;YACjB,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,GAAG,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAClB;IACH,CAAC;CAAA","sourcesContent":["import commander, { Option } from \"commander\";\nimport { cosmiconfig } from \"cosmiconfig\";\nimport { TypeScriptLoader } from \"cosmiconfig-typescript-loader\";\nimport { emptyDir, pathExists, readFile } from \"fs-extra\";\nimport { parseStringPromise } from \"xml2js\";\n\nimport { runApp } from \"./app\";\nimport { ODataEdmxModelBase } from \"./data-model/edmx/ODataEdmxModelBase\";\nimport { downloadMetadata, storeMetadata } from \"./download/\";\nimport { evaluateConfigOptions } from \"./evaluateConfig\";\nimport { CliOptions, ConfigFileOptions, EmitModes, Modes, RunOptions, UrlSourceConfiguration } from \"./OptionModel\";\nimport { logFilePath } from \"./project/logger/logFilePath\";\n\nfunction parseMode(value: string, dummyPrevious: Modes | undefined) {\n switch (value) {\n case \"models\":\n return Modes.models;\n case \"qobjects\":\n return Modes.qobjects;\n case \"service\":\n return Modes.service;\n case \"all\":\n return Modes.all;\n default:\n throw new Error(`Not a valid Mode: ${value}`);\n }\n}\n\nfunction parseEmitMode(value: string, dummyPrevious: EmitModes) {\n switch (value) {\n case \"dts\":\n return EmitModes.dts;\n case \"js\":\n return EmitModes.js;\n case \"ts\":\n return EmitModes.ts;\n case \"js_dts\":\n return EmitModes.js_dts;\n default:\n throw new Error(`Not a valid EmitMode: ${value}`);\n }\n}\n\nfunction processCliArgs() {\n const cli = new commander.Command()\n .version(\"0.3.0\")\n .description(\"CLI to generate Typescript Interfaces for models of a given OData service.\")\n .argument(\"[services...]\", \"Run the generation process only for certain services specified in config file\", [])\n .option(\"-s, --source <url or metadata.xml>\", \"Path to metadata file\")\n .option(\"-o, --output <path>\", \"Output location for generated files\")\n .option(\"-u, --source-url <sourceUrl>\", \"URL to the root of the OData service\")\n .option(\n \"-f, --refresh-file\",\n \"Download metadata again and overwrite existing file (only applies if sourceUrl is specified)\"\n )\n .addOption(\n new Option(\"-m, --mode <mode>\", \"What kind of stuff gets generated\")\n .choices(Object.values(Modes).filter((t): t is string => isNaN(Number(t))))\n .argParser<Modes>(parseMode)\n )\n .addOption(\n new Option(\n \"-e, --emit-mode <mode>\",\n \"Output TS source files, compiled JS files with/wihthout generated d.ts files\"\n )\n .choices(Object.values(EmitModes))\n .argParser<EmitModes>(parseEmitMode)\n )\n .option(\"-p, --prettier\", \"Format result with prettier (only applies if emitMode=ts)\")\n .option(\n \"-t, --tsconfig <path>\",\n \"Specify alternative to 'tsconfig.json' to use specific compilerOptions (applies if emitMode is not ts)\"\n )\n .option(\"-d, --debug\", \"Verbose debug infos\")\n .option(\"-name, --service-name <serviceName>\", \"Give the service your own name\")\n .option(\n \"-n, --disable-auto-managed-key\",\n \"Don't mark single key props as managed by the server side (not editable)\"\n )\n .option(\"-r, --allow-renaming\", \"Allow that property and entity names may be changed by configured casing\")\n .parse(process.argv);\n\n const args = cli.args?.length ? { services: cli.args } : {};\n return {\n ...cli.opts(),\n ...args,\n } as CliOptions;\n}\n\nasync function processConfigFile() {\n const moduleName = \"odata2ts\";\n const explorer = cosmiconfig(moduleName, {\n searchPlaces: [`${moduleName}.config.js`, `${moduleName}.config.ts`, `${moduleName}.config.cjs`],\n loaders: {\n \".ts\": TypeScriptLoader(),\n },\n });\n const discoveredConfig = await explorer.search();\n\n if (discoveredConfig?.config) {\n console.log(\"Loaded config file: \", logFilePath(discoveredConfig.filepath));\n } else {\n console.log(\"No config file found.\");\n }\n\n return discoveredConfig?.config as ConfigFileOptions;\n}\n\nexport class Cli {\n async run(): Promise<void> {\n let runs;\n try {\n const cliOpts = processCliArgs();\n if (cliOpts.debug) {\n console.log(\"CLI opts:\", cliOpts);\n }\n const fileOpts = await processConfigFile();\n\n runs = evaluateConfigOptions(cliOpts, fileOpts);\n } catch (error: any) {\n console.error(\"Bad arguments!\", error?.message);\n process.exit(1);\n }\n\n for (let run of runs) {\n await startServiceGenerationRun(run);\n }\n }\n}\n\nasync function startServiceGenerationRun(options: RunOptions) {\n const { source, output, sourceUrl, refreshFile, sourceUrlConfig, debug, mode, emitMode, prettier, serviceName } =\n options;\n console.log(\"---------------------------\");\n console.log(\n `Starting generation process. Service name ${serviceName ? `\"${serviceName}\"` : \"will be detected automatically!\"}`\n );\n\n if (debug) {\n console.log(\"Resolved config:\", {\n source,\n output,\n sourceUrl,\n refreshFile,\n debug,\n mode: Modes[mode],\n emitMode,\n prettier,\n serviceName,\n });\n }\n\n // evaluate source\n const exists = await pathExists(source);\n console.log(`${exists ? \"Found\" : \"Didn't find\"} metadata file at: `, source);\n\n let metadataXml;\n // download metadata and store on disk\n if (sourceUrl && (!exists || refreshFile)) {\n try {\n metadataXml = await downloadMetadata(sourceUrl, sourceUrlConfig, debug);\n } catch (e) {\n console.error(`Failed to load metadata! Message: ${(e as Error)?.message}`);\n process.exit(10);\n }\n metadataXml = await storeMetadata(source, metadataXml, prettier);\n }\n // otherwise file must exist\n else if (!exists) {\n console.error(`Input source [${source}] doesn't exist!`);\n process.exit(2);\n }\n // read the metadata from file\n else {\n console.log(\"Reading metadata from file:\", source);\n metadataXml = await readFile(source);\n }\n\n const metadataJson = (await parseStringPromise(metadataXml)) as ODataEdmxModelBase<any>;\n // TODO find out if \"1.0\" and \"4.0\" are really correct\n // TODO exit here if no version not suitable version was detected\n // console.log(`OData version detected: ${metadataJson[\"edmx:Edmx\"].$.Version}`);\n\n // ensure that output directory exists\n try {\n await emptyDir(output);\n } catch (error) {\n console.error(`Output path [${output}] couldn't be created!`, error);\n process.exit(3);\n }\n\n // run the app\n try {\n await runApp(metadataJson, options);\n } catch (err: any) {\n console.error(\"Error while running the program\", err);\n process.exit(99);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;AAAA,+DAA8C;AAC9C,6CAA0C;AAC1C,iFAAiE;AACjE,uCAA0D;AAC1D,mCAA4C;AAE5C,+BAA+B;AAE/B,0CAA8D;AAC9D,qDAAyD;AACzD,+CAAoH;AACpH,8DAA2D;AAE3D,SAAS,SAAS,CAAC,KAAa,EAAE,aAAgC;IAChE,QAAQ,KAAK,EAAE;QACb,KAAK,QAAQ;YACX,OAAO,mBAAK,CAAC,MAAM,CAAC;QACtB,KAAK,UAAU;YACb,OAAO,mBAAK,CAAC,QAAQ,CAAC;QACxB,KAAK,SAAS;YACZ,OAAO,mBAAK,CAAC,OAAO,CAAC;QACvB,KAAK,KAAK;YACR,OAAO,mBAAK,CAAC,GAAG,CAAC;QACnB;YACE,MAAM,IAAI,KAAK,CAAC,qBAAqB,KAAK,EAAE,CAAC,CAAC;KACjD;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAa,EAAE,aAAwB;IAC5D,QAAQ,KAAK,EAAE;QACb,KAAK,KAAK;YACR,OAAO,uBAAS,CAAC,GAAG,CAAC;QACvB,KAAK,IAAI;YACP,OAAO,uBAAS,CAAC,EAAE,CAAC;Q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OAAO,CAAC,CAAC;SACrC;QAAC,OAAO,GAAQ,EAAE;YACjB,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,GAAG,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAClB;IACH,CAAC;CAAA","sourcesContent":["import commander, { Option } from \"commander\";\r\nimport { cosmiconfig } from \"cosmiconfig\";\r\nimport { TypeScriptLoader } from \"cosmiconfig-typescript-loader\";\r\nimport { emptyDir, pathExists, readFile } from \"fs-extra\";\r\nimport { parseStringPromise } from \"xml2js\";\r\n\r\nimport { runApp } from \"./app\";\r\nimport { ODataEdmxModelBase } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { downloadMetadata, storeMetadata } from \"./download/\";\r\nimport { evaluateConfigOptions } from \"./evaluateConfig\";\r\nimport { CliOptions, ConfigFileOptions, EmitModes, Modes, RunOptions, UrlSourceConfiguration } from \"./OptionModel\";\r\nimport { logFilePath } from \"./project/logger/logFilePath\";\r\n\r\nfunction parseMode(value: string, dummyPrevious: Modes | undefined) {\r\n switch (value) {\r\n case \"models\":\r\n return Modes.models;\r\n case \"qobjects\":\r\n return Modes.qobjects;\r\n case \"service\":\r\n return Modes.service;\r\n case \"all\":\r\n return Modes.all;\r\n default:\r\n throw new Error(`Not a valid Mode: ${value}`);\r\n }\r\n}\r\n\r\nfunction parseEmitMode(value: string, dummyPrevious: EmitModes) {\r\n switch (value) {\r\n case \"dts\":\r\n return EmitModes.dts;\r\n case \"js\":\r\n return EmitModes.js;\r\n case \"ts\":\r\n return EmitModes.ts;\r\n case \"js_dts\":\r\n return EmitModes.js_dts;\r\n default:\r\n throw new Error(`Not a valid EmitMode: ${value}`);\r\n }\r\n}\r\n\r\nfunction processCliArgs() {\r\n const cli = new commander.Command()\r\n .version(\"0.3.0\")\r\n .description(\"CLI to generate Typescript Interfaces for models of a given OData service.\")\r\n .argument(\"[services...]\", \"Run the generation process only for certain services specified in config file\", [])\r\n .option(\"-s, --source <url or metadata.xml>\", \"Path to metadata file\")\r\n .option(\"-o, --output <path>\", \"Output location for generated files\")\r\n .option(\"-u, --source-url <sourceUrl>\", \"URL to the root of the OData service\")\r\n .option(\r\n \"-f, --refresh-file\",\r\n \"Download metadata again and overwrite existing file (only applies if sourceUrl is specified)\"\r\n )\r\n .addOption(\r\n new Option(\"-m, --mode <mode>\", \"What kind of stuff gets generated\")\r\n .choices(Object.values(Modes).filter((t): t is string => isNaN(Number(t))))\r\n .argParser<Modes>(parseMode)\r\n )\r\n .addOption(\r\n new Option(\r\n \"-e, --emit-mode <mode>\",\r\n \"Output TS source files, compiled JS files with/wihthout generated d.ts files\"\r\n )\r\n .choices(Object.values(EmitModes))\r\n .argParser<EmitModes>(parseEmitMode)\r\n )\r\n .option(\"-p, --prettier\", \"Format result with prettier (only applies if emitMode=ts)\")\r\n .option(\r\n \"-t, --tsconfig <path>\",\r\n \"Specify alternative to 'tsconfig.json' to use specific compilerOptions (applies if emitMode is not ts)\"\r\n )\r\n .option(\"-d, --debug\", \"Verbose debug infos\")\r\n .option(\"-name, --service-name <serviceName>\", \"Give the service your own name\")\r\n .option(\r\n \"-n, --disable-auto-managed-key\",\r\n \"Don't mark single key props as managed by the server side (not editable)\"\r\n )\r\n .option(\"-r, --allow-renaming\", \"Allow that property and entity names may be changed by configured casing\")\r\n .parse(process.argv);\r\n\r\n const args = cli.args?.length ? { services: cli.args } : {};\r\n return {\r\n ...cli.opts(),\r\n ...args,\r\n } as CliOptions;\r\n}\r\n\r\nasync function processConfigFile() {\r\n const moduleName = \"odata2ts\";\r\n const explorer = cosmiconfig(moduleName, {\r\n searchPlaces: [`${moduleName}.config.js`, `${moduleName}.config.ts`, `${moduleName}.config.cjs`],\r\n loaders: {\r\n \".ts\": TypeScriptLoader(),\r\n },\r\n });\r\n const discoveredConfig = await explorer.search();\r\n\r\n if (discoveredConfig?.config) {\r\n console.log(\"Loaded config file: \", logFilePath(discoveredConfig.filepath));\r\n } else {\r\n console.log(\"No config file found.\");\r\n }\r\n\r\n return discoveredConfig?.config as ConfigFileOptions;\r\n}\r\n\r\nexport class Cli {\r\n async run(): Promise<void> {\r\n let runs;\r\n try {\r\n const cliOpts = processCliArgs();\r\n if (cliOpts.debug) {\r\n console.log(\"CLI opts:\", cliOpts);\r\n }\r\n const fileOpts = await processConfigFile();\r\n\r\n runs = evaluateConfigOptions(cliOpts, fileOpts);\r\n } catch (error: any) {\r\n console.error(\"Bad arguments!\", error?.message);\r\n process.exit(1);\r\n }\r\n\r\n for (let run of runs) {\r\n await startServiceGenerationRun(run);\r\n }\r\n }\r\n}\r\n\r\nasync function startServiceGenerationRun(options: RunOptions) {\r\n const { source, output, sourceUrl, refreshFile, sourceUrlConfig, debug, mode, emitMode, prettier, serviceName } =\r\n options;\r\n console.log(\"---------------------------\");\r\n console.log(\r\n `Starting generation process. Service name ${serviceName ? `\"${serviceName}\"` : \"will be detected automatically!\"}`\r\n );\r\n\r\n if (debug) {\r\n console.log(\"Resolved config:\", {\r\n source,\r\n output,\r\n sourceUrl,\r\n refreshFile,\r\n debug,\r\n mode: Modes[mode],\r\n emitMode,\r\n prettier,\r\n serviceName,\r\n });\r\n }\r\n\r\n // evaluate source\r\n const exists = await pathExists(source);\r\n console.log(`${exists ? \"Found\" : \"Didn't find\"} metadata file at: `, source);\r\n\r\n let metadataXml;\r\n // download metadata and store on disk\r\n if (sourceUrl && (!exists || refreshFile)) {\r\n try {\r\n metadataXml = await downloadMetadata(sourceUrl, sourceUrlConfig, debug);\r\n } catch (e) {\r\n console.error(`Failed to load metadata! Message: ${(e as Error)?.message}`);\r\n process.exit(10);\r\n }\r\n metadataXml = await storeMetadata(source, metadataXml, prettier);\r\n }\r\n // otherwise file must exist\r\n else if (!exists) {\r\n console.error(`Input source [${source}] doesn't exist!`);\r\n process.exit(2);\r\n }\r\n // read the metadata from file\r\n else {\r\n console.log(\"Reading metadata from file:\", source);\r\n metadataXml = await readFile(source);\r\n }\r\n\r\n const metadataJson = (await parseStringPromise(metadataXml)) as ODataEdmxModelBase<any>;\r\n // TODO find out if \"1.0\" and \"4.0\" are really correct\r\n // TODO exit here if no version not suitable version was detected\r\n // console.log(`OData version detected: ${metadataJson[\"edmx:Edmx\"].$.Version}`);\r\n\r\n // ensure that output directory exists\r\n try {\r\n await emptyDir(output);\r\n } catch (error) {\r\n console.error(`Output path [${output}] couldn't be created!`, error);\r\n process.exit(3);\r\n }\r\n\r\n // run the app\r\n try {\r\n await runApp(metadataJson, options);\r\n } catch (err: any) {\r\n console.error(\"Error while running the program\", err);\r\n process.exit(99);\r\n }\r\n}\r\n"]}
|
|
@@ -190,6 +190,7 @@ class Digester {
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
addEnum(namespace, models) {
|
|
193
|
+
var _a;
|
|
193
194
|
if (!models || !models.length) {
|
|
194
195
|
return;
|
|
195
196
|
}
|
|
@@ -205,7 +206,7 @@ class Digester {
|
|
|
205
206
|
name: enumName,
|
|
206
207
|
modelName: this.namingHelper.getEnumName(enumName),
|
|
207
208
|
folderPath: filePath,
|
|
208
|
-
members: et.Member.map((m) => m.$.Name),
|
|
209
|
+
members: ((_a = et.Member) === null || _a === void 0 ? void 0 : _a.length) ? et.Member.map((m) => m.$.Name) : [],
|
|
209
210
|
});
|
|
210
211
|
}
|
|
211
212
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataModelDigestion.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestion.ts"],"names":[],"mappings":";;;;AAIA,2CAA2E;AAY3E,+DAAyE;AACzE,wEAAqE;AAErE,8DAA2D;AAQ3D,SAAS,MAAM,CAAC,KAAyB;IACvC,OAAO,KAAK,KAAK,MAAM,CAAC;AAC1B,CAAC;AAED,SAAS,OAAO,CAAC,KAAyB;IACxC,OAAO,KAAK,KAAK,OAAO,CAAC;AAC3B,CAAC;AASD,MAAsB,QAAQ;IAS5B,YACY,OAAqB,EACrB,OAAiB,EACjB,OAAyB,EACzB,YAA0B,EACpC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,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAmB,CACnF,CAAC;IACJ,CAAC;;AAvUH,4BAuaC;AAtakB,mBAAU,GAAG,MAAM,AAAT,CAAU","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { ComplexTypeGenerationOptions, EntityTypeGenerationOptions, PropertyGenerationOptions } from \"../OptionModel\";\r\nimport { DataModel, NamespaceWithAlias, withNamespace } from \"./DataModel\";\r\nimport {\r\n ComplexType as ComplexModelType,\r\n DataTypes,\r\n EntityType as EntityModelType,\r\n ODataVersion,\r\n PropertyModel,\r\n} from \"./DataTypeModel\";\r\nimport { ComplexType, EntityType, EnumType, Property, Schema, TypeDefinition } from \"./edmx/ODataEdmxModelBase\";\r\nimport { SchemaV3 } from \"./edmx/ODataEdmxModelV3\";\r\nimport { SchemaV4 } from \"./edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\nimport { ServiceConfigHelper, WithoutName } from \"./ServiceConfigHelper\";\r\nimport { NameClashValidator } from \"./validation/NameClashValidator\";\r\nimport { NameValidator } from \"./validation/NameValidator\";\r\nimport { NoopValidator } from \"./validation/NoopValidator\";\r\n\r\ntype CollectorTuple = [\r\n Array<PropertyModel>,\r\n Array<string>,\r\n { fqIdName: string; idName: string; qIdName: string; open: boolean }\r\n];\r\n\r\nfunction ifTrue(value: string | undefined): boolean {\r\n return value === \"true\";\r\n}\r\n\r\nfunction ifFalse(value: string | undefined): boolean {\r\n return value === \"false\";\r\n}\r\n\r\nexport interface TypeModel {\r\n outputType: string;\r\n qPath: string;\r\n qCollection: string;\r\n qParam: string | undefined;\r\n}\r\n\r\nexport abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {\r\n protected static EDM_PREFIX = \"Edm.\";\r\n\r\n protected readonly dataModel: DataModel;\r\n protected readonly serviceConfigHelper: ServiceConfigHelper;\r\n protected readonly nameValidator: NameValidator;\r\n\r\n private model2Type = new Map<string, DataTypes>();\r\n\r\n protected constructor(\r\n protected version: ODataVersion,\r\n protected schemas: Array<S>,\r\n protected options: DigestionOptions,\r\n protected namingHelper: NamingHelper,\r\n converters?: MappedConverterChains\r\n ) {\r\n const namespaces = schemas.map<NamespaceWithAlias>((s) => [s.$.Namespace, s.$.Alias]);\r\n this.dataModel = new DataModel(namespaces, version, converters);\r\n this.serviceConfigHelper = new ServiceConfigHelper(options);\r\n this.nameValidator = this.options.bundledFileGeneration ? new NameClashValidator(options) : new NoopValidator();\r\n\r\n this.collectModelTypes(schemas);\r\n }\r\n\r\n private collectModelTypes(schemas: Array<S>) {\r\n schemas.forEach((schema) => {\r\n const { Namespace: ns, Alias: alias } = schema.$;\r\n\r\n schema.EnumType?.forEach((et) => {\r\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.EnumType);\r\n });\r\n schema.ComplexType?.forEach((ct) => {\r\n this.addModel2Type(ns, alias, ct.$.Name, DataTypes.ComplexType);\r\n });\r\n schema.EntityType?.forEach((et) => {\r\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.ModelType);\r\n });\r\n });\r\n }\r\n\r\n private addModel2Type(ns: string, alias: string | undefined, name: string, dt: DataTypes) {\r\n this.model2Type.set(withNamespace(ns, name), dt);\r\n if (alias) {\r\n this.model2Type.set(withNamespace(alias, name), dt);\r\n }\r\n }\r\n\r\n protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;\r\n\r\n protected abstract digestOperations(schema: SchemaV3 | SchemaV4): void;\r\n\r\n protected abstract digestEntityContainer(schema: SchemaV3 | SchemaV4): void;\r\n\r\n /**\r\n * Get essential infos about a given odata type from the version specific service variants.\r\n *\r\n * @param type\r\n * @return tuple of return type, query object, query collection object\r\n */\r\n protected abstract mapODataType(type: string): TypeModel;\r\n\r\n public async digest(): Promise<DataModel> {\r\n this.digestEntityTypesAndOperations();\r\n\r\n // delegate to version specific entity container digestion\r\n this.schemas.forEach((schema) => this.digestEntityContainer(schema));\r\n\r\n this.dataModel.setNameValidation(this.nameValidator.validate());\r\n return this.dataModel;\r\n }\r\n\r\n private digestEntityTypesAndOperations() {\r\n this.schemas.forEach((schema) => {\r\n const ns: NamespaceWithAlias = [schema.$.Namespace, schema.$.Alias];\r\n\r\n // type definitions: alias for primitive types\r\n this.addTypeDefinition(schema.$.Namespace, schema.TypeDefinition);\r\n\r\n // enums\r\n this.addEnum(ns, schema.EnumType);\r\n\r\n // complex types\r\n this.addComplexType(ns, schema.ComplexType);\r\n\r\n // entity types\r\n this.addEntityType(ns, schema.EntityType);\r\n\r\n // V4 only: function & action types\r\n this.digestOperations(schema);\r\n });\r\n\r\n this.postProcessModel();\r\n this.postProcessKeys();\r\n }\r\n\r\n private getBaseModel(\r\n entityConfig: WithoutName<EntityTypeGenerationOptions | ComplexTypeGenerationOptions> | undefined,\r\n model: ComplexType,\r\n namespace: string,\r\n name: string,\r\n fqName: string\r\n ) {\r\n const odataName = model.$.Name;\r\n\r\n // map properties respecting the config\r\n const props = [...(model.Property ?? []), ...this.getNavigationProps(model)].map((p) => {\r\n const epConfig = entityConfig?.properties?.find((ep) => ep.name === p.$.Name);\r\n return this.mapProp(p, epConfig);\r\n });\r\n\r\n // support for base types, i.e. extends clause of interfaces\r\n const baseClasses = [];\r\n let finalBaseClass: string | undefined = undefined;\r\n if (model.$.BaseType) {\r\n baseClasses.push(model.$.BaseType);\r\n const [baseName, basePrefix] = this.namingHelper.getNameAndServicePrefix(model.$.BaseType);\r\n const baseConfig =\r\n this.serviceConfigHelper.findEntityTypeConfig([basePrefix!], baseName) ||\r\n this.serviceConfigHelper.findComplexTypeConfig([basePrefix!], baseName);\r\n finalBaseClass = baseConfig?.mappedName ?? baseName;\r\n }\r\n\r\n return {\r\n fqName,\r\n odataName,\r\n name,\r\n modelName: this.namingHelper.getModelName(name),\r\n qName: this.namingHelper.getQName(name),\r\n editableName: this.namingHelper.getEditableModelName(name),\r\n serviceName: this.namingHelper.getServiceName(name),\r\n serviceCollectionName: this.namingHelper.getCollectionServiceName(name),\r\n folderPath: this.namingHelper.getFolderPath(namespace, name),\r\n baseClasses,\r\n finalBaseClass,\r\n props,\r\n baseProps: [], // postprocess required\r\n abstract: ifTrue(model.$.Abstract),\r\n open: ifTrue(model.$.OpenType),\r\n };\r\n }\r\n\r\n private addTypeDefinition(ns: string, types: Array<TypeDefinition> | undefined) {\r\n if (!types || !types.length) {\r\n return;\r\n }\r\n\r\n for (const t of types) {\r\n this.dataModel.addTypeDefinition(ns, t.$.Name, t.$.UnderlyingType);\r\n }\r\n }\r\n\r\n private addEnum(namespace: NamespaceWithAlias, models: Array<EnumType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const et of models) {\r\n const odataName = et.$.Name;\r\n const fqName = withNamespace(namespace[0], odataName);\r\n const config = this.serviceConfigHelper.findEnumTypeConfig(namespace, odataName);\r\n const enumName = this.nameValidator.addEnumType(fqName, config?.mappedName || odataName);\r\n const filePath = this.namingHelper.getFolderPath(namespace[0], enumName);\r\n this.dataModel.addEnum(namespace[0], odataName, {\r\n fqName,\r\n odataName,\r\n name: enumName,\r\n modelName: this.namingHelper.getEnumName(enumName),\r\n folderPath: filePath,\r\n members: et.Member.map((m) => m.$.Name),\r\n });\r\n }\r\n }\r\n\r\n private addComplexType(namespace: NamespaceWithAlias, models: Array<ComplexType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const config = this.serviceConfigHelper.findComplexTypeConfig(namespace, model.$.Name);\r\n const fqName = withNamespace(namespace[0], model.$.Name);\r\n const name = this.nameValidator.addComplexType(fqName, config?.mappedName || model.$.Name);\r\n const baseModel = this.getBaseModel(config, model, namespace[0], name, fqName);\r\n this.dataModel.addComplexType(namespace[0], baseModel.odataName, baseModel);\r\n }\r\n }\r\n\r\n private addEntityType(namespace: NamespaceWithAlias, models: Array<ET> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const entityConfig = this.serviceConfigHelper.findEntityTypeConfig(namespace, model.$.Name);\r\n const fqName = withNamespace(namespace[0], model.$.Name);\r\n const name = this.nameValidator.addEntityType(fqName, entityConfig?.mappedName || model.$.Name);\r\n const baseModel = this.getBaseModel(entityConfig, model, namespace[0], name, fqName);\r\n\r\n // key support: we add keys from this entity,\r\n // but not keys stemming from base classes (postprocess required)\r\n const keyNames: Array<string> = [];\r\n if (entityConfig?.keys?.length) {\r\n keyNames.push(...entityConfig.keys);\r\n } else {\r\n const entity = model as EntityType;\r\n if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {\r\n const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);\r\n keyNames.push(...propNames);\r\n }\r\n }\r\n\r\n this.dataModel.addEntityType(namespace[0], baseModel.odataName, {\r\n ...baseModel,\r\n id: {\r\n fqName: baseModel.fqName,\r\n modelName: this.namingHelper.getIdModelName(name),\r\n qName: this.namingHelper.getQIdFunctionName(name),\r\n },\r\n generateId: !!keyNames.length,\r\n keyNames: keyNames, // postprocess required to include key specs from base classes\r\n keys: [], // postprocess required to include props from base classes\r\n getKeyUnion: () => keyNames.join(\" | \"),\r\n });\r\n }\r\n }\r\n\r\n private postProcessModel() {\r\n // complex types\r\n const complexTypes = this.dataModel.getComplexTypes();\r\n complexTypes.forEach((ct) => {\r\n const [baseProps, _, baseAttributes] = this.collectBaseClassPropsAndKeys(ct, []);\r\n const { open } = baseAttributes;\r\n ct.baseProps = baseProps.map((bp) => ({ ...bp }));\r\n if (open) {\r\n ct.open = true;\r\n }\r\n });\r\n // entity types\r\n const entityTypes = this.dataModel.getEntityTypes();\r\n entityTypes.forEach((et) => {\r\n const [baseProps, baseKeys, baseAttributes] = this.collectBaseClassPropsAndKeys(et, []);\r\n const { fqIdName, idName, qIdName, open } = baseAttributes;\r\n et.baseProps = baseProps.map((bp) => ({ ...bp }));\r\n\r\n if (!et.keyNames.length && idName) {\r\n et.id = {\r\n fqName: fqIdName,\r\n modelName: idName,\r\n qName: qIdName,\r\n };\r\n et.generateId = false;\r\n }\r\n if (open) {\r\n et.open = open;\r\n }\r\n et.keyNames.unshift(...baseKeys.filter((bk) => !et.keyNames.includes(bk)));\r\n });\r\n }\r\n\r\n private postProcessKeys() {\r\n const entityTypes = this.dataModel.getEntityTypes();\r\n entityTypes.forEach((et) => {\r\n const isSingleKey = et.keyNames.length === 1;\r\n const props = [...et.baseProps, ...et.props];\r\n et.keys = et.keyNames.map((keyName) => {\r\n const prop = props.find((p) => p.odataName === keyName);\r\n if (!prop) {\r\n throw new Error(`Key with name [${keyName}] not found in props!`);\r\n }\r\n\r\n // automatically set key prop to managed, if this is the only key of the given entity\r\n if (prop.managed === undefined) {\r\n prop.managed = !this.options.disableAutoManagedKey && isSingleKey;\r\n }\r\n\r\n return prop;\r\n });\r\n });\r\n }\r\n\r\n private collectBaseClassPropsAndKeys(model: ComplexModelType, visitedModels: string[]): CollectorTuple {\r\n if (visitedModels.includes(model.fqName)) {\r\n throw new Error(`Cyclic inheritance detected for model ${model.fqName}!`);\r\n }\r\n visitedModels.push(model.fqName);\r\n return model.baseClasses.reduce(\r\n ([props, keys, attributes], bc) => {\r\n const baseModel = this.dataModel.getEntityType(bc) || this.dataModel.getComplexType(bc);\r\n if (!baseModel) {\r\n throw new Error(`BaseModel \"${bc}\" doesn't exist!`);\r\n }\r\n\r\n let { fqIdName, idName, qIdName, open } = attributes;\r\n\r\n // recursive\r\n if (baseModel.baseClasses.length) {\r\n const [parentProps, parentKeys, parentAttributes] = this.collectBaseClassPropsAndKeys(\r\n baseModel,\r\n visitedModels\r\n );\r\n props.unshift(...parentProps);\r\n keys.unshift(...parentKeys);\r\n if (parentAttributes?.idName) {\r\n fqIdName = parentAttributes.fqIdName;\r\n idName = parentAttributes.idName;\r\n qIdName = parentAttributes.qIdName;\r\n }\r\n if (parentAttributes?.open) {\r\n open = true;\r\n }\r\n }\r\n\r\n props.push(...baseModel.props);\r\n const entityModel = baseModel as EntityModelType;\r\n if (entityModel.keyNames?.length) {\r\n keys.push(...entityModel.keyNames.filter((kn) => !keys.includes(kn)));\r\n fqIdName = entityModel.id.fqName;\r\n idName = entityModel.id.modelName;\r\n qIdName = entityModel.id.qName;\r\n }\r\n if (baseModel.open) {\r\n open = true;\r\n }\r\n return [props, keys, { fqIdName, idName, qIdName, open }];\r\n },\r\n [[], [], { fqIdName: \"\", idName: \"\", qIdName: \"\", open: false }] as CollectorTuple\r\n );\r\n }\r\n\r\n protected mapProp = (p: Property, entityPropConfig?: PropertyGenerationOptions | undefined): PropertyModel => {\r\n if (!p.$.Type) {\r\n throw new Error(`No type information given for property [${p.$.Name}]!`);\r\n }\r\n\r\n const configProp = this.serviceConfigHelper.findPropConfigByName(p.$.Name);\r\n const modelName = this.namingHelper.getModelPropName(\r\n entityPropConfig?.mappedName || configProp?.mappedName || p.$.Name\r\n );\r\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\r\n let dataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\r\n\r\n // support for primitive type mapping\r\n if (this.namingHelper.includesServicePrefix(dataType)) {\r\n const dt = this.dataModel.getPrimitiveType(dataType);\r\n if (dt !== undefined) {\r\n dataType = dt;\r\n }\r\n }\r\n\r\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\r\n\r\n // domain object known from service:\r\n // EntityType, ComplexType, EnumType\r\n if (this.namingHelper.includesServicePrefix(dataType)) {\r\n const resultDt = this.model2Type.get(dataType)!;\r\n const [dataTypeName, dataTypePrefix] = this.namingHelper.getNameAndServicePrefix(dataType);\r\n const dataTypeNamespace: NamespaceWithAlias = [dataTypePrefix!];\r\n if (!resultDt) {\r\n throw new Error(\r\n `Couldn't determine model data type for property \"${p.$.Name}\"! Given data type: \"${dataType}\".`\r\n );\r\n }\r\n\r\n // special handling for enums\r\n if (resultDt === DataTypes.EnumType) {\r\n const enumConfig = this.serviceConfigHelper.findEnumTypeConfig(dataTypeNamespace, dataTypeName);\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getEnumName(enumConfig?.mappedName ?? dataType),\r\n qPath: \"QEnumPath\",\r\n qObject: isCollection ? \"QEnumCollection\" : undefined,\r\n qParam: \"QEnumParam\",\r\n };\r\n }\r\n // handling of complex & entity types\r\n else {\r\n const entityConfig =\r\n resultDt === DataTypes.ComplexType\r\n ? this.serviceConfigHelper.findComplexTypeConfig(dataTypeNamespace, dataTypeName)\r\n : this.serviceConfigHelper.findEntityTypeConfig(dataTypeNamespace, dataTypeName);\r\n const resultDataType = entityConfig?.mappedName ?? dataType;\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getModelName(resultDataType),\r\n qPath: \"QEntityPath\",\r\n qObject: this.namingHelper.getQName(resultDataType),\r\n qParam: \"QComplexParam\",\r\n };\r\n }\r\n }\r\n // OData built-in data types\r\n else if (dataType.startsWith(Digester.EDM_PREFIX)) {\r\n const { outputType, qPath, qParam, qCollection } = this.mapODataType(dataType);\r\n const { to, toModule: typeModule, converters } = this.dataModel.getConverter(dataType) || {};\r\n\r\n const type = !to ? outputType : to.startsWith(Digester.EDM_PREFIX) ? this.mapODataType(to).outputType : to;\r\n\r\n result = {\r\n dataType: DataTypes.PrimitiveType,\r\n type,\r\n typeModule,\r\n qPath,\r\n qParam,\r\n qObject: isCollection ? qCollection : undefined,\r\n converters,\r\n };\r\n } else {\r\n throw new Error(\r\n `Unknown type [${dataType}]: Not 'Collection(...)', not OData type 'Edm.*', not starting with one of the namespaces!`\r\n );\r\n }\r\n\r\n return {\r\n odataName: p.$.Name,\r\n name: modelName,\r\n odataType: p.$.Type,\r\n fqType: dataType,\r\n required: ifFalse(p.$.Nullable),\r\n isCollection: isCollection,\r\n managed: typeof entityPropConfig?.managed !== \"undefined\" ? entityPropConfig.managed : configProp?.managed,\r\n ...result,\r\n };\r\n };\r\n}\r\n"]}
|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CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACtE,QAAQ,GAAG,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC;gBACjC,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC,SAAS,CAAC;gBAClC,OAAO,GAAG,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC;aAChC;YACD,IAAI,SAAS,CAAC,IAAI,EAAE;gBAClB,IAAI,GAAG,IAAI,CAAC;aACb;YACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC,EACD,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAmB,CACnF,CAAC;IACJ,CAAC;;AAvUH,4BAuaC;AAtakB,mBAAU,GAAG,MAAM,AAAT,CAAU","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { ComplexTypeGenerationOptions, EntityTypeGenerationOptions, PropertyGenerationOptions } from \"../OptionModel\";\r\nimport { DataModel, NamespaceWithAlias, withNamespace } from \"./DataModel\";\r\nimport {\r\n ComplexType as ComplexModelType,\r\n DataTypes,\r\n EntityType as EntityModelType,\r\n ODataVersion,\r\n PropertyModel,\r\n} from \"./DataTypeModel\";\r\nimport { ComplexType, EntityType, EnumType, Property, Schema, TypeDefinition } from \"./edmx/ODataEdmxModelBase\";\r\nimport { SchemaV3 } from \"./edmx/ODataEdmxModelV3\";\r\nimport { SchemaV4 } from \"./edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\nimport { ServiceConfigHelper, WithoutName } from \"./ServiceConfigHelper\";\r\nimport { NameClashValidator } from \"./validation/NameClashValidator\";\r\nimport { NameValidator } from \"./validation/NameValidator\";\r\nimport { NoopValidator } from \"./validation/NoopValidator\";\r\n\r\ntype CollectorTuple = [\r\n Array<PropertyModel>,\r\n Array<string>,\r\n { fqIdName: string; idName: string; qIdName: string; open: boolean }\r\n];\r\n\r\nfunction ifTrue(value: string | undefined): boolean {\r\n return value === \"true\";\r\n}\r\n\r\nfunction ifFalse(value: string | undefined): boolean {\r\n return value === \"false\";\r\n}\r\n\r\nexport interface TypeModel {\r\n outputType: string;\r\n qPath: string;\r\n qCollection: string;\r\n qParam: string | undefined;\r\n}\r\n\r\nexport abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {\r\n protected static EDM_PREFIX = \"Edm.\";\r\n\r\n protected readonly dataModel: DataModel;\r\n protected readonly serviceConfigHelper: ServiceConfigHelper;\r\n protected readonly nameValidator: NameValidator;\r\n\r\n private model2Type = new Map<string, DataTypes>();\r\n\r\n protected constructor(\r\n protected version: ODataVersion,\r\n protected schemas: Array<S>,\r\n protected options: DigestionOptions,\r\n protected namingHelper: NamingHelper,\r\n converters?: MappedConverterChains\r\n ) {\r\n const namespaces = schemas.map<NamespaceWithAlias>((s) => [s.$.Namespace, s.$.Alias]);\r\n this.dataModel = new DataModel(namespaces, version, converters);\r\n this.serviceConfigHelper = new ServiceConfigHelper(options);\r\n this.nameValidator = this.options.bundledFileGeneration ? new NameClashValidator(options) : new NoopValidator();\r\n\r\n this.collectModelTypes(schemas);\r\n }\r\n\r\n private collectModelTypes(schemas: Array<S>) {\r\n schemas.forEach((schema) => {\r\n const { Namespace: ns, Alias: alias } = schema.$;\r\n\r\n schema.EnumType?.forEach((et) => {\r\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.EnumType);\r\n });\r\n schema.ComplexType?.forEach((ct) => {\r\n this.addModel2Type(ns, alias, ct.$.Name, DataTypes.ComplexType);\r\n });\r\n schema.EntityType?.forEach((et) => {\r\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.ModelType);\r\n });\r\n });\r\n }\r\n\r\n private addModel2Type(ns: string, alias: string | undefined, name: string, dt: DataTypes) {\r\n this.model2Type.set(withNamespace(ns, name), dt);\r\n if (alias) {\r\n this.model2Type.set(withNamespace(alias, name), dt);\r\n }\r\n }\r\n\r\n protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;\r\n\r\n protected abstract digestOperations(schema: SchemaV3 | SchemaV4): void;\r\n\r\n protected abstract digestEntityContainer(schema: SchemaV3 | SchemaV4): void;\r\n\r\n /**\r\n * Get essential infos about a given odata type from the version specific service variants.\r\n *\r\n * @param type\r\n * @return tuple of return type, query object, query collection object\r\n */\r\n protected abstract mapODataType(type: string): TypeModel;\r\n\r\n public async digest(): Promise<DataModel> {\r\n this.digestEntityTypesAndOperations();\r\n\r\n // delegate to version specific entity container digestion\r\n this.schemas.forEach((schema) => this.digestEntityContainer(schema));\r\n\r\n this.dataModel.setNameValidation(this.nameValidator.validate());\r\n return this.dataModel;\r\n }\r\n\r\n private digestEntityTypesAndOperations() {\r\n this.schemas.forEach((schema) => {\r\n const ns: NamespaceWithAlias = [schema.$.Namespace, schema.$.Alias];\r\n\r\n // type definitions: alias for primitive types\r\n this.addTypeDefinition(schema.$.Namespace, schema.TypeDefinition);\r\n\r\n // enums\r\n this.addEnum(ns, schema.EnumType);\r\n\r\n // complex types\r\n this.addComplexType(ns, schema.ComplexType);\r\n\r\n // entity types\r\n this.addEntityType(ns, schema.EntityType);\r\n\r\n // V4 only: function & action types\r\n this.digestOperations(schema);\r\n });\r\n\r\n this.postProcessModel();\r\n this.postProcessKeys();\r\n }\r\n\r\n private getBaseModel(\r\n entityConfig: WithoutName<EntityTypeGenerationOptions | ComplexTypeGenerationOptions> | undefined,\r\n model: ComplexType,\r\n namespace: string,\r\n name: string,\r\n fqName: string\r\n ) {\r\n const odataName = model.$.Name;\r\n\r\n // map properties respecting the config\r\n const props = [...(model.Property ?? []), ...this.getNavigationProps(model)].map((p) => {\r\n const epConfig = entityConfig?.properties?.find((ep) => ep.name === p.$.Name);\r\n return this.mapProp(p, epConfig);\r\n });\r\n\r\n // support for base types, i.e. extends clause of interfaces\r\n const baseClasses = [];\r\n let finalBaseClass: string | undefined = undefined;\r\n if (model.$.BaseType) {\r\n baseClasses.push(model.$.BaseType);\r\n const [baseName, basePrefix] = this.namingHelper.getNameAndServicePrefix(model.$.BaseType);\r\n const baseConfig =\r\n this.serviceConfigHelper.findEntityTypeConfig([basePrefix!], baseName) ||\r\n this.serviceConfigHelper.findComplexTypeConfig([basePrefix!], baseName);\r\n finalBaseClass = baseConfig?.mappedName ?? baseName;\r\n }\r\n\r\n return {\r\n fqName,\r\n odataName,\r\n name,\r\n modelName: this.namingHelper.getModelName(name),\r\n qName: this.namingHelper.getQName(name),\r\n editableName: this.namingHelper.getEditableModelName(name),\r\n serviceName: this.namingHelper.getServiceName(name),\r\n serviceCollectionName: this.namingHelper.getCollectionServiceName(name),\r\n folderPath: this.namingHelper.getFolderPath(namespace, name),\r\n baseClasses,\r\n finalBaseClass,\r\n props,\r\n baseProps: [], // postprocess required\r\n abstract: ifTrue(model.$.Abstract),\r\n open: ifTrue(model.$.OpenType),\r\n };\r\n }\r\n\r\n private addTypeDefinition(ns: string, types: Array<TypeDefinition> | undefined) {\r\n if (!types || !types.length) {\r\n return;\r\n }\r\n\r\n for (const t of types) {\r\n this.dataModel.addTypeDefinition(ns, t.$.Name, t.$.UnderlyingType);\r\n }\r\n }\r\n\r\n private addEnum(namespace: NamespaceWithAlias, models: Array<EnumType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const et of models) {\r\n const odataName = et.$.Name;\r\n const fqName = withNamespace(namespace[0], odataName);\r\n const config = this.serviceConfigHelper.findEnumTypeConfig(namespace, odataName);\r\n const enumName = this.nameValidator.addEnumType(fqName, config?.mappedName || odataName);\r\n const filePath = this.namingHelper.getFolderPath(namespace[0], enumName);\r\n this.dataModel.addEnum(namespace[0], odataName, {\r\n fqName,\r\n odataName,\r\n name: enumName,\r\n modelName: this.namingHelper.getEnumName(enumName),\r\n folderPath: filePath,\r\n members: et.Member?.length ? et.Member.map((m) => m.$.Name) : [],\r\n });\r\n }\r\n }\r\n\r\n private addComplexType(namespace: NamespaceWithAlias, models: Array<ComplexType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const config = this.serviceConfigHelper.findComplexTypeConfig(namespace, model.$.Name);\r\n const fqName = withNamespace(namespace[0], model.$.Name);\r\n const name = this.nameValidator.addComplexType(fqName, config?.mappedName || model.$.Name);\r\n const baseModel = this.getBaseModel(config, model, namespace[0], name, fqName);\r\n this.dataModel.addComplexType(namespace[0], baseModel.odataName, baseModel);\r\n }\r\n }\r\n\r\n private addEntityType(namespace: NamespaceWithAlias, models: Array<ET> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const entityConfig = this.serviceConfigHelper.findEntityTypeConfig(namespace, model.$.Name);\r\n const fqName = withNamespace(namespace[0], model.$.Name);\r\n const name = this.nameValidator.addEntityType(fqName, entityConfig?.mappedName || model.$.Name);\r\n const baseModel = this.getBaseModel(entityConfig, model, namespace[0], name, fqName);\r\n\r\n // key support: we add keys from this entity,\r\n // but not keys stemming from base classes (postprocess required)\r\n const keyNames: Array<string> = [];\r\n if (entityConfig?.keys?.length) {\r\n keyNames.push(...entityConfig.keys);\r\n } else {\r\n const entity = model as EntityType;\r\n if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {\r\n const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);\r\n keyNames.push(...propNames);\r\n }\r\n }\r\n\r\n this.dataModel.addEntityType(namespace[0], baseModel.odataName, {\r\n ...baseModel,\r\n id: {\r\n fqName: baseModel.fqName,\r\n modelName: this.namingHelper.getIdModelName(name),\r\n qName: this.namingHelper.getQIdFunctionName(name),\r\n },\r\n generateId: !!keyNames.length,\r\n keyNames: keyNames, // postprocess required to include key specs from base classes\r\n keys: [], // postprocess required to include props from base classes\r\n getKeyUnion: () => keyNames.join(\" | \"),\r\n });\r\n }\r\n }\r\n\r\n private postProcessModel() {\r\n // complex types\r\n const complexTypes = this.dataModel.getComplexTypes();\r\n complexTypes.forEach((ct) => {\r\n const [baseProps, _, baseAttributes] = this.collectBaseClassPropsAndKeys(ct, []);\r\n const { open } = baseAttributes;\r\n ct.baseProps = baseProps.map((bp) => ({ ...bp }));\r\n if (open) {\r\n ct.open = true;\r\n }\r\n });\r\n // entity types\r\n const entityTypes = this.dataModel.getEntityTypes();\r\n entityTypes.forEach((et) => {\r\n const [baseProps, baseKeys, baseAttributes] = this.collectBaseClassPropsAndKeys(et, []);\r\n const { fqIdName, idName, qIdName, open } = baseAttributes;\r\n et.baseProps = baseProps.map((bp) => ({ ...bp }));\r\n\r\n if (!et.keyNames.length && idName) {\r\n et.id = {\r\n fqName: fqIdName,\r\n modelName: idName,\r\n qName: qIdName,\r\n };\r\n et.generateId = false;\r\n }\r\n if (open) {\r\n et.open = open;\r\n }\r\n et.keyNames.unshift(...baseKeys.filter((bk) => !et.keyNames.includes(bk)));\r\n });\r\n }\r\n\r\n private postProcessKeys() {\r\n const entityTypes = this.dataModel.getEntityTypes();\r\n entityTypes.forEach((et) => {\r\n const isSingleKey = et.keyNames.length === 1;\r\n const props = [...et.baseProps, ...et.props];\r\n et.keys = et.keyNames.map((keyName) => {\r\n const prop = props.find((p) => p.odataName === keyName);\r\n if (!prop) {\r\n throw new Error(`Key with name [${keyName}] not found in props!`);\r\n }\r\n\r\n // automatically set key prop to managed, if this is the only key of the given entity\r\n if (prop.managed === undefined) {\r\n prop.managed = !this.options.disableAutoManagedKey && isSingleKey;\r\n }\r\n\r\n return prop;\r\n });\r\n });\r\n }\r\n\r\n private collectBaseClassPropsAndKeys(model: ComplexModelType, visitedModels: string[]): CollectorTuple {\r\n if (visitedModels.includes(model.fqName)) {\r\n throw new Error(`Cyclic inheritance detected for model ${model.fqName}!`);\r\n }\r\n visitedModels.push(model.fqName);\r\n return model.baseClasses.reduce(\r\n ([props, keys, attributes], bc) => {\r\n const baseModel = this.dataModel.getEntityType(bc) || this.dataModel.getComplexType(bc);\r\n if (!baseModel) {\r\n throw new Error(`BaseModel \"${bc}\" doesn't exist!`);\r\n }\r\n\r\n let { fqIdName, idName, qIdName, open } = attributes;\r\n\r\n // recursive\r\n if (baseModel.baseClasses.length) {\r\n const [parentProps, parentKeys, parentAttributes] = this.collectBaseClassPropsAndKeys(\r\n baseModel,\r\n visitedModels\r\n );\r\n props.unshift(...parentProps);\r\n keys.unshift(...parentKeys);\r\n if (parentAttributes?.idName) {\r\n fqIdName = parentAttributes.fqIdName;\r\n idName = parentAttributes.idName;\r\n qIdName = parentAttributes.qIdName;\r\n }\r\n if (parentAttributes?.open) {\r\n open = true;\r\n }\r\n }\r\n\r\n props.push(...baseModel.props);\r\n const entityModel = baseModel as EntityModelType;\r\n if (entityModel.keyNames?.length) {\r\n keys.push(...entityModel.keyNames.filter((kn) => !keys.includes(kn)));\r\n fqIdName = entityModel.id.fqName;\r\n idName = entityModel.id.modelName;\r\n qIdName = entityModel.id.qName;\r\n }\r\n if (baseModel.open) {\r\n open = true;\r\n }\r\n return [props, keys, { fqIdName, idName, qIdName, open }];\r\n },\r\n [[], [], { fqIdName: \"\", idName: \"\", qIdName: \"\", open: false }] as CollectorTuple\r\n );\r\n }\r\n\r\n protected mapProp = (p: Property, entityPropConfig?: PropertyGenerationOptions | undefined): PropertyModel => {\r\n if (!p.$.Type) {\r\n throw new Error(`No type information given for property [${p.$.Name}]!`);\r\n }\r\n\r\n const configProp = this.serviceConfigHelper.findPropConfigByName(p.$.Name);\r\n const modelName = this.namingHelper.getModelPropName(\r\n entityPropConfig?.mappedName || configProp?.mappedName || p.$.Name\r\n );\r\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\r\n let dataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\r\n\r\n // support for primitive type mapping\r\n if (this.namingHelper.includesServicePrefix(dataType)) {\r\n const dt = this.dataModel.getPrimitiveType(dataType);\r\n if (dt !== undefined) {\r\n dataType = dt;\r\n }\r\n }\r\n\r\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\r\n\r\n // domain object known from service:\r\n // EntityType, ComplexType, EnumType\r\n if (this.namingHelper.includesServicePrefix(dataType)) {\r\n const resultDt = this.model2Type.get(dataType)!;\r\n const [dataTypeName, dataTypePrefix] = this.namingHelper.getNameAndServicePrefix(dataType);\r\n const dataTypeNamespace: NamespaceWithAlias = [dataTypePrefix!];\r\n if (!resultDt) {\r\n throw new Error(\r\n `Couldn't determine model data type for property \"${p.$.Name}\"! Given data type: \"${dataType}\".`\r\n );\r\n }\r\n\r\n // special handling for enums\r\n if (resultDt === DataTypes.EnumType) {\r\n const enumConfig = this.serviceConfigHelper.findEnumTypeConfig(dataTypeNamespace, dataTypeName);\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getEnumName(enumConfig?.mappedName ?? dataType),\r\n qPath: \"QEnumPath\",\r\n qObject: isCollection ? \"QEnumCollection\" : undefined,\r\n qParam: \"QEnumParam\",\r\n };\r\n }\r\n // handling of complex & entity types\r\n else {\r\n const entityConfig =\r\n resultDt === DataTypes.ComplexType\r\n ? this.serviceConfigHelper.findComplexTypeConfig(dataTypeNamespace, dataTypeName)\r\n : this.serviceConfigHelper.findEntityTypeConfig(dataTypeNamespace, dataTypeName);\r\n const resultDataType = entityConfig?.mappedName ?? dataType;\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getModelName(resultDataType),\r\n qPath: \"QEntityPath\",\r\n qObject: this.namingHelper.getQName(resultDataType),\r\n qParam: \"QComplexParam\",\r\n };\r\n }\r\n }\r\n // OData built-in data types\r\n else if (dataType.startsWith(Digester.EDM_PREFIX)) {\r\n const { outputType, qPath, qParam, qCollection } = this.mapODataType(dataType);\r\n const { to, toModule: typeModule, converters } = this.dataModel.getConverter(dataType) || {};\r\n\r\n const type = !to ? outputType : to.startsWith(Digester.EDM_PREFIX) ? this.mapODataType(to).outputType : to;\r\n\r\n result = {\r\n dataType: DataTypes.PrimitiveType,\r\n type,\r\n typeModule,\r\n qPath,\r\n qParam,\r\n qObject: isCollection ? qCollection : undefined,\r\n converters,\r\n };\r\n } else {\r\n throw new Error(\r\n `Unknown type [${dataType}]: Not 'Collection(...)', not OData type 'Edm.*', not starting with one of the namespaces!`\r\n );\r\n }\r\n\r\n return {\r\n odataName: p.$.Name,\r\n name: modelName,\r\n odataType: p.$.Type,\r\n fqType: dataType,\r\n required: ifFalse(p.$.Nullable),\r\n isCollection: isCollection,\r\n managed: typeof entityPropConfig?.managed !== \"undefined\" ? entityPropConfig.managed : configProp?.managed,\r\n ...result,\r\n };\r\n };\r\n}\r\n"]}
|
|
@@ -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 Alias?: string;\n };\n EntityType?: Array<ET>;\n ComplexType?: Array<CT>;\n EnumType?: Array<EnumType>;\n EntityContainer?: Array<any>;\n TypeDefinition?: Array<TypeDefinition>;\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 Abstract?: \"true\" | \"false\";\n OpenType?: \"true\" | \"false\";\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 Nullable?: \"true\" | \"false\";\n MaxLength?: number;\n Precision?: number;\n Scale?: number;\n };\n}\n\nexport interface EnumType {\n $: {\n Name: string;\n };\n Member
|
|
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 Alias?: 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 TypeDefinition?: Array<TypeDefinition>;\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 Abstract?: \"true\" | \"false\";\r\n OpenType?: \"true\" | \"false\";\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 Nullable?: \"true\" | \"false\";\r\n MaxLength?: number;\r\n Precision?: number;\r\n Scale?: 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\r\nexport interface TypeDefinition {\r\n $: {\r\n Name: string;\r\n UnderlyingType: string;\r\n MaxLength?: number;\r\n Precision?: number;\r\n Scale?: number;\r\n };\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NameValidator.js","sourceRoot":"","sources":["../../../src/data-model/validation/NameValidator.ts"],"names":[],"mappings":"","sourcesContent":["import { TypeModel } from \"../../TypeModel\";\n\nexport interface NameValidator {\n addEntityType(fqName: string, name: string): string;\n\n addComplexType(fqName: string, name: string): string;\n\n addEnumType(fqName: string, name: string): string;\n\n addUnboundOperationType(fqName: string, name: string): string;\n\n addBoundOperationType(bindingName: string, fqName: string, name: string): string;\n\n addOperationImportType(fqName: string, name: string): string;\n\n addEntitySet(fqName: string, name: string): string;\n\n addSingleton(fqName: string, name: string): string;\n\n validate(): Map<string, ValidationError[]>;\n}\n\nexport interface ValidationError {\n fqName: string;\n type: TypeModel;\n renamedTo?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NameValidator.js","sourceRoot":"","sources":["../../../src/data-model/validation/NameValidator.ts"],"names":[],"mappings":"","sourcesContent":["import { TypeModel } from \"../../TypeModel\";\r\n\r\nexport interface NameValidator {\r\n addEntityType(fqName: string, name: string): string;\r\n\r\n addComplexType(fqName: string, name: string): string;\r\n\r\n addEnumType(fqName: string, name: string): string;\r\n\r\n addUnboundOperationType(fqName: string, name: string): string;\r\n\r\n addBoundOperationType(bindingName: string, fqName: string, name: string): string;\r\n\r\n addOperationImportType(fqName: string, name: string): string;\r\n\r\n addEntitySet(fqName: string, name: string): string;\r\n\r\n addSingleton(fqName: string, name: string): string;\r\n\r\n validate(): Map<string, ValidationError[]>;\r\n}\r\n\r\nexport interface ValidationError {\r\n fqName: string;\r\n type: TypeModel;\r\n renamedTo?: string;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoopValidator.js","sourceRoot":"","sources":["../../../src/data-model/validation/NoopValidator.ts"],"names":[],"mappings":";;;AAGA,MAAa,aAAa;IACxB,qBAAqB,CAAC,WAAmB,EAAE,MAAc,EAAE,IAAY;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,MAAc,EAAE,IAAY;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,IAAY;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,MAAc,EAAE,IAAY;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,MAAc,EAAE,IAAY;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sBAAsB,CAAC,MAAc,EAAE,IAAY;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,IAAY;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uBAAuB,CAAC,MAAc,EAAE,IAAY;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;CACF;AApCD,sCAoCC","sourcesContent":["import { TypeModel } from \"../../TypeModel\";\nimport { NameValidator, ValidationError } from \"./NameValidator\";\n\nexport class NoopValidator implements NameValidator {\n addBoundOperationType(bindingName: string, fqName: string, name: string): string {\n return name;\n }\n\n addComplexType(fqName: string, name: string): string {\n return name;\n }\n\n addEntitySet(fqName: string, name: string): string {\n return name;\n }\n\n addEntityType(fqName: string, name: string): string {\n return name;\n }\n\n addEnumType(fqName: string, name: string): string {\n return name;\n }\n\n addOperationImportType(fqName: string, name: string): string {\n return name;\n }\n\n addSingleton(fqName: string, name: string): string {\n return name;\n }\n\n addUnboundOperationType(fqName: string, name: string): string {\n return name;\n }\n\n validate(): Map<string, ValidationError[]> {\n return new Map();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NoopValidator.js","sourceRoot":"","sources":["../../../src/data-model/validation/NoopValidator.ts"],"names":[],"mappings":";;;AAGA,MAAa,aAAa;IACxB,qBAAqB,CAAC,WAAmB,EAAE,MAAc,EAAE,IAAY;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,MAAc,EAAE,IAAY;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,IAAY;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,MAAc,EAAE,IAAY;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,MAAc,EAAE,IAAY;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sBAAsB,CAAC,MAAc,EAAE,IAAY;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,IAAY;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uBAAuB,CAAC,MAAc,EAAE,IAAY;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;CACF;AApCD,sCAoCC","sourcesContent":["import { TypeModel } from \"../../TypeModel\";\r\nimport { NameValidator, ValidationError } from \"./NameValidator\";\r\n\r\nexport class NoopValidator implements NameValidator {\r\n addBoundOperationType(bindingName: string, fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addComplexType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addEntitySet(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addEntityType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addEnumType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addOperationImportType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addSingleton(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n addUnboundOperationType(fqName: string, name: string): string {\r\n return name;\r\n }\r\n\r\n validate(): Map<string, ValidationError[]> {\r\n return new Map();\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportedNameValidator.js","sourceRoot":"","sources":["../../src/generator/ImportedNameValidator.ts"],"names":[],"mappings":";;;AAAA,MAAa,qBAAqB;IAGhC,YAAmB,aAAyC;QAFpD,kBAAa,GAAG,IAAI,GAAG,EAAkC,CAAC;QAGhE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;YAC5B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,YAAY,CAAC,SAAiB,EAAE,IAAY;;QACjD,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAC;QACtD,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;QAEtC,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC;SAChB;QAED,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC;QACtD,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAEnE,UAAU,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;QAC/B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAEzC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAzBD,sDAyBC","sourcesContent":["export class ImportedNameValidator {\n private importedNames = new Map<string, Record<string, string>>();\n\n public constructor(reservedNames?: Array<string> | undefined) {\n reservedNames?.forEach((rn) => {\n this.importedNames.set(rn, { [\"_\"]: rn });\n });\n }\n\n public validateName(qualifier: string, name: string): string {\n const qualifiers = this.importedNames.get(name) ?? {};\n const hitName = qualifiers[qualifier];\n\n if (hitName) {\n return hitName;\n }\n\n const qualifiersSize = Object.keys(qualifiers).length;\n const result = qualifiersSize ? `${name}_${qualifiersSize}` : name;\n\n qualifiers[qualifier] = result;\n this.importedNames.set(name, qualifiers);\n\n return result;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ImportedNameValidator.js","sourceRoot":"","sources":["../../src/generator/ImportedNameValidator.ts"],"names":[],"mappings":";;;AAAA,MAAa,qBAAqB;IAGhC,YAAmB,aAAyC;QAFpD,kBAAa,GAAG,IAAI,GAAG,EAAkC,CAAC;QAGhE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;YAC5B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,YAAY,CAAC,SAAiB,EAAE,IAAY;;QACjD,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAC;QACtD,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;QAEtC,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC;SAChB;QAED,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC;QACtD,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAEnE,UAAU,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;QAC/B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAEzC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAzBD,sDAyBC","sourcesContent":["export class ImportedNameValidator {\r\n private importedNames = new Map<string, Record<string, string>>();\r\n\r\n public constructor(reservedNames?: Array<string> | undefined) {\r\n reservedNames?.forEach((rn) => {\r\n this.importedNames.set(rn, { [\"_\"]: rn });\r\n });\r\n }\r\n\r\n public validateName(qualifier: string, name: string): string {\r\n const qualifiers = this.importedNames.get(name) ?? {};\r\n const hitName = qualifiers[qualifier];\r\n\r\n if (hitName) {\r\n return hitName;\r\n }\r\n\r\n const qualifiersSize = Object.keys(qualifiers).length;\r\n const result = qualifiersSize ? `${name}_${qualifiersSize}` : name;\r\n\r\n qualifiers[qualifier] = result;\r\n this.importedNames.set(name, qualifiers);\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -58,7 +58,7 @@ class ServiceGenerator {
|
|
|
58
58
|
mainServiceFile.getFile().addClass({
|
|
59
59
|
isExported: true,
|
|
60
60
|
name: mainServiceName,
|
|
61
|
-
typeParameters: [`ClientType extends ${httpClient}`],
|
|
61
|
+
typeParameters: [`in out ClientType extends ${httpClient}`],
|
|
62
62
|
extends: `${rootService}<ClientType>`,
|
|
63
63
|
ctors: this.isV4BigNumber()
|
|
64
64
|
? [
|
|
@@ -181,7 +181,7 @@ class ServiceGenerator {
|
|
|
181
181
|
file.getFile().addClass({
|
|
182
182
|
isExported: true,
|
|
183
183
|
name: model.serviceName,
|
|
184
|
-
typeParameters: [`ClientType extends ${httpClient}`],
|
|
184
|
+
typeParameters: [`in out ClientType extends ${httpClient}`],
|
|
185
185
|
extends: entityServiceType + `<ClientType, ${modelName}, ${editableModelName}, ${qName}>`,
|
|
186
186
|
ctors: [
|
|
187
187
|
{
|
|
@@ -369,7 +369,7 @@ class ServiceGenerator {
|
|
|
369
369
|
file.getFile().addClass({
|
|
370
370
|
isExported: true,
|
|
371
371
|
name: model.serviceCollectionName,
|
|
372
|
-
typeParameters: ["ClientType extends ODataHttpClient"],
|
|
372
|
+
typeParameters: ["in out ClientType extends ODataHttpClient"],
|
|
373
373
|
extends: entitySetServiceType +
|
|
374
374
|
`<ClientType, ${model.modelName}, ${editableModelName}, ${model.qName}, ${paramsModelName}>`,
|
|
375
375
|
ctors: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,kEAAkC;AAClC,uCAMkB;AAClB,uDAAkD;AAClD,sDAA2D;AAoB3D,0DAA2G;AAQ3G,SAAsB,gBAAgB,CACpC,OAAuB,EACvB,SAAoB,EACpB,OAAsB,EACtB,YAA0B,EAC1B,OAAiC;;QAEjC,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QAC3F,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;CAAA;AATD,4CASC;AAED,MAAM,gBAAgB;IACpB,YACU,OAAuB,EACvB,SAAoB,EACpB,OAAsB,EACtB,YAA0B,EAC1B,UAAmC,EAAE;QAJrC,YAAO,GAAP,OAAO,CAAgB;QACvB,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAe;QACtB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,YAAO,GAAP,OAAO,CAA8B;QAyJvC,2BAAsB,GAAG,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C,CAAC,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,mDAA4B;gBAClD,CAAC,CAAC,2BAAW,CAAC,kBAAkB;gBAChC,CAAC,CAAC,2BAAW,CAAC,kBAAkB,CAAC;QAEnC,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,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} 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 EntityType,\r\n FunctionImportType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n ReturnTypeModel,\r\n SingletonType,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { ConfigFileOptions } from \"../OptionModel\";\r\nimport { FileHandler } from \"../project/FileHandler\";\r\nimport { ProjectManager } from \"../project/ProjectManager\";\r\nimport { ClientApiImports, CoreImports, QueryObjectImports, ServiceImports } from \"./import/ImportObjects\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nexport interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, \"properties\" | \"methods\">> {}\r\n\r\nexport interface ServiceGeneratorOptions\r\n extends Pick<ConfigFileOptions, \"enablePrimitivePropertyServices\" | \"v4BigNumberAsString\"> {}\r\n\r\nexport async function generateServices(\r\n project: ProjectManager,\r\n dataModel: DataModel,\r\n version: ODataVersions,\r\n namingHelper: NamingHelper,\r\n options?: ServiceGeneratorOptions\r\n) {\r\n const generator = new ServiceGenerator(project, dataModel, version, namingHelper, options);\r\n return generator.generate();\r\n}\r\n\r\nclass ServiceGenerator {\r\n constructor(\r\n private project: ProjectManager,\r\n private dataModel: DataModel,\r\n private version: ODataVersions,\r\n private namingHelper: NamingHelper,\r\n private options: ServiceGeneratorOptions = {}\r\n ) {}\r\n\r\n private isV4BigNumber() {\r\n return this.options.v4BigNumberAsString && this.version === ODataVersions.V4;\r\n }\r\n\r\n public async generate(): Promise<void> {\r\n const mainServiceName = this.namingHelper.getMainServiceName();\r\n this.project.initServices();\r\n\r\n await Promise.all([\r\n this.generateMainService(mainServiceName),\r\n ...this.generateEntityTypeServices(),\r\n ...this.generateComplexTypeServices(),\r\n ]);\r\n\r\n return this.project.finalizeServices();\r\n }\r\n\r\n private async generateMainService(mainServiceName: string) {\r\n const mainServiceFile = this.project.getMainServiceFile();\r\n const importContainer = mainServiceFile.getImports();\r\n const container = this.dataModel.getEntityContainer();\r\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\r\n\r\n const [httpClient] = importContainer.addClientApi(ClientApiImports.ODataHttpClient);\r\n const [rootService] = importContainer.addServiceObject(this.version, ServiceImports.ODataService);\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 mainServiceFile.getFile().addClass({\r\n isExported: true,\r\n name: mainServiceName,\r\n typeParameters: [`ClientType extends ${httpClient}`],\r\n extends: `${rootService}<ClientType>`,\r\n ctors: this.isV4BigNumber()\r\n ? [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n ],\r\n statements: [`super(client, basePath, true);`],\r\n },\r\n ]\r\n : [],\r\n properties,\r\n methods,\r\n });\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, odataName, entityType }) => {\r\n result.methods.push(this.generateRelatedServiceGetter(name, odataName, entityType, importContainer));\r\n });\r\n\r\n Object.values(container.singletons).forEach((singleton) => {\r\n result.properties.push(this.generateSingletonProp(importContainer, singleton));\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 const op = this.dataModel.getUnboundOperationType(operation);\r\n if (!op) {\r\n throw new Error(`Operation \"${operation}\" not found!`);\r\n }\r\n\r\n result.properties.push(this.generateQOperationProp(op));\r\n result.methods.push(this.generateMethod(name, op, importContainer, \"\"));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateRelatedServiceGetter(\r\n propName: string,\r\n odataPropName: string,\r\n entityType: EntityType,\r\n imports: ImportContainer\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const idName = imports.addGeneratedModel(entityType.id.fqName, entityType.id.modelName);\r\n const idFunctionName = imports.addGeneratedQObject(entityType.id.fqName, entityType.id.qName);\r\n const serviceName = imports.addGeneratedService(entityType.fqName, entityType.serviceName);\r\n const collectionName = imports.addGeneratedService(entityType.fqName, entityType.serviceCollectionName);\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 = \"${odataPropName}\";`,\r\n `const { client, path } = this.__base;`,\r\n 'return typeof id === \"undefined\" || id === null',\r\n `? new ${collectionName}(client, path, fieldName)`,\r\n `: new ${serviceName}(client, path, new ${idFunctionName}(fieldName).buildUrl(id));`,\r\n ],\r\n };\r\n }\r\n\r\n private generateSingletonProp(\r\n importContainer: ImportContainer,\r\n singleton: SingletonType\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const { name, entityType } = singleton;\r\n const type = entityType.serviceName;\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 = entityType.serviceName;\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 ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${propName} = new ${serviceType}(client, path, \"${odataName}\")`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generateEntityTypeService(file: FileHandler, model: ComplexType) {\r\n const importContainer = file.getImports();\r\n\r\n const operations = this.dataModel.getEntityTypeOperations(model.fqName);\r\n const props = [...model.baseProps, ...model.props];\r\n\r\n const [entityServiceType] = importContainer.addServiceObject(this.version, ServiceImports.EntityTypeService);\r\n const [httpClient] = importContainer.addClientApi(ClientApiImports.ODataHttpClient);\r\n\r\n // note: predictable first imports => no need to take renaming into account\r\n const modelName = importContainer.addGeneratedModel(model.fqName, model.modelName);\r\n const editableModelName = importContainer.addGeneratedModel(model.fqName, model.editableName);\r\n const qName = importContainer.addGeneratedQObject(model.fqName, model.qName);\r\n const qObjectName = importContainer.addGeneratedQObject(model.fqName, firstCharLowerCase(model.qName));\r\n\r\n const { properties, methods }: PropsAndOps = deepmerge(\r\n this.generateServiceProperties(importContainer, model.serviceName, props),\r\n this.generateServiceOperations(importContainer, model, operations)\r\n );\r\n\r\n // generate EntityTypeService\r\n file.getFile().addClass({\r\n isExported: true,\r\n name: model.serviceName,\r\n typeParameters: [`ClientType extends ${httpClient}`],\r\n extends: entityServiceType + `<ClientType, ${modelName}, ${editableModelName}, ${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}${this.isV4BigNumber() ? \", true\" : \"\"});`],\r\n },\r\n ],\r\n properties,\r\n methods,\r\n });\r\n }\r\n\r\n private generateServiceProperties(\r\n importContainer: ImportContainer,\r\n serviceName: string,\r\n props: Array<PropertyModel>\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n props.forEach((prop) => {\r\n // complex types, collection of complex types or entityTypes\r\n if ((prop.dataType === DataTypes.ModelType && !prop.isCollection) || prop.dataType === DataTypes.ComplexType) {\r\n result.properties.push(this.generateModelProp(importContainer, prop));\r\n result.methods.push(this.generateModelPropGetter(importContainer, prop));\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.getEntityType(prop.fqType);\r\n if (!entityType) {\r\n throw new Error(`Entity type \"${prop.fqType}\" specified by property not found!`);\r\n }\r\n\r\n result.methods.push(\r\n this.generateRelatedServiceGetter(prop.name, prop.odataName, entityType, importContainer)\r\n );\r\n }\r\n // collection of primitive or enum types\r\n else {\r\n result.properties.push(this.generatePrimitiveCollectionProp(importContainer, prop));\r\n result.methods.push(this.generatePrimitiveCollectionGetter(importContainer, prop));\r\n }\r\n }\r\n // generation of services for each primitive property: turned off by default\r\n else if (this.options.enablePrimitivePropertyServices && prop.dataType === DataTypes.PrimitiveType) {\r\n result.properties.push(this.generatePrimitiveTypeProp(importContainer, prop));\r\n result.methods.push(this.generatePrimitiveTypeGetter(importContainer, prop));\r\n }\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateServiceOperations(\r\n importContainer: ImportContainer,\r\n model: ComplexType,\r\n operations: Array<OperationType>\r\n ): 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, model.fqName));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateModelProp(imports: ImportContainer, prop: PropertyModel): PropertyDeclarationStructure {\r\n const propModel = this.dataModel.getModel(prop.fqType) as ComplexType;\r\n let propModelType: string;\r\n\r\n if (prop.isCollection) {\r\n const modelName = imports.addGeneratedModel(propModel.fqName, propModel.modelName);\r\n const editableModelName = imports.addGeneratedModel(propModel.fqName, propModel.editableName);\r\n const qModelName = imports.addGeneratedQObject(propModel.fqName, propModel.qName);\r\n const [collectionServiceType] = imports.addServiceObject(this.version, ServiceImports.CollectionService);\r\n\r\n propModelType = `${collectionServiceType}<ClientType, ${modelName}, ${qModelName}, ${editableModelName}>`;\r\n } else {\r\n const serviceName = imports.addGeneratedService(propModel.fqName, propModel.serviceName);\r\n propModelType = `${serviceName}<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 imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<PropertyDeclarationStructure> {\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 const [collectionServiceType] = imports.addServiceObject(this.version, ServiceImports.CollectionService);\r\n const isEnum = prop.dataType === DataTypes.EnumType;\r\n let qType: string;\r\n let type: string;\r\n\r\n if (!isEnum) {\r\n // TODO move string concat (StringCollection, GuidCollection...) to better place\r\n [type, qType] = imports.addFromQObject(`${upperCaseFirst(prop.type)}Collection`, prop.qObject);\r\n } else {\r\n const propEnum = this.dataModel.getModel(prop.fqType)!;\r\n const propTypeModel = imports.addGeneratedModel(propEnum.fqName, propEnum.modelName);\r\n [type, qType] = imports.addQObject(QueryObjectImports.EnumCollection, QueryObjectImports.QEnumCollection);\r\n type = `${type}<${propTypeModel}>`;\r\n }\r\n\r\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\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 generatePrimitiveTypeProp(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const [serviceType] = imports.addServiceObject(this.version, ServiceImports.PrimitiveTypeService);\r\n const type = prop.typeModule ? imports.addCustomType(prop.typeModule, prop.type) : prop.type;\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: `${serviceType}<ClientType, ${type}>`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generateModelPropGetter(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const model = this.dataModel.getModel(prop.fqType) as ComplexType;\r\n const isComplexCollection = prop.isCollection && model.dataType === DataTypes.ComplexType;\r\n\r\n const type = isComplexCollection\r\n ? imports.addServiceObject(this.version, ServiceImports.CollectionService)[0]\r\n : prop.isCollection\r\n ? model.serviceCollectionName\r\n : model.serviceName;\r\n const typeWithGenerics = isComplexCollection\r\n ? `${type}<ClientType, ${imports.addGeneratedModel(model.fqName, model.modelName)}, ${imports.addGeneratedQObject(\r\n model.fqName,\r\n model.qName\r\n )}, ${imports.addGeneratedModel(model.fqName, model.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 ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${privateSrvProp} = new ${type}(client, path, \"${prop.odataName}\"${isComplexCollection ? `, ${imports.addGeneratedQObject(model.fqName, firstCharLowerCase(model.qName))}`: \"\"})`,\r\n \"}\",\r\n `return ${privateSrvProp}`,\r\n ],\r\n };\r\n }\r\n\r\n private generatePrimitiveCollectionGetter(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const [collectionServiceType] = imports.addServiceObject(this.version, ServiceImports.CollectionService);\r\n const instanceName = firstCharLowerCase(prop.qObject!);\r\n const [qInstanceName] = imports.addFromQObject(instanceName);\r\n\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 ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${propName} = new ${collectionServiceType}(client, path, \"${prop.odataName}\", ${qInstanceName}${this.isV4BigNumber() ? \", true\": \"\"})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generatePrimitiveTypeGetter(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const [serviceType] = imports.addServiceObject(this.version, ServiceImports.PrimitiveTypeService);\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n // for V2: mapped name must be specified\r\n const useMappedName = this.version === ODataVersions.V2 && prop.name !== prop.odataName;\r\n // for V4: big number support\r\n const useBigNumber = this.isV4BigNumber();\r\n const addParamString = useMappedName ? `, \"${prop.name}\"` : useBigNumber ? \", true\" : \"\";\r\n\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 ` const { client, path, qModel } = this.__base;`,\r\n ` ${propName} = new ${serviceType}(client, path, \"${prop.odataName}\", qModel.${prop.name}.converter${addParamString})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generateEntityCollectionService(file: FileHandler, model: EntityType) {\r\n const importContainer = file.getImports();\r\n const editableModelName = model.editableName;\r\n const qObjectName = firstCharLowerCase(model.qName);\r\n\r\n const [entitySetServiceType] = importContainer.addServiceObject(this.version, ServiceImports.EntitySetService);\r\n const paramsModelName = importContainer.addGeneratedModel(model.id.fqName, model.id.modelName);\r\n const qIdFunctionName = importContainer.addGeneratedQObject(model.id.fqName, model.id.qName);\r\n\r\n const collectionOperations = this.dataModel.getEntitySetOperations(model.fqName);\r\n\r\n const { properties, methods } = this.generateServiceOperations(importContainer, model, collectionOperations);\r\n\r\n file.getFile().addClass({\r\n isExported: true,\r\n name: model.serviceCollectionName,\r\n typeParameters: [\"ClientType extends ODataHttpClient\"],\r\n extends:\r\n entitySetServiceType +\r\n `<ClientType, ${model.modelName}, ${editableModelName}, ${model.qName}, ${paramsModelName}>`,\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}, new ${qIdFunctionName}(name)${\r\n this.isV4BigNumber() ? \", true\" : \"\"\r\n });`,\r\n ],\r\n },\r\n ],\r\n properties,\r\n methods,\r\n });\r\n }\r\n\r\n private generateEntityTypeServices(): Array<Promise<void>> {\r\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\r\n return this.dataModel.getEntityTypes().map((model) => {\r\n const file = this.project.createOrGetServiceFile(model.folderPath, model.serviceName, [\r\n model.serviceName,\r\n model.serviceCollectionName,\r\n ]);\r\n\r\n // entity type service\r\n this.generateEntityTypeService(file, model);\r\n // entity collection service if this entity specified keys at all\r\n if (model.keyNames.length) {\r\n this.generateEntityCollectionService(file, model);\r\n }\r\n\r\n return this.project.finalizeFile(file);\r\n });\r\n }\r\n\r\n private generateComplexTypeServices(): Array<Promise<void>> {\r\n // build service file for complex types\r\n return this.dataModel.getComplexTypes().map((model) => {\r\n const file = this.project.createOrGetServiceFile(model.folderPath, model.serviceName, [model.serviceName]);\r\n\r\n // entity type service\r\n this.generateEntityTypeService(file, model);\r\n\r\n return this.project.finalizeFile(file);\r\n });\r\n }\r\n\r\n private generateMethod(\r\n name: string,\r\n operation: OperationType,\r\n importContainer: ImportContainer,\r\n baseFqName: string\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const isFunc = operation.type === OperationTypes.Function;\r\n const returnType = operation.returnType;\r\n const hasParams = operation.parameters.length > 0;\r\n\r\n // importing dependencies\r\n const [httpClientConfigModel, odataResponse] = importContainer.addClientApi(\r\n ClientApiImports.ODataHttpClientConfig,\r\n ClientApiImports.HttpResponseModel\r\n );\r\n const responseStructure = this.importReturnType(importContainer, returnType);\r\n const qOperationName = importContainer.addGeneratedQObject(baseFqName, operation.qName);\r\n const rtType =\r\n returnType?.type && returnType.dataType !== DataTypes.PrimitiveType\r\n ? importContainer.addGeneratedModel(returnType.fqType, returnType.type)\r\n : returnType?.type;\r\n const paramsModelName = hasParams\r\n ? importContainer.addGeneratedModel(baseFqName, operation.paramsModelName)\r\n : undefined;\r\n\r\n const requestConfigParam = {\r\n name: \"requestConfig\",\r\n hasQuestionToken: true,\r\n type: `${httpClientConfigModel}<ClientType>`,\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 ? [{ name: \"params\", type: paramsModelName }, requestConfigParam] : [requestConfigParam],\r\n returnType: `Promise<${odataResponse}<${responseStructure}<${rtType || \"void\"}>>>`,\r\n statements: [\r\n `if(!${qOpProp}) {`,\r\n ` ${qOpProp} = new ${qOperationName}()`,\r\n \"}\",\r\n\r\n `const { addFullPath, client, getDefaultHeaders } = this.__base;`,\r\n `const url = addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params\" : \"\"}));`,\r\n `${returnType ? \"const response = await \" : \"return\"} client.${\r\n !isFunc\r\n ? // actions: since V4\r\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${\r\n requestConfigParam.name\r\n }, getDefaultHeaders())`\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}, getDefaultHeaders())`\r\n : // functions: since V2\r\n `get(url, ${requestConfigParam.name}, getDefaultHeaders())`\r\n };`,\r\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\r\n ],\r\n };\r\n }\r\n\r\n private importReturnType(imports: ImportContainer, returnType: ReturnTypeModel | undefined): string {\r\n const typeToImport: CoreImports = returnType?.isCollection\r\n ? CoreImports.ODataCollectionResponse\r\n : returnType?.dataType === DataTypes.PrimitiveType\r\n ? CoreImports.ODataValueResponse\r\n : CoreImports.ODataModelResponse;\r\n\r\n return imports.addCoreLib(this.version, typeToImport)[0];\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,kEAAkC;AAClC,uCAMkB;AAClB,uDAAkD;AAClD,sDAA2D;AAoB3D,0DAA2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BACpB,aAAa,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,4BAA4B,CAAC,CAAC,CAAC,IAAI,KACpE,kBAAkB,CAAC,IACrB,wBAAwB;oBAC1B,CAAC,CAAC,SAAS,CAAC,OAAO;wBACnB,CAAC,CAAC,sFAAsF;4BACtF,wBAAwB,kBAAkB,CAAC,IAAI,wBAAwB;wBACzE,CAAC,CAAC,sBAAsB;4BACtB,YAAY,kBAAkB,CAAC,IAAI,wBACzC,GAAG;gBACH,UAAU,CAAC,CAAC,CAAC,UAAU,OAAO,6BAA6B,CAAC,CAAC,CAAC,EAAE;aACjE;SACF,CAAC;IACJ,CAAC;IAEO,gBAAgB,CAAC,OAAwB,EAAE,UAAuC;QACxF,MAAM,YAAY,GAAgB,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,YAAY;YACxD,CAAC,CAAC,2BAAW,CAAC,uBAAuB;YACrC,CAAC,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,mDAA4B;gBAClD,CAAC,CAAC,2BAAW,CAAC,kBAAkB;gBAChC,CAAC,CAAC,2BAAW,CAAC,kBAAkB,CAAC;QAEnC,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,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} 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 EntityType,\r\n FunctionImportType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n ReturnTypeModel,\r\n SingletonType,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { ConfigFileOptions } from \"../OptionModel\";\r\nimport { FileHandler } from \"../project/FileHandler\";\r\nimport { ProjectManager } from \"../project/ProjectManager\";\r\nimport { ClientApiImports, CoreImports, QueryObjectImports, ServiceImports } from \"./import/ImportObjects\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nexport interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, \"properties\" | \"methods\">> {}\r\n\r\nexport interface ServiceGeneratorOptions\r\n extends Pick<ConfigFileOptions, \"enablePrimitivePropertyServices\" | \"v4BigNumberAsString\"> {}\r\n\r\nexport async function generateServices(\r\n project: ProjectManager,\r\n dataModel: DataModel,\r\n version: ODataVersions,\r\n namingHelper: NamingHelper,\r\n options?: ServiceGeneratorOptions\r\n) {\r\n const generator = new ServiceGenerator(project, dataModel, version, namingHelper, options);\r\n return generator.generate();\r\n}\r\n\r\nclass ServiceGenerator {\r\n constructor(\r\n private project: ProjectManager,\r\n private dataModel: DataModel,\r\n private version: ODataVersions,\r\n private namingHelper: NamingHelper,\r\n private options: ServiceGeneratorOptions = {}\r\n ) {}\r\n\r\n private isV4BigNumber() {\r\n return this.options.v4BigNumberAsString && this.version === ODataVersions.V4;\r\n }\r\n\r\n public async generate(): Promise<void> {\r\n const mainServiceName = this.namingHelper.getMainServiceName();\r\n this.project.initServices();\r\n\r\n await Promise.all([\r\n this.generateMainService(mainServiceName),\r\n ...this.generateEntityTypeServices(),\r\n ...this.generateComplexTypeServices(),\r\n ]);\r\n\r\n return this.project.finalizeServices();\r\n }\r\n\r\n private async generateMainService(mainServiceName: string) {\r\n const mainServiceFile = this.project.getMainServiceFile();\r\n const importContainer = mainServiceFile.getImports();\r\n const container = this.dataModel.getEntityContainer();\r\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\r\n\r\n const [httpClient] = importContainer.addClientApi(ClientApiImports.ODataHttpClient);\r\n const [rootService] = importContainer.addServiceObject(this.version, ServiceImports.ODataService);\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 mainServiceFile.getFile().addClass({\r\n isExported: true,\r\n name: mainServiceName,\r\n typeParameters: [`in out ClientType extends ${httpClient}`],\r\n extends: `${rootService}<ClientType>`,\r\n ctors: this.isV4BigNumber()\r\n ? [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n ],\r\n statements: [`super(client, basePath, true);`],\r\n },\r\n ]\r\n : [],\r\n properties,\r\n methods,\r\n });\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, odataName, entityType }) => {\r\n result.methods.push(this.generateRelatedServiceGetter(name, odataName, entityType, importContainer));\r\n });\r\n\r\n Object.values(container.singletons).forEach((singleton) => {\r\n result.properties.push(this.generateSingletonProp(importContainer, singleton));\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 const op = this.dataModel.getUnboundOperationType(operation);\r\n if (!op) {\r\n throw new Error(`Operation \"${operation}\" not found!`);\r\n }\r\n\r\n result.properties.push(this.generateQOperationProp(op));\r\n result.methods.push(this.generateMethod(name, op, importContainer, \"\"));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateRelatedServiceGetter(\r\n propName: string,\r\n odataPropName: string,\r\n entityType: EntityType,\r\n imports: ImportContainer\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const idName = imports.addGeneratedModel(entityType.id.fqName, entityType.id.modelName);\r\n const idFunctionName = imports.addGeneratedQObject(entityType.id.fqName, entityType.id.qName);\r\n const serviceName = imports.addGeneratedService(entityType.fqName, entityType.serviceName);\r\n const collectionName = imports.addGeneratedService(entityType.fqName, entityType.serviceCollectionName);\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 = \"${odataPropName}\";`,\r\n `const { client, path } = this.__base;`,\r\n 'return typeof id === \"undefined\" || id === null',\r\n `? new ${collectionName}(client, path, fieldName)`,\r\n `: new ${serviceName}(client, path, new ${idFunctionName}(fieldName).buildUrl(id));`,\r\n ],\r\n };\r\n }\r\n\r\n private generateSingletonProp(\r\n importContainer: ImportContainer,\r\n singleton: SingletonType\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const { name, entityType } = singleton;\r\n const type = entityType.serviceName;\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 = entityType.serviceName;\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 ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${propName} = new ${serviceType}(client, path, \"${odataName}\")`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generateEntityTypeService(file: FileHandler, model: ComplexType) {\r\n const importContainer = file.getImports();\r\n\r\n const operations = this.dataModel.getEntityTypeOperations(model.fqName);\r\n const props = [...model.baseProps, ...model.props];\r\n\r\n const [entityServiceType] = importContainer.addServiceObject(this.version, ServiceImports.EntityTypeService);\r\n const [httpClient] = importContainer.addClientApi(ClientApiImports.ODataHttpClient);\r\n\r\n // note: predictable first imports => no need to take renaming into account\r\n const modelName = importContainer.addGeneratedModel(model.fqName, model.modelName);\r\n const editableModelName = importContainer.addGeneratedModel(model.fqName, model.editableName);\r\n const qName = importContainer.addGeneratedQObject(model.fqName, model.qName);\r\n const qObjectName = importContainer.addGeneratedQObject(model.fqName, firstCharLowerCase(model.qName));\r\n\r\n const { properties, methods }: PropsAndOps = deepmerge(\r\n this.generateServiceProperties(importContainer, model.serviceName, props),\r\n this.generateServiceOperations(importContainer, model, operations)\r\n );\r\n\r\n // generate EntityTypeService\r\n file.getFile().addClass({\r\n isExported: true,\r\n name: model.serviceName,\r\n typeParameters: [`in out ClientType extends ${httpClient}`],\r\n extends: entityServiceType + `<ClientType, ${modelName}, ${editableModelName}, ${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}${this.isV4BigNumber() ? \", true\" : \"\"});`],\r\n },\r\n ],\r\n properties,\r\n methods,\r\n });\r\n }\r\n\r\n private generateServiceProperties(\r\n importContainer: ImportContainer,\r\n serviceName: string,\r\n props: Array<PropertyModel>\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n props.forEach((prop) => {\r\n // complex types, collection of complex types or entityTypes\r\n if ((prop.dataType === DataTypes.ModelType && !prop.isCollection) || prop.dataType === DataTypes.ComplexType) {\r\n result.properties.push(this.generateModelProp(importContainer, prop));\r\n result.methods.push(this.generateModelPropGetter(importContainer, prop));\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.getEntityType(prop.fqType);\r\n if (!entityType) {\r\n throw new Error(`Entity type \"${prop.fqType}\" specified by property not found!`);\r\n }\r\n\r\n result.methods.push(\r\n this.generateRelatedServiceGetter(prop.name, prop.odataName, entityType, importContainer)\r\n );\r\n }\r\n // collection of primitive or enum types\r\n else {\r\n result.properties.push(this.generatePrimitiveCollectionProp(importContainer, prop));\r\n result.methods.push(this.generatePrimitiveCollectionGetter(importContainer, prop));\r\n }\r\n }\r\n // generation of services for each primitive property: turned off by default\r\n else if (this.options.enablePrimitivePropertyServices && prop.dataType === DataTypes.PrimitiveType) {\r\n result.properties.push(this.generatePrimitiveTypeProp(importContainer, prop));\r\n result.methods.push(this.generatePrimitiveTypeGetter(importContainer, prop));\r\n }\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateServiceOperations(\r\n importContainer: ImportContainer,\r\n model: ComplexType,\r\n operations: Array<OperationType>\r\n ): 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, model.fqName));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateModelProp(imports: ImportContainer, prop: PropertyModel): PropertyDeclarationStructure {\r\n const propModel = this.dataModel.getModel(prop.fqType) as ComplexType;\r\n let propModelType: string;\r\n\r\n if (prop.isCollection) {\r\n const modelName = imports.addGeneratedModel(propModel.fqName, propModel.modelName);\r\n const editableModelName = imports.addGeneratedModel(propModel.fqName, propModel.editableName);\r\n const qModelName = imports.addGeneratedQObject(propModel.fqName, propModel.qName);\r\n const [collectionServiceType] = imports.addServiceObject(this.version, ServiceImports.CollectionService);\r\n\r\n propModelType = `${collectionServiceType}<ClientType, ${modelName}, ${qModelName}, ${editableModelName}>`;\r\n } else {\r\n const serviceName = imports.addGeneratedService(propModel.fqName, propModel.serviceName);\r\n propModelType = `${serviceName}<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 imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<PropertyDeclarationStructure> {\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 const [collectionServiceType] = imports.addServiceObject(this.version, ServiceImports.CollectionService);\r\n const isEnum = prop.dataType === DataTypes.EnumType;\r\n let qType: string;\r\n let type: string;\r\n\r\n if (!isEnum) {\r\n // TODO move string concat (StringCollection, GuidCollection...) to better place\r\n [type, qType] = imports.addFromQObject(`${upperCaseFirst(prop.type)}Collection`, prop.qObject);\r\n } else {\r\n const propEnum = this.dataModel.getModel(prop.fqType)!;\r\n const propTypeModel = imports.addGeneratedModel(propEnum.fqName, propEnum.modelName);\r\n [type, qType] = imports.addQObject(QueryObjectImports.EnumCollection, QueryObjectImports.QEnumCollection);\r\n type = `${type}<${propTypeModel}>`;\r\n }\r\n\r\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\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 generatePrimitiveTypeProp(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const [serviceType] = imports.addServiceObject(this.version, ServiceImports.PrimitiveTypeService);\r\n const type = prop.typeModule ? imports.addCustomType(prop.typeModule, prop.type) : prop.type;\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: `${serviceType}<ClientType, ${type}>`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generateModelPropGetter(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const model = this.dataModel.getModel(prop.fqType) as ComplexType;\r\n const isComplexCollection = prop.isCollection && model.dataType === DataTypes.ComplexType;\r\n\r\n const type = isComplexCollection\r\n ? imports.addServiceObject(this.version, ServiceImports.CollectionService)[0]\r\n : prop.isCollection\r\n ? model.serviceCollectionName\r\n : model.serviceName;\r\n const typeWithGenerics = isComplexCollection\r\n ? `${type}<ClientType, ${imports.addGeneratedModel(model.fqName, model.modelName)}, ${imports.addGeneratedQObject(\r\n model.fqName,\r\n model.qName\r\n )}, ${imports.addGeneratedModel(model.fqName, model.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 ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${privateSrvProp} = new ${type}(client, path, \"${prop.odataName}\"${isComplexCollection ? `, ${imports.addGeneratedQObject(model.fqName, firstCharLowerCase(model.qName))}`: \"\"})`,\r\n \"}\",\r\n `return ${privateSrvProp}`,\r\n ],\r\n };\r\n }\r\n\r\n private generatePrimitiveCollectionGetter(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const [collectionServiceType] = imports.addServiceObject(this.version, ServiceImports.CollectionService);\r\n const instanceName = firstCharLowerCase(prop.qObject!);\r\n const [qInstanceName] = imports.addFromQObject(instanceName);\r\n\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 ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${propName} = new ${collectionServiceType}(client, path, \"${prop.odataName}\", ${qInstanceName}${this.isV4BigNumber() ? \", true\": \"\"})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generatePrimitiveTypeGetter(\r\n imports: ImportContainer,\r\n prop: PropertyModel\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const [serviceType] = imports.addServiceObject(this.version, ServiceImports.PrimitiveTypeService);\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n // for V2: mapped name must be specified\r\n const useMappedName = this.version === ODataVersions.V2 && prop.name !== prop.odataName;\r\n // for V4: big number support\r\n const useBigNumber = this.isV4BigNumber();\r\n const addParamString = useMappedName ? `, \"${prop.name}\"` : useBigNumber ? \", true\" : \"\";\r\n\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 ` const { client, path, qModel } = this.__base;`,\r\n ` ${propName} = new ${serviceType}(client, path, \"${prop.odataName}\", qModel.${prop.name}.converter${addParamString})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generateEntityCollectionService(file: FileHandler, model: EntityType) {\r\n const importContainer = file.getImports();\r\n const editableModelName = model.editableName;\r\n const qObjectName = firstCharLowerCase(model.qName);\r\n\r\n const [entitySetServiceType] = importContainer.addServiceObject(this.version, ServiceImports.EntitySetService);\r\n const paramsModelName = importContainer.addGeneratedModel(model.id.fqName, model.id.modelName);\r\n const qIdFunctionName = importContainer.addGeneratedQObject(model.id.fqName, model.id.qName);\r\n\r\n const collectionOperations = this.dataModel.getEntitySetOperations(model.fqName);\r\n\r\n const { properties, methods } = this.generateServiceOperations(importContainer, model, collectionOperations);\r\n\r\n file.getFile().addClass({\r\n isExported: true,\r\n name: model.serviceCollectionName,\r\n typeParameters: [\"in out ClientType extends ODataHttpClient\"],\r\n extends:\r\n entitySetServiceType +\r\n `<ClientType, ${model.modelName}, ${editableModelName}, ${model.qName}, ${paramsModelName}>`,\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}, new ${qIdFunctionName}(name)${\r\n this.isV4BigNumber() ? \", true\" : \"\"\r\n });`,\r\n ],\r\n },\r\n ],\r\n properties,\r\n methods,\r\n });\r\n }\r\n\r\n private generateEntityTypeServices(): Array<Promise<void>> {\r\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\r\n return this.dataModel.getEntityTypes().map((model) => {\r\n const file = this.project.createOrGetServiceFile(model.folderPath, model.serviceName, [\r\n model.serviceName,\r\n model.serviceCollectionName,\r\n ]);\r\n\r\n // entity type service\r\n this.generateEntityTypeService(file, model);\r\n // entity collection service if this entity specified keys at all\r\n if (model.keyNames.length) {\r\n this.generateEntityCollectionService(file, model);\r\n }\r\n\r\n return this.project.finalizeFile(file);\r\n });\r\n }\r\n\r\n private generateComplexTypeServices(): Array<Promise<void>> {\r\n // build service file for complex types\r\n return this.dataModel.getComplexTypes().map((model) => {\r\n const file = this.project.createOrGetServiceFile(model.folderPath, model.serviceName, [model.serviceName]);\r\n\r\n // entity type service\r\n this.generateEntityTypeService(file, model);\r\n\r\n return this.project.finalizeFile(file);\r\n });\r\n }\r\n\r\n private generateMethod(\r\n name: string,\r\n operation: OperationType,\r\n importContainer: ImportContainer,\r\n baseFqName: string\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const isFunc = operation.type === OperationTypes.Function;\r\n const returnType = operation.returnType;\r\n const hasParams = operation.parameters.length > 0;\r\n\r\n // importing dependencies\r\n const [httpClientConfigModel, odataResponse] = importContainer.addClientApi(\r\n ClientApiImports.ODataHttpClientConfig,\r\n ClientApiImports.HttpResponseModel\r\n );\r\n const responseStructure = this.importReturnType(importContainer, returnType);\r\n const qOperationName = importContainer.addGeneratedQObject(baseFqName, operation.qName);\r\n const rtType =\r\n returnType?.type && returnType.dataType !== DataTypes.PrimitiveType\r\n ? importContainer.addGeneratedModel(returnType.fqType, returnType.type)\r\n : returnType?.type;\r\n const paramsModelName = hasParams\r\n ? importContainer.addGeneratedModel(baseFqName, operation.paramsModelName)\r\n : undefined;\r\n\r\n const requestConfigParam = {\r\n name: \"requestConfig\",\r\n hasQuestionToken: true,\r\n type: `${httpClientConfigModel}<ClientType>`,\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 ? [{ name: \"params\", type: paramsModelName }, requestConfigParam] : [requestConfigParam],\r\n returnType: `Promise<${odataResponse}<${responseStructure}<${rtType || \"void\"}>>>`,\r\n statements: [\r\n `if(!${qOpProp}) {`,\r\n ` ${qOpProp} = new ${qOperationName}()`,\r\n \"}\",\r\n\r\n `const { addFullPath, client, getDefaultHeaders } = this.__base;`,\r\n `const url = addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params\" : \"\"}));`,\r\n `${returnType ? \"const response = await \" : \"return\"} client.${\r\n !isFunc\r\n ? // actions: since V4\r\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${\r\n requestConfigParam.name\r\n }, getDefaultHeaders())`\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}, getDefaultHeaders())`\r\n : // functions: since V2\r\n `get(url, ${requestConfigParam.name}, getDefaultHeaders())`\r\n };`,\r\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\r\n ],\r\n };\r\n }\r\n\r\n private importReturnType(imports: ImportContainer, returnType: ReturnTypeModel | undefined): string {\r\n const typeToImport: CoreImports = returnType?.isCollection\r\n ? CoreImports.ODataCollectionResponse\r\n : returnType?.dataType === DataTypes.PrimitiveType\r\n ? CoreImports.ODataValueResponse\r\n : CoreImports.ODataModelResponse;\r\n\r\n return imports.addCoreLib(this.version, typeToImport)[0];\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportObjects.js","sourceRoot":"","sources":["../../../src/generator/import/ImportObjects.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,+BAA+B;IACxC,SAAS,EAAE,2BAA2B;IACtC,OAAO,EAAE,yBAAyB;CACnC,CAAC;AAEF;;;GAGG;AACH,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,mEAAe,CAAA;IACf,mFAAuB,CAAA;IACvB,yEAAkB,CAAA;IAClB,yEAAkB,CAAA;AACpB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAED;;;;GAIG;AACU,QAAA,sBAAsB,GAAG;IACpC,WAAW,CAAC,uBAAuB;IACnC,WAAW,CAAC,kBAAkB;IAC9B,WAAW,CAAC,kBAAkB;CAC/B,CAAC;AAEF;;GAEG;AACH,IAAY,kBAaX;AAbD,WAAY,kBAAkB;IAC5B,yEAAW,CAAA;IACX,yDAAG,CAAA;IACH,qEAAS,CAAA;IACT,iEAAO,CAAA;IACP,+EAAc,CAAA;IACd,iFAAe,CAAA;IACf,iFAAe,CAAA;IACf,iFAAe,CAAA;IACf,6FAAqB,CAAA;IACrB,yFAAmB,CAAA;IACnB,0EAAW,CAAA;IACX,8EAAa,CAAA;AACf,CAAC,EAbW,kBAAkB,kCAAlB,kBAAkB,QAa7B;AAED;;GAEG;AACH,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,6EAAe,CAAA;IACf,yFAAqB,CAAA;IACrB,iFAAiB,CAAA;AACnB,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B;AAED;;;GAGG;AACH,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,mEAAY,CAAA;IACZ,6EAAiB,CAAA;IACjB,mFAAoB,CAAA;IACpB,6EAAiB,CAAA;IACjB,2EAAgB,CAAA;AAClB,CAAC,EANW,cAAc,8BAAd,cAAc,QAMzB;AAED;;;GAGG;AACU,QAAA,yBAAyB,GAAG;IACvC,cAAc,CAAC,iBAAiB;IAChC,cAAc,CAAC,oBAAoB;IACnC,cAAc,CAAC,iBAAiB;IAChC,cAAc,CAAC,gBAAgB;CAChC,CAAC","sourcesContent":["/**\n * All module names of the main dependencies.\n */\nexport const LIB_MODULES = {\n core: \"@odata2ts/odata-core\",\n qObject: \"@odata2ts/odata-query-objects\",\n clientApi: \"@odata2ts/http-client-api\",\n service: \"@odata2ts/odata-service\",\n};\n\n/**\n * All imported entity names from the core API.\n * Includes versioned file names, i.e. according to OData version.\n */\nexport enum CoreImports {\n DeferredContent,\n ODataCollectionResponse, // versioned\n ODataModelResponse, // versioned\n ODataValueResponse, // versioned\n}\n\n/**\n * For all core imports that are versioned two files exist, one for V2, one for V4.\n * ODataCollectionResponse = ODataCollectionResponseV2 + ODataCollectionResponseV4\n *\n */\nexport const VERSIONED_CORE_IMPORTS = [\n CoreImports.ODataCollectionResponse,\n CoreImports.ODataValueResponse,\n CoreImports.ODataModelResponse,\n];\n\n/**\n * Most relevant, but not all imports from query objects library\n */\nexport enum QueryObjectImports {\n QueryObject,\n QId,\n QFunction,\n QAction,\n EnumCollection,\n QEnumCollection,\n qEnumCollection,\n QCollectionPath,\n QEntityCollectionPath,\n OperationReturnType,\n ReturnTypes,\n QComplexParam,\n}\n\n/**\n * All imports from HTTP client API.\n */\nexport enum ClientApiImports {\n ODataHttpClient,\n ODataHttpClientConfig,\n HttpResponseModel,\n}\n\n/**\n * All imports from service library.\n * Includes versioned file names, i.e. according to OData version.\n */\nexport enum ServiceImports {\n ODataService,\n EntityTypeService,\n PrimitiveTypeService,\n CollectionService,\n EntitySetService,\n}\n\n/**\n * For all versioned imports two files exist, one for V2, one for V4.\n * EntityTypeService = EntityTypeServiceV2 + EntityTypeServiceV4\n */\nexport const VERSIONED_SERVICE_IMPORTS = [\n ServiceImports.EntityTypeService,\n ServiceImports.PrimitiveTypeService,\n ServiceImports.CollectionService,\n ServiceImports.EntitySetService,\n];\n"]}
|
|
1
|
+
{"version":3,"file":"ImportObjects.js","sourceRoot":"","sources":["../../../src/generator/import/ImportObjects.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,+BAA+B;IACxC,SAAS,EAAE,2BAA2B;IACtC,OAAO,EAAE,yBAAyB;CACnC,CAAC;AAEF;;;GAGG;AACH,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,mEAAe,CAAA;IACf,mFAAuB,CAAA;IACvB,yEAAkB,CAAA;IAClB,yEAAkB,CAAA;AACpB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAED;;;;GAIG;AACU,QAAA,sBAAsB,GAAG;IACpC,WAAW,CAAC,uBAAuB;IACnC,WAAW,CAAC,kBAAkB;IAC9B,WAAW,CAAC,kBAAkB;CAC/B,CAAC;AAEF;;GAEG;AACH,IAAY,kBAaX;AAbD,WAAY,kBAAkB;IAC5B,yEAAW,CAAA;IACX,yDAAG,CAAA;IACH,qEAAS,CAAA;IACT,iEAAO,CAAA;IACP,+EAAc,CAAA;IACd,iFAAe,CAAA;IACf,iFAAe,CAAA;IACf,iFAAe,CAAA;IACf,6FAAqB,CAAA;IACrB,yFAAmB,CAAA;IACnB,0EAAW,CAAA;IACX,8EAAa,CAAA;AACf,CAAC,EAbW,kBAAkB,kCAAlB,kBAAkB,QAa7B;AAED;;GAEG;AACH,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,6EAAe,CAAA;IACf,yFAAqB,CAAA;IACrB,iFAAiB,CAAA;AACnB,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B;AAED;;;GAGG;AACH,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,mEAAY,CAAA;IACZ,6EAAiB,CAAA;IACjB,mFAAoB,CAAA;IACpB,6EAAiB,CAAA;IACjB,2EAAgB,CAAA;AAClB,CAAC,EANW,cAAc,8BAAd,cAAc,QAMzB;AAED;;;GAGG;AACU,QAAA,yBAAyB,GAAG;IACvC,cAAc,CAAC,iBAAiB;IAChC,cAAc,CAAC,oBAAoB;IACnC,cAAc,CAAC,iBAAiB;IAChC,cAAc,CAAC,gBAAgB;CAChC,CAAC","sourcesContent":["/**\r\n * All module names of the main dependencies.\r\n */\r\nexport const LIB_MODULES = {\r\n core: \"@odata2ts/odata-core\",\r\n qObject: \"@odata2ts/odata-query-objects\",\r\n clientApi: \"@odata2ts/http-client-api\",\r\n service: \"@odata2ts/odata-service\",\r\n};\r\n\r\n/**\r\n * All imported entity names from the core API.\r\n * Includes versioned file names, i.e. according to OData version.\r\n */\r\nexport enum CoreImports {\r\n DeferredContent,\r\n ODataCollectionResponse, // versioned\r\n ODataModelResponse, // versioned\r\n ODataValueResponse, // versioned\r\n}\r\n\r\n/**\r\n * For all core imports that are versioned two files exist, one for V2, one for V4.\r\n * ODataCollectionResponse = ODataCollectionResponseV2 + ODataCollectionResponseV4\r\n *\r\n */\r\nexport const VERSIONED_CORE_IMPORTS = [\r\n CoreImports.ODataCollectionResponse,\r\n CoreImports.ODataValueResponse,\r\n CoreImports.ODataModelResponse,\r\n];\r\n\r\n/**\r\n * Most relevant, but not all imports from query objects library\r\n */\r\nexport enum QueryObjectImports {\r\n QueryObject,\r\n QId,\r\n QFunction,\r\n QAction,\r\n EnumCollection,\r\n QEnumCollection,\r\n qEnumCollection,\r\n QCollectionPath,\r\n QEntityCollectionPath,\r\n OperationReturnType,\r\n ReturnTypes,\r\n QComplexParam,\r\n}\r\n\r\n/**\r\n * All imports from HTTP client API.\r\n */\r\nexport enum ClientApiImports {\r\n ODataHttpClient,\r\n ODataHttpClientConfig,\r\n HttpResponseModel,\r\n}\r\n\r\n/**\r\n * All imports from service library.\r\n * Includes versioned file names, i.e. according to OData version.\r\n */\r\nexport enum ServiceImports {\r\n ODataService,\r\n EntityTypeService,\r\n PrimitiveTypeService,\r\n CollectionService,\r\n EntitySetService,\r\n}\r\n\r\n/**\r\n * For all versioned imports two files exist, one for V2, one for V4.\r\n * EntityTypeService = EntityTypeServiceV2 + EntityTypeServiceV4\r\n */\r\nexport const VERSIONED_SERVICE_IMPORTS = [\r\n ServiceImports.EntityTypeService,\r\n ServiceImports.PrimitiveTypeService,\r\n ServiceImports.CollectionService,\r\n ServiceImports.EntitySetService,\r\n];\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TsMorphHelper.js","sourceRoot":"","sources":["../../src/project/TsMorphHelper.ts"],"names":[],"mappings":";;;;AAAA,6CAA+C;AAE/C,8EAAmC;AACnC,oEAA4B;AAE5B,gDAA2C;AAE3C;;;;;;;GAOG;AACH,SAAsB,0BAA0B,CAAC,YAAoB,EAAE,QAAmB,EAAE,SAAiB;;QAC3G,MAAM,oBAAoB,GAAG,uBAAS,CAAC,MAAM,KAAK,QAAQ,IAAI,uBAAS,CAAC,GAAG,KAAK,QAAQ,CAAC;QAEzF,mBAAmB;QACnB,qBAAqB;QACrB,MAAM,IAAI,GAAG,IAAA,yBAAI,EAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC;QAE9C,MAAM,KAeF,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAC,eAAe,KAAI,EAAE,EAflC;QACJ,gBAAg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AU,CAAC,CAAC,CAAE,oBAAE,CAAC,oBAAoB,CAAC,UAAU,CAA0B,CAAC,CAAC,CAAC,SAAS,CAAC;AAChG,CAAC;AAED,SAAS,aAAa,CAAC,MAAgD;IACrE,MAAM,GAAG,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1E,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAE,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAiC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC;IACpH,OAAO,UAAU,CAAC,CAAC,CAAE,oBAAE,CAAC,UAAU,CAAC,UAAU,CAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E,CAAC;AAED,SAAS,SAAS,CAAC,MAAgD;IACjE,MAAM,CAAC,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAE,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAmC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IACtH,OAAO,UAAU,CAAC,CAAC,CAAE,oBAAE,CAAC,YAAY,CAAC,UAAU,CAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC","sourcesContent":["import { NewLineKind } from \"@ts-morph/common\";\nimport { CompilerOptions, ModuleKind, ModuleResolutionKind, ScriptTarget } from \"ts-morph\";\nimport load from \"tsconfig-loader\";\nimport ts from \"typescript\";\n\nimport { EmitModes } from \"../OptionModel\";\n\n/**\n * Loads the TS configuration from the specified path.\n * Then maps the appropriate options to ts-morph compiler options.\n *\n * @param tsConfigPath path to tsconfig.json\n * @param emitMode the used emit mode\n * @param outputDir the used output dir\n */\nexport async function loadTsMorphCompilerOptions(tsConfigPath: string, emitMode: EmitModes, outputDir: string) {\n const generateDeclarations = EmitModes.js_dts === emitMode || EmitModes.dts === emitMode;\n\n // load config file\n // NOTE: not async...\n const conf = load({ filename: tsConfigPath });\n\n const {\n // ignored props\n noEmit, // we always want to emit\n importsNotUsedAsValues, // type is missing\n jsx,\n plugins,\n // mapped props\n moduleResolution,\n lib,\n module,\n newLine,\n target,\n rootDir,\n rootDirs,\n ...passThrough\n } = conf?.tsConfig.compilerOptions || {};\n\n const compilerOpts: CompilerOptions = {\n ...passThrough,\n outDir: outputDir,\n declaration: generateDeclarations,\n moduleResolution: getModuleResolutionKind(moduleResolution),\n module: getModuleKind(module),\n target: getTarget(target),\n };\n if (lib) {\n compilerOpts.lib = lib as string[];\n }\n if (newLine) {\n compilerOpts.newLine = newLine?.toLowerCase() === \"lf\" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed;\n }\n\n return compilerOpts;\n}\n\n/**\n * Maps to lower case.\n * Also translates \"node\" to \"nodejs\".\n *\n * @param moduleResolution\n */\nfunction getModuleResolutionKind(\n moduleResolution: string | undefined | Record<string, any>\n): ModuleResolutionKind | undefined {\n const modRes =\n typeof moduleResolution === \"string\"\n ? moduleResolution.toLowerCase() === \"node\"\n ? \"nodejs\"\n : moduleResolution.toLowerCase()\n : undefined;\n const matchedKey = Object.keys(ts.ModuleResolutionKind).find(\n (mk): mk is keyof typeof ModuleResolutionKind => mk.toLowerCase() === modRes\n );\n return matchedKey ? (ts.ModuleResolutionKind[matchedKey] as ModuleResolutionKind) : undefined;\n}\n\nfunction getModuleKind(module: string | undefined | Record<string, any>): ModuleKind | undefined {\n const mod = typeof module === \"string\" ? module.toLowerCase() : undefined;\n const matchedKey = Object.keys(ts.ModuleKind).find((mk): mk is keyof typeof ModuleKind => mk.toLowerCase() === mod);\n return matchedKey ? (ts.ModuleKind[matchedKey] as ModuleKind) : undefined;\n}\n\nfunction getTarget(target: string | undefined | Record<string, any>): ScriptTarget | undefined {\n const t = typeof target === \"string\" ? target.toLowerCase() : undefined;\n const matchedKey = Object.keys(ts.ScriptTarget).find((st): st is keyof typeof ScriptTarget => st.toLowerCase() === t);\n return matchedKey ? (ts.ScriptTarget[matchedKey] as ScriptTarget) : undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TsMorphHelper.js","sourceRoot":"","sources":["../../src/project/TsMorphHelper.ts"],"names":[],"mappings":";;;;AAAA,6CAA+C;AAE/C,8EAAmC;AACnC,oEAA4B;AAE5B,gDAA2C;AAE3C;;;;;;;GAOG;AACH,SAAsB,0BAA0B,CAAC,YAAoB,EAAE,QAAmB,EAAE,SAAiB;;QAC3G,MAAM,oBAAoB,GAAG,uBAAS,CAAC,MAAM,KAAK,QAAQ,IAAI,uBAAS,CAAC,GAAG,KAAK,QAAQ,CAAC;QAEzF,mBAAmB;QACnB,qBAAqB;QACrB,MAAM,IAAI,GAAG,IAAA,yBAAI,EAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC;QAE9C,MAAM,KAeF,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAC,eAAe,KAAI,EAAE,EAflC;QACJ,gBAAgB;QAChB,MAAM,EAAE,yBAAyB;QACjC,sBAAsB,EAAE,kBAAkB;QAC1C,GAAG,EACH,OAAO;QACP,eAAe;QACf,gBAAgB,EAChB,GAAG,EACH,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,QAAQ,OAE8B,EADnC,WAAW,sBAdV,uIAeL,CAAuC,CAAC;QAEzC,MAAM,YAAY,mCACb,WAAW,KACd,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,oBAAoB,EACjC,gBAAgB,EAAE,uBAAuB,CAAC,gBAAgB,CAAC,EAC3D,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,EAC7B,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,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AO,UAAU,CAAC,CAAC,CAAE,oBAAE,CAAC,UAAU,CAAC,UAAU,CAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E,CAAC;AAED,SAAS,SAAS,CAAC,MAAgD;IACjE,MAAM,CAAC,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAE,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAmC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IACtH,OAAO,UAAU,CAAC,CAAC,CAAE,oBAAE,CAAC,YAAY,CAAC,UAAU,CAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC","sourcesContent":["import { NewLineKind } from \"@ts-morph/common\";\r\nimport { CompilerOptions, ModuleKind, ModuleResolutionKind, ScriptTarget } from \"ts-morph\";\r\nimport load from \"tsconfig-loader\";\r\nimport ts from \"typescript\";\r\n\r\nimport { EmitModes } from \"../OptionModel\";\r\n\r\n/**\r\n * Loads the TS configuration from the specified path.\r\n * Then maps the appropriate options to ts-morph compiler options.\r\n *\r\n * @param tsConfigPath path to tsconfig.json\r\n * @param emitMode the used emit mode\r\n * @param outputDir the used output dir\r\n */\r\nexport async function loadTsMorphCompilerOptions(tsConfigPath: string, emitMode: EmitModes, outputDir: string) {\r\n const generateDeclarations = EmitModes.js_dts === emitMode || EmitModes.dts === emitMode;\r\n\r\n // load config file\r\n // NOTE: not async...\r\n const conf = load({ filename: tsConfigPath });\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 };\r\n if (lib) {\r\n compilerOpts.lib = lib as string[];\r\n }\r\n if (newLine) {\r\n compilerOpts.newLine = newLine?.toLowerCase() === \"lf\" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed;\r\n }\r\n\r\n return compilerOpts;\r\n}\r\n\r\n/**\r\n * Maps to lower case.\r\n * Also translates \"node\" to \"nodejs\".\r\n *\r\n * @param moduleResolution\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odata2ts/odata2ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
],
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@odata2ts/odata-query-objects": "^0.21.0",
|
|
51
|
-
"@odata2ts/odata-service": "^0.
|
|
51
|
+
"@odata2ts/odata-service": "^0.19.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@odata2ts/converter-api": "^0.1.2",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@odata2ts/converter-v2-to-v4": "^0.1.4",
|
|
78
78
|
"@odata2ts/odata-query-objects": "^0.21.0",
|
|
79
|
-
"@odata2ts/odata-service": "^0.
|
|
79
|
+
"@odata2ts/odata-service": "^0.19.0",
|
|
80
80
|
"@odata2ts/test-converters": "^0.3.1",
|
|
81
81
|
"@types/fs-extra": "^11.0.1",
|
|
82
82
|
"@types/jest": "^29.5.2",
|
|
@@ -90,6 +90,6 @@
|
|
|
90
90
|
"typescript": "^5.1.3"
|
|
91
91
|
},
|
|
92
92
|
"types": "./lib/index.d.ts",
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "9ae4af562769396e5b031b819042edb9d8cb4479",
|
|
94
94
|
"readme": "README.md"
|
|
95
95
|
}
|