@odata2ts/odata2ts 0.28.0 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,11 +3,38 @@
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.29.1](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.29.0...@odata2ts/odata2ts@0.29.1) (2023-09-13)
7
+
8
+ **Note:** Version bump only for package @odata2ts/odata2ts
9
+
10
+ # [0.29.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.28.0...@odata2ts/odata2ts@0.29.0) (2023-08-08)
11
+
12
+ ### Bug Fixes
13
+
14
+ * **odata2ts:** downgrade prettier plugin xml to 2.2.0 ([36525f9](https://github.com/odata2ts/odata2ts/commit/36525f90e03199a0a4cce197df4662e8288493a6))
15
+
16
+ ### Features
17
+
18
+ * service generation for primitive types ([#201](https://github.com/odata2ts/odata2ts/issues/201)) ([ea9e645](https://github.com/odata2ts/odata2ts/commit/ea9e6452f6b4033c489fbceaf6b75591b550a3f1))
19
+
20
+ ### BREAKING CHANGES
21
+
22
+ * removed the public method "getQObject"
23
+
24
+ * refactor(odata2ts): use __base properties of inherited services
25
+
26
+ * feat(service): introduce PrimitiveTypeService
27
+
28
+ * feat(odata2ts): allow to generate PrimitiveTypeServices via option enablePrimitivePropertyServices
29
+
30
+ * feat(example): integration tests for primitive type services
31
+
6
32
  # [0.28.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.27.0...@odata2ts/odata2ts@0.28.0) (2023-07-31)
7
33
 
8
34
  ### Features
9
35
 
10
36
  * **odat2ts:** v4 big number generation ([#195](https://github.com/odata2ts/odata2ts/issues/195)) ([3e5fdcd](https://github.com/odata2ts/odata2ts/commit/3e5fdcda42f893ed7d069489faa2ad10da8d7837))
37
+
11
38
  * **odata2ts:** ESM support for the generator ([#198](https://github.com/odata2ts/odata2ts/issues/198)) ([6956b9c](https://github.com/odata2ts/odata2ts/commit/6956b9c8321707f04b7109653de50de0b739df3e))
12
39
 
13
40
  # [0.27.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.26.1...@odata2ts/odata2ts@0.27.0) (2023-07-20)
package/README.md CHANGED
@@ -1,81 +1,81 @@
1
- [![npm (scoped)](https://img.shields.io/npm/v/@odata2ts/odata2ts?style=for-the-badge)](https://www.npmjs.com/package/@odata2ts/odata2ts)
2
-
3
- # odata2ts
4
-
5
- The basic idea of `odata2ts` is to leverage the readily available metadata of any OData service
6
- to generate different sorts of typed artefacts which you use in your TypeScript code.
7
- This package (`@odata2ts/odata2ts`) realizes the generation process.
8
-
9
- The generator is supposed to be used with a TypeScript based configuration file.
10
- Then it's able to handle the generation for multiple OData services.
11
-
12
- It comes with powerful configuration options. Some highlights:
13
-
14
- - generation of TypeScript files or compiled JS / DTS files
15
- - name or rename stuff
16
- - naming of pretty much any aspect of the generated artefacts
17
- - e.g. all types should be prefixed with an "I", Person => IPerson
18
- - consistent casing (as in "camelCase" or "PascalCase") even for property names of entity types
19
- - use type converters
20
-
21
- See the [generator documentation](https://odata2ts.github.io/docs/generator/setup-and-usage) for more information.
22
-
23
- ## Installation
24
-
25
- ```
26
- npm install --save-dev @odata2ts/odata2ts
27
- ```
28
-
29
- ### Implicit Dependencies
30
-
31
- Most of the generated artefacts depend on other libraries. `odata2ts` lists them as peer dependencies.
32
-
33
- Depending on your use case, you will need to add runtime dependencies matching the mentioned peer dependencies.
34
- See the [Getting Started Guide](https://odata2ts.github.io/docs/category/getting-started/) of the documentation
35
- for guidance.
36
-
37
- ## Documentation
38
-
39
- [Generator Documentation](https://odata2ts.github.io/docs/generator/setup-and-usage)
40
-
41
- Main documentation for the odata2ts eco system:
42
- [https://odata2ts.github.io](https://odata2ts.github.io/)
43
-
44
- ## Examples
45
-
46
- See [example packages](https://github.com/odata2ts/odata2ts/tree/main/examples) for examples of how to integrate `odata2ts`.
47
-
48
- ## Tests
49
-
50
- See folder [test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/test)
51
- for unit tests.
52
-
53
- See folder [int-test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/int-test) for integration
54
- tests of the CLI.
55
-
56
- Each example package serves as integration test of the generator.
57
-
58
- ## Support, Feedback, Contributing
59
-
60
- This project is open to feature requests, suggestions, bug reports, usage questions etc.
61
- via [GitHub issues](https://github.com/odata2ts/odata2ts/issues).
62
-
63
- Contributions and feedback are encouraged and always welcome.
64
-
65
- See the [contribution guidelines](https://github.com/odata2ts/odata2ts/blob/main/CONTRIBUTING.md) for further information.
66
-
67
- ## Spirit
68
-
69
- This project and this module have been created and are maintained in the following spirit:
70
-
71
- - adhere to the **OData specification** as much as possible
72
- - support any OData service implementation which conforms to the spec
73
- - allow to work around faulty implementations if possible
74
- - stability matters
75
- - exercise Test Driven Development
76
- - bomb the place with unit tests (code coverage > 95%)
77
- - ensure that assumptions & understanding are correct by creating integration tests
78
-
79
- ## License
80
-
81
- MIT - see [License](./LICENSE).
1
+ [![npm (scoped)](https://img.shields.io/npm/v/@odata2ts/odata2ts?style=for-the-badge)](https://www.npmjs.com/package/@odata2ts/odata2ts)
2
+
3
+ # odata2ts
4
+
5
+ The basic idea of `odata2ts` is to leverage the readily available metadata of any OData service
6
+ to generate different sorts of typed artefacts which you use in your TypeScript code.
7
+ This package (`@odata2ts/odata2ts`) realizes the generation process.
8
+
9
+ The generator is supposed to be used with a TypeScript based configuration file.
10
+ Then it's able to handle the generation for multiple OData services.
11
+
12
+ It comes with powerful configuration options. Some highlights:
13
+
14
+ - generation of TypeScript files or compiled JS / DTS files
15
+ - name or rename stuff
16
+ - naming of pretty much any aspect of the generated artefacts
17
+ - e.g. all types should be prefixed with an "I", Person => IPerson
18
+ - consistent casing (as in "camelCase" or "PascalCase") even for property names of entity types
19
+ - use type converters
20
+
21
+ See the [generator documentation](https://odata2ts.github.io/docs/generator/setup-and-usage) for more information.
22
+
23
+ ## Installation
24
+
25
+ ```
26
+ npm install --save-dev @odata2ts/odata2ts
27
+ ```
28
+
29
+ ### Implicit Dependencies
30
+
31
+ Most of the generated artefacts depend on other libraries. `odata2ts` lists them as peer dependencies.
32
+
33
+ Depending on your use case, you will need to add runtime dependencies matching the mentioned peer dependencies.
34
+ See the [Getting Started Guide](https://odata2ts.github.io/docs/category/getting-started/) of the documentation
35
+ for guidance.
36
+
37
+ ## Documentation
38
+
39
+ [Generator Documentation](https://odata2ts.github.io/docs/generator/setup-and-usage)
40
+
41
+ Main documentation for the odata2ts eco system:
42
+ [https://odata2ts.github.io](https://odata2ts.github.io/)
43
+
44
+ ## Examples
45
+
46
+ See [example packages](https://github.com/odata2ts/odata2ts/tree/main/examples) for examples of how to integrate `odata2ts`.
47
+
48
+ ## Tests
49
+
50
+ See folder [test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/test)
51
+ for unit tests.
52
+
53
+ See folder [int-test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/int-test) for integration
54
+ tests of the CLI.
55
+
56
+ Each example package serves as integration test of the generator.
57
+
58
+ ## Support, Feedback, Contributing
59
+
60
+ This project is open to feature requests, suggestions, bug reports, usage questions etc.
61
+ via [GitHub issues](https://github.com/odata2ts/odata2ts/issues).
62
+
63
+ Contributions and feedback are encouraged and always welcome.
64
+
65
+ See the [contribution guidelines](https://github.com/odata2ts/odata2ts/blob/main/CONTRIBUTING.md) for further information.
66
+
67
+ ## Spirit
68
+
69
+ This project and this module have been created and are maintained in the following spirit:
70
+
71
+ - adhere to the **OData specification** as much as possible
72
+ - support any OData service implementation which conforms to the spec
73
+ - allow to work around faulty implementations if possible
74
+ - stability matters
75
+ - exercise Test Driven Development
76
+ - bomb the place with unit tests (code coverage > 95%)
77
+ - ensure that assumptions & understanding are correct by creating integration tests
78
+
79
+ ## License
80
+
81
+ MIT - see [License](./LICENSE).
@@ -195,6 +195,14 @@ export interface ConfigFileOptions extends Omit<CliOptions, "sourceUrl" | "sourc
195
195
  * With this option you can turn that off.
196
196
  */
197
197
  skipComments?: boolean;
198
+ /**
199
+ * With OData you can read, update and delete data on a primitive property (`Edm.*`).
200
+ * Usually, you wouldn't do that, but go for a bigger request, fetching more relevant information in one go.
201
+ *
202
+ * There's one exception: Handling `Edm.Stream´ properties and Media entities. Services for stream / media
203
+ * stuff are generated regardless of this setting.
204
+ */
205
+ enablePrimitivePropertyServices?: boolean;
198
206
  /**
199
207
  * The naming options regarding the generated artefacts.
200
208
  */
@@ -1 +1 @@
1
- {"version":3,"file":"OptionModel.js","sourceRoot":"","sources":["../src/OptionModel.ts"],"names":[],"mappings":";;;AAKA;;GAEG;AACH,IAAY,KAKX;AALD,WAAY,KAAK;IACf,qCAAM,CAAA;IACN,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,+BAAG,CAAA;AACL,CAAC,EALW,KAAK,qBAAL,KAAK,QAKhB;AAED;;GAEG;AACH,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,yBAAT,SAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\nimport { AxiosRequestConfig } from \"axios\";\n\nimport { NameSettings, OverridableNamingOptions } from \"./NamingModel\";\n\n/**\n * Generation mode, by default \"all\".\n */\nexport enum Modes {\n models,\n qobjects,\n service,\n all,\n}\n\n/**\n * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.\n */\nexport enum EmitModes {\n ts = \"ts\",\n js = \"js\",\n dts = \"dts\",\n js_dts = \"js_dts\",\n}\n\n/**\n * Config options for CLI.\n */\nexport interface CliOptions {\n /**\n * The URL to the root of your OData service. The URL might end in a slash or not, it might also end\n * in $metadata, but we usually add this for you.\n *\n * Specifying the URL is a convenience feature to download the metadata file from the given URL.\n * You can configure this request via `sourceConfig` option.\n *\n * The `source` option must still be specified as it is used to store the downloaded file on your disk.\n * By default, the file is used once it has been downloaded.\n */\n sourceUrl?: string;\n /**\n * Downloads the metadata file and overwrites the existing one, if any.\n *\n * Only takes effect, if option `sourceUrl` is specified.\n */\n refreshFile?: boolean;\n /**\n * The source is the file to use (must be an EDMX compliant XML file) or the URL to the\n * metadata (ROOT_SERVICE/$metadata).\n *\n * If not specified, at least one service must be configured in config file.\n */\n source?: string;\n /**\n * Specifies the output directory for the generated stuff.\n *\n * If not specified, at least one service must be configured in config file.\n */\n output?: string;\n /**\n * Only generates the specified services.\n * Relies on an existing config file where these service names are maintained.\n */\n services?: Array<string>;\n /**\n * Specifies what to generate:\n * - {@code Modes.models} will only generate TS interfaces\n * - {@code Modes.qobjects} will generate functional units used in QueryBuilder and for functions and actions\n * - {@code Modes.service} will generate one main OData service client and one per each entity\n * - {@code Modes.all} the same as {@code Modes.service}\n *\n * QObjects will also generate models, and generating the service client will also generate models and QObjects.\n * Defaults to {@code Modes.all}\n */\n mode?: Modes;\n /**\n * Specifies the type of the output files: TypeScript, JS, DTS only, JS with DTS.\n * Defaults to {@code EmitModes.js_dts}\n */\n emitMode?: EmitModes;\n /**\n * Uses prettier with your local configuration to pretty print TypeScript files.\n * Only applies if mode is set to {@code EmitModes.ts}.\n */\n prettier?: boolean;\n /**\n * When compiling TypeScript to JS, \"tsconfig.json\" is used by default to add compilerOptions.\n * This option allows to specify an alternative file.\n *\n * Only takes effect, when mode is set to anything else than {@code EmitModes.ts}.\n */\n tsconfig?: string;\n /**\n * Verbose debugging information.\n */\n debug?: boolean;\n /**\n * Overrides the service name found in the source file.\n *\n * The service name is the basis for all file names and the name of the main OData client service\n * that serves as entry point for the user.\n */\n serviceName?: string;\n /**\n * odata2ts will automatically decide if a key prop is managed on the server side.\n * If managed, the property will not be editable (create, update, patch).\n * The following rule applies:\n * If a property is the only key prop of an entity, then the prop is deemed to be managed;\n * in ony other case the prop is unmanaged.\n */\n disableAutoManagedKey?: boolean;\n /**\n * By default, odata2ts doesn't change param, operation, property or model names.\n * The generated models and their properties are named exactly as advertised by the server.\n *\n * By allowing odata2ts to change these names, certain predefined formatting strategies are used:\n * Model / class names are formatted with PascalCase; property, param, and operation names with camelCase.\n *\n * The naming configuration allows to control this and other naming related settings.\n * Note: Even if renaming is disabled, model prefixing / suffixing still applies.\n */\n allowRenaming?: boolean;\n}\n\n/**\n * Configuration options of the request to retrieve the metadata.\n * Only takes effect if `source` is a URL.\n */\nexport interface UrlSourceConfiguration {\n /**\n * Basic auth credentials: the username.\n * Only takes effect if `password` has also been set.\n */\n username?: string;\n /**\n * Basic auth credentials: the password.\n * Only takes effect if `username` has also been set.\n */\n password?: string;\n /**\n * Custom request configuration.\n * URL and method `GET` are set by default, but can be overwritten.\n */\n custom?: AxiosRequestConfig;\n}\n\n/**\n * Available options for configuration files, i.e. odata2ts.config.ts.\n */\nexport interface ConfigFileOptions extends Omit<CliOptions, \"sourceUrl\" | \"source\" | \"output\" | \"services\"> {\n /**\n * Configuration options of the request to retrieve the metadata.\n * Only takes effect if `sourceUrl` is a URL.\n */\n sourceUrlConfig?: UrlSourceConfiguration;\n\n /**\n * Configuration of each service.\n *\n * @example { services: { trippin: { source: \"...\", ... } }}\n */\n services?: { [serviceName: string]: ServiceGenerationOptions };\n\n /**\n * Specify which converters to use by their package name, e.g. \"@odata2ts/converter-v2-to-v4\".\n * Each converter knows which data type to map.\n *\n * To only use specific converters, the object syntax must be used, where supported converters\n * must be listed by their ids.\n */\n converters?: Array<string | TypeConverterConfig>;\n\n /**\n * For each model an editable version is generated which represents the model definition for\n * create, update and patch actions.\n *\n * You can skip the generation altogether, not generating editable model variants,\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\n */\n skipEditableModels?: boolean;\n\n /**\n * ID models are generated from entity id parameters.\n * The generation for one entity entails one model interface representing the id parameters and\n * one QId function which allows to format the parameters for URL usage and to parse parameters\n * from a URL string.\n *\n * You can skip the generation altogether, not generating models and QId objects, if the\n * generation mode is {@code Mode.model} or {@code Mode.qobject}.\n */\n skipIdModels?: boolean;\n /**\n * Operations are functions and actions of the OData service.\n * The generation for one operation entails one parameter model interface\n * and one QFunction / QAction class.\n *\n * You can skip the generation altogether, neither generating model nor query object,\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\n */\n skipOperations?: boolean;\n /**\n * Model properties have explaining comments by default.\n * With this option you can turn that off.\n */\n skipComments?: boolean;\n\n /**\n * The naming options regarding the generated artefacts.\n */\n naming?: OverridableNamingOptions;\n\n /**\n * Some OData V2 services generate an extra wrapping for entity collection attributes:\n * <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities\n * an object with the property \"results\" is wrapped around the entity collection.\n *\n * If you're using the odata client then there's a build-in workaround in place which transforms\n * the results to remove this extra mapping. However, if you're only interested in the types, then\n * the generated models will not match that extra wrapping.\n *\n * Setting this configuration option to <code>true</code> (default: false) will add this extra\n * wrapping to the generated models. But this option is only valid if the generation mode is set\n * to <code>models</code>; it is ignored otherwise.\n */\n v2ModelsWithExtraResultsWrapping?: boolean;\n /**\n * Numbers of type `Edm.Int64` and `Edm.Decimal` are represented as `number` in V4.\n * However, these numbers might not fit into JS' number type, which might result in precision loss.\n *\n * OData offers a special IEEE754 format option to get those types as `string` instead to prevent any\n * precision loss. So if you're handling very large or very small numbers (JS roughly supports 15 digits),\n * then you should use this option and, probably, also an appropriate converter (see available converters).\n *\n * Activating this option affects the type generation and will use `string` for both mentioned types.\n * All requests are executed with the \"accept\" header set to \"application/json;IEEE754Compatible=true\".\n * Additionally, when sending data the very same value will be set for the \"content-type\" header.\n */\n v4BigNumberAsString?: boolean;\n}\n\n/**\n * Custom generation options which are dependent on a specific odata service.\n */\nexport interface ServiceGenerationOptions\n extends Required<Pick<CliOptions, \"source\" | \"output\">>,\n Pick<CliOptions, \"sourceUrl\" | \"refreshFile\">,\n Omit<ConfigFileOptions, \"services\"> {\n /**\n * Configure generation process for EntityTypes and ComplexTypes including their keys and properties.\n */\n entitiesByName?: Array<EntityGenerationOptions>;\n /**\n * Configure generation process for individual properties based on their name.\n */\n propertiesByName?: Array<PropertyGenerationOptions>;\n}\n\n/**\n * Available options for the actual generation run.\n * Every property is required, except the overriding service name.\n */\nexport interface RunOptions\n extends Required<Omit<ServiceGenerationOptions, \"serviceName\" | \"sourceUrl\" | \"sourceUrlConfig\" | \"refreshFile\">>,\n Pick<ServiceGenerationOptions, \"serviceName\" | \"sourceUrl\" | \"sourceUrlConfig\" | \"refreshFile\"> {\n naming: NameSettings;\n}\n\n/**\n * Configuration options for EntityTypes and ComplexTypes.\n * This config applies if the name matches the name of an EntityType or ComplexType as it is specified\n * in the metadata (e.g. in EDMX <EntityType name=\"Test\" ...)\n */\nexport interface EntityGenerationOptions {\n /**\n * Name of the EntityType or ComplexType, e.g. \"Person\".\n * Must match exactly or can be a regular expression.\n */\n name: string | RegExp;\n /**\n * Use a different name.\n * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).\n */\n mappedName?: string;\n /**\n * Overwrite the key specification by naming the props by their EDMX name.\n */\n keys?: Array<string>;\n /**\n * Configuration of individual properties.\n */\n properties?: Array<PropertyGenerationOptions>;\n\n // converter: string | Array<string>\n\n /**\n * Whether the generated service should allow for querying this model.\n * True by default.\n */\n // queryable?: boolean;\n /**\n * Whether the generated service should allow for creating new models (POST).\n * True by default.\n */\n // creatable?: boolean;\n /**\n * Whether the generated service should allow for updates (PUT).\n * True by default.\n */\n // updatable?: boolean;\n /**\n * Whether the generated service should allow for partial updates (PATCH).\n * True by default.\n */\n // patchable?: boolean;\n /**\n * Whether the generated service should allow for deletion.\n * True by default.\n */\n // deletable?: boolean;\n}\n\n/**\n * All configuration options for properties of models.\n */\nexport interface PropertyGenerationOptions {\n /**\n * Name of the property to match.\n * Must match exactly or can be a regular expression.\n */\n name: string | RegExp;\n /**\n * Use a different name.\n * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).\n */\n mappedName?: string;\n /**\n * Managed attributes - i.e. managed by the server - cannot be created or updated.\n * Hence, they are left out of the editable model versions.\n */\n managed?: boolean;\n\n /**\n * TODO\n *\n * Each converter must specify its package name, e.g. \"@odata2ts/converter-v2-to-v4\",\n * as well it's i\n * and their ids, e.g. \"timeToDurationConverter\".\n *\n * To only use specific converters, the object syntax must be used, where supported converters\n * must be listed by their ids.\n */\n // converters?: Array<Required<TypeConverterConfig>>;\n}\n"]}
1
+ {"version":3,"file":"OptionModel.js","sourceRoot":"","sources":["../src/OptionModel.ts"],"names":[],"mappings":";;;AAKA;;GAEG;AACH,IAAY,KAKX;AALD,WAAY,KAAK;IACf,qCAAM,CAAA;IACN,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,+BAAG,CAAA;AACL,CAAC,EALW,KAAK,qBAAL,KAAK,QAKhB;AAED;;GAEG;AACH,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,yBAAT,SAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\r\nimport { AxiosRequestConfig } from \"axios\";\r\n\r\nimport { NameSettings, OverridableNamingOptions } from \"./NamingModel\";\r\n\r\n/**\r\n * Generation mode, by default \"all\".\r\n */\r\nexport enum Modes {\r\n models,\r\n qobjects,\r\n service,\r\n all,\r\n}\r\n\r\n/**\r\n * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.\r\n */\r\nexport enum EmitModes {\r\n ts = \"ts\",\r\n js = \"js\",\r\n dts = \"dts\",\r\n js_dts = \"js_dts\",\r\n}\r\n\r\n/**\r\n * Config options for CLI.\r\n */\r\nexport interface CliOptions {\r\n /**\r\n * The URL to the root of your OData service. The URL might end in a slash or not, it might also end\r\n * in $metadata, but we usually add this for you.\r\n *\r\n * Specifying the URL is a convenience feature to download the metadata file from the given URL.\r\n * You can configure this request via `sourceConfig` option.\r\n *\r\n * The `source` option must still be specified as it is used to store the downloaded file on your disk.\r\n * By default, the file is used once it has been downloaded.\r\n */\r\n sourceUrl?: string;\r\n /**\r\n * Downloads the metadata file and overwrites the existing one, if any.\r\n *\r\n * Only takes effect, if option `sourceUrl` is specified.\r\n */\r\n refreshFile?: boolean;\r\n /**\r\n * The source is the file to use (must be an EDMX compliant XML file) or the URL to the\r\n * metadata (ROOT_SERVICE/$metadata).\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n source?: string;\r\n /**\r\n * Specifies the output directory for the generated stuff.\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n output?: string;\r\n /**\r\n * Only generates the specified services.\r\n * Relies on an existing config file where these service names are maintained.\r\n */\r\n services?: Array<string>;\r\n /**\r\n * Specifies what to generate:\r\n * - {@code Modes.models} will only generate TS interfaces\r\n * - {@code Modes.qobjects} will generate functional units used in QueryBuilder and for functions and actions\r\n * - {@code Modes.service} will generate one main OData service client and one per each entity\r\n * - {@code Modes.all} the same as {@code Modes.service}\r\n *\r\n * QObjects will also generate models, and generating the service client will also generate models and QObjects.\r\n * Defaults to {@code Modes.all}\r\n */\r\n mode?: Modes;\r\n /**\r\n * Specifies the type of the output files: TypeScript, JS, DTS only, JS with DTS.\r\n * Defaults to {@code EmitModes.js_dts}\r\n */\r\n emitMode?: EmitModes;\r\n /**\r\n * Uses prettier with your local configuration to pretty print TypeScript files.\r\n * Only applies if mode is set to {@code EmitModes.ts}.\r\n */\r\n prettier?: boolean;\r\n /**\r\n * When compiling TypeScript to JS, \"tsconfig.json\" is used by default to add compilerOptions.\r\n * This option allows to specify an alternative file.\r\n *\r\n * Only takes effect, when mode is set to anything else than {@code EmitModes.ts}.\r\n */\r\n tsconfig?: string;\r\n /**\r\n * Verbose debugging information.\r\n */\r\n debug?: boolean;\r\n /**\r\n * Overrides the service name found in the source file.\r\n *\r\n * The service name is the basis for all file names and the name of the main OData client service\r\n * that serves as entry point for the user.\r\n */\r\n serviceName?: string;\r\n /**\r\n * odata2ts will automatically decide if a key prop is managed on the server side.\r\n * If managed, the property will not be editable (create, update, patch).\r\n * The following rule applies:\r\n * If a property is the only key prop of an entity, then the prop is deemed to be managed;\r\n * in ony other case the prop is unmanaged.\r\n */\r\n disableAutoManagedKey?: boolean;\r\n /**\r\n * By default, odata2ts doesn't change param, operation, property or model names.\r\n * The generated models and their properties are named exactly as advertised by the server.\r\n *\r\n * By allowing odata2ts to change these names, certain predefined formatting strategies are used:\r\n * Model / class names are formatted with PascalCase; property, param, and operation names with camelCase.\r\n *\r\n * The naming configuration allows to control this and other naming related settings.\r\n * Note: Even if renaming is disabled, model prefixing / suffixing still applies.\r\n */\r\n allowRenaming?: boolean;\r\n}\r\n\r\n/**\r\n * Configuration options of the request to retrieve the metadata.\r\n * Only takes effect if `source` is a URL.\r\n */\r\nexport interface UrlSourceConfiguration {\r\n /**\r\n * Basic auth credentials: the username.\r\n * Only takes effect if `password` has also been set.\r\n */\r\n username?: string;\r\n /**\r\n * Basic auth credentials: the password.\r\n * Only takes effect if `username` has also been set.\r\n */\r\n password?: string;\r\n /**\r\n * Custom request configuration.\r\n * URL and method `GET` are set by default, but can be overwritten.\r\n */\r\n custom?: AxiosRequestConfig;\r\n}\r\n\r\n/**\r\n * Available options for configuration files, i.e. odata2ts.config.ts.\r\n */\r\nexport interface ConfigFileOptions extends Omit<CliOptions, \"sourceUrl\" | \"source\" | \"output\" | \"services\"> {\r\n /**\r\n * Configuration options of the request to retrieve the metadata.\r\n * Only takes effect if `sourceUrl` is a URL.\r\n */\r\n sourceUrlConfig?: UrlSourceConfiguration;\r\n\r\n /**\r\n * Configuration of each service.\r\n *\r\n * @example { services: { trippin: { source: \"...\", ... } }}\r\n */\r\n services?: { [serviceName: string]: ServiceGenerationOptions };\r\n\r\n /**\r\n * Specify which converters to use by their package name, e.g. \"@odata2ts/converter-v2-to-v4\".\r\n * Each converter knows which data type to map.\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n converters?: Array<string | TypeConverterConfig>;\r\n\r\n /**\r\n * For each model an editable version is generated which represents the model definition for\r\n * create, update and patch actions.\r\n *\r\n * You can skip the generation altogether, not generating editable model variants,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipEditableModels?: boolean;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n * The generation for one entity entails one model interface representing the id parameters and\r\n * one QId function which allows to format the parameters for URL usage and to parse parameters\r\n * from a URL string.\r\n *\r\n * You can skip the generation altogether, not generating models and QId objects, if the\r\n * generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipIdModels?: boolean;\r\n /**\r\n * Operations are functions and actions of the OData service.\r\n * The generation for one operation entails one parameter model interface\r\n * and one QFunction / QAction class.\r\n *\r\n * You can skip the generation altogether, neither generating model nor query object,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipOperations?: boolean;\r\n /**\r\n * Model properties have explaining comments by default.\r\n * With this option you can turn that off.\r\n */\r\n skipComments?: boolean;\r\n /**\r\n * With OData you can read, update and delete data on a primitive property (`Edm.*`).\r\n * Usually, you wouldn't do that, but go for a bigger request, fetching more relevant information in one go.\r\n *\r\n * There's one exception: Handling `Edm.Stream´ properties and Media entities. Services for stream / media\r\n * stuff are generated regardless of this setting.\r\n */\r\n enablePrimitivePropertyServices?: boolean;\r\n\r\n /**\r\n * The naming options regarding the generated artefacts.\r\n */\r\n naming?: OverridableNamingOptions;\r\n\r\n /**\r\n * Some OData V2 services generate an extra wrapping for entity collection attributes:\r\n * <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities\r\n * an object with the property \"results\" is wrapped around the entity collection.\r\n *\r\n * If you're using the odata client then there's a build-in workaround in place which transforms\r\n * the results to remove this extra mapping. However, if you're only interested in the types, then\r\n * the generated models will not match that extra wrapping.\r\n *\r\n * Setting this configuration option to <code>true</code> (default: false) will add this extra\r\n * wrapping to the generated models. But this option is only valid if the generation mode is set\r\n * to <code>models</code>; it is ignored otherwise.\r\n */\r\n v2ModelsWithExtraResultsWrapping?: boolean;\r\n /**\r\n * Numbers of type `Edm.Int64` and `Edm.Decimal` are represented as `number` in V4.\r\n * However, these numbers might not fit into JS' number type, which might result in precision loss.\r\n *\r\n * OData offers a special IEEE754 format option to get those types as `string` instead to prevent any\r\n * precision loss. So if you're handling very large or very small numbers (JS roughly supports 15 digits),\r\n * then you should use this option and, probably, also an appropriate converter (see available converters).\r\n *\r\n * Activating this option affects the type generation and will use `string` for both mentioned types.\r\n * All requests are executed with the \"accept\" header set to \"application/json;IEEE754Compatible=true\".\r\n * Additionally, when sending data the very same value will be set for the \"content-type\" header.\r\n */\r\n v4BigNumberAsString?: boolean;\r\n}\r\n\r\n/**\r\n * Custom generation options which are dependent on a specific odata service.\r\n */\r\nexport interface ServiceGenerationOptions\r\n extends Required<Pick<CliOptions, \"source\" | \"output\">>,\r\n Pick<CliOptions, \"sourceUrl\" | \"refreshFile\">,\r\n Omit<ConfigFileOptions, \"services\"> {\r\n /**\r\n * Configure generation process for EntityTypes and ComplexTypes including their keys and properties.\r\n */\r\n entitiesByName?: Array<EntityGenerationOptions>;\r\n /**\r\n * Configure generation process for individual properties based on their name.\r\n */\r\n propertiesByName?: Array<PropertyGenerationOptions>;\r\n}\r\n\r\n/**\r\n * Available options for the actual generation run.\r\n * Every property is required, except the overriding service name.\r\n */\r\nexport interface RunOptions\r\n extends Required<Omit<ServiceGenerationOptions, \"serviceName\" | \"sourceUrl\" | \"sourceUrlConfig\" | \"refreshFile\">>,\r\n Pick<ServiceGenerationOptions, \"serviceName\" | \"sourceUrl\" | \"sourceUrlConfig\" | \"refreshFile\"> {\r\n naming: NameSettings;\r\n}\r\n\r\n/**\r\n * Configuration options for EntityTypes and ComplexTypes.\r\n * This config applies if the name matches the name of an EntityType or ComplexType as it is specified\r\n * in the metadata (e.g. in EDMX <EntityType name=\"Test\" ...)\r\n */\r\nexport interface EntityGenerationOptions {\r\n /**\r\n * Name of the EntityType or ComplexType, e.g. \"Person\".\r\n * Must match exactly or can be a regular expression.\r\n */\r\n name: string | RegExp;\r\n /**\r\n * Use a different name.\r\n * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).\r\n */\r\n mappedName?: string;\r\n /**\r\n * Overwrite the key specification by naming the props by their EDMX name.\r\n */\r\n keys?: Array<string>;\r\n /**\r\n * Configuration of individual properties.\r\n */\r\n properties?: Array<PropertyGenerationOptions>;\r\n\r\n // converter: string | Array<string>\r\n\r\n /**\r\n * Whether the generated service should allow for querying this model.\r\n * True by default.\r\n */\r\n // queryable?: boolean;\r\n /**\r\n * Whether the generated service should allow for creating new models (POST).\r\n * True by default.\r\n */\r\n // creatable?: boolean;\r\n /**\r\n * Whether the generated service should allow for updates (PUT).\r\n * True by default.\r\n */\r\n // updatable?: boolean;\r\n /**\r\n * Whether the generated service should allow for partial updates (PATCH).\r\n * True by default.\r\n */\r\n // patchable?: boolean;\r\n /**\r\n * Whether the generated service should allow for deletion.\r\n * True by default.\r\n */\r\n // deletable?: boolean;\r\n}\r\n\r\n/**\r\n * All configuration options for properties of models.\r\n */\r\nexport interface PropertyGenerationOptions {\r\n /**\r\n * Name of the property to match.\r\n * Must match exactly or can be a regular expression.\r\n */\r\n name: string | RegExp;\r\n /**\r\n * Use a different name.\r\n * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).\r\n */\r\n mappedName?: string;\r\n /**\r\n * Managed attributes - i.e. managed by the server - cannot be created or updated.\r\n * Hence, they are left out of the editable model versions.\r\n */\r\n managed?: boolean;\r\n\r\n /**\r\n * TODO\r\n *\r\n * Each converter must specify its package name, e.g. \"@odata2ts/converter-v2-to-v4\",\r\n * as well it's i\r\n * and their ids, e.g. \"timeToDurationConverter\".\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n // converters?: Array<Required<TypeConverterConfig>>;\r\n}\r\n"]}
package/lib/app.js CHANGED
@@ -59,7 +59,7 @@ function runApp(metadataJson, options) {
59
59
  // Generate Individual OData-Service
60
60
  if (isServiceGen(options.mode)) {
61
61
  yield project.cleanServiceDir();
62
- yield (0, generator_1.generateServices)(dataModel, project, version, namingHelper, options.v4BigNumberAsString);
62
+ yield (0, generator_1.generateServices)(dataModel, project, version, namingHelper, options);
63
63
  }
64
64
  yield project.writeFiles();
65
65
  });
package/lib/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AAErD,4EAAuE;AACvE,4EAAuE;AAIvE,4DAAyD;AACzD,2CAAqF;AACrF,+CAAkD;AAClD,6DAAgE;AAEhE,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,QAAQ,EAAE,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,SAAsB,MAAM,CAAC,YAAqC,EAAE,OAAmB;;QACrF,uCAAuC;QACvC,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACxD,MAAM,OAAO,GAAG,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,0BAAa,CAAC,EAAE,CAAC,CAAC,CAAC,0BAAa,CAAC,EAAE,CAAC;QAE5E,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;QACtE,MAAM,OAAO,GAAG,WAAW,CAAC,MAAoC,CAAC;QAEjE,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MA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AC;QACnD,IAAA,0BAAc,EAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAEtE,yBAAyB;QACzB,gDAAgD;QAChD,mJAAmJ;QACnJ,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAChD,IAAA,gCAAoB,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACxE;QAED,oCAAoC;QACpC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;YAChC,MAAM,IAAA,4BAAgB,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;SAChG;QAED,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;CAAA;AAxDD,wBAwDC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\n\r\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2\";\r\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\r\nimport { ODataEdmxModelBase, Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { SchemaV3 } from \"./data-model/edmx/ODataEdmxModelV3\";\r\nimport { SchemaV4 } from \"./data-model/edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper\";\r\nimport { generateModels, generateQueryObjects, generateServices } from \"./generator\";\r\nimport { Modes, RunOptions } from \"./OptionModel\";\r\nimport { createProjectManager } from \"./project/ProjectManager\";\r\n\r\nfunction isQObjectGen(mode: Modes) {\r\n return [Modes.qobjects, Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\nfunction isServiceGen(mode: Modes) {\r\n return [Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\n/**\r\n *\r\n * @param metadataJson metadata of a given OData service already parsed as JSON\r\n * @param options further options\r\n */\r\nexport async function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void> {\r\n // determine edmx edmxVersion attribute\r\n const edmxVersion = metadataJson[\"edmx:Edmx\"].$.Version;\r\n const version = edmxVersion === \"1.0\" ? ODataVersions.V2 : ODataVersions.V4;\r\n\r\n const dataService = metadataJson[\"edmx:Edmx\"][\"edmx:DataServices\"][0];\r\n const schemas = dataService.Schema as Array<SchemaV3 | SchemaV4>;\r\n\r\n const detectedSchema = schemas.find((schema) => schema.$.Namespace && schema.EntityType?.length) || schemas[0];\r\n const serviceName = options.serviceName || detectedSchema.$.Namespace;\r\n\r\n const namespaces: Array<string> = [];\r\n schemas.forEach((schema) => {\r\n namespaces.push(schema.$.Namespace);\r\n if (schema.$.Alias) {\r\n namespaces.push(schema.$.Alias);\r\n }\r\n });\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 // handling the overall generation project\r\n const project = await createProjectManager(\r\n namingHelper.getFileNames(),\r\n options.output,\r\n options.emitMode,\r\n options.prettier,\r\n options.tsconfig\r\n );\r\n\r\n // Generate Model Interfaces\r\n // supported edmx types: EntityType, ComplexType, EnumType\r\n const modelsFile = await project.createModelFile();\r\n generateModels(dataModel, modelsFile, version, options, namingHelper);\r\n\r\n // Generate Query Objects\r\n // supported edmx types: EntityType, ComplexType\r\n // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object\r\n if (isQObjectGen(options.mode)) {\r\n const qFile = await project.createQObjectFile();\r\n generateQueryObjects(dataModel, qFile, version, options, namingHelper);\r\n }\r\n\r\n // Generate Individual OData-Service\r\n if (isServiceGen(options.mode)) {\r\n await project.cleanServiceDir();\r\n await generateServices(dataModel, project, version, namingHelper, options.v4BigNumberAsString);\r\n }\r\n\r\n await project.writeFiles();\r\n}\r\n"]}
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AAErD,4EAAuE;AACvE,4EAAuE;AAIvE,4DAAyD;AACzD,2CAAqF;AACrF,+CAAkD;AAClD,6DAAgE;AAEhE,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,QAAQ,EAAE,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,SAAsB,MAAM,CAAC,YAAqC,EAAE,OAAmB;;QACrF,uCAAuC;QACvC,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACxD,MAAM,OAAO,GAAG,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,0BAAa,CAAC,EAAE,CAAC,CAAC,CAAC,0BAAa,CAAC,EAAE,CAAC;QAE5E,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;QACtE,MAAM,OAAO,GAAG,WAAW,CAAC,MAAoC,CAAC;QAEjE,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,WAAC,OAAA,MAAM,CAAC,CAAC,CAAC,SAAS,KAAI,MAAA,MAAM,CAAC,UAAU,0CAAE,MAAM,CAAA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AyB;QACzB,gDAAgD;QAChD,mJAAmJ;QACnJ,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAChD,IAAA,gCAAoB,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACxE;QAED,oCAAoC;QACpC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;YAChC,MAAM,IAAA,4BAAgB,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;SAC5E;QAED,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;CAAA;AAxDD,wBAwDC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\n\r\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2\";\r\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\r\nimport { ODataEdmxModelBase, Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { SchemaV3 } from \"./data-model/edmx/ODataEdmxModelV3\";\r\nimport { SchemaV4 } from \"./data-model/edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper\";\r\nimport { generateModels, generateQueryObjects, generateServices } from \"./generator\";\r\nimport { Modes, RunOptions } from \"./OptionModel\";\r\nimport { createProjectManager } from \"./project/ProjectManager\";\r\n\r\nfunction isQObjectGen(mode: Modes) {\r\n return [Modes.qobjects, Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\nfunction isServiceGen(mode: Modes) {\r\n return [Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\n/**\r\n *\r\n * @param metadataJson metadata of a given OData service already parsed as JSON\r\n * @param options further options\r\n */\r\nexport async function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void> {\r\n // determine edmx edmxVersion attribute\r\n const edmxVersion = metadataJson[\"edmx:Edmx\"].$.Version;\r\n const version = edmxVersion === \"1.0\" ? ODataVersions.V2 : ODataVersions.V4;\r\n\r\n const dataService = metadataJson[\"edmx:Edmx\"][\"edmx:DataServices\"][0];\r\n const schemas = dataService.Schema as Array<SchemaV3 | SchemaV4>;\r\n\r\n const detectedSchema = schemas.find((schema) => schema.$.Namespace && schema.EntityType?.length) || schemas[0];\r\n const serviceName = options.serviceName || detectedSchema.$.Namespace;\r\n\r\n const namespaces: Array<string> = [];\r\n schemas.forEach((schema) => {\r\n namespaces.push(schema.$.Namespace);\r\n if (schema.$.Alias) {\r\n namespaces.push(schema.$.Alias);\r\n }\r\n });\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 // handling the overall generation project\r\n const project = await createProjectManager(\r\n namingHelper.getFileNames(),\r\n options.output,\r\n options.emitMode,\r\n options.prettier,\r\n options.tsconfig\r\n );\r\n\r\n // Generate Model Interfaces\r\n // supported edmx types: EntityType, ComplexType, EnumType\r\n const modelsFile = await project.createModelFile();\r\n generateModels(dataModel, modelsFile, version, options, namingHelper);\r\n\r\n // Generate Query Objects\r\n // supported edmx types: EntityType, ComplexType\r\n // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object\r\n if (isQObjectGen(options.mode)) {\r\n const qFile = await project.createQObjectFile();\r\n generateQueryObjects(dataModel, qFile, version, options, namingHelper);\r\n }\r\n\r\n // Generate Individual OData-Service\r\n if (isServiceGen(options.mode)) {\r\n await project.cleanServiceDir();\r\n await generateServices(dataModel, project, version, namingHelper, options);\r\n }\r\n\r\n await project.writeFiles();\r\n}\r\n"]}
@@ -21,6 +21,7 @@ const defaultConfig = {
21
21
  skipIdModels: false,
22
22
  skipOperations: false,
23
23
  skipComments: false,
24
+ enablePrimitivePropertyServices: false,
24
25
  disableAutoManagedKey: false,
25
26
  allowRenaming: false,
26
27
  v2ModelsWithExtraResultsWrapping: false,
@@ -1 +1 @@
1
- {"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../src/defaultConfig.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAElC,+CAA+D;AAC/D,+CAA6D;AAG7D;;GAEG;AACH,MAAM,aAAa,GAAyB;IAC1C,eAAe,EAAE,EAAE;IACnB,WAAW,EAAE,KAAK;IAClB,IAAI,EAAE,mBAAK,CAAC,GAAG;IACf,QAAQ,EAAE,uBAAS,CAAC,MAAM;IAC1B,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,eAAe;IACzB,UAAU,EAAE,EAAE;IACd,kBAAkB,EAAE,KAAK;IACzB,YAAY,EAAE,KAAK;IACnB,cAAc,EAAE,KAAK;IACrB,YAAY,EAAE,KAAK;IACnB,qBAAqB,EAAE,KAAK;IAC5B,aAAa,EAAE,KAAK;IACpB,gCAAgC,EAAE,KAAK;IACvC,mBAAmB,EAAE,KAAK;IAC1B,MAAM,EAAE;QACN,MAAM,EAAE;YACN,cAAc,EAAE,8BAAgB,CAAC,WAAW;YAC5C,kBAAkB,EAAE,8BAAgB,CAAC,UAAU;YAC/C,cAAc,EAAE;gBACd,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,EAAE;gBACV,gBAAgB,EAAE,IAAI;aACvB;YACD,QAAQ,EAAE;gBACR,MAAM,EAAE,EAAE;gBACV,MAAM,EAAE,IAAI;gBACZ,gBAAgB,EAAE,IAAI;aACvB;YACD,oBAAoB,EAAE;gBACpB,MAAM,EAAE,EAAE;gBACV,MAAM,EAAE,QAAQ;gBAChB,gBAAgB,EAAE,IAAI;aACvB;YACD,QAA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AAM,EAAE,QAAQ,CAAC,YAAY,CAAC,MAAM;SACrC;QACD,oBAAoB,EAAE;YACpB,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM;YAC5C,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM;SAC7C;KACF;CACF,CAAC;AAEF;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,mBAAS,EAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAFD,4CAEC;AAED;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,MAAM,EAAE,MAAM,KAAqB,aAAa,EAA7B,WAAW,kBAAK,aAAa,EAA1C,UAA0B,CAAgB,CAAC;IACjD,OAAO,IAAA,mBAAS,EAAC,WAAW,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;AACjE,CAAC;AAHD,4CAGC","sourcesContent":["import deepmerge from \"deepmerge\";\r\n\r\nimport { NameSettings, NamingStrategies } from \"./NamingModel\";\r\nimport { EmitModes, Modes, RunOptions } from \"./OptionModel\";\r\n\r\nexport type DefaultConfiguration = Omit<RunOptions, \"sourceUrl\" | \"source\" | \"output\" | \"serviceName\">;\r\n/**\r\n * The default configuration.\r\n */\r\nconst defaultConfig: DefaultConfiguration = {\r\n sourceUrlConfig: {},\r\n refreshFile: false,\r\n mode: Modes.all,\r\n emitMode: EmitModes.js_dts,\r\n debug: false,\r\n prettier: false,\r\n tsconfig: \"tsconfig.json\",\r\n converters: [],\r\n skipEditableModels: false,\r\n skipIdModels: false,\r\n skipOperations: false,\r\n skipComments: false,\r\n disableAutoManagedKey: false,\r\n allowRenaming: false,\r\n v2ModelsWithExtraResultsWrapping: false,\r\n v4BigNumberAsString: false,\r\n naming: {\r\n models: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n editableModels: {\r\n prefix: \"Editable\",\r\n suffix: \"\",\r\n applyModelNaming: true,\r\n },\r\n idModels: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n applyModelNaming: true,\r\n },\r\n operationParamModels: {\r\n prefix: \"\",\r\n suffix: \"Params\",\r\n applyModelNaming: true,\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"\",\r\n suffix: \"Model\",\r\n },\r\n },\r\n queryObjects: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n idFunctions: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n },\r\n },\r\n services: {\r\n prefix: \"\",\r\n suffix: \"Service\",\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n prefix: \"\",\r\n suffix: \"Collection\",\r\n applyServiceNaming: true,\r\n },\r\n operations: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n },\r\n relatedServiceGetter: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"\",\r\n suffix: \"\",\r\n },\r\n privateProps: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"_\",\r\n suffix: \"\",\r\n },\r\n },\r\n },\r\n propertiesByName: [],\r\n entitiesByName: [],\r\n};\r\n\r\nconst { models, queryObjects, services } = defaultConfig.naming;\r\nconst minimalNamingConfig: NameSettings = {\r\n models: {\r\n fileName: {\r\n prefix: models.fileName.prefix,\r\n suffix: models.fileName.suffix,\r\n },\r\n idModels: {\r\n applyModelNaming: true,\r\n prefix: models.idModels.prefix,\r\n suffix: models.idModels.suffix,\r\n },\r\n editableModels: {\r\n applyModelNaming: true,\r\n prefix: models.editableModels.prefix,\r\n suffix: models.editableModels.suffix,\r\n },\r\n operationParamModels: {\r\n applyModelNaming: true,\r\n prefix: models.operationParamModels.prefix,\r\n suffix: models.operationParamModels.suffix,\r\n },\r\n },\r\n queryObjects: {\r\n prefix: queryObjects.prefix,\r\n suffix: queryObjects.suffix,\r\n fileName: {\r\n prefix: queryObjects.fileName.prefix,\r\n suffix: queryObjects.fileName.suffix,\r\n },\r\n idFunctions: {\r\n prefix: queryObjects.idFunctions.prefix,\r\n suffix: queryObjects.idFunctions.suffix,\r\n },\r\n },\r\n services: {\r\n prefix: services.prefix,\r\n suffix: services.suffix,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n applyServiceNaming: true,\r\n prefix: services.collection.prefix,\r\n suffix: services.collection.suffix,\r\n },\r\n privateProps: {\r\n prefix: services.privateProps.prefix,\r\n suffix: services.privateProps.suffix,\r\n },\r\n relatedServiceGetter: {\r\n prefix: services.relatedServiceGetter.prefix,\r\n suffix: services.relatedServiceGetter.suffix,\r\n },\r\n },\r\n};\r\n\r\n/**\r\n * Creates a defensive copy of the default config.\r\n */\r\nexport function getDefaultConfig(): DefaultConfiguration {\r\n return deepmerge(defaultConfig, {});\r\n}\r\n\r\n/**\r\n * Creates a defensive copy of the minimal config: minimal in respect to naming.\r\n */\r\nexport function getMinimalConfig(): DefaultConfiguration {\r\n const { naming, ...passThrough } = defaultConfig;\r\n return deepmerge(passThrough, { naming: minimalNamingConfig });\r\n}\r\n"]}
1
+ {"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../src/defaultConfig.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAElC,+CAA+D;AAC/D,+CAA6D;AAG7D;;GAEG;AACH,MAAM,aAAa,GAAyB;IAC1C,eAAe,EAAE,EAAE;IACnB,WAAW,EAAE,KAAK;IAClB,IAAI,EAAE,mBAAK,CAAC,GAAG;IACf,QAAQ,EAAE,uBAAS,CAAC,MAAM;IAC1B,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,eAAe;IACzB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ourcesContent":["import deepmerge from \"deepmerge\";\r\n\r\nimport { NameSettings, NamingStrategies } from \"./NamingModel\";\r\nimport { EmitModes, Modes, RunOptions } from \"./OptionModel\";\r\n\r\nexport type DefaultConfiguration = Omit<RunOptions, \"sourceUrl\" | \"source\" | \"output\" | \"serviceName\">;\r\n/**\r\n * The default configuration.\r\n */\r\nconst defaultConfig: DefaultConfiguration = {\r\n sourceUrlConfig: {},\r\n refreshFile: false,\r\n mode: Modes.all,\r\n emitMode: EmitModes.js_dts,\r\n debug: false,\r\n prettier: false,\r\n tsconfig: \"tsconfig.json\",\r\n converters: [],\r\n skipEditableModels: false,\r\n skipIdModels: false,\r\n skipOperations: false,\r\n skipComments: false,\r\n enablePrimitivePropertyServices: false,\r\n disableAutoManagedKey: false,\r\n allowRenaming: false,\r\n v2ModelsWithExtraResultsWrapping: false,\r\n v4BigNumberAsString: false,\r\n naming: {\r\n models: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n editableModels: {\r\n prefix: \"Editable\",\r\n suffix: \"\",\r\n applyModelNaming: true,\r\n },\r\n idModels: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n applyModelNaming: true,\r\n },\r\n operationParamModels: {\r\n prefix: \"\",\r\n suffix: \"Params\",\r\n applyModelNaming: true,\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"\",\r\n suffix: \"Model\",\r\n },\r\n },\r\n queryObjects: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n idFunctions: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n },\r\n },\r\n services: {\r\n prefix: \"\",\r\n suffix: \"Service\",\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n prefix: \"\",\r\n suffix: \"Collection\",\r\n applyServiceNaming: true,\r\n },\r\n operations: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n },\r\n relatedServiceGetter: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"\",\r\n suffix: \"\",\r\n },\r\n privateProps: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"_\",\r\n suffix: \"\",\r\n },\r\n },\r\n },\r\n propertiesByName: [],\r\n entitiesByName: [],\r\n};\r\n\r\nconst { models, queryObjects, services } = defaultConfig.naming;\r\nconst minimalNamingConfig: NameSettings = {\r\n models: {\r\n fileName: {\r\n prefix: models.fileName.prefix,\r\n suffix: models.fileName.suffix,\r\n },\r\n idModels: {\r\n applyModelNaming: true,\r\n prefix: models.idModels.prefix,\r\n suffix: models.idModels.suffix,\r\n },\r\n editableModels: {\r\n applyModelNaming: true,\r\n prefix: models.editableModels.prefix,\r\n suffix: models.editableModels.suffix,\r\n },\r\n operationParamModels: {\r\n applyModelNaming: true,\r\n prefix: models.operationParamModels.prefix,\r\n suffix: models.operationParamModels.suffix,\r\n },\r\n },\r\n queryObjects: {\r\n prefix: queryObjects.prefix,\r\n suffix: queryObjects.suffix,\r\n fileName: {\r\n prefix: queryObjects.fileName.prefix,\r\n suffix: queryObjects.fileName.suffix,\r\n },\r\n idFunctions: {\r\n prefix: queryObjects.idFunctions.prefix,\r\n suffix: queryObjects.idFunctions.suffix,\r\n },\r\n },\r\n services: {\r\n prefix: services.prefix,\r\n suffix: services.suffix,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n applyServiceNaming: true,\r\n prefix: services.collection.prefix,\r\n suffix: services.collection.suffix,\r\n },\r\n privateProps: {\r\n prefix: services.privateProps.prefix,\r\n suffix: services.privateProps.suffix,\r\n },\r\n relatedServiceGetter: {\r\n prefix: services.relatedServiceGetter.prefix,\r\n suffix: services.relatedServiceGetter.suffix,\r\n },\r\n },\r\n};\r\n\r\n/**\r\n * Creates a defensive copy of the default config.\r\n */\r\nexport function getDefaultConfig(): DefaultConfiguration {\r\n return deepmerge(defaultConfig, {});\r\n}\r\n\r\n/**\r\n * Creates a defensive copy of the minimal config: minimal in respect to naming.\r\n */\r\nexport function getMinimalConfig(): DefaultConfiguration {\r\n const { naming, ...passThrough } = defaultConfig;\r\n return deepmerge(passThrough, { naming: minimalNamingConfig });\r\n}\r\n"]}
@@ -194,9 +194,14 @@ class QueryObjectGenerator {
194
194
  returnTypeOpStmt = `new OperationReturnType(ReturnTypes.COMPLEX${returnType.isCollection ? "_COLLECTION" : ""}, new QComplexParam("NONE", new ${returnType.qObject}))`;
195
195
  }
196
196
  }
197
+ // currently, it only makes sense to add the OperationReturnType if a converter is present
197
198
  else if (returnType.converters && returnType.qParam) {
198
199
  importContainer.addFromQObject("OperationReturnType", "ReturnTypes", returnType.qParam);
199
- returnTypeOpStmt = `new OperationReturnType(ReturnTypes.VALUE${returnType.isCollection ? "_COLLECTION" : ""}, new ${returnType.qParam}("NONE", undefined, ${this.generateConverterStmt(returnType.converters, importContainer)}))`;
200
+ const rtKind = "ReturnTypes.VALUE" + (returnType.isCollection ? "_COLLECTION" : "");
201
+ const converterParam = returnType.converters
202
+ ? ", " + this.generateConverterStmt(returnType.converters, importContainer)
203
+ : "";
204
+ returnTypeOpStmt = `new OperationReturnType(${rtKind}, new ${returnType.qParam}("NONE", undefined${converterParam}))`;
200
205
  }
201
206
  }
202
207
  this.sourceFile.addClass({
@@ -1 +1 @@
1
- {"version":3,"file":"QueryObjectGenerator.js","sourceRoot":"","sources":["../../src/generator/QueryObjectGenerator.ts"],"names":[],"mappings":";;;AACA,qDAAqD;AACrD,uCAAkH;AAClH,sDAA2D;AAa3D,uDAAoD;AAE7C,MAAM,oBAAoB,GAAiC,CAChE,SAAS,EACT,UAAU,EACV,OAAO,EACP,OAAO,EACP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,EAAE;gBACV;oBACE,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,gBAAK,CAAC,OAAO;oBACpB,UAAU,EAAE,IAAI;oBAChB,IAAI,EAAE,CAAA,MAAA,SAAS,CAAC,UAAU,0CAAE,MAAM,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;oBACrD,WAAW,EAAE,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,UAAU,EAAE,eAAe,CAAC;iBAC5E;aACF;YACD,KAAK,EAAE;gBACL;oBACE,UAAU,EAAE;wBACV,UAAU,SAAS,CAAC,SAAS,IAAI,gBAAgB,CAAC,CAAC,CAAC,IAAI,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,GACrG,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAChC,GAAG;qBACJ;iBACF;aACF;YACD,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,WAAW;oBACjB,UAAU,EAAE,CAAC,oBAAoB,CAAC;iBACnC;gBACD,+GAA+G;gBAC/G,GAAG,CAAC,SAAS,CAAC,IAAI,6CAA4B,IAAI,CAAC,SAAS;oBAC1D,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE,UAAU;4BAChB,UAAU,EAAE,CAAC,kCAAkC,CAAC;yBACjD;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ValueConverterImport } from \"@odata2ts/converter-runtime\";\r\nimport { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { OptionalKind, PropertyDeclarationStructure, Scope, SourceFile, VariableDeclarationKind } from \"ts-morph\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport {\r\n ComplexType,\r\n DataTypes,\r\n ModelType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { EntityBasedGeneratorFunction, GeneratorFunctionOptions } from \"../FactoryFunctionModel\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nexport const generateQueryObjects: EntityBasedGeneratorFunction = (\r\n dataModel,\r\n sourceFile,\r\n version,\r\n options,\r\n namingHelper\r\n) => {\r\n const generator = new QueryObjectGenerator(dataModel, sourceFile, version, options, namingHelper);\r\n return generator.generate();\r\n};\r\n\r\nclass QueryObjectGenerator {\r\n constructor(\r\n private dataModel: DataModel,\r\n private sourceFile: SourceFile,\r\n private version: ODataVersions,\r\n private options: GeneratorFunctionOptions,\r\n private namingHelper: NamingHelper\r\n ) {}\r\n\r\n public generate(): void {\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n this.generateModels(importContainer);\r\n if (!this.options.skipOperations) {\r\n this.generateUnboundOperations(importContainer);\r\n }\r\n\r\n this.sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\r\n }\r\n\r\n private generateModels(importContainer: ImportContainer) {\r\n this.dataModel.getModels().forEach((model) => {\r\n this.generateModel(model, importContainer);\r\n if (!this.options.skipIdModels) {\r\n this.generateIdFunction(model, importContainer);\r\n }\r\n if (!this.options.skipOperations) {\r\n this.generateBoundOperations(model.name, importContainer);\r\n }\r\n });\r\n this.dataModel.getComplexTypes().forEach((model) => {\r\n this.generateModel(model, importContainer);\r\n });\r\n\r\n if (this.dataModel.getModels().length || this.dataModel.getComplexTypes().length) {\r\n importContainer.addFromQObject(\"QueryObject\");\r\n }\r\n }\r\n\r\n private generateModel(model: ComplexType, importContainer: ImportContainer) {\r\n let extendsClause = \"QueryObject\";\r\n if (model.baseClasses.length) {\r\n const baseClass = model.baseClasses[0];\r\n const baseModel = this.dataModel.getModel(baseClass) || this.dataModel.getComplexType(baseClass);\r\n extendsClause = baseModel.qName;\r\n }\r\n\r\n this.sourceFile.addClass({\r\n name: model.qName,\r\n isExported: true,\r\n extends: extendsClause,\r\n properties: this.generateQueryObjectProps(model.props, importContainer),\r\n });\r\n\r\n this.sourceFile.addVariableStatement({\r\n declarationKind: VariableDeclarationKind.Const,\r\n isExported: true,\r\n declarations: [\r\n {\r\n name: firstCharLowerCase(model.qName),\r\n initializer: `new ${model.qName}()`,\r\n },\r\n ],\r\n });\r\n }\r\n\r\n private generateQueryObjectProps(\r\n props: Array<PropertyModel>,\r\n importContainer: ImportContainer\r\n ): Array<OptionalKind<PropertyDeclarationStructure>> {\r\n return props.map((prop) => {\r\n const { odataName } = prop;\r\n const name = this.namingHelper.getQPropName(prop.name);\r\n const isModelType = prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType;\r\n let qPathInit: string;\r\n\r\n // factor in collections\r\n if (prop.isCollection) {\r\n const cType = `Q${isModelType ? \"Entity\" : \"\"}CollectionPath`;\r\n const qObject = prop.qObject;\r\n\r\n if (!qObject) {\r\n throw new Error(\"QObject for collection is missing!\");\r\n }\r\n\r\n qPathInit = `new ${cType}(this.withPrefix(\"${odataName}\"), () => ${qObject})`;\r\n\r\n importContainer.addFromQObject(cType);\r\n if (!isModelType) {\r\n importContainer.addFromQObject(qObject);\r\n }\r\n } else {\r\n if (isModelType) {\r\n qPathInit = `new ${prop.qPath}(this.withPrefix(\"${odataName}\"), () => ${prop.qObject!})`;\r\n } else {\r\n let converterStmt = this.generateConverterStmt(prop.converters, importContainer);\r\n qPathInit = `new ${prop.qPath}(this.withPrefix(\"${odataName}\")${converterStmt ? `, ${converterStmt}` : \"\"})`;\r\n }\r\n // add import for data type\r\n importContainer.addFromQObject(prop.qPath);\r\n }\r\n\r\n return {\r\n name,\r\n scope: Scope.Public,\r\n isReadonly: true,\r\n initializer: qPathInit,\r\n } as OptionalKind<PropertyDeclarationStructure>;\r\n });\r\n }\r\n\r\n private generateConverterStmt(converters: Array<ValueConverterImport> | undefined, importContainer: ImportContainer) {\r\n if (!converters?.length) {\r\n return;\r\n }\r\n converters.forEach((converter) => {\r\n importContainer.addCustomType(converter.package, converter.converterId);\r\n });\r\n\r\n if (converters.length === 1) {\r\n return converters[0].converterId;\r\n } else {\r\n importContainer.addCustomType(\"@odata2ts/converter-runtime\", \"createChain\");\r\n\r\n const [first, second, ...moreConverters] = converters;\r\n return moreConverters.reduce(\r\n (stmt, conv) => `${stmt}.chain(${conv.converterId})`,\r\n `createChain(${first.converterId}, ${second.converterId})`\r\n );\r\n }\r\n }\r\n\r\n private generateIdFunction(model: ModelType, importContainer: ImportContainer) {\r\n if (!model.generateId) {\r\n return;\r\n }\r\n\r\n const qFunc = \"QId\";\r\n importContainer.addFromQObject(qFunc);\r\n importContainer.addGeneratedModel(model.idModelName);\r\n\r\n this.sourceFile.addClass({\r\n name: model.qIdFunctionName,\r\n isExported: true,\r\n extends: `${qFunc}<${model.idModelName}>`,\r\n properties: [\r\n {\r\n name: \"params\",\r\n scope: Scope.Private,\r\n isReadonly: true,\r\n initializer: this.getParamInitString(model.keys, importContainer),\r\n },\r\n ],\r\n methods: [\r\n {\r\n name: \"getParams\",\r\n statements: [\"return this.params\"],\r\n },\r\n ],\r\n });\r\n }\r\n\r\n private getParamInitString(props: Array<PropertyModel>, importContainer: ImportContainer) {\r\n return `[${props\r\n .map((prop) => {\r\n const isComplexParam = prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType;\r\n if (prop.qParam) {\r\n importContainer.addFromQObject(prop.qParam);\r\n }\r\n const isMappedNameNecessary = prop.odataName !== prop.name;\r\n const mappedName = isMappedNameNecessary ? `\"${prop.name}\"` : prop.converters?.length ? \"undefined\" : undefined;\r\n const converterStmt = this.generateConverterStmt(prop.converters, importContainer);\r\n const mappedNameParam = mappedName ? `, ${mappedName}` : \"\";\r\n const complexQParam = isComplexParam ? `, new ${prop.qObject}()` : \"\";\r\n const converterParam = converterStmt ? `, ${converterStmt}` : \"\";\r\n return `new ${prop.qParam}(\"${prop.odataName}\"${complexQParam}${mappedNameParam}${converterParam})`;\r\n })\r\n .join(\",\")}]`;\r\n }\r\n\r\n private generateUnboundOperations(importContainer: ImportContainer) {\r\n this.dataModel.getUnboundOperationTypes().forEach((operation) => {\r\n this.generateOperation(operation, importContainer);\r\n });\r\n }\r\n\r\n private generateBoundOperations(bindingName: string, importContainer: ImportContainer) {\r\n this.dataModel.getOperationTypeByEntityOrCollectionBinding(bindingName).forEach((operation) => {\r\n this.generateOperation(operation, importContainer);\r\n });\r\n }\r\n\r\n private generateOperation(operation: OperationType, importContainer: ImportContainer) {\r\n const isV2 = this.version === ODataVersions.V2;\r\n const qOperation = operation.type === OperationTypes.Action ? \"QAction\" : \"QFunction\";\r\n const returnType = operation.returnType;\r\n let returnTypeOpStmt: string = \"\";\r\n const hasParams = operation.parameters.length > 0;\r\n importContainer.addFromQObject(qOperation);\r\n if (hasParams) {\r\n importContainer.addGeneratedModel(operation.paramsModelName);\r\n }\r\n if (returnType) {\r\n if (returnType.dataType === DataTypes.ComplexType || returnType.dataType === DataTypes.ModelType) {\r\n if (returnType.qObject) {\r\n importContainer.addFromQObject(\"OperationReturnType\", \"ReturnTypes\", \"QComplexParam\");\r\n returnTypeOpStmt = `new OperationReturnType(ReturnTypes.COMPLEX${\r\n returnType.isCollection ? \"_COLLECTION\" : \"\"\r\n }, new QComplexParam(\"NONE\", new ${returnType.qObject}))`;\r\n }\r\n } else if (returnType.converters && returnType.qParam) {\r\n importContainer.addFromQObject(\"OperationReturnType\", \"ReturnTypes\", returnType.qParam);\r\n returnTypeOpStmt = `new OperationReturnType(ReturnTypes.VALUE${\r\n returnType.isCollection ? \"_COLLECTION\" : \"\"\r\n }, new ${returnType.qParam}(\"NONE\", undefined, ${this.generateConverterStmt(\r\n returnType.converters,\r\n importContainer\r\n )}))`;\r\n }\r\n }\r\n\r\n this.sourceFile.addClass({\r\n name: operation.qName,\r\n isExported: true,\r\n extends: qOperation + (hasParams ? `<${operation.paramsModelName}>` : \"\"),\r\n properties: [\r\n {\r\n name: \"params\",\r\n scope: Scope.Private,\r\n isReadonly: true,\r\n type: operation.parameters?.length ? undefined : \"[]\",\r\n initializer: this.getParamInitString(operation.parameters, importContainer),\r\n },\r\n ],\r\n ctors: [\r\n {\r\n statements: [\r\n `super(\"${operation.odataName}\"${returnTypeOpStmt ? \", \" + returnTypeOpStmt : isV2 ? \", undefined\" : \"\"}${\r\n isV2 ? \", { v2Mode: true }\" : \"\"\r\n })`,\r\n ],\r\n },\r\n ],\r\n methods: [\r\n {\r\n name: \"getParams\",\r\n statements: [\"return this.params\"],\r\n },\r\n // functions without params: add an overriding buildUrl() to not force users to have to pass undefined as param\r\n ...(operation.type === OperationTypes.Function && !hasParams\r\n ? [\r\n {\r\n name: \"buildUrl\",\r\n statements: [\"return super.buildUrl(undefined)\"],\r\n },\r\n ]\r\n : []),\r\n ],\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"QueryObjectGenerator.js","sourceRoot":"","sources":["../../src/generator/QueryObjectGenerator.ts"],"names":[],"mappings":";;;AACA,qDAAqD;AACrD,uCAAkH;AAClH,sDAA2D;AAa3D,uDAAoD;AAE7C,MAAM,oBAAoB,GAAiC,CAChE,SAAS,EACT,UAAU,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,EAAE;IACF,MAAM,SAAS,GAAG,IAAI,oBAAoB,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAClG,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC,CAAC;AATW,QAAA,oBAAoB,wBAS/B;AAEF,MAAM,oBAAoB;IACxB,YACU,SAAoB,EACpB,UAAsB,EACtB,OAAsB,EACtB,OAAiC,EACjC,YAA0B;QAJ1B,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAY;QACtB,YAAO,GAAP,OAAO,CAAe;QACtB,YAAO,GAAP,OAAO,CAA0B;QACjC,iBAAY,GAAZ,YAAY,CAAc;IACjC,C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AAe,CAAC;iBAC5E;aACF;YACD,KAAK,EAAE;gBACL;oBACE,UAAU,EAAE;wBACV,UAAU,SAAS,CAAC,SAAS,IAAI,gBAAgB,CAAC,CAAC,CAAC,IAAI,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,GACrG,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAChC,GAAG;qBACJ;iBACF;aACF;YACD,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,WAAW;oBACjB,UAAU,EAAE,CAAC,oBAAoB,CAAC;iBACnC;gBACD,+GAA+G;gBAC/G,GAAG,CAAC,SAAS,CAAC,IAAI,6CAA4B,IAAI,CAAC,SAAS;oBAC1D,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE,UAAU;4BAChB,UAAU,EAAE,CAAC,kCAAkC,CAAC;yBACjD;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ValueConverterImport } from \"@odata2ts/converter-runtime\";\r\nimport { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { OptionalKind, PropertyDeclarationStructure, Scope, SourceFile, VariableDeclarationKind } from \"ts-morph\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport {\r\n ComplexType,\r\n DataTypes,\r\n ModelType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { EntityBasedGeneratorFunction, GeneratorFunctionOptions } from \"../FactoryFunctionModel\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nexport const generateQueryObjects: EntityBasedGeneratorFunction = (\r\n dataModel,\r\n sourceFile,\r\n version,\r\n options,\r\n namingHelper\r\n) => {\r\n const generator = new QueryObjectGenerator(dataModel, sourceFile, version, options, namingHelper);\r\n return generator.generate();\r\n};\r\n\r\nclass QueryObjectGenerator {\r\n constructor(\r\n private dataModel: DataModel,\r\n private sourceFile: SourceFile,\r\n private version: ODataVersions,\r\n private options: GeneratorFunctionOptions,\r\n private namingHelper: NamingHelper\r\n ) {}\r\n\r\n public generate(): void {\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n this.generateModels(importContainer);\r\n if (!this.options.skipOperations) {\r\n this.generateUnboundOperations(importContainer);\r\n }\r\n\r\n this.sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\r\n }\r\n\r\n private generateModels(importContainer: ImportContainer) {\r\n this.dataModel.getModels().forEach((model) => {\r\n this.generateModel(model, importContainer);\r\n if (!this.options.skipIdModels) {\r\n this.generateIdFunction(model, importContainer);\r\n }\r\n if (!this.options.skipOperations) {\r\n this.generateBoundOperations(model.name, importContainer);\r\n }\r\n });\r\n this.dataModel.getComplexTypes().forEach((model) => {\r\n this.generateModel(model, importContainer);\r\n });\r\n\r\n if (this.dataModel.getModels().length || this.dataModel.getComplexTypes().length) {\r\n importContainer.addFromQObject(\"QueryObject\");\r\n }\r\n }\r\n\r\n private generateModel(model: ComplexType, importContainer: ImportContainer) {\r\n let extendsClause = \"QueryObject\";\r\n if (model.baseClasses.length) {\r\n const baseClass = model.baseClasses[0];\r\n const baseModel = this.dataModel.getModel(baseClass) || this.dataModel.getComplexType(baseClass);\r\n extendsClause = baseModel.qName;\r\n }\r\n\r\n this.sourceFile.addClass({\r\n name: model.qName,\r\n isExported: true,\r\n extends: extendsClause,\r\n properties: this.generateQueryObjectProps(model.props, importContainer),\r\n });\r\n\r\n this.sourceFile.addVariableStatement({\r\n declarationKind: VariableDeclarationKind.Const,\r\n isExported: true,\r\n declarations: [\r\n {\r\n name: firstCharLowerCase(model.qName),\r\n initializer: `new ${model.qName}()`,\r\n },\r\n ],\r\n });\r\n }\r\n\r\n private generateQueryObjectProps(\r\n props: Array<PropertyModel>,\r\n importContainer: ImportContainer\r\n ): Array<OptionalKind<PropertyDeclarationStructure>> {\r\n return props.map((prop) => {\r\n const { odataName } = prop;\r\n const name = this.namingHelper.getQPropName(prop.name);\r\n const isModelType = prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType;\r\n let qPathInit: string;\r\n\r\n // factor in collections\r\n if (prop.isCollection) {\r\n const cType = `Q${isModelType ? \"Entity\" : \"\"}CollectionPath`;\r\n const qObject = prop.qObject;\r\n\r\n if (!qObject) {\r\n throw new Error(\"QObject for collection is missing!\");\r\n }\r\n\r\n qPathInit = `new ${cType}(this.withPrefix(\"${odataName}\"), () => ${qObject})`;\r\n\r\n importContainer.addFromQObject(cType);\r\n if (!isModelType) {\r\n importContainer.addFromQObject(qObject);\r\n }\r\n } else {\r\n if (isModelType) {\r\n qPathInit = `new ${prop.qPath}(this.withPrefix(\"${odataName}\"), () => ${prop.qObject!})`;\r\n } else {\r\n let converterStmt = this.generateConverterStmt(prop.converters, importContainer);\r\n qPathInit = `new ${prop.qPath}(this.withPrefix(\"${odataName}\")${converterStmt ? `, ${converterStmt}` : \"\"})`;\r\n }\r\n // add import for data type\r\n importContainer.addFromQObject(prop.qPath);\r\n }\r\n\r\n return {\r\n name,\r\n scope: Scope.Public,\r\n isReadonly: true,\r\n initializer: qPathInit,\r\n } as OptionalKind<PropertyDeclarationStructure>;\r\n });\r\n }\r\n\r\n private generateConverterStmt(converters: Array<ValueConverterImport> | undefined, importContainer: ImportContainer) {\r\n if (!converters?.length) {\r\n return;\r\n }\r\n converters.forEach((converter) => {\r\n importContainer.addCustomType(converter.package, converter.converterId);\r\n });\r\n\r\n if (converters.length === 1) {\r\n return converters[0].converterId;\r\n } else {\r\n importContainer.addCustomType(\"@odata2ts/converter-runtime\", \"createChain\");\r\n\r\n const [first, second, ...moreConverters] = converters;\r\n return moreConverters.reduce(\r\n (stmt, conv) => `${stmt}.chain(${conv.converterId})`,\r\n `createChain(${first.converterId}, ${second.converterId})`\r\n );\r\n }\r\n }\r\n\r\n private generateIdFunction(model: ModelType, importContainer: ImportContainer) {\r\n if (!model.generateId) {\r\n return;\r\n }\r\n\r\n const qFunc = \"QId\";\r\n importContainer.addFromQObject(qFunc);\r\n importContainer.addGeneratedModel(model.idModelName);\r\n\r\n this.sourceFile.addClass({\r\n name: model.qIdFunctionName,\r\n isExported: true,\r\n extends: `${qFunc}<${model.idModelName}>`,\r\n properties: [\r\n {\r\n name: \"params\",\r\n scope: Scope.Private,\r\n isReadonly: true,\r\n initializer: this.getParamInitString(model.keys, importContainer),\r\n },\r\n ],\r\n methods: [\r\n {\r\n name: \"getParams\",\r\n statements: [\"return this.params\"],\r\n },\r\n ],\r\n });\r\n }\r\n\r\n private getParamInitString(props: Array<PropertyModel>, importContainer: ImportContainer) {\r\n return `[${props\r\n .map((prop) => {\r\n const isComplexParam = prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType;\r\n if (prop.qParam) {\r\n importContainer.addFromQObject(prop.qParam);\r\n }\r\n const isMappedNameNecessary = prop.odataName !== prop.name;\r\n const mappedName = isMappedNameNecessary ? `\"${prop.name}\"` : prop.converters?.length ? \"undefined\" : undefined;\r\n const converterStmt = this.generateConverterStmt(prop.converters, importContainer);\r\n const mappedNameParam = mappedName ? `, ${mappedName}` : \"\";\r\n const complexQParam = isComplexParam ? `, new ${prop.qObject}()` : \"\";\r\n const converterParam = converterStmt ? `, ${converterStmt}` : \"\";\r\n return `new ${prop.qParam}(\"${prop.odataName}\"${complexQParam}${mappedNameParam}${converterParam})`;\r\n })\r\n .join(\",\")}]`;\r\n }\r\n\r\n private generateUnboundOperations(importContainer: ImportContainer) {\r\n this.dataModel.getUnboundOperationTypes().forEach((operation) => {\r\n this.generateOperation(operation, importContainer);\r\n });\r\n }\r\n\r\n private generateBoundOperations(bindingName: string, importContainer: ImportContainer) {\r\n this.dataModel.getOperationTypeByEntityOrCollectionBinding(bindingName).forEach((operation) => {\r\n this.generateOperation(operation, importContainer);\r\n });\r\n }\r\n\r\n private generateOperation(operation: OperationType, importContainer: ImportContainer) {\r\n const isV2 = this.version === ODataVersions.V2;\r\n const qOperation = operation.type === OperationTypes.Action ? \"QAction\" : \"QFunction\";\r\n const returnType = operation.returnType;\r\n let returnTypeOpStmt: string = \"\";\r\n const hasParams = operation.parameters.length > 0;\r\n importContainer.addFromQObject(qOperation);\r\n if (hasParams) {\r\n importContainer.addGeneratedModel(operation.paramsModelName);\r\n }\r\n if (returnType) {\r\n if (returnType.dataType === DataTypes.ComplexType || returnType.dataType === DataTypes.ModelType) {\r\n if (returnType.qObject) {\r\n importContainer.addFromQObject(\"OperationReturnType\", \"ReturnTypes\", \"QComplexParam\");\r\n returnTypeOpStmt = `new OperationReturnType(ReturnTypes.COMPLEX${\r\n returnType.isCollection ? \"_COLLECTION\" : \"\"\r\n }, new QComplexParam(\"NONE\", new ${returnType.qObject}))`;\r\n }\r\n }\r\n // currently, it only makes sense to add the OperationReturnType if a converter is present\r\n else if (returnType.converters && returnType.qParam) {\r\n importContainer.addFromQObject(\"OperationReturnType\", \"ReturnTypes\", returnType.qParam);\r\n const rtKind = \"ReturnTypes.VALUE\" + (returnType.isCollection ? \"_COLLECTION\" : \"\");\r\n const converterParam = returnType.converters\r\n ? \", \" + this.generateConverterStmt(returnType.converters, importContainer)\r\n : \"\";\r\n returnTypeOpStmt = `new OperationReturnType(${rtKind}, new ${returnType.qParam}(\"NONE\", undefined${converterParam}))`;\r\n }\r\n }\r\n\r\n this.sourceFile.addClass({\r\n name: operation.qName,\r\n isExported: true,\r\n extends: qOperation + (hasParams ? `<${operation.paramsModelName}>` : \"\"),\r\n properties: [\r\n {\r\n name: \"params\",\r\n scope: Scope.Private,\r\n isReadonly: true,\r\n type: operation.parameters?.length ? undefined : \"[]\",\r\n initializer: this.getParamInitString(operation.parameters, importContainer),\r\n },\r\n ],\r\n ctors: [\r\n {\r\n statements: [\r\n `super(\"${operation.odataName}\"${returnTypeOpStmt ? \", \" + returnTypeOpStmt : isV2 ? \", undefined\" : \"\"}${\r\n isV2 ? \", { v2Mode: true }\" : \"\"\r\n })`,\r\n ],\r\n },\r\n ],\r\n methods: [\r\n {\r\n name: \"getParams\",\r\n statements: [\"return this.params\"],\r\n },\r\n // functions without params: add an overriding buildUrl() to not force users to have to pass undefined as param\r\n ...(operation.type === OperationTypes.Function && !hasParams\r\n ? [\r\n {\r\n name: \"buildUrl\",\r\n statements: [\"return super.buildUrl(undefined)\"],\r\n },\r\n ]\r\n : []),\r\n ],\r\n });\r\n }\r\n}\r\n"]}
@@ -2,7 +2,10 @@ import { ODataVersions } from "@odata2ts/odata-core";
2
2
  import { ClassDeclarationStructure } from "ts-morph";
3
3
  import { DataModel } from "../data-model/DataModel";
4
4
  import { NamingHelper } from "../data-model/NamingHelper";
5
+ import { ConfigFileOptions } from "../OptionModel";
5
6
  import { ProjectManager } from "../project/ProjectManager";
6
7
  export interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, "properties" | "methods">> {
7
8
  }
8
- export declare function generateServices(dataModel: DataModel, project: ProjectManager, version: ODataVersions, namingHelper: NamingHelper, v4BigNumberAsString?: boolean): Promise<void>;
9
+ export interface ServiceGeneratorOptions extends Pick<ConfigFileOptions, "enablePrimitivePropertyServices" | "v4BigNumberAsString"> {
10
+ }
11
+ export declare function generateServices(dataModel: DataModel, project: ProjectManager, version: ODataVersions, namingHelper: NamingHelper, options?: ServiceGeneratorOptions): Promise<void>;
@@ -14,20 +14,20 @@ const RESPONSE_TYPES = {
14
14
  model: "ODataModelResponse",
15
15
  value: "ODataValueResponse",
16
16
  };
17
- function generateServices(dataModel, project, version, namingHelper, v4BigNumberAsString = false) {
17
+ function generateServices(dataModel, project, version, namingHelper, options) {
18
18
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
- const generator = new ServiceGenerator(dataModel, project, version, namingHelper, v4BigNumberAsString);
19
+ const generator = new ServiceGenerator(dataModel, project, version, namingHelper, options);
20
20
  return generator.generate();
21
21
  });
22
22
  }
23
23
  exports.generateServices = generateServices;
24
24
  class ServiceGenerator {
25
- constructor(dataModel, project, version, namingHelper, v4BigNumberAsString) {
25
+ constructor(dataModel, project, version, namingHelper, options = {}) {
26
26
  this.dataModel = dataModel;
27
27
  this.project = project;
28
28
  this.version = version;
29
29
  this.namingHelper = namingHelper;
30
- this.v4BigNumberAsString = v4BigNumberAsString;
30
+ this.options = options;
31
31
  this.generateQOperationProp = (operation) => {
32
32
  return {
33
33
  scope: ts_morph_1.Scope.Private,
@@ -38,7 +38,7 @@ class ServiceGenerator {
38
38
  };
39
39
  }
40
40
  isV4BigNumber() {
41
- return this.v4BigNumberAsString && this.version === odata_core_1.ODataVersions.V4;
41
+ return this.options.v4BigNumberAsString && this.version === odata_core_1.ODataVersions.V4;
42
42
  }
43
43
  generate() {
44
44
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -131,9 +131,10 @@ class ServiceGenerator {
131
131
  ],
132
132
  statements: [
133
133
  `const fieldName = "${odataPropName}";`,
134
+ `const { client, path } = this.__base;`,
134
135
  'return typeof id === "undefined" || id === null',
135
- `? new ${collectionName}(this.client, this.getPath(), fieldName)`,
136
- `: new ${serviceName}(this.client, this.getPath(), new ${idFunctionName}(fieldName).buildUrl(id));`,
136
+ `? new ${collectionName}(client, path, fieldName)`,
137
+ `: new ${serviceName}(client, path, new ${idFunctionName}(fieldName).buildUrl(id));`,
137
138
  ],
138
139
  };
139
140
  }
@@ -157,8 +158,9 @@ class ServiceGenerator {
157
158
  name: this.namingHelper.getRelatedServiceGetter(name),
158
159
  statements: [
159
160
  `if(!${propName}) {`,
161
+ ` const { client, path } = this.__base;`,
160
162
  // prettier-ignore
161
- ` ${propName} = new ${serviceType}(this.client, this.getPath(), "${odataName}")`,
163
+ ` ${propName} = new ${serviceType}(client, path, "${odataName}")`,
162
164
  "}",
163
165
  `return ${propName}`,
164
166
  ],
@@ -200,6 +202,9 @@ class ServiceGenerator {
200
202
  });
201
203
  });
202
204
  }
205
+ getPrimitiveServiceType() {
206
+ return "PrimitiveTypeService" + this.getVersionSuffix();
207
+ }
203
208
  generateServiceProperties(serviceName, props, importContainer) {
204
209
  const collectionServiceType = "CollectionService" + this.getVersionSuffix();
205
210
  const result = { properties: [], methods: [] };
@@ -220,6 +225,10 @@ class ServiceGenerator {
220
225
  result.methods.push(this.generatePrimitiveCollectionGetter(prop, collectionServiceType));
221
226
  }
222
227
  }
228
+ else if (this.options.enablePrimitivePropertyServices && prop.dataType === "PrimitiveType" /* DataTypes.PrimitiveType */) {
229
+ result.properties.push(this.generatePrimitiveTypeProp(prop, importContainer));
230
+ result.methods.push(this.generatePrimitiveTypeGetter(prop));
231
+ }
223
232
  });
224
233
  return result;
225
234
  }
@@ -280,6 +289,19 @@ class ServiceGenerator {
280
289
  hasQuestionToken: true,
281
290
  };
282
291
  }
292
+ generatePrimitiveTypeProp(prop, importContainer) {
293
+ const serviceType = this.getPrimitiveServiceType();
294
+ importContainer.addFromService(serviceType);
295
+ if (prop.typeModule) {
296
+ importContainer.addCustomType(prop.typeModule, prop.type);
297
+ }
298
+ return {
299
+ scope: ts_morph_1.Scope.Private,
300
+ name: this.namingHelper.getPrivatePropName(prop.name),
301
+ type: `${serviceType}<ClientType, ${prop.type}>`,
302
+ hasQuestionToken: true,
303
+ };
304
+ }
283
305
  generateModelPropGetter(prop, collectionServiceType) {
284
306
  const complexType = this.dataModel.getComplexType(prop.type);
285
307
  const isComplexCollection = prop.isCollection && complexType;
@@ -298,8 +320,9 @@ class ServiceGenerator {
298
320
  returnType: typeWithGenerics,
299
321
  statements: [
300
322
  `if(!${privateSrvProp}) {`,
323
+ ` const { client, path } = this.__base;`,
301
324
  // prettier-ignore
302
- ` ${privateSrvProp} = new ${type}(this.client, this.getPath(), "${prop.odataName}"${isComplexCollection ? `, ${(0, processors_1.firstCharLowerCase)(complexType.qName)}` : ""})`,
325
+ ` ${privateSrvProp} = new ${type}(client, path, "${prop.odataName}"${isComplexCollection ? `, ${(0, processors_1.firstCharLowerCase)(complexType.qName)}` : ""})`,
303
326
  "}",
304
327
  `return ${privateSrvProp}`,
305
328
  ],
@@ -312,8 +335,29 @@ class ServiceGenerator {
312
335
  name: this.namingHelper.getRelatedServiceGetter(prop.name),
313
336
  statements: [
314
337
  `if(!${propName}) {`,
338
+ ` const { client, path } = this.__base;`,
315
339
  // prettier-ignore
316
- ` ${propName} = new ${collectionServiceType}(this.client, this.getPath(), "${prop.odataName}", ${(0, processors_1.firstCharLowerCase)(prop.qObject)}${this.isV4BigNumber() ? ", true" : ""})`,
340
+ ` ${propName} = new ${collectionServiceType}(client, path, "${prop.odataName}", ${(0, processors_1.firstCharLowerCase)(prop.qObject)}${this.isV4BigNumber() ? ", true" : ""})`,
341
+ "}",
342
+ `return ${propName}`,
343
+ ],
344
+ };
345
+ }
346
+ generatePrimitiveTypeGetter(prop) {
347
+ const serviceType = this.getPrimitiveServiceType();
348
+ const propName = "this." + this.namingHelper.getPrivatePropName(prop.name);
349
+ // for V2: mapped name must be specified
350
+ const useMappedName = this.version === odata_core_1.ODataVersions.V2 && prop.name !== prop.odataName;
351
+ // for V4: big number support
352
+ const useBigNumber = this.isV4BigNumber();
353
+ const addParamString = useMappedName ? `, "${prop.name}"` : useBigNumber ? ", true" : "";
354
+ return {
355
+ scope: ts_morph_1.Scope.Public,
356
+ name: this.namingHelper.getRelatedServiceGetter(prop.name),
357
+ statements: [
358
+ `if(!${propName}) {`,
359
+ ` const { client, path, qModel } = this.__base;`,
360
+ ` ${propName} = new ${serviceType}(client, path, "${prop.odataName}", qModel.${prop.name}.converter${addParamString})`,
317
361
  "}",
318
362
  `return ${propName}`,
319
363
  ],
@@ -416,15 +460,16 @@ class ServiceGenerator {
416
460
  `if(!${qOpProp}) {`,
417
461
  ` ${qOpProp} = new ${operation.qName}()`,
418
462
  "}",
419
- `const url = this.addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? "params" : ""}));`,
420
- `${returnType ? "const response = await " : "return"} this.client.${!isFunc
463
+ `const { addFullPath, client, getDefaultHeaders } = this.__base;`,
464
+ `const url = addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? "params" : ""}));`,
465
+ `${returnType ? "const response = await " : "return"} client.${!isFunc
421
466
  ? // actions: since V4
422
- `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : "{}"}, ${requestConfigParam.name})`
467
+ `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : "{}"}, ${requestConfigParam.name}, getDefaultHeaders())`
423
468
  : operation.usePost
424
469
  ? // V2 POST => BUT values are still query params, they are not part of the request body
425
- `post(url, undefined, ${requestConfigParam.name})`
470
+ `post(url, undefined, ${requestConfigParam.name}, getDefaultHeaders())`
426
471
  : // functions: since V2
427
- `get(url, ${requestConfigParam.name})`};`,
472
+ `get(url, ${requestConfigParam.name}, getDefaultHeaders())`};`,
428
473
  returnType ? `return ${qOpProp}.convertResponse(response);` : "",
429
474
  ],
430
475
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,kEAAkC;AAClC,uCAOkB;AAClB,uDAAkD;AAClD,sDAA2D;AAiB3D,uDAAoD;AAEpD,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,cAAc,GAAG;IACrB,UAAU,EAAE,yBAAyB;IACrC,KAAK,EAAE,oBAAoB;IAC3B,KAAK,EAAE,oBAAoB;CAC5B,CAAC;AAIF,SAAsB,gBAAgB,CACpC,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B,EAC1B,sBAA+B,KAAK;;QAEpC,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC;QACvG,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;CAAA;AATD,4CASC;AAED,MAAM,gBAAgB;IACpB,YACU,SAAoB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["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport deepmerge from \"deepmerge\";\r\nimport {\r\n ClassDeclarationStructure,\r\n MethodDeclarationStructure,\r\n OptionalKind,\r\n PropertyDeclarationStructure,\r\n Scope,\r\n SourceFile,\r\n} from \"ts-morph\";\r\nimport { upperCaseFirst } from \"upper-case-first\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport {\r\n ActionImportType,\r\n ComplexType,\r\n DataTypes,\r\n EntityContainerModel,\r\n FunctionImportType,\r\n ModelType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n SingletonType,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { ProjectManager } from \"../project/ProjectManager\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nconst ROOT_SERVICE = \"ODataService\";\r\n\r\nconst RESPONSE_TYPES = {\r\n collection: \"ODataCollectionResponse\",\r\n model: \"ODataModelResponse\",\r\n value: \"ODataValueResponse\",\r\n};\r\n\r\nexport interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, \"properties\" | \"methods\">> {}\r\n\r\nexport async function generateServices(\r\n dataModel: DataModel,\r\n project: ProjectManager,\r\n version: ODataVersions,\r\n namingHelper: NamingHelper,\r\n v4BigNumberAsString: boolean = false\r\n) {\r\n const generator = new ServiceGenerator(dataModel, project, version, namingHelper, v4BigNumberAsString);\r\n return generator.generate();\r\n}\r\n\r\nclass ServiceGenerator {\r\n constructor(\r\n private dataModel: DataModel,\r\n private project: ProjectManager,\r\n private version: ODataVersions,\r\n private namingHelper: NamingHelper,\r\n private v4BigNumberAsString: boolean\r\n ) {}\r\n\r\n private isV4BigNumber() {\r\n return this.v4BigNumberAsString && this.version === ODataVersions.V4;\r\n }\r\n\r\n public async generate(): Promise<void> {\r\n const sourceFile = await this.project.createMainServiceFile();\r\n const serviceName = this.namingHelper.getMainServiceName();\r\n const container = this.dataModel.getEntityContainer();\r\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\r\n\r\n await this.generateModelServices();\r\n\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n importContainer.addFromClientApi(\"ODataHttpClient\");\r\n importContainer.addFromService(ROOT_SERVICE);\r\n\r\n const { properties, methods }: PropsAndOps = deepmerge(\r\n this.generateMainServiceProperties(container, importContainer),\r\n this.generateMainServiceOperations(unboundOperations, importContainer)\r\n );\r\n\r\n sourceFile.addClass({\r\n isExported: true,\r\n name: serviceName,\r\n typeParameters: [\"ClientType extends ODataHttpClient\"],\r\n extends: `${ROOT_SERVICE}<ClientType>`,\r\n 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 sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\r\n }\r\n\r\n private generateMainServiceProperties(\r\n container: EntityContainerModel,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n Object.values(container.entitySets).forEach(({ name, 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(singleton, importContainer));\r\n result.methods.push(this.generateSingletonGetter(singleton));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateMainServiceOperations(\r\n ops: Array<FunctionImportType | ActionImportType>,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n ops.forEach(({ operation, name }) => {\r\n result.properties.push(this.generateQOperationProp(operation));\r\n result.methods.push(this.generateMethod(name, operation, importContainer));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateRelatedServiceGetter(\r\n propName: string,\r\n odataPropName: string,\r\n entityType: ModelType,\r\n importContainer: ImportContainer,\r\n currentServiceName?: string\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const idName = entityType.idModelName;\r\n const idFunctionName = entityType.qIdFunctionName;\r\n const serviceName = this.namingHelper.getServiceName(entityType.name);\r\n const collectionName = this.namingHelper.getCollectionServiceName(entityType.name);\r\n\r\n importContainer.addFromClientApi(\"ODataHttpClient\");\r\n importContainer.addGeneratedModel(idName);\r\n importContainer.addGeneratedQObject(idFunctionName);\r\n // make sure to not falsely import self-referential stuff\r\n if (!currentServiceName || currentServiceName !== serviceName) {\r\n importContainer.addGeneratedService(serviceName, collectionName, serviceName);\r\n }\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(propName),\r\n parameters: [\r\n {\r\n name: \"id\",\r\n type: `${idName} | undefined`,\r\n hasQuestionToken: true,\r\n },\r\n ],\r\n overloads: [\r\n {\r\n parameters: [],\r\n returnType: `${collectionName}<ClientType>`,\r\n },\r\n {\r\n parameters: [\r\n {\r\n name: \"id\",\r\n type: idName,\r\n },\r\n ],\r\n returnType: `${serviceName}<ClientType>`,\r\n },\r\n ],\r\n statements: [\r\n `const fieldName = \"${odataPropName}\";`,\r\n 'return typeof id === \"undefined\" || id === null',\r\n `? new ${collectionName}(this.client, this.getPath(), fieldName)`,\r\n `: new ${serviceName}(this.client, this.getPath(), new ${idFunctionName}(fieldName).buildUrl(id));`,\r\n ],\r\n };\r\n }\r\n\r\n private generateSingletonProp(\r\n singleton: SingletonType,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const { name, entityType } = singleton;\r\n const type = this.namingHelper.getServiceName(entityType.name);\r\n\r\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), type);\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(name),\r\n type: `${type}<ClientType>`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generateQOperationProp = (operation: OperationType) => {\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(operation.qName),\r\n type: operation.qName,\r\n hasQuestionToken: true,\r\n };\r\n };\r\n\r\n private generateSingletonGetter(singleton: SingletonType): OptionalKind<MethodDeclarationStructure> {\r\n const { name, odataName, entityType } = singleton;\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\r\n const serviceType = this.namingHelper.getServiceName(entityType.name);\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n // prettier-ignore\r\n ` ${propName} = new ${serviceType}(this.client, this.getPath(), \"${odataName}\")`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private getVersionSuffix() {\r\n return this.version === ODataVersions.V2 ? \"V2\" : \"V4\";\r\n }\r\n\r\n private async generateEntityTypeService(\r\n model: ComplexType,\r\n serviceName: string,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const entityServiceType = \"EntityTypeService\" + this.getVersionSuffix();\r\n\r\n const editableModelName = model.editableName;\r\n const qObjectName = firstCharLowerCase(model.qName);\r\n const operations = this.dataModel.getOperationTypeByBinding(model.name);\r\n const props = [...model.baseProps, ...model.props];\r\n\r\n importContainer.addFromService(entityServiceType);\r\n importContainer.addFromClientApi(\"ODataHttpClient\");\r\n importContainer.addGeneratedModel(model.name, editableModelName);\r\n importContainer.addGeneratedQObject(model.qName, qObjectName);\r\n\r\n const { properties, methods }: PropsAndOps = deepmerge(\r\n this.generateServiceProperties(serviceName, props, importContainer),\r\n this.generateServiceOperations(operations, importContainer)\r\n );\r\n\r\n // generate EntityTypeService\r\n serviceFile.addClass({\r\n isExported: true,\r\n name: serviceName,\r\n typeParameters: [\"ClientType extends ODataHttpClient\"],\r\n extends: entityServiceType + `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [`super(client, basePath, name, ${qObjectName}${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 serviceName: string,\r\n props: Array<PropertyModel>,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const collectionServiceType = \"CollectionService\" + this.getVersionSuffix();\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n props.forEach((prop) => {\r\n if ((prop.dataType === DataTypes.ModelType && !prop.isCollection) || prop.dataType === DataTypes.ComplexType) {\r\n result.properties.push(this.generateModelProp(prop, collectionServiceType, serviceName, importContainer));\r\n result.methods.push(this.generateModelPropGetter(prop, collectionServiceType));\r\n } else if (prop.isCollection) {\r\n // collection of entity types\r\n if (prop.dataType === DataTypes.ModelType) {\r\n const entityType = this.dataModel.getModel(prop.type);\r\n result.methods.push(\r\n this.generateRelatedServiceGetter(prop.name, prop.odataName, entityType, importContainer, serviceName)\r\n );\r\n }\r\n // collection of primitive or complex types\r\n else {\r\n result.properties.push(this.generatePrimitiveCollectionProp(prop, collectionServiceType, importContainer));\r\n result.methods.push(this.generatePrimitiveCollectionGetter(prop, collectionServiceType));\r\n }\r\n }\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateServiceOperations(operations: Array<OperationType>, importContainer: ImportContainer): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n operations.forEach((operation) => {\r\n result.properties.push(this.generateQOperationProp(operation));\r\n result.methods.push(this.generateMethod(operation.name, operation, importContainer));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateModelProp(\r\n prop: PropertyModel,\r\n collectionServiceType: string,\r\n serviceName: string,\r\n importContainer: ImportContainer\r\n ): PropertyDeclarationStructure {\r\n const complexType = this.dataModel.getComplexType(prop.type);\r\n const key = this.namingHelper.getServiceName(prop.type);\r\n let propModelType = prop.isCollection ? this.namingHelper.getCollectionServiceName(prop.type) : key;\r\n\r\n if (prop.isCollection && complexType) {\r\n const editableName = complexType.editableName;\r\n importContainer.addFromService(collectionServiceType);\r\n importContainer.addGeneratedModel(complexType.name, editableName);\r\n importContainer.addGeneratedQObject(complexType.qName, firstCharLowerCase(complexType.qName));\r\n propModelType = `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${editableName}>`;\r\n } else {\r\n // don't include imports for this type\r\n if (serviceName !== key) {\r\n importContainer.addGeneratedService(key, propModelType);\r\n }\r\n\r\n propModelType = `${propModelType}<ClientType>`;\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: propModelType,\r\n hasQuestionToken: true,\r\n } as PropertyDeclarationStructure;\r\n }\r\n\r\n private generatePrimitiveCollectionProp(\r\n prop: PropertyModel,\r\n collectionServiceType: string,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const isEnum = prop.dataType === DataTypes.EnumType;\r\n const type = isEnum ? `EnumCollection<${prop.type}>` : `${upperCaseFirst(prop.type)}Collection`;\r\n const qType = isEnum ? \"QEnumCollection\" : prop.qObject;\r\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\r\n\r\n if (!prop.qObject) {\r\n throw new Error(\"Illegal State: [qObject] must be provided for Collection types!\");\r\n }\r\n\r\n importContainer.addFromService(collectionServiceType);\r\n importContainer.addFromQObject(prop.qObject, firstCharLowerCase(prop.qObject));\r\n if (isEnum) {\r\n importContainer.addGeneratedModel(prop.type);\r\n importContainer.addFromQObject(\"EnumCollection\");\r\n } else {\r\n importContainer.addFromQObject(type);\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: `${collectionType}`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generateModelPropGetter(\r\n prop: PropertyModel,\r\n collectionServiceType: string\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const complexType = this.dataModel.getComplexType(prop.type);\r\n const isComplexCollection = prop.isCollection && complexType;\r\n const type = isComplexCollection\r\n ? collectionServiceType\r\n : prop.isCollection\r\n ? this.namingHelper.getCollectionServiceName(prop.type)\r\n : this.namingHelper.getServiceName(prop.type);\r\n const typeWithGenerics = isComplexCollection\r\n ? `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${complexType.editableName}>`\r\n : `${type}<ClientType>`;\r\n\r\n const privateSrvProp = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n returnType: typeWithGenerics,\r\n statements: [\r\n `if(!${privateSrvProp}) {`,\r\n // prettier-ignore\r\n ` ${privateSrvProp} = new ${type}(this.client, this.getPath(), \"${prop.odataName}\"${isComplexCollection ? `, ${firstCharLowerCase(complexType.qName)}`: \"\"})`,\r\n \"}\",\r\n `return ${privateSrvProp}`,\r\n ],\r\n };\r\n }\r\n\r\n private generatePrimitiveCollectionGetter(\r\n prop: PropertyModel,\r\n collectionServiceType: string\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n // prettier-ignore\r\n ` ${propName} = new ${collectionServiceType}(this.client, this.getPath(), \"${prop.odataName}\", ${firstCharLowerCase(prop.qObject!)}${this.isV4BigNumber() ? \", true\": \"\"})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private async generateEntityCollectionService(\r\n model: ModelType,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const entitySetServiceType = \"EntitySetService\" + this.getVersionSuffix();\r\n const editableModelName = model.editableName;\r\n const qObjectName = firstCharLowerCase(model.qName);\r\n\r\n importContainer.addFromService(entitySetServiceType);\r\n importContainer.addGeneratedModel(model.idModelName);\r\n importContainer.addGeneratedQObject(model.qIdFunctionName);\r\n\r\n const collectionOperations = this.dataModel.getOperationTypeByBinding(`Collection(${model.name})`);\r\n\r\n const { properties, methods } = this.generateServiceOperations(collectionOperations, importContainer);\r\n\r\n serviceFile.addClass({\r\n isExported: true,\r\n name: this.namingHelper.getCollectionServiceName(model.name),\r\n typeParameters: [\"ClientType extends ODataHttpClient\"],\r\n extends:\r\n entitySetServiceType +\r\n `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}, ${model.idModelName}>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [\r\n `super(client, basePath, name, ${qObjectName}, new ${model.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 async generateModelServices() {\r\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\r\n for (const model of this.dataModel.getModels()) {\r\n const serviceName = this.namingHelper.getServiceName(model.name);\r\n const serviceFile = await this.project.createServiceFile(serviceName);\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n // entity type service\r\n await this.generateEntityTypeService(model, serviceName, serviceFile, importContainer);\r\n\r\n // entity collection service\r\n await this.generateEntityCollectionService(model, serviceFile, importContainer);\r\n\r\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\r\n }\r\n\r\n // build service file for complex types\r\n for (const model of this.dataModel.getComplexTypes()) {\r\n const serviceName = this.namingHelper.getServiceName(model.name);\r\n const serviceFile = await this.project.createServiceFile(serviceName);\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n // entity type service\r\n await this.generateEntityTypeService(model, serviceName, serviceFile, importContainer);\r\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\r\n }\r\n }\r\n\r\n private generateMethod(\r\n name: string,\r\n operation: OperationType,\r\n importContainer: ImportContainer\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const isFunc = operation.type === OperationTypes.Function;\r\n const odataType = operation.returnType?.isCollection\r\n ? RESPONSE_TYPES.collection + this.getVersionSuffix()\r\n : operation.returnType?.dataType === DataTypes.PrimitiveType\r\n ? RESPONSE_TYPES.value + this.getVersionSuffix()\r\n : RESPONSE_TYPES.model + this.getVersionSuffix();\r\n const returnType = operation.returnType;\r\n const requestConfigParam = {\r\n name: \"requestConfig\",\r\n hasQuestionToken: true,\r\n type: \"ODataHttpClientConfig<ClientType>\",\r\n };\r\n const hasParams = operation.parameters.length > 0;\r\n\r\n // importing dependencies\r\n importContainer.addFromClientApi(\"ODataHttpClientConfig\", \"ODataResponse\");\r\n importContainer.addFromCore(odataType);\r\n if (returnType?.type) {\r\n if ([DataTypes.EnumType, DataTypes.ModelType, DataTypes.ComplexType].includes(returnType.dataType)) {\r\n importContainer.addGeneratedModel(returnType.type);\r\n }\r\n }\r\n importContainer.addGeneratedQObject(operation.qName);\r\n if (hasParams) {\r\n importContainer.addGeneratedModel(operation.paramsModelName);\r\n }\r\n\r\n const qOpProp = \"this.\" + this.namingHelper.getPrivatePropName(operation.qName);\r\n\r\n return {\r\n scope: Scope.Public,\r\n isAsync: true,\r\n name,\r\n parameters: hasParams\r\n ? [{ name: \"params\", type: operation.paramsModelName }, requestConfigParam]\r\n : [requestConfigParam],\r\n returnType: `ODataResponse<${odataType}<${returnType?.type || \"void\"}>>`,\r\n statements: [\r\n `if(!${qOpProp}) {`,\r\n ` ${qOpProp} = new ${operation.qName}()`,\r\n \"}\",\r\n\r\n `const url = this.addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params\" : \"\"}));`,\r\n `${returnType ? \"const response = await \" : \"return\"} this.client.${\r\n !isFunc\r\n ? // actions: since V4\r\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${requestConfigParam.name})`\r\n : operation.usePost\r\n ? // V2 POST => BUT values are still query params, they are not part of the request body\r\n `post(url, undefined, ${requestConfigParam.name})`\r\n : // functions: since V2\r\n `get(url, ${requestConfigParam.name})`\r\n };`,\r\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\r\n ],\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,kEAAkC;AAClC,uCAOkB;AAClB,uDAAkD;AAClD,sDAA2D;AAkB3D,uDAAoD;AAEpD,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,cAAc,GAAG;IACrB,UAAU,EAAE,yBAAyB;IACrC,KAAK,EAAE,oBAAoB;IAC3B,KAAK,EAAE,oBAAoB;CAC5B,CAAC;AAOF,SAAsB,gBAAgB,CACpC,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B,EAC1B,OAAiC;;QAEjC,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,SAAS,EAAE,OAAO,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,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B,EAC1B,UAAmC,EAAE;QAJrC,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAgB;QACvB,YAAO,GAAP,OAAO,CAAe;QACtB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,YAAO,GAAP,OAAO,CAA8B;Q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AC,MAAM;oBACL,CAAC,CAAC,oBAAoB;wBACpB,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;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport deepmerge from \"deepmerge\";\r\nimport {\r\n ClassDeclarationStructure,\r\n MethodDeclarationStructure,\r\n OptionalKind,\r\n PropertyDeclarationStructure,\r\n Scope,\r\n SourceFile,\r\n} from \"ts-morph\";\r\nimport { upperCaseFirst } from \"upper-case-first\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport {\r\n ActionImportType,\r\n ComplexType,\r\n DataTypes,\r\n EntityContainerModel,\r\n FunctionImportType,\r\n ModelType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n SingletonType,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { ConfigFileOptions } from \"../OptionModel\";\r\nimport { ProjectManager } from \"../project/ProjectManager\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nconst ROOT_SERVICE = \"ODataService\";\r\n\r\nconst RESPONSE_TYPES = {\r\n collection: \"ODataCollectionResponse\",\r\n model: \"ODataModelResponse\",\r\n value: \"ODataValueResponse\",\r\n};\r\n\r\nexport interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, \"properties\" | \"methods\">> {}\r\n\r\nexport interface ServiceGeneratorOptions\r\n extends Pick<ConfigFileOptions, \"enablePrimitivePropertyServices\" | \"v4BigNumberAsString\"> {}\r\n\r\nexport async function generateServices(\r\n dataModel: DataModel,\r\n project: ProjectManager,\r\n version: ODataVersions,\r\n namingHelper: NamingHelper,\r\n options?: ServiceGeneratorOptions\r\n) {\r\n const generator = new ServiceGenerator(dataModel, project, version, namingHelper, options);\r\n return generator.generate();\r\n}\r\n\r\nclass ServiceGenerator {\r\n constructor(\r\n private dataModel: DataModel,\r\n private project: ProjectManager,\r\n private version: ODataVersions,\r\n private namingHelper: NamingHelper,\r\n 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 sourceFile = await this.project.createMainServiceFile();\r\n const serviceName = this.namingHelper.getMainServiceName();\r\n const container = this.dataModel.getEntityContainer();\r\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\r\n\r\n await this.generateModelServices();\r\n\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n importContainer.addFromClientApi(\"ODataHttpClient\");\r\n importContainer.addFromService(ROOT_SERVICE);\r\n\r\n const { properties, methods }: PropsAndOps = deepmerge(\r\n this.generateMainServiceProperties(container, importContainer),\r\n this.generateMainServiceOperations(unboundOperations, importContainer)\r\n );\r\n\r\n sourceFile.addClass({\r\n isExported: true,\r\n name: serviceName,\r\n typeParameters: [\"ClientType extends ODataHttpClient\"],\r\n extends: `${ROOT_SERVICE}<ClientType>`,\r\n 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 sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\r\n }\r\n\r\n private generateMainServiceProperties(\r\n container: EntityContainerModel,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n Object.values(container.entitySets).forEach(({ name, 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(singleton, importContainer));\r\n result.methods.push(this.generateSingletonGetter(singleton));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateMainServiceOperations(\r\n ops: Array<FunctionImportType | ActionImportType>,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n ops.forEach(({ operation, name }) => {\r\n result.properties.push(this.generateQOperationProp(operation));\r\n result.methods.push(this.generateMethod(name, operation, importContainer));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateRelatedServiceGetter(\r\n propName: string,\r\n odataPropName: string,\r\n entityType: ModelType,\r\n importContainer: ImportContainer,\r\n currentServiceName?: string\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const idName = entityType.idModelName;\r\n const idFunctionName = entityType.qIdFunctionName;\r\n const serviceName = this.namingHelper.getServiceName(entityType.name);\r\n const collectionName = this.namingHelper.getCollectionServiceName(entityType.name);\r\n\r\n importContainer.addFromClientApi(\"ODataHttpClient\");\r\n importContainer.addGeneratedModel(idName);\r\n importContainer.addGeneratedQObject(idFunctionName);\r\n // make sure to not falsely import self-referential stuff\r\n if (!currentServiceName || currentServiceName !== serviceName) {\r\n importContainer.addGeneratedService(serviceName, collectionName, serviceName);\r\n }\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(propName),\r\n parameters: [\r\n {\r\n name: \"id\",\r\n type: `${idName} | undefined`,\r\n hasQuestionToken: true,\r\n },\r\n ],\r\n overloads: [\r\n {\r\n parameters: [],\r\n returnType: `${collectionName}<ClientType>`,\r\n },\r\n {\r\n parameters: [\r\n {\r\n name: \"id\",\r\n type: idName,\r\n },\r\n ],\r\n returnType: `${serviceName}<ClientType>`,\r\n },\r\n ],\r\n statements: [\r\n `const fieldName = \"${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 singleton: SingletonType,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const { name, entityType } = singleton;\r\n const type = this.namingHelper.getServiceName(entityType.name);\r\n\r\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), type);\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(name),\r\n type: `${type}<ClientType>`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generateQOperationProp = (operation: OperationType) => {\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(operation.qName),\r\n type: operation.qName,\r\n hasQuestionToken: true,\r\n };\r\n };\r\n\r\n private generateSingletonGetter(singleton: SingletonType): OptionalKind<MethodDeclarationStructure> {\r\n const { name, odataName, entityType } = singleton;\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\r\n const serviceType = this.namingHelper.getServiceName(entityType.name);\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n ` 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 getVersionSuffix() {\r\n return this.version === ODataVersions.V2 ? \"V2\" : \"V4\";\r\n }\r\n\r\n private async generateEntityTypeService(\r\n model: ComplexType,\r\n serviceName: string,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const entityServiceType = \"EntityTypeService\" + this.getVersionSuffix();\r\n\r\n const editableModelName = model.editableName;\r\n const qObjectName = firstCharLowerCase(model.qName);\r\n const operations = this.dataModel.getOperationTypeByBinding(model.name);\r\n const props = [...model.baseProps, ...model.props];\r\n\r\n importContainer.addFromService(entityServiceType);\r\n importContainer.addFromClientApi(\"ODataHttpClient\");\r\n importContainer.addGeneratedModel(model.name, editableModelName);\r\n importContainer.addGeneratedQObject(model.qName, qObjectName);\r\n\r\n const { properties, methods }: PropsAndOps = deepmerge(\r\n this.generateServiceProperties(serviceName, props, importContainer),\r\n this.generateServiceOperations(operations, importContainer)\r\n );\r\n\r\n // generate EntityTypeService\r\n serviceFile.addClass({\r\n isExported: true,\r\n name: serviceName,\r\n typeParameters: [\"ClientType extends ODataHttpClient\"],\r\n extends: entityServiceType + `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [`super(client, basePath, name, ${qObjectName}${this.isV4BigNumber() ? \", true\" : \"\"});`],\r\n },\r\n ],\r\n properties,\r\n methods,\r\n });\r\n }\r\n\r\n private getPrimitiveServiceType() {\r\n return \"PrimitiveTypeService\" + this.getVersionSuffix();\r\n }\r\n\r\n private generateServiceProperties(\r\n serviceName: string,\r\n props: Array<PropertyModel>,\r\n importContainer: ImportContainer\r\n ): PropsAndOps {\r\n const collectionServiceType = \"CollectionService\" + this.getVersionSuffix();\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n props.forEach((prop) => {\r\n if ((prop.dataType === DataTypes.ModelType && !prop.isCollection) || prop.dataType === DataTypes.ComplexType) {\r\n result.properties.push(this.generateModelProp(prop, collectionServiceType, serviceName, importContainer));\r\n result.methods.push(this.generateModelPropGetter(prop, collectionServiceType));\r\n } else if (prop.isCollection) {\r\n // collection of entity types\r\n if (prop.dataType === DataTypes.ModelType) {\r\n const entityType = this.dataModel.getModel(prop.type);\r\n result.methods.push(\r\n this.generateRelatedServiceGetter(prop.name, prop.odataName, entityType, importContainer, serviceName)\r\n );\r\n }\r\n // collection of primitive or complex types\r\n else {\r\n result.properties.push(this.generatePrimitiveCollectionProp(prop, collectionServiceType, importContainer));\r\n result.methods.push(this.generatePrimitiveCollectionGetter(prop, collectionServiceType));\r\n }\r\n } else if (this.options.enablePrimitivePropertyServices && prop.dataType === DataTypes.PrimitiveType) {\r\n result.properties.push(this.generatePrimitiveTypeProp(prop, importContainer));\r\n result.methods.push(this.generatePrimitiveTypeGetter(prop));\r\n }\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateServiceOperations(operations: Array<OperationType>, importContainer: ImportContainer): PropsAndOps {\r\n const result: PropsAndOps = { properties: [], methods: [] };\r\n\r\n operations.forEach((operation) => {\r\n result.properties.push(this.generateQOperationProp(operation));\r\n result.methods.push(this.generateMethod(operation.name, operation, importContainer));\r\n });\r\n\r\n return result;\r\n }\r\n\r\n private generateModelProp(\r\n prop: PropertyModel,\r\n collectionServiceType: string,\r\n serviceName: string,\r\n importContainer: ImportContainer\r\n ): PropertyDeclarationStructure {\r\n const complexType = this.dataModel.getComplexType(prop.type);\r\n const key = this.namingHelper.getServiceName(prop.type);\r\n let propModelType = prop.isCollection ? this.namingHelper.getCollectionServiceName(prop.type) : key;\r\n\r\n if (prop.isCollection && complexType) {\r\n const editableName = complexType.editableName;\r\n importContainer.addFromService(collectionServiceType);\r\n importContainer.addGeneratedModel(complexType.name, editableName);\r\n importContainer.addGeneratedQObject(complexType.qName, firstCharLowerCase(complexType.qName));\r\n propModelType = `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${editableName}>`;\r\n } else {\r\n // don't include imports for this type\r\n if (serviceName !== key) {\r\n importContainer.addGeneratedService(key, propModelType);\r\n }\r\n\r\n propModelType = `${propModelType}<ClientType>`;\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: propModelType,\r\n hasQuestionToken: true,\r\n } as PropertyDeclarationStructure;\r\n }\r\n\r\n private generatePrimitiveCollectionProp(\r\n prop: PropertyModel,\r\n collectionServiceType: string,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const isEnum = prop.dataType === DataTypes.EnumType;\r\n const type = isEnum ? `EnumCollection<${prop.type}>` : `${upperCaseFirst(prop.type)}Collection`;\r\n const qType = isEnum ? \"QEnumCollection\" : prop.qObject;\r\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\r\n\r\n if (!prop.qObject) {\r\n throw new Error(\"Illegal State: [qObject] must be provided for Collection types!\");\r\n }\r\n\r\n importContainer.addFromService(collectionServiceType);\r\n importContainer.addFromQObject(prop.qObject, firstCharLowerCase(prop.qObject));\r\n if (isEnum) {\r\n importContainer.addGeneratedModel(prop.type);\r\n importContainer.addFromQObject(\"EnumCollection\");\r\n } else {\r\n importContainer.addFromQObject(type);\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: `${collectionType}`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generatePrimitiveTypeProp(\r\n prop: PropertyModel,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure> {\r\n const serviceType = this.getPrimitiveServiceType();\r\n importContainer.addFromService(serviceType);\r\n if (prop.typeModule) {\r\n importContainer.addCustomType(prop.typeModule, prop.type);\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: `${serviceType}<ClientType, ${prop.type}>`,\r\n hasQuestionToken: true,\r\n };\r\n }\r\n\r\n private generateModelPropGetter(\r\n prop: PropertyModel,\r\n collectionServiceType: string\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const complexType = this.dataModel.getComplexType(prop.type);\r\n const isComplexCollection = prop.isCollection && complexType;\r\n const type = isComplexCollection\r\n ? collectionServiceType\r\n : prop.isCollection\r\n ? this.namingHelper.getCollectionServiceName(prop.type)\r\n : this.namingHelper.getServiceName(prop.type);\r\n const typeWithGenerics = isComplexCollection\r\n ? `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${complexType.editableName}>`\r\n : `${type}<ClientType>`;\r\n\r\n const privateSrvProp = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n returnType: typeWithGenerics,\r\n statements: [\r\n `if(!${privateSrvProp}) {`,\r\n ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${privateSrvProp} = new ${type}(client, path, \"${prop.odataName}\"${isComplexCollection ? `, ${firstCharLowerCase(complexType.qName)}`: \"\"})`,\r\n \"}\",\r\n `return ${privateSrvProp}`,\r\n ],\r\n };\r\n }\r\n\r\n private generatePrimitiveCollectionGetter(\r\n prop: PropertyModel,\r\n collectionServiceType: string\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n ` const { client, path } = this.__base;`,\r\n // prettier-ignore\r\n ` ${propName} = new ${collectionServiceType}(client, path, \"${prop.odataName}\", ${firstCharLowerCase(prop.qObject!)}${this.isV4BigNumber() ? \", true\": \"\"})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n }\r\n\r\n private generatePrimitiveTypeGetter(prop: PropertyModel): OptionalKind<MethodDeclarationStructure> {\r\n const serviceType = this.getPrimitiveServiceType();\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 async generateEntityCollectionService(\r\n model: ModelType,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const entitySetServiceType = \"EntitySetService\" + this.getVersionSuffix();\r\n const editableModelName = model.editableName;\r\n const qObjectName = firstCharLowerCase(model.qName);\r\n\r\n importContainer.addFromService(entitySetServiceType);\r\n importContainer.addGeneratedModel(model.idModelName);\r\n importContainer.addGeneratedQObject(model.qIdFunctionName);\r\n\r\n const collectionOperations = this.dataModel.getOperationTypeByBinding(`Collection(${model.name})`);\r\n\r\n const { properties, methods } = this.generateServiceOperations(collectionOperations, importContainer);\r\n\r\n serviceFile.addClass({\r\n isExported: true,\r\n name: this.namingHelper.getCollectionServiceName(model.name),\r\n typeParameters: [\"ClientType extends ODataHttpClient\"],\r\n extends:\r\n entitySetServiceType +\r\n `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}, ${model.idModelName}>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [\r\n `super(client, basePath, name, ${qObjectName}, new ${model.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 async generateModelServices() {\r\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\r\n for (const model of this.dataModel.getModels()) {\r\n const serviceName = this.namingHelper.getServiceName(model.name);\r\n const serviceFile = await this.project.createServiceFile(serviceName);\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n // entity type service\r\n await this.generateEntityTypeService(model, serviceName, serviceFile, importContainer);\r\n\r\n // entity collection service\r\n await this.generateEntityCollectionService(model, serviceFile, importContainer);\r\n\r\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\r\n }\r\n\r\n // build service file for complex types\r\n for (const model of this.dataModel.getComplexTypes()) {\r\n const serviceName = this.namingHelper.getServiceName(model.name);\r\n const serviceFile = await this.project.createServiceFile(serviceName);\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n // entity type service\r\n await this.generateEntityTypeService(model, serviceName, serviceFile, importContainer);\r\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\r\n }\r\n }\r\n\r\n private generateMethod(\r\n name: string,\r\n operation: OperationType,\r\n importContainer: ImportContainer\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const isFunc = operation.type === OperationTypes.Function;\r\n const odataType = operation.returnType?.isCollection\r\n ? RESPONSE_TYPES.collection + this.getVersionSuffix()\r\n : operation.returnType?.dataType === DataTypes.PrimitiveType\r\n ? RESPONSE_TYPES.value + this.getVersionSuffix()\r\n : RESPONSE_TYPES.model + this.getVersionSuffix();\r\n const returnType = operation.returnType;\r\n const requestConfigParam = {\r\n name: \"requestConfig\",\r\n hasQuestionToken: true,\r\n type: \"ODataHttpClientConfig<ClientType>\",\r\n };\r\n const hasParams = operation.parameters.length > 0;\r\n\r\n // importing dependencies\r\n importContainer.addFromClientApi(\"ODataHttpClientConfig\", \"ODataResponse\");\r\n importContainer.addFromCore(odataType);\r\n if (returnType?.type) {\r\n if ([DataTypes.EnumType, DataTypes.ModelType, DataTypes.ComplexType].includes(returnType.dataType)) {\r\n importContainer.addGeneratedModel(returnType.type);\r\n }\r\n }\r\n importContainer.addGeneratedQObject(operation.qName);\r\n if (hasParams) {\r\n importContainer.addGeneratedModel(operation.paramsModelName);\r\n }\r\n\r\n const qOpProp = \"this.\" + this.namingHelper.getPrivatePropName(operation.qName);\r\n\r\n return {\r\n scope: Scope.Public,\r\n isAsync: true,\r\n name,\r\n parameters: hasParams\r\n ? [{ name: \"params\", type: operation.paramsModelName }, requestConfigParam]\r\n : [requestConfigParam],\r\n returnType: `ODataResponse<${odataType}<${returnType?.type || \"void\"}>>`,\r\n statements: [\r\n `if(!${qOpProp}) {`,\r\n ` ${qOpProp} = new ${operation.qName}()`,\r\n \"}\",\r\n\r\n `const { 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odata2ts/odata2ts",
3
- "version": "0.28.0",
3
+ "version": "0.29.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -44,14 +44,15 @@
44
44
  "v4"
45
45
  ],
46
46
  "peerDependencies": {
47
- "@odata2ts/odata-query-objects": "^0.19.0",
48
- "@odata2ts/odata-service": "^0.16.0"
47
+ "@odata2ts/odata-query-objects": "^0.20.0",
48
+ "@odata2ts/odata-service": "^0.17.1"
49
49
  },
50
50
  "dependencies": {
51
51
  "@odata2ts/converter-api": "^0.1.2",
52
52
  "@odata2ts/converter-runtime": "^0.2.2",
53
- "@odata2ts/odata-core": "^0.3.8",
54
- "@prettier/plugin-xml": "^3.1.1",
53
+ "@odata2ts/http-client-api": "^0.5.1",
54
+ "@odata2ts/odata-core": "^0.4.0",
55
+ "@prettier/plugin-xml": "^2.2.0",
55
56
  "axios": "^1.4.0",
56
57
  "camel-case": "^4.1.2",
57
58
  "commander": "^10.0.1",
@@ -71,10 +72,9 @@
71
72
  },
72
73
  "devDependencies": {
73
74
  "@odata2ts/converter-v2-to-v4": "^0.1.4",
74
- "@odata2ts/http-client-api": "^0.1.0",
75
- "@odata2ts/odata-query-objects": "^0.19.0",
76
- "@odata2ts/odata-service": "^0.16.0",
77
- "@odata2ts/test-converters": "^0.2.6",
75
+ "@odata2ts/odata-query-objects": "^0.20.0",
76
+ "@odata2ts/odata-service": "^0.17.1",
77
+ "@odata2ts/test-converters": "^0.3.0",
78
78
  "@types/fs-extra": "^11.0.1",
79
79
  "@types/jest": "^29.5.2",
80
80
  "@types/node": "^20.3.0",
@@ -87,6 +87,6 @@
87
87
  "typescript": "^5.1.3"
88
88
  },
89
89
  "types": "./lib/index.d.ts",
90
- "gitHead": "50824827bce42019b3488e094e88cd64e41e99e3",
90
+ "gitHead": "372172139002d0d0f4d815e58985ab23b8052243",
91
91
  "readme": "README.md"
92
92
  }