@odata2ts/odata2ts 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,17 +3,42 @@
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.39.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.38.1...@odata2ts/odata2ts@0.39.0) (2024-10-28)
7
+
8
+ ### Features
9
+
10
+ * **generator:** add cast operations to base type services ([#327](https://github.com/odata2ts/odata2ts/issues/327)) ([df52284](https://github.com/odata2ts/odata2ts/commit/df522846e275c160266c02d5c5b49c8be995b3fb))
11
+ * **generator:** conversion of subtype by control info ([#331](https://github.com/odata2ts/odata2ts/issues/331)) ([a8a8a50](https://github.com/odata2ts/odata2ts/commit/a8a8a50c5a619cfe7e32bf6fa399e2f5b1f55ffa))
12
+ * **generator:** qobjects with casted subtype props ([#328](https://github.com/odata2ts/odata2ts/issues/328)) ([88eb9bd](https://github.com/odata2ts/odata2ts/commit/88eb9bdedf02fa4d74ebfc638f89aca583f1852d))
13
+ * **service:** subtype services ([#332](https://github.com/odata2ts/odata2ts/issues/332)) ([6918735](https://github.com/odata2ts/odata2ts/commit/691873557d21418561f017189fe896d544ffcba5))
14
+ * **service:** support no url encoding ([#326](https://github.com/odata2ts/odata2ts/issues/326)) ([304bc62](https://github.com/odata2ts/odata2ts/commit/304bc627199766f7a930bffe28e39bb24eea39b1))
15
+
16
+ ### BREAKING CHANGES
17
+
18
+ * **service:** dedicated options parameter for all services
19
+
20
+ ## [0.38.1](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.38.0...@odata2ts/odata2ts@0.38.1) (2024-09-19)
21
+
22
+ ### Bug Fixes
23
+
24
+ * **generator:** api usage analysis must respect alias ([#317](https://github.com/odata2ts/odata2ts/issues/317)) ([5877161](https://github.com/odata2ts/odata2ts/commit/5877161317d09c5ded9b44ce4a7ecd0f65e65235))
25
+
26
+ * **generator:** set peer dependency of TS to >= 4.7 ([949d874](https://github.com/odata2ts/odata2ts/commit/949d8749828dda06a2072d4153556c53d0adb3cf))
27
+
6
28
  # [0.38.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.37.0...@odata2ts/odata2ts@0.38.0) (2024-09-11)
7
29
 
8
30
  ### Bug Fixes
9
31
 
10
32
  * auto name clash resolution for v4 actions ([#315](https://github.com/odata2ts/odata2ts/issues/315)) ([3366843](https://github.com/odata2ts/odata2ts/commit/3366843dc227f9c8edd5b4660d63c564cc82f121))
33
+
11
34
  * **generator:** add rimraf as dependency ([9f08ccd](https://github.com/odata2ts/odata2ts/commit/9f08ccd5fc68b1de381ea1cb711c6e667ca5be98))
35
+
12
36
  * **generator:** use typeof when using enums as types ([baf784f](https://github.com/odata2ts/odata2ts/commit/baf784f76f119c2394ba4f1c3cd93359dc31171e))
13
37
 
14
38
  ### Features
15
39
 
16
40
  * compile src & test folders as sanity check ([12607f0](https://github.com/odata2ts/odata2ts/commit/12607f04a4ec1142d750318cab5964f3d9a513c4))
41
+
17
42
  * **generator:** allow for numeric enums ([#308](https://github.com/odata2ts/odata2ts/issues/308)) ([a5c36e6](https://github.com/odata2ts/odata2ts/commit/a5c36e6433bb5d793d5f970b12d6ebb8a4c5270d))
18
43
 
19
44
  # [0.37.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.36.3...@odata2ts/odata2ts@0.37.0) (2024-08-25)
@@ -29,6 +54,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
29
54
  ### BREAKING CHANGES
30
55
 
31
56
  * as there is no generated index file all file paths must be fixed.
57
+
32
58
  * ESM tends to break stuff
33
59
 
34
60
  ## [0.36.3](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.36.2...@odata2ts/odata2ts@0.36.3) (2024-08-12)
@@ -54,9 +80,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
54
80
  ### Features
55
81
 
56
82
  * **generator:** add ts-nocheck to each generated file by default ([#284](https://github.com/odata2ts/odata2ts/issues/284)) ([655a3ab](https://github.com/odata2ts/odata2ts/commit/655a3ab801c79e34841f35b1a72cf7d02064f3b8))
83
+
57
84
  * **generator:** generate services based on API reference chain ([#275](https://github.com/odata2ts/odata2ts/issues/275)) ([8fd415b](https://github.com/odata2ts/odata2ts/commit/8fd415bd0a49144e14da08cd5e32d44e947c7f23))
85
+
58
86
  * **generator:** support function overloads for different parameter sets ([#282](https://github.com/odata2ts/odata2ts/issues/282)) ([0b53271](https://github.com/odata2ts/odata2ts/commit/0b532710499d975155c21984a62707ecf4789439))
87
+
59
88
  * **generator:** support type-only imports ([#290](https://github.com/odata2ts/odata2ts/issues/290)) ([dea381e](https://github.com/odata2ts/odata2ts/commit/dea381e7c31f84e03acbaafc15ede58aa9041c13))
89
+
60
90
  * model files always get type checked (no [@ts-nocheck](https://github.com/ts-nocheck)) ([#288](https://github.com/odata2ts/odata2ts/issues/288)) ([43ca58b](https://github.com/odata2ts/odata2ts/commit/43ca58bf72bb8e783b80798eaa73d5fd19676627))
61
91
 
62
92
  ### BREAKING CHANGES
@@ -91,6 +91,9 @@ export interface QueryObjectNamingOptions extends NamingStrategyOption, Required
91
91
  propNamingStrategy?: NamingStrategies;
92
92
  idFunctions: RequiredNamingOptions;
93
93
  operations?: OperationNamingOptions;
94
+ baseType: RequiredNamingOptions & {
95
+ applyQNaming?: boolean;
96
+ };
94
97
  }
95
98
  export interface OperationNamingOptions extends StandardNamingOptions {
96
99
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"NamingModel.js","sourceRoot":"","sources":["../src/NamingModel.ts"],"names":[],"mappings":"AAKA,MAAM,CAAN,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,6BAAS,CAAA;IACT,8CAA0B,CAAA;IAC1B,4CAAwB,CAAA;IACxB,kDAA8B,CAAA;IAC9B,4CAAwB,CAAA;AAC1B,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B","sourcesContent":["/**\r\n * The available naming strategies.\r\n */\r\nimport { PartialDeep } from \"type-fest\";\r\n\r\nexport enum NamingStrategies {\r\n NONE = \"\",\r\n PASCAL_CASE = \"pascalCase\",\r\n CAMEL_CASE = \"camelCase\",\r\n CONSTANT_CASE = \"constantCase\",\r\n SNAKE_CASE = \"snakeCase\",\r\n}\r\n\r\n/**\r\n * Based on an existing configuration (for example default settings) the user only specifies what needs\r\n * to be changed. Hence, all options are completely optional.\r\n */\r\nexport interface OverridableNamingOptions extends PartialDeep<NameSettings> {}\r\n\r\n/**\r\n * The required and optional name settings for the generator.\r\n */\r\nexport interface NameSettings {\r\n /**\r\n * Because multiple artefacts are generated out of the same entity, some name settings are required in order\r\n * to differentiate those artefacts. Out-of-the-box odata2ts provides you with sensible default settings,\r\n * so that you only need to override those settings you want to change.\r\n *\r\n * However, sometimes it makes more sense to start from scratch, so that the defaults don't interfere with\r\n * your own configuration. In this scenario this switch should be enabled to only have default values for\r\n * the required name settings.\r\n */\r\n minimalDefaults?: boolean;\r\n\r\n /**\r\n * Generation options for models, i.e. interfaces representing entity or complex types.\r\n */\r\n models: ModelNamingOptions;\r\n\r\n /**\r\n * Generation options for Query Objects.\r\n *\r\n * By default, prefix = \"Q\"\r\n */\r\n queryObjects: QueryObjectNamingOptions;\r\n\r\n services: ServiceNamingOptions;\r\n}\r\n\r\nexport interface ModelNamingOptions extends NamingStrategyOption, StandardNamingOptions {\r\n /**\r\n * All generated models are bundled into one file.\r\n * This option specifies the formatting of the file name.\r\n */\r\n fileName: FileNamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Choose a specific strategy to format property names of models: pascal-case, camel-case, etc.\r\n * By default, camel-case.\r\n */\r\n propNamingStrategy?: NamingStrategies;\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 override the naming options here.\r\n * By default, prefix = \"Editable\"\r\n */\r\n editableModels: EntityDerivedNamingOptions;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n *\r\n * You can configure the naming options here.\r\n * By default, suffix = \"Id\"\r\n */\r\n idModels: EntityDerivedNamingOptions;\r\n\r\n /**\r\n * Operation parameter models are generated from function or action signatures.\r\n *\r\n * You can configure the naming options here.\r\n * By default, suffix = \"Params\"\r\n */\r\n operationParamModels: EntityDerivedNamingOptions;\r\n}\r\n\r\nexport interface EntityDerivedNamingOptions extends RequiredNamingOptions {\r\n applyModelNaming?: boolean;\r\n}\r\n\r\nexport interface QueryObjectNamingOptions extends NamingStrategyOption, RequiredNamingOptions {\r\n /**\r\n * All generated models are bundled into one file.\r\n * This option specifies the formatting of the file name.\r\n */\r\n fileName: FileNamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Choose a specific strategy to format property names of query objects: pascal-case, camel-case, etc.\r\n * By default, camel-case.\r\n */\r\n propNamingStrategy?: NamingStrategies;\r\n\r\n idFunctions: RequiredNamingOptions;\r\n\r\n operations?: OperationNamingOptions;\r\n}\r\n\r\nexport interface OperationNamingOptions extends StandardNamingOptions {\r\n /**\r\n * Naming options for actions only.\r\n * When this configuration is provided, the parent configuration regarding suffix and prefix is ignored.\r\n */\r\n action?: StandardNamingOptions;\r\n /**\r\n * Naming options for functions only.\r\n * When this configuration is provided, the parent configuration regarding suffix and prefix is ignored.\r\n */\r\n function?: StandardNamingOptions;\r\n}\r\n\r\nexport interface NamingStrategyOption {\r\n /**\r\n * Choose a specific strategy to format names: pascal-case, camel-case, etc.\r\n * Defaults to pascal-case.\r\n */\r\n namingStrategy?: NamingStrategies;\r\n}\r\n\r\nexport interface FileNamingStrategyOption {\r\n /**\r\n * Choose a specific strategy to format names: pascal-case, camel-case, etc.\r\n * Defaults to pascal-case.\r\n */\r\n namingStrategy?: NamingStrategies;\r\n}\r\n\r\nexport interface StandardNamingOptions {\r\n /**\r\n * Prefix all names, e.g. \"I\" => \"ITest\"\r\n */\r\n prefix?: string;\r\n /**\r\n * Suffix all names, e.g. \"model\" => \"TestModel\"\r\n */\r\n suffix?: string;\r\n}\r\n\r\nexport interface RequiredNamingOptions extends Required<StandardNamingOptions> {}\r\n\r\n/**\r\n * Naming options for generated service classes.\r\n * These options affect the main service as well as all services generated for each entity, complex and collection type.\r\n *\r\n * There exists one specialty about services: The file names are not configurable.\r\n * File names are determined by the name of their corresponding classes, so that service file name\r\n * and service class name always correspond.\r\n *\r\n * By default, suffix = Service and namingStrategy = PascalCase\r\n */\r\nexport interface ServiceNamingOptions extends NamingStrategyOption, RequiredNamingOptions {\r\n /**\r\n * Controls the naming options for the main odata service.\r\n * By default, the base service naming options are applied.\r\n * But since this is the main entry point for users, it can be configured individually here.\r\n *\r\n * By default, applyServiceNaming = true\r\n */\r\n main?: NamingStrategyOption & StandardNamingOptions & { applyServiceNaming?: boolean };\r\n\r\n /**\r\n * Name of the service responsible for entity collections.\r\n *\r\n * By default, suffix = Collection and applyServiceNaming = true\r\n */\r\n collection: RequiredNamingOptions & { applyServiceNaming?: boolean };\r\n\r\n /**\r\n * Naming for getter method of another service.\r\n *\r\n * By default, namingStrategy = camelCase\r\n */\r\n relatedServiceGetter: NamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Operations are functions and actions of the OData service and are represented as methods\r\n * of the generated service class. This setting controls the naming of the corresponding\r\n * function.\r\n *\r\n * By default, namingStrategy = camelCase\r\n */\r\n operations?: NamingStrategyOption & OperationNamingOptions;\r\n\r\n /**\r\n * Naming options for private properties of service classes.\r\n *\r\n * By default, prefix = _\r\n */\r\n privateProps: NamingStrategyOption & RequiredNamingOptions;\r\n}\r\n"]}
1
+ {"version":3,"file":"NamingModel.js","sourceRoot":"","sources":["../src/NamingModel.ts"],"names":[],"mappings":"AAKA,MAAM,CAAN,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,6BAAS,CAAA;IACT,8CAA0B,CAAA;IAC1B,4CAAwB,CAAA;IACxB,kDAA8B,CAAA;IAC9B,4CAAwB,CAAA;AAC1B,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B","sourcesContent":["/**\r\n * The available naming strategies.\r\n */\r\nimport { PartialDeep } from \"type-fest\";\r\n\r\nexport enum NamingStrategies {\r\n NONE = \"\",\r\n PASCAL_CASE = \"pascalCase\",\r\n CAMEL_CASE = \"camelCase\",\r\n CONSTANT_CASE = \"constantCase\",\r\n SNAKE_CASE = \"snakeCase\",\r\n}\r\n\r\n/**\r\n * Based on an existing configuration (for example default settings) the user only specifies what needs\r\n * to be changed. Hence, all options are completely optional.\r\n */\r\nexport interface OverridableNamingOptions extends PartialDeep<NameSettings> {}\r\n\r\n/**\r\n * The required and optional name settings for the generator.\r\n */\r\nexport interface NameSettings {\r\n /**\r\n * Because multiple artefacts are generated out of the same entity, some name settings are required in order\r\n * to differentiate those artefacts. Out-of-the-box odata2ts provides you with sensible default settings,\r\n * so that you only need to override those settings you want to change.\r\n *\r\n * However, sometimes it makes more sense to start from scratch, so that the defaults don't interfere with\r\n * your own configuration. In this scenario this switch should be enabled to only have default values for\r\n * the required name settings.\r\n */\r\n minimalDefaults?: boolean;\r\n\r\n /**\r\n * Generation options for models, i.e. interfaces representing entity or complex types.\r\n */\r\n models: ModelNamingOptions;\r\n\r\n /**\r\n * Generation options for Query Objects.\r\n *\r\n * By default, prefix = \"Q\"\r\n */\r\n queryObjects: QueryObjectNamingOptions;\r\n\r\n services: ServiceNamingOptions;\r\n}\r\n\r\nexport interface ModelNamingOptions extends NamingStrategyOption, StandardNamingOptions {\r\n /**\r\n * All generated models are bundled into one file.\r\n * This option specifies the formatting of the file name.\r\n */\r\n fileName: FileNamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Choose a specific strategy to format property names of models: pascal-case, camel-case, etc.\r\n * By default, camel-case.\r\n */\r\n propNamingStrategy?: NamingStrategies;\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 override the naming options here.\r\n * By default, prefix = \"Editable\"\r\n */\r\n editableModels: EntityDerivedNamingOptions;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n *\r\n * You can configure the naming options here.\r\n * By default, suffix = \"Id\"\r\n */\r\n idModels: EntityDerivedNamingOptions;\r\n\r\n /**\r\n * Operation parameter models are generated from function or action signatures.\r\n *\r\n * You can configure the naming options here.\r\n * By default, suffix = \"Params\"\r\n */\r\n operationParamModels: EntityDerivedNamingOptions;\r\n}\r\n\r\nexport interface EntityDerivedNamingOptions extends RequiredNamingOptions {\r\n applyModelNaming?: boolean;\r\n}\r\n\r\nexport interface QueryObjectNamingOptions extends NamingStrategyOption, RequiredNamingOptions {\r\n /**\r\n * All generated models are bundled into one file.\r\n * This option specifies the formatting of the file name.\r\n */\r\n fileName: FileNamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Choose a specific strategy to format property names of query objects: pascal-case, camel-case, etc.\r\n * By default, camel-case.\r\n */\r\n propNamingStrategy?: NamingStrategies;\r\n\r\n idFunctions: RequiredNamingOptions;\r\n\r\n operations?: OperationNamingOptions;\r\n\r\n baseType: RequiredNamingOptions & { applyQNaming?: boolean };\r\n}\r\n\r\nexport interface OperationNamingOptions extends StandardNamingOptions {\r\n /**\r\n * Naming options for actions only.\r\n * When this configuration is provided, the parent configuration regarding suffix and prefix is ignored.\r\n */\r\n action?: StandardNamingOptions;\r\n /**\r\n * Naming options for functions only.\r\n * When this configuration is provided, the parent configuration regarding suffix and prefix is ignored.\r\n */\r\n function?: StandardNamingOptions;\r\n}\r\n\r\nexport interface NamingStrategyOption {\r\n /**\r\n * Choose a specific strategy to format names: pascal-case, camel-case, etc.\r\n * Defaults to pascal-case.\r\n */\r\n namingStrategy?: NamingStrategies;\r\n}\r\n\r\nexport interface FileNamingStrategyOption {\r\n /**\r\n * Choose a specific strategy to format names: pascal-case, camel-case, etc.\r\n * Defaults to pascal-case.\r\n */\r\n namingStrategy?: NamingStrategies;\r\n}\r\n\r\nexport interface StandardNamingOptions {\r\n /**\r\n * Prefix all names, e.g. \"I\" => \"ITest\"\r\n */\r\n prefix?: string;\r\n /**\r\n * Suffix all names, e.g. \"model\" => \"TestModel\"\r\n */\r\n suffix?: string;\r\n}\r\n\r\nexport interface RequiredNamingOptions extends Required<StandardNamingOptions> {}\r\n\r\n/**\r\n * Naming options for generated service classes.\r\n * These options affect the main service as well as all services generated for each entity, complex and collection type.\r\n *\r\n * There exists one specialty about services: The file names are not configurable.\r\n * File names are determined by the name of their corresponding classes, so that service file name\r\n * and service class name always correspond.\r\n *\r\n * By default, suffix = Service and namingStrategy = PascalCase\r\n */\r\nexport interface ServiceNamingOptions extends NamingStrategyOption, RequiredNamingOptions {\r\n /**\r\n * Controls the naming options for the main odata service.\r\n * By default, the base service naming options are applied.\r\n * But since this is the main entry point for users, it can be configured individually here.\r\n *\r\n * By default, applyServiceNaming = true\r\n */\r\n main?: NamingStrategyOption & StandardNamingOptions & { applyServiceNaming?: boolean };\r\n\r\n /**\r\n * Name of the service responsible for entity collections.\r\n *\r\n * By default, suffix = Collection and applyServiceNaming = true\r\n */\r\n collection: RequiredNamingOptions & { applyServiceNaming?: boolean };\r\n\r\n /**\r\n * Naming for getter method of another service.\r\n *\r\n * By default, namingStrategy = camelCase\r\n */\r\n relatedServiceGetter: NamingStrategyOption & RequiredNamingOptions;\r\n\r\n /**\r\n * Operations are functions and actions of the OData service and are represented as methods\r\n * of the generated service class. This setting controls the naming of the corresponding\r\n * function.\r\n *\r\n * By default, namingStrategy = camelCase\r\n */\r\n operations?: NamingStrategyOption & OperationNamingOptions;\r\n\r\n /**\r\n * Naming options for private properties of service classes.\r\n *\r\n * By default, prefix = _\r\n */\r\n privateProps: NamingStrategyOption & RequiredNamingOptions;\r\n}\r\n"]}
@@ -28,16 +28,6 @@ export declare abstract class Digester<S extends Schema<ET, CT>, ET extends Enti
28
28
  * Reverse mapping from fqName to data type: EntityType, ComplexType, EnumType, or Primitive Type.
29
29
  */
30
30
  private model2Type;
31
- /**
32
- * Stores models (ComplexType or EntityType) by fqName that have been referenced in the API
33
- * as entry point or via navProp.
34
- * For these models one or two services are generated.
35
- *
36
- * In this way unnecessary service generation is prevented. For example, complex types that
37
- * are only referenced as response of an operation do not need a generated service.
38
- * @private
39
- */
40
- private serviceModels;
41
31
  protected constructor(version: ODataVersion, schemas: Array<S>, options: DigestionOptions, namingHelper: NamingHelper, converters?: MappedConverterChains);
42
32
  private collectModelTypes;
43
33
  private addModel2Type;
@@ -58,10 +48,28 @@ export declare abstract class Digester<S extends Schema<ET, CT>, ET extends Enti
58
48
  private addEnum;
59
49
  private addComplexType;
60
50
  private addEntityType;
51
+ /**
52
+ * Check that models (ComplexType or EntityType) have been referenced in the API
53
+ * as entry point or via navProp or by virtue of being a base type or subtype of those.
54
+ * For these models one or two services are generated.
55
+ *
56
+ * In this way unnecessary service generation is prevented. For example, complex types that
57
+ * are only referenced as response of an operation do not need a generated service.
58
+ *
59
+ * @param ec
60
+ * @private
61
+ */
61
62
  private analyzeModelUsage;
63
+ /**
64
+ * Check usage of model types within API.
65
+ *
66
+ * @param fqModelName
67
+ * @private
68
+ */
62
69
  private analyze;
63
70
  private postProcessModel;
64
71
  private postProcessKeys;
65
72
  private collectBaseClassPropsAndKeys;
66
73
  protected mapProp: (p: Property, entityPropConfig?: PropertyGenerationOptions | undefined) => PropertyModel;
74
+ private addSubtypes;
67
75
  }
@@ -20,16 +20,6 @@ export class Digester {
20
20
  * Reverse mapping from fqName to data type: EntityType, ComplexType, EnumType, or Primitive Type.
21
21
  */
22
22
  this.model2Type = new Map();
23
- /**
24
- * Stores models (ComplexType or EntityType) by fqName that have been referenced in the API
25
- * as entry point or via navProp.
26
- * For these models one or two services are generated.
27
- *
28
- * In this way unnecessary service generation is prevented. For example, complex types that
29
- * are only referenced as response of an operation do not need a generated service.
30
- * @private
31
- */
32
- this.serviceModels = new Set();
33
23
  this.mapProp = (p, entityPropConfig) => {
34
24
  var _a, _b;
35
25
  if (!p.$.Type) {
@@ -144,7 +134,6 @@ export class Digester {
144
134
  }
145
135
  digestEntityTypesAndOperations() {
146
136
  this.schemas.forEach((schema) => {
147
- var _a;
148
137
  const ns = [schema.$.Namespace, schema.$.Alias];
149
138
  // type definitions: alias for primitive types
150
139
  this.addTypeDefinition(schema.$.Namespace, schema.TypeDefinition);
@@ -156,10 +145,13 @@ export class Digester {
156
145
  this.addEntityType(ns, schema.EntityType);
157
146
  // V4 only: function & action types
158
147
  this.digestOperations(schema);
159
- this.analyzeModelUsage(((_a = schema.EntityContainer) === null || _a === void 0 ? void 0 : _a.length) ? schema.EntityContainer[0] : undefined);
160
148
  });
161
149
  this.postProcessModel();
162
150
  this.postProcessKeys();
151
+ this.schemas.forEach((schema) => {
152
+ var _a;
153
+ this.analyzeModelUsage(((_a = schema.EntityContainer) === null || _a === void 0 ? void 0 : _a.length) ? schema.EntityContainer[0] : undefined);
154
+ });
163
155
  }
164
156
  getBaseModel(entityConfig, model, namespace, name, fqName) {
165
157
  var _a, _b;
@@ -196,7 +188,8 @@ export class Digester {
196
188
  baseProps: [],
197
189
  abstract: ifTrue(model.$.Abstract),
198
190
  open: ifTrue(model.$.OpenType),
199
- genMode: Modes.service,
191
+ genMode: Modes.qobjects,
192
+ subtypes: new Set(),
200
193
  };
201
194
  }
202
195
  addTypeDefinition(ns, types) {
@@ -267,9 +260,20 @@ export class Digester {
267
260
  fqName: baseModel.fqName,
268
261
  modelName: this.namingHelper.getIdModelName(name),
269
262
  qName: this.namingHelper.getQIdFunctionName(name),
270
- }, generateId: !!keyNames.length, keyNames: keyNames, keys: [], getKeyUnion: () => keyNames.join(" | ") }));
263
+ }, generateId: !!keyNames.length, keyNames: keyNames, keys: [], getKeyUnion: () => keyNames.join(" | "), subtypes: new Set() }));
271
264
  }
272
265
  }
266
+ /**
267
+ * Check that models (ComplexType or EntityType) have been referenced in the API
268
+ * as entry point or via navProp or by virtue of being a base type or subtype of those.
269
+ * For these models one or two services are generated.
270
+ *
271
+ * In this way unnecessary service generation is prevented. For example, complex types that
272
+ * are only referenced as response of an operation do not need a generated service.
273
+ *
274
+ * @param ec
275
+ * @private
276
+ */
273
277
  analyzeModelUsage(ec) {
274
278
  var _a, _b;
275
279
  if ((_a = ec === null || ec === void 0 ? void 0 : ec.EntitySet) === null || _a === void 0 ? void 0 : _a.length) {
@@ -280,17 +284,29 @@ export class Digester {
280
284
  ec4.Singleton.forEach((singleton) => this.analyze(singleton.$.Type));
281
285
  }
282
286
  }
287
+ /**
288
+ * Check usage of model types within API.
289
+ *
290
+ * @param fqModelName
291
+ * @private
292
+ */
283
293
  analyze(fqModelName) {
284
294
  var _a;
285
- if (this.serviceModels.has(fqModelName)) {
295
+ // to also resolve aliases the data model needs to be used
296
+ const model = (_a = this.dataModel.getEntityType(fqModelName)) !== null && _a !== void 0 ? _a : this.dataModel.getComplexType(fqModelName);
297
+ if (!(model === null || model === void 0 ? void 0 : model.fqName) || model.genMode === Modes.service) {
286
298
  return;
287
299
  }
288
- this.serviceModels.add(fqModelName);
289
- const model = (_a = this.dataModel.getEntityType(fqModelName)) !== null && _a !== void 0 ? _a : this.dataModel.getComplexType(fqModelName);
300
+ model.genMode = Modes.service;
290
301
  if (model) {
302
+ // respect base classes
291
303
  if (model.baseClasses.length) {
292
304
  this.analyze(model.baseClasses[0]);
293
305
  }
306
+ // include subtypes since each base class can be cast to its subtypes
307
+ model.subtypes.forEach((subtype) => {
308
+ this.analyze(subtype);
309
+ });
294
310
  model === null || model === void 0 ? void 0 : model.props.forEach((p) => {
295
311
  if (p.dataType === "ComplexType" /* DataTypes.ComplexType */ || p.dataType === "ModelType" /* DataTypes.ModelType */) {
296
312
  this.analyze(p.fqType);
@@ -302,19 +318,22 @@ export class Digester {
302
318
  // complex types
303
319
  const complexTypes = this.dataModel.getComplexTypes();
304
320
  complexTypes.forEach((ct) => {
321
+ // build up set of subtypes for each complex type
322
+ this.addSubtypes(ct);
323
+ // get props & keys from base types
305
324
  const [baseProps, _, baseAttributes] = this.collectBaseClassPropsAndKeys(ct, []);
306
325
  const { open } = baseAttributes;
307
326
  ct.baseProps = baseProps.map((bp) => (Object.assign({}, bp)));
308
327
  if (open) {
309
328
  ct.open = true;
310
329
  }
311
- if (!this.serviceModels.has(ct.fqName)) {
312
- ct.genMode = Modes.qobjects;
313
- }
314
330
  });
315
331
  // entity types
316
332
  const entityTypes = this.dataModel.getEntityTypes();
317
333
  entityTypes.forEach((et) => {
334
+ // build up set of subtypes for each entity type
335
+ this.addSubtypes(et);
336
+ // get props & keys from base types
318
337
  const [baseProps, baseKeys, baseAttributes] = this.collectBaseClassPropsAndKeys(et, []);
319
338
  const { fqIdName, idName, qIdName, open } = baseAttributes;
320
339
  et.baseProps = baseProps.map((bp) => (Object.assign({}, bp)));
@@ -329,9 +348,6 @@ export class Digester {
329
348
  if (open) {
330
349
  et.open = open;
331
350
  }
332
- if (!this.serviceModels.has(et.fqName)) {
333
- et.genMode = Modes.qobjects;
334
- }
335
351
  et.keyNames.unshift(...baseKeys.filter((bk) => !et.keyNames.includes(bk)));
336
352
  });
337
353
  }
@@ -393,6 +409,23 @@ export class Digester {
393
409
  return [props, keys, { fqIdName, idName, qIdName, open }];
394
410
  }, [[], [], { fqIdName: "", idName: "", qIdName: "", open: false }]);
395
411
  }
412
+ addSubtypes(model, grandChildren = new Set()) {
413
+ if (!model.baseClasses.length) {
414
+ return;
415
+ }
416
+ model.baseClasses.forEach((baseClass) => {
417
+ const baseType = this.dataModel.getModel(baseClass);
418
+ // add subtypes & base name for q-objects
419
+ baseType.subtypes.add(model.fqName);
420
+ if (!baseType.qBaseName) {
421
+ baseType.qBaseName = this.namingHelper.getQBaseName(baseType.name);
422
+ }
423
+ grandChildren.forEach((gc) => baseType.subtypes.add(gc));
424
+ // recursive
425
+ grandChildren.add(model.fqName);
426
+ this.addSubtypes(baseType, grandChildren);
427
+ });
428
+ }
396
429
  }
397
430
  Digester.EDM_PREFIX = "Edm.";
398
431
  //# sourceMappingURL=DataModelDigestion.js.map
@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CAAC,SAAS,CAAC;gBAClC,OAAO,GAAG,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC;aAChC;YACD,IAAI,SAAS,CAAC,IAAI,EAAE;gBAClB,IAAI,GAAG,IAAI,CAAC;aACb;YACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC,EACD,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAmB,CACnF,CAAC;IACJ,CAAC;;AA1XgB,mBAAU,GAAG,MAAM,AAAT,CAAU","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\nimport type { DigestionOptions } from \"../FactoryFunctionModel.js\";\r\nimport {\r\n ComplexTypeGenerationOptions,\r\n EntityTypeGenerationOptions,\r\n Modes,\r\n PropertyGenerationOptions,\r\n} from \"../OptionModel.js\";\r\nimport { DataModel, NamespaceWithAlias, withNamespace } from \"./DataModel.js\";\r\nimport {\r\n ComplexType as ComplexModelType,\r\n DataTypes,\r\n EntityType as EntityModelType,\r\n ODataVersion,\r\n PropertyModel,\r\n} from \"./DataTypeModel.js\";\r\nimport { ComplexType, EntityType, EnumType, Property, Schema, TypeDefinition } from \"./edmx/ODataEdmxModelBase.js\";\r\nimport { EntityContainerV3, SchemaV3 } from \"./edmx/ODataEdmxModelV3.js\";\r\nimport { EntityContainerV4, SchemaV4 } from \"./edmx/ODataEdmxModelV4.js\";\r\nimport { NamingHelper } from \"./NamingHelper.js\";\r\nimport { ServiceConfigHelper, WithoutName } from \"./ServiceConfigHelper.js\";\r\nimport { NameClashValidator } from \"./validation/NameClashValidator.js\";\r\nimport { NameValidator } from \"./validation/NameValidator.js\";\r\nimport { NoopValidator } from \"./validation/NoopValidator.js\";\r\n\r\ntype CollectorTuple = [\r\n Array<PropertyModel>,\r\n Array<string>,\r\n { fqIdName: string; idName: string; qIdName: string; open: boolean },\r\n];\r\n\r\nfunction ifTrue(value: string | undefined): boolean {\r\n return value === \"true\";\r\n}\r\n\r\nfunction ifFalse(value: string | undefined): boolean {\r\n return value === \"false\";\r\n}\r\n\r\nexport interface TypeModel {\r\n outputType: string;\r\n qPath: string;\r\n qCollection: string;\r\n qParam: string | undefined;\r\n}\r\n\r\nexport abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {\r\n protected static EDM_PREFIX = \"Edm.\";\r\n\r\n protected readonly dataModel: DataModel;\r\n protected readonly serviceConfigHelper: ServiceConfigHelper;\r\n protected readonly nameValidator: NameValidator;\r\n\r\n /**\r\n * Reverse mapping from fqName to data type: EntityType, ComplexType, EnumType, or Primitive Type.\r\n */\r\n private model2Type = new Map<string, DataTypes>();\r\n /**\r\n * Stores models (ComplexType or EntityType) by fqName that have been referenced in the API\r\n * as entry point or via navProp.\r\n * For these models one or two services are generated.\r\n *\r\n * In this way unnecessary service generation is prevented. For example, complex types that\r\n * are only referenced as response of an operation do not need a generated service.\r\n * @private\r\n */\r\n private serviceModels = new Set<string>();\r\n\r\n protected constructor(\r\n protected version: ODataVersion,\r\n protected schemas: Array<S>,\r\n protected options: DigestionOptions,\r\n protected namingHelper: NamingHelper,\r\n converters?: MappedConverterChains,\r\n ) {\r\n const namespaces = schemas.map<NamespaceWithAlias>((s) => [s.$.Namespace, s.$.Alias]);\r\n this.dataModel = new DataModel(namespaces, version, converters);\r\n this.serviceConfigHelper = new ServiceConfigHelper(options);\r\n this.nameValidator = options.bundledFileGeneration ? new NameClashValidator(options) : new NoopValidator();\r\n\r\n this.collectModelTypes(schemas);\r\n }\r\n\r\n private collectModelTypes(schemas: Array<S>) {\r\n schemas.forEach((schema) => {\r\n const { Namespace: ns, Alias: alias } = schema.$;\r\n\r\n schema.EnumType?.forEach((et) => {\r\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.EnumType);\r\n });\r\n schema.ComplexType?.forEach((ct) => {\r\n this.addModel2Type(ns, alias, ct.$.Name, DataTypes.ComplexType);\r\n });\r\n schema.EntityType?.forEach((et) => {\r\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.ModelType);\r\n });\r\n });\r\n }\r\n\r\n private addModel2Type(ns: string, alias: string | undefined, name: string, dt: DataTypes) {\r\n this.model2Type.set(withNamespace(ns, name), dt);\r\n if (alias) {\r\n this.model2Type.set(withNamespace(alias, name), dt);\r\n }\r\n }\r\n\r\n protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;\r\n\r\n protected abstract digestOperations(schema: SchemaV3 | SchemaV4): void;\r\n\r\n protected abstract digestEntityContainer(schema: SchemaV3 | SchemaV4): void;\r\n\r\n /**\r\n * Get essential infos about a given odata type from the version specific service variants.\r\n *\r\n * @param type\r\n * @return tuple of return type, query object, query collection object\r\n */\r\n protected abstract mapODataType(type: string): TypeModel;\r\n\r\n public async digest(): Promise<DataModel> {\r\n this.digestEntityTypesAndOperations();\r\n\r\n // delegate to version specific entity container digestion\r\n this.schemas.forEach((schema) => this.digestEntityContainer(schema));\r\n\r\n this.dataModel.setNameValidation(this.nameValidator.validate());\r\n return this.dataModel;\r\n }\r\n\r\n private digestEntityTypesAndOperations() {\r\n this.schemas.forEach((schema) => {\r\n const ns: NamespaceWithAlias = [schema.$.Namespace, schema.$.Alias];\r\n\r\n // type definitions: alias for primitive types\r\n this.addTypeDefinition(schema.$.Namespace, schema.TypeDefinition);\r\n\r\n // enums\r\n this.addEnum(ns, schema.EnumType);\r\n\r\n // complex types\r\n this.addComplexType(ns, schema.ComplexType);\r\n\r\n // entity types\r\n this.addEntityType(ns, schema.EntityType);\r\n\r\n // V4 only: function & action types\r\n this.digestOperations(schema);\r\n\r\n this.analyzeModelUsage(schema.EntityContainer?.length ? schema.EntityContainer[0] : undefined);\r\n });\r\n\r\n this.postProcessModel();\r\n this.postProcessKeys();\r\n }\r\n\r\n private getBaseModel(\r\n entityConfig: WithoutName<EntityTypeGenerationOptions | ComplexTypeGenerationOptions> | undefined,\r\n model: ComplexType,\r\n namespace: string,\r\n name: string,\r\n fqName: string,\r\n ) {\r\n const odataName = model.$.Name;\r\n\r\n // map properties respecting the config\r\n const props = [...(model.Property ?? []), ...this.getNavigationProps(model)].map((p) => {\r\n const epConfig = entityConfig?.properties?.find((ep) => ep.name === p.$.Name);\r\n return this.mapProp(p, epConfig);\r\n });\r\n\r\n // support for base types, i.e. extends clause of interfaces\r\n const baseClasses = [];\r\n let finalBaseClass: string | undefined = undefined;\r\n if (model.$.BaseType) {\r\n baseClasses.push(model.$.BaseType);\r\n const [baseName, basePrefix] = this.namingHelper.getNameAndServicePrefix(model.$.BaseType);\r\n const baseConfig =\r\n this.serviceConfigHelper.findEntityTypeConfig([basePrefix!], baseName) ||\r\n this.serviceConfigHelper.findComplexTypeConfig([basePrefix!], baseName);\r\n finalBaseClass = baseConfig?.mappedName ?? baseName;\r\n }\r\n\r\n return {\r\n fqName,\r\n odataName,\r\n name,\r\n modelName: this.namingHelper.getModelName(name),\r\n qName: this.namingHelper.getQName(name),\r\n editableName: this.namingHelper.getEditableModelName(name),\r\n serviceName: this.namingHelper.getServiceName(name),\r\n serviceCollectionName: this.namingHelper.getCollectionServiceName(name),\r\n folderPath: this.namingHelper.getFolderPath(namespace, name),\r\n baseClasses,\r\n finalBaseClass,\r\n props,\r\n baseProps: [], // postprocess required\r\n abstract: ifTrue(model.$.Abstract),\r\n open: ifTrue(model.$.OpenType),\r\n genMode: Modes.service,\r\n } satisfies Partial<ComplexModelType>;\r\n }\r\n\r\n private addTypeDefinition(ns: string, types: Array<TypeDefinition> | undefined) {\r\n if (!types || !types.length) {\r\n return;\r\n }\r\n\r\n for (const t of types) {\r\n this.dataModel.addTypeDefinition(ns, t.$.Name, t.$.UnderlyingType);\r\n }\r\n }\r\n\r\n private addEnum(namespace: NamespaceWithAlias, models: Array<EnumType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const et of models) {\r\n const odataName = et.$.Name;\r\n const fqName = withNamespace(namespace[0], odataName);\r\n const config = this.serviceConfigHelper.findEnumTypeConfig(namespace, odataName);\r\n const enumName = this.nameValidator.addEnumType(fqName, config?.mappedName || odataName);\r\n const filePath = this.namingHelper.getFolderPath(namespace[0], enumName);\r\n this.dataModel.addEnum(namespace[0], odataName, {\r\n fqName,\r\n odataName,\r\n name: enumName,\r\n modelName: this.namingHelper.getEnumName(enumName),\r\n folderPath: filePath,\r\n members: et.Member?.length ? et.Member.map((m) => ({ name: m.$.Name, value: m.$.Value })) : [],\r\n });\r\n }\r\n }\r\n\r\n private addComplexType(namespace: NamespaceWithAlias, models: Array<ComplexType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const config = this.serviceConfigHelper.findComplexTypeConfig(namespace, model.$.Name);\r\n const fqName = withNamespace(namespace[0], model.$.Name);\r\n const name = this.nameValidator.addComplexType(fqName, config?.mappedName || model.$.Name);\r\n const baseModel = this.getBaseModel(config, model, namespace[0], name, fqName);\r\n this.dataModel.addComplexType(namespace[0], baseModel.odataName, baseModel);\r\n }\r\n }\r\n\r\n private addEntityType(namespace: NamespaceWithAlias, models: Array<ET> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const entityConfig = this.serviceConfigHelper.findEntityTypeConfig(namespace, model.$.Name);\r\n const fqName = withNamespace(namespace[0], model.$.Name);\r\n const name = this.nameValidator.addEntityType(fqName, entityConfig?.mappedName || model.$.Name);\r\n const baseModel = this.getBaseModel(entityConfig, model, namespace[0], name, fqName);\r\n\r\n // key support: we add keys from this entity,\r\n // but not keys stemming from base classes (postprocess required)\r\n const keyNames: Array<string> = [];\r\n if (entityConfig?.keys?.length) {\r\n keyNames.push(...entityConfig.keys);\r\n } else {\r\n const entity = model as EntityType;\r\n if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {\r\n const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);\r\n keyNames.push(...propNames);\r\n }\r\n }\r\n\r\n this.dataModel.addEntityType(namespace[0], baseModel.odataName, {\r\n ...baseModel,\r\n id: {\r\n fqName: baseModel.fqName,\r\n modelName: this.namingHelper.getIdModelName(name),\r\n qName: this.namingHelper.getQIdFunctionName(name),\r\n },\r\n generateId: !!keyNames.length,\r\n keyNames: keyNames, // postprocess required to include key specs from base classes\r\n keys: [], // postprocess required to include props from base classes\r\n getKeyUnion: () => keyNames.join(\" | \"),\r\n });\r\n }\r\n }\r\n\r\n private analyzeModelUsage(ec: EntityContainerV3 | EntityContainerV4 | undefined) {\r\n if (ec?.EntitySet?.length) {\r\n ec.EntitySet.forEach((et) => this.analyze(et.$.EntityType));\r\n }\r\n const ec4 = ec as EntityContainerV4;\r\n if (ec4?.Singleton?.length) {\r\n ec4.Singleton.forEach((singleton) => this.analyze(singleton.$.Type));\r\n }\r\n }\r\n\r\n private analyze(fqModelName: string) {\r\n if (this.serviceModels.has(fqModelName)) {\r\n return;\r\n }\r\n\r\n this.serviceModels.add(fqModelName);\r\n const model = this.dataModel.getEntityType(fqModelName) ?? this.dataModel.getComplexType(fqModelName);\r\n\r\n if (model) {\r\n if (model.baseClasses.length) {\r\n this.analyze(model.baseClasses[0]);\r\n }\r\n model?.props.forEach((p) => {\r\n if (p.dataType === DataTypes.ComplexType || p.dataType === DataTypes.ModelType) {\r\n this.analyze(p.fqType);\r\n }\r\n });\r\n }\r\n }\r\n\r\n private postProcessModel() {\r\n // complex types\r\n const complexTypes = this.dataModel.getComplexTypes();\r\n complexTypes.forEach((ct) => {\r\n const [baseProps, _, baseAttributes] = this.collectBaseClassPropsAndKeys(ct, []);\r\n const { open } = baseAttributes;\r\n ct.baseProps = baseProps.map((bp) => ({ ...bp }));\r\n if (open) {\r\n ct.open = true;\r\n }\r\n if (!this.serviceModels.has(ct.fqName)) {\r\n ct.genMode = Modes.qobjects;\r\n }\r\n });\r\n // entity types\r\n const entityTypes = this.dataModel.getEntityTypes();\r\n entityTypes.forEach((et) => {\r\n const [baseProps, baseKeys, baseAttributes] = this.collectBaseClassPropsAndKeys(et, []);\r\n const { fqIdName, idName, qIdName, open } = baseAttributes;\r\n et.baseProps = baseProps.map((bp) => ({ ...bp }));\r\n\r\n if (!et.keyNames.length && idName) {\r\n et.id = {\r\n fqName: fqIdName,\r\n modelName: idName,\r\n qName: qIdName,\r\n };\r\n et.generateId = false;\r\n }\r\n if (open) {\r\n et.open = open;\r\n }\r\n if (!this.serviceModels.has(et.fqName)) {\r\n et.genMode = Modes.qobjects;\r\n }\r\n et.keyNames.unshift(...baseKeys.filter((bk) => !et.keyNames.includes(bk)));\r\n });\r\n }\r\n\r\n private postProcessKeys() {\r\n const entityTypes = this.dataModel.getEntityTypes();\r\n entityTypes.forEach((et) => {\r\n const isSingleKey = et.keyNames.length === 1;\r\n const props = [...et.baseProps, ...et.props];\r\n et.keys = et.keyNames.map((keyName) => {\r\n const prop = props.find((p) => p.odataName === keyName);\r\n if (!prop) {\r\n throw new Error(`Key with name [${keyName}] not found in props!`);\r\n }\r\n\r\n // automatically set key prop to managed, if this is the only key of the given entity\r\n if (prop.managed === undefined) {\r\n prop.managed = !this.options.disableAutoManagedKey && isSingleKey;\r\n }\r\n\r\n return prop;\r\n });\r\n });\r\n }\r\n\r\n private collectBaseClassPropsAndKeys(model: ComplexModelType, visitedModels: string[]): CollectorTuple {\r\n if (visitedModels.includes(model.fqName)) {\r\n throw new Error(`Cyclic inheritance detected for model ${model.fqName}!`);\r\n }\r\n visitedModels.push(model.fqName);\r\n return model.baseClasses.reduce(\r\n ([props, keys, attributes], bc) => {\r\n const baseModel = this.dataModel.getEntityType(bc) || this.dataModel.getComplexType(bc);\r\n if (!baseModel) {\r\n throw new Error(`BaseModel \"${bc}\" doesn't exist!`);\r\n }\r\n\r\n let { fqIdName, idName, qIdName, open } = attributes;\r\n\r\n // recursive\r\n if (baseModel.baseClasses.length) {\r\n const [parentProps, parentKeys, parentAttributes] = this.collectBaseClassPropsAndKeys(\r\n baseModel,\r\n visitedModels,\r\n );\r\n props.unshift(...parentProps);\r\n keys.unshift(...parentKeys);\r\n if (parentAttributes?.idName) {\r\n fqIdName = parentAttributes.fqIdName;\r\n idName = parentAttributes.idName;\r\n qIdName = parentAttributes.qIdName;\r\n }\r\n if (parentAttributes?.open) {\r\n open = true;\r\n }\r\n }\r\n\r\n props.push(...baseModel.props);\r\n const entityModel = baseModel as EntityModelType;\r\n if (entityModel.keyNames?.length) {\r\n keys.push(...entityModel.keyNames.filter((kn) => !keys.includes(kn)));\r\n fqIdName = entityModel.id.fqName;\r\n idName = entityModel.id.modelName;\r\n qIdName = entityModel.id.qName;\r\n }\r\n if (baseModel.open) {\r\n open = true;\r\n }\r\n return [props, keys, { fqIdName, idName, qIdName, open }];\r\n },\r\n [[], [], { fqIdName: \"\", idName: \"\", qIdName: \"\", open: false }] as CollectorTuple,\r\n );\r\n }\r\n\r\n protected mapProp = (p: Property, entityPropConfig?: PropertyGenerationOptions | undefined): PropertyModel => {\r\n if (!p.$.Type) {\r\n throw new Error(`No type information given for property [${p.$.Name}]!`);\r\n }\r\n\r\n const configProp = this.serviceConfigHelper.findPropConfigByName(p.$.Name);\r\n const modelName = this.namingHelper.getModelPropName(\r\n entityPropConfig?.mappedName || configProp?.mappedName || p.$.Name,\r\n );\r\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\r\n let odataDataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\r\n\r\n // support for primitive type mapping\r\n if (this.namingHelper.includesServicePrefix(odataDataType)) {\r\n const dt = this.dataModel.getPrimitiveType(odataDataType);\r\n if (dt !== undefined) {\r\n odataDataType = dt;\r\n }\r\n }\r\n\r\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\r\n\r\n // domain object known from service:\r\n // EntityType, ComplexType, EnumType\r\n if (this.namingHelper.includesServicePrefix(odataDataType)) {\r\n const modelType = this.model2Type.get(odataDataType)!;\r\n const [dataTypeName, dataTypePrefix] = this.namingHelper.getNameAndServicePrefix(odataDataType);\r\n const dataTypeNamespace: NamespaceWithAlias = [dataTypePrefix!];\r\n if (!modelType) {\r\n throw new Error(\r\n `Couldn't determine model type (EntityType, ComplexType, etc) for property \"${p.$.Name}\"! Given data type: \"${odataDataType}\".`,\r\n );\r\n }\r\n\r\n // special handling for enums\r\n if (modelType === DataTypes.EnumType) {\r\n const enumConfig = this.serviceConfigHelper.findEnumTypeConfig(dataTypeNamespace, dataTypeName);\r\n result = {\r\n dataType: modelType,\r\n type: this.namingHelper.getEnumName(enumConfig?.mappedName ?? odataDataType),\r\n qPath: this.options.numericEnums ? \"QNumericEnumPath\" : \"QEnumPath\",\r\n qObject: isCollection\r\n ? this.options.numericEnums\r\n ? \"QNumericEnumCollection\"\r\n : \"QEnumCollection\"\r\n : undefined,\r\n qParam: this.options.numericEnums ? \"QNumericEnumParam\" : \"QEnumParam\",\r\n };\r\n }\r\n // handling of complex & entity types\r\n else {\r\n const entityConfig =\r\n modelType === DataTypes.ComplexType\r\n ? this.serviceConfigHelper.findComplexTypeConfig(dataTypeNamespace, dataTypeName)\r\n : this.serviceConfigHelper.findEntityTypeConfig(dataTypeNamespace, dataTypeName);\r\n const typeName = entityConfig?.mappedName ?? odataDataType;\r\n\r\n result = {\r\n dataType: modelType,\r\n type: this.namingHelper.getModelName(typeName),\r\n qPath: \"QEntityPath\",\r\n qObject: this.namingHelper.getQName(typeName),\r\n qParam: \"QComplexParam\",\r\n };\r\n }\r\n }\r\n // OData built-in data types\r\n else if (odataDataType.startsWith(Digester.EDM_PREFIX)) {\r\n const { outputType, qPath, qParam, qCollection } = this.mapODataType(odataDataType);\r\n const { to, toModule: typeModule, converters } = this.dataModel.getConverter(odataDataType) || {};\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 [${odataDataType}]: Not 'Collection(...)', not OData type 'Edm.*', not starting with one of the namespaces!`,\r\n );\r\n }\r\n\r\n return {\r\n odataName: p.$.Name,\r\n name: modelName,\r\n odataType: p.$.Type,\r\n fqType: odataDataType,\r\n required: ifFalse(p.$.Nullable),\r\n isCollection: isCollection,\r\n managed: typeof entityPropConfig?.managed !== \"undefined\" ? entityPropConfig.managed : configProp?.managed,\r\n ...result,\r\n };\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"DataModelDigestion.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestion.ts"],"names":[],"mappings":";AAEA,OAAO,EAGL,KAAK,GAEN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAsB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAY9E,OAAO,EAAE,mBAAmB,EAAe,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAQ9D,SAAS,MAAM,CAAC,KAAyB;IACvC,OAAO,KAAK,KAAK,MAAM,CAAC;AAC1B,CAAC;AAED,SAAS,OAAO,CAAC,KAAyB;IACxC,OAAO,KAAK,KAAK,OAAO,CAAC;AAC3B,CAAC;AASD,MAAM,OAAgB,QAAQ;IAY5B,YACY,OAAqB,EACrB,OAAiB,EACjB,OAAyB,EACzB,YAA0B,EACpC,UAAkC;QAJxB,YAAO,GAAP,OAAO,CAAc;QACrB,YAAO,GAAP,OAAO,CAAU;QACjB,YAAO,GAAP,OAAO,CAAkB;QACzB,iBAAY,GAAZ,YAAY,CAAc;QATtC;;WAEG;QACK,eAAU,GAAG,IAAI,GAAG,EAAqB,CAAC;QAsYxC,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,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;YACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAqB,CAAC;YAExE,yCAAyC;YACzC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACpC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;gBACvB,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aACpE;YACD,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YAEzD,YAAY;YACZ,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAChC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;;AAtgBgB,mBAAU,GAAG,MAAM,AAAT,CAAU","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\nimport type { DigestionOptions } from \"../FactoryFunctionModel.js\";\r\nimport {\r\n ComplexTypeGenerationOptions,\r\n EntityTypeGenerationOptions,\r\n Modes,\r\n PropertyGenerationOptions,\r\n} from \"../OptionModel.js\";\r\nimport { DataModel, NamespaceWithAlias, withNamespace } from \"./DataModel.js\";\r\nimport {\r\n ComplexType as ComplexModelType,\r\n DataTypes,\r\n EntityType as EntityModelType,\r\n ODataVersion,\r\n PropertyModel,\r\n} from \"./DataTypeModel.js\";\r\nimport { ComplexType, EntityType, EnumType, Property, Schema, TypeDefinition } from \"./edmx/ODataEdmxModelBase.js\";\r\nimport { EntityContainerV3, SchemaV3 } from \"./edmx/ODataEdmxModelV3.js\";\r\nimport { EntityContainerV4, SchemaV4 } from \"./edmx/ODataEdmxModelV4.js\";\r\nimport { NamingHelper } from \"./NamingHelper.js\";\r\nimport { ServiceConfigHelper, WithoutName } from \"./ServiceConfigHelper.js\";\r\nimport { NameClashValidator } from \"./validation/NameClashValidator.js\";\r\nimport { NameValidator } from \"./validation/NameValidator.js\";\r\nimport { NoopValidator } from \"./validation/NoopValidator.js\";\r\n\r\ntype CollectorTuple = [\r\n Array<PropertyModel>,\r\n Array<string>,\r\n { fqIdName: string; idName: string; qIdName: string; open: boolean },\r\n];\r\n\r\nfunction ifTrue(value: string | undefined): boolean {\r\n return value === \"true\";\r\n}\r\n\r\nfunction ifFalse(value: string | undefined): boolean {\r\n return value === \"false\";\r\n}\r\n\r\nexport interface TypeModel {\r\n outputType: string;\r\n qPath: string;\r\n qCollection: string;\r\n qParam: string | undefined;\r\n}\r\n\r\nexport abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {\r\n protected static EDM_PREFIX = \"Edm.\";\r\n\r\n protected readonly dataModel: DataModel;\r\n protected readonly serviceConfigHelper: ServiceConfigHelper;\r\n protected readonly nameValidator: NameValidator;\r\n\r\n /**\r\n * Reverse mapping from fqName to data type: EntityType, ComplexType, EnumType, or Primitive Type.\r\n */\r\n private model2Type = new Map<string, DataTypes>();\r\n\r\n protected constructor(\r\n protected version: ODataVersion,\r\n protected schemas: Array<S>,\r\n protected options: DigestionOptions,\r\n protected namingHelper: NamingHelper,\r\n converters?: MappedConverterChains,\r\n ) {\r\n const namespaces = schemas.map<NamespaceWithAlias>((s) => [s.$.Namespace, s.$.Alias]);\r\n this.dataModel = new DataModel(namespaces, version, converters);\r\n this.serviceConfigHelper = new ServiceConfigHelper(options);\r\n this.nameValidator = options.bundledFileGeneration ? new NameClashValidator(options) : new NoopValidator();\r\n\r\n this.collectModelTypes(schemas);\r\n }\r\n\r\n private collectModelTypes(schemas: Array<S>) {\r\n schemas.forEach((schema) => {\r\n const { Namespace: ns, Alias: alias } = schema.$;\r\n\r\n schema.EnumType?.forEach((et) => {\r\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.EnumType);\r\n });\r\n schema.ComplexType?.forEach((ct) => {\r\n this.addModel2Type(ns, alias, ct.$.Name, DataTypes.ComplexType);\r\n });\r\n schema.EntityType?.forEach((et) => {\r\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.ModelType);\r\n });\r\n });\r\n }\r\n\r\n private addModel2Type(ns: string, alias: string | undefined, name: string, dt: DataTypes) {\r\n this.model2Type.set(withNamespace(ns, name), dt);\r\n if (alias) {\r\n this.model2Type.set(withNamespace(alias, name), dt);\r\n }\r\n }\r\n\r\n protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;\r\n\r\n protected abstract digestOperations(schema: SchemaV3 | SchemaV4): void;\r\n\r\n protected abstract digestEntityContainer(schema: SchemaV3 | SchemaV4): void;\r\n\r\n /**\r\n * Get essential infos about a given odata type from the version specific service variants.\r\n *\r\n * @param type\r\n * @return tuple of return type, query object, query collection object\r\n */\r\n protected abstract mapODataType(type: string): TypeModel;\r\n\r\n public async digest(): Promise<DataModel> {\r\n this.digestEntityTypesAndOperations();\r\n\r\n // delegate to version specific entity container digestion\r\n this.schemas.forEach((schema) => this.digestEntityContainer(schema));\r\n\r\n this.dataModel.setNameValidation(this.nameValidator.validate());\r\n return this.dataModel;\r\n }\r\n\r\n private digestEntityTypesAndOperations() {\r\n this.schemas.forEach((schema) => {\r\n const ns: NamespaceWithAlias = [schema.$.Namespace, schema.$.Alias];\r\n\r\n // type definitions: alias for primitive types\r\n this.addTypeDefinition(schema.$.Namespace, schema.TypeDefinition);\r\n\r\n // enums\r\n this.addEnum(ns, schema.EnumType);\r\n\r\n // complex types\r\n this.addComplexType(ns, schema.ComplexType);\r\n\r\n // entity types\r\n this.addEntityType(ns, schema.EntityType);\r\n\r\n // V4 only: function & action types\r\n this.digestOperations(schema);\r\n });\r\n\r\n this.postProcessModel();\r\n this.postProcessKeys();\r\n\r\n this.schemas.forEach((schema) => {\r\n this.analyzeModelUsage(schema.EntityContainer?.length ? schema.EntityContainer[0] : undefined);\r\n });\r\n }\r\n\r\n private getBaseModel(\r\n entityConfig: WithoutName<EntityTypeGenerationOptions | ComplexTypeGenerationOptions> | undefined,\r\n model: ComplexType,\r\n namespace: string,\r\n name: string,\r\n fqName: string,\r\n ) {\r\n const odataName = model.$.Name;\r\n\r\n // map properties respecting the config\r\n const props = [...(model.Property ?? []), ...this.getNavigationProps(model)].map((p) => {\r\n const epConfig = entityConfig?.properties?.find((ep) => ep.name === p.$.Name);\r\n return this.mapProp(p, epConfig);\r\n });\r\n\r\n // support for base types, i.e. extends clause of interfaces\r\n const baseClasses = [];\r\n let finalBaseClass: string | undefined = undefined;\r\n if (model.$.BaseType) {\r\n baseClasses.push(model.$.BaseType);\r\n const [baseName, basePrefix] = this.namingHelper.getNameAndServicePrefix(model.$.BaseType);\r\n const baseConfig =\r\n this.serviceConfigHelper.findEntityTypeConfig([basePrefix!], baseName) ||\r\n this.serviceConfigHelper.findComplexTypeConfig([basePrefix!], baseName);\r\n finalBaseClass = baseConfig?.mappedName ?? baseName;\r\n }\r\n\r\n return {\r\n fqName,\r\n odataName,\r\n name,\r\n modelName: this.namingHelper.getModelName(name),\r\n qName: this.namingHelper.getQName(name),\r\n editableName: this.namingHelper.getEditableModelName(name),\r\n serviceName: this.namingHelper.getServiceName(name),\r\n serviceCollectionName: this.namingHelper.getCollectionServiceName(name),\r\n folderPath: this.namingHelper.getFolderPath(namespace, name),\r\n baseClasses,\r\n finalBaseClass,\r\n props,\r\n baseProps: [], // postprocess required\r\n abstract: ifTrue(model.$.Abstract),\r\n open: ifTrue(model.$.OpenType),\r\n genMode: Modes.qobjects,\r\n subtypes: new Set(),\r\n } satisfies Partial<ComplexModelType>;\r\n }\r\n\r\n private addTypeDefinition(ns: string, types: Array<TypeDefinition> | undefined) {\r\n if (!types || !types.length) {\r\n return;\r\n }\r\n\r\n for (const t of types) {\r\n this.dataModel.addTypeDefinition(ns, t.$.Name, t.$.UnderlyingType);\r\n }\r\n }\r\n\r\n private addEnum(namespace: NamespaceWithAlias, models: Array<EnumType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const et of models) {\r\n const odataName = et.$.Name;\r\n const fqName = withNamespace(namespace[0], odataName);\r\n const config = this.serviceConfigHelper.findEnumTypeConfig(namespace, odataName);\r\n const enumName = this.nameValidator.addEnumType(fqName, config?.mappedName || odataName);\r\n const filePath = this.namingHelper.getFolderPath(namespace[0], enumName);\r\n this.dataModel.addEnum(namespace[0], odataName, {\r\n fqName,\r\n odataName,\r\n name: enumName,\r\n modelName: this.namingHelper.getEnumName(enumName),\r\n folderPath: filePath,\r\n members: et.Member?.length ? et.Member.map((m) => ({ name: m.$.Name, value: m.$.Value })) : [],\r\n });\r\n }\r\n }\r\n\r\n private addComplexType(namespace: NamespaceWithAlias, models: Array<ComplexType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const config = this.serviceConfigHelper.findComplexTypeConfig(namespace, model.$.Name);\r\n const fqName = withNamespace(namespace[0], model.$.Name);\r\n const name = this.nameValidator.addComplexType(fqName, config?.mappedName || model.$.Name);\r\n const baseModel = this.getBaseModel(config, model, namespace[0], name, fqName);\r\n this.dataModel.addComplexType(namespace[0], baseModel.odataName, baseModel);\r\n }\r\n }\r\n\r\n private addEntityType(namespace: NamespaceWithAlias, models: Array<ET> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const entityConfig = this.serviceConfigHelper.findEntityTypeConfig(namespace, model.$.Name);\r\n const fqName = withNamespace(namespace[0], model.$.Name);\r\n const name = this.nameValidator.addEntityType(fqName, entityConfig?.mappedName || model.$.Name);\r\n const baseModel = this.getBaseModel(entityConfig, model, namespace[0], name, fqName);\r\n\r\n // key support: we add keys from this entity,\r\n // but not keys stemming from base classes (postprocess required)\r\n const keyNames: Array<string> = [];\r\n if (entityConfig?.keys?.length) {\r\n keyNames.push(...entityConfig.keys);\r\n } else {\r\n const entity = model as EntityType;\r\n if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {\r\n const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);\r\n keyNames.push(...propNames);\r\n }\r\n }\r\n\r\n this.dataModel.addEntityType(namespace[0], baseModel.odataName, {\r\n ...baseModel,\r\n id: {\r\n fqName: baseModel.fqName,\r\n modelName: this.namingHelper.getIdModelName(name),\r\n qName: this.namingHelper.getQIdFunctionName(name),\r\n },\r\n generateId: !!keyNames.length,\r\n keyNames: keyNames, // postprocess required to include key specs from base classes\r\n keys: [], // postprocess required to include props from base classes\r\n getKeyUnion: () => keyNames.join(\" | \"),\r\n subtypes: new Set(),\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Check that models (ComplexType or EntityType) have been referenced in the API\r\n * as entry point or via navProp or by virtue of being a base type or subtype of those.\r\n * For these models one or two services are generated.\r\n *\r\n * In this way unnecessary service generation is prevented. For example, complex types that\r\n * are only referenced as response of an operation do not need a generated service.\r\n *\r\n * @param ec\r\n * @private\r\n */\r\n private analyzeModelUsage(ec: EntityContainerV3 | EntityContainerV4 | undefined) {\r\n if (ec?.EntitySet?.length) {\r\n ec.EntitySet.forEach((et) => this.analyze(et.$.EntityType));\r\n }\r\n const ec4 = ec as EntityContainerV4;\r\n if (ec4?.Singleton?.length) {\r\n ec4.Singleton.forEach((singleton) => this.analyze(singleton.$.Type));\r\n }\r\n }\r\n\r\n /**\r\n * Check usage of model types within API.\r\n *\r\n * @param fqModelName\r\n * @private\r\n */\r\n private analyze(fqModelName: string) {\r\n // to also resolve aliases the data model needs to be used\r\n const model = this.dataModel.getEntityType(fqModelName) ?? this.dataModel.getComplexType(fqModelName);\r\n if (!model?.fqName || model.genMode === Modes.service) {\r\n return;\r\n }\r\n\r\n model.genMode = Modes.service;\r\n\r\n if (model) {\r\n // respect base classes\r\n if (model.baseClasses.length) {\r\n this.analyze(model.baseClasses[0]);\r\n }\r\n // include subtypes since each base class can be cast to its subtypes\r\n model.subtypes.forEach((subtype) => {\r\n this.analyze(subtype);\r\n });\r\n model?.props.forEach((p) => {\r\n if (p.dataType === DataTypes.ComplexType || p.dataType === DataTypes.ModelType) {\r\n this.analyze(p.fqType);\r\n }\r\n });\r\n }\r\n }\r\n\r\n private postProcessModel() {\r\n // complex types\r\n const complexTypes = this.dataModel.getComplexTypes();\r\n complexTypes.forEach((ct) => {\r\n // build up set of subtypes for each complex type\r\n this.addSubtypes(ct);\r\n\r\n // get props & keys from base types\r\n const [baseProps, _, baseAttributes] = this.collectBaseClassPropsAndKeys(ct, []);\r\n const { open } = baseAttributes;\r\n ct.baseProps = baseProps.map((bp) => ({ ...bp }));\r\n if (open) {\r\n ct.open = true;\r\n }\r\n });\r\n // entity types\r\n const entityTypes = this.dataModel.getEntityTypes();\r\n entityTypes.forEach((et) => {\r\n // build up set of subtypes for each entity type\r\n this.addSubtypes(et);\r\n\r\n // get props & keys from base types\r\n const [baseProps, baseKeys, baseAttributes] = this.collectBaseClassPropsAndKeys(et, []);\r\n const { fqIdName, idName, qIdName, open } = baseAttributes;\r\n et.baseProps = baseProps.map((bp) => ({ ...bp }));\r\n\r\n if (!et.keyNames.length && idName) {\r\n et.id = {\r\n fqName: fqIdName,\r\n modelName: idName,\r\n qName: qIdName,\r\n };\r\n et.generateId = false;\r\n }\r\n if (open) {\r\n et.open = open;\r\n }\r\n et.keyNames.unshift(...baseKeys.filter((bk) => !et.keyNames.includes(bk)));\r\n });\r\n }\r\n\r\n private postProcessKeys() {\r\n const entityTypes = this.dataModel.getEntityTypes();\r\n entityTypes.forEach((et) => {\r\n const isSingleKey = et.keyNames.length === 1;\r\n const props = [...et.baseProps, ...et.props];\r\n et.keys = et.keyNames.map((keyName) => {\r\n const prop = props.find((p) => p.odataName === keyName);\r\n if (!prop) {\r\n throw new Error(`Key with name [${keyName}] not found in props!`);\r\n }\r\n\r\n // automatically set key prop to managed, if this is the only key of the given entity\r\n if (prop.managed === undefined) {\r\n prop.managed = !this.options.disableAutoManagedKey && isSingleKey;\r\n }\r\n\r\n return prop;\r\n });\r\n });\r\n }\r\n\r\n private collectBaseClassPropsAndKeys(model: ComplexModelType, visitedModels: string[]): CollectorTuple {\r\n if (visitedModels.includes(model.fqName)) {\r\n throw new Error(`Cyclic inheritance detected for model ${model.fqName}!`);\r\n }\r\n visitedModels.push(model.fqName);\r\n return model.baseClasses.reduce(\r\n ([props, keys, attributes], bc) => {\r\n const baseModel = this.dataModel.getEntityType(bc) || this.dataModel.getComplexType(bc);\r\n if (!baseModel) {\r\n throw new Error(`BaseModel \"${bc}\" doesn't exist!`);\r\n }\r\n\r\n let { fqIdName, idName, qIdName, open } = attributes;\r\n\r\n // recursive\r\n if (baseModel.baseClasses.length) {\r\n const [parentProps, parentKeys, parentAttributes] = this.collectBaseClassPropsAndKeys(\r\n baseModel,\r\n visitedModels,\r\n );\r\n props.unshift(...parentProps);\r\n keys.unshift(...parentKeys);\r\n if (parentAttributes?.idName) {\r\n fqIdName = parentAttributes.fqIdName;\r\n idName = parentAttributes.idName;\r\n qIdName = parentAttributes.qIdName;\r\n }\r\n if (parentAttributes?.open) {\r\n open = true;\r\n }\r\n }\r\n\r\n props.push(...baseModel.props);\r\n const entityModel = baseModel as EntityModelType;\r\n if (entityModel.keyNames?.length) {\r\n keys.push(...entityModel.keyNames.filter((kn) => !keys.includes(kn)));\r\n fqIdName = entityModel.id.fqName;\r\n idName = entityModel.id.modelName;\r\n qIdName = entityModel.id.qName;\r\n }\r\n if (baseModel.open) {\r\n open = true;\r\n }\r\n return [props, keys, { fqIdName, idName, qIdName, open }];\r\n },\r\n [[], [], { fqIdName: \"\", idName: \"\", qIdName: \"\", open: false }] as CollectorTuple,\r\n );\r\n }\r\n\r\n protected mapProp = (p: Property, entityPropConfig?: PropertyGenerationOptions | undefined): PropertyModel => {\r\n if (!p.$.Type) {\r\n throw new Error(`No type information given for property [${p.$.Name}]!`);\r\n }\r\n\r\n const configProp = this.serviceConfigHelper.findPropConfigByName(p.$.Name);\r\n const modelName = this.namingHelper.getModelPropName(\r\n entityPropConfig?.mappedName || configProp?.mappedName || p.$.Name,\r\n );\r\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\r\n let odataDataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\r\n\r\n // support for primitive type mapping\r\n if (this.namingHelper.includesServicePrefix(odataDataType)) {\r\n const dt = this.dataModel.getPrimitiveType(odataDataType);\r\n if (dt !== undefined) {\r\n odataDataType = dt;\r\n }\r\n }\r\n\r\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\r\n\r\n // domain object known from service:\r\n // EntityType, ComplexType, EnumType\r\n if (this.namingHelper.includesServicePrefix(odataDataType)) {\r\n const modelType = this.model2Type.get(odataDataType)!;\r\n const [dataTypeName, dataTypePrefix] = this.namingHelper.getNameAndServicePrefix(odataDataType);\r\n const dataTypeNamespace: NamespaceWithAlias = [dataTypePrefix!];\r\n if (!modelType) {\r\n throw new Error(\r\n `Couldn't determine model type (EntityType, ComplexType, etc) for property \"${p.$.Name}\"! Given data type: \"${odataDataType}\".`,\r\n );\r\n }\r\n\r\n // special handling for enums\r\n if (modelType === DataTypes.EnumType) {\r\n const enumConfig = this.serviceConfigHelper.findEnumTypeConfig(dataTypeNamespace, dataTypeName);\r\n result = {\r\n dataType: modelType,\r\n type: this.namingHelper.getEnumName(enumConfig?.mappedName ?? odataDataType),\r\n qPath: this.options.numericEnums ? \"QNumericEnumPath\" : \"QEnumPath\",\r\n qObject: isCollection\r\n ? this.options.numericEnums\r\n ? \"QNumericEnumCollection\"\r\n : \"QEnumCollection\"\r\n : undefined,\r\n qParam: this.options.numericEnums ? \"QNumericEnumParam\" : \"QEnumParam\",\r\n };\r\n }\r\n // handling of complex & entity types\r\n else {\r\n const entityConfig =\r\n modelType === DataTypes.ComplexType\r\n ? this.serviceConfigHelper.findComplexTypeConfig(dataTypeNamespace, dataTypeName)\r\n : this.serviceConfigHelper.findEntityTypeConfig(dataTypeNamespace, dataTypeName);\r\n const typeName = entityConfig?.mappedName ?? odataDataType;\r\n\r\n result = {\r\n dataType: modelType,\r\n type: this.namingHelper.getModelName(typeName),\r\n qPath: \"QEntityPath\",\r\n qObject: this.namingHelper.getQName(typeName),\r\n qParam: \"QComplexParam\",\r\n };\r\n }\r\n }\r\n // OData built-in data types\r\n else if (odataDataType.startsWith(Digester.EDM_PREFIX)) {\r\n const { outputType, qPath, qParam, qCollection } = this.mapODataType(odataDataType);\r\n const { to, toModule: typeModule, converters } = this.dataModel.getConverter(odataDataType) || {};\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 [${odataDataType}]: Not 'Collection(...)', not OData type 'Edm.*', not starting with one of the namespaces!`,\r\n );\r\n }\r\n\r\n return {\r\n odataName: p.$.Name,\r\n name: modelName,\r\n odataType: p.$.Type,\r\n fqType: odataDataType,\r\n required: ifFalse(p.$.Nullable),\r\n isCollection: isCollection,\r\n managed: typeof entityPropConfig?.managed !== \"undefined\" ? entityPropConfig.managed : configProp?.managed,\r\n ...result,\r\n };\r\n };\r\n\r\n private addSubtypes(model: ComplexModelType, grandChildren = new Set<string>()) {\r\n if (!model.baseClasses.length) {\r\n return;\r\n }\r\n\r\n model.baseClasses.forEach((baseClass) => {\r\n const baseType = this.dataModel.getModel(baseClass) as ComplexModelType;\r\n\r\n // add subtypes & base name for q-objects\r\n baseType.subtypes.add(model.fqName);\r\n if (!baseType.qBaseName) {\r\n baseType.qBaseName = this.namingHelper.getQBaseName(baseType.name);\r\n }\r\n grandChildren.forEach((gc) => baseType.subtypes.add(gc));\r\n\r\n // recursive\r\n grandChildren.add(model.fqName);\r\n this.addSubtypes(baseType, grandChildren);\r\n });\r\n }\r\n}\r\n"]}
@@ -50,6 +50,7 @@ export interface ComplexType {
50
50
  modelName: string;
51
51
  editableName: string;
52
52
  qName: string;
53
+ qBaseName?: string;
53
54
  serviceName: string;
54
55
  serviceCollectionName: string;
55
56
  folderPath: string;
@@ -60,6 +61,7 @@ export interface ComplexType {
60
61
  abstract: boolean;
61
62
  open: boolean;
62
63
  genMode: Modes;
64
+ subtypes: Set<string>;
63
65
  }
64
66
  export interface EnumType {
65
67
  dataType: DataTypes;
@@ -1 +1 @@
1
- {"version":3,"file":"DataTypeModel.js","sourceRoot":"","sources":["../../src/data-model/DataTypeModel.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,0BAAU,CAAA;IACV,0BAAU,CAAA;AACZ,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB","sourcesContent":["import { ValueConverterImport } from \"@odata2ts/converter-runtime\";\r\nimport { Modes } from \"../OptionModel.js\";\r\n\r\nexport enum ODataVersion {\r\n V2 = \"2.0\",\r\n V4 = \"4.0\",\r\n}\r\n\r\nexport const enum DataTypes {\r\n PrimitiveType = \"PrimitiveType\",\r\n EnumType = \"EnumType\",\r\n ComplexType = \"ComplexType\",\r\n ModelType = \"ModelType\",\r\n}\r\n\r\nexport const enum OperationTypes {\r\n Function = \"Function\",\r\n Action = \"Action\",\r\n}\r\n\r\nexport interface PropertyModel {\r\n odataName: string;\r\n name: string;\r\n odataType: string;\r\n fqType: string;\r\n type: string;\r\n typeModule?: string;\r\n qObject?: string;\r\n qPath: string;\r\n qParam?: string;\r\n required: boolean;\r\n isCollection: boolean;\r\n dataType: DataTypes;\r\n converters?: Array<ValueConverterImport>;\r\n managed?: boolean;\r\n}\r\n\r\nexport type ModelType = EntityType | ComplexType | EnumType;\r\n\r\nexport interface EntityType extends ComplexType {\r\n id: {\r\n // fully qualified name of entity to which this id belongs (might have been inherited)\r\n fqName: string;\r\n // that's the name of the param model for the id function\r\n modelName: string;\r\n // that's the name of the id function which is a q-object\r\n qName: string;\r\n };\r\n generateId: boolean;\r\n keyNames: Array<string>;\r\n keys: Array<PropertyModel>;\r\n getKeyUnion(): string;\r\n}\r\n\r\nexport interface ComplexType {\r\n dataType: DataTypes;\r\n fqName: string;\r\n odataName: string;\r\n name: string;\r\n modelName: string;\r\n editableName: string;\r\n qName: string;\r\n serviceName: string;\r\n serviceCollectionName: string;\r\n folderPath: string;\r\n props: Array<PropertyModel>;\r\n baseProps: Array<PropertyModel>;\r\n baseClasses: Array<string>;\r\n finalBaseClass: string | undefined;\r\n abstract: boolean;\r\n open: boolean;\r\n genMode: Modes;\r\n}\r\n\r\nexport interface EnumType {\r\n dataType: DataTypes;\r\n odataName: string;\r\n fqName: string;\r\n name: string;\r\n modelName: string;\r\n folderPath: string;\r\n members: Array<{ name: string; value: number }>;\r\n}\r\n\r\nexport interface OperationType {\r\n fqName: string;\r\n odataName: string;\r\n name: string;\r\n qName: string;\r\n paramsModelName: string;\r\n type: OperationTypes;\r\n parameters: Array<PropertyModel>;\r\n returnType?: ReturnTypeModel;\r\n usePost?: boolean;\r\n overrides?: Array<Array<PropertyModel>>;\r\n}\r\n\r\nexport interface ReturnTypeModel extends PropertyModel {}\r\n\r\nexport type EntityContainerModel = {\r\n entitySets: { [name: string]: EntitySetType };\r\n singletons: { [name: string]: SingletonType };\r\n functions: { [name: string]: FunctionImportType };\r\n actions: { [name: string]: ActionImportType };\r\n};\r\n\r\nexport interface SingletonType {\r\n fqName: string;\r\n odataName: string;\r\n name: string;\r\n entityType: EntityType;\r\n navPropBinding?: Array<NavPropBindingType>;\r\n}\r\n\r\nexport interface EntitySetType {\r\n fqName: string;\r\n odataName: string;\r\n name: string;\r\n entityType: EntityType;\r\n navPropBinding?: Array<NavPropBindingType>;\r\n}\r\n\r\nexport interface NavPropBindingType {\r\n path: string;\r\n target: string;\r\n}\r\n\r\nexport interface ActionImportType {\r\n fqName: string;\r\n odataName: string;\r\n name: string;\r\n operation: string;\r\n}\r\n\r\nexport interface FunctionImportType extends ActionImportType {\r\n entitySet: string;\r\n}\r\n"]}
1
+ {"version":3,"file":"DataTypeModel.js","sourceRoot":"","sources":["../../src/data-model/DataTypeModel.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,0BAAU,CAAA;IACV,0BAAU,CAAA;AACZ,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB","sourcesContent":["import { ValueConverterImport } from \"@odata2ts/converter-runtime\";\r\nimport { Modes } from \"../OptionModel.js\";\r\n\r\nexport enum ODataVersion {\r\n V2 = \"2.0\",\r\n V4 = \"4.0\",\r\n}\r\n\r\nexport const enum DataTypes {\r\n PrimitiveType = \"PrimitiveType\",\r\n EnumType = \"EnumType\",\r\n ComplexType = \"ComplexType\",\r\n ModelType = \"ModelType\",\r\n}\r\n\r\nexport const enum OperationTypes {\r\n Function = \"Function\",\r\n Action = \"Action\",\r\n}\r\n\r\nexport interface PropertyModel {\r\n odataName: string;\r\n name: string;\r\n odataType: string;\r\n fqType: string;\r\n type: string;\r\n typeModule?: string;\r\n qObject?: string;\r\n qPath: string;\r\n qParam?: string;\r\n required: boolean;\r\n isCollection: boolean;\r\n dataType: DataTypes;\r\n converters?: Array<ValueConverterImport>;\r\n managed?: boolean;\r\n}\r\n\r\nexport type ModelType = EntityType | ComplexType | EnumType;\r\n\r\nexport interface EntityType extends ComplexType {\r\n id: {\r\n // fully qualified name of entity to which this id belongs (might have been inherited)\r\n fqName: string;\r\n // that's the name of the param model for the id function\r\n modelName: string;\r\n // that's the name of the id function which is a q-object\r\n qName: string;\r\n };\r\n generateId: boolean;\r\n keyNames: Array<string>;\r\n keys: Array<PropertyModel>;\r\n getKeyUnion(): string;\r\n}\r\n\r\nexport interface ComplexType {\r\n dataType: DataTypes;\r\n fqName: string;\r\n odataName: string;\r\n name: string;\r\n modelName: string;\r\n editableName: string;\r\n qName: string;\r\n qBaseName?: string;\r\n serviceName: string;\r\n serviceCollectionName: string;\r\n folderPath: string;\r\n props: Array<PropertyModel>;\r\n baseProps: Array<PropertyModel>;\r\n baseClasses: Array<string>;\r\n finalBaseClass: string | undefined;\r\n abstract: boolean;\r\n open: boolean;\r\n genMode: Modes;\r\n subtypes: Set<string>;\r\n}\r\n\r\nexport interface EnumType {\r\n dataType: DataTypes;\r\n odataName: string;\r\n fqName: string;\r\n name: string;\r\n modelName: string;\r\n folderPath: string;\r\n members: Array<{ name: string; value: number }>;\r\n}\r\n\r\nexport interface OperationType {\r\n fqName: string;\r\n odataName: string;\r\n name: string;\r\n qName: string;\r\n paramsModelName: string;\r\n type: OperationTypes;\r\n parameters: Array<PropertyModel>;\r\n returnType?: ReturnTypeModel;\r\n usePost?: boolean;\r\n overrides?: Array<Array<PropertyModel>>;\r\n}\r\n\r\nexport interface ReturnTypeModel extends PropertyModel {}\r\n\r\nexport type EntityContainerModel = {\r\n entitySets: { [name: string]: EntitySetType };\r\n singletons: { [name: string]: SingletonType };\r\n functions: { [name: string]: FunctionImportType };\r\n actions: { [name: string]: ActionImportType };\r\n};\r\n\r\nexport interface SingletonType {\r\n fqName: string;\r\n odataName: string;\r\n name: string;\r\n entityType: EntityType;\r\n navPropBinding?: Array<NavPropBindingType>;\r\n}\r\n\r\nexport interface EntitySetType {\r\n fqName: string;\r\n odataName: string;\r\n name: string;\r\n entityType: EntityType;\r\n navPropBinding?: Array<NavPropBindingType>;\r\n}\r\n\r\nexport interface NavPropBindingType {\r\n path: string;\r\n target: string;\r\n}\r\n\r\nexport interface ActionImportType {\r\n fqName: string;\r\n odataName: string;\r\n name: string;\r\n operation: string;\r\n}\r\n\r\nexport interface FunctionImportType extends ActionImportType {\r\n entitySet: string;\r\n}\r\n"]}
@@ -43,6 +43,7 @@ export declare class NamingHelper {
43
43
  getIdModelName(name: string): string;
44
44
  getOperationParamsModelName(operationName: string, boundEntity?: string): string;
45
45
  getQName(name: string): string;
46
+ getQBaseName(name: string): string;
46
47
  getQPropName(name: string): string;
47
48
  getQIdFunctionName(name: string): string;
48
49
  getQFunctionName(operationName: string, boundEntity?: string): string;
@@ -184,6 +184,12 @@ export class NamingHelper {
184
184
  getQName(name) {
185
185
  return this.getName(name, this.getQObjectNamingStrategy(), this.options.queryObjects);
186
186
  }
187
+ getQBaseName(name) {
188
+ const opts = this.options.queryObjects;
189
+ const strategy = this.getQObjectNamingStrategy();
190
+ const result = this.getName(name, strategy, opts.baseType);
191
+ return opts.baseType.applyQNaming ? this.getName(result, strategy, opts) : result;
192
+ }
187
193
  getQPropName(name) {
188
194
  return this.getName(name, this.getQObjectPropNamingStrategy());
189
195
  }