@odata2ts/odata2ts 0.20.2 → 0.21.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 +14 -0
- package/lib/FactoryFunctionModel.d.ts +2 -2
- package/lib/FactoryFunctionModel.js.map +1 -1
- package/lib/OptionModel.d.ts +14 -0
- package/lib/OptionModel.js.map +1 -1
- package/lib/app.js.map +1 -1
- package/lib/data-model/DataModel.d.ts +18 -2
- package/lib/data-model/DataModel.js +18 -2
- package/lib/data-model/DataModel.js.map +1 -1
- package/lib/data-model/DataModelDigestion.d.ts +1 -0
- package/lib/data-model/DataModelDigestion.js +46 -7
- package/lib/data-model/DataModelDigestion.js.map +1 -1
- package/lib/data-model/edmx/ODataEdmxModelBase.js.map +1 -1
- package/lib/defaultConfig.js +1 -0
- package/lib/defaultConfig.js.map +1 -1
- package/lib/evaluateConfig.js +9 -4
- package/lib/evaluateConfig.js.map +1 -1
- package/lib/generator/ModelGenerator.js +7 -1
- package/lib/generator/ModelGenerator.js.map +1 -1
- package/lib/generator/QueryObjectGenerator.js +2 -0
- package/lib/generator/QueryObjectGenerator.js.map +1 -1
- package/lib/generator/ServiceGenerator.js.map +1 -1
- package/package.json +18 -19
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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.21.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.20.3...@odata2ts/odata2ts@0.21.0) (2023-04-20)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* option for extra-results-wrapping for V2 services and model generation only ([#155](https://github.com/odata2ts/odata2ts/issues/155)) ([795a04c](https://github.com/odata2ts/odata2ts/commit/795a04c42b9e2485975b85b70bc72772bd4bf25a))
|
|
11
|
+
|
|
12
|
+
## [0.20.3](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.20.2...@odata2ts/odata2ts@0.20.3) (2023-04-18)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **odata2ts:** add empty array as type for empty params ([#154](https://github.com/odata2ts/odata2ts/issues/154)) ([fbdd000](https://github.com/odata2ts/odata2ts/commit/fbdd0005d46d7d402d8039bec3ea4aecdb593b88))
|
|
17
|
+
* prevent idModel and qIdFunction from baseclass to be overwritten in digester which breaks multiple inheritance ([#150](https://github.com/odata2ts/odata2ts/issues/150)) ([e17038e](https://github.com/odata2ts/odata2ts/commit/e17038ee0e924101f9dd6ed97e10da5847cb8857))
|
|
18
|
+
* Reorder models and qobjects by inheritance (base types first) ([#151](https://github.com/odata2ts/odata2ts/issues/151)) ([7d456fe](https://github.com/odata2ts/odata2ts/commit/7d456fe3fd28b246721a170cd878d04c3dbc2d80))
|
|
19
|
+
|
|
6
20
|
## [0.20.2](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.20.1...@odata2ts/odata2ts@0.20.2) (2023-04-13)
|
|
7
21
|
|
|
8
22
|
**Note:** Version bump only for package @odata2ts/odata2ts
|
|
@@ -4,10 +4,10 @@ import { DataModel } from "./data-model/DataModel";
|
|
|
4
4
|
import { Schema } from "./data-model/edmx/ODataEdmxModelBase";
|
|
5
5
|
import { NamingHelper } from "./data-model/NamingHelper";
|
|
6
6
|
import { RunOptions } from "./OptionModel";
|
|
7
|
-
export type DigestionOptions = Pick<RunOptions, "converters" | "disableAutoManagedKey" | "propertiesByName" | "entitiesByName">;
|
|
7
|
+
export type DigestionOptions = Pick<RunOptions, "converters" | "disableAutoManagedKey" | "propertiesByName" | "entitiesByName" | "v2ModelsWithExtraResultsWrapping" | "skipEditableModels">;
|
|
8
8
|
/**
|
|
9
9
|
* Takes an EdmxSchema plus the run options and creates a DataModel.
|
|
10
10
|
*/
|
|
11
11
|
export type DigesterFunction<S extends Schema<any, any>> = (schema: S, options: DigestionOptions, namingHelper: NamingHelper) => Promise<DataModel>;
|
|
12
|
-
export type GeneratorFunctionOptions = Pick<RunOptions, "skipEditableModels" | "skipIdModels" | "skipOperations">;
|
|
12
|
+
export type GeneratorFunctionOptions = Pick<RunOptions, "skipEditableModels" | "skipIdModels" | "skipOperations" | "v2ModelsWithExtraResultsWrapping">;
|
|
13
13
|
export type EntityBasedGeneratorFunction = (dataModel: DataModel, sourceFile: SourceFile, version: ODataVersions, options: GeneratorFunctionOptions, namingHelper: NamingHelper) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FactoryFunctionModel.js","sourceRoot":"","sources":["../src/FactoryFunctionModel.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { SourceFile } from \"ts-morph\";\r\n\r\nimport { DataModel } from \"./data-model/DataModel\";\r\nimport { Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper\";\r\nimport { RunOptions } from \"./OptionModel\";\r\n\r\nexport type DigestionOptions = Pick<\r\n RunOptions,\r\n \"converters\"
|
|
1
|
+
{"version":3,"file":"FactoryFunctionModel.js","sourceRoot":"","sources":["../src/FactoryFunctionModel.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { SourceFile } from \"ts-morph\";\r\n\r\nimport { DataModel } from \"./data-model/DataModel\";\r\nimport { Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\r\nimport { NamingHelper } from \"./data-model/NamingHelper\";\r\nimport { RunOptions } from \"./OptionModel\";\r\n\r\nexport type DigestionOptions = Pick<\r\n RunOptions,\r\n | \"converters\"\r\n | \"disableAutoManagedKey\"\r\n | \"propertiesByName\"\r\n | \"entitiesByName\"\r\n | \"v2ModelsWithExtraResultsWrapping\"\r\n | \"skipEditableModels\"\r\n>;\r\n\r\n/**\r\n * Takes an EdmxSchema plus the run options and creates a DataModel.\r\n */\r\nexport type DigesterFunction<S extends Schema<any, any>> = (\r\n schema: S,\r\n options: DigestionOptions,\r\n namingHelper: NamingHelper\r\n) => Promise<DataModel>;\r\n\r\nexport type GeneratorFunctionOptions = Pick<\r\n RunOptions,\r\n \"skipEditableModels\" | \"skipIdModels\" | \"skipOperations\" | \"v2ModelsWithExtraResultsWrapping\"\r\n>;\r\n\r\nexport type EntityBasedGeneratorFunction = (\r\n dataModel: DataModel,\r\n sourceFile: SourceFile,\r\n version: ODataVersions,\r\n options: GeneratorFunctionOptions,\r\n namingHelper: NamingHelper\r\n) => void;\r\n"]}
|
package/lib/OptionModel.d.ts
CHANGED
|
@@ -152,6 +152,20 @@ export interface ConfigFileOptions extends Omit<CliOptions, "source" | "output"
|
|
|
152
152
|
* The naming options regarding the generated artefacts.
|
|
153
153
|
*/
|
|
154
154
|
naming?: OverridableNamingOptions;
|
|
155
|
+
/**
|
|
156
|
+
* Some OData V2 services generate an extra wrapping for entity collection attributes:
|
|
157
|
+
* <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities
|
|
158
|
+
* an object with the property "results" is wrapped around the entity collection.
|
|
159
|
+
*
|
|
160
|
+
* If you're using the odata client then there's a build-in workaround in place which transforms
|
|
161
|
+
* the results to remove this extra mapping. However, if you're only interested in the types, then
|
|
162
|
+
* the generated models will not match that extra wrapping.
|
|
163
|
+
*
|
|
164
|
+
* Setting this configuration option to <code>true</code> (default: false) will add this extra
|
|
165
|
+
* wrapping to the generated models. But this option is only valid if the generation mode is set
|
|
166
|
+
* to <code>models</code>; it is ignored otherwise.
|
|
167
|
+
*/
|
|
168
|
+
v2ModelsWithExtraResultsWrapping?: boolean;
|
|
155
169
|
}
|
|
156
170
|
/**
|
|
157
171
|
* Custom generation options which are dependent on a specific odata service.
|
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,GAAL,aAAK,KAAL,aAAK,QAKhB;AAED;;GAEG;AACH,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { NameSettings, OverridableNamingOptions } from \"./NamingModel\";\r\n\r\n/**\r\n * Generation mode, by default \"all\".\r\n */\r\nexport enum Modes {\r\n models,\r\n qobjects,\r\n service,\r\n all,\r\n}\r\n\r\n/**\r\n * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.\r\n */\r\nexport enum EmitModes {\r\n ts = \"ts\",\r\n js = \"js\",\r\n dts = \"dts\",\r\n js_dts = \"js_dts\",\r\n}\r\n\r\n/**\r\n * Config options for CLI.\r\n */\r\nexport interface CliOptions {\r\n /**\r\n * The source file to use. Must be an EDMX compliant XML file.\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n source?: string;\r\n /**\r\n * Specifies the output directory for the generated stuff.\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n output?: string;\r\n /**\r\n * Only generates the specified services.\r\n * Relies on an existing config file where these service names are maintained.\r\n */\r\n services?: Array<string>;\r\n /**\r\n * Specifies what to generate:\r\n * - {@code Modes.models} will only generate TS interfaces\r\n * - {@code Modes.qobjects} will generate functional units used in QueryBuilder and for functions and actions\r\n * - {@code Modes.service} will generate one main OData service client and one per each entity\r\n * - {@code Modes.all} the same as {@code Modes.service}\r\n *\r\n * QObjects will also generate models, and generating the service client will also generate models and QObjects.\r\n * Defaults to {@code Modes.all}\r\n */\r\n mode?: Modes;\r\n /**\r\n * Specifies the type of the output files: TypeScript, JS, DTS only, JS with DTS.\r\n * Defaults to {@code EmitModes.js_dts}\r\n */\r\n emitMode?: EmitModes;\r\n /**\r\n * Uses prettier with your local configuration to pretty print TypeScript files.\r\n * Only applies if mode is set to {@code EmitModes.ts}.\r\n */\r\n prettier?: boolean;\r\n /**\r\n * When compiling TypeScript to JS, \"tsconfig.json\" is used by default to add compilerOptions.\r\n * This option allows to specify an alternative file.\r\n *\r\n * Only takes effect, when mode is set to anything else than {@code EmitModes.ts}.\r\n */\r\n tsconfig?: string;\r\n /**\r\n * Verbose debugging information.\r\n */\r\n debug?: boolean;\r\n /**\r\n * Overrides the service name found in the source file.\r\n *\r\n * The service name is the basis for all file names and the name of the main OData client service\r\n * that serves as entry point for the user.\r\n */\r\n serviceName?: string;\r\n /**\r\n * odata2ts will automatically decide if a key prop is managed on the server side.\r\n * If managed, the property will not be editable (create, update, patch).\r\n * The following rule applies:\r\n * If a property is the only key prop of an entity, then the prop is deemed to be managed;\r\n * in ony other case the prop is unmanaged.\r\n */\r\n disableAutoManagedKey?: boolean;\r\n /**\r\n * By default, odata2ts doesn't change param, operation, property or model names.\r\n * The generated models and their properties are named exactly as advertised by the server.\r\n *\r\n * By allowing odata2ts to change these names, certain predefined formatting strategies are used:\r\n * Model / class names are formatted with PascalCase; property, param, and operation names with camelCase.\r\n *\r\n * The naming configuration allows to control this and other naming related settings.\r\n * Note: Even if renaming is disabled, model prefixing / suffing still applies.\r\n */\r\n allowRenaming?: boolean;\r\n}\r\n\r\n/**\r\n * Available options for the actual generation run.\r\n * Every property is required, except the overriding service name.\r\n */\r\nexport interface RunOptions extends Required<Omit<ServiceGenerationOptions, \"serviceName\">> {\r\n serviceName?: string;\r\n naming: NameSettings;\r\n}\r\n\r\n/**\r\n * Available options for configuration files, i.e. odata2ts.config.ts.\r\n */\r\nexport interface ConfigFileOptions extends Omit<CliOptions, \"source\" | \"output\" | \"services\"> {\r\n services?: { [serviceName: string]: ServiceGenerationOptions };\r\n\r\n /**\r\n * Specify which converters to use by their package name, e.g. \"@odata2ts/converter-v2-to-v4\".\r\n * Each converter knows which data type to map.\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n converters?: Array<string | TypeConverterConfig>;\r\n\r\n /**\r\n * For each model an editable version is generated which represents the model definition for\r\n * create, update and patch actions.\r\n *\r\n * You can skip the generation altogether, not generating editable model variants,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipEditableModels?: boolean;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n * The generation for one entity entails one model interface representing the id parameters and\r\n * one QId function which allows to format the parameters for URL usage and to parse parameters\r\n * from a URL string.\r\n *\r\n * You can skip the generation altogether, not generating models and QId objects, if the\r\n * generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipIdModels?: boolean;\r\n /**\r\n * Operations are functions and actions of the OData service.\r\n * The generation for one operation entails one parameter model interface\r\n * and one QFunction / QAction class.\r\n *\r\n * You can skip the generation altogether, neither generating model nor query object,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipOperations?: boolean;\r\n\r\n /**\r\n * The naming options regarding the generated artefacts.\r\n */\r\n naming?: OverridableNamingOptions;\r\n}\r\n\r\n/**\r\n * Custom generation options which are dependent on a specific odata service.\r\n */\r\nexport interface ServiceGenerationOptions\r\n extends Required<Pick<CliOptions, \"source\" | \"output\">>,\r\n Omit<ConfigFileOptions, \"services\"> {\r\n /**\r\n * Configure generation process for EntityTypes and ComplexTypes including their keys and properties.\r\n */\r\n entitiesByName?: Array<EntityGenerationOptions>;\r\n /**\r\n * Configure generation process for individual properties based on their name.\r\n */\r\n propertiesByName?: Array<PropertyGenerationOptions>;\r\n}\r\n\r\n/**\r\n * Configuration options for EntityTypes and ComplexTypes.\r\n * This config applies if the name matches the name of an EntityType or ComplexType as it is specified\r\n * in the metadata (e.g. in EDMX <EntityType name=\"Test\" ...)\r\n */\r\nexport interface EntityGenerationOptions {\r\n /**\r\n * Name of the EntityType or ComplexType, e.g. \"Person\".\r\n * Must match exactly or can be a regular expression.\r\n */\r\n name: string | RegExp;\r\n /**\r\n * Use a different name.\r\n * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).\r\n */\r\n mappedName?: string;\r\n /**\r\n * Overwrite the key specification by naming the props by their EDMX name.\r\n */\r\n keys?: Array<string>;\r\n /**\r\n * Configuration of individual properties.\r\n */\r\n // properties?: Array<PropertyGenerationOptions>;\r\n\r\n // converter: string | Array<string>\r\n\r\n /**\r\n * Whether the generated service should allow for querying this model.\r\n * True by default.\r\n */\r\n // queryable?: boolean;\r\n /**\r\n * Whether the generated service should allow for creating new models (POST).\r\n * True by default.\r\n */\r\n // creatable?: boolean;\r\n /**\r\n * Whether the generated service should allow for updates (PUT).\r\n * True by default.\r\n */\r\n // updatable?: boolean;\r\n /**\r\n * Whether the generated service should allow for partial updates (PATCH).\r\n * True by default.\r\n */\r\n // patchable?: boolean;\r\n /**\r\n * Whether the generated service should allow for deletion.\r\n * True by default.\r\n */\r\n // deletable?: boolean;\r\n}\r\n\r\n/**\r\n * All configuration options for properties of models.\r\n */\r\nexport interface PropertyGenerationOptions {\r\n /**\r\n * Name of the property to match.\r\n * Must match exactly or can be a regular expression.\r\n */\r\n name: string | RegExp;\r\n /**\r\n * Use a different name.\r\n * If name is a regular expression, mappedName allows to specify captured groups (via $1, $2, ...).\r\n */\r\n mappedName?: string;\r\n /**\r\n * Managed attributes - i.e. managed by the server - cannot be created or updated.\r\n * Hence, they are left out of the editable model versions.\r\n */\r\n managed?: boolean;\r\n\r\n /**\r\n * TODO\r\n *\r\n * Each converter must specify its package name, e.g. \"@odata2ts/converter-v2-to-v4\",\r\n * as well it's i\r\n * and their ids, e.g. \"timeToDurationConverter\".\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n // converters?: Array<Required<TypeConverterConfig>>;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"OptionModel.js","sourceRoot":"","sources":["../src/OptionModel.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,IAAY,KAKX;AALD,WAAY,KAAK;IACf,qCAAM,CAAA;IACN,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,+BAAG,CAAA;AACL,CAAC,EALW,KAAK,GAAL,aAAK,KAAL,aAAK,QAKhB;AAED;;GAEG;AACH,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { NameSettings, OverridableNamingOptions } from \"./NamingModel\";\r\n\r\n/**\r\n * Generation mode, by default \"all\".\r\n */\r\nexport enum Modes {\r\n models,\r\n qobjects,\r\n service,\r\n all,\r\n}\r\n\r\n/**\r\n * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.\r\n */\r\nexport enum EmitModes {\r\n ts = \"ts\",\r\n js = \"js\",\r\n dts = \"dts\",\r\n js_dts = \"js_dts\",\r\n}\r\n\r\n/**\r\n * Config options for CLI.\r\n */\r\nexport interface CliOptions {\r\n /**\r\n * The source file to use. Must be an EDMX compliant XML file.\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n source?: string;\r\n /**\r\n * Specifies the output directory for the generated stuff.\r\n *\r\n * If not specified, at least one service must be configured in config file.\r\n */\r\n output?: string;\r\n /**\r\n * Only generates the specified services.\r\n * Relies on an existing config file where these service names are maintained.\r\n */\r\n services?: Array<string>;\r\n /**\r\n * Specifies what to generate:\r\n * - {@code Modes.models} will only generate TS interfaces\r\n * - {@code Modes.qobjects} will generate functional units used in QueryBuilder and for functions and actions\r\n * - {@code Modes.service} will generate one main OData service client and one per each entity\r\n * - {@code Modes.all} the same as {@code Modes.service}\r\n *\r\n * QObjects will also generate models, and generating the service client will also generate models and QObjects.\r\n * Defaults to {@code Modes.all}\r\n */\r\n mode?: Modes;\r\n /**\r\n * Specifies the type of the output files: TypeScript, JS, DTS only, JS with DTS.\r\n * Defaults to {@code EmitModes.js_dts}\r\n */\r\n emitMode?: EmitModes;\r\n /**\r\n * Uses prettier with your local configuration to pretty print TypeScript files.\r\n * Only applies if mode is set to {@code EmitModes.ts}.\r\n */\r\n prettier?: boolean;\r\n /**\r\n * When compiling TypeScript to JS, \"tsconfig.json\" is used by default to add compilerOptions.\r\n * This option allows to specify an alternative file.\r\n *\r\n * Only takes effect, when mode is set to anything else than {@code EmitModes.ts}.\r\n */\r\n tsconfig?: string;\r\n /**\r\n * Verbose debugging information.\r\n */\r\n debug?: boolean;\r\n /**\r\n * Overrides the service name found in the source file.\r\n *\r\n * The service name is the basis for all file names and the name of the main OData client service\r\n * that serves as entry point for the user.\r\n */\r\n serviceName?: string;\r\n /**\r\n * odata2ts will automatically decide if a key prop is managed on the server side.\r\n * If managed, the property will not be editable (create, update, patch).\r\n * The following rule applies:\r\n * If a property is the only key prop of an entity, then the prop is deemed to be managed;\r\n * in ony other case the prop is unmanaged.\r\n */\r\n disableAutoManagedKey?: boolean;\r\n /**\r\n * By default, odata2ts doesn't change param, operation, property or model names.\r\n * The generated models and their properties are named exactly as advertised by the server.\r\n *\r\n * By allowing odata2ts to change these names, certain predefined formatting strategies are used:\r\n * Model / class names are formatted with PascalCase; property, param, and operation names with camelCase.\r\n *\r\n * The naming configuration allows to control this and other naming related settings.\r\n * Note: Even if renaming is disabled, model prefixing / suffing still applies.\r\n */\r\n allowRenaming?: boolean;\r\n}\r\n\r\n/**\r\n * Available options for the actual generation run.\r\n * Every property is required, except the overriding service name.\r\n */\r\nexport interface RunOptions extends Required<Omit<ServiceGenerationOptions, \"serviceName\">> {\r\n serviceName?: string;\r\n naming: NameSettings;\r\n}\r\n\r\n/**\r\n * Available options for configuration files, i.e. odata2ts.config.ts.\r\n */\r\nexport interface ConfigFileOptions extends Omit<CliOptions, \"source\" | \"output\" | \"services\"> {\r\n services?: { [serviceName: string]: ServiceGenerationOptions };\r\n\r\n /**\r\n * Specify which converters to use by their package name, e.g. \"@odata2ts/converter-v2-to-v4\".\r\n * Each converter knows which data type to map.\r\n *\r\n * To only use specific converters, the object syntax must be used, where supported converters\r\n * must be listed by their ids.\r\n */\r\n converters?: Array<string | TypeConverterConfig>;\r\n\r\n /**\r\n * For each model an editable version is generated which represents the model definition for\r\n * create, update and patch actions.\r\n *\r\n * You can skip the generation altogether, not generating editable model variants,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipEditableModels?: boolean;\r\n\r\n /**\r\n * ID models are generated from entity id parameters.\r\n * The generation for one entity entails one model interface representing the id parameters and\r\n * one QId function which allows to format the parameters for URL usage and to parse parameters\r\n * from a URL string.\r\n *\r\n * You can skip the generation altogether, not generating models and QId objects, if the\r\n * generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipIdModels?: boolean;\r\n /**\r\n * Operations are functions and actions of the OData service.\r\n * The generation for one operation entails one parameter model interface\r\n * and one QFunction / QAction class.\r\n *\r\n * You can skip the generation altogether, neither generating model nor query object,\r\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\r\n */\r\n skipOperations?: boolean;\r\n\r\n /**\r\n * The naming options regarding the generated artefacts.\r\n */\r\n naming?: OverridableNamingOptions;\r\n\r\n /**\r\n * 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"]}
|
package/lib/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AAErD,4EAAuE;AACvE,4EAAuE;AAIvE,4DAAyD;AACzD,2CAAqF;AACrF,+CAAkD;AAClD,6DAAgE;AAEhE,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,QAAQ,EAAE,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,SAAsB,MAAM,CAAC,YAAqC,EAAE,OAAmB;;;QACrF,uCAAuC;QACvC,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACxD,MAAM,OAAO,GAAG,WA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AC;QAEF,4BAA4B;QAC5B,0DAA0D;QAC1D,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;QACnD,IAAA,0BAAc,EAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAEtE,yBAAyB;QACzB,gDAAgD;QAChD,mJAAmJ;QACnJ,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAChD,IAAA,gCAAoB,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACxE;QAED,oCAAoC;QACpC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;YAChC,MAAM,IAAA,4BAAgB,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACnE;QAED,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;;CAC5B;AAzDD,wBAyDC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AAErD,4EAAuE;AACvE,4EAAuE;AAIvE,4DAAyD;AACzD,2CAAqF;AACrF,+CAAkD;AAClD,6DAAgE;AAEhE,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,QAAQ,EAAE,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,YAAY,CAAC,IAAW;IAC/B,OAAO,CAAC,mBAAK,CAAC,OAAO,EAAE,mBAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IA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AC,CAAC;QACnE,0CAA0C;QAC1C,MAAM,OAAO,GAAG,MAAM,IAAA,qCAAoB,EACxC,YAAY,CAAC,YAAY,EAAE,EAC3B,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,QAAQ,CACjB,CAAC;QAEF,4BAA4B;QAC5B,0DAA0D;QAC1D,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;QACnD,IAAA,0BAAc,EAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAEtE,yBAAyB;QACzB,gDAAgD;QAChD,mJAAmJ;QACnJ,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAChD,IAAA,gCAAoB,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACxE;QAED,oCAAoC;QACpC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC9B,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;YAChC,MAAM,IAAA,4BAAgB,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;SACnE;QAED,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;;CAC5B;AAzDD,wBAyDC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\n\nimport { digest as digestV2 } from \"./data-model/DataModelDigestionV2\";\nimport { digest as digestV4 } from \"./data-model/DataModelDigestionV4\";\nimport { ODataEdmxModelBase, Schema } from \"./data-model/edmx/ODataEdmxModelBase\";\nimport { SchemaV3 } from \"./data-model/edmx/ODataEdmxModelV3\";\nimport { SchemaV4 } from \"./data-model/edmx/ODataEdmxModelV4\";\nimport { NamingHelper } from \"./data-model/NamingHelper\";\nimport { generateModels, generateQueryObjects, generateServices } from \"./generator\";\nimport { Modes, RunOptions } from \"./OptionModel\";\nimport { createProjectManager } from \"./project/ProjectManager\";\n\nfunction isQObjectGen(mode: Modes) {\n return [Modes.qobjects, Modes.service, Modes.all].includes(mode);\n}\n\nfunction isServiceGen(mode: Modes) {\n return [Modes.service, Modes.all].includes(mode);\n}\n\n/**\n *\n * @param metadataJson metadata of a given OData service already parsed as JSON\n * @param options further options\n */\nexport async function runApp(metadataJson: ODataEdmxModelBase<any>, options: RunOptions): Promise<void> {\n // determine edmx edmxVersion attribute\n const edmxVersion = metadataJson[\"edmx:Edmx\"].$.Version;\n const version = edmxVersion === \"1.0\" ? ODataVersions.V2 : ODataVersions.V4;\n\n const dataService = metadataJson[\"edmx:Edmx\"][\"edmx:DataServices\"][0];\n\n // handling multiple schemas => merge them\n const schemaRaw = dataService.Schema.reduce(\n (collector, schema) => ({\n ...schema,\n ...collector,\n }),\n {} as Schema<any, any>\n );\n const detectedServiceName =\n dataService.Schema.length === 1\n ? dataService.Schema[0].$.Namespace\n : dataService.Schema.find((schema) => !schema.EntityContainer)?.$.Namespace;\n\n // encapsulate the whole naming logic\n const namingHelper = new NamingHelper(options, detectedServiceName, options.serviceName);\n // parse model information from edmx into something we can really work with\n // => that stuff is called dataModel!\n const dataModel =\n version === ODataVersions.V2\n ? await digestV2(schemaRaw as SchemaV3, options, namingHelper)\n : await digestV4(schemaRaw as SchemaV4, options, namingHelper);\n // handling the overall generation project\n const project = await createProjectManager(\n namingHelper.getFileNames(),\n options.output,\n options.emitMode,\n options.prettier,\n options.tsconfig\n );\n\n // Generate Model Interfaces\n // supported edmx types: EntityType, ComplexType, EnumType\n const modelsFile = await project.createModelFile();\n generateModels(dataModel, modelsFile, version, options, namingHelper);\n\n // Generate Query Objects\n // supported edmx types: EntityType, ComplexType\n // supported edmx prop types: primitive types, enum types, primitive collection (incl enum types), entity collection, entity object, complex object\n if (isQObjectGen(options.mode)) {\n const qFile = await project.createQObjectFile();\n generateQueryObjects(dataModel, qFile, version, options, namingHelper);\n }\n\n // Generate Individual OData-Service\n if (isServiceGen(options.mode)) {\n await project.cleanServiceDir();\n await generateServices(dataModel, project, version, namingHelper);\n }\n\n await project.writeFiles();\n}\n"]}
|
|
@@ -31,11 +31,19 @@ export declare class DataModel {
|
|
|
31
31
|
*/
|
|
32
32
|
getModel(modelName: string): ModelType;
|
|
33
33
|
/**
|
|
34
|
-
* Retrieve all known
|
|
34
|
+
* Retrieve all known EntityType models from the EDMX model.
|
|
35
35
|
*
|
|
36
36
|
* @returns list of model types
|
|
37
37
|
*/
|
|
38
38
|
getModels(): ModelType[];
|
|
39
|
+
/**
|
|
40
|
+
* Set all model entity types
|
|
41
|
+
*
|
|
42
|
+
* @param models new model types
|
|
43
|
+
*/
|
|
44
|
+
setModels(models: {
|
|
45
|
+
[name: string]: ModelType;
|
|
46
|
+
}): void;
|
|
39
47
|
addComplexType(name: string, model: ComplexType): void;
|
|
40
48
|
/**
|
|
41
49
|
* Get a specific model by its name.
|
|
@@ -45,11 +53,19 @@ export declare class DataModel {
|
|
|
45
53
|
*/
|
|
46
54
|
getComplexType(name: string): ComplexType;
|
|
47
55
|
/**
|
|
48
|
-
* Retrieve all known
|
|
56
|
+
* Retrieve all known ComplexType models from the EDMX model.
|
|
49
57
|
*
|
|
50
58
|
* @returns list of model types
|
|
51
59
|
*/
|
|
52
60
|
getComplexTypes(): ComplexType[];
|
|
61
|
+
/**
|
|
62
|
+
* Set all complex types
|
|
63
|
+
*
|
|
64
|
+
* @param models new complex types
|
|
65
|
+
*/
|
|
66
|
+
setComplexTypes(complexTypes: {
|
|
67
|
+
[name: string]: ComplexType;
|
|
68
|
+
}): void;
|
|
53
69
|
addEnum(name: string, type: EnumType): void;
|
|
54
70
|
/**
|
|
55
71
|
* Get list of all known enums, i.e. EnumType nodes from the EDMX model.
|
|
@@ -40,13 +40,21 @@ class DataModel {
|
|
|
40
40
|
return this.modelTypes[modelName];
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* Retrieve all known
|
|
43
|
+
* Retrieve all known EntityType models from the EDMX model.
|
|
44
44
|
*
|
|
45
45
|
* @returns list of model types
|
|
46
46
|
*/
|
|
47
47
|
getModels() {
|
|
48
48
|
return Object.values(this.modelTypes);
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Set all model entity types
|
|
52
|
+
*
|
|
53
|
+
* @param models new model types
|
|
54
|
+
*/
|
|
55
|
+
setModels(models) {
|
|
56
|
+
this.modelTypes = models;
|
|
57
|
+
}
|
|
50
58
|
addComplexType(name, model) {
|
|
51
59
|
this.complexTypes[name] = model;
|
|
52
60
|
}
|
|
@@ -60,13 +68,21 @@ class DataModel {
|
|
|
60
68
|
return this.complexTypes[name];
|
|
61
69
|
}
|
|
62
70
|
/**
|
|
63
|
-
* Retrieve all known
|
|
71
|
+
* Retrieve all known ComplexType models from the EDMX model.
|
|
64
72
|
*
|
|
65
73
|
* @returns list of model types
|
|
66
74
|
*/
|
|
67
75
|
getComplexTypes() {
|
|
68
76
|
return Object.values(this.complexTypes);
|
|
69
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Set all complex types
|
|
80
|
+
*
|
|
81
|
+
* @param models new complex types
|
|
82
|
+
*/
|
|
83
|
+
setComplexTypes(complexTypes) {
|
|
84
|
+
this.complexTypes = complexTypes;
|
|
85
|
+
}
|
|
70
86
|
addEnum(name, type) {
|
|
71
87
|
this.enumTypes[name] = type;
|
|
72
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataModel.js","sourceRoot":"","sources":["../../src/data-model/DataModel.ts"],"names":[],"mappings":";;;AAGA,mDAWyB;AAQzB,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,MAAa,SAAS;IAUpB,YAAoB,OAAqB,EAAE,aAAoC,IAAI,GAAG,EAAE;QAApE,YAAO,GAAP,OAAO,CAAc;QAPjC,eAAU,GAAkC,EAAE,CAAC;QAC/C,iBAAY,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AAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IAC9C,CAAC;IAEM,kBAAkB;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEM,YAAY,CAAC,QAA8C;QAChE,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;CACF;AAzJD,8BAyJC","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\nimport { ODataTypesV2, ODataTypesV4 } from \"@odata2ts/odata-core\";\r\n\r\nimport {\r\n ActionImportType,\r\n ComplexType,\r\n EntityContainerModel,\r\n EntitySetType,\r\n EnumType,\r\n FunctionImportType,\r\n ModelType,\r\n ODataVersion,\r\n OperationType,\r\n SingletonType,\r\n} from \"./DataTypeModel\";\r\n\r\nexport interface ProjectFiles {\r\n model: string;\r\n qObject: string;\r\n service: string;\r\n}\r\n\r\nconst ROOT_OPERATION_BINDING = \"/\";\r\n\r\nexport class DataModel {\r\n private readonly converters: MappedConverterChains;\r\n\r\n private modelTypes: { [name: string]: ModelType } = {};\r\n private complexTypes: { [name: string]: ComplexType } = {};\r\n private enumTypes: { [name: string]: EnumType } = {};\r\n // combines functions & actions\r\n private operationTypes: { [binding: string]: Array<OperationType> } = {};\r\n private container: EntityContainerModel = { entitySets: {}, singletons: {}, functions: {}, actions: {} };\r\n\r\n constructor(private version: ODataVersion, converters: MappedConverterChains = new Map()) {\r\n this.converters = converters;\r\n }\r\n\r\n /**\r\n * OData version: 2.0 or 4.0.\r\n * @returns\r\n */\r\n public getODataVersion() {\r\n return this.version;\r\n }\r\n\r\n public isV2() {\r\n return this.version === ODataVersion.V2;\r\n }\r\n\r\n public isV4() {\r\n return this.version === ODataVersion.V4;\r\n }\r\n\r\n public addModel(name: string, model: ModelType) {\r\n this.modelTypes[name] = model;\r\n }\r\n\r\n /**\r\n * Get a specific model by its name.\r\n *\r\n * @param modelName the final model name that is generated\r\n * @returns the model type\r\n */\r\n public getModel(modelName: string) {\r\n return this.modelTypes[modelName];\r\n }\r\n\r\n /**\r\n * Retrieve all known EntityType models from the EDMX model.\r\n *\r\n * @returns list of model types\r\n */\r\n public getModels() {\r\n return Object.values(this.modelTypes);\r\n }\r\n\r\n /**\r\n * Set all model entity types\r\n *\r\n * @param models new model types\r\n */\r\n public setModels(models: { [name: string]: ModelType }) {\r\n this.modelTypes = models;\r\n }\r\n\r\n public addComplexType(name: string, model: ComplexType) {\r\n this.complexTypes[name] = model;\r\n }\r\n\r\n /**\r\n * Get a specific model by its name.\r\n *\r\n * @param name the final model name that is generated\r\n * @returns the model type\r\n */\r\n public getComplexType(name: string) {\r\n return this.complexTypes[name];\r\n }\r\n\r\n /**\r\n * Retrieve all known ComplexType models from the EDMX model.\r\n *\r\n * @returns list of model types\r\n */\r\n public getComplexTypes() {\r\n return Object.values(this.complexTypes);\r\n }\r\n\r\n /**\r\n * Set all complex types\r\n *\r\n * @param models new complex types\r\n */\r\n public setComplexTypes(complexTypes: { [name: string]: ComplexType }) {\r\n this.complexTypes = complexTypes;\r\n }\r\n\r\n public addEnum(name: string, type: EnumType) {\r\n this.enumTypes[name] = type;\r\n }\r\n\r\n /**\r\n * Get list of all known enums, i.e. EnumType nodes from the EDMX model.\r\n * @returns list of enum types\r\n */\r\n public getEnums() {\r\n return Object.values(this.enumTypes);\r\n }\r\n\r\n public addOperationType(binding: string, operationType: OperationType) {\r\n if (!this.operationTypes[binding]) {\r\n this.operationTypes[binding] = [];\r\n }\r\n\r\n this.operationTypes[binding].push(operationType);\r\n }\r\n\r\n public getUnboundOperationTypes(): Array<OperationType> {\r\n const operations = this.operationTypes[ROOT_OPERATION_BINDING];\r\n return !operations ? [] : [...operations];\r\n }\r\n\r\n public getOperationTypeByBinding(binding: string): Array<OperationType> {\r\n const operations = this.operationTypes[binding];\r\n return !operations ? [] : [...operations];\r\n }\r\n\r\n public getOperationTypeByEntityOrCollectionBinding(binding: string): Array<OperationType> {\r\n const entityOps = this.operationTypes[binding] || [];\r\n const collOps = this.operationTypes[`Collection(${binding})`] || [];\r\n return [...collOps, ...entityOps];\r\n }\r\n\r\n public addAction(name: string, action: ActionImportType) {\r\n this.container.actions[name] = action;\r\n }\r\n\r\n public addFunction(name: string, func: FunctionImportType) {\r\n this.container.functions[name] = func;\r\n }\r\n\r\n public addSingleton(name: string, singleton: SingletonType) {\r\n this.container.singletons[name] = singleton;\r\n }\r\n\r\n public addEntitySet(name: string, entitySet: EntitySetType) {\r\n this.container.entitySets[name] = entitySet;\r\n }\r\n\r\n public getEntityContainer() {\r\n return this.container;\r\n }\r\n\r\n public getConverter(dataType: ODataTypesV2 | ODataTypesV4 | string) {\r\n return this.converters.get(dataType);\r\n }\r\n}\r\n"]}
|
|
@@ -38,6 +38,7 @@ export declare abstract class Digester<S extends Schema<ET, CT>, ET extends Enti
|
|
|
38
38
|
private addComplexType;
|
|
39
39
|
private addEntityType;
|
|
40
40
|
private postProcessModel;
|
|
41
|
+
private sortModelsByInheritance;
|
|
41
42
|
private collectBaseClassPropsAndKeys;
|
|
42
43
|
protected mapProp: (p: Property) => PropertyModel;
|
|
43
44
|
}
|
|
@@ -172,13 +172,15 @@ class Digester {
|
|
|
172
172
|
}
|
|
173
173
|
postProcessModel() {
|
|
174
174
|
// complex types
|
|
175
|
-
this.dataModel.getComplexTypes()
|
|
176
|
-
|
|
175
|
+
const complexTypes = this.dataModel.getComplexTypes();
|
|
176
|
+
complexTypes.forEach((model) => {
|
|
177
|
+
const [baseProps] = this.collectBaseClassPropsAndKeys(model, []);
|
|
177
178
|
model.baseProps = baseProps;
|
|
178
179
|
});
|
|
180
|
+
const modelTypes = this.dataModel.getModels();
|
|
179
181
|
// entity types
|
|
180
|
-
|
|
181
|
-
const [baseProps, baseKeys, idName, qIdName] = this.collectBaseClassPropsAndKeys(model);
|
|
182
|
+
modelTypes.forEach((model) => {
|
|
183
|
+
const [baseProps, baseKeys, idName, qIdName] = this.collectBaseClassPropsAndKeys(model, []);
|
|
182
184
|
model.baseProps = baseProps;
|
|
183
185
|
if (!model.keyNames.length && idName) {
|
|
184
186
|
model.idModelName = idName;
|
|
@@ -204,15 +206,52 @@ class Digester {
|
|
|
204
206
|
return prop;
|
|
205
207
|
});
|
|
206
208
|
});
|
|
209
|
+
const sortedModelTypes = this.sortModelsByInheritance(modelTypes);
|
|
210
|
+
this.dataModel.setModels(sortedModelTypes);
|
|
211
|
+
const sortedComplexTypes = this.sortModelsByInheritance(complexTypes);
|
|
212
|
+
this.dataModel.setComplexTypes(sortedComplexTypes);
|
|
207
213
|
}
|
|
208
|
-
|
|
214
|
+
sortModelsByInheritance(models) {
|
|
215
|
+
// recursively visit all models and sort them by inheritance such that base classes
|
|
216
|
+
// are always before derived classes
|
|
217
|
+
const sortedModels = {};
|
|
218
|
+
const visitedModels = new Set();
|
|
219
|
+
const inProgressModels = new Set();
|
|
220
|
+
function visit(model) {
|
|
221
|
+
if (inProgressModels.has(model)) {
|
|
222
|
+
throw new Error("Cyclic dependencies detected!");
|
|
223
|
+
}
|
|
224
|
+
if (!visitedModels.has(model)) {
|
|
225
|
+
inProgressModels.add(model);
|
|
226
|
+
for (const baseClassName of model.baseClasses) {
|
|
227
|
+
const baseClass = models.find((e) => e.name === baseClassName);
|
|
228
|
+
if (baseClass) {
|
|
229
|
+
visit(baseClass);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
visitedModels.add(model);
|
|
233
|
+
inProgressModels.delete(model);
|
|
234
|
+
sortedModels[model.name] = model;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
for (const model of models) {
|
|
238
|
+
visit(model);
|
|
239
|
+
}
|
|
240
|
+
return sortedModels;
|
|
241
|
+
}
|
|
242
|
+
collectBaseClassPropsAndKeys(model, visitedModels) {
|
|
243
|
+
if (visitedModels.includes(model.name)) {
|
|
244
|
+
throw new Error(`Cyclic inheritance detected for model ${model.name}!`);
|
|
245
|
+
}
|
|
246
|
+
visitedModels.push(model.name);
|
|
209
247
|
return model.baseClasses.reduce(([props, keys, idName, qIdName], bc) => {
|
|
248
|
+
var _a;
|
|
210
249
|
const baseModel = this.dataModel.getModel(bc) || this.dataModel.getComplexType(bc);
|
|
211
250
|
let idNameResult = idName;
|
|
212
251
|
let qIdNameResult = qIdName;
|
|
213
252
|
// recursive
|
|
214
253
|
if (baseModel.baseClasses.length) {
|
|
215
|
-
const [parentProps, parentKeys, parentIdName, parentQIdName] = this.collectBaseClassPropsAndKeys(baseModel);
|
|
254
|
+
const [parentProps, parentKeys, parentIdName, parentQIdName] = this.collectBaseClassPropsAndKeys(baseModel, visitedModels);
|
|
216
255
|
props.unshift(...parentProps);
|
|
217
256
|
keys.unshift(...parentKeys);
|
|
218
257
|
if (parentIdName) {
|
|
@@ -221,7 +260,7 @@ class Digester {
|
|
|
221
260
|
}
|
|
222
261
|
}
|
|
223
262
|
props.push(...baseModel.props);
|
|
224
|
-
if (baseModel.keyNames) {
|
|
263
|
+
if ((_a = baseModel.keyNames) === null || _a === void 0 ? void 0 : _a.length) {
|
|
225
264
|
keys.push(...baseModel.keyNames.filter((kn) => !keys.includes(kn)));
|
|
226
265
|
idNameResult = baseModel.idModelName;
|
|
227
266
|
qIdNameResult = baseModel.qIdFunctionName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataModelDigestion.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestion.ts"],"names":[],"mappings":";;;;AAGA,2CAAwC;AAIxC,+DAA4D;AAS5D,MAAsB,QAAQ;IAS5B,YACY,OAAqB,EACrB,MAAS,EACT,OAAyB,EACzB,YAA0B,EACpC,UAAkC;QAJxB,YAAO,GAAP,OAAO,CAAc;QACrB,WAAM,GAAN,MAAM,CAAG;QACT,YAAO,GAAP,OAAO,CAAkB;QACzB,iBAAY,GAAZ,YAAY,CAAc;QAN9B,eAAU,GAA2B,IAAI,GAAG,EAAqB,CAAC;QAmNhE,YAAO,GAAG,CAAC,CAAW,EAAiB,EAAE;YACjD,IAAI,CAAC,CAA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a,GAAG,aAAa,CAAC;iBAC/B;aACF;YAED,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;YAC/B,IAAI,SAAS,CAAC,QAAQ,EAAE;gBACtB,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACpE,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC;gBACrC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC;aAC3C;YACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;QACpD,CAAC,EACD,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAA0D,CAC1E,CAAC;IACJ,CAAC;;AAxNH,4BAmSC;AAlSkB,mBAAU,GAAG,MAAM,CAAC;AACpB,uBAAc,GAAG,GAAG,CAAC","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { DataModel } from \"./DataModel\";\r\nimport { ComplexType as ComplexModelType, DataTypes, ODataVersion, PropertyModel } from \"./DataTypeModel\";\r\nimport { ComplexType, EntityType, Property, Schema } from \"./edmx/ODataEdmxModelBase\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\nimport { ServiceConfigHelper } from \"./ServiceConfigHelper\";\r\n\r\nexport interface TypeModel {\r\n outputType: string;\r\n qPath: string;\r\n qCollection: string;\r\n qParam: string | undefined;\r\n}\r\n\r\nexport abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {\r\n protected static EDM_PREFIX = \"Edm.\";\r\n protected static ROOT_OPERATION = \"/\";\r\n\r\n protected readonly dataModel: DataModel;\r\n protected readonly serviceConfigHelper: ServiceConfigHelper;\r\n\r\n private model2Type: Map<string, DataTypes> = new Map<string, DataTypes>();\r\n\r\n protected constructor(\r\n protected version: ODataVersion,\r\n protected schema: S,\r\n protected options: DigestionOptions,\r\n protected namingHelper: NamingHelper,\r\n converters?: MappedConverterChains\r\n ) {\r\n this.dataModel = new DataModel(version, converters);\r\n this.serviceConfigHelper = new ServiceConfigHelper(options);\r\n this.collectModelTypes(this.schema);\r\n }\r\n\r\n protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;\r\n\r\n protected abstract digestEntityContainer(): void;\r\n\r\n /**\r\n * Get essential infos about a given odata type from the version specific service variants.\r\n *\r\n * @param type\r\n * @return tuple of return type, query object, query collection object\r\n */\r\n protected abstract mapODataType(type: string): TypeModel;\r\n\r\n public async digest(): Promise<DataModel> {\r\n this.digestSchema(this.schema);\r\n return this.dataModel;\r\n }\r\n\r\n private collectModelTypes(schema: Schema<ET, CT>) {\r\n const servicePrefix = this.namingHelper.getServicePrefix();\r\n schema.EnumType?.forEach((et) => {\r\n this.model2Type.set(servicePrefix + et.$.Name, DataTypes.EnumType);\r\n });\r\n schema.ComplexType?.forEach((ct) => {\r\n this.model2Type.set(servicePrefix + ct.$.Name, DataTypes.ComplexType);\r\n });\r\n schema.EntityType?.forEach((et) => {\r\n this.model2Type.set(servicePrefix + et.$.Name, DataTypes.ModelType);\r\n });\r\n }\r\n\r\n private digestSchema(schema: Schema<ET, CT>) {\r\n // enums\r\n if (schema.EnumType) {\r\n for (const et of schema.EnumType) {\r\n const name = et.$.Name;\r\n this.dataModel.addEnum(name, {\r\n odataName: name,\r\n name: this.namingHelper.getEnumName(name),\r\n members: et.Member.map((m) => m.$.Name),\r\n });\r\n }\r\n }\r\n\r\n // entity types\r\n this.addEntityType(schema.EntityType);\r\n // complex types\r\n this.addComplexType(schema.ComplexType);\r\n\r\n this.postProcessModel();\r\n\r\n // delegate to concrete entity container digestion\r\n this.digestEntityContainer();\r\n }\r\n\r\n private getBaseModel(model: ComplexType) {\r\n const entityConfig = this.serviceConfigHelper.findConfigEntityByName(model.$.Name);\r\n const entityName = entityConfig?.mappedName || model.$.Name;\r\n\r\n const name = this.namingHelper.getModelName(entityName);\r\n const qName = this.namingHelper.getQName(entityName);\r\n const editableName = this.namingHelper.getEditableModelName(entityName);\r\n const odataName = model.$.Name;\r\n const bType = model.$.BaseType;\r\n const props = [...(model.Property ?? []), ...this.getNavigationProps(model)];\r\n\r\n // support for base types, i.e. extends clause of interfaces\r\n const baseClasses = [];\r\n if (bType) {\r\n baseClasses.push(this.namingHelper.getModelName(bType));\r\n }\r\n\r\n return {\r\n name,\r\n qName,\r\n odataName,\r\n editableName,\r\n baseClasses,\r\n props: props.map(this.mapProp),\r\n baseProps: [], // postprocess required\r\n };\r\n }\r\n\r\n private addComplexType(models: Array<ComplexType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const baseModel = this.getBaseModel(model);\r\n this.dataModel.addComplexType(baseModel.name, baseModel);\r\n }\r\n }\r\n\r\n private addEntityType(models: Array<ET> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const baseModel = this.getBaseModel(model);\r\n const entityConfig = this.serviceConfigHelper.findConfigEntityByName(model.$.Name);\r\n const entityName = entityConfig?.mappedName || model.$.Name;\r\n\r\n // key support: we add keys from this entity,\r\n // but not keys stemming from base classes (postprocess required)\r\n const keyNames: Array<string> = [];\r\n if (entityConfig?.keys?.length) {\r\n keyNames.push(...entityConfig.keys);\r\n } else {\r\n const entity = model as EntityType;\r\n if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {\r\n const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);\r\n keyNames.push(...propNames);\r\n }\r\n }\r\n\r\n this.dataModel.addModel(baseModel.name, {\r\n ...baseModel,\r\n idModelName: this.namingHelper.getIdModelName(entityName),\r\n qIdFunctionName: this.namingHelper.getQIdFunctionName(entityName),\r\n generateId: true,\r\n keyNames: keyNames, // postprocess required to include key specs from base classes\r\n keys: [], // postprocess required to include props from base classes\r\n getKeyUnion: () => keyNames.join(\" | \"),\r\n });\r\n }\r\n }\r\n\r\n private postProcessModel() {\r\n // complex types\r\n this.dataModel.getComplexTypes().forEach((model) => {\r\n const [baseProps] = this.collectBaseClassPropsAndKeys(model);\r\n model.baseProps = baseProps;\r\n });\r\n // entity types\r\n this.dataModel.getModels().forEach((model) => {\r\n const [baseProps, baseKeys, idName, qIdName] = this.collectBaseClassPropsAndKeys(model);\r\n model.baseProps = baseProps;\r\n\r\n if (!model.keyNames.length && idName) {\r\n model.idModelName = idName;\r\n model.qIdFunctionName = qIdName;\r\n model.generateId = false;\r\n }\r\n model.keyNames.unshift(...baseKeys);\r\n\r\n // sanity check: entity types require key specification\r\n if (!model.keyNames.length) {\r\n throw new Error(`Key property is missing from Entity \"${model.name}\" (${model.odataName})!`);\r\n }\r\n\r\n const isSingleKey = model.keyNames.length === 1;\r\n const props = [...model.baseProps, ...model.props];\r\n model.keys = model.keyNames.map((keyName) => {\r\n const prop = props.find((p) => p.odataName === keyName);\r\n if (!prop) {\r\n throw new Error(`Key with name [${keyName}] not found in props!`);\r\n }\r\n // automatically set key prop to managed, if this is the only key of the given entity\r\n if (prop.managed === undefined) {\r\n prop.managed = !this.options.disableAutoManagedKey && isSingleKey;\r\n }\r\n return prop;\r\n });\r\n });\r\n }\r\n\r\n private collectBaseClassPropsAndKeys(model: ComplexModelType): [Array<PropertyModel>, Array<string>, string, string] {\r\n return model.baseClasses.reduce(\r\n ([props, keys, idName, qIdName], bc) => {\r\n const baseModel = this.dataModel.getModel(bc) || this.dataModel.getComplexType(bc);\r\n let idNameResult = idName;\r\n let qIdNameResult = qIdName;\r\n\r\n // recursive\r\n if (baseModel.baseClasses.length) {\r\n const [parentProps, parentKeys, parentIdName, parentQIdName] = this.collectBaseClassPropsAndKeys(baseModel);\r\n props.unshift(...parentProps);\r\n keys.unshift(...parentKeys);\r\n if (parentIdName) {\r\n idNameResult = parentIdName;\r\n qIdNameResult = parentQIdName;\r\n }\r\n }\r\n\r\n props.push(...baseModel.props);\r\n if (baseModel.keyNames) {\r\n keys.push(...baseModel.keyNames.filter((kn) => !keys.includes(kn)));\r\n idNameResult = baseModel.idModelName;\r\n qIdNameResult = baseModel.qIdFunctionName;\r\n }\r\n return [props, keys, idNameResult, qIdNameResult];\r\n },\r\n [[], [], \"\", \"\"] as [Array<PropertyModel>, Array<string>, string, string]\r\n );\r\n }\r\n\r\n protected mapProp = (p: Property): PropertyModel => {\r\n if (!p.$.Type) {\r\n throw new Error(`No type information given for property [${p.$.Name}]!`);\r\n }\r\n\r\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\r\n const dataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\r\n const configProp = this.serviceConfigHelper.findConfigPropByName(p.$.Name);\r\n const name = this.namingHelper.getModelPropName(configProp?.mappedName || p.$.Name);\r\n\r\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\r\n\r\n // domain object known from service:\r\n // EntityType, ComplexType or EnumType\r\n if (dataType.startsWith(this.namingHelper.getServicePrefix())) {\r\n const resultDt = this.model2Type.get(dataType);\r\n if (!resultDt) {\r\n throw new Error(`Couldn't determine model type for data type with name '${dataType}'`);\r\n }\r\n\r\n // special handling for enums\r\n if (resultDt === DataTypes.EnumType) {\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getEnumName(dataType),\r\n qPath: \"QEnumPath\",\r\n qObject: isCollection ? \"QEnumCollection\" : undefined,\r\n qParam: \"QEnumParam\",\r\n };\r\n }\r\n // handling of complex & entity types\r\n else {\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getModelName(dataType),\r\n qPath: \"QEntityPath\",\r\n qObject: this.namingHelper.getQName(dataType),\r\n qParam: \"QComplexParam\",\r\n };\r\n }\r\n }\r\n // OData built-in data types\r\n else if (dataType.startsWith(Digester.EDM_PREFIX)) {\r\n const { outputType, qPath, qParam, qCollection } = this.mapODataType(dataType);\r\n const { to, toModule: typeModule, converters } = this.dataModel.getConverter(dataType) || {};\r\n\r\n const type = !to ? outputType : to.startsWith(Digester.EDM_PREFIX) ? this.mapODataType(to).outputType : to;\r\n\r\n result = {\r\n dataType: DataTypes.PrimitiveType,\r\n type,\r\n typeModule,\r\n qPath,\r\n qParam,\r\n qObject: isCollection ? qCollection : undefined,\r\n converters,\r\n };\r\n } else {\r\n throw new Error(\r\n `Unknown type [${dataType}]: Not 'Collection(...)', not '${this.namingHelper.getServicePrefix()}*', not OData type 'Edm.*'`\r\n );\r\n }\r\n\r\n return {\r\n odataName: p.$.Name,\r\n name,\r\n odataType: p.$.Type,\r\n required: p.$.Nullable === \"false\",\r\n isCollection: isCollection,\r\n managed: configProp?.managed,\r\n ...result,\r\n };\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"DataModelDigestion.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestion.ts"],"names":[],"mappings":";;;;AAGA,2CAAwC;AAIxC,+DAA4D;AAS5D,MAAsB,QAAQ;IAS5B,YACY,OAAqB,EACrB,MAAS,EACT,OAAyB,EACzB,YAA0B,EACpC,UAAkC;QAJxB,YAAO,GAAP,OAAO,CAAc;QACrB,WAAM,GAAN,MAAM,CAAG;QACT,YAAO,GAAP,OAAO,CAAkB;QACzB,iBAAY,GAAZ,YAAY,CAAc;QAN9B,eAAU,GAA2B,IAAI,GAAG,EAAqB,CAAC;QAsQhE,YAAO,GAAG,CAAC,CAAW,EAAiB,EAAE;YACjD,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;aAC1E;YAED,MAAM,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YACv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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;;AA3QH,4BAsVC;AArVkB,mBAAU,GAAG,MAAM,CAAC;AACpB,uBAAc,GAAG,GAAG,CAAC","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\r\n\r\nimport { DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { DataModel } from \"./DataModel\";\r\nimport { ComplexType as ComplexModelType, DataTypes, ModelType, ODataVersion, PropertyModel } from \"./DataTypeModel\";\r\nimport { ComplexType, EntityType, Property, Schema } from \"./edmx/ODataEdmxModelBase\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\nimport { ServiceConfigHelper } from \"./ServiceConfigHelper\";\r\n\r\nexport interface TypeModel {\r\n outputType: string;\r\n qPath: string;\r\n qCollection: string;\r\n qParam: string | undefined;\r\n}\r\n\r\nexport abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {\r\n protected static EDM_PREFIX = \"Edm.\";\r\n protected static ROOT_OPERATION = \"/\";\r\n\r\n protected readonly dataModel: DataModel;\r\n protected readonly serviceConfigHelper: ServiceConfigHelper;\r\n\r\n private model2Type: Map<string, DataTypes> = new Map<string, DataTypes>();\r\n\r\n protected constructor(\r\n protected version: ODataVersion,\r\n protected schema: S,\r\n protected options: DigestionOptions,\r\n protected namingHelper: NamingHelper,\r\n converters?: MappedConverterChains\r\n ) {\r\n this.dataModel = new DataModel(version, converters);\r\n this.serviceConfigHelper = new ServiceConfigHelper(options);\r\n this.collectModelTypes(this.schema);\r\n }\r\n\r\n protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;\r\n\r\n protected abstract digestEntityContainer(): void;\r\n\r\n /**\r\n * Get essential infos about a given odata type from the version specific service variants.\r\n *\r\n * @param type\r\n * @return tuple of return type, query object, query collection object\r\n */\r\n protected abstract mapODataType(type: string): TypeModel;\r\n\r\n public async digest(): Promise<DataModel> {\r\n this.digestSchema(this.schema);\r\n return this.dataModel;\r\n }\r\n\r\n private collectModelTypes(schema: Schema<ET, CT>) {\r\n const servicePrefix = this.namingHelper.getServicePrefix();\r\n schema.EnumType?.forEach((et) => {\r\n this.model2Type.set(servicePrefix + et.$.Name, DataTypes.EnumType);\r\n });\r\n schema.ComplexType?.forEach((ct) => {\r\n this.model2Type.set(servicePrefix + ct.$.Name, DataTypes.ComplexType);\r\n });\r\n schema.EntityType?.forEach((et) => {\r\n this.model2Type.set(servicePrefix + et.$.Name, DataTypes.ModelType);\r\n });\r\n }\r\n\r\n private digestSchema(schema: Schema<ET, CT>) {\r\n // enums\r\n if (schema.EnumType) {\r\n for (const et of schema.EnumType) {\r\n const name = et.$.Name;\r\n this.dataModel.addEnum(name, {\r\n odataName: name,\r\n name: this.namingHelper.getEnumName(name),\r\n members: et.Member.map((m) => m.$.Name),\r\n });\r\n }\r\n }\r\n\r\n // entity types\r\n this.addEntityType(schema.EntityType);\r\n // complex types\r\n this.addComplexType(schema.ComplexType);\r\n\r\n this.postProcessModel();\r\n\r\n // delegate to concrete entity container digestion\r\n this.digestEntityContainer();\r\n }\r\n\r\n private getBaseModel(model: ComplexType) {\r\n const entityConfig = this.serviceConfigHelper.findConfigEntityByName(model.$.Name);\r\n const entityName = entityConfig?.mappedName || model.$.Name;\r\n\r\n const name = this.namingHelper.getModelName(entityName);\r\n const qName = this.namingHelper.getQName(entityName);\r\n const editableName = this.namingHelper.getEditableModelName(entityName);\r\n const odataName = model.$.Name;\r\n const bType = model.$.BaseType;\r\n const props = [...(model.Property ?? []), ...this.getNavigationProps(model)];\r\n\r\n // support for base types, i.e. extends clause of interfaces\r\n const baseClasses = [];\r\n if (bType) {\r\n baseClasses.push(this.namingHelper.getModelName(bType));\r\n }\r\n\r\n return {\r\n name,\r\n qName,\r\n odataName,\r\n editableName,\r\n baseClasses,\r\n props: props.map(this.mapProp),\r\n baseProps: [], // postprocess required\r\n };\r\n }\r\n\r\n private addComplexType(models: Array<ComplexType> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const baseModel = this.getBaseModel(model);\r\n this.dataModel.addComplexType(baseModel.name, baseModel);\r\n }\r\n }\r\n\r\n private addEntityType(models: Array<ET> | undefined) {\r\n if (!models || !models.length) {\r\n return;\r\n }\r\n\r\n for (const model of models) {\r\n const baseModel = this.getBaseModel(model);\r\n const entityConfig = this.serviceConfigHelper.findConfigEntityByName(model.$.Name);\r\n const entityName = entityConfig?.mappedName || model.$.Name;\r\n\r\n // key support: we add keys from this entity,\r\n // but not keys stemming from base classes (postprocess required)\r\n const keyNames: Array<string> = [];\r\n if (entityConfig?.keys?.length) {\r\n keyNames.push(...entityConfig.keys);\r\n } else {\r\n const entity = model as EntityType;\r\n if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {\r\n const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);\r\n keyNames.push(...propNames);\r\n }\r\n }\r\n\r\n this.dataModel.addModel(baseModel.name, {\r\n ...baseModel,\r\n idModelName: this.namingHelper.getIdModelName(entityName),\r\n qIdFunctionName: this.namingHelper.getQIdFunctionName(entityName),\r\n generateId: true,\r\n keyNames: keyNames, // postprocess required to include key specs from base classes\r\n keys: [], // postprocess required to include props from base classes\r\n getKeyUnion: () => keyNames.join(\" | \"),\r\n });\r\n }\r\n }\r\n\r\n private postProcessModel() {\r\n // complex types\r\n 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 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 isCollection = !!p.$.Type.match(/^Collection\\(/);\r\n const dataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\r\n const configProp = this.serviceConfigHelper.findConfigPropByName(p.$.Name);\r\n const name = this.namingHelper.getModelPropName(configProp?.mappedName || p.$.Name);\r\n\r\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\r\n\r\n // domain object known from service:\r\n // EntityType, ComplexType or EnumType\r\n if (dataType.startsWith(this.namingHelper.getServicePrefix())) {\r\n const resultDt = this.model2Type.get(dataType);\r\n if (!resultDt) {\r\n throw new Error(`Couldn't determine model type for data type with name '${dataType}'`);\r\n }\r\n\r\n // special handling for enums\r\n if (resultDt === DataTypes.EnumType) {\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getEnumName(dataType),\r\n qPath: \"QEnumPath\",\r\n qObject: isCollection ? \"QEnumCollection\" : undefined,\r\n qParam: \"QEnumParam\",\r\n };\r\n }\r\n // handling of complex & entity types\r\n else {\r\n result = {\r\n dataType: resultDt,\r\n type: this.namingHelper.getModelName(dataType),\r\n qPath: \"QEntityPath\",\r\n qObject: this.namingHelper.getQName(dataType),\r\n qParam: \"QComplexParam\",\r\n };\r\n }\r\n }\r\n // OData built-in data types\r\n else if (dataType.startsWith(Digester.EDM_PREFIX)) {\r\n const { outputType, qPath, qParam, qCollection } = this.mapODataType(dataType);\r\n const { to, toModule: typeModule, converters } = this.dataModel.getConverter(dataType) || {};\r\n\r\n const type = !to ? outputType : to.startsWith(Digester.EDM_PREFIX) ? this.mapODataType(to).outputType : to;\r\n\r\n result = {\r\n dataType: DataTypes.PrimitiveType,\r\n type,\r\n typeModule,\r\n qPath,\r\n qParam,\r\n qObject: isCollection ? qCollection : undefined,\r\n converters,\r\n };\r\n } else {\r\n throw new Error(\r\n `Unknown type [${dataType}]: Not 'Collection(...)', not '${this.namingHelper.getServicePrefix()}*', not OData type 'Edm.*'`\r\n );\r\n }\r\n\r\n return {\r\n odataName: p.$.Name,\r\n name,\r\n odataType: p.$.Type,\r\n required: p.$.Nullable === \"false\",\r\n isCollection: isCollection,\r\n managed: configProp?.managed,\r\n ...result,\r\n };\r\n };\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ODataEdmxModelBase.js","sourceRoot":"","sources":["../../../src/data-model/edmx/ODataEdmxModelBase.ts"],"names":[],"mappings":"","sourcesContent":["export interface ODataEdmxModelBase<VersionedSchema> {\
|
|
1
|
+
{"version":3,"file":"ODataEdmxModelBase.js","sourceRoot":"","sources":["../../../src/data-model/edmx/ODataEdmxModelBase.ts"],"names":[],"mappings":"","sourcesContent":["export interface ODataEdmxModelBase<VersionedSchema> {\n \"edmx:Edmx\": {\n $: {\n Version: string;\n \"xmlns:edmx\": string;\n };\n // \"edmx:Reference\": Array<any>;\n \"edmx:DataServices\": Array<DataService<VersionedSchema>>;\n };\n}\n\nexport interface DataService<VersionedSchema> {\n Schema: Array<VersionedSchema>;\n}\n\nexport interface Schema<ET extends EntityType, CT extends ComplexType> {\n $: {\n Namespace: string;\n xmlns: string;\n };\n EntityType?: Array<ET>;\n ComplexType?: Array<CT>;\n EnumType?: Array<EnumType>;\n EntityContainer?: Array<any>;\n}\n\nexport interface EntityContainer<ES = EntitySet> {\n $: {\n Name: string;\n };\n EntitySet?: Array<ES>;\n}\n\nexport interface EntitySet {\n $: {\n Name: string;\n EntityType: string;\n };\n}\n\nexport interface EntityType {\n $: {\n Name: string;\n BaseType?: string;\n };\n Key: Array<PropertyRef>;\n Property: Array<Property>;\n}\n\nexport interface ComplexType extends Omit<EntityType, \"Key\"> {}\n\nexport interface PropertyRef {\n PropertyRef: Array<{ $: { Name: string } }>;\n}\n\nexport interface Property {\n $: {\n Name: string;\n Type: string;\n MaxLength?: number;\n Nullable?: \"true\" | \"false\";\n Precision?: number;\n };\n}\n\nexport interface EnumType {\n $: {\n Name: string;\n };\n Member: Array<Member>;\n}\n\nexport interface Member {\n $: {\n Name: string;\n Value: number;\n };\n}\n\nexport interface Parameter extends Property {\n Unicode?: boolean;\n}\n\nexport interface ReturnType {\n $: {\n Type: string;\n };\n}\n"]}
|
package/lib/defaultConfig.js
CHANGED
package/lib/defaultConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../src/defaultConfig.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAElC,+CAA+D;AAC/D,+CAA6D;AAE7D;;GAEG;AACH,MAAM,aAAa,GAA0C;IAC3D,IAAI,EAAE,mBAAK,CAAC,GAAG;IACf,QAAQ,EAAE,uBAAS,CAAC,MAAM;IAC1B,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,eAAe;IACzB,UAAU,EAAE,EAAE;IACd,kBAAkB,EAAE,KAAK;IACzB,YAAY,EAAE,KAAK;IACnB,cAAc,EAAE,KAAK;IACrB,qBAAqB,EAAE,KAAK;IAC5B,aAAa,EAAE,KAAK;IACpB,MAAM,EAAE;QACN,MAAM,EAAE;YACN,cAAc,EAAE,8BAAgB,CAAC,WAAW;YAC5C,kBAAkB,EAAE,8BAAgB,CAAC,UAAU;YAC/C,cAAc,EAAE;gBACd,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,EAAE;gBACV,gBAAgB,EAAE,IAAI;aACvB;YACD,QAAQ,EAAE;gBACR,MAAM,EAAE,EAAE;gBACV,MAAM,EAAE,IAAI;gBACZ,gBAAgB,EAAE,IAAI;aACvB;YACD,oBAAoB,EAAE;gBAC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M;QACvB,IAAI,EAAE;YACJ,kBAAkB,EAAE,IAAI;SACzB;QACD,UAAU,EAAE;YACV,kBAAkB,EAAE,IAAI;YACxB,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM;YAClC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM;SACnC;QACD,YAAY,EAAE;YACZ,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,MAAM;YACpC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,MAAM;SACrC;QACD,oBAAoB,EAAE;YACpB,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM;YAC5C,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM;SAC7C;QACD,uBAAuB,EAAE;YACvB,MAAM,EAAE,QAAQ,CAAC,uBAAuB,CAAC,MAAM;YAC/C,MAAM,EAAE,QAAQ,CAAC,uBAAuB,CAAC,MAAM;SAChD;KACF;CACF,CAAC;AAEF;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,mBAAS,EAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAFD,4CAEC;AAED;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,MAAM,EAAE,MAAM,KAAqB,aAAa,EAA7B,WAAW,kBAAK,aAAa,EAA1C,UAA0B,CAAgB,CAAC;IACjD,OAAO,IAAA,mBAAS,EAAC,WAAW,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;AACjE,CAAC;AAHD,4CAGC","sourcesContent":["import deepmerge from \"deepmerge\";\r\n\r\nimport { NameSettings, NamingStrategies } from \"./NamingModel\";\r\nimport { EmitModes, Modes, RunOptions } from \"./OptionModel\";\r\n\r\n/**\r\n * The default configuration.\r\n */\r\nconst defaultConfig: Omit<RunOptions, \"source\" | \"output\"> = {\r\n mode: Modes.all,\r\n emitMode: EmitModes.js_dts,\r\n debug: false,\r\n prettier: false,\r\n tsconfig: \"tsconfig.json\",\r\n converters: [],\r\n skipEditableModels: false,\r\n skipIdModels: false,\r\n skipOperations: false,\r\n disableAutoManagedKey: false,\r\n allowRenaming: false,\r\n naming: {\r\n models: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n editableModels: {\r\n prefix: \"Editable\",\r\n suffix: \"\",\r\n applyModelNaming: true,\r\n },\r\n idModels: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n applyModelNaming: true,\r\n },\r\n operationParamModels: {\r\n prefix: \"\",\r\n suffix: \"Params\",\r\n applyModelNaming: true,\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"\",\r\n suffix: \"Model\",\r\n },\r\n },\r\n queryObjects: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n idFunctions: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n },\r\n },\r\n services: {\r\n prefix: \"\",\r\n suffix: \"Service\",\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n prefix: \"\",\r\n suffix: \"Collection\",\r\n applyServiceNaming: true,\r\n },\r\n serviceResolverFunction: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"create\",\r\n suffix: \"serviceResolver\",\r\n },\r\n operations: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n },\r\n relatedServiceGetter: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"navTo\",\r\n suffix: \"\",\r\n },\r\n privateProps: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"_\",\r\n suffix: \"\",\r\n },\r\n publicProps: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n },\r\n },\r\n },\r\n propertiesByName: [],\r\n entitiesByName: [],\r\n};\r\n\r\nconst { models, queryObjects, services } = defaultConfig.naming;\r\nconst minimalNamingConfig: NameSettings = {\r\n models: {\r\n fileName: {\r\n prefix: models.fileName.prefix,\r\n suffix: models.fileName.suffix,\r\n },\r\n idModels: {\r\n applyModelNaming: true,\r\n prefix: models.idModels.prefix,\r\n suffix: models.idModels.suffix,\r\n },\r\n editableModels: {\r\n applyModelNaming: true,\r\n prefix: models.editableModels.prefix,\r\n suffix: models.editableModels.suffix,\r\n },\r\n operationParamModels: {\r\n applyModelNaming: true,\r\n prefix: models.operationParamModels.prefix,\r\n suffix: models.operationParamModels.suffix,\r\n },\r\n },\r\n queryObjects: {\r\n prefix: queryObjects.prefix,\r\n suffix: queryObjects.suffix,\r\n fileName: {\r\n prefix: queryObjects.fileName.prefix,\r\n suffix: queryObjects.fileName.suffix,\r\n },\r\n idFunctions: {\r\n prefix: queryObjects.idFunctions.prefix,\r\n suffix: queryObjects.idFunctions.suffix,\r\n },\r\n },\r\n services: {\r\n prefix: services.prefix,\r\n suffix: services.suffix,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n applyServiceNaming: true,\r\n prefix: services.collection.prefix,\r\n suffix: services.collection.suffix,\r\n },\r\n privateProps: {\r\n prefix: services.privateProps.prefix,\r\n suffix: services.privateProps.suffix,\r\n },\r\n relatedServiceGetter: {\r\n prefix: services.relatedServiceGetter.prefix,\r\n suffix: services.relatedServiceGetter.suffix,\r\n },\r\n serviceResolverFunction: {\r\n prefix: services.serviceResolverFunction.prefix,\r\n suffix: services.serviceResolverFunction.suffix,\r\n },\r\n },\r\n};\r\n\r\n/**\r\n * Creates a defensive copy of the default config.\r\n */\r\nexport function getDefaultConfig(): Omit<RunOptions, \"source\" | \"output\"> {\r\n return deepmerge(defaultConfig, {});\r\n}\r\n\r\n/**\r\n * Creates a defensive copy of the minimal config: minimal in respect to naming.\r\n */\r\nexport function getMinimalConfig(): Omit<RunOptions, \"source\" | \"output\"> {\r\n const { naming, ...passThrough } = defaultConfig;\r\n return deepmerge(passThrough, { naming: minimalNamingConfig });\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../src/defaultConfig.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAElC,+CAA+D;AAC/D,+CAA6D;AAE7D;;GAEG;AACH,MAAM,aAAa,GAA0C;IAC3D,IAAI,EAAE,mBAAK,CAAC,GAAG;IACf,QAAQ,EAAE,uBAAS,CAAC,MAAM;IAC1B,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,eAAe;IACzB,UAAU,EAAE,EAAE;IACd,kBAAkB,EAAE,KAAK;IACzB,YAAY,EAAE,KAAK;IACnB,cAAc,EAAE,KAAK;IACrB,qBAAqB,EAAE,KAAK;IAC5B,aAAa,EAAE,KAAK;IACpB,gCAAgC,EAAE,KAAK;IACvC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,cAAc,EAAE,8BAAgB,CAAC,WAAW;YAC5C,kBAAkB,EAAE,8BAAgB,CAAC,UAAU;YAC/C,cAAc,EAAE;gBACd,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,EAAE;gBACV,gBAAgB,EAAE,IAAI;aACvB;YACD,QAAQ,EAAE;gBACR,MAAM,EAAE,EAAE;gBACV,MAAM,EAAE,IAAI;gBACZ,gBAAgB,EAAE,IAAI;aACvB;YACD,oBAAoB,EAAE;gBACpB,MAAM,EAAE,EAAE;gBACV,MAAM,EAAE,QAAQ;gBAChB,gBAAgB,EAAE,IAAI;aACvB;YACD,QAAQ,EAAE;gBACR,cAAc,EAAE,8BAAgB,CAAC,WAAW;gBAC5C,MAAM,EAAE,EAAE;gBACV,MAAM,EAAE,OAAO;aAChB;SACF;QACD,YAAY,EAAE;YACZ,cAAc,EAAE,8BAAgB,CAAC,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YAAY,CAAC,MAAM;YACpC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,MAAM;SACrC;QACD,oBAAoB,EAAE;YACpB,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM;YAC5C,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM;SAC7C;QACD,uBAAuB,EAAE;YACvB,MAAM,EAAE,QAAQ,CAAC,uBAAuB,CAAC,MAAM;YAC/C,MAAM,EAAE,QAAQ,CAAC,uBAAuB,CAAC,MAAM;SAChD;KACF;CACF,CAAC;AAEF;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,mBAAS,EAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAFD,4CAEC;AAED;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,MAAM,EAAE,MAAM,KAAqB,aAAa,EAA7B,WAAW,kBAAK,aAAa,EAA1C,UAA0B,CAAgB,CAAC;IACjD,OAAO,IAAA,mBAAS,EAAC,WAAW,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;AACjE,CAAC;AAHD,4CAGC","sourcesContent":["import deepmerge from \"deepmerge\";\r\n\r\nimport { NameSettings, NamingStrategies } from \"./NamingModel\";\r\nimport { EmitModes, Modes, RunOptions } from \"./OptionModel\";\r\n\r\n/**\r\n * The default configuration.\r\n */\r\nconst defaultConfig: Omit<RunOptions, \"source\" | \"output\"> = {\r\n mode: Modes.all,\r\n emitMode: EmitModes.js_dts,\r\n debug: false,\r\n prettier: false,\r\n tsconfig: \"tsconfig.json\",\r\n converters: [],\r\n skipEditableModels: false,\r\n skipIdModels: false,\r\n skipOperations: false,\r\n disableAutoManagedKey: false,\r\n allowRenaming: false,\r\n v2ModelsWithExtraResultsWrapping: false,\r\n naming: {\r\n models: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n editableModels: {\r\n prefix: \"Editable\",\r\n suffix: \"\",\r\n applyModelNaming: true,\r\n },\r\n idModels: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n applyModelNaming: true,\r\n },\r\n operationParamModels: {\r\n prefix: \"\",\r\n suffix: \"Params\",\r\n applyModelNaming: true,\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"\",\r\n suffix: \"Model\",\r\n },\r\n },\r\n queryObjects: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n idFunctions: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n },\r\n },\r\n services: {\r\n prefix: \"\",\r\n suffix: \"Service\",\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n prefix: \"\",\r\n suffix: \"Collection\",\r\n applyServiceNaming: true,\r\n },\r\n serviceResolverFunction: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"create\",\r\n suffix: \"serviceResolver\",\r\n },\r\n operations: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n },\r\n relatedServiceGetter: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"navTo\",\r\n suffix: \"\",\r\n },\r\n privateProps: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"_\",\r\n suffix: \"\",\r\n },\r\n publicProps: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n },\r\n },\r\n },\r\n propertiesByName: [],\r\n entitiesByName: [],\r\n};\r\n\r\nconst { models, queryObjects, services } = defaultConfig.naming;\r\nconst minimalNamingConfig: NameSettings = {\r\n models: {\r\n fileName: {\r\n prefix: models.fileName.prefix,\r\n suffix: models.fileName.suffix,\r\n },\r\n idModels: {\r\n applyModelNaming: true,\r\n prefix: models.idModels.prefix,\r\n suffix: models.idModels.suffix,\r\n },\r\n editableModels: {\r\n applyModelNaming: true,\r\n prefix: models.editableModels.prefix,\r\n suffix: models.editableModels.suffix,\r\n },\r\n operationParamModels: {\r\n applyModelNaming: true,\r\n prefix: models.operationParamModels.prefix,\r\n suffix: models.operationParamModels.suffix,\r\n },\r\n },\r\n queryObjects: {\r\n prefix: queryObjects.prefix,\r\n suffix: queryObjects.suffix,\r\n fileName: {\r\n prefix: queryObjects.fileName.prefix,\r\n suffix: queryObjects.fileName.suffix,\r\n },\r\n idFunctions: {\r\n prefix: queryObjects.idFunctions.prefix,\r\n suffix: queryObjects.idFunctions.suffix,\r\n },\r\n },\r\n services: {\r\n prefix: services.prefix,\r\n suffix: services.suffix,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n applyServiceNaming: true,\r\n prefix: services.collection.prefix,\r\n suffix: services.collection.suffix,\r\n },\r\n privateProps: {\r\n prefix: services.privateProps.prefix,\r\n suffix: services.privateProps.suffix,\r\n },\r\n relatedServiceGetter: {\r\n prefix: services.relatedServiceGetter.prefix,\r\n suffix: services.relatedServiceGetter.suffix,\r\n },\r\n serviceResolverFunction: {\r\n prefix: services.serviceResolverFunction.prefix,\r\n suffix: services.serviceResolverFunction.suffix,\r\n },\r\n },\r\n};\r\n\r\n/**\r\n * Creates a defensive copy of the default config.\r\n */\r\nexport function getDefaultConfig(): Omit<RunOptions, \"source\" | \"output\"> {\r\n return deepmerge(defaultConfig, {});\r\n}\r\n\r\n/**\r\n * Creates a defensive copy of the minimal config: minimal in respect to naming.\r\n */\r\nexport function getMinimalConfig(): Omit<RunOptions, \"source\" | \"output\"> {\r\n const { naming, ...passThrough } = defaultConfig;\r\n return deepmerge(passThrough, { naming: minimalNamingConfig });\r\n}\r\n"]}
|
package/lib/evaluateConfig.js
CHANGED
|
@@ -47,7 +47,7 @@ function evaluateConfigOptions(cliOpts, configOpts) {
|
|
|
47
47
|
throw new Error("No services were configured in config file, so options --source and --output must be specified!");
|
|
48
48
|
}
|
|
49
49
|
const merged = deepmerge_1.default.all([defaultConfig, confBaseOpts, cliOpts]);
|
|
50
|
-
return [
|
|
50
|
+
return [safeGuardOptions(merged)];
|
|
51
51
|
}
|
|
52
52
|
// Either services are specified or we use all configured services
|
|
53
53
|
const servicesToUse = (cliServices === null || cliServices === void 0 ? void 0 : cliServices.length) ? cliServices : Object.keys(confServices);
|
|
@@ -59,20 +59,25 @@ function evaluateConfigOptions(cliOpts, configOpts) {
|
|
|
59
59
|
}
|
|
60
60
|
const serviceDefault = ((_a = service.naming) === null || _a === void 0 ? void 0 : _a.minimalDefaults) && !((_b = configOpts === null || configOpts === void 0 ? void 0 : configOpts.naming) === null || _b === void 0 ? void 0 : _b.minimalDefaults) ? (0, defaultConfig_1.getMinimalConfig)() : defaultConfig;
|
|
61
61
|
const merged = deepmerge_1.default.all([serviceDefault, confBaseOpts, service, cliBaseOpts]);
|
|
62
|
-
return
|
|
62
|
+
return safeGuardOptions(merged);
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
exports.evaluateConfigOptions = evaluateConfigOptions;
|
|
66
66
|
/**
|
|
67
|
-
* Make sure that
|
|
67
|
+
* Make sure that some options are only active if in correct mode.
|
|
68
68
|
* @param options
|
|
69
69
|
*/
|
|
70
|
-
function
|
|
70
|
+
function safeGuardOptions(options) {
|
|
71
|
+
// skip options are not valid for service generation
|
|
71
72
|
if (options.mode === OptionModel_1.Modes.service || options.mode === OptionModel_1.Modes.all) {
|
|
72
73
|
options.skipEditableModels = false;
|
|
73
74
|
options.skipIdModels = false;
|
|
74
75
|
options.skipOperations = false;
|
|
75
76
|
}
|
|
77
|
+
// special option which is only valid for model generation
|
|
78
|
+
if (options.mode !== OptionModel_1.Modes.models) {
|
|
79
|
+
options.v2ModelsWithExtraResultsWrapping = false;
|
|
80
|
+
}
|
|
76
81
|
return options;
|
|
77
82
|
}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AC,MAAM,EAAE;QACjC,OAAO,CAAC,gCAAgC,GAAG,KAAK,CAAC;KAClD;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import deepmerge from \"deepmerge\";\r\n\r\nimport { getDefaultConfig, getMinimalConfig } from \"./defaultConfig\";\r\nimport { CliOptions, ConfigFileOptions, Modes, RunOptions } from \"./OptionModel\";\r\n\r\n/**\r\n * Provides default values and evaluates the various config file and CLI options.\r\n * This function always returns a list of RunOptions,\r\n * whereby each item represents one generation run / one service.\r\n *\r\n * Configurations are merged in the following order (last one wins):\r\n * - default values\r\n * - config file: base settings\r\n * - config file: service specific settings\r\n * - CLI options\r\n *\r\n * If the CLI options specify source and output, then the service config is completely ignored and only the\r\n * base settings are applied from the config file.\r\n *\r\n * If the CLI options do not specify source and output, but do specify services, then these services must\r\n * exist in the config file and each service must supply values for source and output as a minimum.\r\n *\r\n * If the CLI options neither entail source nor services, then at least one service must be configured in the\r\n * config file. All configured services are returned.\r\n *\r\n * @param cliOpts CLI passed options\r\n * @param configOpts config file options\r\n */\r\nexport function evaluateConfigOptions(\r\n cliOpts: CliOptions,\r\n configOpts: ConfigFileOptions | undefined\r\n): Array<RunOptions> {\r\n const defaultConfig = configOpts?.naming?.minimalDefaults ? getMinimalConfig() : getDefaultConfig();\r\n // No config file\r\n if (!configOpts) {\r\n if (!cliOpts.source || !cliOpts.output) {\r\n throw new Error(\"Without any configuration file options --source and --output must be specified!\");\r\n }\r\n return [deepmerge(defaultConfig, cliOpts)];\r\n }\r\n\r\n const { services: cliServices, source, output, ...cliBaseOpts } = cliOpts;\r\n const { services: confServices, ...confBaseOpts } = configOpts;\r\n\r\n // No configurations of services in config file\r\n // or CLI opts specify source and output => ignore service config\r\n if ((source && output) || !confServices) {\r\n if (!source || !output) {\r\n throw new Error(\r\n \"No services were configured in config file, so options --source and --output must be specified!\"\r\n );\r\n }\r\n const merged = deepmerge.all([defaultConfig, confBaseOpts, cliOpts]) as RunOptions;\r\n return [safeGuardOptions(merged)];\r\n }\r\n\r\n // Either services are specified or we use all configured services\r\n const servicesToUse = cliServices?.length ? cliServices : Object.keys(confServices);\r\n return servicesToUse.map((s) => {\r\n const service = confServices[s];\r\n if (!service) {\r\n throw new Error(`Specified service \"${s}\" doesn't exist in configuration!`);\r\n }\r\n const serviceDefault =\r\n service.naming?.minimalDefaults && !configOpts?.naming?.minimalDefaults ? getMinimalConfig() : defaultConfig;\r\n const merged = deepmerge.all([serviceDefault, confBaseOpts, service, cliBaseOpts]) as RunOptions;\r\n return safeGuardOptions(merged);\r\n });\r\n}\r\n\r\n/**\r\n * Make sure that some options are only active if in correct mode.\r\n * @param options\r\n */\r\nfunction safeGuardOptions(options: RunOptions): RunOptions {\r\n // skip options are not valid for service generation\r\n if (options.mode === Modes.service || options.mode === Modes.all) {\r\n options.skipEditableModels = false;\r\n options.skipIdModels = false;\r\n options.skipOperations = false;\r\n }\r\n // special option which is only valid for model generation\r\n if (options.mode !== Modes.models) {\r\n options.v2ModelsWithExtraResultsWrapping = false;\r\n }\r\n\r\n return options;\r\n}\r\n"]}
|
|
@@ -84,7 +84,13 @@ class ModelGenerator {
|
|
|
84
84
|
}
|
|
85
85
|
// Collections
|
|
86
86
|
if (prop.isCollection) {
|
|
87
|
-
|
|
87
|
+
const type = `Array<${prop.type}>`;
|
|
88
|
+
if (this.dataModel.isV2() && this.options.v2ModelsWithExtraResultsWrapping) {
|
|
89
|
+
return `{ results: ${type} }` + suffix;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return type + suffix;
|
|
93
|
+
}
|
|
88
94
|
}
|
|
89
95
|
// primitive, enum & complex types
|
|
90
96
|
return prop.type + (prop.required ? "" : " | null") + suffix;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelGenerator.js","sourceRoot":"","sources":["../../src/generator/ModelGenerator.ts"],"names":[],"mappings":";;;AAOA,uDAAoD;AAE7C,MAAM,cAAc,GAAiC,CAAC,SAAS,EAAE,UAAU,E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import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { SourceFile } from \"ts-morph\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport { ComplexType, DataTypes, ModelType, OperationType, PropertyModel } from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { EntityBasedGeneratorFunction, GeneratorFunctionOptions } from \"../FactoryFunctionModel\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nexport const generateModels: EntityBasedGeneratorFunction = (dataModel, sourceFile, version, options, namingHelper) => {\r\n const generator = new ModelGenerator(dataModel, sourceFile, version, options, namingHelper);\r\n return generator.generate();\r\n};\r\n\r\nconst DEFERRED_CONTENT = \"DeferredContent\";\r\n\r\nclass ModelGenerator {\r\n private importContainer!: ImportContainer;\r\n\r\n constructor(\r\n private dataModel: DataModel,\r\n private sourceFile: SourceFile,\r\n private version: ODataVersions,\r\n private options: GeneratorFunctionOptions,\r\n private namingHelper: NamingHelper\r\n ) {}\r\n\r\n public generate(): void {\r\n this.importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n this.generateEnums();\r\n this.generateModels();\r\n if (!this.options.skipOperations) {\r\n this.generateUnboundOperationParams();\r\n }\r\n }\r\n\r\n private generateEnums() {\r\n this.dataModel.getEnums().forEach((et) => {\r\n this.sourceFile.addEnum({\r\n name: et.name,\r\n isExported: true,\r\n members: et.members.map((mem) => ({ name: mem, initializer: `\"${mem}\"` })),\r\n });\r\n });\r\n }\r\n\r\n private generateModels() {\r\n this.dataModel.getModels().forEach((model) => {\r\n this.generateModel(model);\r\n if (!this.options.skipIdModels) {\r\n this.generateIdModel(model);\r\n }\r\n if (!this.options.skipEditableModels) {\r\n this.generateEditableModel(model);\r\n }\r\n if (!this.options.skipOperations) {\r\n this.generateBoundOperationParams(model.name);\r\n }\r\n });\r\n this.dataModel.getComplexTypes().forEach((model) => {\r\n this.generateModel(model);\r\n if (!this.options.skipEditableModels) {\r\n this.generateEditableModel(model);\r\n }\r\n });\r\n\r\n this.sourceFile.addImportDeclarations(this.importContainer.getImportDeclarations());\r\n }\r\n\r\n private generateModel(model: ComplexType) {\r\n this.sourceFile.addInterface({\r\n name: model.name,\r\n isExported: true,\r\n properties: model.props.map((p) => {\r\n const isEntity = p.dataType == DataTypes.ModelType;\r\n return {\r\n name: p.name,\r\n type: this.getPropType(p),\r\n // props for entities or entity collections are not added in V4 if not explicitly expanded\r\n hasQuestionToken: this.dataModel.isV4() && isEntity,\r\n };\r\n }),\r\n extends: model.baseClasses,\r\n });\r\n }\r\n\r\n private getPropType(prop: PropertyModel): string {\r\n const isEntity = prop.dataType == DataTypes.ModelType;\r\n\r\n // V2 entity special: deferred content\r\n let suffix = \"\";\r\n if (isEntity && this.dataModel.isV2()) {\r\n this.importContainer.addFromCore(DEFERRED_CONTENT);\r\n suffix = ` | ${DEFERRED_CONTENT}`;\r\n }\r\n // custom types which require type imports => possible via converters\r\n else if (prop.typeModule) {\r\n this.importContainer.addCustomType(prop.typeModule, prop.type);\r\n }\r\n\r\n // Collections\r\n if (prop.isCollection) {\r\n return `Array<${prop.type}>` + suffix;\r\n }\r\n\r\n // primitive, enum & complex types\r\n return prop.type + (prop.required ? \"\" : \" | null\") + suffix;\r\n }\r\n\r\n private generateIdModel(model: ModelType) {\r\n if (!model.generateId) {\r\n return;\r\n }\r\n const singleType = model.keys.length === 1 ? `${model.keys[0].type} | ` : \"\";\r\n const keyTypes = model.keys.map((keyProp) => `${keyProp.name}: ${this.getPropType(keyProp)}`).join(\",\");\r\n const type = `${singleType}{${keyTypes}}`;\r\n\r\n this.sourceFile.addTypeAlias({\r\n name: model.idModelName,\r\n isExported: true,\r\n type,\r\n });\r\n }\r\n\r\n private generateEditableModel(model: ComplexType) {\r\n const entityTypes = [DataTypes.ModelType, DataTypes.ComplexType];\r\n const allProps = [...model.baseProps, ...model.props].filter((p) => !p.managed);\r\n\r\n const requiredProps = allProps\r\n .filter((p) => p.required && !entityTypes.includes(p.dataType))\r\n .map((p) => `\"${p.name}\"`)\r\n .join(\" | \");\r\n const optionalProps = allProps\r\n .filter((p) => !p.required && !entityTypes.includes(p.dataType))\r\n .map((p) => `\"${p.name}\"`)\r\n .join(\" | \");\r\n const complexProps = allProps.filter((p) => p.dataType === DataTypes.ComplexType);\r\n\r\n const extendsClause = [\r\n requiredProps ? `Pick<${model.name}, ${requiredProps}>` : null,\r\n optionalProps ? `Partial<Pick<${model.name}, ${optionalProps}>>` : null,\r\n ].filter((e): e is string => !!e);\r\n\r\n this.sourceFile.addInterface({\r\n name: model.editableName,\r\n isExported: true,\r\n extends: extendsClause,\r\n properties: !complexProps\r\n ? undefined\r\n : complexProps.map((p) => {\r\n return {\r\n name: p.name,\r\n type: this.getEditablePropType(p),\r\n // optional props don't need to be specified in editable model\r\n // also, entities would require deep insert func => we make it optional for now\r\n hasQuestionToken: !p.required || p.dataType === DataTypes.ModelType,\r\n };\r\n }),\r\n });\r\n }\r\n\r\n private getEditablePropType(prop: PropertyModel): string {\r\n const type =\r\n prop.dataType === DataTypes.ModelType\r\n ? this.dataModel.getModel(prop.type).editableName\r\n : prop.dataType === DataTypes.ComplexType\r\n ? this.dataModel.getComplexType(prop.type).editableName\r\n : prop.type;\r\n\r\n // Collections\r\n if (prop.isCollection) {\r\n return `Array<${type}>`;\r\n }\r\n\r\n // primitive, enum & complex types\r\n return type + (prop.required ? \"\" : \" | null\");\r\n }\r\n\r\n private generateUnboundOperationParams() {\r\n this.dataModel.getUnboundOperationTypes().forEach((operation) => {\r\n this.generateOperationParams(operation);\r\n });\r\n }\r\n\r\n private generateBoundOperationParams(entityName: string) {\r\n this.dataModel.getOperationTypeByEntityOrCollectionBinding(entityName).forEach((operation) => {\r\n this.generateOperationParams(operation);\r\n });\r\n }\r\n\r\n private generateOperationParams(operation: OperationType) {\r\n if (!operation.parameters.length) {\r\n return;\r\n }\r\n this.sourceFile.addInterface({\r\n name: operation.paramsModelName,\r\n isExported: true,\r\n properties: operation.parameters.map((p) => {\r\n return {\r\n name: p.name,\r\n type: this.getPropType(p),\r\n hasQuestionToken: !p.required,\r\n };\r\n }),\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ModelGenerator.js","sourceRoot":"","sources":["../../src/generator/ModelGenerator.ts"],"names":[],"mappings":";;;AAOA,uDAAoD;AAE7C,MAAM,cAAc,GAAiC,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;IACpH,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC5F,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC,CAAC;AAHW,QAAA,cAAc,kBAGzB;AAEF,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAE3C,MAAM,cAAc;IAGlB,YACU,SAAoB,EACpB,UAAsB,EACtB,OAAsB,EACtB,OAAiC,EACjC,YAA0B;QAJ1B,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAY;QACtB,YAAO,GAAP,OAAO,CAAe;QACtB,YAAO,GAAP,OAAO,CAA0B;QACjC,iBAAY,GAAZ,YAAY,CAAc;IACjC,CAAC;IAEG,QAAQ;QACb,IAAI,CAAC,eAAe,GAAG,IAAI,iCAAe,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC;QAE7E,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;YAChC,IAAI,CAAC,8BAA8B,EAAE,CAAC;SACvC;IACH,CAAC;IAEO,aAAa;QACnB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;YACvC,IAAI,CAAC,UAAU,CAAC,OAAO,CAA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AAC,UAAU,CAAC,MAAM,EAAE;YAChC,OAAO;SACR;QACD,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;YAC3B,IAAI,EAAE,SAAS,CAAC,eAAe;YAC/B,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACzC,OAAO;oBACL,IAAI,EAAE,CAAC,CAAC,IAAI;oBACZ,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;oBACzB,gBAAgB,EAAE,CAAC,CAAC,CAAC,QAAQ;iBAC9B,CAAC;YACJ,CAAC,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { SourceFile } from \"ts-morph\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport { ComplexType, DataTypes, ModelType, OperationType, PropertyModel } from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { EntityBasedGeneratorFunction, GeneratorFunctionOptions } from \"../FactoryFunctionModel\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nexport const generateModels: EntityBasedGeneratorFunction = (dataModel, sourceFile, version, options, namingHelper) => {\r\n const generator = new ModelGenerator(dataModel, sourceFile, version, options, namingHelper);\r\n return generator.generate();\r\n};\r\n\r\nconst DEFERRED_CONTENT = \"DeferredContent\";\r\n\r\nclass ModelGenerator {\r\n private importContainer!: ImportContainer;\r\n\r\n constructor(\r\n private dataModel: DataModel,\r\n private sourceFile: SourceFile,\r\n private version: ODataVersions,\r\n private options: GeneratorFunctionOptions,\r\n private namingHelper: NamingHelper\r\n ) {}\r\n\r\n public generate(): void {\r\n this.importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n this.generateEnums();\r\n this.generateModels();\r\n if (!this.options.skipOperations) {\r\n this.generateUnboundOperationParams();\r\n }\r\n }\r\n\r\n private generateEnums() {\r\n this.dataModel.getEnums().forEach((et) => {\r\n this.sourceFile.addEnum({\r\n name: et.name,\r\n isExported: true,\r\n members: et.members.map((mem) => ({ name: mem, initializer: `\"${mem}\"` })),\r\n });\r\n });\r\n }\r\n\r\n private generateModels() {\r\n this.dataModel.getModels().forEach((model) => {\r\n this.generateModel(model);\r\n if (!this.options.skipIdModels) {\r\n this.generateIdModel(model);\r\n }\r\n if (!this.options.skipEditableModels) {\r\n this.generateEditableModel(model);\r\n }\r\n if (!this.options.skipOperations) {\r\n this.generateBoundOperationParams(model.name);\r\n }\r\n });\r\n this.dataModel.getComplexTypes().forEach((model) => {\r\n this.generateModel(model);\r\n if (!this.options.skipEditableModels) {\r\n this.generateEditableModel(model);\r\n }\r\n });\r\n\r\n this.sourceFile.addImportDeclarations(this.importContainer.getImportDeclarations());\r\n }\r\n\r\n private generateModel(model: ComplexType) {\r\n this.sourceFile.addInterface({\r\n name: model.name,\r\n isExported: true,\r\n properties: model.props.map((p) => {\r\n const isEntity = p.dataType == DataTypes.ModelType;\r\n return {\r\n name: p.name,\r\n type: this.getPropType(p),\r\n // props for entities or entity collections are not added in V4 if not explicitly expanded\r\n hasQuestionToken: this.dataModel.isV4() && isEntity,\r\n };\r\n }),\r\n extends: model.baseClasses,\r\n });\r\n }\r\n\r\n private getPropType(prop: PropertyModel): string {\r\n const isEntity = prop.dataType == DataTypes.ModelType;\r\n\r\n // V2 entity special: deferred content\r\n let suffix = \"\";\r\n if (isEntity && this.dataModel.isV2()) {\r\n this.importContainer.addFromCore(DEFERRED_CONTENT);\r\n suffix = ` | ${DEFERRED_CONTENT}`;\r\n }\r\n // custom types which require type imports => possible via converters\r\n else if (prop.typeModule) {\r\n this.importContainer.addCustomType(prop.typeModule, prop.type);\r\n }\r\n\r\n // Collections\r\n if (prop.isCollection) {\r\n const type = `Array<${prop.type}>`;\r\n if (this.dataModel.isV2() && this.options.v2ModelsWithExtraResultsWrapping) {\r\n return `{ results: ${type} }` + suffix;\r\n } else {\r\n return type + suffix;\r\n }\r\n }\r\n\r\n // primitive, enum & complex types\r\n return prop.type + (prop.required ? \"\" : \" | null\") + suffix;\r\n }\r\n\r\n private generateIdModel(model: ModelType) {\r\n if (!model.generateId) {\r\n return;\r\n }\r\n const singleType = model.keys.length === 1 ? `${model.keys[0].type} | ` : \"\";\r\n const keyTypes = model.keys.map((keyProp) => `${keyProp.name}: ${this.getPropType(keyProp)}`).join(\",\");\r\n const type = `${singleType}{${keyTypes}}`;\r\n\r\n this.sourceFile.addTypeAlias({\r\n name: model.idModelName,\r\n isExported: true,\r\n type,\r\n });\r\n }\r\n\r\n private generateEditableModel(model: ComplexType) {\r\n const entityTypes = [DataTypes.ModelType, DataTypes.ComplexType];\r\n const allProps = [...model.baseProps, ...model.props].filter((p) => !p.managed);\r\n\r\n const requiredProps = allProps\r\n .filter((p) => p.required && !entityTypes.includes(p.dataType))\r\n .map((p) => `\"${p.name}\"`)\r\n .join(\" | \");\r\n const optionalProps = allProps\r\n .filter((p) => !p.required && !entityTypes.includes(p.dataType))\r\n .map((p) => `\"${p.name}\"`)\r\n .join(\" | \");\r\n const complexProps = allProps.filter((p) => p.dataType === DataTypes.ComplexType);\r\n\r\n const extendsClause = [\r\n requiredProps ? `Pick<${model.name}, ${requiredProps}>` : null,\r\n optionalProps ? `Partial<Pick<${model.name}, ${optionalProps}>>` : null,\r\n ].filter((e): e is string => !!e);\r\n\r\n this.sourceFile.addInterface({\r\n name: model.editableName,\r\n isExported: true,\r\n extends: extendsClause,\r\n properties: !complexProps\r\n ? undefined\r\n : complexProps.map((p) => {\r\n return {\r\n name: p.name,\r\n type: this.getEditablePropType(p),\r\n // optional props don't need to be specified in editable model\r\n // also, entities would require deep insert func => we make it optional for now\r\n hasQuestionToken: !p.required || p.dataType === DataTypes.ModelType,\r\n };\r\n }),\r\n });\r\n }\r\n\r\n private getEditablePropType(prop: PropertyModel): string {\r\n const type =\r\n prop.dataType === DataTypes.ModelType\r\n ? this.dataModel.getModel(prop.type).editableName\r\n : prop.dataType === DataTypes.ComplexType\r\n ? this.dataModel.getComplexType(prop.type).editableName\r\n : prop.type;\r\n\r\n // Collections\r\n if (prop.isCollection) {\r\n return `Array<${type}>`;\r\n }\r\n\r\n // primitive, enum & complex types\r\n return type + (prop.required ? \"\" : \" | null\");\r\n }\r\n\r\n private generateUnboundOperationParams() {\r\n this.dataModel.getUnboundOperationTypes().forEach((operation) => {\r\n this.generateOperationParams(operation);\r\n });\r\n }\r\n\r\n private generateBoundOperationParams(entityName: string) {\r\n this.dataModel.getOperationTypeByEntityOrCollectionBinding(entityName).forEach((operation) => {\r\n this.generateOperationParams(operation);\r\n });\r\n }\r\n\r\n private generateOperationParams(operation: OperationType) {\r\n if (!operation.parameters.length) {\r\n return;\r\n }\r\n this.sourceFile.addInterface({\r\n name: operation.paramsModelName,\r\n isExported: true,\r\n properties: operation.parameters.map((p) => {\r\n return {\r\n name: p.name,\r\n type: this.getPropType(p),\r\n hasQuestionToken: !p.required,\r\n };\r\n }),\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -177,6 +177,7 @@ class QueryObjectGenerator {
|
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
generateOperation(operation, importContainer) {
|
|
180
|
+
var _a;
|
|
180
181
|
const isV2 = this.version === odata_core_1.ODataVersions.V2;
|
|
181
182
|
const qOperation = operation.type === "Action" /* OperationTypes.Action */ ? "QAction" : "QFunction";
|
|
182
183
|
const returnType = operation.returnType;
|
|
@@ -207,6 +208,7 @@ class QueryObjectGenerator {
|
|
|
207
208
|
name: "params",
|
|
208
209
|
scope: ts_morph_1.Scope.Private,
|
|
209
210
|
isReadonly: true,
|
|
211
|
+
type: ((_a = operation.parameters) === null || _a === void 0 ? void 0 : _a.length) ? undefined : "[]",
|
|
210
212
|
initializer: this.getParamInitString(operation.parameters, importContainer),
|
|
211
213
|
},
|
|
212
214
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryObjectGenerator.js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;YACvB,IAAI,EAAE,SAAS,CAAC,KAAK;YACrB,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,UAAU,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACzE,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,gBAAK,CAAC,OAAO;oBACpB,UAAU,EAAE,IAAI;oBAChB,WAAW,EAAE,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,UAAU,EAAE,eAAe,CAAC;iBAC5E;aACF;YACD,KAAK,EAAE;gBACL;oBACE,UAAU,EAAE;wBACV,UAAU,SAAS,CAAC,SAAS,IAAI,gBAAgB,CAAC,CAAC,CAAC,IAAI,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,GACrG,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAChC,GAAG;qBACJ;iBACF;aACF;YACD,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,WAAW;oBACjB,UAAU,EAAE,CAAC,oBAAoB,CAAC;iBACnC;gBACD,+GAA+G;gBAC/G,GAAG,CAAC,SAAS,CAAC,IAAI,6CAA4B,IAAI,CAAC,SAAS;oBAC1D,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE,UAAU;4BAChB,UAAU,EAAE,CAAC,kCAAkC,CAAC;yBACjD;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ValueConverterImport } from \"@odata2ts/converter-runtime\";\r\nimport { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { OptionalKind, PropertyDeclarationStructure, Scope, SourceFile, VariableDeclarationKind } from \"ts-morph\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport {\r\n ComplexType,\r\n DataTypes,\r\n ModelType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { EntityBasedGeneratorFunction, GeneratorFunctionOptions } from \"../FactoryFunctionModel\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nexport const generateQueryObjects: EntityBasedGeneratorFunction = (\r\n dataModel,\r\n sourceFile,\r\n version,\r\n options,\r\n namingHelper\r\n) => {\r\n const generator = new QueryObjectGenerator(dataModel, sourceFile, version, options, namingHelper);\r\n return generator.generate();\r\n};\r\n\r\nclass QueryObjectGenerator {\r\n constructor(\r\n private dataModel: DataModel,\r\n private sourceFile: SourceFile,\r\n private version: ODataVersions,\r\n private options: GeneratorFunctionOptions,\r\n private namingHelper: NamingHelper\r\n ) {}\r\n\r\n public generate(): void {\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n this.generateModels(importContainer);\r\n if (!this.options.skipOperations) {\r\n this.generateUnboundOperations(importContainer);\r\n }\r\n\r\n this.sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\r\n }\r\n\r\n private generateModels(importContainer: ImportContainer) {\r\n this.dataModel.getModels().forEach((model) => {\r\n this.generateModel(model, importContainer);\r\n if (!this.options.skipIdModels) {\r\n this.generateIdFunction(model, importContainer);\r\n }\r\n if (!this.options.skipOperations) {\r\n this.generateBoundOperations(model.name, importContainer);\r\n }\r\n });\r\n this.dataModel.getComplexTypes().forEach((model) => {\r\n this.generateModel(model, importContainer);\r\n });\r\n\r\n if (this.dataModel.getModels().length || this.dataModel.getComplexTypes().length) {\r\n importContainer.addFromQObject(\"QueryObject\");\r\n }\r\n }\r\n\r\n private generateModel(model: ComplexType, importContainer: ImportContainer) {\r\n let extendsClause = \"QueryObject\";\r\n if (model.baseClasses.length) {\r\n const baseClass = model.baseClasses[0];\r\n const baseModel = this.dataModel.getModel(baseClass) || this.dataModel.getComplexType(baseClass);\r\n extendsClause = baseModel.qName;\r\n }\r\n\r\n this.sourceFile.addClass({\r\n name: model.qName,\r\n isExported: true,\r\n extends: extendsClause,\r\n properties: this.generateQueryObjectProps(model.props, importContainer),\r\n });\r\n\r\n this.sourceFile.addVariableStatement({\r\n declarationKind: VariableDeclarationKind.Const,\r\n isExported: true,\r\n declarations: [\r\n {\r\n name: firstCharLowerCase(model.qName),\r\n initializer: `new ${model.qName}()`,\r\n },\r\n ],\r\n });\r\n }\r\n\r\n private generateQueryObjectProps(\r\n props: Array<PropertyModel>,\r\n importContainer: ImportContainer\r\n ): Array<OptionalKind<PropertyDeclarationStructure>> {\r\n return props.map((prop) => {\r\n const { odataName } = prop;\r\n const name = this.namingHelper.getQPropName(prop.name);\r\n const isModelType = prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType;\r\n let qPathInit: string;\r\n\r\n // factor in collections\r\n if (prop.isCollection) {\r\n const cType = `Q${isModelType ? \"Entity\" : \"\"}CollectionPath`;\r\n const qObject = prop.qObject;\r\n\r\n if (!qObject) {\r\n throw new Error(\"QObject for collection is missing!\");\r\n }\r\n\r\n qPathInit = `new ${cType}(this.withPrefix(\"${odataName}\"), () => ${qObject})`;\r\n\r\n importContainer.addFromQObject(cType);\r\n if (!isModelType) {\r\n importContainer.addFromQObject(qObject);\r\n }\r\n } else {\r\n if (isModelType) {\r\n qPathInit = `new ${prop.qPath}(this.withPrefix(\"${odataName}\"), () => ${prop.qObject!})`;\r\n } else {\r\n let converterStmt = this.generateConverterStmt(prop.converters, importContainer);\r\n qPathInit = `new ${prop.qPath}(this.withPrefix(\"${odataName}\")${converterStmt ? `, ${converterStmt}` : \"\"})`;\r\n }\r\n // add import for data type\r\n importContainer.addFromQObject(prop.qPath);\r\n }\r\n\r\n return {\r\n name,\r\n scope: Scope.Public,\r\n isReadonly: true,\r\n initializer: qPathInit,\r\n } as OptionalKind<PropertyDeclarationStructure>;\r\n });\r\n }\r\n\r\n private generateConverterStmt(converters: Array<ValueConverterImport> | undefined, importContainer: ImportContainer) {\r\n if (!converters?.length) {\r\n return;\r\n }\r\n converters.forEach((converter) => {\r\n importContainer.addCustomType(converter.package, converter.converterId);\r\n });\r\n\r\n if (converters.length === 1) {\r\n return converters[0].converterId;\r\n } else {\r\n importContainer.addCustomType(\"@odata2ts/converter-runtime\", \"createChain\");\r\n\r\n const [first, second, ...moreConverters] = converters;\r\n return moreConverters.reduce(\r\n (stmt, conv) => `${stmt}.chain(${conv.converterId})`,\r\n `createChain(${first.converterId}, ${second.converterId})`\r\n );\r\n }\r\n }\r\n\r\n private generateIdFunction(model: ModelType, importContainer: ImportContainer) {\r\n if (!model.generateId) {\r\n return;\r\n }\r\n\r\n const qFunc = \"QId\";\r\n importContainer.addFromQObject(qFunc);\r\n importContainer.addGeneratedModel(model.idModelName);\r\n\r\n this.sourceFile.addClass({\r\n name: model.qIdFunctionName,\r\n isExported: true,\r\n extends: `${qFunc}<${model.idModelName}>`,\r\n properties: [\r\n {\r\n name: \"params\",\r\n scope: Scope.Private,\r\n isReadonly: true,\r\n initializer: this.getParamInitString(model.keys, importContainer),\r\n },\r\n ],\r\n methods: [\r\n {\r\n name: \"getParams\",\r\n statements: [\"return this.params\"],\r\n },\r\n ],\r\n });\r\n }\r\n\r\n private getParamInitString(props: Array<PropertyModel>, importContainer: ImportContainer) {\r\n return `[${props\r\n .map((prop) => {\r\n const isComplexParam = prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType;\r\n if (prop.qParam) {\r\n importContainer.addFromQObject(prop.qParam);\r\n }\r\n const isMappedNameNecessary = prop.odataName !== prop.name;\r\n const mappedName = isMappedNameNecessary ? `\"${prop.name}\"` : prop.converters?.length ? \"undefined\" : undefined;\r\n const converterStmt = this.generateConverterStmt(prop.converters, importContainer);\r\n const mappedNameParam = mappedName ? `, ${mappedName}` : \"\";\r\n const complexQParam = isComplexParam ? `, new ${prop.qObject}()` : \"\";\r\n const converterParam = converterStmt ? `, ${converterStmt}` : \"\";\r\n return `new ${prop.qParam}(\"${prop.odataName}\"${complexQParam}${mappedNameParam}${converterParam})`;\r\n })\r\n .join(\",\")}]`;\r\n }\r\n\r\n private generateUnboundOperations(importContainer: ImportContainer) {\r\n this.dataModel.getUnboundOperationTypes().forEach((operation) => {\r\n this.generateOperation(operation, importContainer);\r\n });\r\n }\r\n\r\n private generateBoundOperations(bindingName: string, importContainer: ImportContainer) {\r\n this.dataModel.getOperationTypeByEntityOrCollectionBinding(bindingName).forEach((operation) => {\r\n this.generateOperation(operation, importContainer);\r\n });\r\n }\r\n\r\n private generateOperation(operation: OperationType, importContainer: ImportContainer) {\r\n const isV2 = this.version === ODataVersions.V2;\r\n const qOperation = operation.type === OperationTypes.Action ? \"QAction\" : \"QFunction\";\r\n const returnType = operation.returnType;\r\n let returnTypeOpStmt: string = \"\";\r\n const hasParams = operation.parameters.length > 0;\r\n importContainer.addFromQObject(qOperation);\r\n if (hasParams) {\r\n importContainer.addGeneratedModel(operation.paramsModelName);\r\n }\r\n if (returnType) {\r\n if (returnType.dataType === DataTypes.ComplexType || returnType.dataType === DataTypes.ModelType) {\r\n if (returnType.qObject) {\r\n importContainer.addFromQObject(\"OperationReturnType\", \"ReturnTypes\", \"QComplexParam\");\r\n returnTypeOpStmt = `new OperationReturnType(ReturnTypes.COMPLEX${\r\n returnType.isCollection ? \"_COLLECTION\" : \"\"\r\n }, new QComplexParam(\"NONE\", new ${returnType.qObject}))`;\r\n }\r\n } else if (returnType.converters && returnType.qParam) {\r\n importContainer.addFromQObject(\"OperationReturnType\", \"ReturnTypes\", returnType.qParam);\r\n returnTypeOpStmt = `new OperationReturnType(ReturnTypes.VALUE${\r\n returnType.isCollection ? \"_COLLECTION\" : \"\"\r\n }, new ${returnType.qParam}(\"NONE\", undefined, ${this.generateConverterStmt(\r\n returnType.converters,\r\n importContainer\r\n )}))`;\r\n }\r\n }\r\n\r\n this.sourceFile.addClass({\r\n name: operation.qName,\r\n isExported: true,\r\n extends: qOperation + (hasParams ? `<${operation.paramsModelName}>` : \"\"),\r\n properties: [\r\n {\r\n name: \"params\",\r\n scope: Scope.Private,\r\n isReadonly: true,\r\n initializer: this.getParamInitString(operation.parameters, importContainer),\r\n },\r\n ],\r\n ctors: [\r\n {\r\n statements: [\r\n `super(\"${operation.odataName}\"${returnTypeOpStmt ? \", \" + returnTypeOpStmt : isV2 ? \", undefined\" : \"\"}${\r\n isV2 ? \", { v2Mode: true }\" : \"\"\r\n })`,\r\n ],\r\n },\r\n ],\r\n methods: [\r\n {\r\n name: \"getParams\",\r\n statements: [\"return this.params\"],\r\n },\r\n // functions without params: add an overriding buildUrl() to not force users to have to pass undefined as param\r\n ...(operation.type === OperationTypes.Function && !hasParams\r\n ? [\r\n {\r\n name: \"buildUrl\",\r\n statements: [\"return super.buildUrl(undefined)\"],\r\n },\r\n ]\r\n : []),\r\n ],\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"QueryObjectGenerator.js","sourceRoot":"","sources":["../../src/generator/QueryObjectGenerator.ts"],"names":[],"mappings":";;;AACA,qDAAqD;AACrD,uCAAkH;AAClH,sDAA2D;AAa3D,uDAAoD;AAE7C,MAAM,oBAAoB,GAAiC,CAChE,SAAS,EACT,UAAU,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,EAAE;IACF,MAAM,SAAS,GAAG,IAAI,oBAAoB,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAClG,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC,CAAC;AATW,QAAA,oBAAoB,wBAS/B;AAEF,MAAM,oBAAoB;IACxB,YACU,SAAoB,EACpB,UAAsB,EACtB,OAAsB,EACtB,OAAiC,EACjC,YAA0B;QAJ1B,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAY;QACtB,YAAO,GAAP,OAAO,CAAe;QACtB,YAAO,GA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AAG,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,GACrG,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAChC,GAAG;qBACJ;iBACF;aACF;YACD,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,WAAW;oBACjB,UAAU,EAAE,CAAC,oBAAoB,CAAC;iBACnC;gBACD,+GAA+G;gBAC/G,GAAG,CAAC,SAAS,CAAC,IAAI,6CAA4B,IAAI,CAAC,SAAS;oBAC1D,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE,UAAU;4BAChB,UAAU,EAAE,CAAC,kCAAkC,CAAC;yBACjD;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ValueConverterImport } from \"@odata2ts/converter-runtime\";\r\nimport { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { OptionalKind, PropertyDeclarationStructure, Scope, SourceFile, VariableDeclarationKind } from \"ts-morph\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport {\r\n ComplexType,\r\n DataTypes,\r\n ModelType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { EntityBasedGeneratorFunction, GeneratorFunctionOptions } from \"../FactoryFunctionModel\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nexport const generateQueryObjects: EntityBasedGeneratorFunction = (\r\n dataModel,\r\n sourceFile,\r\n version,\r\n options,\r\n namingHelper\r\n) => {\r\n const generator = new QueryObjectGenerator(dataModel, sourceFile, version, options, namingHelper);\r\n return generator.generate();\r\n};\r\n\r\nclass QueryObjectGenerator {\r\n constructor(\r\n private dataModel: DataModel,\r\n private sourceFile: SourceFile,\r\n private version: ODataVersions,\r\n private options: GeneratorFunctionOptions,\r\n private namingHelper: NamingHelper\r\n ) {}\r\n\r\n public generate(): void {\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n this.generateModels(importContainer);\r\n if (!this.options.skipOperations) {\r\n this.generateUnboundOperations(importContainer);\r\n }\r\n\r\n this.sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\r\n }\r\n\r\n private generateModels(importContainer: ImportContainer) {\r\n this.dataModel.getModels().forEach((model) => {\r\n this.generateModel(model, importContainer);\r\n if (!this.options.skipIdModels) {\r\n this.generateIdFunction(model, importContainer);\r\n }\r\n if (!this.options.skipOperations) {\r\n this.generateBoundOperations(model.name, importContainer);\r\n }\r\n });\r\n this.dataModel.getComplexTypes().forEach((model) => {\r\n this.generateModel(model, importContainer);\r\n });\r\n\r\n if (this.dataModel.getModels().length || this.dataModel.getComplexTypes().length) {\r\n importContainer.addFromQObject(\"QueryObject\");\r\n }\r\n }\r\n\r\n private generateModel(model: ComplexType, importContainer: ImportContainer) {\r\n let extendsClause = \"QueryObject\";\r\n if (model.baseClasses.length) {\r\n const baseClass = model.baseClasses[0];\r\n const baseModel = this.dataModel.getModel(baseClass) || this.dataModel.getComplexType(baseClass);\r\n extendsClause = baseModel.qName;\r\n }\r\n\r\n this.sourceFile.addClass({\r\n name: model.qName,\r\n isExported: true,\r\n extends: extendsClause,\r\n properties: this.generateQueryObjectProps(model.props, importContainer),\r\n });\r\n\r\n this.sourceFile.addVariableStatement({\r\n declarationKind: VariableDeclarationKind.Const,\r\n isExported: true,\r\n declarations: [\r\n {\r\n name: firstCharLowerCase(model.qName),\r\n initializer: `new ${model.qName}()`,\r\n },\r\n ],\r\n });\r\n }\r\n\r\n private generateQueryObjectProps(\r\n props: Array<PropertyModel>,\r\n importContainer: ImportContainer\r\n ): Array<OptionalKind<PropertyDeclarationStructure>> {\r\n return props.map((prop) => {\r\n const { odataName } = prop;\r\n const name = this.namingHelper.getQPropName(prop.name);\r\n const isModelType = prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType;\r\n let qPathInit: string;\r\n\r\n // factor in collections\r\n if (prop.isCollection) {\r\n const cType = `Q${isModelType ? \"Entity\" : \"\"}CollectionPath`;\r\n const qObject = prop.qObject;\r\n\r\n if (!qObject) {\r\n throw new Error(\"QObject for collection is missing!\");\r\n }\r\n\r\n qPathInit = `new ${cType}(this.withPrefix(\"${odataName}\"), () => ${qObject})`;\r\n\r\n importContainer.addFromQObject(cType);\r\n if (!isModelType) {\r\n importContainer.addFromQObject(qObject);\r\n }\r\n } else {\r\n if (isModelType) {\r\n qPathInit = `new ${prop.qPath}(this.withPrefix(\"${odataName}\"), () => ${prop.qObject!})`;\r\n } else {\r\n let converterStmt = this.generateConverterStmt(prop.converters, importContainer);\r\n qPathInit = `new ${prop.qPath}(this.withPrefix(\"${odataName}\")${converterStmt ? `, ${converterStmt}` : \"\"})`;\r\n }\r\n // add import for data type\r\n importContainer.addFromQObject(prop.qPath);\r\n }\r\n\r\n return {\r\n name,\r\n scope: Scope.Public,\r\n isReadonly: true,\r\n initializer: qPathInit,\r\n } as OptionalKind<PropertyDeclarationStructure>;\r\n });\r\n }\r\n\r\n private generateConverterStmt(converters: Array<ValueConverterImport> | undefined, importContainer: ImportContainer) {\r\n if (!converters?.length) {\r\n return;\r\n }\r\n converters.forEach((converter) => {\r\n importContainer.addCustomType(converter.package, converter.converterId);\r\n });\r\n\r\n if (converters.length === 1) {\r\n return converters[0].converterId;\r\n } else {\r\n importContainer.addCustomType(\"@odata2ts/converter-runtime\", \"createChain\");\r\n\r\n const [first, second, ...moreConverters] = converters;\r\n return moreConverters.reduce(\r\n (stmt, conv) => `${stmt}.chain(${conv.converterId})`,\r\n `createChain(${first.converterId}, ${second.converterId})`\r\n );\r\n }\r\n }\r\n\r\n private generateIdFunction(model: ModelType, importContainer: ImportContainer) {\r\n if (!model.generateId) {\r\n return;\r\n }\r\n\r\n const qFunc = \"QId\";\r\n importContainer.addFromQObject(qFunc);\r\n importContainer.addGeneratedModel(model.idModelName);\r\n\r\n this.sourceFile.addClass({\r\n name: model.qIdFunctionName,\r\n isExported: true,\r\n extends: `${qFunc}<${model.idModelName}>`,\r\n properties: [\r\n {\r\n name: \"params\",\r\n scope: Scope.Private,\r\n isReadonly: true,\r\n initializer: this.getParamInitString(model.keys, importContainer),\r\n },\r\n ],\r\n methods: [\r\n {\r\n name: \"getParams\",\r\n statements: [\"return this.params\"],\r\n },\r\n ],\r\n });\r\n }\r\n\r\n private getParamInitString(props: Array<PropertyModel>, importContainer: ImportContainer) {\r\n return `[${props\r\n .map((prop) => {\r\n const isComplexParam = prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType;\r\n if (prop.qParam) {\r\n importContainer.addFromQObject(prop.qParam);\r\n }\r\n const isMappedNameNecessary = prop.odataName !== prop.name;\r\n const mappedName = isMappedNameNecessary ? `\"${prop.name}\"` : prop.converters?.length ? \"undefined\" : undefined;\r\n const converterStmt = this.generateConverterStmt(prop.converters, importContainer);\r\n const mappedNameParam = mappedName ? `, ${mappedName}` : \"\";\r\n const complexQParam = isComplexParam ? `, new ${prop.qObject}()` : \"\";\r\n const converterParam = converterStmt ? `, ${converterStmt}` : \"\";\r\n return `new ${prop.qParam}(\"${prop.odataName}\"${complexQParam}${mappedNameParam}${converterParam})`;\r\n })\r\n .join(\",\")}]`;\r\n }\r\n\r\n private generateUnboundOperations(importContainer: ImportContainer) {\r\n this.dataModel.getUnboundOperationTypes().forEach((operation) => {\r\n this.generateOperation(operation, importContainer);\r\n });\r\n }\r\n\r\n private generateBoundOperations(bindingName: string, importContainer: ImportContainer) {\r\n this.dataModel.getOperationTypeByEntityOrCollectionBinding(bindingName).forEach((operation) => {\r\n this.generateOperation(operation, importContainer);\r\n });\r\n }\r\n\r\n private generateOperation(operation: OperationType, importContainer: ImportContainer) {\r\n const isV2 = this.version === ODataVersions.V2;\r\n const qOperation = operation.type === OperationTypes.Action ? \"QAction\" : \"QFunction\";\r\n const returnType = operation.returnType;\r\n let returnTypeOpStmt: string = \"\";\r\n const hasParams = operation.parameters.length > 0;\r\n importContainer.addFromQObject(qOperation);\r\n if (hasParams) {\r\n importContainer.addGeneratedModel(operation.paramsModelName);\r\n }\r\n if (returnType) {\r\n if (returnType.dataType === DataTypes.ComplexType || returnType.dataType === DataTypes.ModelType) {\r\n if (returnType.qObject) {\r\n importContainer.addFromQObject(\"OperationReturnType\", \"ReturnTypes\", \"QComplexParam\");\r\n returnTypeOpStmt = `new OperationReturnType(ReturnTypes.COMPLEX${\r\n returnType.isCollection ? \"_COLLECTION\" : \"\"\r\n }, new QComplexParam(\"NONE\", new ${returnType.qObject}))`;\r\n }\r\n } else if (returnType.converters && returnType.qParam) {\r\n importContainer.addFromQObject(\"OperationReturnType\", \"ReturnTypes\", returnType.qParam);\r\n returnTypeOpStmt = `new OperationReturnType(ReturnTypes.VALUE${\r\n returnType.isCollection ? \"_COLLECTION\" : \"\"\r\n }, new ${returnType.qParam}(\"NONE\", undefined, ${this.generateConverterStmt(\r\n returnType.converters,\r\n importContainer\r\n )}))`;\r\n }\r\n }\r\n\r\n this.sourceFile.addClass({\r\n name: operation.qName,\r\n isExported: true,\r\n extends: qOperation + (hasParams ? `<${operation.paramsModelName}>` : \"\"),\r\n properties: [\r\n {\r\n name: \"params\",\r\n scope: Scope.Private,\r\n isReadonly: true,\r\n type: operation.parameters?.length ? undefined : \"[]\",\r\n initializer: this.getParamInitString(operation.parameters, importContainer),\r\n },\r\n ],\r\n ctors: [\r\n {\r\n statements: [\r\n `super(\"${operation.odataName}\"${returnTypeOpStmt ? \", \" + returnTypeOpStmt : isV2 ? \", undefined\" : \"\"}${\r\n isV2 ? \", { v2Mode: true }\" : \"\"\r\n })`,\r\n ],\r\n },\r\n ],\r\n methods: [\r\n {\r\n name: \"getParams\",\r\n statements: [\"return this.params\"],\r\n },\r\n // functions without params: add an overriding buildUrl() to not force users to have to pass undefined as param\r\n ...(operation.type === OperationTypes.Function && !hasParams\r\n ? [\r\n {\r\n name: \"buildUrl\",\r\n statements: [\"return super.buildUrl(undefined)\"],\r\n },\r\n ]\r\n : []),\r\n ],\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,uCAAqH;AACrH,uDAAkD;AAClD,sDAA2D;AAiB3D,uDAAoD;AAEpD,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,cAAc,GAAG;IACrB,UAAU,EAAE,yBAAyB;IACrC,KAAK,EAAE,oBAAoB;IAC3B,KAAK,EAAE,oBAAoB;CAC5B,CAAC;AAEF,SAAsB,gBAAgB,CACpC,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B;;QAE1B,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAClF,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;CAAA;AARD,4CAQC;AAED,MAAM,gBAAgB;IACpB,YACU,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B;QAH1B,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAgB;QACvB,YAAO,GAAP,OAAO,CAAe;QACtB,iBAAY,GAAZ,YAAY,CAAc;QA0F5B,4BAAuB,GAAG,CAAC,SAAwB,EAAE,EAAE;YAC7D,OAAO;gBACL,KAAK,EAAE,gBAAK,CAAC,OAAO;gBACpB,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,SAAS,CAAC,KAAK,CAAC;gBAC3D,IAAI,EAAE,SAAS,CAAC,KAAK;gBACrB,gBAAgB,EAAE,IAAI;aACvB,CAAC;QACJ,CAAC,CAAC;IAhGC,CAAC;IAES,QAAQ;;YACnB,MAAM,UA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kBAAkB,CAAC,IAAI,GAAG;wBACpD,CAAC,CAAC,sBAAsB;4BACtB,YAAY,kBAAkB,CAAC,IAAI,GACzC,GAAG;gBACH,UAAU,CAAC,CAAC,CAAC,UAAU,OAAO,6BAA6B,CAAC,CAAC,CAAC,EAAE;aACjE;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport { MethodDeclarationStructure, OptionalKind, PropertyDeclarationStructure, Scope, SourceFile } from \"ts-morph\";\nimport { upperCaseFirst } from \"upper-case-first\";\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\n\nimport { DataModel } from \"../data-model/DataModel\";\nimport {\n ActionImportType,\n ComplexType,\n DataTypes,\n EntitySetType,\n FunctionImportType,\n ModelType,\n OperationType,\n OperationTypes,\n PropertyModel,\n SingletonType,\n} from \"../data-model/DataTypeModel\";\nimport { NamingHelper } from \"../data-model/NamingHelper\";\nimport { ProjectManager } from \"../project/ProjectManager\";\nimport { ImportContainer } from \"./ImportContainer\";\n\nconst ROOT_SERVICE = \"ODataService\";\n\nconst RESPONSE_TYPES = {\n collection: \"ODataCollectionResponse\",\n model: \"ODataModelResponse\",\n value: \"ODataValueResponse\",\n};\n\nexport async function generateServices(\n dataModel: DataModel,\n project: ProjectManager,\n version: ODataVersions,\n namingHelper: NamingHelper\n) {\n const generator = new ServiceGenerator(dataModel, project, version, namingHelper);\n return generator.generate();\n}\n\nclass ServiceGenerator {\n constructor(\n private dataModel: DataModel,\n private project: ProjectManager,\n private version: ODataVersions,\n private namingHelper: NamingHelper\n ) {}\n\n public async generate(): Promise<void> {\n const sourceFile = await this.project.createMainServiceFile();\n const serviceName = this.namingHelper.getMainServiceName();\n const container = this.dataModel.getEntityContainer();\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\n\n await this.generateModelServices();\n\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\n importContainer.addFromClientApi(\"ODataClient\");\n importContainer.addFromService(ROOT_SERVICE);\n\n sourceFile.addClass({\n isExported: true,\n name: serviceName,\n typeParameters: [\"ClientType extends ODataClient\"],\n extends: `${ROOT_SERVICE}<ClientType>`,\n properties: [\n {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(\"name\"),\n type: \"string\",\n initializer: `\"${this.namingHelper.getODataServiceName()}\"`,\n },\n ...this.generateEntityServiceResolverProp(container.entitySets, importContainer),\n ...this.generateServiceGettersByAssignment(container.entitySets),\n ...this.generateServiceTypeProps(container.singletons, this.namingHelper.getServiceName, importContainer),\n ...Object.values(unboundOperations).map(({ operation }) => this.generateQOperationProps(operation)),\n ],\n methods: [\n ...this.generateServiceTypeGetters(container.singletons, this.namingHelper.getServiceName),\n ...this.generateUnboundOperations(unboundOperations, importContainer),\n ],\n });\n\n sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\n }\n\n private generateEntityServiceResolverProp(\n services: Record<string, EntitySetType>,\n importContainer: ImportContainer\n ): OptionalKind<PropertyDeclarationStructure>[] {\n return Object.values(services).map(({ name, entityType }) => {\n const resolverName = this.namingHelper.getServiceResolverName(entityType.name);\n\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), resolverName);\n\n return {\n name: this.namingHelper.getPublicPropNameForService(name),\n scope: Scope.Public,\n initializer: `${resolverName}(this.client, this.getPath(), \"${name}\")`,\n };\n });\n }\n\n private generateServiceGettersByAssignment(\n services: Record<string, EntitySetType>\n ): OptionalKind<PropertyDeclarationStructure>[] {\n return Object.values(services).map(({ name, odataName, entityType }) => {\n const propName = this.namingHelper.getPublicPropNameForService(name);\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(name),\n initializer: `this.${propName}.get.bind(this.${propName})`,\n };\n });\n }\n\n private generateServiceTypeProps(\n services: Record<string, SingletonType | EntitySetType>,\n typeRetriever: (name: string) => string,\n importContainer: ImportContainer\n ): OptionalKind<PropertyDeclarationStructure>[] {\n return Object.values(services).map(({ name, entityType }) => {\n const type = typeRetriever(entityType.name);\n\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), type);\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(name),\n type: `${type}<ClientType>`,\n hasQuestionToken: true,\n };\n });\n }\n\n private generateQOperationProps = (operation: OperationType) => {\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(operation.qName),\n type: operation.qName,\n hasQuestionToken: true,\n };\n };\n\n private generateServiceTypeGetters(\n services: Record<string, SingletonType | EntitySetType>,\n typeRetriever: (name: string) => string\n ): OptionalKind<MethodDeclarationStructure>[] {\n return Object.values(services).map(({ name, odataName, entityType }) => {\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\n const serviceType = typeRetriever(entityType.name);\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(name),\n statements: [\n `if(!${propName}) {`,\n // prettier-ignore\n ` ${propName} = new ${serviceType}(this.client, this.getPath(), \"${odataName}\")`,\n \"}\",\n `return ${propName}`,\n ],\n };\n });\n }\n\n private getVersionSuffix() {\n return this.version === ODataVersions.V2 ? \"V2\" : \"V4\";\n }\n\n private async generateModelService(\n model: ComplexType,\n serviceName: string,\n serviceFile: SourceFile,\n importContainer: ImportContainer\n ) {\n const entityServiceType = \"EntityTypeService\" + this.getVersionSuffix();\n const collectionServiceType = \"CollectionService\" + this.getVersionSuffix();\n\n const editableModelName = model.editableName;\n const operations = this.dataModel.getOperationTypeByBinding(model.name);\n const props = [...model.baseProps, ...model.props];\n const modelProps = props.filter(\n (prop) => prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType\n );\n const primColProps = props.filter(\n (prop) => prop.isCollection && prop.dataType !== DataTypes.ModelType && prop.dataType !== DataTypes.ComplexType\n );\n\n importContainer.addFromService(entityServiceType);\n importContainer.addFromClientApi(\"ODataClient\");\n importContainer.addGeneratedModel(model.name, editableModelName);\n importContainer.addGeneratedQObject(model.qName, firstCharLowerCase(model.qName));\n\n // generate EntityTypeService\n serviceFile.addClass({\n isExported: true,\n name: serviceName,\n typeParameters: [\"ClientType extends ODataClient\"],\n extends: entityServiceType + `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}>`,\n ctors: [\n {\n parameters: [\n { name: \"client\", type: \"ClientType\" },\n { name: \"basePath\", type: \"string\" },\n { name: \"name\", type: \"string\" },\n ],\n statements: [`super(client, basePath, name, ${firstCharLowerCase(model.qName)});`],\n },\n ],\n properties: [\n ...this.generateModelProps(modelProps, collectionServiceType, serviceName, importContainer),\n ...this.generatePrimitiveCollectionProps(primColProps, collectionServiceType, importContainer),\n ...operations.map(this.generateQOperationProps),\n ],\n methods: [\n ...this.generateModelPropGetters(modelProps, collectionServiceType),\n ...this.generatePrimitiveCollectionGetters(primColProps, collectionServiceType),\n ...this.generateBoundOperations(operations, importContainer),\n ],\n });\n }\n\n private generateModelProps(\n modelProps: Array<PropertyModel>,\n collectionServiceType: string,\n serviceName: string,\n importContainer: ImportContainer\n ): Array<PropertyDeclarationStructure> {\n return modelProps.map((prop) => {\n const complexType = this.dataModel.getComplexType(prop.type);\n const key = this.namingHelper.getServiceName(prop.type);\n let propModelType = prop.isCollection ? this.namingHelper.getCollectionServiceName(prop.type) : key;\n\n if (prop.isCollection && complexType) {\n const editableName = complexType.editableName;\n importContainer.addFromService(collectionServiceType);\n importContainer.addGeneratedModel(complexType.name, editableName);\n importContainer.addGeneratedQObject(complexType.qName, firstCharLowerCase(complexType.qName));\n propModelType = `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${editableName}>`;\n } else {\n // don't include imports for this type\n if (serviceName !== key) {\n importContainer.addGeneratedService(key, propModelType);\n }\n\n propModelType = `${propModelType}<ClientType>`;\n }\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(prop.name),\n type: propModelType,\n hasQuestionToken: true,\n } as PropertyDeclarationStructure;\n });\n }\n\n private generatePrimitiveCollectionProps(\n primColProps: Array<PropertyModel>,\n collectionServiceType: string,\n importContainer: ImportContainer\n ): Array<PropertyDeclarationStructure> {\n return primColProps.map((prop) => {\n const isEnum = prop.dataType === DataTypes.EnumType;\n const type = isEnum ? `EnumCollection<${prop.type}>` : `${upperCaseFirst(prop.type)}Collection`;\n const qType = isEnum ? \"QEnumCollection\" : `Q${type}`;\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\n\n if (!prop.qObject) {\n throw new Error(\"Illegal State: [qObject] must be provided for Collection types!\");\n }\n\n importContainer.addFromService(collectionServiceType);\n importContainer.addFromQObject(prop.qObject, firstCharLowerCase(prop.qObject));\n if (isEnum) {\n importContainer.addGeneratedModel(prop.type);\n importContainer.addFromQObject(\"EnumCollection\");\n } else {\n importContainer.addFromQObject(type);\n }\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(prop.name),\n type: `${collectionType}`,\n hasQuestionToken: true,\n } as PropertyDeclarationStructure;\n });\n }\n\n private generateModelPropGetters(\n modelProps: Array<PropertyModel>,\n collectionServiceType: string\n ): Array<MethodDeclarationStructure> {\n return modelProps.map((prop) => {\n const complexType = this.dataModel.getComplexType(prop.type);\n const isComplexCollection = prop.isCollection && complexType;\n const type = isComplexCollection\n ? collectionServiceType\n : prop.isCollection\n ? this.namingHelper.getCollectionServiceName(prop.type)\n : this.namingHelper.getServiceName(prop.type);\n const typeWithGenerics = isComplexCollection\n ? `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${complexType.editableName}>`\n : `${type}<ClientType>`;\n\n const privateSrvProp = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\n\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\n returnType: typeWithGenerics,\n statements: [\n `if(!${privateSrvProp}) {`,\n // prettier-ignore\n ` ${privateSrvProp} = new ${type}(this.client, this.getPath(), \"${prop.odataName}\"${isComplexCollection ? `, ${firstCharLowerCase(complexType.qName)}`: \"\"})`,\n \"}\",\n `return ${privateSrvProp}`,\n ],\n } as MethodDeclarationStructure;\n });\n }\n\n private generatePrimitiveCollectionGetters(\n primColProps: Array<PropertyModel>,\n collectionServiceType: string\n ): Array<MethodDeclarationStructure> {\n return primColProps.map((prop) => {\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\n statements: [\n `if(!${propName}) {`,\n // prettier-ignore\n ` ${propName} = new ${collectionServiceType}(this.client, this.getPath(), \"${prop.odataName}\", ${firstCharLowerCase(prop.qObject!)})`,\n \"}\",\n `return ${propName}`,\n ],\n } as MethodDeclarationStructure;\n });\n }\n\n private async generateEntityCollectionService(\n model: ModelType,\n serviceName: string,\n serviceFile: SourceFile,\n importContainer: ImportContainer\n ) {\n const entitySetServiceType = \"EntitySetService\" + this.getVersionSuffix();\n const editableModelName = model.editableName;\n const qObjectName = firstCharLowerCase(model.qName);\n\n importContainer.addFromService(entitySetServiceType);\n importContainer.addGeneratedModel(model.idModelName);\n importContainer.addGeneratedQObject(model.qIdFunctionName);\n\n const collectionOperations = this.dataModel.getOperationTypeByBinding(`Collection(${model.name})`);\n\n serviceFile.addClass({\n isExported: true,\n name: this.namingHelper.getCollectionServiceName(model.name),\n typeParameters: [\"ClientType extends ODataClient\"],\n extends:\n entitySetServiceType +\n `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}, ${model.idModelName}, ${serviceName}<ClientType>>`,\n ctors: [\n {\n parameters: [\n { name: \"client\", type: \"ClientType\" },\n { name: \"basePath\", type: \"string\" },\n { name: \"name\", type: \"string\" },\n ],\n statements: [\n `super(client, basePath, name, ${qObjectName}, ${serviceName}, new ${model.qIdFunctionName}(name));`,\n ],\n },\n ],\n properties: [...collectionOperations.map(this.generateQOperationProps)],\n methods: [...this.generateBoundOperations(collectionOperations, importContainer)],\n });\n }\n\n private generateEntityServiceResolver(\n model: ModelType,\n serviceName: string,\n serviceFile: SourceFile,\n importContainer: ImportContainer\n ) {\n const idFunctionName = model.qIdFunctionName;\n const collectionName = this.namingHelper.getCollectionServiceName(model.name);\n\n importContainer.addFromClientApi(\"ODataClient\");\n importContainer.addFromService(\"EntityServiceResolver\");\n importContainer.addGeneratedQObject(idFunctionName);\n\n serviceFile.addFunction({\n name: this.namingHelper.getServiceResolverName(model.name),\n isExported: true,\n parameters: [\n {\n name: \"client\",\n type: \"ODataClient\",\n },\n {\n name: \"basePath\",\n type: \"string\",\n },\n {\n name: \"entityName\",\n type: \"string\",\n },\n ],\n statements: [\n `return new EntityServiceResolver(client, basePath, entityName, ${idFunctionName}, ${serviceName}, ${collectionName});`,\n ],\n });\n }\n\n private async generateModelServices() {\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\n for (const model of this.dataModel.getModels()) {\n const serviceName = this.namingHelper.getServiceName(model.name);\n const serviceFile = await this.project.createServiceFile(serviceName);\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\n\n // entity type service\n await this.generateModelService(model, serviceName, serviceFile, importContainer);\n\n // entity collection service\n await this.generateEntityCollectionService(model, serviceName, serviceFile, importContainer);\n\n // the resolver function\n await this.generateEntityServiceResolver(model, serviceName, serviceFile, importContainer);\n\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\n }\n\n // build service file for complex types\n for (const model of this.dataModel.getComplexTypes()) {\n const serviceName = this.namingHelper.getServiceName(model.name);\n const serviceFile = await this.project.createServiceFile(serviceName);\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\n\n // entity type service\n await this.generateModelService(model, serviceName, serviceFile, importContainer);\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\n }\n }\n\n private generateBoundOperations(operations: Array<OperationType>, importContainer: ImportContainer) {\n return operations.reduce<Array<OptionalKind<MethodDeclarationStructure>>>((collector, operation) => {\n collector.push(this.generateMethod(operation.name, operation, importContainer));\n\n return collector;\n }, []);\n }\n\n private generateUnboundOperations(\n operations: Array<FunctionImportType | ActionImportType>,\n importContainer: ImportContainer\n ) {\n return Object.values(operations).reduce<Array<OptionalKind<MethodDeclarationStructure>>>(\n (collector, { name, operation }) => {\n collector.push(this.generateMethod(name, operation, importContainer));\n\n return collector;\n },\n []\n );\n }\n\n private generateMethod(\n name: string,\n operation: OperationType,\n importContainer: ImportContainer\n ): OptionalKind<MethodDeclarationStructure> {\n const isFunc = operation.type === OperationTypes.Function;\n const odataType = operation.returnType?.isCollection\n ? RESPONSE_TYPES.collection + this.getVersionSuffix()\n : operation.returnType?.dataType === DataTypes.PrimitiveType\n ? RESPONSE_TYPES.value + this.getVersionSuffix()\n : RESPONSE_TYPES.model + this.getVersionSuffix();\n const returnType = operation.returnType;\n const requestConfigParam = { name: \"requestConfig\", hasQuestionToken: true, type: \"ODataClientConfig<ClientType>\" };\n const hasParams = operation.parameters.length > 0;\n\n // importing dependencies\n importContainer.addFromClientApi(\"ODataClientConfig\", \"ODataResponse\");\n importContainer.addFromCore(odataType);\n if (returnType?.type) {\n if ([DataTypes.EnumType, DataTypes.ModelType, DataTypes.ComplexType].includes(returnType.dataType)) {\n importContainer.addGeneratedModel(returnType.type);\n }\n }\n importContainer.addGeneratedQObject(operation.qName);\n if (hasParams) {\n importContainer.addGeneratedModel(operation.paramsModelName);\n }\n\n const qOpProp = \"this.\" + this.namingHelper.getPrivatePropName(operation.qName);\n\n return {\n scope: Scope.Public,\n isAsync: true,\n name,\n parameters: hasParams\n ? [{ name: \"params\", type: operation.paramsModelName }, requestConfigParam]\n : [requestConfigParam],\n returnType: `ODataResponse<${odataType}<${returnType?.type || \"void\"}>>`,\n statements: [\n `if(!${qOpProp}) {`,\n ` ${qOpProp} = new ${operation.qName}()`,\n \"}\",\n\n `const url = this.addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params\" : \"\"}));`,\n `${returnType ? \"const response = await \" : \"return\"} this.client.${\n !isFunc\n ? // actions: since V4\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${requestConfigParam.name})`\n : operation.usePost\n ? // V2 POST => BUT values are still query params, they are not part of the request body\n `post(url, undefined, ${requestConfigParam.name})`\n : // functions: since V2\n `get(url, ${requestConfigParam.name})`\n };`,\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\n ],\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";;;;AAAA,qDAAqD;AACrD,uCAAqH;AACrH,uDAAkD;AAClD,sDAA2D;AAiB3D,uDAAoD;AAEpD,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,cAAc,GAAG;IACrB,UAAU,EAAE,yBAAyB;IACrC,KAAK,EAAE,oBAAoB;IAC3B,KAAK,EAAE,oBAAoB;CAC5B,CAAC;AAEF,SAAsB,gBAAgB,CACpC,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B;;QAE1B,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAClF,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;CAAA;AARD,4CAQC;AAED,MAAM,gBAAgB;IACpB,YACU,SAAoB,EACpB,OAAuB,EACvB,OAAsB,EACtB,YAA0B;QAH1B,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAgB;QACvB,YAAO,GAAP,OAAO,CAAe;QACtB,iBAAY,GAAZ,YAAY,CAAc;QA0F5B,4BAAuB,GAAG,CAAC,SAAwB,EAAE,EAAE;YAC7D,OAAO;gBACL,KAAK,EAAE,gBAAK,CAAC,OAAO;gBACpB,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,SAAS,CAAC,KAAK,CAAC;gBAC3D,IAAI,EAAE,SAAS,CAAC,KAAK;gBACrB,gBAAgB,EAAE,IAAI;aACvB,CAAC;QACJ,CAAC,CAAC;IAhGC,CAAC;IAES,QAAQ;;YACnB,MAAM,UAAU,GAAG,M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AC,IAAI,GAAG;wBACpD,CAAC,CAAC,sBAAsB;4BACtB,YAAY,kBAAkB,CAAC,IAAI,GACzC,GAAG;gBACH,UAAU,CAAC,CAAC,CAAC,UAAU,OAAO,6BAA6B,CAAC,CAAC,CAAC,EAAE;aACjE;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { MethodDeclarationStructure, OptionalKind, PropertyDeclarationStructure, Scope, SourceFile } from \"ts-morph\";\r\nimport { upperCaseFirst } from \"upper-case-first\";\r\nimport { firstCharLowerCase } from \"xml2js/lib/processors\";\r\n\r\nimport { DataModel } from \"../data-model/DataModel\";\r\nimport {\r\n ActionImportType,\r\n ComplexType,\r\n DataTypes,\r\n EntitySetType,\r\n FunctionImportType,\r\n ModelType,\r\n OperationType,\r\n OperationTypes,\r\n PropertyModel,\r\n SingletonType,\r\n} from \"../data-model/DataTypeModel\";\r\nimport { NamingHelper } from \"../data-model/NamingHelper\";\r\nimport { ProjectManager } from \"../project/ProjectManager\";\r\nimport { ImportContainer } from \"./ImportContainer\";\r\n\r\nconst ROOT_SERVICE = \"ODataService\";\r\n\r\nconst RESPONSE_TYPES = {\r\n collection: \"ODataCollectionResponse\",\r\n model: \"ODataModelResponse\",\r\n value: \"ODataValueResponse\",\r\n};\r\n\r\nexport async function generateServices(\r\n dataModel: DataModel,\r\n project: ProjectManager,\r\n version: ODataVersions,\r\n namingHelper: NamingHelper\r\n) {\r\n const generator = new ServiceGenerator(dataModel, project, version, namingHelper);\r\n return generator.generate();\r\n}\r\n\r\nclass ServiceGenerator {\r\n constructor(\r\n private dataModel: DataModel,\r\n private project: ProjectManager,\r\n private version: ODataVersions,\r\n private namingHelper: NamingHelper\r\n ) {}\r\n\r\n public async generate(): Promise<void> {\r\n const sourceFile = await this.project.createMainServiceFile();\r\n const serviceName = this.namingHelper.getMainServiceName();\r\n const container = this.dataModel.getEntityContainer();\r\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\r\n\r\n await this.generateModelServices();\r\n\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n importContainer.addFromClientApi(\"ODataClient\");\r\n importContainer.addFromService(ROOT_SERVICE);\r\n\r\n sourceFile.addClass({\r\n isExported: true,\r\n name: serviceName,\r\n typeParameters: [\"ClientType extends ODataClient\"],\r\n extends: `${ROOT_SERVICE}<ClientType>`,\r\n properties: [\r\n {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(\"name\"),\r\n type: \"string\",\r\n initializer: `\"${this.namingHelper.getODataServiceName()}\"`,\r\n },\r\n ...this.generateEntityServiceResolverProp(container.entitySets, importContainer),\r\n ...this.generateServiceGettersByAssignment(container.entitySets),\r\n ...this.generateServiceTypeProps(container.singletons, this.namingHelper.getServiceName, importContainer),\r\n ...Object.values(unboundOperations).map(({ operation }) => this.generateQOperationProps(operation)),\r\n ],\r\n methods: [\r\n ...this.generateServiceTypeGetters(container.singletons, this.namingHelper.getServiceName),\r\n ...this.generateUnboundOperations(unboundOperations, importContainer),\r\n ],\r\n });\r\n\r\n sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));\r\n }\r\n\r\n private generateEntityServiceResolverProp(\r\n services: Record<string, EntitySetType>,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure>[] {\r\n return Object.values(services).map(({ name, entityType }) => {\r\n const resolverName = this.namingHelper.getServiceResolverName(entityType.name);\r\n\r\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), resolverName);\r\n\r\n return {\r\n name: this.namingHelper.getPublicPropNameForService(name),\r\n scope: Scope.Public,\r\n initializer: `${resolverName}(this.client, this.getPath(), \"${name}\")`,\r\n };\r\n });\r\n }\r\n\r\n private generateServiceGettersByAssignment(\r\n services: Record<string, EntitySetType>\r\n ): OptionalKind<PropertyDeclarationStructure>[] {\r\n return Object.values(services).map(({ name, odataName, entityType }) => {\r\n const propName = this.namingHelper.getPublicPropNameForService(name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(name),\r\n initializer: `this.${propName}.get.bind(this.${propName})`,\r\n };\r\n });\r\n }\r\n\r\n private generateServiceTypeProps(\r\n services: Record<string, SingletonType | EntitySetType>,\r\n typeRetriever: (name: string) => string,\r\n importContainer: ImportContainer\r\n ): OptionalKind<PropertyDeclarationStructure>[] {\r\n return Object.values(services).map(({ name, entityType }) => {\r\n const type = typeRetriever(entityType.name);\r\n\r\n importContainer.addGeneratedService(this.namingHelper.getServiceName(entityType.name), type);\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(name),\r\n type: `${type}<ClientType>`,\r\n hasQuestionToken: true,\r\n };\r\n });\r\n }\r\n\r\n private generateQOperationProps = (operation: OperationType) => {\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(operation.qName),\r\n type: operation.qName,\r\n hasQuestionToken: true,\r\n };\r\n };\r\n\r\n private generateServiceTypeGetters(\r\n services: Record<string, SingletonType | EntitySetType>,\r\n typeRetriever: (name: string) => string\r\n ): OptionalKind<MethodDeclarationStructure>[] {\r\n return Object.values(services).map(({ name, odataName, entityType }) => {\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\r\n const serviceType = typeRetriever(entityType.name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n // prettier-ignore\r\n ` ${propName} = new ${serviceType}(this.client, this.getPath(), \"${odataName}\")`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n };\r\n });\r\n }\r\n\r\n private getVersionSuffix() {\r\n return this.version === ODataVersions.V2 ? \"V2\" : \"V4\";\r\n }\r\n\r\n private async generateModelService(\r\n model: ComplexType,\r\n serviceName: string,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const entityServiceType = \"EntityTypeService\" + this.getVersionSuffix();\r\n const collectionServiceType = \"CollectionService\" + this.getVersionSuffix();\r\n\r\n const editableModelName = model.editableName;\r\n const operations = this.dataModel.getOperationTypeByBinding(model.name);\r\n const props = [...model.baseProps, ...model.props];\r\n const modelProps = props.filter(\r\n (prop) => prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType\r\n );\r\n const primColProps = props.filter(\r\n (prop) => prop.isCollection && prop.dataType !== DataTypes.ModelType && prop.dataType !== DataTypes.ComplexType\r\n );\r\n\r\n importContainer.addFromService(entityServiceType);\r\n importContainer.addFromClientApi(\"ODataClient\");\r\n importContainer.addGeneratedModel(model.name, editableModelName);\r\n importContainer.addGeneratedQObject(model.qName, firstCharLowerCase(model.qName));\r\n\r\n // generate EntityTypeService\r\n serviceFile.addClass({\r\n isExported: true,\r\n name: serviceName,\r\n typeParameters: [\"ClientType extends ODataClient\"],\r\n extends: entityServiceType + `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [`super(client, basePath, name, ${firstCharLowerCase(model.qName)});`],\r\n },\r\n ],\r\n properties: [\r\n ...this.generateModelProps(modelProps, collectionServiceType, serviceName, importContainer),\r\n ...this.generatePrimitiveCollectionProps(primColProps, collectionServiceType, importContainer),\r\n ...operations.map(this.generateQOperationProps),\r\n ],\r\n methods: [\r\n ...this.generateModelPropGetters(modelProps, collectionServiceType),\r\n ...this.generatePrimitiveCollectionGetters(primColProps, collectionServiceType),\r\n ...this.generateBoundOperations(operations, importContainer),\r\n ],\r\n });\r\n }\r\n\r\n private generateModelProps(\r\n modelProps: Array<PropertyModel>,\r\n collectionServiceType: string,\r\n serviceName: string,\r\n importContainer: ImportContainer\r\n ): Array<PropertyDeclarationStructure> {\r\n return modelProps.map((prop) => {\r\n const complexType = this.dataModel.getComplexType(prop.type);\r\n const key = this.namingHelper.getServiceName(prop.type);\r\n let propModelType = prop.isCollection ? this.namingHelper.getCollectionServiceName(prop.type) : key;\r\n\r\n if (prop.isCollection && complexType) {\r\n const editableName = complexType.editableName;\r\n importContainer.addFromService(collectionServiceType);\r\n importContainer.addGeneratedModel(complexType.name, editableName);\r\n importContainer.addGeneratedQObject(complexType.qName, firstCharLowerCase(complexType.qName));\r\n propModelType = `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${editableName}>`;\r\n } else {\r\n // don't include imports for this type\r\n if (serviceName !== key) {\r\n importContainer.addGeneratedService(key, propModelType);\r\n }\r\n\r\n propModelType = `${propModelType}<ClientType>`;\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: propModelType,\r\n hasQuestionToken: true,\r\n } as PropertyDeclarationStructure;\r\n });\r\n }\r\n\r\n private generatePrimitiveCollectionProps(\r\n primColProps: Array<PropertyModel>,\r\n collectionServiceType: string,\r\n importContainer: ImportContainer\r\n ): Array<PropertyDeclarationStructure> {\r\n return primColProps.map((prop) => {\r\n const isEnum = prop.dataType === DataTypes.EnumType;\r\n const type = isEnum ? `EnumCollection<${prop.type}>` : `${upperCaseFirst(prop.type)}Collection`;\r\n const qType = isEnum ? \"QEnumCollection\" : `Q${type}`;\r\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\r\n\r\n if (!prop.qObject) {\r\n throw new Error(\"Illegal State: [qObject] must be provided for Collection types!\");\r\n }\r\n\r\n importContainer.addFromService(collectionServiceType);\r\n importContainer.addFromQObject(prop.qObject, firstCharLowerCase(prop.qObject));\r\n if (isEnum) {\r\n importContainer.addGeneratedModel(prop.type);\r\n importContainer.addFromQObject(\"EnumCollection\");\r\n } else {\r\n importContainer.addFromQObject(type);\r\n }\r\n\r\n return {\r\n scope: Scope.Private,\r\n name: this.namingHelper.getPrivatePropName(prop.name),\r\n type: `${collectionType}`,\r\n hasQuestionToken: true,\r\n } as PropertyDeclarationStructure;\r\n });\r\n }\r\n\r\n private generateModelPropGetters(\r\n modelProps: Array<PropertyModel>,\r\n collectionServiceType: string\r\n ): Array<MethodDeclarationStructure> {\r\n return modelProps.map((prop) => {\r\n const complexType = this.dataModel.getComplexType(prop.type);\r\n const isComplexCollection = prop.isCollection && complexType;\r\n const type = isComplexCollection\r\n ? collectionServiceType\r\n : prop.isCollection\r\n ? this.namingHelper.getCollectionServiceName(prop.type)\r\n : this.namingHelper.getServiceName(prop.type);\r\n const typeWithGenerics = isComplexCollection\r\n ? `${collectionServiceType}<ClientType, ${complexType.name}, ${complexType.qName}, ${complexType.editableName}>`\r\n : `${type}<ClientType>`;\r\n\r\n const privateSrvProp = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n returnType: typeWithGenerics,\r\n statements: [\r\n `if(!${privateSrvProp}) {`,\r\n // prettier-ignore\r\n ` ${privateSrvProp} = new ${type}(this.client, this.getPath(), \"${prop.odataName}\"${isComplexCollection ? `, ${firstCharLowerCase(complexType.qName)}`: \"\"})`,\r\n \"}\",\r\n `return ${privateSrvProp}`,\r\n ],\r\n } as MethodDeclarationStructure;\r\n });\r\n }\r\n\r\n private generatePrimitiveCollectionGetters(\r\n primColProps: Array<PropertyModel>,\r\n collectionServiceType: string\r\n ): Array<MethodDeclarationStructure> {\r\n return primColProps.map((prop) => {\r\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\r\n return {\r\n scope: Scope.Public,\r\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\r\n statements: [\r\n `if(!${propName}) {`,\r\n // prettier-ignore\r\n ` ${propName} = new ${collectionServiceType}(this.client, this.getPath(), \"${prop.odataName}\", ${firstCharLowerCase(prop.qObject!)})`,\r\n \"}\",\r\n `return ${propName}`,\r\n ],\r\n } as MethodDeclarationStructure;\r\n });\r\n }\r\n\r\n private async generateEntityCollectionService(\r\n model: ModelType,\r\n serviceName: string,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const entitySetServiceType = \"EntitySetService\" + this.getVersionSuffix();\r\n const editableModelName = model.editableName;\r\n const qObjectName = firstCharLowerCase(model.qName);\r\n\r\n importContainer.addFromService(entitySetServiceType);\r\n importContainer.addGeneratedModel(model.idModelName);\r\n importContainer.addGeneratedQObject(model.qIdFunctionName);\r\n\r\n const collectionOperations = this.dataModel.getOperationTypeByBinding(`Collection(${model.name})`);\r\n\r\n serviceFile.addClass({\r\n isExported: true,\r\n name: this.namingHelper.getCollectionServiceName(model.name),\r\n typeParameters: [\"ClientType extends ODataClient\"],\r\n extends:\r\n entitySetServiceType +\r\n `<ClientType, ${model.name}, ${editableModelName}, ${model.qName}, ${model.idModelName}, ${serviceName}<ClientType>>`,\r\n ctors: [\r\n {\r\n parameters: [\r\n { name: \"client\", type: \"ClientType\" },\r\n { name: \"basePath\", type: \"string\" },\r\n { name: \"name\", type: \"string\" },\r\n ],\r\n statements: [\r\n `super(client, basePath, name, ${qObjectName}, ${serviceName}, new ${model.qIdFunctionName}(name));`,\r\n ],\r\n },\r\n ],\r\n properties: [...collectionOperations.map(this.generateQOperationProps)],\r\n methods: [...this.generateBoundOperations(collectionOperations, importContainer)],\r\n });\r\n }\r\n\r\n private generateEntityServiceResolver(\r\n model: ModelType,\r\n serviceName: string,\r\n serviceFile: SourceFile,\r\n importContainer: ImportContainer\r\n ) {\r\n const idFunctionName = model.qIdFunctionName;\r\n const collectionName = this.namingHelper.getCollectionServiceName(model.name);\r\n\r\n importContainer.addFromClientApi(\"ODataClient\");\r\n importContainer.addFromService(\"EntityServiceResolver\");\r\n importContainer.addGeneratedQObject(idFunctionName);\r\n\r\n serviceFile.addFunction({\r\n name: this.namingHelper.getServiceResolverName(model.name),\r\n isExported: true,\r\n parameters: [\r\n {\r\n name: \"client\",\r\n type: \"ODataClient\",\r\n },\r\n {\r\n name: \"basePath\",\r\n type: \"string\",\r\n },\r\n {\r\n name: \"entityName\",\r\n type: \"string\",\r\n },\r\n ],\r\n statements: [\r\n `return new EntityServiceResolver(client, basePath, entityName, ${idFunctionName}, ${serviceName}, ${collectionName});`,\r\n ],\r\n });\r\n }\r\n\r\n private async generateModelServices() {\r\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\r\n for (const model of this.dataModel.getModels()) {\r\n const serviceName = this.namingHelper.getServiceName(model.name);\r\n const serviceFile = await this.project.createServiceFile(serviceName);\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n // entity type service\r\n await this.generateModelService(model, serviceName, serviceFile, importContainer);\r\n\r\n // entity collection service\r\n await this.generateEntityCollectionService(model, serviceName, serviceFile, importContainer);\r\n\r\n // the resolver function\r\n await this.generateEntityServiceResolver(model, serviceName, serviceFile, importContainer);\r\n\r\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\r\n }\r\n\r\n // build service file for complex types\r\n for (const model of this.dataModel.getComplexTypes()) {\r\n const serviceName = this.namingHelper.getServiceName(model.name);\r\n const serviceFile = await this.project.createServiceFile(serviceName);\r\n const importContainer = new ImportContainer(this.namingHelper.getFileNames());\r\n\r\n // entity type service\r\n await this.generateModelService(model, serviceName, serviceFile, importContainer);\r\n serviceFile.addImportDeclarations(importContainer.getImportDeclarations(true));\r\n }\r\n }\r\n\r\n private generateBoundOperations(operations: Array<OperationType>, importContainer: ImportContainer) {\r\n return operations.reduce<Array<OptionalKind<MethodDeclarationStructure>>>((collector, operation) => {\r\n collector.push(this.generateMethod(operation.name, operation, importContainer));\r\n\r\n return collector;\r\n }, []);\r\n }\r\n\r\n private generateUnboundOperations(\r\n operations: Array<FunctionImportType | ActionImportType>,\r\n importContainer: ImportContainer\r\n ) {\r\n return Object.values(operations).reduce<Array<OptionalKind<MethodDeclarationStructure>>>(\r\n (collector, { name, operation }) => {\r\n collector.push(this.generateMethod(name, operation, importContainer));\r\n\r\n return collector;\r\n },\r\n []\r\n );\r\n }\r\n\r\n private generateMethod(\r\n name: string,\r\n operation: OperationType,\r\n importContainer: ImportContainer\r\n ): OptionalKind<MethodDeclarationStructure> {\r\n const isFunc = operation.type === OperationTypes.Function;\r\n const odataType = operation.returnType?.isCollection\r\n ? RESPONSE_TYPES.collection + this.getVersionSuffix()\r\n : operation.returnType?.dataType === DataTypes.PrimitiveType\r\n ? RESPONSE_TYPES.value + this.getVersionSuffix()\r\n : RESPONSE_TYPES.model + this.getVersionSuffix();\r\n const returnType = operation.returnType;\r\n const requestConfigParam = { name: \"requestConfig\", hasQuestionToken: true, type: \"ODataClientConfig<ClientType>\" };\r\n const hasParams = operation.parameters.length > 0;\r\n\r\n // importing dependencies\r\n importContainer.addFromClientApi(\"ODataClientConfig\", \"ODataResponse\");\r\n importContainer.addFromCore(odataType);\r\n if (returnType?.type) {\r\n if ([DataTypes.EnumType, DataTypes.ModelType, DataTypes.ComplexType].includes(returnType.dataType)) {\r\n importContainer.addGeneratedModel(returnType.type);\r\n }\r\n }\r\n importContainer.addGeneratedQObject(operation.qName);\r\n if (hasParams) {\r\n importContainer.addGeneratedModel(operation.paramsModelName);\r\n }\r\n\r\n const qOpProp = \"this.\" + this.namingHelper.getPrivatePropName(operation.qName);\r\n\r\n return {\r\n scope: Scope.Public,\r\n isAsync: true,\r\n name,\r\n parameters: hasParams\r\n ? [{ name: \"params\", type: operation.paramsModelName }, requestConfigParam]\r\n : [requestConfigParam],\r\n returnType: `ODataResponse<${odataType}<${returnType?.type || \"void\"}>>`,\r\n statements: [\r\n `if(!${qOpProp}) {`,\r\n ` ${qOpProp} = new ${operation.qName}()`,\r\n \"}\",\r\n\r\n `const url = this.addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params\" : \"\"}));`,\r\n `${returnType ? \"const response = await \" : \"return\"} this.client.${\r\n !isFunc\r\n ? // actions: since V4\r\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${requestConfigParam.name})`\r\n : operation.usePost\r\n ? // V2 POST => BUT values are still query params, they are not part of the request body\r\n `post(url, undefined, ${requestConfigParam.name})`\r\n : // functions: since V2\r\n `get(url, ${requestConfigParam.name})`\r\n };`,\r\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\r\n ],\r\n };\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odata2ts/odata2ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,27 +32,26 @@
|
|
|
32
32
|
"LICENSE"
|
|
33
33
|
],
|
|
34
34
|
"keywords": [
|
|
35
|
-
"odata2ts",
|
|
36
|
-
"odata",
|
|
37
|
-
"odata v2",
|
|
38
|
-
"odata v4",
|
|
39
35
|
"odata client",
|
|
40
|
-
"cli",
|
|
41
36
|
"generator",
|
|
42
|
-
"odata client generator",
|
|
43
|
-
"typescript",
|
|
44
37
|
"ts",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
38
|
+
"model",
|
|
39
|
+
"interface",
|
|
40
|
+
"odata",
|
|
41
|
+
"typescript",
|
|
42
|
+
"odata2ts",
|
|
43
|
+
"v2",
|
|
44
|
+
"v4",
|
|
45
|
+
"cli"
|
|
47
46
|
],
|
|
48
47
|
"peerDependencies": {
|
|
49
48
|
"@odata2ts/odata-client-api": "^0.6.3",
|
|
50
|
-
"@odata2ts/odata-query-objects": "^0.17.
|
|
51
|
-
"@odata2ts/odata-service": "^0.13.
|
|
49
|
+
"@odata2ts/odata-query-objects": "^0.17.3",
|
|
50
|
+
"@odata2ts/odata-service": "^0.13.9"
|
|
52
51
|
},
|
|
53
52
|
"dependencies": {
|
|
54
|
-
"@odata2ts/converter-api": "^0.1.
|
|
55
|
-
"@odata2ts/converter-runtime": "^0.1.
|
|
53
|
+
"@odata2ts/converter-api": "^0.1.2",
|
|
54
|
+
"@odata2ts/converter-runtime": "^0.1.5",
|
|
56
55
|
"@odata2ts/odata-core": "^0.3.7",
|
|
57
56
|
"camel-case": "^4.1.2",
|
|
58
57
|
"commander": "^9.1.0",
|
|
@@ -68,13 +67,13 @@
|
|
|
68
67
|
"ts-node": "^10.7.0",
|
|
69
68
|
"tsconfig-loader": "^1.1.0",
|
|
70
69
|
"upper-case-first": "^2.0.2",
|
|
71
|
-
"xml2js": "^0.
|
|
70
|
+
"xml2js": "^0.5.0"
|
|
72
71
|
},
|
|
73
72
|
"devDependencies": {
|
|
74
|
-
"@odata2ts/converter-v2-to-v4": "^0.1.
|
|
73
|
+
"@odata2ts/converter-v2-to-v4": "^0.1.4",
|
|
75
74
|
"@odata2ts/odata-client-api": "^0.6.3",
|
|
76
|
-
"@odata2ts/odata-query-objects": "^0.17.
|
|
77
|
-
"@odata2ts/odata-service": "^0.13.
|
|
75
|
+
"@odata2ts/odata-query-objects": "^0.17.3",
|
|
76
|
+
"@odata2ts/odata-service": "^0.13.9",
|
|
78
77
|
"@types/fs-extra": "^9.0.13",
|
|
79
78
|
"@types/jest": "^27.4.1",
|
|
80
79
|
"@types/node": "^17.0.23",
|
|
@@ -88,6 +87,6 @@
|
|
|
88
87
|
"typescript": "^4.9.4"
|
|
89
88
|
},
|
|
90
89
|
"types": "./lib/index.d.ts",
|
|
91
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "f58b15c1d3239f3a16f56aec2811fa4071b0789e",
|
|
92
91
|
"readme": "README.md"
|
|
93
92
|
}
|