@odata2ts/odata2ts 0.19.2 → 0.20.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,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.20.1](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.20.0...@odata2ts/odata2ts@0.20.1) (2023-04-08)
7
+
8
+ **Note:** Version bump only for package @odata2ts/odata2ts
9
+
10
+ # [0.20.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.19.2...@odata2ts/odata2ts@0.20.0) (2023-04-04)
11
+
12
+ ### Features
13
+
14
+ * **odata2ts:** Entity configuration options ([#145](https://github.com/odata2ts/odata2ts/issues/145)) ([03264c5](https://github.com/odata2ts/odata2ts/commit/03264c5f31a758f9b8d854630cf2c90632e9d8d8))
15
+
6
16
  ## [0.19.2](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.19.1...@odata2ts/odata2ts@0.19.2) (2023-03-23)
7
17
 
8
18
  ### Bug Fixes
9
19
 
10
20
  * **odata2ts:** entity resolver uses wrong Q-Id function when id is inherited ([e05f4eb](https://github.com/odata2ts/odata2ts/commit/e05f4ebd8afd472cdad0194f899159d2a60c3d92))
21
+
11
22
  * **odata2ts:** semantically wrong unit test ([541a687](https://github.com/odata2ts/odata2ts/commit/541a6874517ef6444fe6f428b64dc894158b066b))
12
23
 
13
24
  ## [0.19.1](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.19.0...@odata2ts/odata2ts@0.19.1) (2023-02-24)
package/README.md CHANGED
@@ -2,34 +2,74 @@
2
2
 
3
3
  # odata2ts
4
4
 
5
- Generate TypeScript models, magical q-objects and / or complete client services
6
- from readily available metadata descriptions of your OData service.
5
+ The basic idea of `odata2ts` is to leverage the readily available metadata of any OData service
6
+ to generate different sorts of typed artefacts which you use in your TypeScript code.
7
+ This package `@odata2ts/odata2ts` realizes the generation process.
8
+
9
+ The generator is supposed to be used with a TypeScript based configuration file.
10
+ Then it's able to handle the generation for multiple OData services.
11
+
12
+ It comes with powerful configuration options. Some highlights:
13
+ - generation of TypeScript files or compiled JS / DTS files
14
+ - name or rename stuff
15
+ - naming of pretty much any aspect of the generated artefacts
16
+ - e.g. all types should be prefixed with an "I", Person => IPerson
17
+ - consistent casing (as in "camelCase" or "PascalCase") even for property names of entity types
18
+ - use type converters
19
+
20
+ See the [generator documentation](https://odata2ts.github.io/docs/generator/setup-and-usage) for more information.
7
21
 
8
22
  ## Installation
9
23
 
10
24
  ```
11
25
  npm install --save-dev @odata2ts/odata2ts
12
-
13
- yarn add --dev @odata2ts/odata2ts
14
26
  ```
15
27
 
16
- ## Implicit Dependencies
17
- The generated artefacts depend on other libraries. `odata2ts` lists them as peer dependencies.
18
- Hence, you will need to add runtime dependencies matching the mentioned peer dependencies.
19
- See the Getting Started Guide of the documentation.
28
+ ### Implicit Dependencies
29
+ Most of the generated artefacts depend on other libraries. `odata2ts` lists them as peer dependencies.
30
+
31
+ Depending on your use case, you will need to add runtime dependencies matching the mentioned peer dependencies.
32
+ See the [Getting Started Guide](https://odata2ts.github.io/docs/category/getting-started/) of the documentation
33
+ for guidance.
20
34
 
21
35
  ## Documentation
36
+ [Generator Documentation](https://odata2ts.github.io/docs/generator/setup-and-usage)
37
+
22
38
  Main documentation for the odata2ts eco system:
23
39
  [https://odata2ts.github.io](https://odata2ts.github.io/)
24
40
 
41
+
25
42
  ## Examples
26
43
  See [example packages](https://github.com/odata2ts/odata2ts/tree/main/examples) for examples of how to integrate `odata2ts`.
27
44
 
45
+ ## Tests
46
+ See folder [test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/test)
47
+ for unit tests.
48
+
49
+ See folder [int-test](https://github.com/odata2ts/odata2ts/tree/main/packages/odata2ts/int-test) for integration
50
+ tests of the CLI.
51
+
52
+ Each example package serves as integration test of the generator.
53
+
54
+ ## Support, Feedback, Contributing
55
+ This project is open to feature requests, suggestions, bug reports, usage questions etc.
56
+ via [GitHub issues](https://github.com/odata2ts/odata2ts/issues).
57
+
58
+ Contributions and feedback are encouraged and always welcome.
59
+
60
+ See the [contribution guidelines](https://github.com/odata2ts/odata2ts/blob/main/CONTRIBUTING.md) for further information.
61
+
28
62
  ## Spirit
29
- * Adhere to the OData specification as much as possible
30
- * Test Driven Development
31
- * High Code Coverage: > 90%
63
+ This project and this module have been created and are maintained in the following spirit:
64
+
65
+ * adhere to the **OData specification** as much as possible
66
+ * support any OData service implementation which conforms to the spec
67
+ * allow to work around faulty implementations if possible
68
+ * stability matters
69
+ * exercise Test Driven Development
70
+ * bomb the place with unit tests (code coverage > 95%)
71
+ * ensure that assumptions & understanding are correct by creating integration tests
32
72
 
33
73
  ## License
34
- MIT
74
+ MIT - see [License](./LICENSE).
35
75
 
@@ -4,7 +4,7 @@ import { DataModel } from "./data-model/DataModel";
4
4
  import { Schema } from "./data-model/edmx/ODataEdmxModelBase";
5
5
  import { NamingHelper } from "./data-model/NamingHelper";
6
6
  import { RunOptions } from "./OptionModel";
7
- export type DigestionOptions = Pick<RunOptions, "converters" | "disableAutoManagedKey" | "propertiesByName">;
7
+ export type DigestionOptions = Pick<RunOptions, "converters" | "disableAutoManagedKey" | "propertiesByName" | "entitiesByName">;
8
8
  /**
9
9
  * Takes an EdmxSchema plus the run options and creates a DataModel.
10
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"FactoryFunctionModel.js","sourceRoot":"","sources":["../src/FactoryFunctionModel.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { SourceFile } from \"ts-morph\";\r\n\r\nimport { DataModel } from \"./data-model/DataModel\";\r\nimport { Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper\";\r\nimport { RunOptions } from \"./OptionModel\";\r\n\r\nexport type DigestionOptions = Pick<RunOptions, \"converters\" | \"disableAutoManagedKey\" | \"propertiesByName\">; //TODO | \"entitiesByName\">;\r\n\r\n/**\r\n * Takes an EdmxSchema plus the run options and creates a DataModel.\r\n */\r\nexport type DigesterFunction<S extends Schema<any, any>> = (\r\n schema: S,\r\n options: DigestionOptions,\r\n namingHelper: NamingHelper\r\n) => Promise<DataModel>;\r\n\r\nexport type GeneratorFunctionOptions = Pick<RunOptions, \"skipEditableModels\" | \"skipIdModels\" | \"skipOperations\">;\r\n\r\nexport type EntityBasedGeneratorFunction = (\r\n dataModel: DataModel,\r\n sourceFile: SourceFile,\r\n version: ODataVersions,\r\n options: GeneratorFunctionOptions,\r\n namingHelper: NamingHelper\r\n) => void;\r\n"]}
1
+ {"version":3,"file":"FactoryFunctionModel.js","sourceRoot":"","sources":["../src/FactoryFunctionModel.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { SourceFile } from \"ts-morph\";\r\n\r\nimport { DataModel } from \"./data-model/DataModel\";\r\nimport { Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper\";\r\nimport { RunOptions } from \"./OptionModel\";\r\n\r\nexport type DigestionOptions = Pick<\r\n RunOptions,\r\n \"converters\" | \"disableAutoManagedKey\" | \"propertiesByName\" | \"entitiesByName\"\r\n>;\r\n\r\n/**\r\n * Takes an EdmxSchema plus the run options and creates a DataModel.\r\n */\r\nexport type DigesterFunction<S extends Schema<any, any>> = (\r\n schema: S,\r\n options: DigestionOptions,\r\n namingHelper: NamingHelper\r\n) => Promise<DataModel>;\r\n\r\nexport type GeneratorFunctionOptions = Pick<RunOptions, \"skipEditableModels\" | \"skipIdModels\" | \"skipOperations\">;\r\n\r\nexport type EntityBasedGeneratorFunction = (\r\n dataModel: DataModel,\r\n sourceFile: SourceFile,\r\n version: ODataVersions,\r\n options: GeneratorFunctionOptions,\r\n namingHelper: NamingHelper\r\n) => void;\r\n"]}
@@ -158,8 +158,9 @@ export interface ConfigFileOptions extends Omit<CliOptions, "source" | "output"
158
158
  */
159
159
  export interface ServiceGenerationOptions extends Required<Pick<CliOptions, "source" | "output">>, Omit<ConfigFileOptions, "services"> {
160
160
  /**
161
- * Configure generation process for EntityTypes and ComplexTypes including their properties.
161
+ * Configure generation process for EntityTypes and ComplexTypes including their keys and properties.
162
162
  */
163
+ entitiesByName?: Array<EntityGenerationOptions>;
163
164
  /**
164
165
  * Configure generation process for individual properties based on their name.
165
166
  */
@@ -168,7 +169,7 @@ export interface ServiceGenerationOptions extends Required<Pick<CliOptions, "sou
168
169
  /**
169
170
  * Configuration options for EntityTypes and ComplexTypes.
170
171
  * This config applies if the name matches the name of an EntityType or ComplexType as it is specified
171
- * in the metadata (e.g. in EDMX <EntityType name="Test" ....)
172
+ * in the metadata (e.g. in EDMX <EntityType name="Test" ...)
172
173
  */
173
174
  export interface EntityGenerationOptions {
174
175
  /**
@@ -182,9 +183,9 @@ export interface EntityGenerationOptions {
182
183
  */
183
184
  mappedName?: string;
184
185
  /**
185
- * Configuration of individual properties.
186
+ * Overwrite the key specification by naming the props by their EDMX name.
186
187
  */
187
- properties?: Array<PropertyGenerationOptions>;
188
+ keys?: Array<string>;
188
189
  }
189
190
  /**
190
191
  * All configuration options for properties of models.
@@ -1 +1 @@
1
- {"version":3,"file":"OptionModel.js","sourceRoot":"","sources":["../src/OptionModel.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,IAAY,KAKX;AALD,WAAY,KAAK;IACf,qCAAM,CAAA;IACN,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,+BAAG,CAAA;AACL,CAAC,EALW,KAAK,GAAL,aAAK,KAAL,aAAK,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,GAAT,iBAAS,KAAT,iBAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\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 source file to use. Must be an EDMX compliant XML file.\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 / suffing still applies.\r\n */\r\n allowRenaming?: boolean;\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 extends Required<Omit<ServiceGenerationOptions, \"serviceName\">> {\r\n serviceName?: string;\r\n naming: NameSettings;\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, \"source\" | \"output\" | \"services\"> {\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 /**\r\n * The naming options regarding the generated artefacts.\r\n */\r\n naming?: OverridableNamingOptions;\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 Omit<ConfigFileOptions, \"services\"> {\r\n /**\r\n * Configure generation process for EntityTypes and ComplexTypes including their 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 * 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 * 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"]}
1
+ {"version":3,"file":"OptionModel.js","sourceRoot":"","sources":["../src/OptionModel.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,IAAY,KAKX;AALD,WAAY,KAAK;IACf,qCAAM,CAAA;IACN,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,+BAAG,CAAA;AACL,CAAC,EALW,KAAK,GAAL,aAAK,KAAL,aAAK,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,GAAT,iBAAS,KAAT,iBAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\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 source file to use. Must be an EDMX compliant XML file.\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 / suffing still applies.\r\n */\r\n allowRenaming?: boolean;\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 extends Required<Omit<ServiceGenerationOptions, \"serviceName\">> {\r\n serviceName?: string;\r\n naming: NameSettings;\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, \"source\" | \"output\" | \"services\"> {\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 /**\r\n * The naming options regarding the generated artefacts.\r\n */\r\n naming?: OverridableNamingOptions;\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 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 * 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.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,mBA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} from \"./data-model/DataModelDigestionV2\";\r\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\r\nimport { ODataEdmxModelBase, Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { SchemaV3 } from \"./data-model/edmx/ODataEdmxModelV3\";\r\nimport { SchemaV4 } from \"./data-model/edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper\";\r\nimport { generateModels, generateQueryObjects, generateServices } from \"./generator\";\r\nimport { Modes, RunOptions } from \"./OptionModel\";\r\nimport { createProjectManager } from \"./project/ProjectManager\";\r\n\r\nfunction isQObjectGen(mode: Modes) {\r\n return [Modes.qobjects, Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\nfunction isServiceGen(mode: Modes) {\r\n return [Modes.service, Modes.all].includes(mode);\r\n}\r\n\r\n/**\r\n *\r\n * @param metadataJson metadata of a given OData service already parsed as JSON\r\n * @param options further options\r\n */\r\nexport async function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void> {\r\n // determine edmx edmxVersion attribute\r\n const edmxVersion = metadataJson[\"edmx:Edmx\"].$.Version;\r\n const version = edmxVersion === \"1.0\" ? ODataVersions.V2 : ODataVersions.V4;\r\n\r\n const dataService = metadataJson[\"edmx:Edmx\"][\"edmx:DataServices\"][0];\r\n\r\n // handling multiple schemas => merge them\r\n const schemaRaw = dataService.Schema.reduce(\r\n (collector, schema) => ({\r\n ...schema,\r\n ...collector,\r\n }),\r\n {} as Schema<any, any>\r\n );\r\n const detectedServiceName =\r\n dataService.Schema.length === 1\r\n ? dataService.Schema[0].$.Namespace\r\n : dataService.Schema.find((schema) => !schema.EntityContainer)?.$.Namespace;\r\n\r\n // encapsulate the whole naming logic\r\n const namingHelper = new NamingHelper(options, detectedServiceName, options.serviceName);\r\n // parse model information from edmx into something we can really work with\r\n // => that stuff is called dataModel!\r\n const dataModel =\r\n version === ODataVersions.V2\r\n ? await digestV2(schemaRaw as SchemaV3, options, namingHelper)\r\n : await digestV4(schemaRaw as SchemaV4, options, namingHelper);\r\n // handling the overall generation project\r\n const project = await createProjectManager(\r\n namingHelper.getFileNames(),\r\n options.output,\r\n options.emitMode,\r\n options.prettier,\r\n options.tsconfig\r\n );\r\n\r\n // Generate Model Interfaces\r\n // supported edmx types: EntityType, ComplexType, EnumType\r\n const modelsFile = await project.createModelFile();\r\n generateModels(dataModel, modelsFile, version, options, namingHelper);\r\n\r\n // Generate Query Objects\r\n // supported edmx types: EntityType, ComplexType\r\n // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object\r\n if (isQObjectGen(options.mode)) {\r\n const qFile = await project.createQObjectFile();\r\n generateQueryObjects(dataModel, qFile, version, options, namingHelper);\r\n }\r\n\r\n // Generate Individual OData-Service\r\n if (isServiceGen(options.mode)) {\r\n await project.cleanServiceDir();\r\n await generateServices(dataModel, project, version, namingHelper);\r\n }\r\n\r\n await project.writeFiles();\r\n}\r\n"]}
1
+ {"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,CAA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QAAQ,EAChB,OAAO,CAAC,QAAQ,CACjB,CAAC;QAEF,4BAA4B;QAC5B,0DAA0D;QAC1D,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;QACnD,IAAA,0BAAc,EAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAEtE,yBAAyB;QACzB,gDAAgD;QAChD,mJAAmJ;QACnJ,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAChD,IAAA,gCAAoB,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACxE;QAED,oCAAoC;QACpC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;YAChC,MAAM,IAAA,4BAAgB,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACnE;QAED,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;;CAC5B;AAzDD,wBAyDC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\n\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2\";\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\nimport { ODataEdmxModelBase, Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\nimport { SchemaV3 } from \"./data-model/edmx/ODataEdmxModelV3\";\nimport { SchemaV4 } from \"./data-model/edmx/ODataEdmxModelV4\";\nimport { NamingHelper } from \"./data-model/NamingHelper\";\nimport { generateModels, generateQueryObjects, generateServices } from \"./generator\";\nimport { Modes, RunOptions } from \"./OptionModel\";\nimport { createProjectManager } from \"./project/ProjectManager\";\n\nfunction isQObjectGen(mode: Modes) {\n return [Modes.qobjects, Modes.service, Modes.all].includes(mode);\n}\n\nfunction isServiceGen(mode: Modes) {\n return [Modes.service, Modes.all].includes(mode);\n}\n\n/**\n *\n * @param metadataJson metadata of a given OData service already parsed as JSON\n * @param options further options\n */\nexport async function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void> {\n // determine edmx edmxVersion attribute\n const edmxVersion = metadataJson[\"edmx:Edmx\"].$.Version;\n const version = edmxVersion === \"1.0\" ? ODataVersions.V2 : ODataVersions.V4;\n\n const dataService = metadataJson[\"edmx:Edmx\"][\"edmx:DataServices\"][0];\n\n // handling multiple schemas => merge them\n const schemaRaw = dataService.Schema.reduce(\n (collector, schema) => ({\n ...schema,\n ...collector,\n }),\n {} as Schema<any, any>\n );\n const detectedServiceName =\n dataService.Schema.length === 1\n ? dataService.Schema[0].$.Namespace\n : dataService.Schema.find((schema) => !schema.EntityContainer)?.$.Namespace;\n\n // encapsulate the whole naming logic\n const namingHelper = new NamingHelper(options, detectedServiceName, options.serviceName);\n // parse model information from edmx into something we can really work with\n // => that stuff is called dataModel!\n const dataModel =\n version === ODataVersions.V2\n ? await digestV2(schemaRaw as SchemaV3, options, namingHelper)\n : await digestV4(schemaRaw as SchemaV4, options, namingHelper);\n // handling the overall generation project\n const project = await createProjectManager(\n namingHelper.getFileNames(),\n options.output,\n options.emitMode,\n options.prettier,\n options.tsconfig\n );\n\n // Generate Model Interfaces\n // supported edmx types: EntityType, ComplexType, EnumType\n const modelsFile = await project.createModelFile();\n generateModels(dataModel, modelsFile, version, options, namingHelper);\n\n // Generate Query Objects\n // supported edmx types: EntityType, ComplexType\n // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object\n if (isQObjectGen(options.mode)) {\n const qFile = await project.createQObjectFile();\n generateQueryObjects(dataModel, qFile, version, options, namingHelper);\n }\n\n // Generate Individual OData-Service\n if (isServiceGen(options.mode)) {\n await project.cleanServiceDir();\n await generateServices(dataModel, project, version, namingHelper);\n }\n\n await project.writeFiles();\n}\n"]}
@@ -113,9 +113,11 @@ class Digester {
113
113
  }
114
114
  getBaseModel(model) {
115
115
  var _a;
116
- const name = this.namingHelper.getModelName(model.$.Name);
117
- const qName = this.namingHelper.getQName(model.$.Name);
118
- const editableName = this.namingHelper.getEditableModelName(model.$.Name);
116
+ const entityConfig = this.serviceConfigHelper.findConfigEntityByName(model.$.Name);
117
+ const entityName = (entityConfig === null || entityConfig === void 0 ? void 0 : entityConfig.mappedName) || model.$.Name;
118
+ const name = this.namingHelper.getModelName(entityName);
119
+ const qName = this.namingHelper.getQName(entityName);
120
+ const editableName = this.namingHelper.getEditableModelName(entityName);
119
121
  const odataName = model.$.Name;
120
122
  const bType = model.$.BaseType;
121
123
  const props = [...((_a = model.Property) !== null && _a !== void 0 ? _a : []), ...this.getNavigationProps(model)];
@@ -144,20 +146,28 @@ class Digester {
144
146
  }
145
147
  }
146
148
  addEntityType(models) {
149
+ var _a;
147
150
  if (!models || !models.length) {
148
151
  return;
149
152
  }
150
153
  for (const model of models) {
151
154
  const baseModel = this.getBaseModel(model);
155
+ const entityConfig = this.serviceConfigHelper.findConfigEntityByName(model.$.Name);
156
+ const entityName = (entityConfig === null || entityConfig === void 0 ? void 0 : entityConfig.mappedName) || model.$.Name;
152
157
  // key support: we add keys from this entity,
153
158
  // but not keys stemming from base classes (postprocess required)
154
159
  const keyNames = [];
155
- const entity = model;
156
- if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {
157
- const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);
158
- keyNames.push(...propNames);
160
+ if ((_a = entityConfig === null || entityConfig === void 0 ? void 0 : entityConfig.keys) === null || _a === void 0 ? void 0 : _a.length) {
161
+ keyNames.push(...entityConfig.keys);
162
+ }
163
+ else {
164
+ const entity = model;
165
+ if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {
166
+ const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);
167
+ keyNames.push(...propNames);
168
+ }
159
169
  }
160
- this.dataModel.addModel(baseModel.name, Object.assign(Object.assign({}, baseModel), { idModelName: this.namingHelper.getIdModelName(model.$.Name), qIdFunctionName: this.namingHelper.getQIdFunctionName(model.$.Name), generateId: true, keyNames: keyNames, keys: [], getKeyUnion: () => keyNames.join(" | ") }));
170
+ this.dataModel.addModel(baseModel.name, Object.assign(Object.assign({}, baseModel), { idModelName: this.namingHelper.getIdModelName(entityName), qIdFunctionName: this.namingHelper.getQIdFunctionName(entityName), generateId: true, keyNames: keyNames, keys: [], getKeyUnion: () => keyNames.join(" | ") }));
161
171
  }
162
172
  }
163
173
  postProcessModel() {
@@ -1 +1 @@
1
- {"version":3,"file":"DataModelDigestion.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestion.ts"],"names":[],"mappings":";;;;AAGA,2CAAwC;AAIxC,+DAA4D;AAS5D,MAAsB,QAAQ;IAS5B,YACY,OAAqB,EACrB,MAAS,EACT,OAAyB,EACzB,YAA0B,EACpC,UAAkC;QAJxB,YAAO,GAAP,OAAO,CAAc;QACrB,WAAM,GAAN,MAAM,CAAG;QACT,YAAO,GAAP,OAAO,CAAkB;QACzB,iBAAY,GAAZ,YAAY,CAAc;QAN9B,eAAU,GAA2B,IAAI,GAAG,EAAqB,CAAC;QA0MhE,YAAO,GAAG,CAAC,CAAW,EAAiB,EAAE;YACjD,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;aAC1E;YAED,MAAM,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YACvD,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;YACnE,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,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MAAM,EAAE;gBAChC,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,CAAC,GAAG,IAAI,CAAC,4BAA4B,CAAC,SAAS,CAAC,CAAC;gBAC5G,KAAK,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC;gBAC9B,IAAI,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;gBAC5B,IAAI,YAAY,EAAE;oBAChB,YAAY,GAAG,YAAY,CAAC;oBAC5B,aAAa,GAAG,aAAa,CAAC;iBAC/B;aACF;YAED,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;YAC/B,IAAI,SAAS,CAAC,QAAQ,EAAE;gBACtB,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACpE,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC;gBACrC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC;aAC3C;YACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;QACpD,CAAC,EACD,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAA0D,CAC1E,CAAC;IACJ,CAAC;;AA/MH,4BA0RC;AAzRkB,mBAAU,GAAG,MAAM,CAAC;AACpB,uBAAc,GAAG,GAAG,CAAC","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { DataModel } from \"./DataModel\";\r\nimport { ComplexType as ComplexModelType, DataTypes, ODataVersion, PropertyModel } from \"./DataTypeModel\";\r\nimport { ComplexType, EntityType, Property, Schema } from \"./edmx/ODataEdmxModelBase\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\nimport { ServiceConfigHelper } from \"./ServiceConfigHelper\";\r\n\r\nexport interface TypeModel {\r\n outputType: string;\r\n qPath: string;\r\n qCollection: string;\r\n qParam: string | undefined;\r\n}\r\n\r\nexport abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {\r\n protected static EDM_PREFIX = \"Edm.\";\r\n protected static ROOT_OPERATION = \"/\";\r\n\r\n protected readonly dataModel: DataModel;\r\n protected readonly serviceConfigHelper: ServiceConfigHelper;\r\n\r\n private model2Type: Map<string, DataTypes> = new Map<string, DataTypes>();\r\n\r\n protected constructor(\r\n protected version: ODataVersion,\r\n protected schema: S,\r\n protected options: DigestionOptions,\r\n protected namingHelper: NamingHelper,\r\n converters?: MappedConverterChains\r\n ) {\r\n this.dataModel = new DataModel(version, converters);\r\n this.serviceConfigHelper = new ServiceConfigHelper(options);\r\n this.collectModelTypes(this.schema);\r\n }\r\n\r\n protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;\r\n\r\n protected abstract digestEntityContainer(): void;\r\n\r\n /**\r\n * Get essential infos about a given odata type from the version specific service variants.\r\n *\r\n * @param type\r\n * @return tuple of return type, query object, query collection object\r\n */\r\n protected abstract mapODataType(type: string): TypeModel;\r\n\r\n public async digest(): Promise<DataModel> {\r\n this.digestSchema(this.schema);\r\n return this.dataModel;\r\n }\r\n\r\n private collectModelTypes(schema: Schema<ET, CT>) {\r\n const servicePrefix = this.namingHelper.getServicePrefix();\r\n schema.EnumType?.forEach((et) => {\r\n this.model2Type.set(servicePrefix + et.$.Name, DataTypes.EnumType);\r\n });\r\n schema.ComplexType?.forEach((ct) => {\r\n this.model2Type.set(servicePrefix + ct.$.Name, DataTypes.ComplexType);\r\n });\r\n schema.EntityType?.forEach((et) => {\r\n this.model2Type.set(servicePrefix + et.$.Name, DataTypes.ModelType);\r\n });\r\n }\r\n\r\n private digestSchema(schema: Schema<ET, CT>) {\r\n // enums\r\n if (schema.EnumType) {\r\n for (const et of schema.EnumType) {\r\n const name = et.$.Name;\r\n this.dataModel.addEnum(name, {\r\n odataName: name,\r\n name: this.namingHelper.getEnumName(name),\r\n members: et.Member.map((m) => m.$.Name),\r\n });\r\n }\r\n }\r\n\r\n // entity types\r\n this.addEntityType(schema.EntityType);\r\n // complex types\r\n this.addComplexType(schema.ComplexType);\r\n\r\n this.postProcessModel();\r\n\r\n // delegate to concrete entity container digestion\r\n this.digestEntityContainer();\r\n }\r\n\r\n private getBaseModel(model: ComplexType) {\r\n const name = this.namingHelper.getModelName(model.$.Name);\r\n const qName = this.namingHelper.getQName(model.$.Name);\r\n const editableName = this.namingHelper.getEditableModelName(model.$.Name);\r\n const odataName = model.$.Name;\r\n const bType = model.$.BaseType;\r\n const props = [...(model.Property ?? []), ...this.getNavigationProps(model)];\r\n\r\n // support for base types, i.e. extends clause of interfaces\r\n const baseClasses = [];\r\n if (bType) {\r\n baseClasses.push(this.namingHelper.getModelName(bType));\r\n }\r\n\r\n return {\r\n name,\r\n qName,\r\n odataName,\r\n editableName,\r\n baseClasses,\r\n props: props.map(this.mapProp),\r\n baseProps: [], // postprocess required\r\n };\r\n }\r\n\r\n private addComplexType(models: Array<ComplexType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const baseModel = this.getBaseModel(model);\r\n this.dataModel.addComplexType(baseModel.name, baseModel);\r\n }\r\n }\r\n\r\n private addEntityType(models: Array<ET> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const baseModel = this.getBaseModel(model);\r\n\r\n // key support: we add keys from this entity,\r\n // but not keys stemming from base classes (postprocess required)\r\n const keyNames: Array<string> = [];\r\n const entity = model as EntityType;\r\n if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {\r\n const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);\r\n keyNames.push(...propNames);\r\n }\r\n\r\n this.dataModel.addModel(baseModel.name, {\r\n ...baseModel,\r\n idModelName: this.namingHelper.getIdModelName(model.$.Name),\r\n qIdFunctionName: this.namingHelper.getQIdFunctionName(model.$.Name),\r\n generateId: true,\r\n keyNames: keyNames, // postprocess required to include key specs from base classes\r\n keys: [], // postprocess required to include props from base classes\r\n getKeyUnion: () => keyNames.join(\" | \"),\r\n });\r\n }\r\n }\r\n\r\n private postProcessModel() {\r\n // complex types\r\n this.dataModel.getComplexTypes().forEach((model) => {\r\n const [baseProps] = this.collectBaseClassPropsAndKeys(model);\r\n model.baseProps = baseProps;\r\n });\r\n // entity types\r\n this.dataModel.getModels().forEach((model) => {\r\n const [baseProps, baseKeys, idName, qIdName] = this.collectBaseClassPropsAndKeys(model);\r\n model.baseProps = baseProps;\r\n\r\n if (!model.keyNames.length && idName) {\r\n model.idModelName = idName;\r\n model.qIdFunctionName = qIdName;\r\n model.generateId = false;\r\n }\r\n model.keyNames.unshift(...baseKeys);\r\n\r\n // sanity check: entity types require key specification\r\n if (!model.keyNames.length) {\r\n throw new Error(`Key property is missing from Entity \"${model.name}\" (${model.odataName})!`);\r\n }\r\n\r\n const isSingleKey = model.keyNames.length === 1;\r\n const props = [...model.baseProps, ...model.props];\r\n model.keys = model.keyNames.map((keyName) => {\r\n const prop = props.find((p) => p.odataName === keyName);\r\n if (!prop) {\r\n throw new Error(`Key with name [${keyName}] not found in props!`);\r\n }\r\n // automatically set key prop to managed, if this is the only key of the given entity\r\n if (prop.managed === undefined) {\r\n prop.managed = !this.options.disableAutoManagedKey && isSingleKey;\r\n }\r\n return prop;\r\n });\r\n });\r\n }\r\n\r\n private collectBaseClassPropsAndKeys(model: ComplexModelType): [Array<PropertyModel>, Array<string>, string, string] {\r\n return model.baseClasses.reduce(\r\n ([props, keys, idName, qIdName], bc) => {\r\n const baseModel = this.dataModel.getModel(bc) || this.dataModel.getComplexType(bc);\r\n let idNameResult = idName;\r\n let qIdNameResult = qIdName;\r\n\r\n // recursive\r\n if (baseModel.baseClasses.length) {\r\n const [parentProps, parentKeys, parentIdName, parentQIdName] = this.collectBaseClassPropsAndKeys(baseModel);\r\n props.unshift(...parentProps);\r\n keys.unshift(...parentKeys);\r\n if (parentIdName) {\r\n idNameResult = parentIdName;\r\n qIdNameResult = parentQIdName;\r\n }\r\n }\r\n\r\n props.push(...baseModel.props);\r\n if (baseModel.keyNames) {\r\n keys.push(...baseModel.keyNames.filter((kn) => !keys.includes(kn)));\r\n idNameResult = baseModel.idModelName;\r\n qIdNameResult = baseModel.qIdFunctionName;\r\n }\r\n return [props, keys, idNameResult, qIdNameResult];\r\n },\r\n [[], [], \"\", \"\"] as [Array<PropertyModel>, Array<string>, string, string]\r\n );\r\n }\r\n\r\n protected mapProp = (p: Property): PropertyModel => {\r\n if (!p.$.Type) {\r\n throw new Error(`No type information given for property [${p.$.Name}]!`);\r\n }\r\n\r\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\r\n const dataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\r\n const configProp = this.serviceConfigHelper.findConfigPropByName(p.$.Name);\r\n const name = this.namingHelper.getModelPropName(configProp?.mappedName || p.$.Name);\r\n\r\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\r\n\r\n // domain object known from service:\r\n // EntityType, ComplexType or EnumType\r\n if (dataType.startsWith(this.namingHelper.getServicePrefix())) {\r\n const resultDt = this.model2Type.get(dataType);\r\n if (!resultDt) {\r\n throw new Error(`Couldn't determine model type for data type with name '${dataType}'`);\r\n }\r\n\r\n // special handling for enums\r\n if (resultDt === DataTypes.EnumType) {\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getEnumName(dataType),\r\n qPath: \"QEnumPath\",\r\n qObject: isCollection ? \"QEnumCollection\" : undefined,\r\n qParam: \"QEnumParam\",\r\n };\r\n }\r\n // handling of complex & entity types\r\n else {\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getModelName(dataType),\r\n qPath: \"QEntityPath\",\r\n qObject: this.namingHelper.getQName(dataType),\r\n qParam: \"QComplexParam\",\r\n };\r\n }\r\n }\r\n // OData built-in data types\r\n else if (dataType.startsWith(Digester.EDM_PREFIX)) {\r\n const { outputType, qPath, qParam, qCollection } = this.mapODataType(dataType);\r\n const { to, toModule: typeModule, converters } = this.dataModel.getConverter(dataType) || {};\r\n\r\n const type = !to ? outputType : to.startsWith(Digester.EDM_PREFIX) ? this.mapODataType(to).outputType : to;\r\n\r\n result = {\r\n dataType: DataTypes.PrimitiveType,\r\n type,\r\n typeModule,\r\n qPath,\r\n qParam,\r\n qObject: isCollection ? qCollection : undefined,\r\n converters,\r\n };\r\n } else {\r\n throw new Error(\r\n `Unknown type [${dataType}]: Not 'Collection(...)', not '${this.namingHelper.getServicePrefix()}*', not OData type 'Edm.*'`\r\n );\r\n }\r\n\r\n return {\r\n odataName: p.$.Name,\r\n name,\r\n odataType: p.$.Type,\r\n required: p.$.Nullable === \"false\",\r\n isCollection: isCollection,\r\n managed: configProp?.managed,\r\n ...result,\r\n };\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"DataModelDigestion.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestion.ts"],"names":[],"mappings":";;;;AAGA,2CAAwC;AAIxC,+DAA4D;AAS5D,MAAsB,QAAQ;IAS5B,YACY,OAAqB,EACrB,MAAS,EACT,OAAyB,EACzB,YAA0B,EACpC,UAAkC;QAJxB,YAAO,GAAP,OAAO,CAAc;QACrB,WAAM,GAAN,MAAM,CAAG;QACT,YAAO,GAAP,OAAO,CAAkB;QACzB,iBAAY,GAAZ,YAAY,CAAc;QAN9B,eAAU,GAA2B,IAAI,GAAG,EAAqB,CAAC;QAmNhE,YAAO,GAAG,CAAC,CAAW,EAAiB,EAAE;YACjD,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;aAC1E;YAED,MAAM,YA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ACtB,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACpE,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC;gBACrC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC;aAC3C;YACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;QACpD,CAAC,EACD,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAA0D,CAC1E,CAAC;IACJ,CAAC;;AAxNH,4BAmSC;AAlSkB,mBAAU,GAAG,MAAM,CAAC;AACpB,uBAAc,GAAG,GAAG,CAAC","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { DataModel } from \"./DataModel\";\r\nimport { ComplexType as ComplexModelType, DataTypes, ODataVersion, PropertyModel } from \"./DataTypeModel\";\r\nimport { ComplexType, EntityType, Property, Schema } from \"./edmx/ODataEdmxModelBase\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\nimport { ServiceConfigHelper } from \"./ServiceConfigHelper\";\r\n\r\nexport interface TypeModel {\r\n outputType: string;\r\n qPath: string;\r\n qCollection: string;\r\n qParam: string | undefined;\r\n}\r\n\r\nexport abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {\r\n protected static EDM_PREFIX = \"Edm.\";\r\n protected static ROOT_OPERATION = \"/\";\r\n\r\n protected readonly dataModel: DataModel;\r\n protected readonly serviceConfigHelper: ServiceConfigHelper;\r\n\r\n private model2Type: Map<string, DataTypes> = new Map<string, DataTypes>();\r\n\r\n protected constructor(\r\n protected version: ODataVersion,\r\n protected schema: S,\r\n protected options: DigestionOptions,\r\n protected namingHelper: NamingHelper,\r\n converters?: MappedConverterChains\r\n ) {\r\n this.dataModel = new DataModel(version, converters);\r\n this.serviceConfigHelper = new ServiceConfigHelper(options);\r\n this.collectModelTypes(this.schema);\r\n }\r\n\r\n protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;\r\n\r\n protected abstract digestEntityContainer(): void;\r\n\r\n /**\r\n * Get essential infos about a given odata type from the version specific service variants.\r\n *\r\n * @param type\r\n * @return tuple of return type, query object, query collection object\r\n */\r\n protected abstract mapODataType(type: string): TypeModel;\r\n\r\n public async digest(): Promise<DataModel> {\r\n this.digestSchema(this.schema);\r\n return this.dataModel;\r\n }\r\n\r\n private collectModelTypes(schema: Schema<ET, CT>) {\r\n const servicePrefix = this.namingHelper.getServicePrefix();\r\n schema.EnumType?.forEach((et) => {\r\n this.model2Type.set(servicePrefix + et.$.Name, DataTypes.EnumType);\r\n });\r\n schema.ComplexType?.forEach((ct) => {\r\n this.model2Type.set(servicePrefix + ct.$.Name, DataTypes.ComplexType);\r\n });\r\n schema.EntityType?.forEach((et) => {\r\n this.model2Type.set(servicePrefix + et.$.Name, DataTypes.ModelType);\r\n });\r\n }\r\n\r\n private digestSchema(schema: Schema<ET, CT>) {\r\n // enums\r\n if (schema.EnumType) {\r\n for (const et of schema.EnumType) {\r\n const name = et.$.Name;\r\n this.dataModel.addEnum(name, {\r\n odataName: name,\r\n name: this.namingHelper.getEnumName(name),\r\n members: et.Member.map((m) => m.$.Name),\r\n });\r\n }\r\n }\r\n\r\n // entity types\r\n this.addEntityType(schema.EntityType);\r\n // complex types\r\n this.addComplexType(schema.ComplexType);\r\n\r\n this.postProcessModel();\r\n\r\n // delegate to concrete entity container digestion\r\n this.digestEntityContainer();\r\n }\r\n\r\n private getBaseModel(model: ComplexType) {\r\n const entityConfig = this.serviceConfigHelper.findConfigEntityByName(model.$.Name);\r\n const entityName = entityConfig?.mappedName || model.$.Name;\r\n\r\n const name = this.namingHelper.getModelName(entityName);\r\n const qName = this.namingHelper.getQName(entityName);\r\n const editableName = this.namingHelper.getEditableModelName(entityName);\r\n const odataName = model.$.Name;\r\n const bType = model.$.BaseType;\r\n const props = [...(model.Property ?? []), ...this.getNavigationProps(model)];\r\n\r\n // support for base types, i.e. extends clause of interfaces\r\n const baseClasses = [];\r\n if (bType) {\r\n baseClasses.push(this.namingHelper.getModelName(bType));\r\n }\r\n\r\n return {\r\n name,\r\n qName,\r\n odataName,\r\n editableName,\r\n baseClasses,\r\n props: props.map(this.mapProp),\r\n baseProps: [], // postprocess required\r\n };\r\n }\r\n\r\n private addComplexType(models: Array<ComplexType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const baseModel = this.getBaseModel(model);\r\n this.dataModel.addComplexType(baseModel.name, baseModel);\r\n }\r\n }\r\n\r\n private addEntityType(models: Array<ET> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const baseModel = this.getBaseModel(model);\r\n const entityConfig = this.serviceConfigHelper.findConfigEntityByName(model.$.Name);\r\n const entityName = entityConfig?.mappedName || model.$.Name;\r\n\r\n // key support: we add keys from this entity,\r\n // but not keys stemming from base classes (postprocess required)\r\n const keyNames: Array<string> = [];\r\n if (entityConfig?.keys?.length) {\r\n keyNames.push(...entityConfig.keys);\r\n } else {\r\n const entity = model as EntityType;\r\n if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {\r\n const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);\r\n keyNames.push(...propNames);\r\n }\r\n }\r\n\r\n this.dataModel.addModel(baseModel.name, {\r\n ...baseModel,\r\n idModelName: this.namingHelper.getIdModelName(entityName),\r\n qIdFunctionName: this.namingHelper.getQIdFunctionName(entityName),\r\n generateId: true,\r\n keyNames: keyNames, // postprocess required to include key specs from base classes\r\n keys: [], // postprocess required to include props from base classes\r\n getKeyUnion: () => keyNames.join(\" | \"),\r\n });\r\n }\r\n }\r\n\r\n private postProcessModel() {\r\n // complex types\r\n this.dataModel.getComplexTypes().forEach((model) => {\r\n const [baseProps] = this.collectBaseClassPropsAndKeys(model);\r\n model.baseProps = baseProps;\r\n });\r\n // entity types\r\n this.dataModel.getModels().forEach((model) => {\r\n const [baseProps, baseKeys, idName, qIdName] = this.collectBaseClassPropsAndKeys(model);\r\n model.baseProps = baseProps;\r\n\r\n if (!model.keyNames.length && idName) {\r\n model.idModelName = idName;\r\n model.qIdFunctionName = qIdName;\r\n model.generateId = false;\r\n }\r\n model.keyNames.unshift(...baseKeys);\r\n\r\n // sanity check: entity types require key specification\r\n if (!model.keyNames.length) {\r\n throw new Error(`Key property is missing from Entity \"${model.name}\" (${model.odataName})!`);\r\n }\r\n\r\n const isSingleKey = model.keyNames.length === 1;\r\n const props = [...model.baseProps, ...model.props];\r\n model.keys = model.keyNames.map((keyName) => {\r\n const prop = props.find((p) => p.odataName === keyName);\r\n if (!prop) {\r\n throw new Error(`Key with name [${keyName}] not found in props!`);\r\n }\r\n // automatically set key prop to managed, if this is the only key of the given entity\r\n if (prop.managed === undefined) {\r\n prop.managed = !this.options.disableAutoManagedKey && isSingleKey;\r\n }\r\n return prop;\r\n });\r\n });\r\n }\r\n\r\n private collectBaseClassPropsAndKeys(model: ComplexModelType): [Array<PropertyModel>, Array<string>, string, string] {\r\n return model.baseClasses.reduce(\r\n ([props, keys, idName, qIdName], bc) => {\r\n const baseModel = this.dataModel.getModel(bc) || this.dataModel.getComplexType(bc);\r\n let idNameResult = idName;\r\n let qIdNameResult = qIdName;\r\n\r\n // recursive\r\n if (baseModel.baseClasses.length) {\r\n const [parentProps, parentKeys, parentIdName, parentQIdName] = this.collectBaseClassPropsAndKeys(baseModel);\r\n props.unshift(...parentProps);\r\n keys.unshift(...parentKeys);\r\n if (parentIdName) {\r\n idNameResult = parentIdName;\r\n qIdNameResult = parentQIdName;\r\n }\r\n }\r\n\r\n props.push(...baseModel.props);\r\n if (baseModel.keyNames) {\r\n keys.push(...baseModel.keyNames.filter((kn) => !keys.includes(kn)));\r\n idNameResult = baseModel.idModelName;\r\n qIdNameResult = baseModel.qIdFunctionName;\r\n }\r\n return [props, keys, idNameResult, qIdNameResult];\r\n },\r\n [[], [], \"\", \"\"] as [Array<PropertyModel>, Array<string>, string, string]\r\n );\r\n }\r\n\r\n protected mapProp = (p: Property): PropertyModel => {\r\n if (!p.$.Type) {\r\n throw new Error(`No type information given for property [${p.$.Name}]!`);\r\n }\r\n\r\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\r\n const dataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\r\n const configProp = this.serviceConfigHelper.findConfigPropByName(p.$.Name);\r\n const name = this.namingHelper.getModelPropName(configProp?.mappedName || p.$.Name);\r\n\r\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\r\n\r\n // domain object known from service:\r\n // EntityType, ComplexType or EnumType\r\n if (dataType.startsWith(this.namingHelper.getServicePrefix())) {\r\n const resultDt = this.model2Type.get(dataType);\r\n if (!resultDt) {\r\n throw new Error(`Couldn't determine model type for data type with name '${dataType}'`);\r\n }\r\n\r\n // special handling for enums\r\n if (resultDt === DataTypes.EnumType) {\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getEnumName(dataType),\r\n qPath: \"QEnumPath\",\r\n qObject: isCollection ? \"QEnumCollection\" : undefined,\r\n qParam: \"QEnumParam\",\r\n };\r\n }\r\n // handling of complex & entity types\r\n else {\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getModelName(dataType),\r\n qPath: \"QEntityPath\",\r\n qObject: this.namingHelper.getQName(dataType),\r\n qParam: \"QComplexParam\",\r\n };\r\n }\r\n }\r\n // OData built-in data types\r\n else if (dataType.startsWith(Digester.EDM_PREFIX)) {\r\n const { outputType, qPath, qParam, qCollection } = this.mapODataType(dataType);\r\n const { to, toModule: typeModule, converters } = this.dataModel.getConverter(dataType) || {};\r\n\r\n const type = !to ? outputType : to.startsWith(Digester.EDM_PREFIX) ? this.mapODataType(to).outputType : to;\r\n\r\n result = {\r\n dataType: DataTypes.PrimitiveType,\r\n type,\r\n typeModule,\r\n qPath,\r\n qParam,\r\n qObject: isCollection ? qCollection : undefined,\r\n converters,\r\n };\r\n } else {\r\n throw new Error(\r\n `Unknown type [${dataType}]: Not 'Collection(...)', not '${this.namingHelper.getServicePrefix()}*', not OData type 'Edm.*'`\r\n );\r\n }\r\n\r\n return {\r\n odataName: p.$.Name,\r\n name,\r\n odataType: p.$.Type,\r\n required: p.$.Nullable === \"false\",\r\n isCollection: isCollection,\r\n managed: configProp?.managed,\r\n ...result,\r\n };\r\n };\r\n}\r\n"]}
@@ -1,13 +1,21 @@
1
1
  import { DigestionOptions } from "../FactoryFunctionModel";
2
- import { PropertyGenerationOptions } from "../OptionModel";
2
+ import { EntityGenerationOptions, PropertyGenerationOptions } from "../OptionModel";
3
3
  export interface ConfiguredProp extends Omit<PropertyGenerationOptions, "name"> {
4
4
  }
5
+ export interface ConfiguredEntity extends Omit<EntityGenerationOptions, "name"> {
6
+ }
5
7
  export declare class ServiceConfigHelper {
6
8
  private propMapping;
9
+ private entityMapping;
7
10
  private propRegExps;
11
+ private entityRegExps;
8
12
  constructor(options: DigestionOptions);
9
13
  private evaluateProps;
10
14
  private getPropByName;
11
15
  private getPropByRegExp;
12
16
  findConfigPropByName: (name: string) => ConfiguredProp | undefined;
17
+ private evaluateEntities;
18
+ private getEntityByName;
19
+ private getEntityByRegExp;
20
+ findConfigEntityByName: (name: string) => ConfiguredEntity | undefined;
13
21
  }
@@ -2,18 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ServiceConfigHelper = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const EXCEPTION_NO_NAME = "PropertiesByName: No value for required attribute [name] specified!";
6
- const EXCEPTION_WRONG_NAME_TYPE = "PropertiesByName: Wrong type for attribute [name]! You have to supply either a plain string or a RegExp.";
5
+ const EXCEPTION_NO_NAME = "No value for required attribute [name] specified!";
6
+ const EXCEPTION_WRONG_NAME_TYPE = "Wrong type for attribute [name]! You have to supply either a plain string or a RegExp.";
7
7
  class ServiceConfigHelper {
8
8
  constructor(options) {
9
9
  this.propMapping = new Map();
10
+ this.entityMapping = new Map();
10
11
  this.propRegExps = [];
12
+ this.entityRegExps = [];
11
13
  this.findConfigPropByName = (name) => {
12
14
  const stringProp = this.getPropByName(name);
13
15
  const reProp = this.getPropByRegExp(name);
14
16
  return stringProp && reProp ? Object.assign(Object.assign({}, reProp), stringProp) : stringProp || reProp;
15
17
  };
18
+ this.findConfigEntityByName = (name) => {
19
+ const stringEnt = this.getEntityByName(name);
20
+ const reEnt = this.getEntityByRegExp(name);
21
+ return stringEnt && reEnt ? Object.assign(Object.assign({}, reEnt), stringEnt) : stringEnt || reEnt;
22
+ };
16
23
  this.evaluateProps(options);
24
+ this.evaluateEntities(options);
17
25
  }
18
26
  evaluateProps(options) {
19
27
  options.propertiesByName.forEach((prop) => {
@@ -58,6 +66,49 @@ class ServiceConfigHelper {
58
66
  return Object.assign(Object.assign({}, result), prop);
59
67
  }, {});
60
68
  }
69
+ evaluateEntities(options) {
70
+ options.entitiesByName.forEach((ent) => {
71
+ if (!ent.name) {
72
+ throw new Error(EXCEPTION_NO_NAME);
73
+ }
74
+ switch (typeof ent.name) {
75
+ case "string":
76
+ // TODO: check for existing prop.name and throw?
77
+ this.entityMapping.set(ent.name, ent);
78
+ break;
79
+ case "object":
80
+ const { source, ignoreCase } = ent.name;
81
+ if (!source) {
82
+ throw new Error(EXCEPTION_WRONG_NAME_TYPE);
83
+ }
84
+ this.entityRegExps.push([new RegExp(`^${source}$`, ignoreCase ? "i" : ""), ent]);
85
+ break;
86
+ default:
87
+ throw new Error(EXCEPTION_WRONG_NAME_TYPE);
88
+ }
89
+ });
90
+ }
91
+ getEntityByName(nameToMap) {
92
+ const stringProp = this.entityMapping.get(nameToMap);
93
+ if (!stringProp) {
94
+ return;
95
+ }
96
+ const { name } = stringProp, attrs = tslib_1.__rest(stringProp, ["name"]);
97
+ return Object.assign({}, attrs);
98
+ }
99
+ getEntityByRegExp(nameToMap) {
100
+ const resultList = this.entityRegExps
101
+ .filter(([regExp]) => regExp.test(nameToMap))
102
+ .map((_a) => {
103
+ var [regExp, _b] = _a, { name, mappedName } = _b, attrs = tslib_1.__rest(_b, ["name", "mappedName"]);
104
+ return (Object.assign({ mappedName: mappedName ? nameToMap.replace(regExp, mappedName) : undefined }, attrs));
105
+ });
106
+ return !resultList.length
107
+ ? undefined
108
+ : resultList.reduce((result, prop) => {
109
+ return Object.assign(Object.assign({}, result), prop);
110
+ }, {});
111
+ }
61
112
  }
62
113
  exports.ServiceConfigHelper = ServiceConfigHelper;
63
114
  //# sourceMappingURL=ServiceConfigHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceConfigHelper.js","sourceRoot":"","sources":["../../src/data-model/ServiceConfigHelper.ts"],"names":[],"mappings":";;;;AAKA,MAAM,iBAAiB,GAAG,qEAAqE,CAAC;AAChG,MAAM,yBAAyB,GAC7B,0GAA0G,CAAC;AAE7G,MAAa,mBAAmB;IAI9B,YAAY,OAAyB;QAH7B,gBAAW,GAAG,IAAI,GAAG,EAAqC,CAAC;QAC3D,gBAAW,GAA+C,EAAE,CAAC;QAqD9D,yBAAoB,GAAG,CAAC,IAAY,EAA8B,EAAE;YACzE,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YAE1C,OAAO,UAAU,IAAI,MAAM,CAAC,CAAC,iCAAM,MAAM,GAAK,UAAU,EAAG,CAAC,CAAC,UAAU,IAAI,MAAM,CAAC;QACpF,CAAC,CAAC;QAvDA,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAEO,aAAa,CAAC,OAAyB;QAC7C,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CA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AAC,EAAwC,EAAE,EAAE;gBAA5C,CAAC,MAAM,UAAiC,EAA/B,EAAE,IAAI,EAAE,UAAU,OAAY,EAAP,KAAK,sBAA5B,sBAA8B,CAAF;YAAQ,OAAA,iBACjD,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,IACvE,KAAK,EACR,CAAA;SAAA,CAAC,CAAC;QAEN,OAAO,CAAC,UAAU,CAAC,MAAM;YACvB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,UAAU,CAAC,MAAM,CAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;gBACjD,uCAAY,MAAM,GAAK,IAAI,EAAG;YAChC,CAAC,EAAE,EAAE,CAAC,CAAC;IACb,CAAC;CAQF;AA7DD,kDA6DC","sourcesContent":["import { DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { PropertyGenerationOptions } from \"../OptionModel\";\r\n\r\nexport interface ConfiguredProp extends Omit<PropertyGenerationOptions, \"name\"> {}\r\n\r\nconst EXCEPTION_NO_NAME = \"PropertiesByName: No value for required attribute [name] specified!\";\r\nconst EXCEPTION_WRONG_NAME_TYPE =\r\n \"PropertiesByName: Wrong type for attribute [name]! You have to supply either a plain string or a RegExp.\";\r\n\r\nexport class ServiceConfigHelper {\r\n private propMapping = new Map<string, PropertyGenerationOptions>();\r\n private propRegExps: Array<[RegExp, PropertyGenerationOptions]> = [];\r\n\r\n constructor(options: DigestionOptions) {\r\n this.evaluateProps(options);\r\n }\r\n\r\n private evaluateProps(options: DigestionOptions) {\r\n options.propertiesByName.forEach((prop) => {\r\n if (!prop.name) {\r\n throw new Error(EXCEPTION_NO_NAME);\r\n }\r\n switch (typeof prop.name) {\r\n case \"string\":\r\n // TODO: check for existing prop.name and throw?\r\n this.propMapping.set(prop.name, prop);\r\n break;\r\n case \"object\":\r\n const { source, ignoreCase } = prop.name as RegExp;\r\n if (!source) {\r\n throw new Error(EXCEPTION_WRONG_NAME_TYPE);\r\n }\r\n this.propRegExps.push([new RegExp(`^${source}$`, ignoreCase ? \"i\" : \"\"), prop]);\r\n break;\r\n default:\r\n throw new Error(EXCEPTION_WRONG_NAME_TYPE);\r\n }\r\n });\r\n }\r\n\r\n private getPropByName(nameToMap: string): ConfiguredProp | undefined {\r\n const stringProp = this.propMapping.get(nameToMap);\r\n if (!stringProp) {\r\n return;\r\n }\r\n const { name, ...attrs } = stringProp;\r\n return { ...attrs };\r\n }\r\n\r\n private getPropByRegExp(nameToMap: string): ConfiguredProp | undefined {\r\n const resultList = this.propRegExps\r\n .filter(([regExp]) => regExp.test(nameToMap))\r\n .map(([regExp, { name, mappedName, ...attrs }]) => ({\r\n mappedName: mappedName ? nameToMap.replace(regExp, mappedName) : undefined,\r\n ...attrs,\r\n }));\r\n\r\n return !resultList.length\r\n ? undefined\r\n : resultList.reduce<ConfiguredProp>((result, prop) => {\r\n return { ...result, ...prop };\r\n }, {});\r\n }\r\n\r\n public findConfigPropByName = (name: string): ConfiguredProp | undefined => {\r\n const stringProp = this.getPropByName(name);\r\n const reProp = this.getPropByRegExp(name);\r\n\r\n return stringProp && reProp ? { ...reProp, ...stringProp } : stringProp || reProp;\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"ServiceConfigHelper.js","sourceRoot":"","sources":["../../src/data-model/ServiceConfigHelper.ts"],"names":[],"mappings":";;;;AAMA,MAAM,iBAAiB,GAAG,mDAAmD,CAAC;AAC9E,MAAM,yBAAyB,GAC7B,wFAAwF,CAAC;AAE3F,MAAa,mBAAmB;IAM9B,YAAY,OAAyB;QAL7B,gBAAW,GAAG,IAAI,GAAG,EAAqC,CAAC;QAC3D,kBAAa,GAAG,IAAI,GAAG,EAAmC,CAAC;QAC3D,gBAAW,GAA+C,EAAE,CAAC;QAC7D,kBAAa,GAA6C,EAAE,CAAC;QAsD9D,yBAAoB,GAAG,CAAC,IAAY,EAA8B,EAAE;YACzE,MAAM,UA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C,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aAC5C,GAAG,CAAC,CAAC,EAAwC,EAAE,EAAE;gBAA5C,CAAC,MAAM,UAAiC,EAA/B,EAAE,IAAI,EAAE,UAAU,OAAY,EAAP,KAAK,sBAA5B,sBAA8B,CAAF;YAAQ,OAAA,iBACjD,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,IACvE,KAAK,EACR,CAAA;SAAA,CAAC,CAAC;QAEN,OAAO,CAAC,UAAU,CAAC,MAAM;YACvB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,UAAU,CAAC,MAAM,CAAmB,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;gBACnD,uCAAY,MAAM,GAAK,IAAI,EAAG;YAChC,CAAC,EAAE,EAAE,CAAC,CAAC;IACb,CAAC;CAQF;AAtHD,kDAsHC","sourcesContent":["import { DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { EntityGenerationOptions, PropertyGenerationOptions } from \"../OptionModel\";\r\n\r\nexport interface ConfiguredProp extends Omit<PropertyGenerationOptions, \"name\"> {}\r\nexport interface ConfiguredEntity extends Omit<EntityGenerationOptions, \"name\"> {}\r\n\r\nconst EXCEPTION_NO_NAME = \"No value for required attribute [name] specified!\";\r\nconst EXCEPTION_WRONG_NAME_TYPE =\r\n \"Wrong type for attribute [name]! You have to supply either a plain string or a RegExp.\";\r\n\r\nexport class ServiceConfigHelper {\r\n private propMapping = new Map<string, PropertyGenerationOptions>();\r\n private entityMapping = new Map<string, EntityGenerationOptions>();\r\n private propRegExps: Array<[RegExp, PropertyGenerationOptions]> = [];\r\n private entityRegExps: Array<[RegExp, EntityGenerationOptions]> = [];\r\n\r\n constructor(options: DigestionOptions) {\r\n this.evaluateProps(options);\r\n this.evaluateEntities(options);\r\n }\r\n\r\n private evaluateProps(options: DigestionOptions) {\r\n options.propertiesByName.forEach((prop) => {\r\n if (!prop.name) {\r\n throw new Error(EXCEPTION_NO_NAME);\r\n }\r\n switch (typeof prop.name) {\r\n case \"string\":\r\n // TODO: check for existing prop.name and throw?\r\n this.propMapping.set(prop.name, prop);\r\n break;\r\n case \"object\":\r\n const { source, ignoreCase } = prop.name as RegExp;\r\n if (!source) {\r\n throw new Error(EXCEPTION_WRONG_NAME_TYPE);\r\n }\r\n this.propRegExps.push([new RegExp(`^${source}$`, ignoreCase ? \"i\" : \"\"), prop]);\r\n break;\r\n default:\r\n throw new Error(EXCEPTION_WRONG_NAME_TYPE);\r\n }\r\n });\r\n }\r\n\r\n private getPropByName(nameToMap: string): ConfiguredProp | undefined {\r\n const stringProp = this.propMapping.get(nameToMap);\r\n if (!stringProp) {\r\n return;\r\n }\r\n const { name, ...attrs } = stringProp;\r\n return { ...attrs };\r\n }\r\n\r\n private getPropByRegExp(nameToMap: string): ConfiguredProp | undefined {\r\n const resultList = this.propRegExps\r\n .filter(([regExp]) => regExp.test(nameToMap))\r\n .map(([regExp, { name, mappedName, ...attrs }]) => ({\r\n mappedName: mappedName ? nameToMap.replace(regExp, mappedName) : undefined,\r\n ...attrs,\r\n }));\r\n\r\n return !resultList.length\r\n ? undefined\r\n : resultList.reduce<ConfiguredProp>((result, prop) => {\r\n return { ...result, ...prop };\r\n }, {});\r\n }\r\n\r\n public findConfigPropByName = (name: string): ConfiguredProp | undefined => {\r\n const stringProp = this.getPropByName(name);\r\n const reProp = this.getPropByRegExp(name);\r\n\r\n return stringProp && reProp ? { ...reProp, ...stringProp } : stringProp || reProp;\r\n };\r\n\r\n private evaluateEntities(options: DigestionOptions) {\r\n options.entitiesByName.forEach((ent) => {\r\n if (!ent.name) {\r\n throw new Error(EXCEPTION_NO_NAME);\r\n }\r\n switch (typeof ent.name) {\r\n case \"string\":\r\n // TODO: check for existing prop.name and throw?\r\n this.entityMapping.set(ent.name, ent);\r\n break;\r\n case \"object\":\r\n const { source, ignoreCase } = ent.name as RegExp;\r\n if (!source) {\r\n throw new Error(EXCEPTION_WRONG_NAME_TYPE);\r\n }\r\n this.entityRegExps.push([new RegExp(`^${source}$`, ignoreCase ? \"i\" : \"\"), ent]);\r\n break;\r\n default:\r\n throw new Error(EXCEPTION_WRONG_NAME_TYPE);\r\n }\r\n });\r\n }\r\n\r\n private getEntityByName(nameToMap: string): ConfiguredEntity | undefined {\r\n const stringProp = this.entityMapping.get(nameToMap);\r\n if (!stringProp) {\r\n return;\r\n }\r\n const { name, ...attrs } = stringProp;\r\n return { ...attrs };\r\n }\r\n\r\n private getEntityByRegExp(nameToMap: string): ConfiguredEntity | undefined {\r\n const resultList = this.entityRegExps\r\n .filter(([regExp]) => regExp.test(nameToMap))\r\n .map(([regExp, { name, mappedName, ...attrs }]) => ({\r\n mappedName: mappedName ? nameToMap.replace(regExp, mappedName) : undefined,\r\n ...attrs,\r\n }));\r\n\r\n return !resultList.length\r\n ? undefined\r\n : resultList.reduce<ConfiguredEntity>((result, prop) => {\r\n return { ...result, ...prop };\r\n }, {});\r\n }\r\n\r\n public findConfigEntityByName = (name: string): ConfiguredEntity | undefined => {\r\n const stringEnt = this.getEntityByName(name);\r\n const reEnt = this.getEntityByRegExp(name);\r\n\r\n return stringEnt && reEnt ? { ...reEnt, ...stringEnt } : stringEnt || reEnt;\r\n };\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ODataEdmxModelBase.js","sourceRoot":"","sources":["../../../src/data-model/edmx/ODataEdmxModelBase.ts"],"names":[],"mappings":"","sourcesContent":["export interface ODataEdmxModelBase<VersionedSchema> {\r\n \"edmx:Edmx\": {\r\n $: {\r\n Version: string;\r\n \"xmlns:edmx\": string;\r\n };\r\n // \"edmx:Reference\": Array<any>;\r\n \"edmx:DataServices\": Array<DataService<VersionedSchema>>;\r\n };\r\n}\r\n\r\nexport interface DataService<VersionedSchema> {\r\n Schema: Array<VersionedSchema>;\r\n}\r\n\r\nexport interface Schema<ET extends EntityType, CT extends ComplexType> {\r\n $: {\r\n Namespace: string;\r\n xmlns: string;\r\n };\r\n EntityType?: Array<ET>;\r\n ComplexType?: Array<CT>;\r\n EnumType?: Array<EnumType>;\r\n EntityContainer?: Array<any>;\r\n}\r\n\r\nexport interface EntityContainer<ES = EntitySet> {\r\n $: {\r\n Name: string;\r\n };\r\n EntitySet?: Array<ES>;\r\n}\r\n\r\nexport interface EntitySet {\r\n $: {\r\n Name: string;\r\n EntityType: string;\r\n };\r\n}\r\n\r\nexport interface EntityType {\r\n $: {\r\n Name: string;\r\n BaseType?: string;\r\n };\r\n Key: Array<PropertyRef>;\r\n Property: Array<Property>;\r\n}\r\n\r\nexport interface ComplexType extends Omit<EntityType, \"Key\"> {}\r\n\r\nexport interface PropertyRef {\r\n PropertyRef: Array<{ $: { Name: string } }>;\r\n}\r\n\r\nexport interface Property {\r\n $: {\r\n Name: string;\r\n Type: string;\r\n MaxLength?: number;\r\n Nullable?: \"true\" | \"false\";\r\n Precision?: number;\r\n };\r\n}\r\n\r\nexport interface EnumType {\r\n $: {\r\n Name: string;\r\n };\r\n Member: Array<Member>;\r\n}\r\n\r\nexport interface Member {\r\n $: {\r\n Name: string;\r\n Value: number;\r\n };\r\n}\r\n\r\nexport interface Parameter extends Property {\r\n Unicode?: boolean;\r\n}\r\n\r\nexport interface ReturnType {\r\n $: {\r\n Type: string;\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"ODataEdmxModelBase.js","sourceRoot":"","sources":["../../../src/data-model/edmx/ODataEdmxModelBase.ts"],"names":[],"mappings":"","sourcesContent":["export interface ODataEdmxModelBase<VersionedSchema> {\n \"edmx:Edmx\": {\n $: {\n Version: string;\n \"xmlns:edmx\": string;\n };\n // \"edmx:Reference\": Array<any>;\n \"edmx:DataServices\": Array<DataService<VersionedSchema>>;\n };\n}\n\nexport interface DataService<VersionedSchema> {\n Schema: Array<VersionedSchema>;\n}\n\nexport interface Schema<ET extends EntityType, CT extends ComplexType> {\n $: {\n Namespace: string;\n xmlns: string;\n };\n EntityType?: Array<ET>;\n ComplexType?: Array<CT>;\n EnumType?: Array<EnumType>;\n EntityContainer?: Array<any>;\n}\n\nexport interface EntityContainer<ES = EntitySet> {\n $: {\n Name: string;\n };\n EntitySet?: Array<ES>;\n}\n\nexport interface EntitySet {\n $: {\n Name: string;\n EntityType: string;\n };\n}\n\nexport interface EntityType {\n $: {\n Name: string;\n BaseType?: string;\n };\n Key: Array<PropertyRef>;\n Property: Array<Property>;\n}\n\nexport interface ComplexType extends Omit<EntityType, \"Key\"> {}\n\nexport interface PropertyRef {\n PropertyRef: Array<{ $: { Name: string } }>;\n}\n\nexport interface Property {\n $: {\n Name: string;\n Type: string;\n MaxLength?: number;\n Nullable?: \"true\" | \"false\";\n Precision?: number;\n };\n}\n\nexport interface EnumType {\n $: {\n Name: string;\n };\n Member: Array<Member>;\n}\n\nexport interface Member {\n $: {\n Name: string;\n Value: number;\n };\n}\n\nexport interface Parameter extends Property {\n Unicode?: boolean;\n}\n\nexport interface ReturnType {\n $: {\n Type: string;\n };\n}\n"]}
@@ -96,7 +96,7 @@ const defaultConfig = {
96
96
  },
97
97
  },
98
98
  propertiesByName: [],
99
- // entitiesByName: [],
99
+ entitiesByName: [],
100
100
  };
101
101
  const { models, queryObjects, services } = defaultConfig.naming;
102
102
  const minimalNamingConfig = {
@@ -1 +1 @@
1
- {"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../src/defaultConfig.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAElC,+CAA+D;AAC/D,+CAA6D;AAE7D;;GAEG;AACH,MAAM,aAAa,GAA0C;IAC3D,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,EA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AA1C,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\n/**\r\n * The default configuration.\r\n */\r\nconst defaultConfig: Omit<RunOptions, \"source\" | \"output\"> = {\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 disableAutoManagedKey: false,\r\n allowRenaming: 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 serviceResolverFunction: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"create\",\r\n suffix: \"serviceResolver\",\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: \"navTo\",\r\n suffix: \"\",\r\n },\r\n privateProps: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"_\",\r\n suffix: \"\",\r\n },\r\n publicProps: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\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 serviceResolverFunction: {\r\n prefix: services.serviceResolverFunction.prefix,\r\n suffix: services.serviceResolverFunction.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(): Omit<RunOptions, \"source\" | \"output\"> {\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(): Omit<RunOptions, \"source\" | \"output\"> {\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;AAE7D;;GAEG;AACH,MAAM,aAAa,GAA0C;IAC3D,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,qBAAqB,EAAE,KAAK;IAC5B,aAAa,EAAE,KAAK;IACpB,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,I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AE,YAAY,CAAC,WAAW,CAAC,MAAM;SACxC;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,IAAI,EAAE;YACJ,kBAAkB,EAAE,IAAI;SACzB;QACD,UAAU,EAAE;YACV,kBAAkB,EAAE,IAAI;YACxB,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM;YAClC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM;SACnC;QACD,YAAY,EAAE;YACZ,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,MAAM;YACpC,MAAM,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;QACD,uBAAuB,EAAE;YACvB,MAAM,EAAE,QAAQ,CAAC,uBAAuB,CAAC,MAAM;YAC/C,MAAM,EAAE,QAAQ,CAAC,uBAAuB,CAAC,MAAM;SAChD;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\n/**\r\n * The default configuration.\r\n */\r\nconst defaultConfig: Omit<RunOptions, \"source\" | \"output\"> = {\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 disableAutoManagedKey: false,\r\n allowRenaming: 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 serviceResolverFunction: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"create\",\r\n suffix: \"serviceResolver\",\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: \"navTo\",\r\n suffix: \"\",\r\n },\r\n privateProps: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"_\",\r\n suffix: \"\",\r\n },\r\n publicProps: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\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 serviceResolverFunction: {\r\n prefix: services.serviceResolverFunction.prefix,\r\n suffix: services.serviceResolverFunction.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(): Omit<RunOptions, \"source\" | \"output\"> {\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(): Omit<RunOptions, \"source\" | \"output\"> {\r\n const { naming, ...passThrough } = defaultConfig;\r\n return deepmerge(passThrough, { naming: minimalNamingConfig });\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,uCAAqH;AACrH,uDAAkD;AAClD,sDAA2D;AAiB3D,uDAAoD;AAEpD,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,cAAc,GAAG;IACrB,UAAU,EAAE,yBAAyB;IACrC,KAAK,EAAE,oBAAoB;IAC3B,KAAK,EAAE,oBAAoB;CAC5B,CAAC;AAEF,SAAsB,gBAAgB,CACpC,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B;;QAE1B,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAClF,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;CAAA;AARD,4CAQC;AAED,MAAM,gBAAgB;IACpB,YACU,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B;QAH1B,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAgB;QACvB,YAAO,GAAP,OAAO,CAAe;QACtB,iBAAY,GAAZ,YAAY,CAAc;QA0F5B,4BAAuB,GAAG,CAAC,SAAwB,EAAE,EAAE;YAC7D,OAAO;gBACL,KAAK,EAAE,gBAAK,CAAC,OAAO;gBACpB,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,SAAS,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AG,OAAO,4BAA4B,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,GAAG;oBACvG,CAAC,CAAC,SAAS,CAAC,OAAO;wBACnB,CAAC,CAAC,sFAAsF;4BACtF,wBAAwB,kBAAkB,CAAC,IAAI,GAAG;wBACpD,CAAC,CAAC,sBAAsB;4BACtB,YAAY,kBAAkB,CAAC,IAAI,GACzC,GAAG;gBACH,UAAU,CAAC,CAAC,CAAC,UAAU,OAAO,6BAA6B,CAAC,CAAC,CAAC,EAAE;aACjE;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport { MethodDeclarationStructure, OptionalKind, PropertyDeclarationStructure, Scope, SourceFile } from \"ts-morph\";\nimport { upperCaseFirst } from \"upper-case-first\";\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\n\nimport { DataModel } from \"../data-model/DataModel\";\nimport {\n ActionImportType,\n ComplexType,\n DataTypes,\n EntitySetType,\n FunctionImportType,\n ModelType,\n OperationType,\n OperationTypes,\n PropertyModel,\n SingletonType,\n} from \"../data-model/DataTypeModel\";\nimport { NamingHelper } from \"../data-model/NamingHelper\";\nimport { ProjectManager } from \"../project/ProjectManager\";\nimport { ImportContainer } from \"./ImportContainer\";\n\nconst ROOT_SERVICE = \"ODataService\";\n\nconst RESPONSE_TYPES = {\n collection: \"ODataCollectionResponse\",\n model: \"ODataModelResponse\",\n value: \"ODataValueResponse\",\n};\n\nexport async function generateServices(\n dataModel: DataModel,\n project: ProjectManager,\n version: ODataVersions,\n namingHelper: NamingHelper\n) {\n const generator = new ServiceGenerator(dataModel, project, version, namingHelper);\n return generator.generate();\n}\n\nclass ServiceGenerator {\n constructor(\n private dataModel: DataModel,\n private project: ProjectManager,\n private version: ODataVersions,\n private namingHelper: NamingHelper\n ) {}\n\n public async generate(): Promise<void> {\n const sourceFile = await this.project.createMainServiceFile();\n const serviceName = this.namingHelper.getMainServiceName();\n const container = this.dataModel.getEntityContainer();\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\n\n await this.generateModelServices();\n\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\n importContainer.addFromClientApi(\"ODataClient\");\n importContainer.addFromService(ROOT_SERVICE);\n\n sourceFile.addClass({\n isExported: true,\n name: serviceName,\n typeParameters: [\"ClientType extends ODataClient\"],\n extends: `${ROOT_SERVICE}<ClientType>`,\n properties: [\n {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(\"name\"),\n type: \"string\",\n initializer: `\"${this.namingHelper.getODataServiceName()}\"`,\n },\n ...this.generateEntityServiceResolverProp(container.entitySets, importContainer),\n ...this.generateServiceGettersByAssignment(container.entitySets),\n ...this.generateServiceTypeProps(container.singletons, this.namingHelper.getServiceName, importContainer),\n ...Object.values(unboundOperations).map(({ operation }) => this.generateQOperationProps(operation)),\n ],\n methods: [\n ...this.generateServiceTypeGetters(container.singletons, this.namingHelper.getServiceName),\n ...this.generateUnboundOperations(unboundOperations, importContainer),\n ],\n });\n\n sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\n }\n\n private generateEntityServiceResolverProp(\n services: Record<string, EntitySetType>,\n importContainer: ImportContainer\n ): OptionalKind<PropertyDeclarationStructure>[] {\n return Object.values(services).map(({ name, entityType }) => {\n const resolverName = this.namingHelper.getServiceResolverName(entityType.name);\n\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), resolverName);\n\n return {\n name: this.namingHelper.getPublicPropNameForService(name),\n scope: Scope.Public,\n initializer: `${resolverName}(this.client, this.getPath(), \"${name}\")`,\n };\n });\n }\n\n private generateServiceGettersByAssignment(\n services: Record<string, EntitySetType>\n ): OptionalKind<PropertyDeclarationStructure>[] {\n return Object.values(services).map(({ name, odataName, entityType }) => {\n const propName = this.namingHelper.getPublicPropNameForService(name);\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(name),\n initializer: `this.${propName}.get.bind(this.${propName})`,\n };\n });\n }\n\n private generateServiceTypeProps(\n services: Record<string, SingletonType | EntitySetType>,\n typeRetriever: (name: string) => string,\n importContainer: ImportContainer\n ): OptionalKind<PropertyDeclarationStructure>[] {\n return Object.values(services).map(({ name, entityType }) => {\n const type = typeRetriever(entityType.name);\n\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), type);\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(name),\n type: `${type}<ClientType>`,\n hasQuestionToken: true,\n };\n });\n }\n\n private generateQOperationProps = (operation: OperationType) => {\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(operation.qName),\n type: operation.qName,\n hasQuestionToken: true,\n };\n };\n\n private generateServiceTypeGetters(\n services: Record<string, SingletonType | EntitySetType>,\n typeRetriever: (name: string) => string\n ): OptionalKind<MethodDeclarationStructure>[] {\n return Object.values(services).map(({ name, odataName, entityType }) => {\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\n const serviceType = typeRetriever(entityType.name);\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(name),\n statements: [\n `if(!${propName}) {`,\n // prettier-ignore\n ` ${propName} = new ${serviceType}(this.client, this.getPath(), \"${odataName}\")`,\n \"}\",\n `return ${propName}`,\n ],\n };\n });\n }\n\n private getVersionSuffix() {\n return this.version === ODataVersions.V2 ? \"V2\" : \"V4\";\n }\n\n private async generateModelService(\n model: ComplexType,\n serviceName: string,\n serviceFile: SourceFile,\n importContainer: ImportContainer\n ) {\n const entityServiceType = \"EntityTypeService\" + this.getVersionSuffix();\n const collectionServiceType = \"CollectionService\" + this.getVersionSuffix();\n\n const editableModelName = model.editableName;\n const operations = this.dataModel.getOperationTypeByBinding(model.name);\n const props = [...model.baseProps, ...model.props];\n const modelProps = props.filter(\n (prop) => prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType\n );\n const primColProps = props.filter(\n (prop) => prop.isCollection && prop.dataType !== DataTypes.ModelType && prop.dataType !== DataTypes.ComplexType\n );\n\n importContainer.addFromService(entityServiceType);\n importContainer.addFromClientApi(\"ODataClient\");\n importContainer.addGeneratedModel(model.name, editableModelName);\n importContainer.addGeneratedQObject(model.qName, firstCharLowerCase(model.qName));\n\n // generate EntityTypeService\n serviceFile.addClass({\n isExported: true,\n name: serviceName,\n typeParameters: [\"ClientType extends ODataClient\"],\n extends: entityServiceType + `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}>`,\n ctors: [\n {\n parameters: [\n { name: \"client\", type: \"ClientType\" },\n { name: \"basePath\", type: \"string\" },\n { name: \"name\", type: \"string\" },\n ],\n statements: [`super(client, basePath, name, ${firstCharLowerCase(model.qName)});`],\n },\n ],\n properties: [\n ...this.generateModelProps(modelProps, collectionServiceType, serviceName, importContainer),\n ...this.generatePrimitiveCollectionProps(primColProps, collectionServiceType, importContainer),\n ...operations.map(this.generateQOperationProps),\n ],\n methods: [\n ...this.generateModelPropGetters(modelProps, collectionServiceType),\n ...this.generatePrimitiveCollectionGetters(primColProps, collectionServiceType),\n ...this.generateBoundOperations(operations, importContainer),\n ],\n });\n }\n\n private generateModelProps(\n modelProps: Array<PropertyModel>,\n collectionServiceType: string,\n serviceName: string,\n importContainer: ImportContainer\n ): Array<PropertyDeclarationStructure> {\n return modelProps.map((prop) => {\n const complexType = this.dataModel.getComplexType(prop.type);\n const key = this.namingHelper.getServiceName(prop.type);\n let propModelType = prop.isCollection ? this.namingHelper.getCollectionServiceName(prop.type) : key;\n\n if (prop.isCollection && complexType) {\n const editableName = complexType.editableName;\n importContainer.addFromService(collectionServiceType);\n importContainer.addGeneratedModel(complexType.name, editableName);\n importContainer.addGeneratedQObject(complexType.qName, firstCharLowerCase(complexType.qName));\n propModelType = `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${editableName}>`;\n } else {\n // don't include imports for this type\n if (serviceName !== key) {\n importContainer.addGeneratedService(key, propModelType);\n }\n\n propModelType = `${propModelType}<ClientType>`;\n }\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(prop.name),\n type: propModelType,\n hasQuestionToken: true,\n } as PropertyDeclarationStructure;\n });\n }\n\n private generatePrimitiveCollectionProps(\n primColProps: Array<PropertyModel>,\n collectionServiceType: string,\n importContainer: ImportContainer\n ): Array<PropertyDeclarationStructure> {\n return primColProps.map((prop) => {\n const isEnum = prop.dataType === DataTypes.EnumType;\n const type = isEnum ? `EnumCollection<${prop.type}>` : `${upperCaseFirst(prop.type)}Collection`;\n const qType = isEnum ? \"QEnumCollection\" : `Q${type}`;\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\n\n if (!prop.qObject) {\n throw new Error(\"Illegal State: [qObject] must be provided for Collection types!\");\n }\n\n importContainer.addFromService(collectionServiceType);\n importContainer.addFromQObject(prop.qObject, firstCharLowerCase(prop.qObject));\n if (isEnum) {\n importContainer.addGeneratedModel(prop.type);\n importContainer.addFromQObject(\"EnumCollection\");\n } else {\n importContainer.addFromQObject(type);\n }\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(prop.name),\n type: `${collectionType}`,\n hasQuestionToken: true,\n } as PropertyDeclarationStructure;\n });\n }\n\n private generateModelPropGetters(\n modelProps: Array<PropertyModel>,\n collectionServiceType: string\n ): Array<MethodDeclarationStructure> {\n return modelProps.map((prop) => {\n const complexType = this.dataModel.getComplexType(prop.type);\n const isComplexCollection = prop.isCollection && complexType;\n const type = isComplexCollection\n ? collectionServiceType\n : prop.isCollection\n ? this.namingHelper.getCollectionServiceName(prop.type)\n : this.namingHelper.getServiceName(prop.type);\n const typeWithGenerics = isComplexCollection\n ? `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${complexType.editableName}>`\n : `${type}<ClientType>`;\n\n const privateSrvProp = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\n\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\n returnType: typeWithGenerics,\n statements: [\n `if(!${privateSrvProp}) {`,\n // prettier-ignore\n ` ${privateSrvProp} = new ${type}(this.client, this.getPath(), \"${prop.odataName}\"${isComplexCollection ? `, ${firstCharLowerCase(complexType.qName)}`: \"\"})`,\n \"}\",\n `return ${privateSrvProp}`,\n ],\n } as MethodDeclarationStructure;\n });\n }\n\n private generatePrimitiveCollectionGetters(\n primColProps: Array<PropertyModel>,\n collectionServiceType: string\n ): Array<MethodDeclarationStructure> {\n return primColProps.map((prop) => {\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\n statements: [\n `if(!${propName}) {`,\n // prettier-ignore\n ` ${propName} = new ${collectionServiceType}(this.client, this.getPath(), \"${prop.odataName}\", ${firstCharLowerCase(prop.qObject!)})`,\n \"}\",\n `return ${propName}`,\n ],\n } as MethodDeclarationStructure;\n });\n }\n\n private async generateEntityCollectionService(\n model: ModelType,\n serviceName: string,\n serviceFile: SourceFile,\n importContainer: ImportContainer\n ) {\n const entitySetServiceType = \"EntitySetService\" + this.getVersionSuffix();\n const editableModelName = model.editableName;\n const qObjectName = firstCharLowerCase(model.qName);\n\n importContainer.addFromService(entitySetServiceType);\n importContainer.addGeneratedModel(model.idModelName);\n importContainer.addGeneratedQObject(model.qIdFunctionName);\n\n const collectionOperations = this.dataModel.getOperationTypeByBinding(`Collection(${model.name})`);\n\n serviceFile.addClass({\n isExported: true,\n name: this.namingHelper.getCollectionServiceName(model.name),\n typeParameters: [\"ClientType extends ODataClient\"],\n extends:\n entitySetServiceType +\n `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}, ${model.idModelName}, ${serviceName}<ClientType>>`,\n ctors: [\n {\n parameters: [\n { name: \"client\", type: \"ClientType\" },\n { name: \"basePath\", type: \"string\" },\n { name: \"name\", type: \"string\" },\n ],\n statements: [\n `super(client, basePath, name, ${qObjectName}, ${serviceName}, new ${model.qIdFunctionName}(name));`,\n ],\n },\n ],\n properties: [...collectionOperations.map(this.generateQOperationProps)],\n methods: [...this.generateBoundOperations(collectionOperations, importContainer)],\n });\n }\n\n private generateEntityServiceResolver(\n model: ModelType,\n serviceName: string,\n serviceFile: SourceFile,\n importContainer: ImportContainer\n ) {\n const idFunctionName = model.qIdFunctionName;\n const collectionName = this.namingHelper.getCollectionServiceName(model.name);\n\n importContainer.addFromClientApi(\"ODataClient\");\n importContainer.addFromService(\"EntityServiceResolver\");\n importContainer.addGeneratedQObject(idFunctionName);\n\n serviceFile.addFunction({\n name: this.namingHelper.getServiceResolverName(model.name),\n isExported: true,\n parameters: [\n {\n name: \"client\",\n type: \"ODataClient\",\n },\n {\n name: \"basePath\",\n type: \"string\",\n },\n {\n name: \"entityName\",\n type: \"string\",\n },\n ],\n statements: [\n `return new EntityServiceResolver(client, basePath, entityName, ${idFunctionName}, ${serviceName}, ${collectionName});`,\n ],\n });\n }\n\n private async generateModelServices() {\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\n for (const model of this.dataModel.getModels()) {\n const serviceName = this.namingHelper.getServiceName(model.name);\n const serviceFile = await this.project.createServiceFile(serviceName);\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\n\n // entity type service\n await this.generateModelService(model, serviceName, serviceFile, importContainer);\n\n // entity collection service\n await this.generateEntityCollectionService(model, serviceName, serviceFile, importContainer);\n\n // the resolver function\n await this.generateEntityServiceResolver(model, serviceName, serviceFile, importContainer);\n\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\n }\n\n // build service file for complex types\n for (const model of this.dataModel.getComplexTypes()) {\n const serviceName = this.namingHelper.getServiceName(model.name);\n const serviceFile = await this.project.createServiceFile(serviceName);\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\n\n // entity type service\n await this.generateModelService(model, serviceName, serviceFile, importContainer);\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\n }\n }\n\n private generateBoundOperations(operations: Array<OperationType>, importContainer: ImportContainer) {\n return operations.reduce<Array<OptionalKind<MethodDeclarationStructure>>>((collector, operation) => {\n collector.push(this.generateMethod(operation.name, operation, importContainer));\n\n return collector;\n }, []);\n }\n\n private generateUnboundOperations(\n operations: Array<FunctionImportType | ActionImportType>,\n importContainer: ImportContainer\n ) {\n return Object.values(operations).reduce<Array<OptionalKind<MethodDeclarationStructure>>>(\n (collector, { name, operation }) => {\n collector.push(this.generateMethod(name, operation, importContainer));\n\n return collector;\n },\n []\n );\n }\n\n private generateMethod(\n name: string,\n operation: OperationType,\n importContainer: ImportContainer\n ): OptionalKind<MethodDeclarationStructure> {\n const isFunc = operation.type === OperationTypes.Function;\n const odataType = operation.returnType?.isCollection\n ? RESPONSE_TYPES.collection + this.getVersionSuffix()\n : operation.returnType?.dataType === DataTypes.PrimitiveType\n ? RESPONSE_TYPES.value + this.getVersionSuffix()\n : RESPONSE_TYPES.model + this.getVersionSuffix();\n const returnType = operation.returnType;\n const requestConfigParam = { name: \"requestConfig\", hasQuestionToken: true, type: \"ODataClientConfig<ClientType>\" };\n const hasParams = operation.parameters.length > 0;\n\n // importing dependencies\n importContainer.addFromClientApi(\"ODataClientConfig\", \"ODataResponse\");\n importContainer.addFromCore(odataType);\n if (returnType?.type) {\n if ([DataTypes.EnumType, DataTypes.ModelType, DataTypes.ComplexType].includes(returnType.dataType)) {\n importContainer.addGeneratedModel(returnType.type);\n }\n }\n importContainer.addGeneratedQObject(operation.qName);\n if (hasParams) {\n importContainer.addGeneratedModel(operation.paramsModelName);\n }\n\n const qOpProp = \"this.\" + this.namingHelper.getPrivatePropName(operation.qName);\n\n return {\n scope: Scope.Public,\n isAsync: true,\n name,\n parameters: hasParams\n ? [{ name: \"params\", type: operation.paramsModelName }, requestConfigParam]\n : [requestConfigParam],\n returnType: `ODataResponse<${odataType}<${returnType?.type || \"void\"}>>`,\n statements: [\n `if(!${qOpProp}) {`,\n ` ${qOpProp} = new ${operation.qName}()`,\n \"}\",\n\n `const url = this.addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params\" : \"\"}));`,\n `${returnType ? \"const response = await \" : \"return\"} this.client.${\n !isFunc\n ? // actions: since V4\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${requestConfigParam.name})`\n : operation.usePost\n ? // V2 POST => BUT values are still query params, they are not part of the request body\n `post(url, undefined, ${requestConfigParam.name})`\n : // functions: since V2\n `get(url, ${requestConfigParam.name})`\n };`,\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\n ],\n };\n }\n}\n"]}
1
+ {"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,uCAAqH;AACrH,uDAAkD;AAClD,sDAA2D;AAiB3D,uDAAoD;AAEpD,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,cAAc,GAAG;IACrB,UAAU,EAAE,yBAAyB;IACrC,KAAK,EAAE,oBAAoB;IAC3B,KAAK,EAAE,oBAAoB;CAC5B,CAAC;AAEF,SAAsB,gBAAgB,CACpC,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B;;QAE1B,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAClF,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;CAAA;AARD,4CAQC;AAED,MAAM,gBAAgB;IACpB,YACU,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B;QAH1B,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAgB;QACvB,YAAO,GAAP,OAAO,CAAe;QACtB,iBAAY,GAAZ,YAAY,CAAc;QA0F5B,4BAAuB,GAAG,CAAC,SAAwB,EAAE,EAAE;YAC7D,OAAO;gBACL,KAAK,EAAE,gBAAK,CAAC,OAAO;gBACpB,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,SAAS,CAAC,KAAK,CAAC;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CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,GAAG;oBACvG,CAAC,CAAC,SAAS,CAAC,OAAO;wBACnB,CAAC,CAAC,sFAAsF;4BACtF,wBAAwB,kBAAkB,CAAC,IAAI,GAAG;wBACpD,CAAC,CAAC,sBAAsB;4BACtB,YAAY,kBAAkB,CAAC,IAAI,GACzC,GAAG;gBACH,UAAU,CAAC,CAAC,CAAC,UAAU,OAAO,6BAA6B,CAAC,CAAC,CAAC,EAAE;aACjE;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { MethodDeclarationStructure, OptionalKind, PropertyDeclarationStructure, Scope, SourceFile } from \"ts-morph\";\r\nimport { upperCaseFirst } from \"upper-case-first\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport {\r\n ActionImportType,\r\n ComplexType,\r\n DataTypes,\r\n EntitySetType,\r\n FunctionImportType,\r\n ModelType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n SingletonType,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { ProjectManager } from \"../project/ProjectManager\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nconst ROOT_SERVICE = \"ODataService\";\r\n\r\nconst RESPONSE_TYPES = {\r\n collection: \"ODataCollectionResponse\",\r\n model: \"ODataModelResponse\",\r\n value: \"ODataValueResponse\",\r\n};\r\n\r\nexport async function generateServices(\r\n dataModel: DataModel,\r\n project: ProjectManager,\r\n version: ODataVersions,\r\n namingHelper: NamingHelper\r\n) {\r\n const generator = new ServiceGenerator(dataModel, project, version, namingHelper);\r\n return generator.generate();\r\n}\r\n\r\nclass ServiceGenerator {\r\n constructor(\r\n private dataModel: DataModel,\r\n private project: ProjectManager,\r\n private version: ODataVersions,\r\n private namingHelper: NamingHelper\r\n ) {}\r\n\r\n public async generate(): Promise<void> {\r\n const sourceFile = await this.project.createMainServiceFile();\r\n const serviceName = this.namingHelper.getMainServiceName();\r\n const container = this.dataModel.getEntityContainer();\r\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\r\n\r\n await this.generateModelServices();\r\n\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n importContainer.addFromClientApi(\"ODataClient\");\r\n importContainer.addFromService(ROOT_SERVICE);\r\n\r\n sourceFile.addClass({\r\n isExported: true,\r\n name: serviceName,\r\n typeParameters: [\"ClientType extends ODataClient\"],\r\n extends: `${ROOT_SERVICE}<ClientType>`,\r\n properties: [\r\n {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(\"name\"),\r\n type: \"string\",\r\n initializer: `\"${this.namingHelper.getODataServiceName()}\"`,\r\n },\r\n ...this.generateEntityServiceResolverProp(container.entitySets, importContainer),\r\n ...this.generateServiceGettersByAssignment(container.entitySets),\r\n ...this.generateServiceTypeProps(container.singletons, this.namingHelper.getServiceName, importContainer),\r\n ...Object.values(unboundOperations).map(({ operation }) => this.generateQOperationProps(operation)),\r\n ],\r\n methods: [\r\n ...this.generateServiceTypeGetters(container.singletons, this.namingHelper.getServiceName),\r\n ...this.generateUnboundOperations(unboundOperations, importContainer),\r\n ],\r\n });\r\n\r\n sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\r\n }\r\n\r\n private generateEntityServiceResolverProp(\r\n services: Record<string, EntitySetType>,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure>[] {\r\n return Object.values(services).map(({ name, entityType }) => {\r\n const resolverName = this.namingHelper.getServiceResolverName(entityType.name);\r\n\r\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), resolverName);\r\n\r\n return {\r\n name: this.namingHelper.getPublicPropNameForService(name),\r\n scope: Scope.Public,\r\n initializer: `${resolverName}(this.client, this.getPath(), \"${name}\")`,\r\n };\r\n });\r\n }\r\n\r\n private generateServiceGettersByAssignment(\r\n services: Record<string, EntitySetType>\r\n ): OptionalKind<PropertyDeclarationStructure>[] {\r\n return Object.values(services).map(({ name, odataName, entityType }) => {\r\n const propName = this.namingHelper.getPublicPropNameForService(name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(name),\r\n initializer: `this.${propName}.get.bind(this.${propName})`,\r\n };\r\n });\r\n }\r\n\r\n private generateServiceTypeProps(\r\n services: Record<string, SingletonType | EntitySetType>,\r\n typeRetriever: (name: string) => string,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure>[] {\r\n return Object.values(services).map(({ name, entityType }) => {\r\n const type = typeRetriever(entityType.name);\r\n\r\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), type);\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(name),\r\n type: `${type}<ClientType>`,\r\n hasQuestionToken: true,\r\n };\r\n });\r\n }\r\n\r\n private generateQOperationProps = (operation: OperationType) => {\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(operation.qName),\r\n type: operation.qName,\r\n hasQuestionToken: true,\r\n };\r\n };\r\n\r\n private generateServiceTypeGetters(\r\n services: Record<string, SingletonType | EntitySetType>,\r\n typeRetriever: (name: string) => string\r\n ): OptionalKind<MethodDeclarationStructure>[] {\r\n return Object.values(services).map(({ name, odataName, entityType }) => {\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\r\n const serviceType = typeRetriever(entityType.name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n // prettier-ignore\r\n ` ${propName} = new ${serviceType}(this.client, this.getPath(), \"${odataName}\")`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n });\r\n }\r\n\r\n private getVersionSuffix() {\r\n return this.version === ODataVersions.V2 ? \"V2\" : \"V4\";\r\n }\r\n\r\n private async generateModelService(\r\n model: ComplexType,\r\n serviceName: string,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const entityServiceType = \"EntityTypeService\" + this.getVersionSuffix();\r\n const collectionServiceType = \"CollectionService\" + this.getVersionSuffix();\r\n\r\n const editableModelName = model.editableName;\r\n const operations = this.dataModel.getOperationTypeByBinding(model.name);\r\n const props = [...model.baseProps, ...model.props];\r\n const modelProps = props.filter(\r\n (prop) => prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType\r\n );\r\n const primColProps = props.filter(\r\n (prop) => prop.isCollection && prop.dataType !== DataTypes.ModelType && prop.dataType !== DataTypes.ComplexType\r\n );\r\n\r\n importContainer.addFromService(entityServiceType);\r\n importContainer.addFromClientApi(\"ODataClient\");\r\n importContainer.addGeneratedModel(model.name, editableModelName);\r\n importContainer.addGeneratedQObject(model.qName, firstCharLowerCase(model.qName));\r\n\r\n // generate EntityTypeService\r\n serviceFile.addClass({\r\n isExported: true,\r\n name: serviceName,\r\n typeParameters: [\"ClientType extends ODataClient\"],\r\n extends: entityServiceType + `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [`super(client, basePath, name, ${firstCharLowerCase(model.qName)});`],\r\n },\r\n ],\r\n properties: [\r\n ...this.generateModelProps(modelProps, collectionServiceType, serviceName, importContainer),\r\n ...this.generatePrimitiveCollectionProps(primColProps, collectionServiceType, importContainer),\r\n ...operations.map(this.generateQOperationProps),\r\n ],\r\n methods: [\r\n ...this.generateModelPropGetters(modelProps, collectionServiceType),\r\n ...this.generatePrimitiveCollectionGetters(primColProps, collectionServiceType),\r\n ...this.generateBoundOperations(operations, importContainer),\r\n ],\r\n });\r\n }\r\n\r\n private generateModelProps(\r\n modelProps: Array<PropertyModel>,\r\n collectionServiceType: string,\r\n serviceName: string,\r\n importContainer: ImportContainer\r\n ): Array<PropertyDeclarationStructure> {\r\n return modelProps.map((prop) => {\r\n const complexType = this.dataModel.getComplexType(prop.type);\r\n const key = this.namingHelper.getServiceName(prop.type);\r\n let propModelType = prop.isCollection ? this.namingHelper.getCollectionServiceName(prop.type) : key;\r\n\r\n if (prop.isCollection && complexType) {\r\n const editableName = complexType.editableName;\r\n importContainer.addFromService(collectionServiceType);\r\n importContainer.addGeneratedModel(complexType.name, editableName);\r\n importContainer.addGeneratedQObject(complexType.qName, firstCharLowerCase(complexType.qName));\r\n propModelType = `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${editableName}>`;\r\n } else {\r\n // don't include imports for this type\r\n if (serviceName !== key) {\r\n importContainer.addGeneratedService(key, propModelType);\r\n }\r\n\r\n propModelType = `${propModelType}<ClientType>`;\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: propModelType,\r\n hasQuestionToken: true,\r\n } as PropertyDeclarationStructure;\r\n });\r\n }\r\n\r\n private generatePrimitiveCollectionProps(\r\n primColProps: Array<PropertyModel>,\r\n collectionServiceType: string,\r\n importContainer: ImportContainer\r\n ): Array<PropertyDeclarationStructure> {\r\n return primColProps.map((prop) => {\r\n const isEnum = prop.dataType === DataTypes.EnumType;\r\n const type = isEnum ? `EnumCollection<${prop.type}>` : `${upperCaseFirst(prop.type)}Collection`;\r\n const qType = isEnum ? \"QEnumCollection\" : `Q${type}`;\r\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\r\n\r\n if (!prop.qObject) {\r\n throw new Error(\"Illegal State: [qObject] must be provided for Collection types!\");\r\n }\r\n\r\n importContainer.addFromService(collectionServiceType);\r\n importContainer.addFromQObject(prop.qObject, firstCharLowerCase(prop.qObject));\r\n if (isEnum) {\r\n importContainer.addGeneratedModel(prop.type);\r\n importContainer.addFromQObject(\"EnumCollection\");\r\n } else {\r\n importContainer.addFromQObject(type);\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: `${collectionType}`,\r\n hasQuestionToken: true,\r\n } as PropertyDeclarationStructure;\r\n });\r\n }\r\n\r\n private generateModelPropGetters(\r\n modelProps: Array<PropertyModel>,\r\n collectionServiceType: string\r\n ): Array<MethodDeclarationStructure> {\r\n return modelProps.map((prop) => {\r\n const complexType = this.dataModel.getComplexType(prop.type);\r\n const isComplexCollection = prop.isCollection && complexType;\r\n const type = isComplexCollection\r\n ? collectionServiceType\r\n : prop.isCollection\r\n ? this.namingHelper.getCollectionServiceName(prop.type)\r\n : this.namingHelper.getServiceName(prop.type);\r\n const typeWithGenerics = isComplexCollection\r\n ? `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${complexType.editableName}>`\r\n : `${type}<ClientType>`;\r\n\r\n const privateSrvProp = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n returnType: typeWithGenerics,\r\n statements: [\r\n `if(!${privateSrvProp}) {`,\r\n // prettier-ignore\r\n ` ${privateSrvProp} = new ${type}(this.client, this.getPath(), \"${prop.odataName}\"${isComplexCollection ? `, ${firstCharLowerCase(complexType.qName)}`: \"\"})`,\r\n \"}\",\r\n `return ${privateSrvProp}`,\r\n ],\r\n } as MethodDeclarationStructure;\r\n });\r\n }\r\n\r\n private generatePrimitiveCollectionGetters(\r\n primColProps: Array<PropertyModel>,\r\n collectionServiceType: string\r\n ): Array<MethodDeclarationStructure> {\r\n return primColProps.map((prop) => {\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n // prettier-ignore\r\n ` ${propName} = new ${collectionServiceType}(this.client, this.getPath(), \"${prop.odataName}\", ${firstCharLowerCase(prop.qObject!)})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n } as MethodDeclarationStructure;\r\n });\r\n }\r\n\r\n private async generateEntityCollectionService(\r\n model: ModelType,\r\n serviceName: string,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const entitySetServiceType = \"EntitySetService\" + this.getVersionSuffix();\r\n const editableModelName = model.editableName;\r\n const qObjectName = firstCharLowerCase(model.qName);\r\n\r\n importContainer.addFromService(entitySetServiceType);\r\n importContainer.addGeneratedModel(model.idModelName);\r\n importContainer.addGeneratedQObject(model.qIdFunctionName);\r\n\r\n const collectionOperations = this.dataModel.getOperationTypeByBinding(`Collection(${model.name})`);\r\n\r\n serviceFile.addClass({\r\n isExported: true,\r\n name: this.namingHelper.getCollectionServiceName(model.name),\r\n typeParameters: [\"ClientType extends ODataClient\"],\r\n extends:\r\n entitySetServiceType +\r\n `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}, ${model.idModelName}, ${serviceName}<ClientType>>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [\r\n `super(client, basePath, name, ${qObjectName}, ${serviceName}, new ${model.qIdFunctionName}(name));`,\r\n ],\r\n },\r\n ],\r\n properties: [...collectionOperations.map(this.generateQOperationProps)],\r\n methods: [...this.generateBoundOperations(collectionOperations, importContainer)],\r\n });\r\n }\r\n\r\n private generateEntityServiceResolver(\r\n model: ModelType,\r\n serviceName: string,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const idFunctionName = model.qIdFunctionName;\r\n const collectionName = this.namingHelper.getCollectionServiceName(model.name);\r\n\r\n importContainer.addFromClientApi(\"ODataClient\");\r\n importContainer.addFromService(\"EntityServiceResolver\");\r\n importContainer.addGeneratedQObject(idFunctionName);\r\n\r\n serviceFile.addFunction({\r\n name: this.namingHelper.getServiceResolverName(model.name),\r\n isExported: true,\r\n parameters: [\r\n {\r\n name: \"client\",\r\n type: \"ODataClient\",\r\n },\r\n {\r\n name: \"basePath\",\r\n type: \"string\",\r\n },\r\n {\r\n name: \"entityName\",\r\n type: \"string\",\r\n },\r\n ],\r\n statements: [\r\n `return new EntityServiceResolver(client, basePath, entityName, ${idFunctionName}, ${serviceName}, ${collectionName});`,\r\n ],\r\n });\r\n }\r\n\r\n private async generateModelServices() {\r\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\r\n for (const model of this.dataModel.getModels()) {\r\n const serviceName = this.namingHelper.getServiceName(model.name);\r\n const serviceFile = await this.project.createServiceFile(serviceName);\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n // entity type service\r\n await this.generateModelService(model, serviceName, serviceFile, importContainer);\r\n\r\n // entity collection service\r\n await this.generateEntityCollectionService(model, serviceName, serviceFile, importContainer);\r\n\r\n // the resolver function\r\n await this.generateEntityServiceResolver(model, serviceName, serviceFile, importContainer);\r\n\r\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\r\n }\r\n\r\n // build service file for complex types\r\n for (const model of this.dataModel.getComplexTypes()) {\r\n const serviceName = this.namingHelper.getServiceName(model.name);\r\n const serviceFile = await this.project.createServiceFile(serviceName);\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n // entity type service\r\n await this.generateModelService(model, serviceName, serviceFile, importContainer);\r\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\r\n }\r\n }\r\n\r\n private generateBoundOperations(operations: Array<OperationType>, importContainer: ImportContainer) {\r\n return operations.reduce<Array<OptionalKind<MethodDeclarationStructure>>>((collector, operation) => {\r\n collector.push(this.generateMethod(operation.name, operation, importContainer));\r\n\r\n return collector;\r\n }, []);\r\n }\r\n\r\n private generateUnboundOperations(\r\n operations: Array<FunctionImportType | ActionImportType>,\r\n importContainer: ImportContainer\r\n ) {\r\n return Object.values(operations).reduce<Array<OptionalKind<MethodDeclarationStructure>>>(\r\n (collector, { name, operation }) => {\r\n collector.push(this.generateMethod(name, operation, importContainer));\r\n\r\n return collector;\r\n },\r\n []\r\n );\r\n }\r\n\r\n private generateMethod(\r\n name: string,\r\n operation: OperationType,\r\n importContainer: ImportContainer\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const isFunc = operation.type === OperationTypes.Function;\r\n const odataType = operation.returnType?.isCollection\r\n ? RESPONSE_TYPES.collection + this.getVersionSuffix()\r\n : operation.returnType?.dataType === DataTypes.PrimitiveType\r\n ? RESPONSE_TYPES.value + this.getVersionSuffix()\r\n : RESPONSE_TYPES.model + this.getVersionSuffix();\r\n const returnType = operation.returnType;\r\n const requestConfigParam = { name: \"requestConfig\", hasQuestionToken: true, type: \"ODataClientConfig<ClientType>\" };\r\n const hasParams = operation.parameters.length > 0;\r\n\r\n // importing dependencies\r\n importContainer.addFromClientApi(\"ODataClientConfig\", \"ODataResponse\");\r\n importContainer.addFromCore(odataType);\r\n if (returnType?.type) {\r\n if ([DataTypes.EnumType, DataTypes.ModelType, DataTypes.ComplexType].includes(returnType.dataType)) {\r\n importContainer.addGeneratedModel(returnType.type);\r\n }\r\n }\r\n importContainer.addGeneratedQObject(operation.qName);\r\n if (hasParams) {\r\n importContainer.addGeneratedModel(operation.paramsModelName);\r\n }\r\n\r\n const qOpProp = \"this.\" + this.namingHelper.getPrivatePropName(operation.qName);\r\n\r\n return {\r\n scope: Scope.Public,\r\n isAsync: true,\r\n name,\r\n parameters: hasParams\r\n ? [{ name: \"params\", type: operation.paramsModelName }, requestConfigParam]\r\n : [requestConfigParam],\r\n returnType: `ODataResponse<${odataType}<${returnType?.type || \"void\"}>>`,\r\n statements: [\r\n `if(!${qOpProp}) {`,\r\n ` ${qOpProp} = new ${operation.qName}()`,\r\n \"}\",\r\n\r\n `const url = this.addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params\" : \"\"}));`,\r\n `${returnType ? \"const response = await \" : \"return\"} this.client.${\r\n !isFunc\r\n ? // actions: since V4\r\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${requestConfigParam.name})`\r\n : operation.usePost\r\n ? // V2 POST => BUT values are still query params, they are not part of the request body\r\n `post(url, undefined, ${requestConfigParam.name})`\r\n : // functions: since V2\r\n `get(url, ${requestConfigParam.name})`\r\n };`,\r\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\r\n ],\r\n };\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odata2ts/odata2ts",
3
- "version": "0.19.2",
3
+ "version": "0.20.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -46,14 +46,14 @@
46
46
  "js"
47
47
  ],
48
48
  "peerDependencies": {
49
- "@odata2ts/odata-client-api": "^0.6.0",
50
- "@odata2ts/odata-query-objects": "^0.17.0",
51
- "@odata2ts/odata-service": "^0.13.5"
49
+ "@odata2ts/odata-client-api": "^0.6.3",
50
+ "@odata2ts/odata-query-objects": "^0.17.1",
51
+ "@odata2ts/odata-service": "^0.13.7"
52
52
  },
53
53
  "dependencies": {
54
54
  "@odata2ts/converter-api": "^0.1.1",
55
55
  "@odata2ts/converter-runtime": "^0.1.2",
56
- "@odata2ts/odata-core": "^0.3.6",
56
+ "@odata2ts/odata-core": "^0.3.7",
57
57
  "camel-case": "^4.1.2",
58
58
  "commander": "^9.1.0",
59
59
  "constant-case": "^3.0.4",
@@ -72,9 +72,9 @@
72
72
  },
73
73
  "devDependencies": {
74
74
  "@odata2ts/converter-v2-to-v4": "^0.1.2",
75
- "@odata2ts/odata-client-api": "^0.6.2",
76
- "@odata2ts/odata-query-objects": "^0.17.0",
77
- "@odata2ts/odata-service": "^0.13.5",
75
+ "@odata2ts/odata-client-api": "^0.6.3",
76
+ "@odata2ts/odata-query-objects": "^0.17.1",
77
+ "@odata2ts/odata-service": "^0.13.7",
78
78
  "@types/fs-extra": "^9.0.13",
79
79
  "@types/jest": "^27.4.1",
80
80
  "@types/node": "^17.0.23",
@@ -88,6 +88,6 @@
88
88
  "typescript": "^4.9.4"
89
89
  },
90
90
  "types": "./lib/index.d.ts",
91
- "gitHead": "f094f0a6606f8f3d4ce17b8300edb74259cc5825",
91
+ "gitHead": "e822bca2fc167a490cd7467167868c624fe7b9a1",
92
92
  "readme": "README.md"
93
93
  }