@odata2ts/odata2ts 0.39.2 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/lib/FactoryFunctionModel.d.ts +2 -2
- package/lib/FactoryFunctionModel.js.map +1 -1
- package/lib/OptionModel.d.ts +3 -3
- package/lib/OptionModel.js.map +1 -1
- package/lib/data-model/DataModelDigestion.js +4 -7
- package/lib/data-model/DataModelDigestion.js.map +1 -1
- package/lib/defaultConfig.js +1 -1
- package/lib/defaultConfig.js.map +1 -1
- package/lib/generator/ModelGenerator.js +18 -9
- package/lib/generator/ModelGenerator.js.map +1 -1
- package/lib/generator/QueryObjectGenerator.js +1 -1
- package/lib/generator/QueryObjectGenerator.js.map +1 -1
- package/lib/generator/ServiceGenerator.d.ts +1 -1
- package/lib/generator/ServiceGenerator.js +1 -1
- package/lib/generator/ServiceGenerator.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
### Dependencies
|
|
7
|
+
|
|
8
|
+
* The following workspace dependencies were updated
|
|
9
|
+
* devDependencies
|
|
10
|
+
* @odata2ts/odata-query-objects bumped from ^0.28.0 to ^0.28.1
|
|
11
|
+
* @odata2ts/odata-service bumped from ^0.23.0 to ^0.23.1
|
|
12
|
+
* peerDependencies
|
|
13
|
+
* @odata2ts/odata-query-objects bumped from ^0.28.0 to ^0.28.1
|
|
14
|
+
* @odata2ts/odata-service bumped from ^0.23.0 to ^0.23.1
|
|
15
|
+
|
|
16
|
+
## [0.40.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts-v0.39.2...@odata2ts/odata2ts-v0.40.0) (2025-11-01)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### ⚠ BREAKING CHANGES
|
|
20
|
+
|
|
21
|
+
* **odata2ts:** config option `numericEnum` has been refactored to `enumType`; use `enumType: "numeric"` if you previously used `numericEnum: true`.
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* **odata2ts:** generate enums as string union type ([#367](https://github.com/odata2ts/odata2ts/issues/367)) ([22a5516](https://github.com/odata2ts/odata2ts/commit/22a551671d660fbf915fb4542b62551cf070a260))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Dependencies
|
|
29
|
+
|
|
30
|
+
* The following workspace dependencies were updated
|
|
31
|
+
* devDependencies
|
|
32
|
+
* @odata2ts/odata-query-objects bumped from ^0.27.1 to ^0.28.0
|
|
33
|
+
* @odata2ts/odata-service bumped from ^0.22.2 to ^0.23.0
|
|
34
|
+
* peerDependencies
|
|
35
|
+
* @odata2ts/odata-query-objects bumped from ^0.27.1 to ^0.28.0
|
|
36
|
+
* @odata2ts/odata-service bumped from ^0.22.2 to ^0.23.0
|
|
37
|
+
|
|
6
38
|
## [0.39.2](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts@0.39.1...@odata2ts/odata2ts-v0.39.2) (2025-10-16)
|
|
7
39
|
|
|
8
40
|
|
|
@@ -4,10 +4,10 @@ import { Schema } from "./data-model/edmx/ODataEdmxModelBase.js";
|
|
|
4
4
|
import { NamingHelper } from "./data-model/NamingHelper.js";
|
|
5
5
|
import { RunOptions } from "./OptionModel.js";
|
|
6
6
|
import { ProjectManager } from "./project/ProjectManager.js";
|
|
7
|
-
export type DigestionOptions = Pick<RunOptions, "converters" | "disableAutoManagedKey" | "propertiesByName" | "byTypeAndName" | "v2ModelsWithExtraResultsWrapping" | "v4BigNumberAsString" | "skipEditableModels" | "skipComments" | "disableAutomaticNameClashResolution" | "bundledFileGeneration" | "
|
|
7
|
+
export type DigestionOptions = Pick<RunOptions, "converters" | "disableAutoManagedKey" | "propertiesByName" | "byTypeAndName" | "v2ModelsWithExtraResultsWrapping" | "v4BigNumberAsString" | "skipEditableModels" | "skipComments" | "disableAutomaticNameClashResolution" | "bundledFileGeneration" | "enumType">;
|
|
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: Array<S>, options: DigestionOptions, namingHelper: NamingHelper) => Promise<DataModel>;
|
|
12
|
-
export type GeneratorFunctionOptions = Pick<RunOptions, "skipEditableModels" | "skipIdModels" | "skipOperations" | "skipComments" | "v2ModelsWithExtraResultsWrapping" | "
|
|
12
|
+
export type GeneratorFunctionOptions = Pick<RunOptions, "skipEditableModels" | "skipIdModels" | "skipOperations" | "skipComments" | "v2ModelsWithExtraResultsWrapping" | "enumType">;
|
|
13
13
|
export type EntityBasedGeneratorFunction = (project: ProjectManager, dataModel: DataModel, version: ODataVersions, options: GeneratorFunctionOptions, namingHelper: NamingHelper) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FactoryFunctionModel.js","sourceRoot":"","sources":["../src/FactoryFunctionModel.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport { DataModel } from \"./data-model/DataModel.js\";\nimport { Schema } from \"./data-model/edmx/ODataEdmxModelBase.js\";\nimport { NamingHelper } from \"./data-model/NamingHelper.js\";\nimport { RunOptions } from \"./OptionModel.js\";\nimport { ProjectManager } from \"./project/ProjectManager.js\";\n\nexport type DigestionOptions = Pick<\n RunOptions,\n | \"converters\"\n | \"disableAutoManagedKey\"\n | \"propertiesByName\"\n | \"byTypeAndName\"\n | \"v2ModelsWithExtraResultsWrapping\"\n | \"v4BigNumberAsString\"\n | \"skipEditableModels\"\n | \"skipComments\"\n | \"disableAutomaticNameClashResolution\"\n | \"bundledFileGeneration\"\n | \"
|
|
1
|
+
{"version":3,"file":"FactoryFunctionModel.js","sourceRoot":"","sources":["../src/FactoryFunctionModel.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport { DataModel } from \"./data-model/DataModel.js\";\nimport { Schema } from \"./data-model/edmx/ODataEdmxModelBase.js\";\nimport { NamingHelper } from \"./data-model/NamingHelper.js\";\nimport { RunOptions } from \"./OptionModel.js\";\nimport { ProjectManager } from \"./project/ProjectManager.js\";\n\nexport type DigestionOptions = Pick<\n RunOptions,\n | \"converters\"\n | \"disableAutoManagedKey\"\n | \"propertiesByName\"\n | \"byTypeAndName\"\n | \"v2ModelsWithExtraResultsWrapping\"\n | \"v4BigNumberAsString\"\n | \"skipEditableModels\"\n | \"skipComments\"\n | \"disableAutomaticNameClashResolution\"\n | \"bundledFileGeneration\"\n | \"enumType\"\n>;\n\n/**\n * Takes an EdmxSchema plus the run options and creates a DataModel.\n */\nexport type DigesterFunction<S extends Schema<any, any>> = (\n schema: Array<S>,\n options: DigestionOptions,\n namingHelper: NamingHelper,\n) => Promise<DataModel>;\n\nexport type GeneratorFunctionOptions = Pick<\n RunOptions,\n | \"skipEditableModels\"\n | \"skipIdModels\"\n | \"skipOperations\"\n | \"skipComments\"\n | \"v2ModelsWithExtraResultsWrapping\"\n | \"enumType\"\n>;\n\nexport type EntityBasedGeneratorFunction = (\n project: ProjectManager,\n dataModel: DataModel,\n version: ODataVersions,\n options: GeneratorFunctionOptions,\n namingHelper: NamingHelper,\n) => Promise<void>;\n"]}
|
package/lib/OptionModel.d.ts
CHANGED
|
@@ -254,10 +254,10 @@ export interface ConfigFileOptions extends Omit<CliOptions, "sourceUrl" | "sourc
|
|
|
254
254
|
*/
|
|
255
255
|
bundledFileGeneration?: boolean;
|
|
256
256
|
/**
|
|
257
|
-
*
|
|
258
|
-
*
|
|
257
|
+
* By default, odata2ts generates string enums.
|
|
258
|
+
* With this option you can also generate numeric enums or a simple string union type.
|
|
259
259
|
*/
|
|
260
|
-
|
|
260
|
+
enumType?: "string" | "numeric" | "string-union";
|
|
261
261
|
}
|
|
262
262
|
/**
|
|
263
263
|
* 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":"AAKA;;GAEG;AACH,MAAM,CAAN,IAAY,KAKX;AALD,WAAY,KAAK;IACf,qCAAM,CAAA;IACN,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,+BAAG,CAAA;AACL,CAAC,EALW,KAAK,KAAL,KAAK,QAKhB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\nimport { AxiosRequestConfig } from \"axios\";\nimport { NameSettings, OverridableNamingOptions } from \"./NamingModel.js\";\nimport { TypeModel } from \"./TypeModel.js\";\n\n/**\n * Generation mode, by default \"all\".\n */\nexport enum Modes {\n models,\n qobjects,\n service,\n all,\n}\n\n/**\n * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.\n */\nexport enum EmitModes {\n ts = \"ts\",\n js = \"js\",\n dts = \"dts\",\n js_dts = \"js_dts\",\n}\n\n/**\n * Config options for CLI.\n */\nexport interface CliOptions {\n /**\n * The URL to the root of your OData service. The URL might end in a slash or not, it might also end\n * in $metadata, but we usually add this for you.\n *\n * Specifying the URL is a convenience feature to download the metadata file from the given URL.\n * You can configure this request via `sourceConfig` option.\n *\n * The `source` option must still be specified as it is used to store the downloaded file on your disk.\n * By default, the file is used once it has been downloaded.\n */\n sourceUrl?: string;\n /**\n * Downloads the metadata file and overwrites the existing one, if any.\n *\n * Only takes effect, if option `sourceUrl` is specified.\n */\n refreshFile?: boolean;\n /**\n * The source is the file to use (must be an EDMX compliant XML file) or the URL to the\n * metadata (ROOT_SERVICE/$metadata).\n *\n * If not specified, at least one service must be configured in config file.\n */\n source?: string;\n /**\n * Specifies the output directory for the generated stuff.\n *\n * If not specified, at least one service must be configured in config file.\n */\n output?: string;\n /**\n * Only generates the specified services.\n * Relies on an existing config file where these service names are maintained.\n */\n services?: Array<string>;\n /**\n * Specifies what to generate:\n * - {@code Modes.models} will only generate TS interfaces\n * - {@code Modes.qobjects} will generate functional units used in QueryBuilder and for functions and actions\n * - {@code Modes.service} will generate one main OData service client and one per each entity\n * - {@code Modes.all} the same as {@code Modes.service}\n *\n * QObjects will also generate models, and generating the service client will also generate models and QObjects.\n * Defaults to {@code Modes.all}\n */\n mode?: Modes;\n /**\n * Specifies the type of the output files: TypeScript, JS, DTS only, JS with DTS.\n * Defaults to {@code EmitModes.js_dts}\n */\n emitMode?: EmitModes;\n /**\n * Uses prettier with your local configuration to pretty print TypeScript files.\n * Only applies if mode is set to {@code EmitModes.ts}.\n */\n prettier?: boolean;\n /**\n * When compiling TypeScript to JS, \"tsconfig.json\" is used by default to add compilerOptions.\n * This option allows to specify an alternative file.\n *\n * Only takes effect, when mode is set to anything else than {@code EmitModes.ts}.\n */\n tsconfig?: string;\n /**\n * Verbose debugging information.\n */\n debug?: boolean;\n /**\n * Overrides the service name found in the source file.\n *\n * The service name is the basis for all file names and the name of the main OData client service\n * that serves as entry point for the user.\n */\n serviceName?: string;\n /**\n * odata2ts will automatically decide if a key prop is managed on the server side.\n * If managed, the property will not be editable (create, update, patch).\n * The following rule applies:\n * If a property is the only key prop of an entity, then the prop is deemed to be managed;\n * in ony other case the prop is unmanaged.\n */\n disableAutoManagedKey?: boolean;\n /**\n * By default, odata2ts doesn't change param, operation, property or model names.\n * The generated models and their properties are named exactly as advertised by the server.\n *\n * By allowing odata2ts to change these names, certain predefined formatting strategies are used:\n * Model / class names are formatted with PascalCase; property, param, and operation names with camelCase.\n *\n * The naming configuration allows to control this and other naming related settings.\n * Note: Even if renaming is disabled, model prefixing / suffixing still applies.\n */\n allowRenaming?: boolean;\n}\n\n/**\n * Configuration options of the request to retrieve the metadata.\n * Only takes effect if `source` is a URL.\n */\nexport interface UrlSourceConfiguration {\n /**\n * Basic auth credentials: the username.\n * Only takes effect if `password` has also been set.\n */\n username?: string;\n /**\n * Basic auth credentials: the password.\n * Only takes effect if `username` has also been set.\n */\n password?: string;\n /**\n * Custom request configuration.\n * URL and method `GET` are set by default, but can be overwritten.\n */\n custom?: AxiosRequestConfig;\n}\n\n/**\n * Available options for configuration files, i.e. odata2ts.config.ts.\n */\nexport interface ConfigFileOptions extends Omit<CliOptions, \"sourceUrl\" | \"source\" | \"output\" | \"services\"> {\n /**\n * Configuration options of the request to retrieve the metadata.\n * Only takes effect if `sourceUrl` is a URL.\n */\n sourceUrlConfig?: UrlSourceConfiguration;\n\n /**\n * Configuration of each service.\n *\n * @example { services: { trippin: { source: \"...\", ... } }}\n */\n services?: { [serviceName: string]: ServiceGenerationOptions };\n\n /**\n * Specify which converters to use by their package name, e.g. \"@odata2ts/converter-v2-to-v4\".\n * Each converter knows which data type to map.\n *\n * To only use specific converters, the object syntax must be used, where supported converters\n * must be listed by their ids.\n */\n converters?: Array<string | TypeConverterConfig>;\n\n /**\n * For each model an editable version is generated which represents the model definition for\n * create, update and patch actions.\n *\n * You can skip the generation altogether, not generating editable model variants,\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\n */\n skipEditableModels?: boolean;\n\n /**\n * ID models are generated from entity id parameters.\n * The generation for one entity entails one model interface representing the id parameters and\n * one QId function which allows to format the parameters for URL usage and to parse parameters\n * from a URL string.\n *\n * You can skip the generation altogether, not generating models and QId objects, if the\n * generation mode is {@code Mode.model} or {@code Mode.qobject}.\n */\n skipIdModels?: boolean;\n /**\n * Operations are functions and actions of the OData service.\n * The generation for one operation entails one parameter model interface\n * and one QFunction / QAction class.\n *\n * You can skip the generation altogether, neither generating model nor query object,\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\n */\n skipOperations?: boolean;\n /**\n * Model properties have explaining comments by default.\n * With this option you can turn that off.\n */\n skipComments?: boolean;\n /**\n * With OData you can read, update and delete data on a primitive property (`Edm.*`).\n * Usually, you wouldn't do that, but go for a bigger request, fetching more relevant information in one go.\n *\n * There's one exception: Handling `Edm.Stream´ properties and Media entities. Services for stream / media\n * stuff are generated regardless of this setting.\n */\n enablePrimitivePropertyServices?: boolean;\n\n /**\n * The naming options regarding the generated artefacts.\n */\n naming?: OverridableNamingOptions;\n\n /**\n * Some OData V2 services generate an extra wrapping for entity collection attributes:\n * <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities\n * an object with the property \"results\" is wrapped around the entity collection.\n *\n * If you're using the odata client then there's a build-in workaround in place which transforms\n * the results to remove this extra mapping. However, if you're only interested in the types, then\n * the generated models will not match that extra wrapping.\n *\n * Setting this configuration option to <code>true</code> (default: false) will add this extra\n * wrapping to the generated models. But this option is only valid if the generation mode is set\n * to <code>models</code>; it is ignored otherwise.\n */\n v2ModelsWithExtraResultsWrapping?: boolean;\n /**\n * Numbers of type `Edm.Int64` and `Edm.Decimal` are represented as `number` in V4.\n * However, these numbers might not fit into JS' number type, which might result in precision loss.\n *\n * OData offers a special IEEE754 format option to get those types as `string` instead to prevent any\n * precision loss. So if you're handling very large or very small numbers (JS roughly supports 15 digits),\n * then you should use this option and, probably, also an appropriate converter (see available converters).\n *\n * Activating this option affects the type generation and will use `string` for both mentioned types.\n * All requests are executed with the \"accept\" header set to \"application/json;IEEE754Compatible=true\".\n * Additionally, when sending data the very same value will be set for the \"content-type\" header.\n */\n v4BigNumberAsString?: boolean;\n /**\n * OData allows for namespaces so any entity is unique by virtue of it's name within a namespace.\n * odata2ts works with these fully qualified names internally, but only uses the plain name when generating\n * stuff. This might lead to name clashes (same name in different namespaces).\n *\n * odata2ts employs a simple, automatic resolution strategy: Adding a counter at the end of the name.\n * Set this property to true in order to disable this automatism.\n */\n disableAutomaticNameClashResolution?: boolean;\n /**\n * By default, odata2ts generates a folder structure with individual files per entity.\n * This allows for handling and scaling the generation process for large data structures.\n *\n * However, especially UI5 has problems with recursive structures, which are absolutely valid within\n * OData. Here the solution is to generate only one file per type to circumvent cyclic imports.\n * To enable this behaviour set this option to true.\n */\n bundledFileGeneration?: boolean;\n /**\n * If enabled, odata2ts will generate numeric enums instead of string enums.\n * This\n */\n numericEnums?: boolean;\n}\n\n/**\n * Custom generation options which are dependent on a specific odata service.\n */\nexport interface ServiceGenerationOptions\n extends Required<Pick<CliOptions, \"source\" | \"output\">>,\n Pick<CliOptions, \"sourceUrl\" | \"refreshFile\">,\n Omit<ConfigFileOptions, \"services\"> {\n /**\n * Configure generation process for individual properties based on their name.\n */\n propertiesByName?: Array<PropertyGenerationOptions>;\n /**\n * Rename any EntityType, ComplexType, EnumType, Function or Action.\n *\n * You must match the simple name (e.g. \"Person\") or the fully qualified name\n * (e.g. \"Trippin.Person\") exactly. Alternatively, you can rename a bunch of types\n * by using regular expressions.\n *\n * By providing additional type information via the \"type\" attribute you get even more options which only apply\n * to the given type.\n */\n byTypeAndName?: Array<ComplexTypeGenerationOptions | EntityTypeGenerationOptions | GenericTypeGenerationOptions>;\n}\n\n/**\n * Available options for the actual generation run.\n * Every property is required, except the overriding service name.\n */\nexport interface RunOptions\n extends Required<Omit<ServiceGenerationOptions, \"serviceName\" | \"sourceUrl\" | \"sourceUrlConfig\" | \"refreshFile\">>,\n Pick<ServiceGenerationOptions, \"serviceName\" | \"sourceUrl\" | \"sourceUrlConfig\" | \"refreshFile\"> {\n naming: NameSettings;\n}\n\nexport interface RenameOptions {\n /**\n * Matcher for the name of any EntityType, ComplexType, EnumType, Function or Action\n * as it is stated in the EDMX model, e.g. \"Person\". As OData supports namespaces\n * you can also use the fully qualified name (including the namespace) to address any model,\n * e.g. \"Trippin.Person\". You can also match properties by their name.\n *\n * If the name is specified as plain string, it must match either the name or the fully qualified name\n * exactly (case-sensitive).\n *\n * Alternatively, a regular expression can be used which is always applied to the fully qualified name\n * (e.g. Trippin.Person). The regular expression must match the whole string\n * (e.g. `/Person/` won't do, `/.*\\.Person/` would work).\n *\n * To make regular expressions useful, captured groups are also supported in combination with\n * the `mappedName` attribute.\n */\n name: string | RegExp;\n\n /**\n * If specified, this attribute value is used as final name for the matched name as it will\n * appear in the generated typescript.\n *\n * When using a regular expression for matching the name, then captured groups can be referenced\n * as usual via $1, $2, etc. For example:\n * - name: /Trippin\\.(.+)/\n * - mappedName: \"T_$1\"\n * The result would be \"T_Person\".\n */\n mappedName?: string;\n}\n\nexport type TypeBasedGenerationOptions =\n | GenericTypeGenerationOptions\n | ComplexTypeGenerationOptions\n | EntityTypeGenerationOptions;\n\nexport interface GenericTypeGenerationOptions extends RenameOptions {\n type:\n | TypeModel.Any\n | TypeModel.EnumType\n | TypeModel.OperationType\n | TypeModel.OperationImportType\n | TypeModel.Singleton\n | TypeModel.EntitySet;\n}\n\nexport interface ComplexTypeGenerationOptions extends RenameOptions {\n type: TypeModel.ComplexType;\n\n /**\n * Configuration of individual properties.\n */\n properties?: Array<PropertyGenerationOptions>;\n\n // converter: string | Array<string>\n}\n\n/**\n * Configuration options for EntityTypes and ComplexTypes.\n * This config applies if the name matches the name of an EntityType or ComplexType as it is specified\n * in the metadata (e.g. in EDMX <EntityType name=\"Test\" ...)\n */\nexport interface EntityTypeGenerationOptions extends Omit<ComplexTypeGenerationOptions, \"type\"> {\n type: TypeModel.EntityType;\n\n /**\n * Overwrite the key specification by naming the props by their EDMX name.\n */\n keys?: Array<string>;\n\n /**\n * Whether the generated service should allow for querying this model.\n * True by default.\n */\n // queryable?: boolean;\n /**\n * Whether the generated service should allow for creating new models (POST).\n * True by default.\n */\n // creatable?: boolean;\n /**\n * Whether the generated service should allow for updates (PUT).\n * True by default.\n */\n // updatable?: boolean;\n /**\n * Whether the generated service should allow for partial updates (PATCH).\n * True by default.\n */\n // patchable?: boolean;\n /**\n * Whether the generated service should allow for deletion.\n * True by default.\n */\n // deletable?: boolean;\n}\n\n/**\n * All configuration options for properties of models.\n */\nexport interface PropertyGenerationOptions extends RenameOptions {\n /**\n * Managed attributes - i.e. managed by the server - cannot be created or updated.\n * Hence, they are left out of the editable model versions.\n */\n managed?: boolean;\n\n /**\n * TODO\n *\n * Each converter must specify its package name, e.g. \"@odata2ts/converter-v2-to-v4\",\n * as well it's i\n * and their ids, e.g. \"timeToDurationConverter\".\n *\n * To only use specific converters, the object syntax must be used, where supported converters\n * must be listed by their ids.\n */\n // converters?: Array<Required<TypeConverterConfig>>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"OptionModel.js","sourceRoot":"","sources":["../src/OptionModel.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,CAAN,IAAY,KAKX;AALD,WAAY,KAAK;IACf,qCAAM,CAAA;IACN,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,+BAAG,CAAA;AACL,CAAC,EALW,KAAK,KAAL,KAAK,QAKhB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB","sourcesContent":["import { TypeConverterConfig } from \"@odata2ts/converter-runtime\";\nimport { AxiosRequestConfig } from \"axios\";\nimport { NameSettings, OverridableNamingOptions } from \"./NamingModel.js\";\nimport { TypeModel } from \"./TypeModel.js\";\n\n/**\n * Generation mode, by default \"all\".\n */\nexport enum Modes {\n models,\n qobjects,\n service,\n all,\n}\n\n/**\n * What kind of stuff to emit: Either raw TS or TS that has been compiled to JS / DTS.\n */\nexport enum EmitModes {\n ts = \"ts\",\n js = \"js\",\n dts = \"dts\",\n js_dts = \"js_dts\",\n}\n\n/**\n * Config options for CLI.\n */\nexport interface CliOptions {\n /**\n * The URL to the root of your OData service. The URL might end in a slash or not, it might also end\n * in $metadata, but we usually add this for you.\n *\n * Specifying the URL is a convenience feature to download the metadata file from the given URL.\n * You can configure this request via `sourceConfig` option.\n *\n * The `source` option must still be specified as it is used to store the downloaded file on your disk.\n * By default, the file is used once it has been downloaded.\n */\n sourceUrl?: string;\n /**\n * Downloads the metadata file and overwrites the existing one, if any.\n *\n * Only takes effect, if option `sourceUrl` is specified.\n */\n refreshFile?: boolean;\n /**\n * The source is the file to use (must be an EDMX compliant XML file) or the URL to the\n * metadata (ROOT_SERVICE/$metadata).\n *\n * If not specified, at least one service must be configured in config file.\n */\n source?: string;\n /**\n * Specifies the output directory for the generated stuff.\n *\n * If not specified, at least one service must be configured in config file.\n */\n output?: string;\n /**\n * Only generates the specified services.\n * Relies on an existing config file where these service names are maintained.\n */\n services?: Array<string>;\n /**\n * Specifies what to generate:\n * - {@code Modes.models} will only generate TS interfaces\n * - {@code Modes.qobjects} will generate functional units used in QueryBuilder and for functions and actions\n * - {@code Modes.service} will generate one main OData service client and one per each entity\n * - {@code Modes.all} the same as {@code Modes.service}\n *\n * QObjects will also generate models, and generating the service client will also generate models and QObjects.\n * Defaults to {@code Modes.all}\n */\n mode?: Modes;\n /**\n * Specifies the type of the output files: TypeScript, JS, DTS only, JS with DTS.\n * Defaults to {@code EmitModes.js_dts}\n */\n emitMode?: EmitModes;\n /**\n * Uses prettier with your local configuration to pretty print TypeScript files.\n * Only applies if mode is set to {@code EmitModes.ts}.\n */\n prettier?: boolean;\n /**\n * When compiling TypeScript to JS, \"tsconfig.json\" is used by default to add compilerOptions.\n * This option allows to specify an alternative file.\n *\n * Only takes effect, when mode is set to anything else than {@code EmitModes.ts}.\n */\n tsconfig?: string;\n /**\n * Verbose debugging information.\n */\n debug?: boolean;\n /**\n * Overrides the service name found in the source file.\n *\n * The service name is the basis for all file names and the name of the main OData client service\n * that serves as entry point for the user.\n */\n serviceName?: string;\n /**\n * odata2ts will automatically decide if a key prop is managed on the server side.\n * If managed, the property will not be editable (create, update, patch).\n * The following rule applies:\n * If a property is the only key prop of an entity, then the prop is deemed to be managed;\n * in ony other case the prop is unmanaged.\n */\n disableAutoManagedKey?: boolean;\n /**\n * By default, odata2ts doesn't change param, operation, property or model names.\n * The generated models and their properties are named exactly as advertised by the server.\n *\n * By allowing odata2ts to change these names, certain predefined formatting strategies are used:\n * Model / class names are formatted with PascalCase; property, param, and operation names with camelCase.\n *\n * The naming configuration allows to control this and other naming related settings.\n * Note: Even if renaming is disabled, model prefixing / suffixing still applies.\n */\n allowRenaming?: boolean;\n}\n\n/**\n * Configuration options of the request to retrieve the metadata.\n * Only takes effect if `source` is a URL.\n */\nexport interface UrlSourceConfiguration {\n /**\n * Basic auth credentials: the username.\n * Only takes effect if `password` has also been set.\n */\n username?: string;\n /**\n * Basic auth credentials: the password.\n * Only takes effect if `username` has also been set.\n */\n password?: string;\n /**\n * Custom request configuration.\n * URL and method `GET` are set by default, but can be overwritten.\n */\n custom?: AxiosRequestConfig;\n}\n\n/**\n * Available options for configuration files, i.e. odata2ts.config.ts.\n */\nexport interface ConfigFileOptions extends Omit<CliOptions, \"sourceUrl\" | \"source\" | \"output\" | \"services\"> {\n /**\n * Configuration options of the request to retrieve the metadata.\n * Only takes effect if `sourceUrl` is a URL.\n */\n sourceUrlConfig?: UrlSourceConfiguration;\n\n /**\n * Configuration of each service.\n *\n * @example { services: { trippin: { source: \"...\", ... } }}\n */\n services?: { [serviceName: string]: ServiceGenerationOptions };\n\n /**\n * Specify which converters to use by their package name, e.g. \"@odata2ts/converter-v2-to-v4\".\n * Each converter knows which data type to map.\n *\n * To only use specific converters, the object syntax must be used, where supported converters\n * must be listed by their ids.\n */\n converters?: Array<string | TypeConverterConfig>;\n\n /**\n * For each model an editable version is generated which represents the model definition for\n * create, update and patch actions.\n *\n * You can skip the generation altogether, not generating editable model variants,\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\n */\n skipEditableModels?: boolean;\n\n /**\n * ID models are generated from entity id parameters.\n * The generation for one entity entails one model interface representing the id parameters and\n * one QId function which allows to format the parameters for URL usage and to parse parameters\n * from a URL string.\n *\n * You can skip the generation altogether, not generating models and QId objects, if the\n * generation mode is {@code Mode.model} or {@code Mode.qobject}.\n */\n skipIdModels?: boolean;\n /**\n * Operations are functions and actions of the OData service.\n * The generation for one operation entails one parameter model interface\n * and one QFunction / QAction class.\n *\n * You can skip the generation altogether, neither generating model nor query object,\n * if the generation mode is {@code Mode.model} or {@code Mode.qobject}.\n */\n skipOperations?: boolean;\n /**\n * Model properties have explaining comments by default.\n * With this option you can turn that off.\n */\n skipComments?: boolean;\n /**\n * With OData you can read, update and delete data on a primitive property (`Edm.*`).\n * Usually, you wouldn't do that, but go for a bigger request, fetching more relevant information in one go.\n *\n * There's one exception: Handling `Edm.Stream´ properties and Media entities. Services for stream / media\n * stuff are generated regardless of this setting.\n */\n enablePrimitivePropertyServices?: boolean;\n\n /**\n * The naming options regarding the generated artefacts.\n */\n naming?: OverridableNamingOptions;\n\n /**\n * Some OData V2 services generate an extra wrapping for entity collection attributes:\n * <code>trips: {results: [...]}</code>. So instead of directly returning an array of entities\n * an object with the property \"results\" is wrapped around the entity collection.\n *\n * If you're using the odata client then there's a build-in workaround in place which transforms\n * the results to remove this extra mapping. However, if you're only interested in the types, then\n * the generated models will not match that extra wrapping.\n *\n * Setting this configuration option to <code>true</code> (default: false) will add this extra\n * wrapping to the generated models. But this option is only valid if the generation mode is set\n * to <code>models</code>; it is ignored otherwise.\n */\n v2ModelsWithExtraResultsWrapping?: boolean;\n /**\n * Numbers of type `Edm.Int64` and `Edm.Decimal` are represented as `number` in V4.\n * However, these numbers might not fit into JS' number type, which might result in precision loss.\n *\n * OData offers a special IEEE754 format option to get those types as `string` instead to prevent any\n * precision loss. So if you're handling very large or very small numbers (JS roughly supports 15 digits),\n * then you should use this option and, probably, also an appropriate converter (see available converters).\n *\n * Activating this option affects the type generation and will use `string` for both mentioned types.\n * All requests are executed with the \"accept\" header set to \"application/json;IEEE754Compatible=true\".\n * Additionally, when sending data the very same value will be set for the \"content-type\" header.\n */\n v4BigNumberAsString?: boolean;\n /**\n * OData allows for namespaces so any entity is unique by virtue of it's name within a namespace.\n * odata2ts works with these fully qualified names internally, but only uses the plain name when generating\n * stuff. This might lead to name clashes (same name in different namespaces).\n *\n * odata2ts employs a simple, automatic resolution strategy: Adding a counter at the end of the name.\n * Set this property to true in order to disable this automatism.\n */\n disableAutomaticNameClashResolution?: boolean;\n /**\n * By default, odata2ts generates a folder structure with individual files per entity.\n * This allows for handling and scaling the generation process for large data structures.\n *\n * However, especially UI5 has problems with recursive structures, which are absolutely valid within\n * OData. Here the solution is to generate only one file per type to circumvent cyclic imports.\n * To enable this behaviour set this option to true.\n */\n bundledFileGeneration?: boolean;\n /**\n * By default, odata2ts generates string enums.\n * With this option you can also generate numeric enums or a simple string union type.\n */\n enumType?: \"string\" | \"numeric\" | \"string-union\";\n}\n\n/**\n * Custom generation options which are dependent on a specific odata service.\n */\nexport interface ServiceGenerationOptions\n extends Required<Pick<CliOptions, \"source\" | \"output\">>,\n Pick<CliOptions, \"sourceUrl\" | \"refreshFile\">,\n Omit<ConfigFileOptions, \"services\"> {\n /**\n * Configure generation process for individual properties based on their name.\n */\n propertiesByName?: Array<PropertyGenerationOptions>;\n /**\n * Rename any EntityType, ComplexType, EnumType, Function or Action.\n *\n * You must match the simple name (e.g. \"Person\") or the fully qualified name\n * (e.g. \"Trippin.Person\") exactly. Alternatively, you can rename a bunch of types\n * by using regular expressions.\n *\n * By providing additional type information via the \"type\" attribute you get even more options which only apply\n * to the given type.\n */\n byTypeAndName?: Array<ComplexTypeGenerationOptions | EntityTypeGenerationOptions | GenericTypeGenerationOptions>;\n}\n\n/**\n * Available options for the actual generation run.\n * Every property is required, except the overriding service name.\n */\nexport interface RunOptions\n extends Required<Omit<ServiceGenerationOptions, \"serviceName\" | \"sourceUrl\" | \"sourceUrlConfig\" | \"refreshFile\">>,\n Pick<ServiceGenerationOptions, \"serviceName\" | \"sourceUrl\" | \"sourceUrlConfig\" | \"refreshFile\"> {\n naming: NameSettings;\n}\n\nexport interface RenameOptions {\n /**\n * Matcher for the name of any EntityType, ComplexType, EnumType, Function or Action\n * as it is stated in the EDMX model, e.g. \"Person\". As OData supports namespaces\n * you can also use the fully qualified name (including the namespace) to address any model,\n * e.g. \"Trippin.Person\". You can also match properties by their name.\n *\n * If the name is specified as plain string, it must match either the name or the fully qualified name\n * exactly (case-sensitive).\n *\n * Alternatively, a regular expression can be used which is always applied to the fully qualified name\n * (e.g. Trippin.Person). The regular expression must match the whole string\n * (e.g. `/Person/` won't do, `/.*\\.Person/` would work).\n *\n * To make regular expressions useful, captured groups are also supported in combination with\n * the `mappedName` attribute.\n */\n name: string | RegExp;\n\n /**\n * If specified, this attribute value is used as final name for the matched name as it will\n * appear in the generated typescript.\n *\n * When using a regular expression for matching the name, then captured groups can be referenced\n * as usual via $1, $2, etc. For example:\n * - name: /Trippin\\.(.+)/\n * - mappedName: \"T_$1\"\n * The result would be \"T_Person\".\n */\n mappedName?: string;\n}\n\nexport type TypeBasedGenerationOptions =\n | GenericTypeGenerationOptions\n | ComplexTypeGenerationOptions\n | EntityTypeGenerationOptions;\n\nexport interface GenericTypeGenerationOptions extends RenameOptions {\n type:\n | TypeModel.Any\n | TypeModel.EnumType\n | TypeModel.OperationType\n | TypeModel.OperationImportType\n | TypeModel.Singleton\n | TypeModel.EntitySet;\n}\n\nexport interface ComplexTypeGenerationOptions extends RenameOptions {\n type: TypeModel.ComplexType;\n\n /**\n * Configuration of individual properties.\n */\n properties?: Array<PropertyGenerationOptions>;\n\n // converter: string | Array<string>\n}\n\n/**\n * Configuration options for EntityTypes and ComplexTypes.\n * This config applies if the name matches the name of an EntityType or ComplexType as it is specified\n * in the metadata (e.g. in EDMX <EntityType name=\"Test\" ...)\n */\nexport interface EntityTypeGenerationOptions extends Omit<ComplexTypeGenerationOptions, \"type\"> {\n type: TypeModel.EntityType;\n\n /**\n * Overwrite the key specification by naming the props by their EDMX name.\n */\n keys?: Array<string>;\n\n /**\n * Whether the generated service should allow for querying this model.\n * True by default.\n */\n // queryable?: boolean;\n /**\n * Whether the generated service should allow for creating new models (POST).\n * True by default.\n */\n // creatable?: boolean;\n /**\n * Whether the generated service should allow for updates (PUT).\n * True by default.\n */\n // updatable?: boolean;\n /**\n * Whether the generated service should allow for partial updates (PATCH).\n * True by default.\n */\n // patchable?: boolean;\n /**\n * Whether the generated service should allow for deletion.\n * True by default.\n */\n // deletable?: boolean;\n}\n\n/**\n * All configuration options for properties of models.\n */\nexport interface PropertyGenerationOptions extends RenameOptions {\n /**\n * Managed attributes - i.e. managed by the server - cannot be created or updated.\n * Hence, they are left out of the editable model versions.\n */\n managed?: boolean;\n\n /**\n * TODO\n *\n * Each converter must specify its package name, e.g. \"@odata2ts/converter-v2-to-v4\",\n * as well it's i\n * and their ids, e.g. \"timeToDurationConverter\".\n *\n * To only use specific converters, the object syntax must be used, where supported converters\n * must be listed by their ids.\n */\n // converters?: Array<Required<TypeConverterConfig>>;\n}\n"]}
|
|
@@ -48,17 +48,14 @@ export class Digester {
|
|
|
48
48
|
}
|
|
49
49
|
// special handling for enums
|
|
50
50
|
if (modelType === "EnumType" /* DataTypes.EnumType */) {
|
|
51
|
+
const isNumericEnum = this.options.enumType === "numeric";
|
|
51
52
|
const enumConfig = this.serviceConfigHelper.findEnumTypeConfig(dataTypeNamespace, dataTypeName);
|
|
52
53
|
result = {
|
|
53
54
|
dataType: modelType,
|
|
54
55
|
type: this.namingHelper.getEnumName((_a = enumConfig === null || enumConfig === void 0 ? void 0 : enumConfig.mappedName) !== null && _a !== void 0 ? _a : odataDataType),
|
|
55
|
-
qPath:
|
|
56
|
-
qObject: isCollection
|
|
57
|
-
|
|
58
|
-
? "QNumericEnumCollection"
|
|
59
|
-
: "QEnumCollection"
|
|
60
|
-
: undefined,
|
|
61
|
-
qParam: this.options.numericEnums ? "QNumericEnumParam" : "QEnumParam",
|
|
56
|
+
qPath: isNumericEnum ? "QNumericEnumPath" : "QEnumPath",
|
|
57
|
+
qObject: isCollection ? (isNumericEnum ? "QNumericEnumCollection" : "QEnumCollection") : undefined,
|
|
58
|
+
qParam: isNumericEnum ? "QNumericEnumParam" : "QEnumParam",
|
|
62
59
|
};
|
|
63
60
|
}
|
|
64
61
|
// handling of complex & entity types
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataModelDigestion.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestion.ts"],"names":[],"mappings":";AAEA,OAAO,EAGL,KAAK,GAEN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAsB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAY9E,OAAO,EAAE,mBAAmB,EAAe,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAQ9D,SAAS,MAAM,CAAC,KAAyB;IACvC,OAAO,KAAK,KAAK,MAAM,CAAC;AAC1B,CAAC;AAED,SAAS,OAAO,CAAC,KAAyB;IACxC,OAAO,KAAK,KAAK,OAAO,CAAC;AAC3B,CAAC;AASD,MAAM,OAAgB,QAAQ;IAY5B,YACY,OAAqB,EACrB,OAAiB,EACjB,OAAyB,EACzB,YAA0B,EACpC,UAAkC;QAJxB,YAAO,GAAP,OAAO,CAAc;QACrB,YAAO,GAAP,OAAO,CAAU;QACjB,YAAO,GAAP,OAAO,CAAkB;QACzB,iBAAY,GAAZ,YAAY,CAAc;QATtC;;WAEG;QACK,eAAU,GAAG,IAAI,GAAG,EAAqB,CAAC;QAsYxC,YAAO,GAAG,CAAC,CAAW,EAAE,gBAAwD,EAAiB,EAAE;;YAC3G,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;aAC1E;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC3E,MAAM,SAAS,GAAG,I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AC,QAAQ,CAAC,IAAI,CAAC,CAAC;aACpE;YACD,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YAEzD,YAAY;YACZ,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAChC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;;AAtgBgB,mBAAU,GAAG,MAAM,AAAT,CAAU","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\nimport type { DigestionOptions } from \"../FactoryFunctionModel.js\";\nimport {\n ComplexTypeGenerationOptions,\n EntityTypeGenerationOptions,\n Modes,\n PropertyGenerationOptions,\n} from \"../OptionModel.js\";\nimport { DataModel, NamespaceWithAlias, withNamespace } from \"./DataModel.js\";\nimport {\n ComplexType as ComplexModelType,\n DataTypes,\n EntityType as EntityModelType,\n ODataVersion,\n PropertyModel,\n} from \"./DataTypeModel.js\";\nimport { ComplexType, EntityType, EnumType, Property, Schema, TypeDefinition } from \"./edmx/ODataEdmxModelBase.js\";\nimport { EntityContainerV3, SchemaV3 } from \"./edmx/ODataEdmxModelV3.js\";\nimport { EntityContainerV4, SchemaV4 } from \"./edmx/ODataEdmxModelV4.js\";\nimport { NamingHelper } from \"./NamingHelper.js\";\nimport { ServiceConfigHelper, WithoutName } from \"./ServiceConfigHelper.js\";\nimport { NameClashValidator } from \"./validation/NameClashValidator.js\";\nimport { NameValidator } from \"./validation/NameValidator.js\";\nimport { NoopValidator } from \"./validation/NoopValidator.js\";\n\ntype CollectorTuple = [\n Array<PropertyModel>,\n Array<string>,\n { fqIdName: string; idName: string; qIdName: string; open: boolean },\n];\n\nfunction ifTrue(value: string | undefined): boolean {\n return value === \"true\";\n}\n\nfunction ifFalse(value: string | undefined): boolean {\n return value === \"false\";\n}\n\nexport interface TypeModel {\n outputType: string;\n qPath: string;\n qCollection: string;\n qParam: string | undefined;\n}\n\nexport abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {\n protected static EDM_PREFIX = \"Edm.\";\n\n protected readonly dataModel: DataModel;\n protected readonly serviceConfigHelper: ServiceConfigHelper;\n protected readonly nameValidator: NameValidator;\n\n /**\n * Reverse mapping from fqName to data type: EntityType, ComplexType, EnumType, or Primitive Type.\n */\n private model2Type = new Map<string, DataTypes>();\n\n protected constructor(\n protected version: ODataVersion,\n protected schemas: Array<S>,\n protected options: DigestionOptions,\n protected namingHelper: NamingHelper,\n converters?: MappedConverterChains,\n ) {\n const namespaces = schemas.map<NamespaceWithAlias>((s) => [s.$.Namespace, s.$.Alias]);\n this.dataModel = new DataModel(namespaces, version, converters);\n this.serviceConfigHelper = new ServiceConfigHelper(options);\n this.nameValidator = options.bundledFileGeneration ? new NameClashValidator(options) : new NoopValidator();\n\n this.collectModelTypes(schemas);\n }\n\n private collectModelTypes(schemas: Array<S>) {\n schemas.forEach((schema) => {\n const { Namespace: ns, Alias: alias } = schema.$;\n\n schema.EnumType?.forEach((et) => {\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.EnumType);\n });\n schema.ComplexType?.forEach((ct) => {\n this.addModel2Type(ns, alias, ct.$.Name, DataTypes.ComplexType);\n });\n schema.EntityType?.forEach((et) => {\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.ModelType);\n });\n });\n }\n\n private addModel2Type(ns: string, alias: string | undefined, name: string, dt: DataTypes) {\n this.model2Type.set(withNamespace(ns, name), dt);\n if (alias) {\n this.model2Type.set(withNamespace(alias, name), dt);\n }\n }\n\n protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;\n\n protected abstract digestOperations(schema: SchemaV3 | SchemaV4): void;\n\n protected abstract digestEntityContainer(schema: SchemaV3 | SchemaV4): void;\n\n /**\n * Get essential infos about a given odata type from the version specific service variants.\n *\n * @param type\n * @return tuple of return type, query object, query collection object\n */\n protected abstract mapODataType(type: string): TypeModel;\n\n public async digest(): Promise<DataModel> {\n this.digestEntityTypesAndOperations();\n\n // delegate to version specific entity container digestion\n this.schemas.forEach((schema) => this.digestEntityContainer(schema));\n\n this.dataModel.setNameValidation(this.nameValidator.validate());\n return this.dataModel;\n }\n\n private digestEntityTypesAndOperations() {\n this.schemas.forEach((schema) => {\n const ns: NamespaceWithAlias = [schema.$.Namespace, schema.$.Alias];\n\n // type definitions: alias for primitive types\n this.addTypeDefinition(schema.$.Namespace, schema.TypeDefinition);\n\n // enums\n this.addEnum(ns, schema.EnumType);\n\n // complex types\n this.addComplexType(ns, schema.ComplexType);\n\n // entity types\n this.addEntityType(ns, schema.EntityType);\n\n // V4 only: function & action types\n this.digestOperations(schema);\n });\n\n this.postProcessModel();\n this.postProcessKeys();\n\n this.schemas.forEach((schema) => {\n this.analyzeModelUsage(schema.EntityContainer?.length ? schema.EntityContainer[0] : undefined);\n });\n }\n\n private getBaseModel(\n entityConfig: WithoutName<EntityTypeGenerationOptions | ComplexTypeGenerationOptions> | undefined,\n model: ComplexType,\n namespace: string,\n name: string,\n fqName: string,\n ) {\n const odataName = model.$.Name;\n\n // map properties respecting the config\n const props = [...(model.Property ?? []), ...this.getNavigationProps(model)].map((p) => {\n const epConfig = entityConfig?.properties?.find((ep) => ep.name === p.$.Name);\n return this.mapProp(p, epConfig);\n });\n\n // support for base types, i.e. extends clause of interfaces\n const baseClasses = [];\n let finalBaseClass: string | undefined = undefined;\n if (model.$.BaseType) {\n baseClasses.push(model.$.BaseType);\n const [baseName, basePrefix] = this.namingHelper.getNameAndServicePrefix(model.$.BaseType);\n const baseConfig =\n this.serviceConfigHelper.findEntityTypeConfig([basePrefix!], baseName) ||\n this.serviceConfigHelper.findComplexTypeConfig([basePrefix!], baseName);\n finalBaseClass = baseConfig?.mappedName ?? baseName;\n }\n\n return {\n fqName,\n odataName,\n name,\n modelName: this.namingHelper.getModelName(name),\n qName: this.namingHelper.getQName(name),\n editableName: this.namingHelper.getEditableModelName(name),\n serviceName: this.namingHelper.getServiceName(name),\n serviceCollectionName: this.namingHelper.getCollectionServiceName(name),\n folderPath: this.namingHelper.getFolderPath(namespace, name),\n baseClasses,\n finalBaseClass,\n props,\n baseProps: [], // postprocess required\n abstract: ifTrue(model.$.Abstract),\n open: ifTrue(model.$.OpenType),\n genMode: Modes.qobjects,\n subtypes: new Set(),\n } satisfies Partial<ComplexModelType>;\n }\n\n private addTypeDefinition(ns: string, types: Array<TypeDefinition> | undefined) {\n if (!types || !types.length) {\n return;\n }\n\n for (const t of types) {\n this.dataModel.addTypeDefinition(ns, t.$.Name, t.$.UnderlyingType);\n }\n }\n\n private addEnum(namespace: NamespaceWithAlias, models: Array<EnumType> | undefined) {\n if (!models || !models.length) {\n return;\n }\n\n for (const et of models) {\n const odataName = et.$.Name;\n const fqName = withNamespace(namespace[0], odataName);\n const config = this.serviceConfigHelper.findEnumTypeConfig(namespace, odataName);\n const enumName = this.nameValidator.addEnumType(fqName, config?.mappedName || odataName);\n const filePath = this.namingHelper.getFolderPath(namespace[0], enumName);\n this.dataModel.addEnum(namespace[0], odataName, {\n fqName,\n odataName,\n name: enumName,\n modelName: this.namingHelper.getEnumName(enumName),\n folderPath: filePath,\n members: et.Member?.length ? et.Member.map((m) => ({ name: m.$.Name, value: m.$.Value })) : [],\n });\n }\n }\n\n private addComplexType(namespace: NamespaceWithAlias, models: Array<ComplexType> | undefined) {\n if (!models || !models.length) {\n return;\n }\n\n for (const model of models) {\n const config = this.serviceConfigHelper.findComplexTypeConfig(namespace, model.$.Name);\n const fqName = withNamespace(namespace[0], model.$.Name);\n const name = this.nameValidator.addComplexType(fqName, config?.mappedName || model.$.Name);\n const baseModel = this.getBaseModel(config, model, namespace[0], name, fqName);\n this.dataModel.addComplexType(namespace[0], baseModel.odataName, baseModel);\n }\n }\n\n private addEntityType(namespace: NamespaceWithAlias, models: Array<ET> | undefined) {\n if (!models || !models.length) {\n return;\n }\n\n for (const model of models) {\n const entityConfig = this.serviceConfigHelper.findEntityTypeConfig(namespace, model.$.Name);\n const fqName = withNamespace(namespace[0], model.$.Name);\n const name = this.nameValidator.addEntityType(fqName, entityConfig?.mappedName || model.$.Name);\n const baseModel = this.getBaseModel(entityConfig, model, namespace[0], name, fqName);\n\n // key support: we add keys from this entity,\n // but not keys stemming from base classes (postprocess required)\n const keyNames: Array<string> = [];\n if (entityConfig?.keys?.length) {\n keyNames.push(...entityConfig.keys);\n } else {\n const entity = model as EntityType;\n if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {\n const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);\n keyNames.push(...propNames);\n }\n }\n\n this.dataModel.addEntityType(namespace[0], baseModel.odataName, {\n ...baseModel,\n id: {\n fqName: baseModel.fqName,\n modelName: this.namingHelper.getIdModelName(name),\n qName: this.namingHelper.getQIdFunctionName(name),\n },\n generateId: !!keyNames.length,\n keyNames: keyNames, // postprocess required to include key specs from base classes\n keys: [], // postprocess required to include props from base classes\n getKeyUnion: () => keyNames.join(\" | \"),\n subtypes: new Set(),\n });\n }\n }\n\n /**\n * Check that models (ComplexType or EntityType) have been referenced in the API\n * as entry point or via navProp or by virtue of being a base type or subtype of those.\n * For these models one or two services are generated.\n *\n * In this way unnecessary service generation is prevented. For example, complex types that\n * are only referenced as response of an operation do not need a generated service.\n *\n * @param ec\n * @private\n */\n private analyzeModelUsage(ec: EntityContainerV3 | EntityContainerV4 | undefined) {\n if (ec?.EntitySet?.length) {\n ec.EntitySet.forEach((et) => this.analyze(et.$.EntityType));\n }\n const ec4 = ec as EntityContainerV4;\n if (ec4?.Singleton?.length) {\n ec4.Singleton.forEach((singleton) => this.analyze(singleton.$.Type));\n }\n }\n\n /**\n * Check usage of model types within API.\n *\n * @param fqModelName\n * @private\n */\n private analyze(fqModelName: string) {\n // to also resolve aliases the data model needs to be used\n const model = this.dataModel.getEntityType(fqModelName) ?? this.dataModel.getComplexType(fqModelName);\n if (!model?.fqName || model.genMode === Modes.service) {\n return;\n }\n\n model.genMode = Modes.service;\n\n if (model) {\n // respect base classes\n if (model.baseClasses.length) {\n this.analyze(model.baseClasses[0]);\n }\n // include subtypes since each base class can be cast to its subtypes\n model.subtypes.forEach((subtype) => {\n this.analyze(subtype);\n });\n model?.props.forEach((p) => {\n if (p.dataType === DataTypes.ComplexType || p.dataType === DataTypes.ModelType) {\n this.analyze(p.fqType);\n }\n });\n }\n }\n\n private postProcessModel() {\n // complex types\n const complexTypes = this.dataModel.getComplexTypes();\n complexTypes.forEach((ct) => {\n // build up set of subtypes for each complex type\n this.addSubtypes(ct);\n\n // get props & keys from base types\n const [baseProps, _, baseAttributes] = this.collectBaseClassPropsAndKeys(ct, []);\n const { open } = baseAttributes;\n ct.baseProps = baseProps.map((bp) => ({ ...bp }));\n if (open) {\n ct.open = true;\n }\n });\n // entity types\n const entityTypes = this.dataModel.getEntityTypes();\n entityTypes.forEach((et) => {\n // build up set of subtypes for each entity type\n this.addSubtypes(et);\n\n // get props & keys from base types\n const [baseProps, baseKeys, baseAttributes] = this.collectBaseClassPropsAndKeys(et, []);\n const { fqIdName, idName, qIdName, open } = baseAttributes;\n et.baseProps = baseProps.map((bp) => ({ ...bp }));\n\n if (!et.keyNames.length && idName) {\n et.id = {\n fqName: fqIdName,\n modelName: idName,\n qName: qIdName,\n };\n et.generateId = false;\n }\n if (open) {\n et.open = open;\n }\n et.keyNames.unshift(...baseKeys.filter((bk) => !et.keyNames.includes(bk)));\n });\n }\n\n private postProcessKeys() {\n const entityTypes = this.dataModel.getEntityTypes();\n entityTypes.forEach((et) => {\n const isSingleKey = et.keyNames.length === 1;\n const props = [...et.baseProps, ...et.props];\n et.keys = et.keyNames.map((keyName) => {\n const prop = props.find((p) => p.odataName === keyName);\n if (!prop) {\n throw new Error(`Key with name [${keyName}] not found in props!`);\n }\n\n // automatically set key prop to managed, if this is the only key of the given entity\n if (prop.managed === undefined) {\n prop.managed = !this.options.disableAutoManagedKey && isSingleKey;\n }\n\n return prop;\n });\n });\n }\n\n private collectBaseClassPropsAndKeys(model: ComplexModelType, visitedModels: string[]): CollectorTuple {\n if (visitedModels.includes(model.fqName)) {\n throw new Error(`Cyclic inheritance detected for model ${model.fqName}!`);\n }\n visitedModels.push(model.fqName);\n return model.baseClasses.reduce(\n ([props, keys, attributes], bc) => {\n const baseModel = this.dataModel.getEntityType(bc) || this.dataModel.getComplexType(bc);\n if (!baseModel) {\n throw new Error(`BaseModel \"${bc}\" doesn't exist!`);\n }\n\n let { fqIdName, idName, qIdName, open } = attributes;\n\n // recursive\n if (baseModel.baseClasses.length) {\n const [parentProps, parentKeys, parentAttributes] = this.collectBaseClassPropsAndKeys(\n baseModel,\n visitedModels,\n );\n props.unshift(...parentProps);\n keys.unshift(...parentKeys);\n if (parentAttributes?.idName) {\n fqIdName = parentAttributes.fqIdName;\n idName = parentAttributes.idName;\n qIdName = parentAttributes.qIdName;\n }\n if (parentAttributes?.open) {\n open = true;\n }\n }\n\n props.push(...baseModel.props);\n const entityModel = baseModel as EntityModelType;\n if (entityModel.keyNames?.length) {\n keys.push(...entityModel.keyNames.filter((kn) => !keys.includes(kn)));\n fqIdName = entityModel.id.fqName;\n idName = entityModel.id.modelName;\n qIdName = entityModel.id.qName;\n }\n if (baseModel.open) {\n open = true;\n }\n return [props, keys, { fqIdName, idName, qIdName, open }];\n },\n [[], [], { fqIdName: \"\", idName: \"\", qIdName: \"\", open: false }] as CollectorTuple,\n );\n }\n\n protected mapProp = (p: Property, entityPropConfig?: PropertyGenerationOptions | undefined): PropertyModel => {\n if (!p.$.Type) {\n throw new Error(`No type information given for property [${p.$.Name}]!`);\n }\n\n const configProp = this.serviceConfigHelper.findPropConfigByName(p.$.Name);\n const modelName = this.namingHelper.getModelPropName(\n entityPropConfig?.mappedName || configProp?.mappedName || p.$.Name,\n );\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\n let odataDataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\n\n // support for primitive type mapping\n if (this.namingHelper.includesServicePrefix(odataDataType)) {\n const dt = this.dataModel.getPrimitiveType(odataDataType);\n if (dt !== undefined) {\n odataDataType = dt;\n }\n }\n\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\n\n // domain object known from service:\n // EntityType, ComplexType, EnumType\n if (this.namingHelper.includesServicePrefix(odataDataType)) {\n const modelType = this.model2Type.get(odataDataType)!;\n const [dataTypeName, dataTypePrefix] = this.namingHelper.getNameAndServicePrefix(odataDataType);\n const dataTypeNamespace: NamespaceWithAlias = [dataTypePrefix!];\n if (!modelType) {\n throw new Error(\n `Couldn't determine model type (EntityType, ComplexType, etc) for property \"${p.$.Name}\"! Given data type: \"${odataDataType}\".`,\n );\n }\n\n // special handling for enums\n if (modelType === DataTypes.EnumType) {\n const enumConfig = this.serviceConfigHelper.findEnumTypeConfig(dataTypeNamespace, dataTypeName);\n result = {\n dataType: modelType,\n type: this.namingHelper.getEnumName(enumConfig?.mappedName ?? odataDataType),\n qPath: this.options.numericEnums ? \"QNumericEnumPath\" : \"QEnumPath\",\n qObject: isCollection\n ? this.options.numericEnums\n ? \"QNumericEnumCollection\"\n : \"QEnumCollection\"\n : undefined,\n qParam: this.options.numericEnums ? \"QNumericEnumParam\" : \"QEnumParam\",\n };\n }\n // handling of complex & entity types\n else {\n const entityConfig =\n modelType === DataTypes.ComplexType\n ? this.serviceConfigHelper.findComplexTypeConfig(dataTypeNamespace, dataTypeName)\n : this.serviceConfigHelper.findEntityTypeConfig(dataTypeNamespace, dataTypeName);\n const typeName = entityConfig?.mappedName ?? odataDataType;\n\n result = {\n dataType: modelType,\n type: this.namingHelper.getModelName(typeName),\n qPath: \"QEntityPath\",\n qObject: this.namingHelper.getQName(typeName),\n qParam: \"QComplexParam\",\n };\n }\n }\n // OData built-in data types\n else if (odataDataType.startsWith(Digester.EDM_PREFIX)) {\n const { outputType, qPath, qParam, qCollection } = this.mapODataType(odataDataType);\n const { to, toModule: typeModule, converters } = this.dataModel.getConverter(odataDataType) || {};\n\n const type = !to ? outputType : to.startsWith(Digester.EDM_PREFIX) ? this.mapODataType(to).outputType : to;\n\n result = {\n dataType: DataTypes.PrimitiveType,\n type,\n typeModule,\n qPath,\n qParam,\n qObject: isCollection ? qCollection : undefined,\n converters,\n };\n } else {\n throw new Error(\n `Unknown type [${odataDataType}]: Not 'Collection(...)', not OData type 'Edm.*', not starting with one of the namespaces!`,\n );\n }\n\n return {\n odataName: p.$.Name,\n name: modelName,\n odataType: p.$.Type,\n fqType: odataDataType,\n required: ifFalse(p.$.Nullable),\n isCollection: isCollection,\n managed: typeof entityPropConfig?.managed !== \"undefined\" ? entityPropConfig.managed : configProp?.managed,\n ...result,\n };\n };\n\n private addSubtypes(model: ComplexModelType, grandChildren = new Set<string>()) {\n if (!model.baseClasses.length) {\n return;\n }\n\n model.baseClasses.forEach((baseClass) => {\n const baseType = this.dataModel.getModel(baseClass) as ComplexModelType;\n\n // add subtypes & base name for q-objects\n baseType.subtypes.add(model.fqName);\n if (!baseType.qBaseName) {\n baseType.qBaseName = this.namingHelper.getQBaseName(baseType.name);\n }\n grandChildren.forEach((gc) => baseType.subtypes.add(gc));\n\n // recursive\n grandChildren.add(model.fqName);\n this.addSubtypes(baseType, grandChildren);\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DataModelDigestion.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestion.ts"],"names":[],"mappings":";AAEA,OAAO,EAGL,KAAK,GAEN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAsB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAY9E,OAAO,EAAE,mBAAmB,EAAe,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAQ9D,SAAS,MAAM,CAAC,KAAyB;IACvC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CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC,EACD,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAmB,CACnF,CAAC;IACJ,CAAC;IAmGO,WAAW,CAAC,KAAuB,EAAE,gBAAgB,IAAI,GAAG,EAAU;QAC5E,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE;YAC7B,OAAO;SACR;QAED,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;YACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAqB,CAAC;YAExE,yCAAyC;YACzC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACpC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;gBACvB,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aACpE;YACD,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YAEzD,YAAY;YACZ,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAChC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;;AAngBgB,mBAAU,GAAG,MAAM,AAAT,CAAU","sourcesContent":["import { MappedConverterChains } from \"@odata2ts/converter-runtime\";\nimport type { DigestionOptions } from \"../FactoryFunctionModel.js\";\nimport {\n ComplexTypeGenerationOptions,\n EntityTypeGenerationOptions,\n Modes,\n PropertyGenerationOptions,\n} from \"../OptionModel.js\";\nimport { DataModel, NamespaceWithAlias, withNamespace } from \"./DataModel.js\";\nimport {\n ComplexType as ComplexModelType,\n DataTypes,\n EntityType as EntityModelType,\n ODataVersion,\n PropertyModel,\n} from \"./DataTypeModel.js\";\nimport { ComplexType, EntityType, EnumType, Property, Schema, TypeDefinition } from \"./edmx/ODataEdmxModelBase.js\";\nimport { EntityContainerV3, SchemaV3 } from \"./edmx/ODataEdmxModelV3.js\";\nimport { EntityContainerV4, SchemaV4 } from \"./edmx/ODataEdmxModelV4.js\";\nimport { NamingHelper } from \"./NamingHelper.js\";\nimport { ServiceConfigHelper, WithoutName } from \"./ServiceConfigHelper.js\";\nimport { NameClashValidator } from \"./validation/NameClashValidator.js\";\nimport { NameValidator } from \"./validation/NameValidator.js\";\nimport { NoopValidator } from \"./validation/NoopValidator.js\";\n\ntype CollectorTuple = [\n Array<PropertyModel>,\n Array<string>,\n { fqIdName: string; idName: string; qIdName: string; open: boolean },\n];\n\nfunction ifTrue(value: string | undefined): boolean {\n return value === \"true\";\n}\n\nfunction ifFalse(value: string | undefined): boolean {\n return value === \"false\";\n}\n\nexport interface TypeModel {\n outputType: string;\n qPath: string;\n qCollection: string;\n qParam: string | undefined;\n}\n\nexport abstract class Digester<S extends Schema<ET, CT>, ET extends EntityType, CT extends ComplexType> {\n protected static EDM_PREFIX = \"Edm.\";\n\n protected readonly dataModel: DataModel;\n protected readonly serviceConfigHelper: ServiceConfigHelper;\n protected readonly nameValidator: NameValidator;\n\n /**\n * Reverse mapping from fqName to data type: EntityType, ComplexType, EnumType, or Primitive Type.\n */\n private model2Type = new Map<string, DataTypes>();\n\n protected constructor(\n protected version: ODataVersion,\n protected schemas: Array<S>,\n protected options: DigestionOptions,\n protected namingHelper: NamingHelper,\n converters?: MappedConverterChains,\n ) {\n const namespaces = schemas.map<NamespaceWithAlias>((s) => [s.$.Namespace, s.$.Alias]);\n this.dataModel = new DataModel(namespaces, version, converters);\n this.serviceConfigHelper = new ServiceConfigHelper(options);\n this.nameValidator = options.bundledFileGeneration ? new NameClashValidator(options) : new NoopValidator();\n\n this.collectModelTypes(schemas);\n }\n\n private collectModelTypes(schemas: Array<S>) {\n schemas.forEach((schema) => {\n const { Namespace: ns, Alias: alias } = schema.$;\n\n schema.EnumType?.forEach((et) => {\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.EnumType);\n });\n schema.ComplexType?.forEach((ct) => {\n this.addModel2Type(ns, alias, ct.$.Name, DataTypes.ComplexType);\n });\n schema.EntityType?.forEach((et) => {\n this.addModel2Type(ns, alias, et.$.Name, DataTypes.ModelType);\n });\n });\n }\n\n private addModel2Type(ns: string, alias: string | undefined, name: string, dt: DataTypes) {\n this.model2Type.set(withNamespace(ns, name), dt);\n if (alias) {\n this.model2Type.set(withNamespace(alias, name), dt);\n }\n }\n\n protected abstract getNavigationProps(entityType: ET | ComplexType): Array<Property>;\n\n protected abstract digestOperations(schema: SchemaV3 | SchemaV4): void;\n\n protected abstract digestEntityContainer(schema: SchemaV3 | SchemaV4): void;\n\n /**\n * Get essential infos about a given odata type from the version specific service variants.\n *\n * @param type\n * @return tuple of return type, query object, query collection object\n */\n protected abstract mapODataType(type: string): TypeModel;\n\n public async digest(): Promise<DataModel> {\n this.digestEntityTypesAndOperations();\n\n // delegate to version specific entity container digestion\n this.schemas.forEach((schema) => this.digestEntityContainer(schema));\n\n this.dataModel.setNameValidation(this.nameValidator.validate());\n return this.dataModel;\n }\n\n private digestEntityTypesAndOperations() {\n this.schemas.forEach((schema) => {\n const ns: NamespaceWithAlias = [schema.$.Namespace, schema.$.Alias];\n\n // type definitions: alias for primitive types\n this.addTypeDefinition(schema.$.Namespace, schema.TypeDefinition);\n\n // enums\n this.addEnum(ns, schema.EnumType);\n\n // complex types\n this.addComplexType(ns, schema.ComplexType);\n\n // entity types\n this.addEntityType(ns, schema.EntityType);\n\n // V4 only: function & action types\n this.digestOperations(schema);\n });\n\n this.postProcessModel();\n this.postProcessKeys();\n\n this.schemas.forEach((schema) => {\n this.analyzeModelUsage(schema.EntityContainer?.length ? schema.EntityContainer[0] : undefined);\n });\n }\n\n private getBaseModel(\n entityConfig: WithoutName<EntityTypeGenerationOptions | ComplexTypeGenerationOptions> | undefined,\n model: ComplexType,\n namespace: string,\n name: string,\n fqName: string,\n ) {\n const odataName = model.$.Name;\n\n // map properties respecting the config\n const props = [...(model.Property ?? []), ...this.getNavigationProps(model)].map((p) => {\n const epConfig = entityConfig?.properties?.find((ep) => ep.name === p.$.Name);\n return this.mapProp(p, epConfig);\n });\n\n // support for base types, i.e. extends clause of interfaces\n const baseClasses = [];\n let finalBaseClass: string | undefined = undefined;\n if (model.$.BaseType) {\n baseClasses.push(model.$.BaseType);\n const [baseName, basePrefix] = this.namingHelper.getNameAndServicePrefix(model.$.BaseType);\n const baseConfig =\n this.serviceConfigHelper.findEntityTypeConfig([basePrefix!], baseName) ||\n this.serviceConfigHelper.findComplexTypeConfig([basePrefix!], baseName);\n finalBaseClass = baseConfig?.mappedName ?? baseName;\n }\n\n return {\n fqName,\n odataName,\n name,\n modelName: this.namingHelper.getModelName(name),\n qName: this.namingHelper.getQName(name),\n editableName: this.namingHelper.getEditableModelName(name),\n serviceName: this.namingHelper.getServiceName(name),\n serviceCollectionName: this.namingHelper.getCollectionServiceName(name),\n folderPath: this.namingHelper.getFolderPath(namespace, name),\n baseClasses,\n finalBaseClass,\n props,\n baseProps: [], // postprocess required\n abstract: ifTrue(model.$.Abstract),\n open: ifTrue(model.$.OpenType),\n genMode: Modes.qobjects,\n subtypes: new Set(),\n } satisfies Partial<ComplexModelType>;\n }\n\n private addTypeDefinition(ns: string, types: Array<TypeDefinition> | undefined) {\n if (!types || !types.length) {\n return;\n }\n\n for (const t of types) {\n this.dataModel.addTypeDefinition(ns, t.$.Name, t.$.UnderlyingType);\n }\n }\n\n private addEnum(namespace: NamespaceWithAlias, models: Array<EnumType> | undefined) {\n if (!models || !models.length) {\n return;\n }\n\n for (const et of models) {\n const odataName = et.$.Name;\n const fqName = withNamespace(namespace[0], odataName);\n const config = this.serviceConfigHelper.findEnumTypeConfig(namespace, odataName);\n const enumName = this.nameValidator.addEnumType(fqName, config?.mappedName || odataName);\n const filePath = this.namingHelper.getFolderPath(namespace[0], enumName);\n this.dataModel.addEnum(namespace[0], odataName, {\n fqName,\n odataName,\n name: enumName,\n modelName: this.namingHelper.getEnumName(enumName),\n folderPath: filePath,\n members: et.Member?.length ? et.Member.map((m) => ({ name: m.$.Name, value: m.$.Value })) : [],\n });\n }\n }\n\n private addComplexType(namespace: NamespaceWithAlias, models: Array<ComplexType> | undefined) {\n if (!models || !models.length) {\n return;\n }\n\n for (const model of models) {\n const config = this.serviceConfigHelper.findComplexTypeConfig(namespace, model.$.Name);\n const fqName = withNamespace(namespace[0], model.$.Name);\n const name = this.nameValidator.addComplexType(fqName, config?.mappedName || model.$.Name);\n const baseModel = this.getBaseModel(config, model, namespace[0], name, fqName);\n this.dataModel.addComplexType(namespace[0], baseModel.odataName, baseModel);\n }\n }\n\n private addEntityType(namespace: NamespaceWithAlias, models: Array<ET> | undefined) {\n if (!models || !models.length) {\n return;\n }\n\n for (const model of models) {\n const entityConfig = this.serviceConfigHelper.findEntityTypeConfig(namespace, model.$.Name);\n const fqName = withNamespace(namespace[0], model.$.Name);\n const name = this.nameValidator.addEntityType(fqName, entityConfig?.mappedName || model.$.Name);\n const baseModel = this.getBaseModel(entityConfig, model, namespace[0], name, fqName);\n\n // key support: we add keys from this entity,\n // but not keys stemming from base classes (postprocess required)\n const keyNames: Array<string> = [];\n if (entityConfig?.keys?.length) {\n keyNames.push(...entityConfig.keys);\n } else {\n const entity = model as EntityType;\n if (entity.Key && entity.Key.length && entity.Key[0].PropertyRef.length) {\n const propNames = entity.Key[0].PropertyRef.map((key) => key.$.Name);\n keyNames.push(...propNames);\n }\n }\n\n this.dataModel.addEntityType(namespace[0], baseModel.odataName, {\n ...baseModel,\n id: {\n fqName: baseModel.fqName,\n modelName: this.namingHelper.getIdModelName(name),\n qName: this.namingHelper.getQIdFunctionName(name),\n },\n generateId: !!keyNames.length,\n keyNames: keyNames, // postprocess required to include key specs from base classes\n keys: [], // postprocess required to include props from base classes\n getKeyUnion: () => keyNames.join(\" | \"),\n subtypes: new Set(),\n });\n }\n }\n\n /**\n * Check that models (ComplexType or EntityType) have been referenced in the API\n * as entry point or via navProp or by virtue of being a base type or subtype of those.\n * For these models one or two services are generated.\n *\n * In this way unnecessary service generation is prevented. For example, complex types that\n * are only referenced as response of an operation do not need a generated service.\n *\n * @param ec\n * @private\n */\n private analyzeModelUsage(ec: EntityContainerV3 | EntityContainerV4 | undefined) {\n if (ec?.EntitySet?.length) {\n ec.EntitySet.forEach((et) => this.analyze(et.$.EntityType));\n }\n const ec4 = ec as EntityContainerV4;\n if (ec4?.Singleton?.length) {\n ec4.Singleton.forEach((singleton) => this.analyze(singleton.$.Type));\n }\n }\n\n /**\n * Check usage of model types within API.\n *\n * @param fqModelName\n * @private\n */\n private analyze(fqModelName: string) {\n // to also resolve aliases the data model needs to be used\n const model = this.dataModel.getEntityType(fqModelName) ?? this.dataModel.getComplexType(fqModelName);\n if (!model?.fqName || model.genMode === Modes.service) {\n return;\n }\n\n model.genMode = Modes.service;\n\n if (model) {\n // respect base classes\n if (model.baseClasses.length) {\n this.analyze(model.baseClasses[0]);\n }\n // include subtypes since each base class can be cast to its subtypes\n model.subtypes.forEach((subtype) => {\n this.analyze(subtype);\n });\n model?.props.forEach((p) => {\n if (p.dataType === DataTypes.ComplexType || p.dataType === DataTypes.ModelType) {\n this.analyze(p.fqType);\n }\n });\n }\n }\n\n private postProcessModel() {\n // complex types\n const complexTypes = this.dataModel.getComplexTypes();\n complexTypes.forEach((ct) => {\n // build up set of subtypes for each complex type\n this.addSubtypes(ct);\n\n // get props & keys from base types\n const [baseProps, _, baseAttributes] = this.collectBaseClassPropsAndKeys(ct, []);\n const { open } = baseAttributes;\n ct.baseProps = baseProps.map((bp) => ({ ...bp }));\n if (open) {\n ct.open = true;\n }\n });\n // entity types\n const entityTypes = this.dataModel.getEntityTypes();\n entityTypes.forEach((et) => {\n // build up set of subtypes for each entity type\n this.addSubtypes(et);\n\n // get props & keys from base types\n const [baseProps, baseKeys, baseAttributes] = this.collectBaseClassPropsAndKeys(et, []);\n const { fqIdName, idName, qIdName, open } = baseAttributes;\n et.baseProps = baseProps.map((bp) => ({ ...bp }));\n\n if (!et.keyNames.length && idName) {\n et.id = {\n fqName: fqIdName,\n modelName: idName,\n qName: qIdName,\n };\n et.generateId = false;\n }\n if (open) {\n et.open = open;\n }\n et.keyNames.unshift(...baseKeys.filter((bk) => !et.keyNames.includes(bk)));\n });\n }\n\n private postProcessKeys() {\n const entityTypes = this.dataModel.getEntityTypes();\n entityTypes.forEach((et) => {\n const isSingleKey = et.keyNames.length === 1;\n const props = [...et.baseProps, ...et.props];\n et.keys = et.keyNames.map((keyName) => {\n const prop = props.find((p) => p.odataName === keyName);\n if (!prop) {\n throw new Error(`Key with name [${keyName}] not found in props!`);\n }\n\n // automatically set key prop to managed, if this is the only key of the given entity\n if (prop.managed === undefined) {\n prop.managed = !this.options.disableAutoManagedKey && isSingleKey;\n }\n\n return prop;\n });\n });\n }\n\n private collectBaseClassPropsAndKeys(model: ComplexModelType, visitedModels: string[]): CollectorTuple {\n if (visitedModels.includes(model.fqName)) {\n throw new Error(`Cyclic inheritance detected for model ${model.fqName}!`);\n }\n visitedModels.push(model.fqName);\n return model.baseClasses.reduce(\n ([props, keys, attributes], bc) => {\n const baseModel = this.dataModel.getEntityType(bc) || this.dataModel.getComplexType(bc);\n if (!baseModel) {\n throw new Error(`BaseModel \"${bc}\" doesn't exist!`);\n }\n\n let { fqIdName, idName, qIdName, open } = attributes;\n\n // recursive\n if (baseModel.baseClasses.length) {\n const [parentProps, parentKeys, parentAttributes] = this.collectBaseClassPropsAndKeys(\n baseModel,\n visitedModels,\n );\n props.unshift(...parentProps);\n keys.unshift(...parentKeys);\n if (parentAttributes?.idName) {\n fqIdName = parentAttributes.fqIdName;\n idName = parentAttributes.idName;\n qIdName = parentAttributes.qIdName;\n }\n if (parentAttributes?.open) {\n open = true;\n }\n }\n\n props.push(...baseModel.props);\n const entityModel = baseModel as EntityModelType;\n if (entityModel.keyNames?.length) {\n keys.push(...entityModel.keyNames.filter((kn) => !keys.includes(kn)));\n fqIdName = entityModel.id.fqName;\n idName = entityModel.id.modelName;\n qIdName = entityModel.id.qName;\n }\n if (baseModel.open) {\n open = true;\n }\n return [props, keys, { fqIdName, idName, qIdName, open }];\n },\n [[], [], { fqIdName: \"\", idName: \"\", qIdName: \"\", open: false }] as CollectorTuple,\n );\n }\n\n protected mapProp = (p: Property, entityPropConfig?: PropertyGenerationOptions | undefined): PropertyModel => {\n if (!p.$.Type) {\n throw new Error(`No type information given for property [${p.$.Name}]!`);\n }\n\n const configProp = this.serviceConfigHelper.findPropConfigByName(p.$.Name);\n const modelName = this.namingHelper.getModelPropName(\n entityPropConfig?.mappedName || configProp?.mappedName || p.$.Name,\n );\n const isCollection = !!p.$.Type.match(/^Collection\\(/);\n let odataDataType = p.$.Type.replace(/^Collection\\(([^\\)]+)\\)/, \"$1\");\n\n // support for primitive type mapping\n if (this.namingHelper.includesServicePrefix(odataDataType)) {\n const dt = this.dataModel.getPrimitiveType(odataDataType);\n if (dt !== undefined) {\n odataDataType = dt;\n }\n }\n\n let result: Pick<PropertyModel, \"dataType\" | \"type\" | \"typeModule\" | \"qPath\" | \"qParam\" | \"qObject\" | \"converters\">;\n\n // domain object known from service:\n // EntityType, ComplexType, EnumType\n if (this.namingHelper.includesServicePrefix(odataDataType)) {\n const modelType = this.model2Type.get(odataDataType)!;\n const [dataTypeName, dataTypePrefix] = this.namingHelper.getNameAndServicePrefix(odataDataType);\n const dataTypeNamespace: NamespaceWithAlias = [dataTypePrefix!];\n if (!modelType) {\n throw new Error(\n `Couldn't determine model type (EntityType, ComplexType, etc) for property \"${p.$.Name}\"! Given data type: \"${odataDataType}\".`,\n );\n }\n\n // special handling for enums\n if (modelType === DataTypes.EnumType) {\n const isNumericEnum = this.options.enumType === \"numeric\";\n const enumConfig = this.serviceConfigHelper.findEnumTypeConfig(dataTypeNamespace, dataTypeName);\n result = {\n dataType: modelType,\n type: this.namingHelper.getEnumName(enumConfig?.mappedName ?? odataDataType),\n qPath: isNumericEnum ? \"QNumericEnumPath\" : \"QEnumPath\",\n qObject: isCollection ? (isNumericEnum ? \"QNumericEnumCollection\" : \"QEnumCollection\") : undefined,\n qParam: isNumericEnum ? \"QNumericEnumParam\" : \"QEnumParam\",\n };\n }\n // handling of complex & entity types\n else {\n const entityConfig =\n modelType === DataTypes.ComplexType\n ? this.serviceConfigHelper.findComplexTypeConfig(dataTypeNamespace, dataTypeName)\n : this.serviceConfigHelper.findEntityTypeConfig(dataTypeNamespace, dataTypeName);\n const typeName = entityConfig?.mappedName ?? odataDataType;\n\n result = {\n dataType: modelType,\n type: this.namingHelper.getModelName(typeName),\n qPath: \"QEntityPath\",\n qObject: this.namingHelper.getQName(typeName),\n qParam: \"QComplexParam\",\n };\n }\n }\n // OData built-in data types\n else if (odataDataType.startsWith(Digester.EDM_PREFIX)) {\n const { outputType, qPath, qParam, qCollection } = this.mapODataType(odataDataType);\n const { to, toModule: typeModule, converters } = this.dataModel.getConverter(odataDataType) || {};\n\n const type = !to ? outputType : to.startsWith(Digester.EDM_PREFIX) ? this.mapODataType(to).outputType : to;\n\n result = {\n dataType: DataTypes.PrimitiveType,\n type,\n typeModule,\n qPath,\n qParam,\n qObject: isCollection ? qCollection : undefined,\n converters,\n };\n } else {\n throw new Error(\n `Unknown type [${odataDataType}]: Not 'Collection(...)', not OData type 'Edm.*', not starting with one of the namespaces!`,\n );\n }\n\n return {\n odataName: p.$.Name,\n name: modelName,\n odataType: p.$.Type,\n fqType: odataDataType,\n required: ifFalse(p.$.Nullable),\n isCollection: isCollection,\n managed: typeof entityPropConfig?.managed !== \"undefined\" ? entityPropConfig.managed : configProp?.managed,\n ...result,\n };\n };\n\n private addSubtypes(model: ComplexModelType, grandChildren = new Set<string>()) {\n if (!model.baseClasses.length) {\n return;\n }\n\n model.baseClasses.forEach((baseClass) => {\n const baseType = this.dataModel.getModel(baseClass) as ComplexModelType;\n\n // add subtypes & base name for q-objects\n baseType.subtypes.add(model.fqName);\n if (!baseType.qBaseName) {\n baseType.qBaseName = this.namingHelper.getQBaseName(baseType.name);\n }\n grandChildren.forEach((gc) => baseType.subtypes.add(gc));\n\n // recursive\n grandChildren.add(model.fqName);\n this.addSubtypes(baseType, grandChildren);\n });\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,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAgB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAc,MAAM,kBAAkB,CAAC;AAGhE;;GAEG;AACH,MAAM,aAAa,GAAyB;IAC1C,eAAe,EAAE,EAAE;IACnB,WAAW,EAAE,KAAK;IAClB,IAAI,EAAE,KAAK,CAAC,GAAG;IACf,QAAQ,EAAE,SAAS,CAAC,MAAM;IAC1B,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,eAAe;IACzB,UAAU,EAAE,EAAE;IACd,kBAAkB,EAAE,KAAK;IACzB,YAAY,EAAE,KAAK;IACnB,cAAc,EAAE,KAAK;IACrB,YAAY,EAAE,KAAK;IACnB,+BAA+B,EAAE,KAAK;IACtC,qBAAqB,EAAE,KAAK;IAC5B,aAAa,EAAE,KAAK;IACpB,gCAAgC,EAAE,KAAK;IACvC,mBAAmB,EAAE,KAAK;IAC1B,mCAAmC,EAAE,KAAK;IAC1C,qBAAqB,EAAE,IAAI;IAC3B,
|
|
1
|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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;KACF;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,SAAS,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,EAAE,MAAM,KAAqB,aAAa,EAA7B,WAAW,UAAK,aAAa,EAA1C,UAA0B,CAAgB,CAAC;IACjD,OAAO,SAAS,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import deepmerge from \"deepmerge\";\nimport { NameSettings, NamingStrategies } from \"./NamingModel.js\";\nimport { EmitModes, Modes, RunOptions } from \"./OptionModel.js\";\n\nexport type DefaultConfiguration = Omit<RunOptions, \"sourceUrl\" | \"source\" | \"output\" | \"serviceName\">;\n/**\n * The default configuration.\n */\nconst defaultConfig: DefaultConfiguration = {\n sourceUrlConfig: {},\n refreshFile: false,\n mode: Modes.all,\n emitMode: EmitModes.js_dts,\n debug: false,\n prettier: false,\n tsconfig: \"tsconfig.json\",\n converters: [],\n skipEditableModels: false,\n skipIdModels: false,\n skipOperations: false,\n skipComments: false,\n enablePrimitivePropertyServices: false,\n disableAutoManagedKey: false,\n allowRenaming: false,\n v2ModelsWithExtraResultsWrapping: false,\n v4BigNumberAsString: false,\n disableAutomaticNameClashResolution: false,\n bundledFileGeneration: true,\n enumType: \"string\",\n naming: {\n models: {\n namingStrategy: NamingStrategies.PASCAL_CASE,\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\n editableModels: {\n prefix: \"Editable\",\n suffix: \"\",\n applyModelNaming: true,\n },\n idModels: {\n prefix: \"\",\n suffix: \"Id\",\n applyModelNaming: true,\n },\n operationParamModels: {\n prefix: \"\",\n suffix: \"Params\",\n applyModelNaming: true,\n },\n fileName: {\n namingStrategy: NamingStrategies.PASCAL_CASE,\n prefix: \"\",\n suffix: \"Model\",\n },\n },\n queryObjects: {\n namingStrategy: NamingStrategies.PASCAL_CASE,\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\n prefix: \"Q\",\n suffix: \"\",\n idFunctions: {\n prefix: \"\",\n suffix: \"Id\",\n },\n fileName: {\n namingStrategy: NamingStrategies.PASCAL_CASE,\n prefix: \"Q\",\n suffix: \"\",\n },\n baseType: {\n applyQNaming: true,\n prefix: \"\",\n suffix: \"BaseType\",\n },\n },\n services: {\n prefix: \"\",\n suffix: \"Service\",\n namingStrategy: NamingStrategies.PASCAL_CASE,\n main: {\n applyServiceNaming: true,\n },\n collection: {\n prefix: \"\",\n suffix: \"Collection\",\n applyServiceNaming: true,\n },\n operations: {\n namingStrategy: NamingStrategies.CAMEL_CASE,\n },\n relatedServiceGetter: {\n namingStrategy: NamingStrategies.CAMEL_CASE,\n prefix: \"\",\n suffix: \"\",\n },\n privateProps: {\n namingStrategy: NamingStrategies.CAMEL_CASE,\n prefix: \"_\",\n suffix: \"\",\n },\n },\n },\n propertiesByName: [],\n byTypeAndName: [],\n};\n\nconst { models, queryObjects, services } = defaultConfig.naming;\nconst minimalNamingConfig: NameSettings = {\n models: {\n fileName: {\n prefix: models.fileName.prefix,\n suffix: models.fileName.suffix,\n },\n idModels: {\n applyModelNaming: true,\n prefix: models.idModels.prefix,\n suffix: models.idModels.suffix,\n },\n editableModels: {\n applyModelNaming: true,\n prefix: models.editableModels.prefix,\n suffix: models.editableModels.suffix,\n },\n operationParamModels: {\n applyModelNaming: true,\n prefix: models.operationParamModels.prefix,\n suffix: models.operationParamModels.suffix,\n },\n },\n queryObjects: {\n prefix: queryObjects.prefix,\n suffix: queryObjects.suffix,\n fileName: {\n prefix: queryObjects.fileName.prefix,\n suffix: queryObjects.fileName.suffix,\n },\n idFunctions: {\n prefix: queryObjects.idFunctions.prefix,\n suffix: queryObjects.idFunctions.suffix,\n },\n baseType: {\n prefix: queryObjects.baseType.prefix,\n suffix: queryObjects.baseType.suffix,\n },\n },\n services: {\n prefix: services.prefix,\n suffix: services.suffix,\n main: {\n applyServiceNaming: true,\n },\n collection: {\n applyServiceNaming: true,\n prefix: services.collection.prefix,\n suffix: services.collection.suffix,\n },\n privateProps: {\n prefix: services.privateProps.prefix,\n suffix: services.privateProps.suffix,\n },\n relatedServiceGetter: {\n prefix: services.relatedServiceGetter.prefix,\n suffix: services.relatedServiceGetter.suffix,\n },\n },\n};\n\n/**\n * Creates a defensive copy of the default config.\n */\nexport function getDefaultConfig(): DefaultConfiguration {\n return deepmerge(defaultConfig, {});\n}\n\n/**\n * Creates a defensive copy of the minimal config: minimal in respect to naming.\n */\nexport function getMinimalConfig(): DefaultConfiguration {\n const { naming, ...passThrough } = defaultConfig;\n return deepmerge(passThrough, { naming: minimalNamingConfig });\n}\n"]}
|
|
@@ -31,15 +31,24 @@ class ModelGenerator {
|
|
|
31
31
|
generateEnums() {
|
|
32
32
|
return this.dataModel.getEnums().map((et) => {
|
|
33
33
|
const file = this.project.createOrGetModelFile(et.folderPath, et.modelName);
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
const enumType = this.options.enumType;
|
|
35
|
+
if (enumType === "string-union") {
|
|
36
|
+
file.getFile().addTypeAlias({
|
|
37
|
+
name: et.modelName,
|
|
38
|
+
isExported: true,
|
|
39
|
+
type: et.members.map((mem) => `"${mem.name}"`).join(" | "),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
file.getFile().addEnum({
|
|
44
|
+
name: et.modelName,
|
|
45
|
+
isExported: true,
|
|
46
|
+
members: et.members.map((mem) => ({
|
|
47
|
+
name: mem.name,
|
|
48
|
+
initializer: enumType === "numeric" ? String(mem.value) : `"${mem.name}"`,
|
|
49
|
+
})),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
43
52
|
return this.project.finalizeFile(file);
|
|
44
53
|
});
|
|
45
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelGenerator.js","sourceRoot":"","sources":["../../src/generator/ModelGenerator.ts"],"names":[],"mappings":";AACA,OAAO,EAAgC,aAAa,EAAE,MAAM,UAAU,CAAC;AAOvE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,MAAM,CAAC,MAAM,cAAc,GAAiC,CAC1D,OAAuB,EACvB,SAAS,EACT,OAAO,EACP,OAAO,EACP,YAAY,EACZ,EAAE;IACF,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IACzF,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC,CAAC;AAEF,MAAM,cAAc;IAClB,YACU,OAAuB,EACvB,SAAoB,EACpB,OAAsB,EACtB,OAAiC,EACjC,YAA0B;QAJ1B,YAAO,GAAP,OAAO,CAAgB;QACvB,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAe;QACtB,YAAO,GAAP,OAAO,CAA0B;QACjC,iBAAY,GAAZ,YAAY,CAAc;IACjC,CAAC;IAES,QAAQ;;YACnB,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YAE1B,MAAM,QAAQ,GAAyB;gBACrC,GAAG,IAAI,CAAC,aAAa,EAAE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AK,EAAE,EAAE;gCAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,KAAK,CAAC,CAAC;gCAC7D,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC,CAAC;gCACxE,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;oCAC3B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;iCACnB;4BACH,CAAC,CAAC,CAAC;wBACL,CAAC,CAAC,CAAC;wBACH,IAAI,KAAK,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;4BAChC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;yBACrB;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;aACF,CAAC,CAAC;SACJ;IACH,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport { JSDocStructure, OptionalKind, StructureKind } from \"ts-morph\";\nimport { DataModel } from \"../data-model/DataModel.js\";\nimport { ComplexType, DataTypes, EntityType, OperationType, PropertyModel } from \"../data-model/DataTypeModel.js\";\nimport { NamingHelper } from \"../data-model/NamingHelper.js\";\nimport { EntityBasedGeneratorFunction, GeneratorFunctionOptions } from \"../FactoryFunctionModel.js\";\nimport { FileHandler } from \"../project/FileHandler.js\";\nimport { ProjectManager } from \"../project/ProjectManager.js\";\nimport { CoreImports } from \"./import/ImportObjects.js\";\nimport { ImportContainer } from \"./ImportContainer.js\";\n\nexport const generateModels: EntityBasedGeneratorFunction = (\n project: ProjectManager,\n dataModel,\n version,\n options,\n namingHelper,\n) => {\n const generator = new ModelGenerator(project, dataModel, version, options, namingHelper);\n return generator.generate();\n};\n\nclass ModelGenerator {\n constructor(\n private project: ProjectManager,\n private dataModel: DataModel,\n private version: ODataVersions,\n private options: GeneratorFunctionOptions,\n private namingHelper: NamingHelper,\n ) {}\n\n public async generate(): Promise<void> {\n this.project.initModels();\n\n const promises: Array<Promise<void>> = [\n ...this.generateEnums(),\n ...this.generateEntityTypeModels(),\n ...this.generateComplexTypeModels(),\n ];\n\n if (!this.options.skipOperations) {\n promises.push(this.generateUnboundOperationParams());\n }\n\n await Promise.all(promises);\n\n return this.project.finalizeModels();\n }\n\n private generateEnums() {\n return this.dataModel.getEnums().map((et) => {\n const file = this.project.createOrGetModelFile(et.folderPath, et.modelName);\n\n const isNumeric = this.options.numericEnums;\n file.getFile().addEnum({\n name: et.modelName,\n isExported: true,\n members: et.members.map((mem) => ({\n name: mem.name,\n initializer: isNumeric ? String(mem.value) : `\"${mem.name}\"`,\n })),\n });\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateEntityTypeModels() {\n return this.dataModel.getEntityTypes().map((model) => {\n const file = this.project.createOrGetModelFile(model.folderPath, model.modelName, [\n model.modelName,\n model.id.modelName,\n model.editableName,\n ]);\n\n // query model\n this.generateModel(file, model);\n\n // key model\n if (!this.options.skipIdModels && model.generateId) {\n this.generateIdModel(file, model);\n }\n\n // editable model\n if (!this.options.skipEditableModels) {\n this.generateEditableModel(file, model);\n }\n\n // param models for bound operations\n if (!this.options.skipOperations) {\n [\n ...this.dataModel.getEntityTypeOperations(model.fqName),\n ...this.dataModel.getEntitySetOperations(model.fqName),\n ].forEach((operation) => {\n this.generateOperationParams(file, operation);\n });\n }\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateComplexTypeModels() {\n return this.dataModel.getComplexTypes().map((model) => {\n const file = this.project.createOrGetModelFile(model.folderPath, model.modelName, [\n model.modelName,\n model.editableName,\n ]);\n\n // query model\n this.generateModel(file, model);\n\n // editable model\n if (!this.options.skipEditableModels) {\n this.generateEditableModel(file, model);\n }\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateModel(file: FileHandler, model: ComplexType | EntityType) {\n const imports = file.getImports();\n let extendsClause = undefined;\n if (model.finalBaseClass) {\n const modelName = imports.addGeneratedModel(\n model.baseClasses[0],\n this.namingHelper.getModelName(model.finalBaseClass),\n );\n extendsClause = [modelName];\n }\n\n file.getFile().addInterface({\n name: model.modelName,\n isExported: true,\n properties: model.props.map((p) => {\n const isEntity = p.dataType == DataTypes.ModelType;\n return {\n name: p.name,\n type: this.getPropType(file.getImports(), p),\n // props for entities or entity collections are not added in V4 if not explicitly expanded\n hasQuestionToken: this.dataModel.isV4() && isEntity,\n docs: this.options.skipComments ? undefined : [this.generatePropDoc(p, model)],\n };\n }),\n extends: extendsClause,\n });\n }\n\n private generatePropDoc(prop: PropertyModel, model: ComplexType | EntityType): OptionalKind<JSDocStructure> {\n const isKeyProp = (model as EntityType).keyNames?.includes(prop.odataName);\n const baseAttribs: Array<string> = [];\n if (isKeyProp) {\n baseAttribs.push(\"**Key Property**: This is a key property used to identify the entity.\");\n }\n if (prop.managed) {\n baseAttribs.push(\"**Managed**: This property is managed on the server side and cannot be edited.\");\n }\n if (prop.converters?.length) {\n baseAttribs.push(`**Applied Converters**: ${prop.converters.map((c) => c.converterId).join(\",\")}.`);\n }\n\n const attributeTable: Array<[string, string]> = [\n [\"Name\", prop.odataName],\n [\"Type\", prop.odataType],\n ];\n if (prop.required) {\n attributeTable.push([\"Nullable\", \"false\"]);\n }\n\n const description =\n (baseAttribs ? baseAttribs.join(\"<br/>\") + \"\\n\\n\" : \"\") +\n \"OData Attributes:\\n\" +\n \"|Attribute Name | Attribute Value |\\n| --- | ---|\\n\" +\n attributeTable.map((row) => `| ${row[0]} | \\`${row[1]}\\` |`).join(\"\\n\");\n\n return { kind: StructureKind.JSDoc, description };\n }\n\n private getPropType(imports: ImportContainer, prop: PropertyModel): string {\n // V2 entity special: deferred content\n let suffix = \"\";\n if (this.dataModel.isV2() && prop.dataType == DataTypes.ModelType) {\n const defContent = imports.addCoreLib(this.version, CoreImports.DeferredContent);\n suffix = ` | ${defContent}`;\n }\n\n let typeName: string;\n if (prop.dataType === DataTypes.PrimitiveType) {\n // custom types which require type imports => possible via converters\n typeName = prop.typeModule ? imports.addCustomType(prop.typeModule, prop.type, true) : prop.type;\n } else {\n typeName = imports.addGeneratedModel(prop.fqType, prop.type);\n }\n\n // Collections\n if (prop.isCollection) {\n const type = `Array<${typeName}>`;\n if (this.dataModel.isV2() && this.options.v2ModelsWithExtraResultsWrapping) {\n return `{ results: ${type} }` + suffix;\n } else {\n return type + suffix;\n }\n }\n\n // primitive, enum & complex types\n return typeName + (prop.required ? \"\" : \" | null\") + suffix;\n }\n\n private generateIdModel(file: FileHandler, model: EntityType) {\n const singleType = model.keys.length === 1 ? `${model.keys[0].type} | ` : \"\";\n const keyTypes = model.keys\n .map((keyProp) => `${keyProp.name}: ${this.getPropType(file.getImports(), keyProp)}`)\n .join(\",\");\n const type = `${singleType}{${keyTypes}}`;\n\n file.getFile().addTypeAlias({\n name: model.id.modelName,\n isExported: true,\n type,\n });\n }\n\n private generateEditableModel(file: FileHandler, model: ComplexType) {\n const entityTypes = [DataTypes.ModelType, DataTypes.ComplexType];\n const allProps = [...model.baseProps, ...model.props].filter((p) => !p.managed);\n\n const requiredProps = allProps\n .filter((p) => p.required && !entityTypes.includes(p.dataType))\n .map((p) => `\"${p.name}\"`)\n .join(\" | \");\n const optionalProps = allProps\n .filter((p) => !p.required && !entityTypes.includes(p.dataType))\n .map((p) => `\"${p.name}\"`)\n .join(\" | \");\n const complexProps = allProps.filter((p) => p.dataType === DataTypes.ComplexType);\n\n const extendsClause = [\n requiredProps ? `Pick<${model.modelName}, ${requiredProps}>` : null,\n optionalProps ? `Partial<Pick<${model.modelName}, ${optionalProps}>>` : null,\n ].filter((e): e is string => !!e);\n\n file.getFile().addInterface({\n name: model.editableName,\n isExported: true,\n extends: extendsClause,\n properties: !complexProps\n ? undefined\n : complexProps.map((p) => {\n return {\n name: p.name,\n type: this.getEditablePropType(file.getImports(), p),\n // optional props don't need to be specified in editable model\n // also, entities would require deep insert func => we make it optional for now\n hasQuestionToken: !p.required || p.dataType === DataTypes.ModelType,\n };\n }),\n });\n }\n\n private getEditablePropType(imports: ImportContainer, prop: PropertyModel): string {\n const isModelType = [DataTypes.ModelType, DataTypes.ComplexType].includes(prop.dataType);\n\n let editableType = prop.type;\n if (isModelType) {\n const editName = this.dataModel.getComplexType(prop.fqType)!.editableName;\n editableType = imports.addGeneratedModel(prop.fqType, editName);\n }\n\n // Collections\n if (prop.isCollection) {\n return `Array<${editableType}>`;\n }\n\n // primitive, enum & complex types\n return editableType + (prop.required ? \"\" : \" | null\");\n }\n\n private async generateUnboundOperationParams() {\n const unboundOps = this.dataModel.getUnboundOperationTypes();\n const reservedNames = unboundOps.map((op) => op.paramsModelName);\n const file = this.project.createOrGetMainModelFile(reservedNames);\n\n unboundOps.forEach((operation) => {\n this.generateOperationParams(file, operation);\n });\n }\n\n private generateOperationParams(file: FileHandler, operation: OperationType) {\n const paramSets = [operation.parameters, ...(operation.overrides ?? [])].filter((pSet) => !!pSet.length);\n\n // standard: one interface for parameters\n if (paramSets.length === 1) {\n file.getFile().addInterface({\n name: operation.paramsModelName,\n isExported: true,\n properties: paramSets[0].map((p) => {\n return {\n name: p.name,\n type: this.getPropType(file.getImports(), p),\n hasQuestionToken: !p.required,\n };\n }),\n });\n }\n // function overload: one type with intersections of different param models\n else if (paramSets.length > 1) {\n file.getFile().addTypeAlias({\n name: operation.paramsModelName,\n isExported: true,\n type: (writer) => {\n paramSets.forEach((pSet, index) => {\n writer.block(() => {\n pSet.forEach((param, index) => {\n const paramType = this.getPropType(file.getImports(), param);\n writer.write(`${param.name}${param.required ? \"\" : \"?\"}: ${paramType}`);\n if (index < pSet.length - 1) {\n writer.write(\",\");\n }\n });\n });\n if (index < paramSets.length - 1) {\n writer.write(\" | \");\n }\n });\n },\n });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelGenerator.js","sourceRoot":"","sources":["../../src/generator/ModelGenerator.ts"],"names":[],"mappings":";AACA,OAAO,EAAgC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CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC,CAAC;gCACxE,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;oCAC3B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;iCACnB;4BACH,CAAC,CAAC,CAAC;wBACL,CAAC,CAAC,CAAC;wBACH,IAAI,KAAK,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;4BAChC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;yBACrB;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;aACF,CAAC,CAAC;SACJ;IACH,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport { JSDocStructure, OptionalKind, StructureKind } from \"ts-morph\";\nimport { DataModel } from \"../data-model/DataModel.js\";\nimport { ComplexType, DataTypes, EntityType, OperationType, PropertyModel } from \"../data-model/DataTypeModel.js\";\nimport { NamingHelper } from \"../data-model/NamingHelper.js\";\nimport { EntityBasedGeneratorFunction, GeneratorFunctionOptions } from \"../FactoryFunctionModel.js\";\nimport { FileHandler } from \"../project/FileHandler.js\";\nimport { ProjectManager } from \"../project/ProjectManager.js\";\nimport { CoreImports } from \"./import/ImportObjects.js\";\nimport { ImportContainer } from \"./ImportContainer.js\";\n\nexport const generateModels: EntityBasedGeneratorFunction = (\n project: ProjectManager,\n dataModel,\n version,\n options,\n namingHelper,\n) => {\n const generator = new ModelGenerator(project, dataModel, version, options, namingHelper);\n return generator.generate();\n};\n\nclass ModelGenerator {\n constructor(\n private project: ProjectManager,\n private dataModel: DataModel,\n private version: ODataVersions,\n private options: GeneratorFunctionOptions,\n private namingHelper: NamingHelper,\n ) {}\n\n public async generate(): Promise<void> {\n this.project.initModels();\n\n const promises: Array<Promise<void>> = [\n ...this.generateEnums(),\n ...this.generateEntityTypeModels(),\n ...this.generateComplexTypeModels(),\n ];\n\n if (!this.options.skipOperations) {\n promises.push(this.generateUnboundOperationParams());\n }\n\n await Promise.all(promises);\n\n return this.project.finalizeModels();\n }\n\n private generateEnums() {\n return this.dataModel.getEnums().map((et) => {\n const file = this.project.createOrGetModelFile(et.folderPath, et.modelName);\n\n const enumType = this.options.enumType;\n if (enumType === \"string-union\") {\n file.getFile().addTypeAlias({\n name: et.modelName,\n isExported: true,\n type: et.members.map((mem) => `\"${mem.name}\"`).join(\" | \"),\n });\n } else {\n file.getFile().addEnum({\n name: et.modelName,\n isExported: true,\n members: et.members.map((mem) => ({\n name: mem.name,\n initializer: enumType === \"numeric\" ? String(mem.value) : `\"${mem.name}\"`,\n })),\n });\n }\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateEntityTypeModels() {\n return this.dataModel.getEntityTypes().map((model) => {\n const file = this.project.createOrGetModelFile(model.folderPath, model.modelName, [\n model.modelName,\n model.id.modelName,\n model.editableName,\n ]);\n\n // query model\n this.generateModel(file, model);\n\n // key model\n if (!this.options.skipIdModels && model.generateId) {\n this.generateIdModel(file, model);\n }\n\n // editable model\n if (!this.options.skipEditableModels) {\n this.generateEditableModel(file, model);\n }\n\n // param models for bound operations\n if (!this.options.skipOperations) {\n [\n ...this.dataModel.getEntityTypeOperations(model.fqName),\n ...this.dataModel.getEntitySetOperations(model.fqName),\n ].forEach((operation) => {\n this.generateOperationParams(file, operation);\n });\n }\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateComplexTypeModels() {\n return this.dataModel.getComplexTypes().map((model) => {\n const file = this.project.createOrGetModelFile(model.folderPath, model.modelName, [\n model.modelName,\n model.editableName,\n ]);\n\n // query model\n this.generateModel(file, model);\n\n // editable model\n if (!this.options.skipEditableModels) {\n this.generateEditableModel(file, model);\n }\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateModel(file: FileHandler, model: ComplexType | EntityType) {\n const imports = file.getImports();\n let extendsClause = undefined;\n if (model.finalBaseClass) {\n const modelName = imports.addGeneratedModel(\n model.baseClasses[0],\n this.namingHelper.getModelName(model.finalBaseClass),\n );\n extendsClause = [modelName];\n }\n\n file.getFile().addInterface({\n name: model.modelName,\n isExported: true,\n properties: model.props.map((p) => {\n const isEntity = p.dataType == DataTypes.ModelType;\n return {\n name: p.name,\n type: this.getPropType(file.getImports(), p),\n // props for entities or entity collections are not added in V4 if not explicitly expanded\n hasQuestionToken: this.dataModel.isV4() && isEntity,\n docs: this.options.skipComments ? undefined : [this.generatePropDoc(p, model)],\n };\n }),\n extends: extendsClause,\n });\n }\n\n private generatePropDoc(prop: PropertyModel, model: ComplexType | EntityType): OptionalKind<JSDocStructure> {\n const isKeyProp = (model as EntityType).keyNames?.includes(prop.odataName);\n const baseAttribs: Array<string> = [];\n if (isKeyProp) {\n baseAttribs.push(\"**Key Property**: This is a key property used to identify the entity.\");\n }\n if (prop.managed) {\n baseAttribs.push(\"**Managed**: This property is managed on the server side and cannot be edited.\");\n }\n if (prop.converters?.length) {\n baseAttribs.push(`**Applied Converters**: ${prop.converters.map((c) => c.converterId).join(\",\")}.`);\n }\n\n const attributeTable: Array<[string, string]> = [\n [\"Name\", prop.odataName],\n [\"Type\", prop.odataType],\n ];\n if (prop.required) {\n attributeTable.push([\"Nullable\", \"false\"]);\n }\n\n const description =\n (baseAttribs ? baseAttribs.join(\"<br/>\") + \"\\n\\n\" : \"\") +\n \"OData Attributes:\\n\" +\n \"|Attribute Name | Attribute Value |\\n| --- | ---|\\n\" +\n attributeTable.map((row) => `| ${row[0]} | \\`${row[1]}\\` |`).join(\"\\n\");\n\n return { kind: StructureKind.JSDoc, description };\n }\n\n private getPropType(imports: ImportContainer, prop: PropertyModel): string {\n // V2 entity special: deferred content\n let suffix = \"\";\n if (this.dataModel.isV2() && prop.dataType == DataTypes.ModelType) {\n const defContent = imports.addCoreLib(this.version, CoreImports.DeferredContent);\n suffix = ` | ${defContent}`;\n }\n\n let typeName: string;\n if (prop.dataType === DataTypes.PrimitiveType) {\n // custom types which require type imports => possible via converters\n typeName = prop.typeModule ? imports.addCustomType(prop.typeModule, prop.type, true) : prop.type;\n } else {\n typeName = imports.addGeneratedModel(prop.fqType, prop.type);\n }\n\n // Collections\n if (prop.isCollection) {\n const type = `Array<${typeName}>`;\n if (this.dataModel.isV2() && this.options.v2ModelsWithExtraResultsWrapping) {\n return `{ results: ${type} }` + suffix;\n } else {\n return type + suffix;\n }\n }\n\n // primitive, enum & complex types\n return typeName + (prop.required ? \"\" : \" | null\") + suffix;\n }\n\n private generateIdModel(file: FileHandler, model: EntityType) {\n const singleType = model.keys.length === 1 ? `${model.keys[0].type} | ` : \"\";\n const keyTypes = model.keys\n .map((keyProp) => `${keyProp.name}: ${this.getPropType(file.getImports(), keyProp)}`)\n .join(\",\");\n const type = `${singleType}{${keyTypes}}`;\n\n file.getFile().addTypeAlias({\n name: model.id.modelName,\n isExported: true,\n type,\n });\n }\n\n private generateEditableModel(file: FileHandler, model: ComplexType) {\n const entityTypes = [DataTypes.ModelType, DataTypes.ComplexType];\n const allProps = [...model.baseProps, ...model.props].filter((p) => !p.managed);\n\n const requiredProps = allProps\n .filter((p) => p.required && !entityTypes.includes(p.dataType))\n .map((p) => `\"${p.name}\"`)\n .join(\" | \");\n const optionalProps = allProps\n .filter((p) => !p.required && !entityTypes.includes(p.dataType))\n .map((p) => `\"${p.name}\"`)\n .join(\" | \");\n const complexProps = allProps.filter((p) => p.dataType === DataTypes.ComplexType);\n\n const extendsClause = [\n requiredProps ? `Pick<${model.modelName}, ${requiredProps}>` : null,\n optionalProps ? `Partial<Pick<${model.modelName}, ${optionalProps}>>` : null,\n ].filter((e): e is string => !!e);\n\n file.getFile().addInterface({\n name: model.editableName,\n isExported: true,\n extends: extendsClause,\n properties: !complexProps\n ? undefined\n : complexProps.map((p) => {\n return {\n name: p.name,\n type: this.getEditablePropType(file.getImports(), p),\n // optional props don't need to be specified in editable model\n // also, entities would require deep insert func => we make it optional for now\n hasQuestionToken: !p.required || p.dataType === DataTypes.ModelType,\n };\n }),\n });\n }\n\n private getEditablePropType(imports: ImportContainer, prop: PropertyModel): string {\n const isModelType = [DataTypes.ModelType, DataTypes.ComplexType].includes(prop.dataType);\n\n let editableType = prop.type;\n if (isModelType) {\n const editName = this.dataModel.getComplexType(prop.fqType)!.editableName;\n editableType = imports.addGeneratedModel(prop.fqType, editName);\n }\n\n // Collections\n if (prop.isCollection) {\n return `Array<${editableType}>`;\n }\n\n // primitive, enum & complex types\n return editableType + (prop.required ? \"\" : \" | null\");\n }\n\n private async generateUnboundOperationParams() {\n const unboundOps = this.dataModel.getUnboundOperationTypes();\n const reservedNames = unboundOps.map((op) => op.paramsModelName);\n const file = this.project.createOrGetMainModelFile(reservedNames);\n\n unboundOps.forEach((operation) => {\n this.generateOperationParams(file, operation);\n });\n }\n\n private generateOperationParams(file: FileHandler, operation: OperationType) {\n const paramSets = [operation.parameters, ...(operation.overrides ?? [])].filter((pSet) => !!pSet.length);\n\n // standard: one interface for parameters\n if (paramSets.length === 1) {\n file.getFile().addInterface({\n name: operation.paramsModelName,\n isExported: true,\n properties: paramSets[0].map((p) => {\n return {\n name: p.name,\n type: this.getPropType(file.getImports(), p),\n hasQuestionToken: !p.required,\n };\n }),\n });\n }\n // function overload: one type with intersections of different param models\n else if (paramSets.length > 1) {\n file.getFile().addTypeAlias({\n name: operation.paramsModelName,\n isExported: true,\n type: (writer) => {\n paramSets.forEach((pSet, index) => {\n writer.block(() => {\n pSet.forEach((param, index) => {\n const paramType = this.getPropType(file.getImports(), param);\n writer.write(`${param.name}${param.required ? \"\" : \"?\"}: ${paramType}`);\n if (index < pSet.length - 1) {\n writer.write(\",\");\n }\n });\n });\n if (index < paramSets.length - 1) {\n writer.write(\" | \");\n }\n });\n },\n });\n }\n }\n}\n"]}
|
|
@@ -150,7 +150,7 @@ class QueryObjectGenerator {
|
|
|
150
150
|
const name = this.namingHelper.getQPropName(prop.name);
|
|
151
151
|
const isModelType = prop.dataType === "ModelType" /* DataTypes.ModelType */ || prop.dataType === "ComplexType" /* DataTypes.ComplexType */;
|
|
152
152
|
const isEnumType = prop.dataType === "EnumType" /* DataTypes.EnumType */;
|
|
153
|
-
const isNumericEnum = this.options.
|
|
153
|
+
const isNumericEnum = this.options.enumType === "numeric";
|
|
154
154
|
let qPathInit;
|
|
155
155
|
// factor in collections
|
|
156
156
|
if (prop.isCollection) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryObjectGenerator.js","sourceRoot":"","sources":["../../src/generator/QueryObjectGenerator.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAKL,KAAK,EACL,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAc9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D,MAAM,CAAC,MAAM,oBAAoB,GAAiC,CAChE,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,YAAY,EACZ,EAAE;IACF,MAAM,SAAS,GAAG,IAAI,oBAAoB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC/F,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC,CAAC;AAEF,MAAM,oBAAoB;IACxB,YACU,OAAuB,EACvB,SAAoB,EACpB,OAAsB,EACtB,OAAiC,EACjC,YAA0B;QAJ1B,YAAO,GAAP,OAAO,CAAgB;QACvB,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAe;QACtB,YAAO,GAAP,OAAO,CAA0B;QACjC,iBAAY,GAAZ,YAAY,CAAc;IACjC,CAAC;IAES,QAAQ;;YACnB,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;YAE5B,mCAAmC;YACnC,MAAM,QAAQ,GAAyB,CAAC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Import } from \"@odata2ts/converter-runtime\";\nimport { ODataVersions } from \"@odata2ts/odata-core\";\nimport {\n GetAccessorDeclarationStructure,\n MethodDeclarationStructure,\n OptionalKind,\n PropertyDeclarationStructure,\n Scope,\n VariableDeclarationKind,\n} from \"ts-morph\";\nimport { firstCharLowerCase } from \"xml2js/lib/processors.js\";\nimport { DataModel } from \"../data-model/DataModel.js\";\nimport {\n ComplexType,\n DataTypes,\n EntityType,\n OperationType,\n OperationTypes,\n PropertyModel,\n} from \"../data-model/DataTypeModel.js\";\nimport { NamingHelper } from \"../data-model/NamingHelper.js\";\nimport { EntityBasedGeneratorFunction, GeneratorFunctionOptions } from \"../FactoryFunctionModel.js\";\nimport { FileHandler } from \"../project/FileHandler.js\";\nimport { ProjectManager } from \"../project/ProjectManager.js\";\nimport { QueryObjectImports } from \"./import/ImportObjects.js\";\nimport { ImportContainer } from \"./ImportContainer.js\";\n\nexport const generateQueryObjects: EntityBasedGeneratorFunction = (\n project,\n dataModel,\n version,\n options,\n namingHelper,\n) => {\n const generator = new QueryObjectGenerator(project, dataModel, version, options, namingHelper);\n return generator.generate();\n};\n\nclass QueryObjectGenerator {\n constructor(\n private project: ProjectManager,\n private dataModel: DataModel,\n private version: ODataVersions,\n private options: GeneratorFunctionOptions,\n private namingHelper: NamingHelper,\n ) {}\n\n public async generate(): Promise<void> {\n this.project.initQObjects();\n\n // process EntityType & ComplexType\n const promises: Array<Promise<void>> = [...this.generateEntityTypes(), ...this.generateComplexTypes()];\n if (!this.options.skipOperations) {\n // process unbound operations\n promises.push(this.generateUnboundOperations());\n }\n\n await Promise.all(promises);\n\n return this.project.finalizeQObjects();\n }\n\n private generateEntityTypes() {\n return this.dataModel.getEntityTypes().map((model) => {\n const file = this.project.createOrGetQObjectFile(model.folderPath, model.qName, [\n model.qName,\n firstCharLowerCase(model.qName),\n model.id.qName,\n ]);\n\n // q object\n this.generateModel(file, model);\n\n // qId function\n if (!this.options.skipIdModels && model.generateId) {\n this.generateIdFunction(file, model);\n }\n\n // bound q operations\n if (!this.options.skipOperations) {\n [\n ...this.dataModel.getEntityTypeOperations(model.fqName),\n ...this.dataModel.getEntitySetOperations(model.fqName),\n ].forEach((operation) => {\n this.generateOperation(file, operation, model.fqName);\n });\n }\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateComplexTypes() {\n return this.dataModel.getComplexTypes().map((model) => {\n const file = this.project.createOrGetQObjectFile(model.folderPath, model.qName, [\n model.qName,\n firstCharLowerCase(model.qName),\n ]);\n\n this.generateModel(file, model);\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateModel(file: FileHandler, model: ComplexType) {\n const imports = file.getImports();\n const properties = this.generateQueryObjectProps(file.getImports(), model.props);\n\n let extendsClause: string;\n if (model.baseClasses.length) {\n const baseClass = model.baseClasses[0];\n const baseModel = this.dataModel.getModel(baseClass) as ComplexType;\n if (!baseModel) {\n throw new Error(`Entity or complex type \"${baseClass}\" from baseClass attribute not found!`);\n }\n extendsClause = imports.addGeneratedQObject(baseClass, baseModel.qBaseName!);\n } else {\n extendsClause = imports.addQObject(QueryObjectImports.QueryObject);\n }\n\n if (model.qBaseName) {\n // base class which used for extension\n file.getFile().addClass({\n name: model.qBaseName,\n isExported: true,\n extends: extendsClause,\n properties,\n });\n\n const [props, getAccessors, methods, statements] = Array.from(model.subtypes).reduce<\n [\n Array<string>,\n OptionalKind<GetAccessorDeclarationStructure>[],\n OptionalKind<MethodDeclarationStructure>[],\n Array<string>,\n ]\n >(\n (collector, subtype) => {\n const subClass = this.dataModel.getModel(subtype) as ComplexType;\n const methodName = `__as${subClass.qName}`;\n const enumerablePropDef = imports.addQObject(QueryObjectImports.ENUMERABLE_PROP_DEFINITION);\n\n collector[0].push(`\"${subClass.fqName}\": \"${subClass.qName}\"`);\n\n subClass.props.forEach((prop) => {\n const propName = this.namingHelper.getQPropName(prop.name);\n const fqPropName = `${subClass.qName}_${propName}`;\n collector[1].push({\n name: fqPropName,\n scope: Scope.Public,\n statements: `return this.${methodName}().${propName};`,\n });\n collector[3].push(`${fqPropName}: ${enumerablePropDef}`);\n });\n\n collector[2].push({\n name: methodName,\n scope: Scope.Private,\n statements: `return new ${subClass.qName}(this.withPrefix(\"${subClass.fqName}\"))`,\n });\n\n return collector;\n },\n [[], [], [], []],\n );\n\n file.getFile().addClass({\n name: model.qName,\n isExported: true,\n extends: model.qBaseName,\n properties: [\n {\n name: \"__subtypeMapping\",\n scope: Scope.Protected,\n isReadonly: true,\n initializer: `{ ${props.join(\",\")} }`,\n },\n ],\n getAccessors,\n methods,\n });\n\n file.getFile().addStatements(`Object.defineProperties(${model.qName}.prototype, { ${statements.join(\",\")} });`);\n } else {\n file.getFile().addClass({\n name: model.qName,\n isExported: true,\n extends: extendsClause,\n properties: properties,\n });\n }\n\n file.getFile().addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: firstCharLowerCase(model.qName),\n initializer: `new ${model.qName}()`,\n },\n ],\n });\n }\n\n private generateQueryObjectProps(\n importContainer: ImportContainer,\n props: Array<PropertyModel>,\n ): Array<OptionalKind<PropertyDeclarationStructure>> {\n return props.map((prop) => {\n const { odataName } = prop;\n const name = this.namingHelper.getQPropName(prop.name);\n const isModelType = prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType;\n const isEnumType = prop.dataType === DataTypes.EnumType;\n const isNumericEnum = this.options.numericEnums;\n\n let qPathInit: string;\n\n // factor in collections\n if (prop.isCollection) {\n const qPath = importContainer.addQObject(\n isModelType\n ? QueryObjectImports.QEntityCollectionPath\n : isEnumType\n ? isNumericEnum\n ? QueryObjectImports.QNumericEnumCollectionPath\n : QueryObjectImports.QEnumCollectionPath\n : QueryObjectImports.QCollectionPath,\n );\n const qObject = isModelType\n ? importContainer.addGeneratedQObject(prop.fqType, prop.qObject!)\n : isEnumType\n ? importContainer.addGeneratedModel(prop.fqType, prop.type, false)\n : importContainer.addQObject(prop.qObject!);\n\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\"), ${isEnumType ? qObject : `() => ${qObject}`})`;\n } else {\n // add import for data type\n const qPath = importContainer.addQObject(prop.qPath);\n if (isModelType) {\n const qObject = importContainer.addGeneratedQObject(prop.fqType, prop.qObject!);\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\"), () => ${qObject})`;\n } else if (isEnumType) {\n const qObject = importContainer.addGeneratedModel(prop.fqType, prop.type, false);\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\"), ${qObject})`;\n } else {\n let converterStmt = this.generateConverterStmt(importContainer, prop.converters);\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\")${converterStmt ? `, ${converterStmt}` : \"\"})`;\n }\n }\n\n return {\n name,\n scope: Scope.Public,\n isReadonly: true,\n initializer: qPathInit,\n } as OptionalKind<PropertyDeclarationStructure>;\n });\n }\n\n private generateConverterStmt(importContainer: ImportContainer, converters: Array<ValueConverterImport> | undefined) {\n if (!converters?.length) {\n return undefined;\n }\n const converterIds = converters.map((converter) => {\n return importContainer.addCustomType(converter.package, converter.converterId);\n });\n\n if (converterIds.length === 1) {\n return converterIds[0];\n } else {\n const createChain = importContainer.addCustomType(\"@odata2ts/converter-runtime\", \"createChain\");\n\n const [first, second, ...moreConverters] = converterIds;\n return moreConverters.reduce((stmt, convId) => `${stmt}.chain(${convId})`, `${createChain}(${first}, ${second})`);\n }\n }\n\n private generateIdFunction(file: FileHandler, model: EntityType) {\n const importContainer = file.getImports();\n const qFunc = importContainer.addQObject(QueryObjectImports.QId);\n const idModelName = importContainer.addGeneratedModel(model.fqName, model.id.modelName);\n\n file.getFile().addClass({\n name: model.id.qName,\n isExported: true,\n extends: `${qFunc}<${idModelName}>`,\n properties: [\n {\n name: \"params\",\n scope: Scope.Private,\n isReadonly: true,\n initializer: this.getParamInitString(importContainer, model.keys),\n },\n ],\n methods: [\n {\n name: \"getParams\",\n statements: [\"return this.params\"],\n },\n ],\n });\n }\n\n private getParamInitString(\n importContainer: ImportContainer,\n props: Array<PropertyModel>,\n overloads?: Array<Array<PropertyModel>>,\n ) {\n const allParams = [props, ...(overloads ?? [])].map((paramSet) => {\n const pString = paramSet\n .map((prop) => {\n let complexQParam = \"\";\n if (prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType) {\n const importedQObject = importContainer.addGeneratedQObject(prop.fqType, prop.qObject!);\n complexQParam = `, new ${importedQObject}()`;\n }\n\n const qParam = importContainer.addQObject(prop.qParam!);\n const isMappedNameNecessary = prop.odataName !== prop.name;\n const mappedName = isMappedNameNecessary\n ? `\"${prop.name}\"`\n : prop.converters?.length\n ? \"undefined\"\n : undefined;\n const converterStmt = this.generateConverterStmt(importContainer, prop.converters);\n const mappedNameParam = mappedName ? `, ${mappedName}` : \"\";\n const converterParam = converterStmt ? `, ${converterStmt}` : \"\";\n return `new ${qParam}(\"${prop.odataName}\"${complexQParam}${mappedNameParam}${converterParam})`;\n })\n .join(\",\");\n return `[${pString}]`;\n });\n\n return allParams.length === 1 ? allParams[0] : `[${allParams.join(\",\")}]`;\n }\n\n private async generateUnboundOperations() {\n const unboundOps = this.dataModel.getUnboundOperationTypes();\n const reservedNames = unboundOps.map((op) => op.qName);\n const file = this.project.createOrGetMainQObjectFile(reservedNames);\n\n unboundOps.forEach((operation) => {\n this.generateOperation(file, operation, \"\");\n });\n }\n\n private generateOperation(file: FileHandler, operation: OperationType, baseFqName: string) {\n const imports = file.getImports();\n const isV2 = this.version === ODataVersions.V2;\n const returnType = operation.returnType;\n const hasParams = operation.parameters.length > 0 || operation.overrides?.length;\n const isParamsOptional = !![operation.parameters, ...(operation.overrides ?? [])].find((pSet) => pSet.length === 0);\n\n // imports\n const qOp = operation.type === OperationTypes.Action ? QueryObjectImports.QAction : QueryObjectImports.QFunction;\n const qOperation = imports.addQObject(qOp);\n const paramModelName = hasParams ? imports.addGeneratedModel(baseFqName, operation.paramsModelName) : undefined;\n\n let returnTypeOpStmt: string = \"\";\n if (returnType) {\n if (returnType.dataType === DataTypes.ComplexType || returnType.dataType === DataTypes.ModelType) {\n if (returnType.qObject) {\n const opRt = imports.addQObject(QueryObjectImports.OperationReturnType);\n const rts = imports.addQObject(QueryObjectImports.ReturnTypes);\n const rType = returnType.isCollection\n ? \"COLLECTION\"\n : returnType.dataType === DataTypes.ComplexType\n ? \"COMPLEX\"\n : \"ENTITY\";\n const qComplexParam = imports.addQObject(QueryObjectImports.QComplexParam);\n const returnQName = imports.addGeneratedQObject(returnType.fqType, returnType.qObject);\n\n returnTypeOpStmt = `new ${opRt}(${rts}.${rType}, new ${qComplexParam}(\"NONE\", new ${returnQName}))`;\n }\n }\n // currently, it only makes sense to add the OperationReturnType if a converter is present\n else if (returnType.converters && returnType.qParam) {\n const rtClass = imports.addQObject(QueryObjectImports.OperationReturnType);\n const rtTypes = imports.addQObject(QueryObjectImports.ReturnTypes);\n const rType = returnType.isCollection ? \"COLLECTION\" : \"VALUE\";\n const qParam = imports.addQObject(returnType.qParam);\n\n const rtKind = `${rtTypes}.${rType}`;\n\n const converterParam = returnType.converters\n ? \", \" + this.generateConverterStmt(imports, returnType.converters)\n : \"\";\n returnTypeOpStmt = `new ${rtClass}(${rtKind}, new ${qParam}(\"NONE\", undefined${converterParam}))`;\n }\n }\n\n file.getFile().addClass({\n name: operation.qName,\n isExported: true,\n extends: qOperation + (hasParams ? `<${paramModelName}>` : \"\"),\n properties: [\n {\n name: \"params\",\n scope: Scope.Private,\n isReadonly: true,\n type: hasParams ? undefined : \"[]\",\n initializer: this.getParamInitString(imports, operation.parameters, operation.overrides),\n },\n ],\n ctors: [\n {\n statements: [\n `super(\"${operation.odataName}\"${returnTypeOpStmt ? \", \" + returnTypeOpStmt : isV2 ? \", undefined\" : \"\"}${\n isV2 ? \", { v2Mode: true }\" : \"\"\n })`,\n ],\n },\n ],\n methods: [\n {\n name: \"getParams\",\n statements: [\"return this.params\"],\n },\n // functions without params: add an overriding buildUrl() to not force users to have to pass undefined as param\n ...(operation.type === OperationTypes.Function && !hasParams\n ? [\n {\n name: \"buildUrl\",\n parameters: [\n {\n name: \"notEncoded\",\n initializer: \"false\",\n },\n ],\n statements: [\"return super.buildUrl(undefined, notEncoded)\"],\n } as OptionalKind<MethodDeclarationStructure>,\n ]\n : []),\n ],\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"QueryObjectGenerator.js","sourceRoot":"","sources":["../../src/generator/QueryObjectGenerator.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAKL,KAAK,EACL,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAc9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D,MAAM,CAAC,MAAM,oBAAoB,GAAiC,CAChE,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,YAAY,EACZ,EAAE;IACF,MAAM,SAAS,GAAG,IAAI,oBAAoB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC/F,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC,CAAC;AAEF,MAAM,oBAAoB;IACxB,YACU,OAAuB,EACvB,SAAoB,EACpB,OAAsB,EACtB,OAAiC,EACjC,YAA0B;QAJ1B,YAAO,GAAP,OAAO,CAAgB;QACvB,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAe;QACtB,YAAO,GAAP,OAAO,CAA0B;QACjC,iBAAY,GAAZ,YAAY,CAAc;IACjC,CAAC;IAES,QAAQ;;YACnB,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;YAE5B,mCAAmC;YACnC,MAAM,QAAQ,GAAyB,CAAC,GAAG,IAAI,CAAC,mBAAmB,EAAE,EAAE,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;YACvG,IAAI,CAAC,IAAI,CAAC,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E,UAAU,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,cAAc,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9D,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,KAAK,CAAC,OAAO;oBACpB,UAAU,EAAE,IAAI;oBAChB,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;oBAClC,WAAW,EAAE,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,SAAS,CAAC;iBACzF;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;gCACV;oCACE,IAAI,EAAE,YAAY;oCAClB,WAAW,EAAE,OAAO;iCACrB;6BACF;4BACD,UAAU,EAAE,CAAC,8CAA8C,CAAC;yBACjB;qBAC9C;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ValueConverterImport } from \"@odata2ts/converter-runtime\";\nimport { ODataVersions } from \"@odata2ts/odata-core\";\nimport {\n GetAccessorDeclarationStructure,\n MethodDeclarationStructure,\n OptionalKind,\n PropertyDeclarationStructure,\n Scope,\n VariableDeclarationKind,\n} from \"ts-morph\";\nimport { firstCharLowerCase } from \"xml2js/lib/processors.js\";\nimport { DataModel } from \"../data-model/DataModel.js\";\nimport {\n ComplexType,\n DataTypes,\n EntityType,\n OperationType,\n OperationTypes,\n PropertyModel,\n} from \"../data-model/DataTypeModel.js\";\nimport { NamingHelper } from \"../data-model/NamingHelper.js\";\nimport { EntityBasedGeneratorFunction, GeneratorFunctionOptions } from \"../FactoryFunctionModel.js\";\nimport { FileHandler } from \"../project/FileHandler.js\";\nimport { ProjectManager } from \"../project/ProjectManager.js\";\nimport { QueryObjectImports } from \"./import/ImportObjects.js\";\nimport { ImportContainer } from \"./ImportContainer.js\";\n\nexport const generateQueryObjects: EntityBasedGeneratorFunction = (\n project,\n dataModel,\n version,\n options,\n namingHelper,\n) => {\n const generator = new QueryObjectGenerator(project, dataModel, version, options, namingHelper);\n return generator.generate();\n};\n\nclass QueryObjectGenerator {\n constructor(\n private project: ProjectManager,\n private dataModel: DataModel,\n private version: ODataVersions,\n private options: GeneratorFunctionOptions,\n private namingHelper: NamingHelper,\n ) {}\n\n public async generate(): Promise<void> {\n this.project.initQObjects();\n\n // process EntityType & ComplexType\n const promises: Array<Promise<void>> = [...this.generateEntityTypes(), ...this.generateComplexTypes()];\n if (!this.options.skipOperations) {\n // process unbound operations\n promises.push(this.generateUnboundOperations());\n }\n\n await Promise.all(promises);\n\n return this.project.finalizeQObjects();\n }\n\n private generateEntityTypes() {\n return this.dataModel.getEntityTypes().map((model) => {\n const file = this.project.createOrGetQObjectFile(model.folderPath, model.qName, [\n model.qName,\n firstCharLowerCase(model.qName),\n model.id.qName,\n ]);\n\n // q object\n this.generateModel(file, model);\n\n // qId function\n if (!this.options.skipIdModels && model.generateId) {\n this.generateIdFunction(file, model);\n }\n\n // bound q operations\n if (!this.options.skipOperations) {\n [\n ...this.dataModel.getEntityTypeOperations(model.fqName),\n ...this.dataModel.getEntitySetOperations(model.fqName),\n ].forEach((operation) => {\n this.generateOperation(file, operation, model.fqName);\n });\n }\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateComplexTypes() {\n return this.dataModel.getComplexTypes().map((model) => {\n const file = this.project.createOrGetQObjectFile(model.folderPath, model.qName, [\n model.qName,\n firstCharLowerCase(model.qName),\n ]);\n\n this.generateModel(file, model);\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateModel(file: FileHandler, model: ComplexType) {\n const imports = file.getImports();\n const properties = this.generateQueryObjectProps(file.getImports(), model.props);\n\n let extendsClause: string;\n if (model.baseClasses.length) {\n const baseClass = model.baseClasses[0];\n const baseModel = this.dataModel.getModel(baseClass) as ComplexType;\n if (!baseModel) {\n throw new Error(`Entity or complex type \"${baseClass}\" from baseClass attribute not found!`);\n }\n extendsClause = imports.addGeneratedQObject(baseClass, baseModel.qBaseName!);\n } else {\n extendsClause = imports.addQObject(QueryObjectImports.QueryObject);\n }\n\n if (model.qBaseName) {\n // base class which used for extension\n file.getFile().addClass({\n name: model.qBaseName,\n isExported: true,\n extends: extendsClause,\n properties,\n });\n\n const [props, getAccessors, methods, statements] = Array.from(model.subtypes).reduce<\n [\n Array<string>,\n OptionalKind<GetAccessorDeclarationStructure>[],\n OptionalKind<MethodDeclarationStructure>[],\n Array<string>,\n ]\n >(\n (collector, subtype) => {\n const subClass = this.dataModel.getModel(subtype) as ComplexType;\n const methodName = `__as${subClass.qName}`;\n const enumerablePropDef = imports.addQObject(QueryObjectImports.ENUMERABLE_PROP_DEFINITION);\n\n collector[0].push(`\"${subClass.fqName}\": \"${subClass.qName}\"`);\n\n subClass.props.forEach((prop) => {\n const propName = this.namingHelper.getQPropName(prop.name);\n const fqPropName = `${subClass.qName}_${propName}`;\n collector[1].push({\n name: fqPropName,\n scope: Scope.Public,\n statements: `return this.${methodName}().${propName};`,\n });\n collector[3].push(`${fqPropName}: ${enumerablePropDef}`);\n });\n\n collector[2].push({\n name: methodName,\n scope: Scope.Private,\n statements: `return new ${subClass.qName}(this.withPrefix(\"${subClass.fqName}\"))`,\n });\n\n return collector;\n },\n [[], [], [], []],\n );\n\n file.getFile().addClass({\n name: model.qName,\n isExported: true,\n extends: model.qBaseName,\n properties: [\n {\n name: \"__subtypeMapping\",\n scope: Scope.Protected,\n isReadonly: true,\n initializer: `{ ${props.join(\",\")} }`,\n },\n ],\n getAccessors,\n methods,\n });\n\n file.getFile().addStatements(`Object.defineProperties(${model.qName}.prototype, { ${statements.join(\",\")} });`);\n } else {\n file.getFile().addClass({\n name: model.qName,\n isExported: true,\n extends: extendsClause,\n properties: properties,\n });\n }\n\n file.getFile().addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: firstCharLowerCase(model.qName),\n initializer: `new ${model.qName}()`,\n },\n ],\n });\n }\n\n private generateQueryObjectProps(\n importContainer: ImportContainer,\n props: Array<PropertyModel>,\n ): Array<OptionalKind<PropertyDeclarationStructure>> {\n return props.map((prop) => {\n const { odataName } = prop;\n const name = this.namingHelper.getQPropName(prop.name);\n const isModelType = prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType;\n const isEnumType = prop.dataType === DataTypes.EnumType;\n const isNumericEnum = this.options.enumType === \"numeric\";\n\n let qPathInit: string;\n\n // factor in collections\n if (prop.isCollection) {\n const qPath = importContainer.addQObject(\n isModelType\n ? QueryObjectImports.QEntityCollectionPath\n : isEnumType\n ? isNumericEnum\n ? QueryObjectImports.QNumericEnumCollectionPath\n : QueryObjectImports.QEnumCollectionPath\n : QueryObjectImports.QCollectionPath,\n );\n const qObject = isModelType\n ? importContainer.addGeneratedQObject(prop.fqType, prop.qObject!)\n : isEnumType\n ? importContainer.addGeneratedModel(prop.fqType, prop.type, false)\n : importContainer.addQObject(prop.qObject!);\n\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\"), ${isEnumType ? qObject : `() => ${qObject}`})`;\n } else {\n // add import for data type\n const qPath = importContainer.addQObject(prop.qPath);\n if (isModelType) {\n const qObject = importContainer.addGeneratedQObject(prop.fqType, prop.qObject!);\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\"), () => ${qObject})`;\n } else if (isEnumType) {\n const qObject = importContainer.addGeneratedModel(prop.fqType, prop.type, false);\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\"), ${qObject})`;\n } else {\n let converterStmt = this.generateConverterStmt(importContainer, prop.converters);\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\")${converterStmt ? `, ${converterStmt}` : \"\"})`;\n }\n }\n\n return {\n name,\n scope: Scope.Public,\n isReadonly: true,\n initializer: qPathInit,\n } as OptionalKind<PropertyDeclarationStructure>;\n });\n }\n\n private generateConverterStmt(importContainer: ImportContainer, converters: Array<ValueConverterImport> | undefined) {\n if (!converters?.length) {\n return undefined;\n }\n const converterIds = converters.map((converter) => {\n return importContainer.addCustomType(converter.package, converter.converterId);\n });\n\n if (converterIds.length === 1) {\n return converterIds[0];\n } else {\n const createChain = importContainer.addCustomType(\"@odata2ts/converter-runtime\", \"createChain\");\n\n const [first, second, ...moreConverters] = converterIds;\n return moreConverters.reduce((stmt, convId) => `${stmt}.chain(${convId})`, `${createChain}(${first}, ${second})`);\n }\n }\n\n private generateIdFunction(file: FileHandler, model: EntityType) {\n const importContainer = file.getImports();\n const qFunc = importContainer.addQObject(QueryObjectImports.QId);\n const idModelName = importContainer.addGeneratedModel(model.fqName, model.id.modelName);\n\n file.getFile().addClass({\n name: model.id.qName,\n isExported: true,\n extends: `${qFunc}<${idModelName}>`,\n properties: [\n {\n name: \"params\",\n scope: Scope.Private,\n isReadonly: true,\n initializer: this.getParamInitString(importContainer, model.keys),\n },\n ],\n methods: [\n {\n name: \"getParams\",\n statements: [\"return this.params\"],\n },\n ],\n });\n }\n\n private getParamInitString(\n importContainer: ImportContainer,\n props: Array<PropertyModel>,\n overloads?: Array<Array<PropertyModel>>,\n ) {\n const allParams = [props, ...(overloads ?? [])].map((paramSet) => {\n const pString = paramSet\n .map((prop) => {\n let complexQParam = \"\";\n if (prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType) {\n const importedQObject = importContainer.addGeneratedQObject(prop.fqType, prop.qObject!);\n complexQParam = `, new ${importedQObject}()`;\n }\n\n const qParam = importContainer.addQObject(prop.qParam!);\n const isMappedNameNecessary = prop.odataName !== prop.name;\n const mappedName = isMappedNameNecessary\n ? `\"${prop.name}\"`\n : prop.converters?.length\n ? \"undefined\"\n : undefined;\n const converterStmt = this.generateConverterStmt(importContainer, prop.converters);\n const mappedNameParam = mappedName ? `, ${mappedName}` : \"\";\n const converterParam = converterStmt ? `, ${converterStmt}` : \"\";\n return `new ${qParam}(\"${prop.odataName}\"${complexQParam}${mappedNameParam}${converterParam})`;\n })\n .join(\",\");\n return `[${pString}]`;\n });\n\n return allParams.length === 1 ? allParams[0] : `[${allParams.join(\",\")}]`;\n }\n\n private async generateUnboundOperations() {\n const unboundOps = this.dataModel.getUnboundOperationTypes();\n const reservedNames = unboundOps.map((op) => op.qName);\n const file = this.project.createOrGetMainQObjectFile(reservedNames);\n\n unboundOps.forEach((operation) => {\n this.generateOperation(file, operation, \"\");\n });\n }\n\n private generateOperation(file: FileHandler, operation: OperationType, baseFqName: string) {\n const imports = file.getImports();\n const isV2 = this.version === ODataVersions.V2;\n const returnType = operation.returnType;\n const hasParams = operation.parameters.length > 0 || operation.overrides?.length;\n const isParamsOptional = !![operation.parameters, ...(operation.overrides ?? [])].find((pSet) => pSet.length === 0);\n\n // imports\n const qOp = operation.type === OperationTypes.Action ? QueryObjectImports.QAction : QueryObjectImports.QFunction;\n const qOperation = imports.addQObject(qOp);\n const paramModelName = hasParams ? imports.addGeneratedModel(baseFqName, operation.paramsModelName) : undefined;\n\n let returnTypeOpStmt: string = \"\";\n if (returnType) {\n if (returnType.dataType === DataTypes.ComplexType || returnType.dataType === DataTypes.ModelType) {\n if (returnType.qObject) {\n const opRt = imports.addQObject(QueryObjectImports.OperationReturnType);\n const rts = imports.addQObject(QueryObjectImports.ReturnTypes);\n const rType = returnType.isCollection\n ? \"COLLECTION\"\n : returnType.dataType === DataTypes.ComplexType\n ? \"COMPLEX\"\n : \"ENTITY\";\n const qComplexParam = imports.addQObject(QueryObjectImports.QComplexParam);\n const returnQName = imports.addGeneratedQObject(returnType.fqType, returnType.qObject);\n\n returnTypeOpStmt = `new ${opRt}(${rts}.${rType}, new ${qComplexParam}(\"NONE\", new ${returnQName}))`;\n }\n }\n // currently, it only makes sense to add the OperationReturnType if a converter is present\n else if (returnType.converters && returnType.qParam) {\n const rtClass = imports.addQObject(QueryObjectImports.OperationReturnType);\n const rtTypes = imports.addQObject(QueryObjectImports.ReturnTypes);\n const rType = returnType.isCollection ? \"COLLECTION\" : \"VALUE\";\n const qParam = imports.addQObject(returnType.qParam);\n\n const rtKind = `${rtTypes}.${rType}`;\n\n const converterParam = returnType.converters\n ? \", \" + this.generateConverterStmt(imports, returnType.converters)\n : \"\";\n returnTypeOpStmt = `new ${rtClass}(${rtKind}, new ${qParam}(\"NONE\", undefined${converterParam}))`;\n }\n }\n\n file.getFile().addClass({\n name: operation.qName,\n isExported: true,\n extends: qOperation + (hasParams ? `<${paramModelName}>` : \"\"),\n properties: [\n {\n name: \"params\",\n scope: Scope.Private,\n isReadonly: true,\n type: hasParams ? undefined : \"[]\",\n initializer: this.getParamInitString(imports, operation.parameters, operation.overrides),\n },\n ],\n ctors: [\n {\n statements: [\n `super(\"${operation.odataName}\"${returnTypeOpStmt ? \", \" + returnTypeOpStmt : isV2 ? \", undefined\" : \"\"}${\n isV2 ? \", { v2Mode: true }\" : \"\"\n })`,\n ],\n },\n ],\n methods: [\n {\n name: \"getParams\",\n statements: [\"return this.params\"],\n },\n // functions without params: add an overriding buildUrl() to not force users to have to pass undefined as param\n ...(operation.type === OperationTypes.Function && !hasParams\n ? [\n {\n name: \"buildUrl\",\n parameters: [\n {\n name: \"notEncoded\",\n initializer: \"false\",\n },\n ],\n statements: [\"return super.buildUrl(undefined, notEncoded)\"],\n } as OptionalKind<MethodDeclarationStructure>,\n ]\n : []),\n ],\n });\n }\n}\n"]}
|
|
@@ -6,6 +6,6 @@ import { ConfigFileOptions } from "../OptionModel.js";
|
|
|
6
6
|
import { ProjectManager } from "../project/ProjectManager.js";
|
|
7
7
|
export interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, "properties" | "methods">> {
|
|
8
8
|
}
|
|
9
|
-
export interface ServiceGeneratorOptions extends Pick<ConfigFileOptions, "enablePrimitivePropertyServices" | "v4BigNumberAsString" | "
|
|
9
|
+
export interface ServiceGeneratorOptions extends Pick<ConfigFileOptions, "enablePrimitivePropertyServices" | "v4BigNumberAsString" | "enumType"> {
|
|
10
10
|
}
|
|
11
11
|
export declare function generateServices(project: ProjectManager, dataModel: DataModel, version: ODataVersions, namingHelper: NamingHelper, options?: ServiceGeneratorOptions): Promise<void>;
|
|
@@ -271,7 +271,7 @@ class ServiceGenerator {
|
|
|
271
271
|
}
|
|
272
272
|
const collectionServiceType = imports.addServiceObject(this.version, ServiceImports.CollectionService);
|
|
273
273
|
const isEnum = prop.dataType === "EnumType" /* DataTypes.EnumType */;
|
|
274
|
-
const isNumericEnum = this.options.
|
|
274
|
+
const isNumericEnum = this.options.enumType === "numeric";
|
|
275
275
|
let qType;
|
|
276
276
|
let type;
|
|
277
277
|
if (isEnum) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAKL,KAAK,GACN,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAgB9D,OAAO,EAAqB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG7D,OA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W,CAAC,0BAA0B,CAAC;QAE/C,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACxD,CAAC;IAEO,sBAAsB,CAC5B,eAAgC,EAChC,KAAkB,EAClB,YAAqB;QAErB,MAAM,MAAM,GAAgB,EAAE,UAAU,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAE5D,IAAI,IAAI,CAAC,OAAO,KAAK,aAAa,CAAC,EAAE,EAAE;YACrC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAgB,CAAC;gBACjE,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;gBACzF,MAAM,WAAW,GAAG,eAAe,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;gBACtF,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;oBAClB,IAAI,EAAE,KAAK,cAAc,CAAC,WAAW,CAAC,EAAE;oBACxC,KAAK,EAAE,KAAK,CAAC,MAAM;oBACnB,UAAU,EAAE;wBACV,gDAAgD;wBAChD,cAAc,WAAW,mBAAmB,QAAQ,CAAC,MAAM,oCAAoC;qBAChG;iBACF,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport deepmerge from \"deepmerge\";\nimport {\n ClassDeclarationStructure,\n MethodDeclarationStructure,\n OptionalKind,\n PropertyDeclarationStructure,\n Scope,\n} from \"ts-morph\";\nimport { upperCaseFirst } from \"upper-case-first\";\nimport { firstCharLowerCase } from \"xml2js/lib/processors.js\";\nimport { DataModel } from \"../data-model/DataModel.js\";\nimport {\n ActionImportType,\n ComplexType,\n DataTypes,\n EntityContainerModel,\n EntityType,\n FunctionImportType,\n OperationType,\n OperationTypes,\n PropertyModel,\n ReturnTypeModel,\n SingletonType,\n} from \"../data-model/DataTypeModel.js\";\nimport { NamingHelper } from \"../data-model/NamingHelper.js\";\nimport { ConfigFileOptions, Modes } from \"../OptionModel.js\";\nimport { FileHandler } from \"../project/FileHandler.js\";\nimport { ProjectManager } from \"../project/ProjectManager.js\";\nimport { ClientApiImports, CoreImports, QueryObjectImports, ServiceImports } from \"./import/ImportObjects.js\";\nimport { ImportContainer } from \"./ImportContainer.js\";\n\nexport interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, \"properties\" | \"methods\">> {}\n\nexport interface ServiceGeneratorOptions\n extends Pick<ConfigFileOptions, \"enablePrimitivePropertyServices\" | \"v4BigNumberAsString\" | \"numericEnums\"> {}\n\nexport async function generateServices(\n project: ProjectManager,\n dataModel: DataModel,\n version: ODataVersions,\n namingHelper: NamingHelper,\n options?: ServiceGeneratorOptions,\n) {\n const generator = new ServiceGenerator(project, dataModel, version, namingHelper, options);\n return generator.generate();\n}\n\nclass ServiceGenerator {\n constructor(\n private project: ProjectManager,\n private dataModel: DataModel,\n private version: ODataVersions,\n private namingHelper: NamingHelper,\n private options: ServiceGeneratorOptions = {},\n ) {}\n\n private isV4BigNumber() {\n return this.options.v4BigNumberAsString && this.version === ODataVersions.V4;\n }\n\n public async generate(): Promise<void> {\n const mainServiceName = this.namingHelper.getMainServiceName();\n this.project.initServices();\n\n await Promise.all([\n this.generateMainService(mainServiceName),\n ...this.generateEntityTypeServices(),\n ...this.generateComplexTypeServices(),\n ]);\n\n return this.project.finalizeServices();\n }\n\n private async generateMainService(mainServiceName: string) {\n const mainServiceFile = this.project.getMainServiceFile();\n const importContainer = mainServiceFile.getImports();\n const container = this.dataModel.getEntityContainer();\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\n\n const httpClient = importContainer.addClientApi(ClientApiImports.ODataHttpClient);\n const rootService = importContainer.addServiceObject(this.version, ServiceImports.ODataService);\n\n const { properties, methods }: PropsAndOps = deepmerge(\n this.generateMainServiceProperties(container, importContainer),\n this.generateMainServiceOperations(unboundOperations, importContainer),\n );\n\n mainServiceFile.getFile().addClass({\n isExported: true,\n name: mainServiceName,\n typeParameters: [`in out ClientType extends ${httpClient}`],\n extends: `${rootService}<ClientType>`,\n ctors: this.isV4BigNumber()\n ? [\n {\n parameters: [\n { name: \"client\", type: \"ClientType\" },\n { name: \"basePath\", type: \"string\" },\n {\n name: \"options\",\n type: importContainer.addServiceObject(this.version, ServiceImports.ODataServiceOptions),\n hasQuestionToken: true,\n },\n ],\n statements: [`super(client, basePath, options);`, \"this.__base.options.bigNumbersAsString = true;\"],\n },\n ]\n : [],\n properties,\n methods,\n });\n }\n\n private generateMainServiceProperties(\n container: EntityContainerModel,\n importContainer: ImportContainer,\n ): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n Object.values(container.entitySets).forEach(({ name, odataName, entityType }) => {\n result.methods.push(this.generateRelatedServiceGetter(name, odataName, entityType, importContainer));\n });\n\n Object.values(container.singletons).forEach((singleton) => {\n result.properties.push(this.generateSingletonProp(importContainer, singleton));\n result.methods.push(this.generateSingletonGetter(singleton));\n });\n\n return result;\n }\n\n private generateMainServiceOperations(\n ops: Array<FunctionImportType | ActionImportType>,\n importContainer: ImportContainer,\n ): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n ops.forEach(({ operation, name }) => {\n const op = this.dataModel.getUnboundOperationType(operation);\n if (!op) {\n throw new Error(`Operation \"${operation}\" not found!`);\n }\n\n result.properties.push(this.generateQOperationProp(op));\n result.methods.push(this.generateMethod(name, op, importContainer, \"\"));\n });\n\n return result;\n }\n\n private generateRelatedServiceGetter(\n propName: string,\n odataPropName: string,\n entityType: EntityType,\n imports: ImportContainer,\n ): OptionalKind<MethodDeclarationStructure> {\n const idName = imports.addGeneratedModel(entityType.id.fqName, entityType.id.modelName);\n const idFunctionName = imports.addGeneratedQObject(entityType.id.fqName, entityType.id.qName);\n const serviceName = imports.addGeneratedService(entityType.fqName, entityType.serviceName);\n const collectionName = imports.addGeneratedService(entityType.fqName, entityType.serviceCollectionName);\n\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(propName),\n parameters: [\n {\n name: \"id\",\n type: `${idName} | undefined`,\n hasQuestionToken: true,\n },\n ],\n overloads: [\n {\n parameters: [],\n returnType: `${collectionName}<ClientType>`,\n },\n {\n parameters: [\n {\n name: \"id\",\n type: idName,\n },\n ],\n returnType: `${serviceName}<ClientType>`,\n },\n ],\n statements: [\n `const fieldName = \"${odataPropName}\";`,\n `const { client, path, options, isUrlNotEncoded } = this.__base;`,\n 'return typeof id === \"undefined\" || id === null',\n `? new ${collectionName}(client, path, fieldName, options)`,\n `: new ${serviceName}(client, path, new ${idFunctionName}(fieldName).buildUrl(id, isUrlNotEncoded()), options);`,\n ],\n };\n }\n\n private generateSingletonProp(\n importContainer: ImportContainer,\n singleton: SingletonType,\n ): OptionalKind<PropertyDeclarationStructure> {\n const { name, entityType } = singleton;\n const type = entityType.serviceName;\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(name),\n type: `${type}<ClientType>`,\n hasQuestionToken: true,\n };\n }\n\n private generateQOperationProp = (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 generateSingletonGetter(singleton: SingletonType): OptionalKind<MethodDeclarationStructure> {\n const { name, odataName, entityType } = singleton;\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\n const serviceType = entityType.serviceName;\n\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(name),\n statements: [\n `if(!${propName}) {`,\n ` const { client, path, options } = this.__base;`,\n // prettier-ignore\n ` ${propName} = new ${serviceType}(client, path, \"${odataName}\", options)`,\n \"}\",\n `return ${propName}`,\n ],\n };\n }\n\n private generateEntityTypeService(file: FileHandler, model: ComplexType, isComplexType = false) {\n const importContainer = file.getImports();\n\n const operations = this.dataModel.getEntityTypeOperations(model.fqName);\n const props = [...model.baseProps, ...model.props];\n\n const entityServiceType = importContainer.addServiceObject(\n this.version,\n this.version === ODataVersions.V2 && isComplexType\n ? ServiceImports.ComplexTypeService\n : ServiceImports.EntityTypeService,\n );\n const httpClient = importContainer.addClientApi(ClientApiImports.ODataHttpClient);\n\n // note: predictable first imports => no need to take renaming into account\n const modelName = importContainer.addGeneratedModel(model.fqName, model.modelName);\n const editableModelName = importContainer.addGeneratedModel(model.fqName, model.editableName);\n const qName = importContainer.addGeneratedQObject(model.fqName, model.qName, true);\n const qObjectName = importContainer.addGeneratedQObject(model.fqName, firstCharLowerCase(model.qName));\n const serviceOptions = importContainer.addServiceObject(\n this.version,\n this.version === ODataVersions.V4\n ? ServiceImports.ODataServiceOptionsInternal\n : ServiceImports.ODataServiceOptions,\n );\n\n const { properties, methods }: PropsAndOps = deepmerge(\n deepmerge(\n this.generateServiceProperties(importContainer, model.serviceName, props),\n this.generateServiceOperations(importContainer, model, operations),\n ),\n this.generateCastOperations(importContainer, model, false),\n );\n\n // generate EntityTypeService\n file.getFile().addClass({\n isExported: true,\n name: model.serviceName,\n typeParameters: [`in out ClientType extends ${httpClient}`],\n extends: entityServiceType + `<ClientType, ${modelName}, ${editableModelName}, ${qName}>`,\n ctors: [\n {\n parameters: [\n { name: \"client\", type: \"ClientType\" },\n { name: \"basePath\", type: \"string\" },\n { name: \"name\", type: \"string\" },\n { name: \"options\", type: serviceOptions, hasQuestionToken: true },\n ],\n statements: [`super(client, basePath, name, ${qObjectName}, options);`],\n },\n ],\n properties,\n methods,\n });\n }\n\n private generateServiceProperties(\n importContainer: ImportContainer,\n serviceName: string,\n props: Array<PropertyModel>,\n ): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n props.forEach((prop) => {\n // collection of ComplexTypes, ComplexTypes, or EntityTypes\n if ((prop.dataType === DataTypes.ModelType && !prop.isCollection) || prop.dataType === DataTypes.ComplexType) {\n result.properties.push(this.generateModelProp(importContainer, prop));\n result.methods.push(this.generateModelPropGetter(importContainer, prop));\n } else if (prop.isCollection) {\n // collection of EntityTypes\n if (prop.dataType === DataTypes.ModelType) {\n const entityType = this.dataModel.getEntityType(prop.fqType);\n if (!entityType) {\n throw new Error(`Entity type \"${prop.fqType}\" specified by property not found!`);\n }\n\n result.methods.push(\n this.generateRelatedServiceGetter(prop.name, prop.odataName, entityType, importContainer),\n );\n }\n // collection of primitive or enum types\n else {\n result.properties.push(this.generatePrimitiveCollectionProp(importContainer, prop));\n result.methods.push(this.generatePrimitiveCollectionGetter(importContainer, prop));\n }\n }\n // generation of services for each primitive property: turned off by default\n else if (this.options.enablePrimitivePropertyServices && prop.dataType === DataTypes.PrimitiveType) {\n result.properties.push(this.generatePrimitiveTypeProp(importContainer, prop));\n result.methods.push(this.generatePrimitiveTypeGetter(importContainer, prop));\n }\n });\n\n return result;\n }\n\n private generateServiceOperations(\n importContainer: ImportContainer,\n model: ComplexType,\n operations: Array<OperationType>,\n ): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n operations.forEach((operation) => {\n result.properties.push(this.generateQOperationProp(operation));\n result.methods.push(this.generateMethod(operation.name, operation, importContainer, model.fqName));\n });\n\n return result;\n }\n\n private generateModelProp(imports: ImportContainer, prop: PropertyModel): PropertyDeclarationStructure {\n const propModel = this.dataModel.getModel(prop.fqType) as ComplexType;\n let propModelType: string;\n\n if (prop.isCollection) {\n const modelName = imports.addGeneratedModel(propModel.fqName, propModel.modelName);\n const editableModelName = imports.addGeneratedModel(propModel.fqName, propModel.editableName);\n const qModelName = imports.addGeneratedQObject(propModel.fqName, propModel.qName, true);\n const collectionServiceType = imports.addServiceObject(this.version, ServiceImports.CollectionService);\n\n propModelType = `${collectionServiceType}<ClientType, ${modelName}, ${qModelName}, ${editableModelName}>`;\n } else {\n const serviceName = imports.addGeneratedService(propModel.fqName, propModel.serviceName);\n propModelType = `${serviceName}<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 private generatePrimitiveCollectionProp(\n imports: ImportContainer,\n prop: PropertyModel,\n ): OptionalKind<PropertyDeclarationStructure> {\n if (!prop.qObject) {\n throw new Error(\"Illegal State: [qObject] must be provided for Collection types!\");\n }\n\n const collectionServiceType = imports.addServiceObject(this.version, ServiceImports.CollectionService);\n const isEnum = prop.dataType === DataTypes.EnumType;\n const isNumericEnum = this.options.numericEnums;\n let qType: string;\n let type: string;\n\n if (isEnum) {\n const propEnum = this.dataModel.getModel(prop.fqType)!;\n const propTypeModel = imports.addGeneratedModel(propEnum.fqName, propEnum.modelName, false);\n type = `${imports.addQObjectType(QueryObjectImports.EnumCollection)}<typeof ${propTypeModel}>`;\n qType = `${imports.addQObjectType(\n isNumericEnum ? QueryObjectImports.QNumericEnumCollection : QueryObjectImports.QEnumCollection,\n )}<typeof ${propTypeModel}>`;\n } else {\n // TODO refactor string concat\n type = imports.addQObjectType(`${upperCaseFirst(prop.type)}Collection`);\n qType = imports.addQObjectType(prop.qObject);\n }\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(prop.name),\n type: `${collectionType}`,\n hasQuestionToken: true,\n };\n }\n\n private generatePrimitiveTypeProp(\n imports: ImportContainer,\n prop: PropertyModel,\n ): OptionalKind<PropertyDeclarationStructure> {\n const serviceType = imports.addServiceObject(this.version, ServiceImports.PrimitiveTypeService);\n const type = prop.typeModule ? imports.addCustomType(prop.typeModule, prop.type, true) : prop.type;\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(prop.name),\n type: `${serviceType}<ClientType, ${type}>`,\n hasQuestionToken: true,\n };\n }\n\n private generateModelPropGetter(\n imports: ImportContainer,\n prop: PropertyModel,\n ): OptionalKind<MethodDeclarationStructure> {\n const model = this.dataModel.getModel(prop.fqType) as ComplexType;\n const isComplexCollection = prop.isCollection && model.dataType === DataTypes.ComplexType;\n\n const type = isComplexCollection\n ? imports.addServiceObject(this.version, ServiceImports.CollectionService)\n : prop.isCollection\n ? model.serviceCollectionName\n : model.serviceName;\n const typeWithGenerics = isComplexCollection\n ? `${type}<ClientType, ${imports.addGeneratedModel(model.fqName, model.modelName)}, ${imports.addGeneratedQObject(\n model.fqName,\n model.qName,\n true,\n )}, ${imports.addGeneratedModel(model.fqName, model.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 ` const { client, path, options } = this.__base;`,\n // prettier-ignore\n ` ${privateSrvProp} = new ${type}(client, path, \"${prop.odataName}\"${isComplexCollection ? `, ${imports.addGeneratedQObject(model.fqName, firstCharLowerCase(model.qName))}`: \"\"}, options)`,\n \"}\",\n `return ${privateSrvProp}`,\n ],\n };\n }\n\n private generatePrimitiveCollectionGetter(\n imports: ImportContainer,\n prop: PropertyModel,\n ): OptionalKind<MethodDeclarationStructure> {\n const collectionServiceType = imports.addServiceObject(this.version, ServiceImports.CollectionService);\n const qCollectionName = imports.addQObject(prop.qObject!);\n const enumName =\n prop.dataType === DataTypes.EnumType ? imports.addGeneratedModel(prop.fqType, prop.type) : undefined;\n\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 ` const { client, path, options } = this.__base;`,\n // prettier-ignore\n ` ${propName} = new ${collectionServiceType}(client, path, \"${prop.odataName}\", new ${qCollectionName}(${enumName ?? \"\"}), options)`,\n \"}\",\n `return ${propName}`,\n ],\n };\n }\n\n private generatePrimitiveTypeGetter(\n imports: ImportContainer,\n prop: PropertyModel,\n ): OptionalKind<MethodDeclarationStructure> {\n const serviceType = imports.addServiceObject(this.version, ServiceImports.PrimitiveTypeService);\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\n // for V2: mapped name must be specified\n const v2MappedName =\n this.version === ODataVersions.V4 ? \"\" : prop.name !== prop.odataName ? `, \"${prop.name}\"` : \", undefined\";\n\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\n statements: [\n `if(!${propName}) {`,\n ` const { client, path, qModel, options } = this.__base;`,\n ` ${propName} = new ${serviceType}(client, path, \"${prop.odataName}\", qModel.${prop.name}.converter${v2MappedName}, options)`,\n \"}\",\n `return ${propName}`,\n ],\n };\n }\n\n private generateEntityCollectionService(file: FileHandler, model: EntityType) {\n const importContainer = file.getImports();\n const editableModelName = model.editableName;\n const qObjectName = firstCharLowerCase(model.qName);\n\n const entitySetServiceType = importContainer.addServiceObject(this.version, ServiceImports.EntitySetService);\n const paramsModelName = importContainer.addGeneratedModel(model.id.fqName, model.id.modelName);\n const qIdFunctionName = importContainer.addGeneratedQObject(model.id.fqName, model.id.qName);\n const serviceOptions = importContainer.addServiceObject(\n this.version,\n this.version === ODataVersions.V4\n ? ServiceImports.ODataServiceOptionsInternal\n : ServiceImports.ODataServiceOptions,\n );\n\n const collectionOperations = this.dataModel.getEntitySetOperations(model.fqName);\n\n const { properties, methods } = deepmerge(\n this.generateServiceOperations(importContainer, model, collectionOperations),\n this.generateCastOperations(importContainer, model, true),\n );\n\n file.getFile().addClass({\n isExported: true,\n name: model.serviceCollectionName,\n typeParameters: [\"in out ClientType extends ODataHttpClient\"],\n extends:\n entitySetServiceType +\n `<ClientType, ${model.modelName}, ${editableModelName}, ${model.qName}, ${paramsModelName}>`,\n ctors: [\n {\n parameters: [\n { name: \"client\", type: \"ClientType\" },\n { name: \"basePath\", type: \"string\" },\n { name: \"name\", type: \"string\" },\n { name: \"options\", type: serviceOptions, hasQuestionToken: true },\n ],\n statements: [`super(client, basePath, name, ${qObjectName}, new ${qIdFunctionName}(name), options);`],\n },\n ],\n properties,\n methods,\n });\n }\n\n private generateEntityTypeServices(): Array<Promise<void>> {\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\n return this.dataModel\n .getEntityTypes()\n .filter((model) => model.genMode === Modes.service || model.genMode === Modes.all)\n .map((model) => {\n const file = this.project.createOrGetServiceFile(model.folderPath, model.serviceName, [\n model.serviceName,\n model.serviceCollectionName,\n ]);\n\n // entity type service\n this.generateEntityTypeService(file, model);\n // entity collection service if this entity specified keys at all\n if (model.keyNames.length) {\n this.generateEntityCollectionService(file, model);\n }\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateComplexTypeServices(): Array<Promise<void>> {\n // build service file for complex types\n return this.dataModel\n .getComplexTypes()\n .filter((model) => model.genMode === Modes.service || model.genMode === Modes.all)\n .map((model) => {\n const file = this.project.createOrGetServiceFile(model.folderPath, model.serviceName, [model.serviceName]);\n\n // entity type service\n this.generateEntityTypeService(file, model, true);\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateMethod(\n name: string,\n operation: OperationType,\n importContainer: ImportContainer,\n baseFqName: string,\n ): OptionalKind<MethodDeclarationStructure> {\n const isFunc = operation.type === OperationTypes.Function;\n const returnType = operation.returnType;\n const hasParams = operation.parameters.length > 0 || operation.overrides?.length;\n const isParamsOptional = !![operation.parameters, ...(operation.overrides ?? [])].find((pSet) => pSet.length === 0);\n\n // importing dependencies\n const httpClientConfigModel = importContainer.addClientApi(ClientApiImports.ODataHttpClientConfig);\n const odataResponse = importContainer.addClientApi(ClientApiImports.HttpResponseModel);\n const responseStructure = this.importReturnType(importContainer, returnType);\n const qOperationName = importContainer.addGeneratedQObject(baseFqName, operation.qName);\n const rtType =\n returnType?.type && returnType.dataType !== DataTypes.PrimitiveType\n ? importContainer.addGeneratedModel(returnType.fqType, returnType.type)\n : returnType?.type;\n const paramsModelName = hasParams\n ? importContainer.addGeneratedModel(baseFqName, operation.paramsModelName)\n : undefined;\n\n const requestConfigParam = {\n name: \"requestConfig\",\n hasQuestionToken: true,\n type: `${httpClientConfigModel}<ClientType>`,\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: paramsModelName, hasQuestionToken: isParamsOptional }, requestConfigParam]\n : [requestConfigParam],\n returnType: `Promise<${odataResponse}<${responseStructure}<${rtType || \"void\"}>>>`,\n statements: [\n `if(!${qOpProp}) {`,\n ` ${qOpProp} = new ${qOperationName}()`,\n \"}\",\n\n `const { addFullPath, client, getDefaultHeaders, isUrlNotEncoded } = this.__base;`,\n `const url = addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params, \" : \"\"}${isFunc ? \"isUrlNotEncoded()\" : \"\"}));`,\n `${returnType ? \"const response = await \" : \"return\"} client.${\n !isFunc\n ? // actions: since V4\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${\n requestConfigParam.name\n }, getDefaultHeaders())`\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}, getDefaultHeaders())`\n : // functions: since V2\n `get(url, ${requestConfigParam.name}, getDefaultHeaders())`\n };`,\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\n ],\n };\n }\n\n private importReturnType(imports: ImportContainer, returnType: ReturnTypeModel | undefined): string {\n const typeToImport: CoreImports = returnType?.isCollection\n ? CoreImports.ODataCollectionResponse\n : returnType?.dataType === DataTypes.PrimitiveType\n ? CoreImports.ODataValueResponse\n : this.version === ODataVersions.V4\n ? CoreImports.ODataModelResponseV4\n : CoreImports.ODataEntityModelResponseV2;\n\n return imports.addCoreLib(this.version, typeToImport);\n }\n\n private generateCastOperations(\n importContainer: ImportContainer,\n model: ComplexType,\n isCollection: boolean,\n ): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n if (this.version === ODataVersions.V4) {\n model.subtypes.forEach((subtype) => {\n const subClass = this.dataModel.getModel(subtype) as ComplexType;\n const serviceName = isCollection ? subClass.serviceCollectionName : subClass.serviceName;\n const serviceType = importContainer.addGeneratedService(subClass.fqName, serviceName);\n result.methods.push({\n name: `as${upperCaseFirst(serviceName)}`,\n scope: Scope.Public,\n statements: [\n \"const { client, path, options } = this.__base;\",\n `return new ${serviceType}(client, path, \"${subClass.fqName}\", { ...options, subtype: true });`,\n ],\n });\n });\n }\n\n return result;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ServiceGenerator.js","sourceRoot":"","sources":["../../src/generator/ServiceGenerator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAKL,KAAK,GACN,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAgB9D,OAAO,EAAqB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAQ9G,MAAM,UAAgB,gBAAgB,CACpC,OAAuB,EACvB,SAAoB,EACpB,OAAsB,EACtB,YAA0B,EAC1B,OAAiC;;QAEjC,MAAM,SAAS,GAAG,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QAC3F,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;CAAA;AAED,MAAM,gBAAgB;IACpB,YACU,OAAuB,EACvB,SAAoB,EACpB,OAAsB,EACtB,YAA0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AAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAgB,CAAC;gBACjE,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;gBACzF,MAAM,WAAW,GAAG,eAAe,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;gBACtF,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;oBAClB,IAAI,EAAE,KAAK,cAAc,CAAC,WAAW,CAAC,EAAE;oBACxC,KAAK,EAAE,KAAK,CAAC,MAAM;oBACnB,UAAU,EAAE;wBACV,gDAAgD;wBAChD,cAAc,WAAW,mBAAmB,QAAQ,CAAC,MAAM,oCAAoC;qBAChG;iBACF,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport deepmerge from \"deepmerge\";\nimport {\n ClassDeclarationStructure,\n MethodDeclarationStructure,\n OptionalKind,\n PropertyDeclarationStructure,\n Scope,\n} from \"ts-morph\";\nimport { upperCaseFirst } from \"upper-case-first\";\nimport { firstCharLowerCase } from \"xml2js/lib/processors.js\";\nimport { DataModel } from \"../data-model/DataModel.js\";\nimport {\n ActionImportType,\n ComplexType,\n DataTypes,\n EntityContainerModel,\n EntityType,\n FunctionImportType,\n OperationType,\n OperationTypes,\n PropertyModel,\n ReturnTypeModel,\n SingletonType,\n} from \"../data-model/DataTypeModel.js\";\nimport { NamingHelper } from \"../data-model/NamingHelper.js\";\nimport { ConfigFileOptions, Modes } from \"../OptionModel.js\";\nimport { FileHandler } from \"../project/FileHandler.js\";\nimport { ProjectManager } from \"../project/ProjectManager.js\";\nimport { ClientApiImports, CoreImports, QueryObjectImports, ServiceImports } from \"./import/ImportObjects.js\";\nimport { ImportContainer } from \"./ImportContainer.js\";\n\nexport interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, \"properties\" | \"methods\">> {}\n\nexport interface ServiceGeneratorOptions\n extends Pick<ConfigFileOptions, \"enablePrimitivePropertyServices\" | \"v4BigNumberAsString\" | \"enumType\"> {}\n\nexport async function generateServices(\n project: ProjectManager,\n dataModel: DataModel,\n version: ODataVersions,\n namingHelper: NamingHelper,\n options?: ServiceGeneratorOptions,\n) {\n const generator = new ServiceGenerator(project, dataModel, version, namingHelper, options);\n return generator.generate();\n}\n\nclass ServiceGenerator {\n constructor(\n private project: ProjectManager,\n private dataModel: DataModel,\n private version: ODataVersions,\n private namingHelper: NamingHelper,\n private options: ServiceGeneratorOptions = {},\n ) {}\n\n private isV4BigNumber() {\n return this.options.v4BigNumberAsString && this.version === ODataVersions.V4;\n }\n\n public async generate(): Promise<void> {\n const mainServiceName = this.namingHelper.getMainServiceName();\n this.project.initServices();\n\n await Promise.all([\n this.generateMainService(mainServiceName),\n ...this.generateEntityTypeServices(),\n ...this.generateComplexTypeServices(),\n ]);\n\n return this.project.finalizeServices();\n }\n\n private async generateMainService(mainServiceName: string) {\n const mainServiceFile = this.project.getMainServiceFile();\n const importContainer = mainServiceFile.getImports();\n const container = this.dataModel.getEntityContainer();\n const unboundOperations = [...Object.values(container.functions), ...Object.values(container.actions)];\n\n const httpClient = importContainer.addClientApi(ClientApiImports.ODataHttpClient);\n const rootService = importContainer.addServiceObject(this.version, ServiceImports.ODataService);\n\n const { properties, methods }: PropsAndOps = deepmerge(\n this.generateMainServiceProperties(container, importContainer),\n this.generateMainServiceOperations(unboundOperations, importContainer),\n );\n\n mainServiceFile.getFile().addClass({\n isExported: true,\n name: mainServiceName,\n typeParameters: [`in out ClientType extends ${httpClient}`],\n extends: `${rootService}<ClientType>`,\n ctors: this.isV4BigNumber()\n ? [\n {\n parameters: [\n { name: \"client\", type: \"ClientType\" },\n { name: \"basePath\", type: \"string\" },\n {\n name: \"options\",\n type: importContainer.addServiceObject(this.version, ServiceImports.ODataServiceOptions),\n hasQuestionToken: true,\n },\n ],\n statements: [`super(client, basePath, options);`, \"this.__base.options.bigNumbersAsString = true;\"],\n },\n ]\n : [],\n properties,\n methods,\n });\n }\n\n private generateMainServiceProperties(\n container: EntityContainerModel,\n importContainer: ImportContainer,\n ): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n Object.values(container.entitySets).forEach(({ name, odataName, entityType }) => {\n result.methods.push(this.generateRelatedServiceGetter(name, odataName, entityType, importContainer));\n });\n\n Object.values(container.singletons).forEach((singleton) => {\n result.properties.push(this.generateSingletonProp(importContainer, singleton));\n result.methods.push(this.generateSingletonGetter(singleton));\n });\n\n return result;\n }\n\n private generateMainServiceOperations(\n ops: Array<FunctionImportType | ActionImportType>,\n importContainer: ImportContainer,\n ): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n ops.forEach(({ operation, name }) => {\n const op = this.dataModel.getUnboundOperationType(operation);\n if (!op) {\n throw new Error(`Operation \"${operation}\" not found!`);\n }\n\n result.properties.push(this.generateQOperationProp(op));\n result.methods.push(this.generateMethod(name, op, importContainer, \"\"));\n });\n\n return result;\n }\n\n private generateRelatedServiceGetter(\n propName: string,\n odataPropName: string,\n entityType: EntityType,\n imports: ImportContainer,\n ): OptionalKind<MethodDeclarationStructure> {\n const idName = imports.addGeneratedModel(entityType.id.fqName, entityType.id.modelName);\n const idFunctionName = imports.addGeneratedQObject(entityType.id.fqName, entityType.id.qName);\n const serviceName = imports.addGeneratedService(entityType.fqName, entityType.serviceName);\n const collectionName = imports.addGeneratedService(entityType.fqName, entityType.serviceCollectionName);\n\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(propName),\n parameters: [\n {\n name: \"id\",\n type: `${idName} | undefined`,\n hasQuestionToken: true,\n },\n ],\n overloads: [\n {\n parameters: [],\n returnType: `${collectionName}<ClientType>`,\n },\n {\n parameters: [\n {\n name: \"id\",\n type: idName,\n },\n ],\n returnType: `${serviceName}<ClientType>`,\n },\n ],\n statements: [\n `const fieldName = \"${odataPropName}\";`,\n `const { client, path, options, isUrlNotEncoded } = this.__base;`,\n 'return typeof id === \"undefined\" || id === null',\n `? new ${collectionName}(client, path, fieldName, options)`,\n `: new ${serviceName}(client, path, new ${idFunctionName}(fieldName).buildUrl(id, isUrlNotEncoded()), options);`,\n ],\n };\n }\n\n private generateSingletonProp(\n importContainer: ImportContainer,\n singleton: SingletonType,\n ): OptionalKind<PropertyDeclarationStructure> {\n const { name, entityType } = singleton;\n const type = entityType.serviceName;\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(name),\n type: `${type}<ClientType>`,\n hasQuestionToken: true,\n };\n }\n\n private generateQOperationProp = (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 generateSingletonGetter(singleton: SingletonType): OptionalKind<MethodDeclarationStructure> {\n const { name, odataName, entityType } = singleton;\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(name);\n const serviceType = entityType.serviceName;\n\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(name),\n statements: [\n `if(!${propName}) {`,\n ` const { client, path, options } = this.__base;`,\n // prettier-ignore\n ` ${propName} = new ${serviceType}(client, path, \"${odataName}\", options)`,\n \"}\",\n `return ${propName}`,\n ],\n };\n }\n\n private generateEntityTypeService(file: FileHandler, model: ComplexType, isComplexType = false) {\n const importContainer = file.getImports();\n\n const operations = this.dataModel.getEntityTypeOperations(model.fqName);\n const props = [...model.baseProps, ...model.props];\n\n const entityServiceType = importContainer.addServiceObject(\n this.version,\n this.version === ODataVersions.V2 && isComplexType\n ? ServiceImports.ComplexTypeService\n : ServiceImports.EntityTypeService,\n );\n const httpClient = importContainer.addClientApi(ClientApiImports.ODataHttpClient);\n\n // note: predictable first imports => no need to take renaming into account\n const modelName = importContainer.addGeneratedModel(model.fqName, model.modelName);\n const editableModelName = importContainer.addGeneratedModel(model.fqName, model.editableName);\n const qName = importContainer.addGeneratedQObject(model.fqName, model.qName, true);\n const qObjectName = importContainer.addGeneratedQObject(model.fqName, firstCharLowerCase(model.qName));\n const serviceOptions = importContainer.addServiceObject(\n this.version,\n this.version === ODataVersions.V4\n ? ServiceImports.ODataServiceOptionsInternal\n : ServiceImports.ODataServiceOptions,\n );\n\n const { properties, methods }: PropsAndOps = deepmerge(\n deepmerge(\n this.generateServiceProperties(importContainer, model.serviceName, props),\n this.generateServiceOperations(importContainer, model, operations),\n ),\n this.generateCastOperations(importContainer, model, false),\n );\n\n // generate EntityTypeService\n file.getFile().addClass({\n isExported: true,\n name: model.serviceName,\n typeParameters: [`in out ClientType extends ${httpClient}`],\n extends: entityServiceType + `<ClientType, ${modelName}, ${editableModelName}, ${qName}>`,\n ctors: [\n {\n parameters: [\n { name: \"client\", type: \"ClientType\" },\n { name: \"basePath\", type: \"string\" },\n { name: \"name\", type: \"string\" },\n { name: \"options\", type: serviceOptions, hasQuestionToken: true },\n ],\n statements: [`super(client, basePath, name, ${qObjectName}, options);`],\n },\n ],\n properties,\n methods,\n });\n }\n\n private generateServiceProperties(\n importContainer: ImportContainer,\n serviceName: string,\n props: Array<PropertyModel>,\n ): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n props.forEach((prop) => {\n // collection of ComplexTypes, ComplexTypes, or EntityTypes\n if ((prop.dataType === DataTypes.ModelType && !prop.isCollection) || prop.dataType === DataTypes.ComplexType) {\n result.properties.push(this.generateModelProp(importContainer, prop));\n result.methods.push(this.generateModelPropGetter(importContainer, prop));\n } else if (prop.isCollection) {\n // collection of EntityTypes\n if (prop.dataType === DataTypes.ModelType) {\n const entityType = this.dataModel.getEntityType(prop.fqType);\n if (!entityType) {\n throw new Error(`Entity type \"${prop.fqType}\" specified by property not found!`);\n }\n\n result.methods.push(\n this.generateRelatedServiceGetter(prop.name, prop.odataName, entityType, importContainer),\n );\n }\n // collection of primitive or enum types\n else {\n result.properties.push(this.generatePrimitiveCollectionProp(importContainer, prop));\n result.methods.push(this.generatePrimitiveCollectionGetter(importContainer, prop));\n }\n }\n // generation of services for each primitive property: turned off by default\n else if (this.options.enablePrimitivePropertyServices && prop.dataType === DataTypes.PrimitiveType) {\n result.properties.push(this.generatePrimitiveTypeProp(importContainer, prop));\n result.methods.push(this.generatePrimitiveTypeGetter(importContainer, prop));\n }\n });\n\n return result;\n }\n\n private generateServiceOperations(\n importContainer: ImportContainer,\n model: ComplexType,\n operations: Array<OperationType>,\n ): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n operations.forEach((operation) => {\n result.properties.push(this.generateQOperationProp(operation));\n result.methods.push(this.generateMethod(operation.name, operation, importContainer, model.fqName));\n });\n\n return result;\n }\n\n private generateModelProp(imports: ImportContainer, prop: PropertyModel): PropertyDeclarationStructure {\n const propModel = this.dataModel.getModel(prop.fqType) as ComplexType;\n let propModelType: string;\n\n if (prop.isCollection) {\n const modelName = imports.addGeneratedModel(propModel.fqName, propModel.modelName);\n const editableModelName = imports.addGeneratedModel(propModel.fqName, propModel.editableName);\n const qModelName = imports.addGeneratedQObject(propModel.fqName, propModel.qName, true);\n const collectionServiceType = imports.addServiceObject(this.version, ServiceImports.CollectionService);\n\n propModelType = `${collectionServiceType}<ClientType, ${modelName}, ${qModelName}, ${editableModelName}>`;\n } else {\n const serviceName = imports.addGeneratedService(propModel.fqName, propModel.serviceName);\n propModelType = `${serviceName}<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 private generatePrimitiveCollectionProp(\n imports: ImportContainer,\n prop: PropertyModel,\n ): OptionalKind<PropertyDeclarationStructure> {\n if (!prop.qObject) {\n throw new Error(\"Illegal State: [qObject] must be provided for Collection types!\");\n }\n\n const collectionServiceType = imports.addServiceObject(this.version, ServiceImports.CollectionService);\n const isEnum = prop.dataType === DataTypes.EnumType;\n const isNumericEnum = this.options.enumType === \"numeric\";\n let qType: string;\n let type: string;\n\n if (isEnum) {\n const propEnum = this.dataModel.getModel(prop.fqType)!;\n const propTypeModel = imports.addGeneratedModel(propEnum.fqName, propEnum.modelName, false);\n type = `${imports.addQObjectType(QueryObjectImports.EnumCollection)}<typeof ${propTypeModel}>`;\n qType = `${imports.addQObjectType(\n isNumericEnum ? QueryObjectImports.QNumericEnumCollection : QueryObjectImports.QEnumCollection,\n )}<typeof ${propTypeModel}>`;\n } else {\n // TODO refactor string concat\n type = imports.addQObjectType(`${upperCaseFirst(prop.type)}Collection`);\n qType = imports.addQObjectType(prop.qObject);\n }\n const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(prop.name),\n type: `${collectionType}`,\n hasQuestionToken: true,\n };\n }\n\n private generatePrimitiveTypeProp(\n imports: ImportContainer,\n prop: PropertyModel,\n ): OptionalKind<PropertyDeclarationStructure> {\n const serviceType = imports.addServiceObject(this.version, ServiceImports.PrimitiveTypeService);\n const type = prop.typeModule ? imports.addCustomType(prop.typeModule, prop.type, true) : prop.type;\n\n return {\n scope: Scope.Private,\n name: this.namingHelper.getPrivatePropName(prop.name),\n type: `${serviceType}<ClientType, ${type}>`,\n hasQuestionToken: true,\n };\n }\n\n private generateModelPropGetter(\n imports: ImportContainer,\n prop: PropertyModel,\n ): OptionalKind<MethodDeclarationStructure> {\n const model = this.dataModel.getModel(prop.fqType) as ComplexType;\n const isComplexCollection = prop.isCollection && model.dataType === DataTypes.ComplexType;\n\n const type = isComplexCollection\n ? imports.addServiceObject(this.version, ServiceImports.CollectionService)\n : prop.isCollection\n ? model.serviceCollectionName\n : model.serviceName;\n const typeWithGenerics = isComplexCollection\n ? `${type}<ClientType, ${imports.addGeneratedModel(model.fqName, model.modelName)}, ${imports.addGeneratedQObject(\n model.fqName,\n model.qName,\n true,\n )}, ${imports.addGeneratedModel(model.fqName, model.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 ` const { client, path, options } = this.__base;`,\n // prettier-ignore\n ` ${privateSrvProp} = new ${type}(client, path, \"${prop.odataName}\"${isComplexCollection ? `, ${imports.addGeneratedQObject(model.fqName, firstCharLowerCase(model.qName))}`: \"\"}, options)`,\n \"}\",\n `return ${privateSrvProp}`,\n ],\n };\n }\n\n private generatePrimitiveCollectionGetter(\n imports: ImportContainer,\n prop: PropertyModel,\n ): OptionalKind<MethodDeclarationStructure> {\n const collectionServiceType = imports.addServiceObject(this.version, ServiceImports.CollectionService);\n const qCollectionName = imports.addQObject(prop.qObject!);\n const enumName =\n prop.dataType === DataTypes.EnumType ? imports.addGeneratedModel(prop.fqType, prop.type) : undefined;\n\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 ` const { client, path, options } = this.__base;`,\n // prettier-ignore\n ` ${propName} = new ${collectionServiceType}(client, path, \"${prop.odataName}\", new ${qCollectionName}(${enumName ?? \"\"}), options)`,\n \"}\",\n `return ${propName}`,\n ],\n };\n }\n\n private generatePrimitiveTypeGetter(\n imports: ImportContainer,\n prop: PropertyModel,\n ): OptionalKind<MethodDeclarationStructure> {\n const serviceType = imports.addServiceObject(this.version, ServiceImports.PrimitiveTypeService);\n const propName = \"this.\" + this.namingHelper.getPrivatePropName(prop.name);\n // for V2: mapped name must be specified\n const v2MappedName =\n this.version === ODataVersions.V4 ? \"\" : prop.name !== prop.odataName ? `, \"${prop.name}\"` : \", undefined\";\n\n return {\n scope: Scope.Public,\n name: this.namingHelper.getRelatedServiceGetter(prop.name),\n statements: [\n `if(!${propName}) {`,\n ` const { client, path, qModel, options } = this.__base;`,\n ` ${propName} = new ${serviceType}(client, path, \"${prop.odataName}\", qModel.${prop.name}.converter${v2MappedName}, options)`,\n \"}\",\n `return ${propName}`,\n ],\n };\n }\n\n private generateEntityCollectionService(file: FileHandler, model: EntityType) {\n const importContainer = file.getImports();\n const editableModelName = model.editableName;\n const qObjectName = firstCharLowerCase(model.qName);\n\n const entitySetServiceType = importContainer.addServiceObject(this.version, ServiceImports.EntitySetService);\n const paramsModelName = importContainer.addGeneratedModel(model.id.fqName, model.id.modelName);\n const qIdFunctionName = importContainer.addGeneratedQObject(model.id.fqName, model.id.qName);\n const serviceOptions = importContainer.addServiceObject(\n this.version,\n this.version === ODataVersions.V4\n ? ServiceImports.ODataServiceOptionsInternal\n : ServiceImports.ODataServiceOptions,\n );\n\n const collectionOperations = this.dataModel.getEntitySetOperations(model.fqName);\n\n const { properties, methods } = deepmerge(\n this.generateServiceOperations(importContainer, model, collectionOperations),\n this.generateCastOperations(importContainer, model, true),\n );\n\n file.getFile().addClass({\n isExported: true,\n name: model.serviceCollectionName,\n typeParameters: [\"in out ClientType extends ODataHttpClient\"],\n extends:\n entitySetServiceType +\n `<ClientType, ${model.modelName}, ${editableModelName}, ${model.qName}, ${paramsModelName}>`,\n ctors: [\n {\n parameters: [\n { name: \"client\", type: \"ClientType\" },\n { name: \"basePath\", type: \"string\" },\n { name: \"name\", type: \"string\" },\n { name: \"options\", type: serviceOptions, hasQuestionToken: true },\n ],\n statements: [`super(client, basePath, name, ${qObjectName}, new ${qIdFunctionName}(name), options);`],\n },\n ],\n properties,\n methods,\n });\n }\n\n private generateEntityTypeServices(): Array<Promise<void>> {\n // build service file for each entity, consisting of EntityTypeService & EntityCollectionService\n return this.dataModel\n .getEntityTypes()\n .filter((model) => model.genMode === Modes.service || model.genMode === Modes.all)\n .map((model) => {\n const file = this.project.createOrGetServiceFile(model.folderPath, model.serviceName, [\n model.serviceName,\n model.serviceCollectionName,\n ]);\n\n // entity type service\n this.generateEntityTypeService(file, model);\n // entity collection service if this entity specified keys at all\n if (model.keyNames.length) {\n this.generateEntityCollectionService(file, model);\n }\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateComplexTypeServices(): Array<Promise<void>> {\n // build service file for complex types\n return this.dataModel\n .getComplexTypes()\n .filter((model) => model.genMode === Modes.service || model.genMode === Modes.all)\n .map((model) => {\n const file = this.project.createOrGetServiceFile(model.folderPath, model.serviceName, [model.serviceName]);\n\n // entity type service\n this.generateEntityTypeService(file, model, true);\n\n return this.project.finalizeFile(file);\n });\n }\n\n private generateMethod(\n name: string,\n operation: OperationType,\n importContainer: ImportContainer,\n baseFqName: string,\n ): OptionalKind<MethodDeclarationStructure> {\n const isFunc = operation.type === OperationTypes.Function;\n const returnType = operation.returnType;\n const hasParams = operation.parameters.length > 0 || operation.overrides?.length;\n const isParamsOptional = !![operation.parameters, ...(operation.overrides ?? [])].find((pSet) => pSet.length === 0);\n\n // importing dependencies\n const httpClientConfigModel = importContainer.addClientApi(ClientApiImports.ODataHttpClientConfig);\n const odataResponse = importContainer.addClientApi(ClientApiImports.HttpResponseModel);\n const responseStructure = this.importReturnType(importContainer, returnType);\n const qOperationName = importContainer.addGeneratedQObject(baseFqName, operation.qName);\n const rtType =\n returnType?.type && returnType.dataType !== DataTypes.PrimitiveType\n ? importContainer.addGeneratedModel(returnType.fqType, returnType.type)\n : returnType?.type;\n const paramsModelName = hasParams\n ? importContainer.addGeneratedModel(baseFqName, operation.paramsModelName)\n : undefined;\n\n const requestConfigParam = {\n name: \"requestConfig\",\n hasQuestionToken: true,\n type: `${httpClientConfigModel}<ClientType>`,\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: paramsModelName, hasQuestionToken: isParamsOptional }, requestConfigParam]\n : [requestConfigParam],\n returnType: `Promise<${odataResponse}<${responseStructure}<${rtType || \"void\"}>>>`,\n statements: [\n `if(!${qOpProp}) {`,\n ` ${qOpProp} = new ${qOperationName}()`,\n \"}\",\n\n `const { addFullPath, client, getDefaultHeaders, isUrlNotEncoded } = this.__base;`,\n `const url = addFullPath(${qOpProp}.buildUrl(${isFunc && hasParams ? \"params, \" : \"\"}${isFunc ? \"isUrlNotEncoded()\" : \"\"}));`,\n `${returnType ? \"const response = await \" : \"return\"} client.${\n !isFunc\n ? // actions: since V4\n `post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : \"{}\"}, ${\n requestConfigParam.name\n }, getDefaultHeaders())`\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}, getDefaultHeaders())`\n : // functions: since V2\n `get(url, ${requestConfigParam.name}, getDefaultHeaders())`\n };`,\n returnType ? `return ${qOpProp}.convertResponse(response);` : \"\",\n ],\n };\n }\n\n private importReturnType(imports: ImportContainer, returnType: ReturnTypeModel | undefined): string {\n const typeToImport: CoreImports = returnType?.isCollection\n ? CoreImports.ODataCollectionResponse\n : returnType?.dataType === DataTypes.PrimitiveType\n ? CoreImports.ODataValueResponse\n : this.version === ODataVersions.V4\n ? CoreImports.ODataModelResponseV4\n : CoreImports.ODataEntityModelResponseV2;\n\n return imports.addCoreLib(this.version, typeToImport);\n }\n\n private generateCastOperations(\n importContainer: ImportContainer,\n model: ComplexType,\n isCollection: boolean,\n ): PropsAndOps {\n const result: PropsAndOps = { properties: [], methods: [] };\n\n if (this.version === ODataVersions.V4) {\n model.subtypes.forEach((subtype) => {\n const subClass = this.dataModel.getModel(subtype) as ComplexType;\n const serviceName = isCollection ? subClass.serviceCollectionName : subClass.serviceName;\n const serviceType = importContainer.addGeneratedService(subClass.fqName, serviceName);\n result.methods.push({\n name: `as${upperCaseFirst(serviceName)}`,\n scope: Scope.Public,\n statements: [\n \"const { client, path, options } = this.__base;\",\n `return new ${serviceType}(client, path, \"${subClass.fqName}\", { ...options, subtype: true });`,\n ],\n });\n });\n }\n\n return result;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odata2ts/odata2ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.1",
|
|
4
4
|
"description": "Flexible generator to produce various TypeScript artefacts (from simple model interfaces to complete odata clients) from OData metadata files",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"odata2ts",
|
|
@@ -68,14 +68,14 @@
|
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@odata2ts/converter-v2-to-v4": "^0.5.1",
|
|
71
|
-
"@odata2ts/odata-query-objects": "^0.
|
|
72
|
-
"@odata2ts/odata-service": "^0.
|
|
71
|
+
"@odata2ts/odata-query-objects": "^0.28.1",
|
|
72
|
+
"@odata2ts/odata-service": "^0.23.1",
|
|
73
73
|
"@odata2ts/test-converters": "^0.5.0",
|
|
74
74
|
"@types/node": "^22.4.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@odata2ts/odata-query-objects": "^0.
|
|
78
|
-
"@odata2ts/odata-service": "^0.
|
|
77
|
+
"@odata2ts/odata-query-objects": "^0.28.1",
|
|
78
|
+
"@odata2ts/odata-service": "^0.23.1",
|
|
79
79
|
"typescript": ">= 4.7"
|
|
80
80
|
},
|
|
81
81
|
"publishConfig": {
|