@odata2ts/odata2ts 0.25.1 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/lib/OptionModel.d.ts +4 -0
- package/lib/OptionModel.js.map +1 -1
- package/lib/data-model/DataModelDigestion.d.ts +2 -1
- package/lib/data-model/DataModelDigestion.js +9 -5
- package/lib/data-model/DataModelDigestion.js.map +1 -1
- package/lib/data-model/DataModelDigestionV2.js +1 -1
- package/lib/data-model/DataModelDigestionV2.js.map +1 -1
- package/lib/data-model/DataModelDigestionV4.js +5 -5
- package/lib/data-model/DataModelDigestionV4.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.26.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.25.1...@odata2ts/odata2ts@0.26.0) (2023-07-13)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **odata2ts:** bound operations with namespace as part of the name ([#187](https://github.com/odata2ts/odata2ts/issues/187)) ([68209f2](https://github.com/odata2ts/odata2ts/commit/68209f2bb5bc16fdaa36e5a3ddef21d72ce8f273))
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **odata2ts:** allow property configuration via entity ([#188](https://github.com/odata2ts/odata2ts/issues/188)) ([bdb5bef](https://github.com/odata2ts/odata2ts/commit/bdb5bef6d70827e4cc06d8a8b73c6a31edb92a2e))
|
|
15
|
+
|
|
6
16
|
## [0.25.1](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.25.0...@odata2ts/odata2ts@0.25.1) (2023-07-10)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
package/lib/OptionModel.d.ts
CHANGED
|
@@ -205,6 +205,10 @@ export interface EntityGenerationOptions {
|
|
|
205
205
|
* Overwrite the key specification by naming the props by their EDMX name.
|
|
206
206
|
*/
|
|
207
207
|
keys?: Array<string>;
|
|
208
|
+
/**
|
|
209
|
+
* Configuration of individual properties.
|
|
210
|
+
*/
|
|
211
|
+
properties?: Array<PropertyGenerationOptions>;
|
|
208
212
|
}
|
|
209
213
|
/**
|
|
210
214
|
* All configuration options for properties of models.
|
package/lib/OptionModel.js.map
CHANGED
|
@@ -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,qBAAL,KAAK,QAKhB;AAED;;GAEG;AACH,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,yBAAT,SAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\r\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 * Model properties have explaining comments by default.\r\n * With this option you can turn that off.\r\n */\r\n skipComments?: boolean;\r\n\r\n /**\r\n * The naming options regarding the generated artefacts.\r\n */\r\n naming?: OverridableNamingOptions;\r\n\r\n /**\r\n * Some OData V2 services generate an extra wrapping for entity collection attributes:\r\n * <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities\r\n * an object with the property \"results\" is wrapped around the entity collection.\r\n *\r\n * If you're using the odata client then there's a build-in workaround in place which transforms\r\n * the results to remove this extra mapping. However, if you're only interested in the types, then\r\n * the generated models will not match that extra wrapping.\r\n *\r\n * Setting this configuration option to <code>true</code> (default: false) will add this extra\r\n * wrapping to the generated models. But this option is only valid if the generation mode is set\r\n * to <code>models</code>; it is ignored otherwise.\r\n */\r\n v2ModelsWithExtraResultsWrapping?: boolean;\r\n}\r\n\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"]}
|
|
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,qBAAL,KAAK,QAKhB;AAED;;GAEG;AACH,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,yBAAT,SAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\r\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 * Model properties have explaining comments by default.\r\n * With this option you can turn that off.\r\n */\r\n skipComments?: boolean;\r\n\r\n /**\r\n * The naming options regarding the generated artefacts.\r\n */\r\n naming?: OverridableNamingOptions;\r\n\r\n /**\r\n * Some OData V2 services generate an extra wrapping for entity collection attributes:\r\n * <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities\r\n * an object with the property \"results\" is wrapped around the entity collection.\r\n *\r\n * If you're using the odata client then there's a build-in workaround in place which transforms\r\n * the results to remove this extra mapping. However, if you're only interested in the types, then\r\n * the generated models will not match that extra wrapping.\r\n *\r\n * Setting this configuration option to <code>true</code> (default: false) will add this extra\r\n * wrapping to the generated models. But this option is only valid if the generation mode is set\r\n * to <code>models</code>; it is ignored otherwise.\r\n */\r\n v2ModelsWithExtraResultsWrapping?: boolean;\r\n}\r\n\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"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MappedConverterChains } from "@odata2ts/converter-runtime";
|
|
2
2
|
import { DigestionOptions } from "../FactoryFunctionModel";
|
|
3
|
+
import { PropertyGenerationOptions } from "../OptionModel";
|
|
3
4
|
import { DataModel } from "./DataModel";
|
|
4
5
|
import { ODataVersion, PropertyModel } from "./DataTypeModel";
|
|
5
6
|
import { ComplexType, EntityType, Property, Schema } from "./edmx/ODataEdmxModelBase";
|
|
@@ -44,5 +45,5 @@ export declare abstract class Digester<S extends Schema<ET, CT>, ET extends Enti
|
|
|
44
45
|
private postProcessModel;
|
|
45
46
|
private sortModelsByInheritance;
|
|
46
47
|
private collectBaseClassPropsAndKeys;
|
|
47
|
-
protected mapProp: (p: Property) => PropertyModel;
|
|
48
|
+
protected mapProp: (p: Property, entityPropConfig?: PropertyGenerationOptions | undefined) => PropertyModel;
|
|
48
49
|
}
|
|
@@ -11,12 +11,12 @@ class Digester {
|
|
|
11
11
|
this.options = options;
|
|
12
12
|
this.namingHelper = namingHelper;
|
|
13
13
|
this.model2Type = new Map();
|
|
14
|
-
this.mapProp = (p) => {
|
|
14
|
+
this.mapProp = (p, entityPropConfig) => {
|
|
15
15
|
if (!p.$.Type) {
|
|
16
16
|
throw new Error(`No type information given for property [${p.$.Name}]!`);
|
|
17
17
|
}
|
|
18
18
|
const configProp = this.serviceConfigHelper.findConfigPropByName(p.$.Name);
|
|
19
|
-
const name = this.namingHelper.getModelPropName((configProp === null || configProp === void 0 ? void 0 : configProp.mappedName) || p.$.Name);
|
|
19
|
+
const name = this.namingHelper.getModelPropName((entityPropConfig === null || entityPropConfig === void 0 ? void 0 : entityPropConfig.mappedName) || (configProp === null || configProp === void 0 ? void 0 : configProp.mappedName) || p.$.Name);
|
|
20
20
|
const isCollection = !!p.$.Type.match(/^Collection\(/);
|
|
21
21
|
let dataType = p.$.Type.replace(/^Collection\(([^\)]+)\)/, "$1");
|
|
22
22
|
if (this.namingHelper.includesServicePrefix(dataType)) {
|
|
@@ -27,7 +27,7 @@ class Digester {
|
|
|
27
27
|
}
|
|
28
28
|
let result;
|
|
29
29
|
// domain object known from service:
|
|
30
|
-
// EntityType, ComplexType, EnumType
|
|
30
|
+
// EntityType, ComplexType, EnumType
|
|
31
31
|
if (this.namingHelper.includesServicePrefix(dataType)) {
|
|
32
32
|
const resultDt = this.model2Type.get(dataType);
|
|
33
33
|
if (!resultDt) {
|
|
@@ -72,7 +72,7 @@ class Digester {
|
|
|
72
72
|
else {
|
|
73
73
|
throw new Error(`Unknown type [${dataType}]: Not 'Collection(...)', not OData type 'Edm.*', not starting with one of the namespaces!W`);
|
|
74
74
|
}
|
|
75
|
-
return Object.assign({ odataName: p.$.Name, name, odataType: p.$.Type, required: p.$.Nullable === "false", isCollection: isCollection, managed: configProp === null || configProp === void 0 ? void 0 : configProp.managed }, result);
|
|
75
|
+
return Object.assign({ odataName: p.$.Name, name, odataType: p.$.Type, required: p.$.Nullable === "false", isCollection: isCollection, managed: typeof (entityPropConfig === null || entityPropConfig === void 0 ? void 0 : entityPropConfig.managed) !== "undefined" ? entityPropConfig.managed : configProp === null || configProp === void 0 ? void 0 : configProp.managed }, result);
|
|
76
76
|
};
|
|
77
77
|
this.dataModel = new DataModel_1.DataModel(version, converters);
|
|
78
78
|
this.serviceConfigHelper = new ServiceConfigHelper_1.ServiceConfigHelper(options);
|
|
@@ -146,7 +146,11 @@ class Digester {
|
|
|
146
146
|
odataName,
|
|
147
147
|
editableName,
|
|
148
148
|
baseClasses,
|
|
149
|
-
props: props.map(
|
|
149
|
+
props: props.map((p) => {
|
|
150
|
+
var _a;
|
|
151
|
+
const epConfig = (_a = entityConfig === null || entityConfig === void 0 ? void 0 : entityConfig.properties) === null || _a === void 0 ? void 0 : _a.find((ep) => ep.name === p.$.Name);
|
|
152
|
+
return this.mapProp(p, epConfig);
|
|
153
|
+
}),
|
|
150
154
|
baseProps: [], // postprocess required
|
|
151
155
|
};
|
|
152
156
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataModelDigestion.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestion.ts"],"names":[],"mappings":";;;;AAGA,2CAAwC;AAMxC,+DAA4D;AAS5D,MAAsB,QAAQ;IAS5B,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;QAN9B,eAAU,GAA2B,IAAI,GAAG,EAAqB,CAAC;QAmShE,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,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,UAAU,KAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACpF,MAAM,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YACvD,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;YACjE,IAAI,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AE,aAAa,CAAC,CAAC;QACpD,CAAC,EACD,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAA0D,CAC1E,CAAC;IACJ,CAAC;;AAxSH,4BAyXC;AAxXkB,mBAAU,GAAG,MAAM,AAAT,CAAU;AACpB,uBAAc,GAAG,GAAG,AAAN,CAAO","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, ModelType, ODataVersion, PropertyModel } from \"./DataTypeModel\";\r\nimport { ComplexType, EntityType, Property, Schema, TypeDefinition } from \"./edmx/ODataEdmxModelBase\";\r\nimport { SchemaV3 } from \"./edmx/ODataEdmxModelV3\";\r\nimport { SchemaV4 } from \"./edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\nimport { ServiceConfigHelper } 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 schemas: Array<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\r\n this.collectModelTypes(schemas);\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 return this.dataModel;\r\n }\r\n\r\n private collectModelTypes(schemas: Array<S>) {\r\n schemas.forEach((schema) => {\r\n const servicePrefix = schema.$.Namespace + \".\";\r\n\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\r\n private digestEntityTypesAndOperations() {\r\n this.schemas.forEach((schema) => {\r\n // type definitions: alias for primitive types\r\n this.addTypeDefinition(schema.TypeDefinition);\r\n\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 // V4 only: function & action types\r\n this.digestOperations(schema);\r\n });\r\n\r\n this.postProcessModel();\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 addTypeDefinition(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(t.$.Name, t.$.UnderlyingType);\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 const complexTypes = this.dataModel.getComplexTypes();\r\n complexTypes.forEach((model) => {\r\n const [baseProps] = this.collectBaseClassPropsAndKeys(model, []);\r\n model.baseProps = baseProps;\r\n });\r\n const modelTypes = this.dataModel.getModels();\r\n // entity types\r\n modelTypes.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 const sortedModelTypes = this.sortModelsByInheritance<ModelType>(modelTypes);\r\n this.dataModel.setModels(sortedModelTypes);\r\n\r\n const sortedComplexTypes = this.sortModelsByInheritance<ComplexModelType>(complexTypes);\r\n this.dataModel.setComplexTypes(sortedComplexTypes);\r\n }\r\n\r\n private sortModelsByInheritance<Type extends ComplexModelType>(models: Type[]): { [name: string]: Type } {\r\n // recursively visit all models and sort them by inheritance such that base classes\r\n // are always before derived classes\r\n const sortedModels: { [name: string]: Type } = {};\r\n const visitedModels = new Set<Type>();\r\n const inProgressModels = new Set<Type>();\r\n\r\n function visit(model: Type) {\r\n if (inProgressModels.has(model)) {\r\n throw new Error(\"Cyclic dependencies detected!\");\r\n }\r\n\r\n if (!visitedModels.has(model)) {\r\n inProgressModels.add(model);\r\n\r\n for (const baseClassName of model.baseClasses) {\r\n const baseClass = models.find((e) => e.name === baseClassName);\r\n if (baseClass) {\r\n visit(baseClass);\r\n }\r\n }\r\n visitedModels.add(model);\r\n inProgressModels.delete(model);\r\n sortedModels[model.name] = model;\r\n }\r\n }\r\n\r\n for (const model of models) {\r\n visit(model);\r\n }\r\n return sortedModels;\r\n }\r\n\r\n private collectBaseClassPropsAndKeys(\r\n model: ComplexModelType,\r\n visitedModels: string[]\r\n ): [Array<PropertyModel>, Array<string>, string, string] {\r\n if (visitedModels.includes(model.name)) {\r\n throw new Error(`Cyclic inheritance detected for model ${model.name}!`);\r\n }\r\n visitedModels.push(model.name);\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 if (!baseModel) {\r\n throw new Error(`BaseModel \"${bc}\" doesn't exist!`);\r\n }\r\n\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(\r\n baseModel,\r\n visitedModels\r\n );\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?.length) {\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 configProp = this.serviceConfigHelper.findConfigPropByName(p.$.Name);\r\n const name = this.namingHelper.getModelPropName(configProp?.mappedName || p.$.Name);\r\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\r\n let dataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\r\n if (this.namingHelper.includesServicePrefix(dataType)) {\r\n const dtName = this.namingHelper.stripServicePrefix(dataType);\r\n if (this.dataModel.getPrimitiveType(dtName) !== undefined) {\r\n dataType = this.dataModel.getPrimitiveType(dtName)!;\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 or TypeDefinition\r\n if (this.namingHelper.includesServicePrefix(dataType)) {\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 OData type 'Edm.*', not starting with one of the namespaces!W`\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":";;;;AAIA,2CAAwC;AAMxC,+DAA4D;AAS5D,MAAsB,QAAQ;IAS5B,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;QAN9B,eAAU,GAA2B,IAAI,GAAG,EAAqB,CAAC;QAsShE,YAAO,GAAG,CAAC,CAAW,EAAE,gBAAwD,EAAiB,EAAE;YAC3G,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,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC3E,MAAM,IAAI,GAAG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AAC;YAE5B,YAAY;YACZ,IAAI,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE;gBAChC,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,CAAC,GAAG,IAAI,CAAC,4BAA4B,CAC9F,SAAS,EACT,aAAa,CACd,CAAC;gBACF,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,MAAA,SAAS,CAAC,QAAQ,0CAAE,MAAM,EAAE;gBAC9B,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;;AA3SH,4BA4XC;AA3XkB,mBAAU,GAAG,MAAM,AAAT,CAAU;AACpB,uBAAc,GAAG,GAAG,AAAN,CAAO","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { PropertyGenerationOptions } from \"../OptionModel\";\r\nimport { DataModel } from \"./DataModel\";\r\nimport { ComplexType as ComplexModelType, DataTypes, ModelType, ODataVersion, PropertyModel } from \"./DataTypeModel\";\r\nimport { ComplexType, EntityType, Property, Schema, TypeDefinition } from \"./edmx/ODataEdmxModelBase\";\r\nimport { SchemaV3 } from \"./edmx/ODataEdmxModelV3\";\r\nimport { SchemaV4 } from \"./edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\nimport { ServiceConfigHelper } 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 schemas: Array<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\r\n this.collectModelTypes(schemas);\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 return this.dataModel;\r\n }\r\n\r\n private collectModelTypes(schemas: Array<S>) {\r\n schemas.forEach((schema) => {\r\n const servicePrefix = schema.$.Namespace + \".\";\r\n\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\r\n private digestEntityTypesAndOperations() {\r\n this.schemas.forEach((schema) => {\r\n // type definitions: alias for primitive types\r\n this.addTypeDefinition(schema.TypeDefinition);\r\n\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 // V4 only: function & action types\r\n this.digestOperations(schema);\r\n });\r\n\r\n this.postProcessModel();\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((p) => {\r\n const epConfig = entityConfig?.properties?.find((ep) => ep.name === p.$.Name);\r\n return this.mapProp(p, epConfig);\r\n }),\r\n baseProps: [], // postprocess required\r\n };\r\n }\r\n\r\n private addTypeDefinition(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(t.$.Name, t.$.UnderlyingType);\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 const complexTypes = this.dataModel.getComplexTypes();\r\n complexTypes.forEach((model) => {\r\n const [baseProps] = this.collectBaseClassPropsAndKeys(model, []);\r\n model.baseProps = baseProps;\r\n });\r\n const modelTypes = this.dataModel.getModels();\r\n // entity types\r\n modelTypes.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 const sortedModelTypes = this.sortModelsByInheritance<ModelType>(modelTypes);\r\n this.dataModel.setModels(sortedModelTypes);\r\n\r\n const sortedComplexTypes = this.sortModelsByInheritance<ComplexModelType>(complexTypes);\r\n this.dataModel.setComplexTypes(sortedComplexTypes);\r\n }\r\n\r\n private sortModelsByInheritance<Type extends ComplexModelType>(models: Type[]): { [name: string]: Type } {\r\n // recursively visit all models and sort them by inheritance such that base classes\r\n // are always before derived classes\r\n const sortedModels: { [name: string]: Type } = {};\r\n const visitedModels = new Set<Type>();\r\n const inProgressModels = new Set<Type>();\r\n\r\n function visit(model: Type) {\r\n if (inProgressModels.has(model)) {\r\n throw new Error(\"Cyclic dependencies detected!\");\r\n }\r\n\r\n if (!visitedModels.has(model)) {\r\n inProgressModels.add(model);\r\n\r\n for (const baseClassName of model.baseClasses) {\r\n const baseClass = models.find((e) => e.name === baseClassName);\r\n if (baseClass) {\r\n visit(baseClass);\r\n }\r\n }\r\n visitedModels.add(model);\r\n inProgressModels.delete(model);\r\n sortedModels[model.name] = model;\r\n }\r\n }\r\n\r\n for (const model of models) {\r\n visit(model);\r\n }\r\n return sortedModels;\r\n }\r\n\r\n private collectBaseClassPropsAndKeys(\r\n model: ComplexModelType,\r\n visitedModels: string[]\r\n ): [Array<PropertyModel>, Array<string>, string, string] {\r\n if (visitedModels.includes(model.name)) {\r\n throw new Error(`Cyclic inheritance detected for model ${model.name}!`);\r\n }\r\n visitedModels.push(model.name);\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 if (!baseModel) {\r\n throw new Error(`BaseModel \"${bc}\" doesn't exist!`);\r\n }\r\n\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(\r\n baseModel,\r\n visitedModels\r\n );\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?.length) {\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, 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.findConfigPropByName(p.$.Name);\r\n const name = this.namingHelper.getModelPropName(entityPropConfig?.mappedName || configProp?.mappedName || p.$.Name);\r\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\r\n let dataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\r\n if (this.namingHelper.includesServicePrefix(dataType)) {\r\n const dtName = this.namingHelper.stripServicePrefix(dataType);\r\n if (this.dataModel.getPrimitiveType(dtName) !== undefined) {\r\n dataType = this.dataModel.getPrimitiveType(dtName)!;\r\n }\r\n }\r\n\r\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\r\n\r\n // domain object known from service:\r\n // EntityType, ComplexType, EnumType\r\n if (this.namingHelper.includesServicePrefix(dataType)) {\r\n const resultDt = this.model2Type.get(dataType);\r\n 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 OData type 'Edm.*', not starting with one of the namespaces!W`\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: typeof entityPropConfig?.managed !== \"undefined\" ? entityPropConfig.managed : configProp?.managed,\r\n ...result,\r\n };\r\n };\r\n}\r\n"]}
|
|
@@ -66,7 +66,7 @@ class DigesterV3 extends DataModelDigestion_1.Digester {
|
|
|
66
66
|
var _a, _b, _c, _d;
|
|
67
67
|
const name = this.namingHelper.getFunctionName(funcImport.$.Name);
|
|
68
68
|
const usePost = ((_a = funcImport.$["m:HttpMethod"]) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === "POST";
|
|
69
|
-
const parameters = (_c = (_b = funcImport.Parameter) === null || _b === void 0 ? void 0 : _b.map(this.mapProp)) !== null && _c !== void 0 ? _c : [];
|
|
69
|
+
const parameters = (_c = (_b = funcImport.Parameter) === null || _b === void 0 ? void 0 : _b.map((p) => this.mapProp(p))) !== null && _c !== void 0 ? _c : [];
|
|
70
70
|
// TODO: the spec allows for multiple ReturnType elements
|
|
71
71
|
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/mc-csdl/f510f36a-36bf-47f4-ac41-4a0ff921fbfa
|
|
72
72
|
// totally unclear how the response object would look like
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataModelDigestionV2.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestionV2.ts"],"names":[],"mappings":";;;;AAAA,mEAAoF;AACpF,qDAAmE;AAGnE,6DAA2D;AAC3D,mDAA6F;AAK7F;;;;;;GAMG;AACI,MAAM,MAAM,GAA+B,CAAO,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;IACzF,MAAM,UAAU,GAAG,MAAM,IAAA,kCAAc,EAAC,0BAAa,CAAC,EAAE,EA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AAE,QAAQ;oBACpB,KAAK,EAAE,uBAAuB;oBAC9B,WAAW,EAAE,6BAA6B;oBAC1C,MAAM,EAAE,wBAAwB;iBACjC,CAAC;YACJ,KAAK,yBAAY,CAAC,MAAM;gBACtB,OAAO;oBACL,UAAU,EAAE,QAAQ;oBACpB,KAAK,EAAE,aAAa;oBACpB,WAAW,EAAE,mBAAmB;oBAChC,MAAM,EAAE,SAAS;iBAClB,CAAC;YACJ,KAAK,yBAAY,CAAC,IAAI;gBACpB,OAAO;oBACL,UAAU,EAAE,QAAQ;oBACpB,KAAK,EAAE,aAAa;oBACpB,WAAW,EAAE,mBAAmB;oBAChC,MAAM,EAAE,cAAc;iBACvB,CAAC;YACJ;gBACE,OAAO;oBACL,UAAU,EAAE,QAAQ;oBACpB,KAAK,EAAE,eAAe;oBACtB,WAAW,EAAE,qBAAqB;oBAClC,MAAM,EAAE,SAAS;iBAClB,CAAC;SACL;IACH,CAAC;CACF","sourcesContent":["import { MappedConverterChains, loadConverters } from \"@odata2ts/converter-runtime\";\r\nimport { ODataTypesV2, ODataVersions } from \"@odata2ts/odata-core\";\r\n\r\nimport { DigesterFunction, DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { Digester, TypeModel } from \"./DataModelDigestion\";\r\nimport { ODataVersion, OperationType, OperationTypes, PropertyModel } from \"./DataTypeModel\";\r\nimport { ComplexType, Property } from \"./edmx/ODataEdmxModelBase\";\r\nimport { AssociationEnd, ComplexTypeV3, EntityTypeV3, NavigationProperty, SchemaV3 } from \"./edmx/ODataEdmxModelV3\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\n\r\n/**\r\n * Digests an EDMX schema to produce a DataModel.\r\n *\r\n * @param schema\r\n * @param options\r\n * @param namingHelper\r\n */\r\nexport const digest: DigesterFunction<SchemaV3> = async (schemas, options, namingHelper) => {\r\n const converters = await loadConverters(ODataVersions.V2, options.converters);\r\n\r\n const digester = new DigesterV3(schemas, options, namingHelper, converters);\r\n return digester.digest();\r\n};\r\n\r\nclass DigesterV3 extends Digester<SchemaV3, EntityTypeV3, ComplexTypeV3> {\r\n constructor(\r\n schemas: Array<SchemaV3>,\r\n options: DigestionOptions,\r\n namingHelper: NamingHelper,\r\n converters: MappedConverterChains | undefined\r\n ) {\r\n super(ODataVersion.V2, schemas, options, namingHelper, converters);\r\n }\r\n\r\n private findAssociationEnd(np: NavigationProperty): AssociationEnd {\r\n for (let schema of this.schemas) {\r\n if (schema.Association) {\r\n const relationship = this.namingHelper.stripServicePrefix(np.$.Relationship);\r\n const association = schema.Association?.find((a) => a.$.Name === relationship);\r\n const result = association?.End.find((e) => e.$.Role === np.$.ToRole);\r\n if (result) {\r\n return result;\r\n }\r\n }\r\n }\r\n throw new Error(`Association end couldn't be determined for NavigationProperty [${np.$.Name}]`);\r\n }\r\n\r\n protected getNavigationProps(entityType: ComplexType | EntityTypeV3): Array<Property> {\r\n // return (entityType as EntityTypeV3).NavigationProperty || [];\r\n const et = entityType as EntityTypeV3;\r\n if (et.NavigationProperty) {\r\n return et.NavigationProperty.map((np) => {\r\n const end = this.findAssociationEnd(np);\r\n const isRequired = end.$.Multiplicity !== \"*\" && !end.$.Multiplicity.startsWith(\"0..\");\r\n const isCollection = end.$.Multiplicity !== \"1\" && !end.$.Multiplicity.endsWith(\"..1\");\r\n\r\n return {\r\n $: {\r\n Name: np.$.Name,\r\n Type: isCollection ? `Collection(${end.$.Type})` : end.$.Type,\r\n Nullable: isRequired ? \"false\" : \"true\",\r\n },\r\n };\r\n });\r\n }\r\n\r\n return [];\r\n }\r\n\r\n // in V2 all we have & need is the FunctionImport: Function & Action elements are only known in V4.\r\n protected digestOperations(schema: SchemaV3) {}\r\n\r\n protected digestEntityContainer(schema: SchemaV3) {\r\n if (schema.EntityContainer && schema.EntityContainer.length) {\r\n const container = schema.EntityContainer[0];\r\n\r\n container.FunctionImport?.forEach((funcImport) => {\r\n const name = this.namingHelper.getFunctionName(funcImport.$.Name);\r\n const usePost = funcImport.$[\"m:HttpMethod\"]?.toUpperCase() === \"POST\";\r\n const parameters = funcImport.Parameter?.map(this.mapProp) ?? [];\r\n\r\n // TODO: the spec allows for multiple ReturnType elements\r\n // https://docs.microsoft.com/en-us/openspecs/windows_protocols/mc-csdl/f510f36a-36bf-47f4-ac41-4a0ff921fbfa\r\n // totally unclear how the response object would look like\r\n const returnTypeDef =\r\n funcImport.$.ReturnType || (funcImport.ReturnType?.length ? funcImport.ReturnType[0].$.Type : undefined);\r\n const returnType: PropertyModel | undefined = returnTypeDef\r\n ? this.mapProp({ $: { Name: \"NO_NAME_BECAUSE_RETURN_TYPE\", Type: returnTypeDef } })\r\n : undefined;\r\n\r\n const operation: OperationType = {\r\n name,\r\n odataName: funcImport.$.Name,\r\n paramsModelName: this.namingHelper.getOperationParamsModelName(funcImport.$.Name),\r\n qName: this.namingHelper.getQFunctionName(funcImport.$.Name),\r\n type: OperationTypes.Function,\r\n parameters,\r\n returnType,\r\n usePost,\r\n };\r\n this.dataModel.addOperationType(\"/\", operation);\r\n\r\n this.dataModel.addFunction(name, {\r\n name,\r\n odataName: funcImport.$.Name,\r\n // TODO: does this really match V4 model?!\r\n entitySet: funcImport.$.EntitySet!,\r\n operation: operation,\r\n });\r\n });\r\n\r\n container.EntitySet?.forEach((entitySet) => {\r\n const name = entitySet.$.Name;\r\n\r\n this.dataModel.addEntitySet(name, {\r\n name,\r\n odataName: entitySet.$.Name,\r\n entityType: this.dataModel.getModel(this.namingHelper.getModelName(entitySet.$.EntityType)),\r\n });\r\n });\r\n }\r\n }\r\n\r\n protected mapODataType(type: string): TypeModel {\r\n switch (type) {\r\n case ODataTypesV2.Boolean:\r\n return {\r\n outputType: \"boolean\",\r\n qPath: \"QBooleanPath\",\r\n qCollection: \"QBooleanCollection\",\r\n qParam: \"QBooleanParam\",\r\n };\r\n case ODataTypesV2.Int16:\r\n case ODataTypesV2.Int32:\r\n return {\r\n outputType: \"number\",\r\n qPath: \"QNumberV2Path\",\r\n qCollection: \"QNumberV2Collection\",\r\n qParam: \"QNumberParam\",\r\n };\r\n case ODataTypesV2.Byte:\r\n case ODataTypesV2.SByte:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringNumberV2Path\",\r\n qCollection: \"QStringNumberV2Collection\",\r\n qParam: \"QStringNumberV2Param\",\r\n };\r\n case ODataTypesV2.Int64:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringNumberV2Path\",\r\n qCollection: \"QStringNumberV2Collection\",\r\n qParam: \"QInt64V2Param\",\r\n };\r\n case ODataTypesV2.Single:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringNumberV2Path\",\r\n qCollection: \"QStringNumberV2Collection\",\r\n qParam: \"QSingleV2Param\",\r\n };\r\n case ODataTypesV2.Double:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringNumberV2Path\",\r\n qCollection: \"QStringNumberV2Collection\",\r\n qParam: \"QDoubleV2Param\",\r\n };\r\n case ODataTypesV2.Decimal:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringNumberV2Path\",\r\n qCollection: \"QStringNumberV2Collection\",\r\n qParam: \"QDecimalV2Param\",\r\n };\r\n case ODataTypesV2.String:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringV2Path\",\r\n qCollection: \"QStringV2Collection\",\r\n qParam: \"QStringParam\",\r\n };\r\n case ODataTypesV2.DateTime:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QDateTimeV2Path\",\r\n qCollection: \"QDateTimeV2Collection\",\r\n qParam: \"QDateTimeV2Param\",\r\n };\r\n case ODataTypesV2.Time:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QTimeV2Path\",\r\n qCollection: \"QTimeV2Collection\",\r\n qParam: \"QTimeV2Param\",\r\n };\r\n case ODataTypesV2.DateTimeOffset:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QDateTimeOffsetV2Path\",\r\n qCollection: \"QDateTimeOffsetV2Collection\",\r\n qParam: \"QDateTimeOffsetV2Param\",\r\n };\r\n case ODataTypesV2.Binary:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QBinaryPath\",\r\n qCollection: \"QBinaryCollection\",\r\n qParam: undefined,\r\n };\r\n case ODataTypesV2.Guid:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QGuidV2Path\",\r\n qCollection: \"QGuidV2Collection\",\r\n qParam: \"QGuidV2Param\",\r\n };\r\n default:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringV2Path\",\r\n qCollection: \"QStringV2Collection\",\r\n qParam: undefined,\r\n };\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"DataModelDigestionV2.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestionV2.ts"],"names":[],"mappings":";;;;AAAA,mEAAoF;AACpF,qDAAmE;AAGnE,6DAA2D;AAC3D,mDAA6F;AAK7F;;;;;;GAMG;AACI,MAAM,MAAM,GAA+B,CAAO,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;IACzF,MAAM,UAAU,GAAG,MAAM,IAAA,kCAAc,EAAC,0BAAa,CAAC,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9E,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IAC5E,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;AAC3B,CAAC,CAAA,CAAC;AALW,QAAA,MAAM,UAKjB;AAEF,MAAM,UAAW,SAAQ,6BAA+C;IACtE,YACE,OAAwB,EACxB,OAAyB,EACzB,YAA0B,EAC1B,UAA6C;QAE7C,KAAK,CAAC,4BAAY,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC;IAEO,kBAAkB,CAAC,EAAsB;;QAC/C,KAAK,IAAI,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;YAC/B,IAAI,MAAM,CAAC,WAAW,EAAE;gBACtB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WAAW,EAAE,qBAAqB;oBAClC,MAAM,EAAE,SAAS;iBAClB,CAAC;SACL;IACH,CAAC;CACF","sourcesContent":["import { MappedConverterChains, loadConverters } from \"@odata2ts/converter-runtime\";\r\nimport { ODataTypesV2, ODataVersions } from \"@odata2ts/odata-core\";\r\n\r\nimport { DigesterFunction, DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { Digester, TypeModel } from \"./DataModelDigestion\";\r\nimport { ODataVersion, OperationType, OperationTypes, PropertyModel } from \"./DataTypeModel\";\r\nimport { ComplexType, Property } from \"./edmx/ODataEdmxModelBase\";\r\nimport { AssociationEnd, ComplexTypeV3, EntityTypeV3, NavigationProperty, SchemaV3 } from \"./edmx/ODataEdmxModelV3\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\n\r\n/**\r\n * Digests an EDMX schema to produce a DataModel.\r\n *\r\n * @param schema\r\n * @param options\r\n * @param namingHelper\r\n */\r\nexport const digest: DigesterFunction<SchemaV3> = async (schemas, options, namingHelper) => {\r\n const converters = await loadConverters(ODataVersions.V2, options.converters);\r\n\r\n const digester = new DigesterV3(schemas, options, namingHelper, converters);\r\n return digester.digest();\r\n};\r\n\r\nclass DigesterV3 extends Digester<SchemaV3, EntityTypeV3, ComplexTypeV3> {\r\n constructor(\r\n schemas: Array<SchemaV3>,\r\n options: DigestionOptions,\r\n namingHelper: NamingHelper,\r\n converters: MappedConverterChains | undefined\r\n ) {\r\n super(ODataVersion.V2, schemas, options, namingHelper, converters);\r\n }\r\n\r\n private findAssociationEnd(np: NavigationProperty): AssociationEnd {\r\n for (let schema of this.schemas) {\r\n if (schema.Association) {\r\n const relationship = this.namingHelper.stripServicePrefix(np.$.Relationship);\r\n const association = schema.Association?.find((a) => a.$.Name === relationship);\r\n const result = association?.End.find((e) => e.$.Role === np.$.ToRole);\r\n if (result) {\r\n return result;\r\n }\r\n }\r\n }\r\n throw new Error(`Association end couldn't be determined for NavigationProperty [${np.$.Name}]`);\r\n }\r\n\r\n protected getNavigationProps(entityType: ComplexType | EntityTypeV3): Array<Property> {\r\n // return (entityType as EntityTypeV3).NavigationProperty || [];\r\n const et = entityType as EntityTypeV3;\r\n if (et.NavigationProperty) {\r\n return et.NavigationProperty.map((np) => {\r\n const end = this.findAssociationEnd(np);\r\n const isRequired = end.$.Multiplicity !== \"*\" && !end.$.Multiplicity.startsWith(\"0..\");\r\n const isCollection = end.$.Multiplicity !== \"1\" && !end.$.Multiplicity.endsWith(\"..1\");\r\n\r\n return {\r\n $: {\r\n Name: np.$.Name,\r\n Type: isCollection ? `Collection(${end.$.Type})` : end.$.Type,\r\n Nullable: isRequired ? \"false\" : \"true\",\r\n },\r\n };\r\n });\r\n }\r\n\r\n return [];\r\n }\r\n\r\n // in V2 all we have & need is the FunctionImport: Function & Action elements are only known in V4.\r\n protected digestOperations(schema: SchemaV3) {}\r\n\r\n protected digestEntityContainer(schema: SchemaV3) {\r\n if (schema.EntityContainer && schema.EntityContainer.length) {\r\n const container = schema.EntityContainer[0];\r\n\r\n container.FunctionImport?.forEach((funcImport) => {\r\n const name = this.namingHelper.getFunctionName(funcImport.$.Name);\r\n const usePost = funcImport.$[\"m:HttpMethod\"]?.toUpperCase() === \"POST\";\r\n const parameters = funcImport.Parameter?.map((p) => this.mapProp(p)) ?? [];\r\n\r\n // TODO: the spec allows for multiple ReturnType elements\r\n // https://docs.microsoft.com/en-us/openspecs/windows_protocols/mc-csdl/f510f36a-36bf-47f4-ac41-4a0ff921fbfa\r\n // totally unclear how the response object would look like\r\n const returnTypeDef =\r\n funcImport.$.ReturnType || (funcImport.ReturnType?.length ? funcImport.ReturnType[0].$.Type : undefined);\r\n const returnType: PropertyModel | undefined = returnTypeDef\r\n ? this.mapProp({ $: { Name: \"NO_NAME_BECAUSE_RETURN_TYPE\", Type: returnTypeDef } })\r\n : undefined;\r\n\r\n const operation: OperationType = {\r\n name,\r\n odataName: funcImport.$.Name,\r\n paramsModelName: this.namingHelper.getOperationParamsModelName(funcImport.$.Name),\r\n qName: this.namingHelper.getQFunctionName(funcImport.$.Name),\r\n type: OperationTypes.Function,\r\n parameters,\r\n returnType,\r\n usePost,\r\n };\r\n this.dataModel.addOperationType(\"/\", operation);\r\n\r\n this.dataModel.addFunction(name, {\r\n name,\r\n odataName: funcImport.$.Name,\r\n // TODO: does this really match V4 model?!\r\n entitySet: funcImport.$.EntitySet!,\r\n operation: operation,\r\n });\r\n });\r\n\r\n container.EntitySet?.forEach((entitySet) => {\r\n const name = entitySet.$.Name;\r\n\r\n this.dataModel.addEntitySet(name, {\r\n name,\r\n odataName: entitySet.$.Name,\r\n entityType: this.dataModel.getModel(this.namingHelper.getModelName(entitySet.$.EntityType)),\r\n });\r\n });\r\n }\r\n }\r\n\r\n protected mapODataType(type: string): TypeModel {\r\n switch (type) {\r\n case ODataTypesV2.Boolean:\r\n return {\r\n outputType: \"boolean\",\r\n qPath: \"QBooleanPath\",\r\n qCollection: \"QBooleanCollection\",\r\n qParam: \"QBooleanParam\",\r\n };\r\n case ODataTypesV2.Int16:\r\n case ODataTypesV2.Int32:\r\n return {\r\n outputType: \"number\",\r\n qPath: \"QNumberV2Path\",\r\n qCollection: \"QNumberV2Collection\",\r\n qParam: \"QNumberParam\",\r\n };\r\n case ODataTypesV2.Byte:\r\n case ODataTypesV2.SByte:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringNumberV2Path\",\r\n qCollection: \"QStringNumberV2Collection\",\r\n qParam: \"QStringNumberV2Param\",\r\n };\r\n case ODataTypesV2.Int64:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringNumberV2Path\",\r\n qCollection: \"QStringNumberV2Collection\",\r\n qParam: \"QInt64V2Param\",\r\n };\r\n case ODataTypesV2.Single:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringNumberV2Path\",\r\n qCollection: \"QStringNumberV2Collection\",\r\n qParam: \"QSingleV2Param\",\r\n };\r\n case ODataTypesV2.Double:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringNumberV2Path\",\r\n qCollection: \"QStringNumberV2Collection\",\r\n qParam: \"QDoubleV2Param\",\r\n };\r\n case ODataTypesV2.Decimal:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringNumberV2Path\",\r\n qCollection: \"QStringNumberV2Collection\",\r\n qParam: \"QDecimalV2Param\",\r\n };\r\n case ODataTypesV2.String:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringV2Path\",\r\n qCollection: \"QStringV2Collection\",\r\n qParam: \"QStringParam\",\r\n };\r\n case ODataTypesV2.DateTime:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QDateTimeV2Path\",\r\n qCollection: \"QDateTimeV2Collection\",\r\n qParam: \"QDateTimeV2Param\",\r\n };\r\n case ODataTypesV2.Time:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QTimeV2Path\",\r\n qCollection: \"QTimeV2Collection\",\r\n qParam: \"QTimeV2Param\",\r\n };\r\n case ODataTypesV2.DateTimeOffset:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QDateTimeOffsetV2Path\",\r\n qCollection: \"QDateTimeOffsetV2Collection\",\r\n qParam: \"QDateTimeOffsetV2Param\",\r\n };\r\n case ODataTypesV2.Binary:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QBinaryPath\",\r\n qCollection: \"QBinaryCollection\",\r\n qParam: undefined,\r\n };\r\n case ODataTypesV2.Guid:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QGuidV2Path\",\r\n qCollection: \"QGuidV2Collection\",\r\n qParam: \"QGuidV2Param\",\r\n };\r\n default:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringV2Path\",\r\n qCollection: \"QStringV2Collection\",\r\n qParam: undefined,\r\n };\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -21,8 +21,8 @@ class DigesterV4 extends DataModelDigestion_1.Digester {
|
|
|
21
21
|
}
|
|
22
22
|
digestOperations(schema) {
|
|
23
23
|
// functions & actions
|
|
24
|
-
this.addOperations(schema.Function, "Function" /* OperationTypes.Function */);
|
|
25
|
-
this.addOperations(schema.Action, "Action" /* OperationTypes.Action */);
|
|
24
|
+
this.addOperations(schema.$.Namespace, schema.Function, "Function" /* OperationTypes.Function */);
|
|
25
|
+
this.addOperations(schema.$.Namespace, schema.Action, "Action" /* OperationTypes.Action */);
|
|
26
26
|
}
|
|
27
27
|
digestEntityContainer(schema) {
|
|
28
28
|
var _a, _b, _c, _d;
|
|
@@ -149,13 +149,13 @@ class DigesterV4 extends DataModelDigestion_1.Digester {
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
addOperations(operations, type) {
|
|
152
|
+
addOperations(namespace, operations, type) {
|
|
153
153
|
if (!operations || !operations.length) {
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
operations.forEach((op) => {
|
|
157
157
|
var _a, _b, _c;
|
|
158
|
-
const params = (_b = (_a = op.Parameter) === null || _a === void 0 ? void 0 : _a.map(this.mapProp)) !== null && _b !== void 0 ? _b : [];
|
|
158
|
+
const params = (_b = (_a = op.Parameter) === null || _a === void 0 ? void 0 : _a.map((p) => this.mapProp(p))) !== null && _b !== void 0 ? _b : [];
|
|
159
159
|
const returnType = (_c = op.ReturnType) === null || _c === void 0 ? void 0 : _c.map((rt) => {
|
|
160
160
|
return this.mapProp(Object.assign(Object.assign({}, rt), { $: Object.assign({ Name: "NO_NAME_BECAUSE_RETURN_TYPE" }, rt.$) }));
|
|
161
161
|
})[0];
|
|
@@ -176,7 +176,7 @@ class DigesterV4 extends DataModelDigestion_1.Digester {
|
|
|
176
176
|
? this.namingHelper.getQFunctionName(op.$.Name, bindingProp)
|
|
177
177
|
: this.namingHelper.getQActionName(op.$.Name, bindingProp);
|
|
178
178
|
this.dataModel.addOperationType(binding, {
|
|
179
|
-
odataName: op.$.Name,
|
|
179
|
+
odataName: isBound ? `${namespace}.${op.$.Name}` : op.$.Name,
|
|
180
180
|
name,
|
|
181
181
|
qName,
|
|
182
182
|
paramsModelName: this.namingHelper.getOperationParamsModelName(op.$.Name, bindingProp),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataModelDigestionV4.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestionV4.ts"],"names":[],"mappings":";;;;AAAA,mEAAoF;AACpF,qDAAmE;AAGnE,6DAA2D;AAC3D,mDAA6F;AAKtF,MAAM,MAAM,GAA+B,CAAO,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;IACzF,MAAM,UAAU,GAAG,MAAM,IAAA,kCAAc,EAAC,0BAAa,CAAC,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9E,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IAC5E,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;AAC3B,CAAC,CAAA,CAAC;AALW,QAAA,MAAM,UAKjB;AAEF,MAAM,UAAW,SAAQ,6BAA+C;IACtE,YACE,OAAwB,EACxB,OAAyB,EACzB,YAA0B,EAC1B,UAAkC;QAElC,KAAK,CAAC,4BAAY,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC;IAES,kBAAkB,CAAC,UAAsC;QACjE,OAAQ,UAA2B,CAAC,kBAAkB,IAAI,EAAE,CAAC;IAC/D,CAAC;IAES,gBAAgB,CAAC,MAAgB;QACzC,sBAAsB;QACtB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,2CAA0B,CAAC;QAC7D,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,uCAAwB,CAAC;IAC3D,CAAC;IAES,qBAAqB,CAAC,MAAgB;;QAC9C,IAAI,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE;YAC3D,MAAM,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CA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AAM;gBAClB,UAAU,EAAE,UAAU;aACvB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,oBAAoB,CAAC,IAAY;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QACpF,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,GAAG,CAAC,CAAC;SACrE;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { MappedConverterChains, loadConverters } from \"@odata2ts/converter-runtime\";\r\nimport { ODataTypesV4, ODataVersions } from \"@odata2ts/odata-core\";\r\n\r\nimport { DigesterFunction, DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { Digester, TypeModel } from \"./DataModelDigestion\";\r\nimport { ODataVersion, OperationType, OperationTypes, PropertyModel } from \"./DataTypeModel\";\r\nimport { ComplexType, Property } from \"./edmx/ODataEdmxModelBase\";\r\nimport { ComplexTypeV4, EntityTypeV4, Operation, SchemaV4 } from \"./edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\n\r\nexport const digest: DigesterFunction<SchemaV4> = async (schemas, options, namingHelper) => {\r\n const converters = await loadConverters(ODataVersions.V2, options.converters);\r\n\r\n const digester = new DigesterV4(schemas, options, namingHelper, converters);\r\n return digester.digest();\r\n};\r\n\r\nclass DigesterV4 extends Digester<SchemaV4, EntityTypeV4, ComplexTypeV4> {\r\n constructor(\r\n schemas: Array<SchemaV4>,\r\n options: DigestionOptions,\r\n namingHelper: NamingHelper,\r\n converters?: MappedConverterChains\r\n ) {\r\n super(ODataVersion.V4, schemas, options, namingHelper, converters);\r\n }\r\n\r\n protected getNavigationProps(entityType: ComplexType | EntityTypeV4): Array<Property> {\r\n return (entityType as EntityTypeV4).NavigationProperty || [];\r\n }\r\n\r\n protected digestOperations(schema: SchemaV4) {\r\n // functions & actions\r\n this.addOperations(schema.Function, OperationTypes.Function);\r\n this.addOperations(schema.Action, OperationTypes.Action);\r\n }\r\n\r\n protected digestEntityContainer(schema: SchemaV4) {\r\n if (schema.EntityContainer && schema.EntityContainer.length) {\r\n const container = schema.EntityContainer[0];\r\n\r\n container.ActionImport?.forEach((actionImport) => {\r\n const name = this.namingHelper.getActionName(actionImport.$.Name);\r\n const operationName = this.namingHelper.getActionName(actionImport.$.Action);\r\n\r\n this.dataModel.addAction(name, {\r\n name: name,\r\n odataName: actionImport.$.Name,\r\n operation: this.getRootOperationType(operationName),\r\n });\r\n });\r\n\r\n container.FunctionImport?.forEach((funcImport) => {\r\n const name = this.namingHelper.getFunctionName(funcImport.$.Name);\r\n const operationName = this.namingHelper.getFunctionName(funcImport.$.Function);\r\n\r\n this.dataModel.addFunction(name, {\r\n name,\r\n odataName: funcImport.$.Name,\r\n operation: this.getRootOperationType(operationName),\r\n entitySet: funcImport.$.EntitySet,\r\n });\r\n });\r\n\r\n container.Singleton?.forEach((singleton) => {\r\n const name = singleton.$.Name;\r\n const navPropBindings = singleton.NavigationPropertyBinding || [];\r\n\r\n this.dataModel.addSingleton(name, {\r\n name,\r\n odataName: singleton.$.Name,\r\n entityType: this.dataModel.getModel(this.namingHelper.getModelName(singleton.$.Type)),\r\n navPropBinding: navPropBindings.map((binding) => ({\r\n path: this.namingHelper.stripServicePrefix(binding.$.Path),\r\n target: binding.$.Target,\r\n })),\r\n });\r\n });\r\n\r\n container.EntitySet?.forEach((entitySet) => {\r\n const name = entitySet.$.Name;\r\n const navPropBindings = entitySet.NavigationPropertyBinding || [];\r\n\r\n this.dataModel.addEntitySet(name, {\r\n name,\r\n odataName: entitySet.$.Name,\r\n entityType: this.dataModel.getModel(this.namingHelper.getModelName(entitySet.$.EntityType)),\r\n navPropBinding: navPropBindings.map((binding) => ({\r\n path: this.namingHelper.stripServicePrefix(binding.$.Path),\r\n target: binding.$.Target,\r\n })),\r\n });\r\n });\r\n }\r\n }\r\n\r\n protected mapODataType(type: string): TypeModel {\r\n switch (type) {\r\n case ODataTypesV4.Boolean:\r\n return {\r\n outputType: \"boolean\",\r\n qPath: \"QBooleanPath\",\r\n qCollection: \"QBooleanCollection\",\r\n qParam: \"QBooleanParam\",\r\n };\r\n case ODataTypesV4.Byte:\r\n case ODataTypesV4.SByte:\r\n case ODataTypesV4.Int16:\r\n case ODataTypesV4.Int32:\r\n case ODataTypesV4.Int64:\r\n case ODataTypesV4.Single:\r\n case ODataTypesV4.Double:\r\n case ODataTypesV4.Decimal:\r\n return {\r\n outputType: \"number\",\r\n qPath: \"QNumberPath\",\r\n qCollection: \"QNumberCollection\",\r\n qParam: \"QNumberParam\",\r\n };\r\n case ODataTypesV4.String:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringPath\",\r\n qCollection: \"QStringCollection\",\r\n qParam: \"QStringParam\",\r\n };\r\n case ODataTypesV4.Date:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QDatePath\",\r\n qCollection: \"QDateCollection\",\r\n qParam: \"QDateParam\",\r\n };\r\n case ODataTypesV4.TimeOfDay:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QTimeOfDayPath\",\r\n qCollection: \"QTimeOfDayCollection\",\r\n qParam: \"QTimeOfDayParam\",\r\n };\r\n case ODataTypesV4.DateTimeOffset:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QDateTimeOffsetPath\",\r\n qCollection: \"QDateTimeOffsetCollection\",\r\n qParam: \"QDateTimeOffsetParam\",\r\n };\r\n case ODataTypesV4.Binary:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QBinaryPath\",\r\n qCollection: \"QBinaryCollection\",\r\n qParam: undefined,\r\n };\r\n case ODataTypesV4.Guid:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QGuidPath\",\r\n qCollection: \"QGuidCollection\",\r\n qParam: \"QGuidParam\",\r\n };\r\n default:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringPath\",\r\n qCollection: \"QStringCollection\",\r\n qParam: undefined,\r\n };\r\n }\r\n }\r\n\r\n private addOperations(operations: Array<Operation> | undefined, type: OperationTypes) {\r\n if (!operations || !operations.length) {\r\n return;\r\n }\r\n\r\n operations.forEach((op) => {\r\n const params: Array<PropertyModel> = op.Parameter?.map(this.mapProp) ?? [];\r\n const returnType: PropertyModel | undefined = op.ReturnType?.map((rt) => {\r\n return this.mapProp({ ...rt, $: { Name: \"NO_NAME_BECAUSE_RETURN_TYPE\", ...rt.$ } });\r\n })[0];\r\n const isBound = op.$.IsBound === \"true\";\r\n\r\n if (isBound && !params.length) {\r\n throw new Error(`IllegalState: Operation '${op.$.Name}' is bound, but has no parameters!`);\r\n }\r\n\r\n const bindingProp = isBound ? params.shift() : undefined;\r\n const binding = bindingProp\r\n ? bindingProp.isCollection\r\n ? `Collection(${bindingProp.type})`\r\n : bindingProp.type\r\n : DigesterV4.ROOT_OPERATION;\r\n\r\n const name =\r\n type === OperationTypes.Function\r\n ? this.namingHelper.getFunctionName(op.$.Name)\r\n : this.namingHelper.getActionName(op.$.Name);\r\n const qName =\r\n type === OperationTypes.Function\r\n ? this.namingHelper.getQFunctionName(op.$.Name, bindingProp)\r\n : this.namingHelper.getQActionName(op.$.Name, bindingProp);\r\n this.dataModel.addOperationType(binding, {\r\n odataName: op.$.Name,\r\n name,\r\n qName,\r\n paramsModelName: this.namingHelper.getOperationParamsModelName(op.$.Name, bindingProp),\r\n type: type,\r\n parameters: params,\r\n returnType: returnType,\r\n });\r\n });\r\n }\r\n\r\n private getRootOperationType(name: string): OperationType {\r\n const rootOps = this.dataModel.getOperationTypeByBinding(DigesterV4.ROOT_OPERATION);\r\n const rootOp = rootOps.find((op) => op.name === name);\r\n if (!rootOp) {\r\n throw new Error(`Couldn't find root operation with name [${name}]`);\r\n }\r\n return rootOp;\r\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AAC,IAAI;gBAC5D,IAAI;gBACJ,KAAK;gBACL,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,2BAA2B,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC;gBACtF,IAAI,EAAE,IAAI;gBACV,UAAU,EAAE,MAAM;gBAClB,UAAU,EAAE,UAAU;aACvB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,oBAAoB,CAAC,IAAY;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QACpF,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,GAAG,CAAC,CAAC;SACrE;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { MappedConverterChains, loadConverters } from \"@odata2ts/converter-runtime\";\r\nimport { ODataTypesV4, ODataVersions } from \"@odata2ts/odata-core\";\r\n\r\nimport { DigesterFunction, DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { Digester, TypeModel } from \"./DataModelDigestion\";\r\nimport { ODataVersion, OperationType, OperationTypes, PropertyModel } from \"./DataTypeModel\";\r\nimport { ComplexType, Property } from \"./edmx/ODataEdmxModelBase\";\r\nimport { ComplexTypeV4, EntityTypeV4, Operation, SchemaV4 } from \"./edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\n\r\nexport const digest: DigesterFunction<SchemaV4> = async (schemas, options, namingHelper) => {\r\n const converters = await loadConverters(ODataVersions.V2, options.converters);\r\n\r\n const digester = new DigesterV4(schemas, options, namingHelper, converters);\r\n return digester.digest();\r\n};\r\n\r\nclass DigesterV4 extends Digester<SchemaV4, EntityTypeV4, ComplexTypeV4> {\r\n constructor(\r\n schemas: Array<SchemaV4>,\r\n options: DigestionOptions,\r\n namingHelper: NamingHelper,\r\n converters?: MappedConverterChains\r\n ) {\r\n super(ODataVersion.V4, schemas, options, namingHelper, converters);\r\n }\r\n\r\n protected getNavigationProps(entityType: ComplexType | EntityTypeV4): Array<Property> {\r\n return (entityType as EntityTypeV4).NavigationProperty || [];\r\n }\r\n\r\n protected digestOperations(schema: SchemaV4) {\r\n // functions & actions\r\n this.addOperations(schema.$.Namespace, schema.Function, OperationTypes.Function);\r\n this.addOperations(schema.$.Namespace, schema.Action, OperationTypes.Action);\r\n }\r\n\r\n protected digestEntityContainer(schema: SchemaV4) {\r\n if (schema.EntityContainer && schema.EntityContainer.length) {\r\n const container = schema.EntityContainer[0];\r\n\r\n container.ActionImport?.forEach((actionImport) => {\r\n const name = this.namingHelper.getActionName(actionImport.$.Name);\r\n const operationName = this.namingHelper.getActionName(actionImport.$.Action);\r\n\r\n this.dataModel.addAction(name, {\r\n name: name,\r\n odataName: actionImport.$.Name,\r\n operation: this.getRootOperationType(operationName),\r\n });\r\n });\r\n\r\n container.FunctionImport?.forEach((funcImport) => {\r\n const name = this.namingHelper.getFunctionName(funcImport.$.Name);\r\n const operationName = this.namingHelper.getFunctionName(funcImport.$.Function);\r\n\r\n this.dataModel.addFunction(name, {\r\n name,\r\n odataName: funcImport.$.Name,\r\n operation: this.getRootOperationType(operationName),\r\n entitySet: funcImport.$.EntitySet,\r\n });\r\n });\r\n\r\n container.Singleton?.forEach((singleton) => {\r\n const name = singleton.$.Name;\r\n const navPropBindings = singleton.NavigationPropertyBinding || [];\r\n\r\n this.dataModel.addSingleton(name, {\r\n name,\r\n odataName: singleton.$.Name,\r\n entityType: this.dataModel.getModel(this.namingHelper.getModelName(singleton.$.Type)),\r\n navPropBinding: navPropBindings.map((binding) => ({\r\n path: this.namingHelper.stripServicePrefix(binding.$.Path),\r\n target: binding.$.Target,\r\n })),\r\n });\r\n });\r\n\r\n container.EntitySet?.forEach((entitySet) => {\r\n const name = entitySet.$.Name;\r\n const navPropBindings = entitySet.NavigationPropertyBinding || [];\r\n\r\n this.dataModel.addEntitySet(name, {\r\n name,\r\n odataName: entitySet.$.Name,\r\n entityType: this.dataModel.getModel(this.namingHelper.getModelName(entitySet.$.EntityType)),\r\n navPropBinding: navPropBindings.map((binding) => ({\r\n path: this.namingHelper.stripServicePrefix(binding.$.Path),\r\n target: binding.$.Target,\r\n })),\r\n });\r\n });\r\n }\r\n }\r\n\r\n protected mapODataType(type: string): TypeModel {\r\n switch (type) {\r\n case ODataTypesV4.Boolean:\r\n return {\r\n outputType: \"boolean\",\r\n qPath: \"QBooleanPath\",\r\n qCollection: \"QBooleanCollection\",\r\n qParam: \"QBooleanParam\",\r\n };\r\n case ODataTypesV4.Byte:\r\n case ODataTypesV4.SByte:\r\n case ODataTypesV4.Int16:\r\n case ODataTypesV4.Int32:\r\n case ODataTypesV4.Int64:\r\n case ODataTypesV4.Single:\r\n case ODataTypesV4.Double:\r\n case ODataTypesV4.Decimal:\r\n return {\r\n outputType: \"number\",\r\n qPath: \"QNumberPath\",\r\n qCollection: \"QNumberCollection\",\r\n qParam: \"QNumberParam\",\r\n };\r\n case ODataTypesV4.String:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringPath\",\r\n qCollection: \"QStringCollection\",\r\n qParam: \"QStringParam\",\r\n };\r\n case ODataTypesV4.Date:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QDatePath\",\r\n qCollection: \"QDateCollection\",\r\n qParam: \"QDateParam\",\r\n };\r\n case ODataTypesV4.TimeOfDay:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QTimeOfDayPath\",\r\n qCollection: \"QTimeOfDayCollection\",\r\n qParam: \"QTimeOfDayParam\",\r\n };\r\n case ODataTypesV4.DateTimeOffset:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QDateTimeOffsetPath\",\r\n qCollection: \"QDateTimeOffsetCollection\",\r\n qParam: \"QDateTimeOffsetParam\",\r\n };\r\n case ODataTypesV4.Binary:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QBinaryPath\",\r\n qCollection: \"QBinaryCollection\",\r\n qParam: undefined,\r\n };\r\n case ODataTypesV4.Guid:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QGuidPath\",\r\n qCollection: \"QGuidCollection\",\r\n qParam: \"QGuidParam\",\r\n };\r\n default:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringPath\",\r\n qCollection: \"QStringCollection\",\r\n qParam: undefined,\r\n };\r\n }\r\n }\r\n\r\n private addOperations(namespace: string, operations: Array<Operation> | undefined, type: OperationTypes) {\r\n if (!operations || !operations.length) {\r\n return;\r\n }\r\n\r\n operations.forEach((op) => {\r\n const params: Array<PropertyModel> = op.Parameter?.map((p) => this.mapProp(p)) ?? [];\r\n const returnType: PropertyModel | undefined = op.ReturnType?.map((rt) => {\r\n return this.mapProp({ ...rt, $: { Name: \"NO_NAME_BECAUSE_RETURN_TYPE\", ...rt.$ } });\r\n })[0];\r\n const isBound = op.$.IsBound === \"true\";\r\n\r\n if (isBound && !params.length) {\r\n throw new Error(`IllegalState: Operation '${op.$.Name}' is bound, but has no parameters!`);\r\n }\r\n\r\n const bindingProp = isBound ? params.shift() : undefined;\r\n const binding = bindingProp\r\n ? bindingProp.isCollection\r\n ? `Collection(${bindingProp.type})`\r\n : bindingProp.type\r\n : DigesterV4.ROOT_OPERATION;\r\n\r\n const name =\r\n type === OperationTypes.Function\r\n ? this.namingHelper.getFunctionName(op.$.Name)\r\n : this.namingHelper.getActionName(op.$.Name);\r\n const qName =\r\n type === OperationTypes.Function\r\n ? this.namingHelper.getQFunctionName(op.$.Name, bindingProp)\r\n : this.namingHelper.getQActionName(op.$.Name, bindingProp);\r\n this.dataModel.addOperationType(binding, {\r\n odataName: isBound ? `${namespace}.${op.$.Name}` : op.$.Name,\r\n name,\r\n qName,\r\n paramsModelName: this.namingHelper.getOperationParamsModelName(op.$.Name, bindingProp),\r\n type: type,\r\n parameters: params,\r\n returnType: returnType,\r\n });\r\n });\r\n }\r\n\r\n private getRootOperationType(name: string): OperationType {\r\n const rootOps = this.dataModel.getOperationTypeByBinding(DigesterV4.ROOT_OPERATION);\r\n const rootOp = rootOps.find((op) => op.name === name);\r\n if (!rootOp) {\r\n throw new Error(`Couldn't find root operation with name [${name}]`);\r\n }\r\n return rootOp;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odata2ts/odata2ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -86,6 +86,6 @@
|
|
|
86
86
|
"typescript": "^5.1.3"
|
|
87
87
|
},
|
|
88
88
|
"types": "./lib/index.d.ts",
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "bf7321302887f9c70c2933467fd11859360aac6d",
|
|
90
90
|
"readme": "README.md"
|
|
91
91
|
}
|