@odata2ts/odata2ts 0.40.2 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/lib/data-model/DataModelDigestionV4.js +2 -0
- package/lib/data-model/DataModelDigestionV4.js.map +1 -1
- package/lib/data-model/DataTypeModel.d.ts +1 -0
- package/lib/data-model/DataTypeModel.js.map +1 -1
- package/lib/data-model/edmx/ODataEdmxModelV4.d.ts +1 -0
- package/lib/data-model/edmx/ODataEdmxModelV4.js.map +1 -1
- package/lib/generator/ImportContainer.js +7 -2
- package/lib/generator/ImportContainer.js.map +1 -1
- package/lib/generator/QueryObjectGenerator.js +21 -26
- package/lib/generator/QueryObjectGenerator.js.map +1 -1
- package/lib/generator/ServiceGenerator.js +43 -34
- package/lib/generator/ServiceGenerator.js.map +1 -1
- package/lib/generator/import/ImportObjects.d.ts +16 -6
- package/lib/generator/import/ImportObjects.js +13 -3
- package/lib/generator/import/ImportObjects.js.map +1 -1
- package/lib/generator/import/ImportResponseHelper.d.ts +5 -0
- package/lib/generator/import/ImportResponseHelper.js +47 -0
- package/lib/generator/import/ImportResponseHelper.js.map +1 -0
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,49 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
13
13
|
* @odata2ts/odata-query-objects bumped from ^0.28.0 to ^0.28.1
|
|
14
14
|
* @odata2ts/odata-service bumped from ^0.23.0 to ^0.23.1
|
|
15
15
|
|
|
16
|
+
## [0.41.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts-v0.40.2...@odata2ts/odata2ts-v0.41.0) (2026-07-20)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### ⚠ BREAKING CHANGES
|
|
20
|
+
|
|
21
|
+
* **qobject:** removing OperationReturnType, ResponseHelper and ResponseTypes
|
|
22
|
+
* **qobject:** QAction & QFunction with different constructor signatures; intro of QFunctionV2 & QFunctionV4
|
|
23
|
+
* **service:** introduce RequestCmd as intermediary command object including converters
|
|
24
|
+
* **service:** adapt operations to UrlRequestCmd
|
|
25
|
+
* use command pattern to allow users to retrieve request info (URL, method, data, headers) and add request and response converters before performing the request via the new `execute()` method
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* allow GET request to be POSTed ([#388](https://github.com/odata2ts/odata2ts/issues/388)) ([bbdce8f](https://github.com/odata2ts/odata2ts/commit/bbdce8f5e90cdfd4e59330861e258584dc804158))
|
|
30
|
+
* composable functions ([#386](https://github.com/odata2ts/odata2ts/issues/386)) ([2eac7c1](https://github.com/odata2ts/odata2ts/commit/2eac7c1b8049e8cf7d6ee6be2e465f8e9ef0464d))
|
|
31
|
+
* Intermediary RequestCmd ([#384](https://github.com/odata2ts/odata2ts/issues/384)) ([113fdf4](https://github.com/odata2ts/odata2ts/commit/113fdf41041e69c922023cc91ce0d374ebb1073d))
|
|
32
|
+
* **odata2ts:** recognize IsComposable attribute & generate composable request commands ([2eac7c1](https://github.com/odata2ts/odata2ts/commit/2eac7c1b8049e8cf7d6ee6be2e465f8e9ef0464d))
|
|
33
|
+
* **service:** introduce ComposableUrlRequestCmd ([2eac7c1](https://github.com/odata2ts/odata2ts/commit/2eac7c1b8049e8cf7d6ee6be2e465f8e9ef0464d))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* **example:** use new execute method ([113fdf4](https://github.com/odata2ts/odata2ts/commit/113fdf41041e69c922023cc91ce0d374ebb1073d))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Code Refactoring
|
|
42
|
+
|
|
43
|
+
* **qobject:** QAction & QFunction with different constructor signatures; intro of QFunctionV2 & QFunctionV4 ([113fdf4](https://github.com/odata2ts/odata2ts/commit/113fdf41041e69c922023cc91ce0d374ebb1073d))
|
|
44
|
+
* **qobject:** removing OperationReturnType, ResponseHelper and ResponseTypes ([113fdf4](https://github.com/odata2ts/odata2ts/commit/113fdf41041e69c922023cc91ce0d374ebb1073d))
|
|
45
|
+
* **service:** adapt operations to UrlRequestCmd ([113fdf4](https://github.com/odata2ts/odata2ts/commit/113fdf41041e69c922023cc91ce0d374ebb1073d))
|
|
46
|
+
* **service:** introduce RequestCmd as intermediary command object including converters ([113fdf4](https://github.com/odata2ts/odata2ts/commit/113fdf41041e69c922023cc91ce0d374ebb1073d))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Dependencies
|
|
50
|
+
|
|
51
|
+
* The following workspace dependencies were updated
|
|
52
|
+
* devDependencies
|
|
53
|
+
* @odata2ts/odata-query-objects bumped from ^0.28.2 to ^0.29.0
|
|
54
|
+
* @odata2ts/odata-service bumped from ^0.23.2 to ^0.24.0
|
|
55
|
+
* peerDependencies
|
|
56
|
+
* @odata2ts/odata-query-objects bumped from ^0.28.2 to ^0.29.0
|
|
57
|
+
* @odata2ts/odata-service bumped from ^0.23.2 to ^0.24.0
|
|
58
|
+
|
|
16
59
|
## [0.40.2](https://github.com/odata2ts/odata2ts/compare/@odata2ts/odata2ts-v0.40.1...@odata2ts/odata2ts-v0.40.2) (2026-07-03)
|
|
17
60
|
|
|
18
61
|
|
|
@@ -195,6 +195,7 @@ class DigesterV4 extends Digester {
|
|
|
195
195
|
var _a, _b, _c, _d;
|
|
196
196
|
const odataName = op.$.Name;
|
|
197
197
|
const isBound = op.$.IsBound === "true";
|
|
198
|
+
const isComposable = op.$.IsComposable === "true";
|
|
198
199
|
const fqName = withNamespace(namespace, odataName);
|
|
199
200
|
const opConfig = this.serviceConfigHelper.findOperationTypeConfig(ns, odataName);
|
|
200
201
|
const params = (_b = (_a = op.Parameter) === null || _a === void 0 ? void 0 : _a.map((p) => this.mapProp(p))) !== null && _b !== void 0 ? _b : [];
|
|
@@ -224,6 +225,7 @@ class DigesterV4 extends Digester {
|
|
|
224
225
|
type,
|
|
225
226
|
parameters: params,
|
|
226
227
|
returnType,
|
|
228
|
+
composable: isComposable,
|
|
227
229
|
};
|
|
228
230
|
if (bindingProp) {
|
|
229
231
|
this.dataModel.addBoundOperationType(namespace, bindingProp, opType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataModelDigestionV4.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestionV4.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAyB,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAsB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAa,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAgD,MAAM,oBAAoB,CAAC;AAKhG,MAAM,CAAC,MAAM,MAAM,GAA+B,CAAO,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;IACzF,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9E,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IAC5E,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;AAC3B,CAAC,CAAA,CAAC;AAEF,MAAM,UAAW,SAAQ,QAA+C;IACtE,YACE,OAAwB,EACxB,OAAyB,EACzB,YAA0B,EAC1B,UAAkC;QAElC,KAAK,CAAC,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC;IAES,kBAAkB,CAAC,UAAsC;QACjE,OAAQ,UAA2B,CAAC,kBAAkB,IAAI,EAAE,CAAC;IAC/D,CAAC;IAES,gBAAgB,CAAC,MAAgB;QACzC,MAAM,WAAW,GAAuB,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,M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AM;gBAClB,UAAU;aACX,CAAC;YAEF,IAAI,WAAW,EAAE;gBACf,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;aACtE;iBAAM;gBACL,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;aAC3D;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { loadConverters, MappedConverterChains } from \"@odata2ts/converter-runtime\";\nimport { ODataTypesV4, ODataVersions } from \"@odata2ts/odata-core\";\nimport { DigesterFunction, DigestionOptions } from \"../FactoryFunctionModel.js\";\nimport { NamespaceWithAlias, withNamespace } from \"./DataModel.js\";\nimport { Digester, TypeModel } from \"./DataModelDigestion.js\";\nimport { ODataVersion, OperationType, OperationTypes, PropertyModel } from \"./DataTypeModel.js\";\nimport { ComplexType, Property } from \"./edmx/ODataEdmxModelBase.js\";\nimport { ComplexTypeV4, EntityTypeV4, Operation, SchemaV4 } from \"./edmx/ODataEdmxModelV4.js\";\nimport { NamingHelper } from \"./NamingHelper.js\";\n\nexport const digest: DigesterFunction<SchemaV4> = async (schemas, options, namingHelper) => {\n const converters = await loadConverters(ODataVersions.V4, options.converters);\n\n const digester = new DigesterV4(schemas, options, namingHelper, converters);\n return digester.digest();\n};\n\nclass DigesterV4 extends Digester<SchemaV4, EntityTypeV4, ComplexTypeV4> {\n constructor(\n schemas: Array<SchemaV4>,\n options: DigestionOptions,\n namingHelper: NamingHelper,\n converters?: MappedConverterChains,\n ) {\n super(ODataVersion.V4, schemas, options, namingHelper, converters);\n }\n\n protected getNavigationProps(entityType: ComplexType | EntityTypeV4): Array<Property> {\n return (entityType as EntityTypeV4).NavigationProperty || [];\n }\n\n protected digestOperations(schema: SchemaV4) {\n const nsWithAlias: NamespaceWithAlias = [schema.$.Namespace, schema.$.Alias];\n // functions & actions\n this.addOperations(nsWithAlias, schema.Function, OperationTypes.Function);\n this.addOperations(nsWithAlias, schema.Action, OperationTypes.Action);\n }\n\n protected digestEntityContainer(schema: SchemaV4) {\n if (schema.EntityContainer && schema.EntityContainer.length) {\n const container = schema.EntityContainer[0];\n\n const ecName = container.$.Name;\n\n container.ActionImport?.forEach((actionImport) => {\n const odataName = actionImport.$.Name;\n const fqName = withNamespace(ecName, odataName);\n const opConfig = this.serviceConfigHelper.findOperationImportConfig(ecName, odataName);\n const opName = this.nameValidator.addOperationImportType(fqName, opConfig?.mappedName || odataName);\n\n this.dataModel.addAction(fqName, {\n fqName,\n name: this.namingHelper.getActionName(opName),\n odataName: actionImport.$.Name,\n operation: actionImport.$.Action,\n });\n });\n\n container.FunctionImport?.forEach((funcImport) => {\n const odataName = funcImport.$.Name;\n const fqName = withNamespace(ecName, odataName);\n const opConfig = this.serviceConfigHelper.findOperationImportConfig(ecName, odataName);\n const opName = this.nameValidator.addOperationImportType(fqName, opConfig?.mappedName || odataName);\n\n this.dataModel.addFunction(fqName, {\n fqName,\n odataName,\n name: this.namingHelper.getFunctionName(opName),\n operation: funcImport.$.Function,\n entitySet: funcImport.$.EntitySet,\n });\n });\n\n container.Singleton?.forEach((singleton) => {\n const odataName = singleton.$.Name;\n const fqName = withNamespace(ecName, odataName);\n const singletonConfig = this.serviceConfigHelper.findOperationImportConfig(ecName, odataName);\n const name = this.nameValidator.addSingleton(\n withNamespace(fqName, odataName),\n singletonConfig?.mappedName || odataName,\n );\n const navPropBindings = singleton.NavigationPropertyBinding || [];\n const entityType = this.dataModel.getEntityType(singleton.$.Type);\n if (!entityType) {\n throw new Error(`Entity type \"${singleton.$.Type}\" not found!`);\n }\n\n this.dataModel.addSingleton(fqName, {\n fqName,\n odataName,\n name,\n entityType,\n navPropBinding: navPropBindings.map((binding) => ({\n path: this.namingHelper.stripServicePrefix(binding.$.Path),\n target: binding.$.Target,\n })),\n });\n });\n\n container.EntitySet?.forEach((entitySet) => {\n const odataName = entitySet.$.Name;\n const fqName = withNamespace(ecName, odataName);\n const config = this.serviceConfigHelper.findOperationImportConfig(ecName, odataName);\n const name = this.nameValidator.addEntitySet(fqName, config?.mappedName || odataName);\n const navPropBindings = entitySet.NavigationPropertyBinding || [];\n const entityType = this.dataModel.getEntityType(entitySet.$.EntityType);\n if (!entityType) {\n throw new Error(`Entity type \"${entitySet.$.EntityType}\" not found!`);\n }\n\n this.dataModel.addEntitySet(fqName, {\n fqName,\n odataName,\n name,\n entityType,\n navPropBinding: navPropBindings.map((binding) => ({\n path: this.namingHelper.stripServicePrefix(binding.$.Path),\n target: binding.$.Target,\n })),\n });\n });\n }\n }\n\n protected mapODataType(type: string): TypeModel {\n switch (type) {\n case ODataTypesV4.Boolean:\n return {\n outputType: \"boolean\",\n qPath: \"QBooleanPath\",\n qCollection: \"QBooleanCollection\",\n qParam: \"QBooleanParam\",\n };\n case ODataTypesV4.Int64:\n case ODataTypesV4.Decimal:\n if (this.options.v4BigNumberAsString) {\n return {\n outputType: \"string\",\n qPath: \"QBigNumberPath\",\n qCollection: \"QBigNumberCollection\",\n qParam: \"QBigNumberParam\",\n };\n }\n // yes, intentional fall through!\n case ODataTypesV4.Byte:\n case ODataTypesV4.SByte:\n case ODataTypesV4.Int16:\n case ODataTypesV4.Int32:\n case ODataTypesV4.Single:\n case ODataTypesV4.Double:\n return {\n outputType: \"number\",\n qPath: \"QNumberPath\",\n qCollection: \"QNumberCollection\",\n qParam: \"QNumberParam\",\n };\n case ODataTypesV4.String:\n return {\n outputType: \"string\",\n qPath: \"QStringPath\",\n qCollection: \"QStringCollection\",\n qParam: \"QStringParam\",\n };\n case ODataTypesV4.Date:\n return {\n outputType: \"string\",\n qPath: \"QDatePath\",\n qCollection: \"QDateCollection\",\n qParam: \"QDateParam\",\n };\n case ODataTypesV4.TimeOfDay:\n return {\n outputType: \"string\",\n qPath: \"QTimeOfDayPath\",\n qCollection: \"QTimeOfDayCollection\",\n qParam: \"QTimeOfDayParam\",\n };\n case ODataTypesV4.DateTimeOffset:\n return {\n outputType: \"string\",\n qPath: \"QDateTimeOffsetPath\",\n qCollection: \"QDateTimeOffsetCollection\",\n qParam: \"QDateTimeOffsetParam\",\n };\n // case ODataTypesV4.Duration:\n // return {\n // outputType: \"string\",\n // qPath: \"QDurationPath\",\n // qCollection: \"QDurationCollection\",\n // qParam: \"QDurationParam\",\n // };\n case ODataTypesV4.Binary:\n return {\n outputType: \"string\",\n qPath: \"QBinaryPath\",\n qCollection: \"QBinaryCollection\",\n qParam: \"QBinaryParam\",\n };\n case ODataTypesV4.Guid:\n return {\n outputType: \"string\",\n qPath: \"QGuidPath\",\n qCollection: \"QGuidCollection\",\n qParam: \"QGuidParam\",\n };\n default:\n return {\n outputType: \"string\",\n qPath: \"QStringPath\",\n qCollection: \"QStringCollection\",\n qParam: undefined,\n };\n }\n }\n\n private addOperations(ns: NamespaceWithAlias, operations: Array<Operation> | undefined, type: OperationTypes) {\n const [namespace] = ns;\n if (!operations || !operations.length) {\n return;\n }\n\n operations.forEach((op) => {\n const odataName = op.$.Name;\n const isBound = op.$.IsBound === \"true\";\n const fqName = withNamespace(namespace, odataName);\n const opConfig = this.serviceConfigHelper.findOperationTypeConfig(ns, odataName);\n const params: Array<PropertyModel> = op.Parameter?.map((p) => this.mapProp(p)) ?? [];\n const returnType: PropertyModel | undefined = op.ReturnType?.map((rt) => {\n return this.mapProp({ ...rt, $: { Name: \"NO_NAME_BECAUSE_RETURN_TYPE\", ...rt.$ } });\n })[0];\n\n if (isBound && !params.length) {\n throw new Error(`IllegalState: Operation '${odataName}' is bound, but has no parameters!`);\n }\n\n const bindingProp = isBound ? params.shift() : undefined;\n const bindingEntityName = bindingProp ? this.dataModel.getModel(bindingProp!.fqType)?.name : undefined;\n\n const opName = bindingEntityName\n ? this.nameValidator.addBoundOperationType(bindingEntityName, fqName, opConfig?.mappedName || odataName, type)\n : this.nameValidator.addUnboundOperationType(fqName, opConfig?.mappedName || odataName, type);\n\n const name =\n type === OperationTypes.Function\n ? this.namingHelper.getFunctionName(opName)\n : this.namingHelper.getActionName(opName);\n const qName =\n type === OperationTypes.Function\n ? this.namingHelper.getQFunctionName(opName, bindingEntityName)\n : this.namingHelper.getQActionName(opName, bindingEntityName);\n const opType: OperationType = {\n fqName,\n odataName: isBound ? fqName : odataName,\n name,\n qName,\n paramsModelName: this.namingHelper.getOperationParamsModelName(opName, bindingEntityName),\n type,\n parameters: params,\n returnType,\n };\n\n if (bindingProp) {\n this.dataModel.addBoundOperationType(namespace, bindingProp, opType);\n } else {\n this.dataModel.addUnboundOperationType(namespace, opType);\n }\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DataModelDigestionV4.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestionV4.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAyB,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAsB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAa,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAgD,MAAM,oBAAoB,CAAC;AAKhG,MAAM,CAAC,MAAM,MAAM,GAA+B,CAAO,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;IACzF,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9E,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IAC5E,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;AAC3B,CAAC,CAAA,CAAC;AAEF,MAAM,UAAW,SAAQ,QAA+C;IACtE,YACE,OAAwB,EACxB,OAAyB,EACzB,YAA0B,EAC1B,UAAkC;QAElC,KAAK,CAAC,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU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M,EAAE,iBAAiB,CAAC,CAAC;YAClE,MAAM,MAAM,GAAkB;gBAC5B,MAAM;gBACN,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;gBACvC,IAAI;gBACJ,KAAK;gBACL,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,2BAA2B,CAAC,MAAM,EAAE,iBAAiB,CAAC;gBACzF,IAAI;gBACJ,UAAU,EAAE,MAAM;gBAClB,UAAU;gBACV,UAAU,EAAE,YAAY;aACzB,CAAC;YAEF,IAAI,WAAW,EAAE;gBACf,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;aACtE;iBAAM;gBACL,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;aAC3D;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { loadConverters, MappedConverterChains } from \"@odata2ts/converter-runtime\";\nimport { ODataTypesV4, ODataVersions } from \"@odata2ts/odata-core\";\nimport { DigesterFunction, DigestionOptions } from \"../FactoryFunctionModel.js\";\nimport { NamespaceWithAlias, withNamespace } from \"./DataModel.js\";\nimport { Digester, TypeModel } from \"./DataModelDigestion.js\";\nimport { ODataVersion, OperationType, OperationTypes, PropertyModel } from \"./DataTypeModel.js\";\nimport { ComplexType, Property } from \"./edmx/ODataEdmxModelBase.js\";\nimport { ComplexTypeV4, EntityTypeV4, Operation, SchemaV4 } from \"./edmx/ODataEdmxModelV4.js\";\nimport { NamingHelper } from \"./NamingHelper.js\";\n\nexport const digest: DigesterFunction<SchemaV4> = async (schemas, options, namingHelper) => {\n const converters = await loadConverters(ODataVersions.V4, options.converters);\n\n const digester = new DigesterV4(schemas, options, namingHelper, converters);\n return digester.digest();\n};\n\nclass DigesterV4 extends Digester<SchemaV4, EntityTypeV4, ComplexTypeV4> {\n constructor(\n schemas: Array<SchemaV4>,\n options: DigestionOptions,\n namingHelper: NamingHelper,\n converters?: MappedConverterChains,\n ) {\n super(ODataVersion.V4, schemas, options, namingHelper, converters);\n }\n\n protected getNavigationProps(entityType: ComplexType | EntityTypeV4): Array<Property> {\n return (entityType as EntityTypeV4).NavigationProperty || [];\n }\n\n protected digestOperations(schema: SchemaV4) {\n const nsWithAlias: NamespaceWithAlias = [schema.$.Namespace, schema.$.Alias];\n // functions & actions\n this.addOperations(nsWithAlias, schema.Function, OperationTypes.Function);\n this.addOperations(nsWithAlias, schema.Action, OperationTypes.Action);\n }\n\n protected digestEntityContainer(schema: SchemaV4) {\n if (schema.EntityContainer && schema.EntityContainer.length) {\n const container = schema.EntityContainer[0];\n\n const ecName = container.$.Name;\n\n container.ActionImport?.forEach((actionImport) => {\n const odataName = actionImport.$.Name;\n const fqName = withNamespace(ecName, odataName);\n const opConfig = this.serviceConfigHelper.findOperationImportConfig(ecName, odataName);\n const opName = this.nameValidator.addOperationImportType(fqName, opConfig?.mappedName || odataName);\n\n this.dataModel.addAction(fqName, {\n fqName,\n name: this.namingHelper.getActionName(opName),\n odataName: actionImport.$.Name,\n operation: actionImport.$.Action,\n });\n });\n\n container.FunctionImport?.forEach((funcImport) => {\n const odataName = funcImport.$.Name;\n const fqName = withNamespace(ecName, odataName);\n const opConfig = this.serviceConfigHelper.findOperationImportConfig(ecName, odataName);\n const opName = this.nameValidator.addOperationImportType(fqName, opConfig?.mappedName || odataName);\n\n this.dataModel.addFunction(fqName, {\n fqName,\n odataName,\n name: this.namingHelper.getFunctionName(opName),\n operation: funcImport.$.Function,\n entitySet: funcImport.$.EntitySet,\n });\n });\n\n container.Singleton?.forEach((singleton) => {\n const odataName = singleton.$.Name;\n const fqName = withNamespace(ecName, odataName);\n const singletonConfig = this.serviceConfigHelper.findOperationImportConfig(ecName, odataName);\n const name = this.nameValidator.addSingleton(\n withNamespace(fqName, odataName),\n singletonConfig?.mappedName || odataName,\n );\n const navPropBindings = singleton.NavigationPropertyBinding || [];\n const entityType = this.dataModel.getEntityType(singleton.$.Type);\n if (!entityType) {\n throw new Error(`Entity type \"${singleton.$.Type}\" not found!`);\n }\n\n this.dataModel.addSingleton(fqName, {\n fqName,\n odataName,\n name,\n entityType,\n navPropBinding: navPropBindings.map((binding) => ({\n path: this.namingHelper.stripServicePrefix(binding.$.Path),\n target: binding.$.Target,\n })),\n });\n });\n\n container.EntitySet?.forEach((entitySet) => {\n const odataName = entitySet.$.Name;\n const fqName = withNamespace(ecName, odataName);\n const config = this.serviceConfigHelper.findOperationImportConfig(ecName, odataName);\n const name = this.nameValidator.addEntitySet(fqName, config?.mappedName || odataName);\n const navPropBindings = entitySet.NavigationPropertyBinding || [];\n const entityType = this.dataModel.getEntityType(entitySet.$.EntityType);\n if (!entityType) {\n throw new Error(`Entity type \"${entitySet.$.EntityType}\" not found!`);\n }\n\n this.dataModel.addEntitySet(fqName, {\n fqName,\n odataName,\n name,\n entityType,\n navPropBinding: navPropBindings.map((binding) => ({\n path: this.namingHelper.stripServicePrefix(binding.$.Path),\n target: binding.$.Target,\n })),\n });\n });\n }\n }\n\n protected mapODataType(type: string): TypeModel {\n switch (type) {\n case ODataTypesV4.Boolean:\n return {\n outputType: \"boolean\",\n qPath: \"QBooleanPath\",\n qCollection: \"QBooleanCollection\",\n qParam: \"QBooleanParam\",\n };\n case ODataTypesV4.Int64:\n case ODataTypesV4.Decimal:\n if (this.options.v4BigNumberAsString) {\n return {\n outputType: \"string\",\n qPath: \"QBigNumberPath\",\n qCollection: \"QBigNumberCollection\",\n qParam: \"QBigNumberParam\",\n };\n }\n // yes, intentional fall through!\n case ODataTypesV4.Byte:\n case ODataTypesV4.SByte:\n case ODataTypesV4.Int16:\n case ODataTypesV4.Int32:\n case ODataTypesV4.Single:\n case ODataTypesV4.Double:\n return {\n outputType: \"number\",\n qPath: \"QNumberPath\",\n qCollection: \"QNumberCollection\",\n qParam: \"QNumberParam\",\n };\n case ODataTypesV4.String:\n return {\n outputType: \"string\",\n qPath: \"QStringPath\",\n qCollection: \"QStringCollection\",\n qParam: \"QStringParam\",\n };\n case ODataTypesV4.Date:\n return {\n outputType: \"string\",\n qPath: \"QDatePath\",\n qCollection: \"QDateCollection\",\n qParam: \"QDateParam\",\n };\n case ODataTypesV4.TimeOfDay:\n return {\n outputType: \"string\",\n qPath: \"QTimeOfDayPath\",\n qCollection: \"QTimeOfDayCollection\",\n qParam: \"QTimeOfDayParam\",\n };\n case ODataTypesV4.DateTimeOffset:\n return {\n outputType: \"string\",\n qPath: \"QDateTimeOffsetPath\",\n qCollection: \"QDateTimeOffsetCollection\",\n qParam: \"QDateTimeOffsetParam\",\n };\n // case ODataTypesV4.Duration:\n // return {\n // outputType: \"string\",\n // qPath: \"QDurationPath\",\n // qCollection: \"QDurationCollection\",\n // qParam: \"QDurationParam\",\n // };\n case ODataTypesV4.Binary:\n return {\n outputType: \"string\",\n qPath: \"QBinaryPath\",\n qCollection: \"QBinaryCollection\",\n qParam: \"QBinaryParam\",\n };\n case ODataTypesV4.Guid:\n return {\n outputType: \"string\",\n qPath: \"QGuidPath\",\n qCollection: \"QGuidCollection\",\n qParam: \"QGuidParam\",\n };\n default:\n return {\n outputType: \"string\",\n qPath: \"QStringPath\",\n qCollection: \"QStringCollection\",\n qParam: undefined,\n };\n }\n }\n\n private addOperations(ns: NamespaceWithAlias, operations: Array<Operation> | undefined, type: OperationTypes) {\n const [namespace] = ns;\n if (!operations || !operations.length) {\n return;\n }\n\n operations.forEach((op) => {\n const odataName = op.$.Name;\n const isBound = op.$.IsBound === \"true\";\n const isComposable = op.$.IsComposable === \"true\";\n const fqName = withNamespace(namespace, odataName);\n const opConfig = this.serviceConfigHelper.findOperationTypeConfig(ns, odataName);\n const params: Array<PropertyModel> = op.Parameter?.map((p) => this.mapProp(p)) ?? [];\n const returnType: PropertyModel | undefined = op.ReturnType?.map((rt) => {\n return this.mapProp({ ...rt, $: { Name: \"NO_NAME_BECAUSE_RETURN_TYPE\", ...rt.$ } });\n })[0];\n\n if (isBound && !params.length) {\n throw new Error(`IllegalState: Operation '${odataName}' is bound, but has no parameters!`);\n }\n\n const bindingProp = isBound ? params.shift() : undefined;\n const bindingEntityName = bindingProp ? this.dataModel.getModel(bindingProp!.fqType)?.name : undefined;\n\n const opName = bindingEntityName\n ? this.nameValidator.addBoundOperationType(bindingEntityName, fqName, opConfig?.mappedName || odataName, type)\n : this.nameValidator.addUnboundOperationType(fqName, opConfig?.mappedName || odataName, type);\n\n const name =\n type === OperationTypes.Function\n ? this.namingHelper.getFunctionName(opName)\n : this.namingHelper.getActionName(opName);\n const qName =\n type === OperationTypes.Function\n ? this.namingHelper.getQFunctionName(opName, bindingEntityName)\n : this.namingHelper.getQActionName(opName, bindingEntityName);\n const opType: OperationType = {\n fqName,\n odataName: isBound ? fqName : odataName,\n name,\n qName,\n paramsModelName: this.namingHelper.getOperationParamsModelName(opName, bindingEntityName),\n type,\n parameters: params,\n returnType,\n composable: isComposable,\n };\n\n if (bindingProp) {\n this.dataModel.addBoundOperationType(namespace, bindingProp, opType);\n } else {\n this.dataModel.addUnboundOperationType(namespace, opType);\n }\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTypeModel.js","sourceRoot":"","sources":["../../src/data-model/DataTypeModel.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,0BAAU,CAAA;IACV,0BAAU,CAAA;AACZ,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB","sourcesContent":["import { ValueConverterImport } from \"@odata2ts/converter-runtime\";\nimport { Modes } from \"../OptionModel.js\";\n\nexport enum ODataVersion {\n V2 = \"2.0\",\n V4 = \"4.0\",\n}\n\nexport const enum DataTypes {\n PrimitiveType = \"PrimitiveType\",\n EnumType = \"EnumType\",\n ComplexType = \"ComplexType\",\n ModelType = \"ModelType\",\n}\n\nexport const enum OperationTypes {\n Function = \"Function\",\n Action = \"Action\",\n}\n\nexport interface PropertyModel {\n odataName: string;\n name: string;\n odataType: string;\n fqType: string;\n type: string;\n typeModule?: string;\n qObject?: string;\n qPath: string;\n qParam?: string;\n required: boolean;\n isCollection: boolean;\n dataType: DataTypes;\n converters?: Array<ValueConverterImport>;\n managed?: boolean;\n}\n\nexport type ModelType = EntityType | ComplexType | EnumType;\n\nexport interface EntityType extends ComplexType {\n id: {\n // fully qualified name of entity to which this id belongs (might have been inherited)\n fqName: string;\n // that's the name of the param model for the id function\n modelName: string;\n // that's the name of the id function which is a q-object\n qName: string;\n };\n generateId: boolean;\n keyNames: Array<string>;\n keys: Array<PropertyModel>;\n getKeyUnion(): string;\n}\n\nexport interface ComplexType {\n dataType: DataTypes;\n fqName: string;\n odataName: string;\n name: string;\n modelName: string;\n editableName: string;\n qName: string;\n qBaseName?: string;\n serviceName: string;\n serviceCollectionName: string;\n folderPath: string;\n props: Array<PropertyModel>;\n baseProps: Array<PropertyModel>;\n baseClasses: Array<string>;\n finalBaseClass: string | undefined;\n abstract: boolean;\n open: boolean;\n genMode: Modes;\n subtypes: Set<string>;\n}\n\nexport interface EnumType {\n dataType: DataTypes;\n odataName: string;\n fqName: string;\n name: string;\n modelName: string;\n folderPath: string;\n members: Array<{ name: string; value: number }>;\n}\n\nexport interface OperationType {\n fqName: string;\n odataName: string;\n name: string;\n qName: string;\n paramsModelName: string;\n type: OperationTypes;\n parameters: Array<PropertyModel>;\n returnType?: ReturnTypeModel;\n usePost?: boolean;\n overrides?: Array<Array<PropertyModel>>;\n}\n\nexport interface ReturnTypeModel extends PropertyModel {}\n\nexport type EntityContainerModel = {\n entitySets: { [name: string]: EntitySetType };\n singletons: { [name: string]: SingletonType };\n functions: { [name: string]: FunctionImportType };\n actions: { [name: string]: ActionImportType };\n};\n\nexport interface SingletonType {\n fqName: string;\n odataName: string;\n name: string;\n entityType: EntityType;\n navPropBinding?: Array<NavPropBindingType>;\n}\n\nexport interface EntitySetType {\n fqName: string;\n odataName: string;\n name: string;\n entityType: EntityType;\n navPropBinding?: Array<NavPropBindingType>;\n}\n\nexport interface NavPropBindingType {\n path: string;\n target: string;\n}\n\nexport interface ActionImportType {\n fqName: string;\n odataName: string;\n name: string;\n operation: string;\n}\n\nexport interface FunctionImportType extends ActionImportType {\n entitySet: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DataTypeModel.js","sourceRoot":"","sources":["../../src/data-model/DataTypeModel.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,0BAAU,CAAA;IACV,0BAAU,CAAA;AACZ,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB","sourcesContent":["import { ValueConverterImport } from \"@odata2ts/converter-runtime\";\nimport { Modes } from \"../OptionModel.js\";\n\nexport enum ODataVersion {\n V2 = \"2.0\",\n V4 = \"4.0\",\n}\n\nexport const enum DataTypes {\n PrimitiveType = \"PrimitiveType\",\n EnumType = \"EnumType\",\n ComplexType = \"ComplexType\",\n ModelType = \"ModelType\",\n}\n\nexport const enum OperationTypes {\n Function = \"Function\",\n Action = \"Action\",\n}\n\nexport interface PropertyModel {\n odataName: string;\n name: string;\n odataType: string;\n fqType: string;\n type: string;\n typeModule?: string;\n qObject?: string;\n qPath: string;\n qParam?: string;\n required: boolean;\n isCollection: boolean;\n dataType: DataTypes;\n converters?: Array<ValueConverterImport>;\n managed?: boolean;\n}\n\nexport type ModelType = EntityType | ComplexType | EnumType;\n\nexport interface EntityType extends ComplexType {\n id: {\n // fully qualified name of entity to which this id belongs (might have been inherited)\n fqName: string;\n // that's the name of the param model for the id function\n modelName: string;\n // that's the name of the id function which is a q-object\n qName: string;\n };\n generateId: boolean;\n keyNames: Array<string>;\n keys: Array<PropertyModel>;\n getKeyUnion(): string;\n}\n\nexport interface ComplexType {\n dataType: DataTypes;\n fqName: string;\n odataName: string;\n name: string;\n modelName: string;\n editableName: string;\n qName: string;\n qBaseName?: string;\n serviceName: string;\n serviceCollectionName: string;\n folderPath: string;\n props: Array<PropertyModel>;\n baseProps: Array<PropertyModel>;\n baseClasses: Array<string>;\n finalBaseClass: string | undefined;\n abstract: boolean;\n open: boolean;\n genMode: Modes;\n subtypes: Set<string>;\n}\n\nexport interface EnumType {\n dataType: DataTypes;\n odataName: string;\n fqName: string;\n name: string;\n modelName: string;\n folderPath: string;\n members: Array<{ name: string; value: number }>;\n}\n\nexport interface OperationType {\n fqName: string;\n odataName: string;\n name: string;\n qName: string;\n paramsModelName: string;\n type: OperationTypes;\n parameters: Array<PropertyModel>;\n returnType?: ReturnTypeModel;\n usePost?: boolean;\n overrides?: Array<Array<PropertyModel>>;\n composable?: boolean;\n}\n\nexport interface ReturnTypeModel extends PropertyModel {}\n\nexport type EntityContainerModel = {\n entitySets: { [name: string]: EntitySetType };\n singletons: { [name: string]: SingletonType };\n functions: { [name: string]: FunctionImportType };\n actions: { [name: string]: ActionImportType };\n};\n\nexport interface SingletonType {\n fqName: string;\n odataName: string;\n name: string;\n entityType: EntityType;\n navPropBinding?: Array<NavPropBindingType>;\n}\n\nexport interface EntitySetType {\n fqName: string;\n odataName: string;\n name: string;\n entityType: EntityType;\n navPropBinding?: Array<NavPropBindingType>;\n}\n\nexport interface NavPropBindingType {\n path: string;\n target: string;\n}\n\nexport interface ActionImportType {\n fqName: string;\n odataName: string;\n name: string;\n operation: string;\n}\n\nexport interface FunctionImportType extends ActionImportType {\n entitySet: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ODataEdmxModelV4.js","sourceRoot":"","sources":["../../../src/data-model/edmx/ODataEdmxModelV4.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ComplexType,\n EntityContainer,\n EntitySet,\n EntityType,\n ODataEdmxModelBase,\n Property,\n ReturnType,\n Schema,\n} from \"./ODataEdmxModelBase.js\";\n\nexport interface ODataEdmxModelV4 extends ODataEdmxModelBase<SchemaV4> {}\n\nexport interface SchemaV4 extends Schema<EntityTypeV4, ComplexTypeV4> {\n EntityContainer?: Array<EntityContainerV4>;\n Function?: Array<Operation>;\n Action?: Array<Operation>;\n}\n\nexport interface EntityTypeV4 extends EntityType {\n NavigationProperty?: Array<NavigationProperty>;\n}\n\nexport interface ComplexTypeV4 extends ComplexType {\n NavigationProperty?: Array<NavigationProperty>;\n}\n\nexport interface NavigationProperty {\n $: {\n Name: string;\n Type: string;\n Nullable?: \"true\" | \"false\";\n Partner?: string;\n };\n // TODO: OnDelete, ReferentialConstraint, etc.\n}\n\nexport interface EntityContainerV4 extends EntityContainer<EntitySetV4> {\n Singleton?: Array<Singleton>;\n FunctionImport?: Array<FunctionImport>;\n ActionImport?: Array<ActionImport>;\n}\n\nexport interface EntitySetV4 extends EntitySet {\n NavigationPropertyBinding?: Array<NavigationPropertyBinding>;\n}\n\nexport interface Singleton {\n $: {\n Name: string;\n Type: string;\n };\n NavigationPropertyBinding?: Array<NavigationPropertyBinding>;\n}\n\nexport interface FunctionImport {\n $: {\n Name: string;\n Function: string;\n EntitySet: string;\n };\n}\n\nexport interface ActionImport {\n $: {\n Name: string;\n Action: string;\n };\n}\n\nexport interface NavigationPropertyBinding {\n $: {\n Path: string;\n Target: string;\n };\n}\n\nexport interface Operation {\n $: {\n Name: string;\n IsBound?: \"true\" | \"false\";\n };\n Parameter?: Array<Parameter>;\n ReturnType?: Array<ReturnType>;\n}\n\nexport interface Parameter extends Property {\n Unicode?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ODataEdmxModelV4.js","sourceRoot":"","sources":["../../../src/data-model/edmx/ODataEdmxModelV4.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ComplexType,\n EntityContainer,\n EntitySet,\n EntityType,\n ODataEdmxModelBase,\n Property,\n ReturnType,\n Schema,\n} from \"./ODataEdmxModelBase.js\";\n\nexport interface ODataEdmxModelV4 extends ODataEdmxModelBase<SchemaV4> {}\n\nexport interface SchemaV4 extends Schema<EntityTypeV4, ComplexTypeV4> {\n EntityContainer?: Array<EntityContainerV4>;\n Function?: Array<Operation>;\n Action?: Array<Operation>;\n}\n\nexport interface EntityTypeV4 extends EntityType {\n NavigationProperty?: Array<NavigationProperty>;\n}\n\nexport interface ComplexTypeV4 extends ComplexType {\n NavigationProperty?: Array<NavigationProperty>;\n}\n\nexport interface NavigationProperty {\n $: {\n Name: string;\n Type: string;\n Nullable?: \"true\" | \"false\";\n Partner?: string;\n };\n // TODO: OnDelete, ReferentialConstraint, etc.\n}\n\nexport interface EntityContainerV4 extends EntityContainer<EntitySetV4> {\n Singleton?: Array<Singleton>;\n FunctionImport?: Array<FunctionImport>;\n ActionImport?: Array<ActionImport>;\n}\n\nexport interface EntitySetV4 extends EntitySet {\n NavigationPropertyBinding?: Array<NavigationPropertyBinding>;\n}\n\nexport interface Singleton {\n $: {\n Name: string;\n Type: string;\n };\n NavigationPropertyBinding?: Array<NavigationPropertyBinding>;\n}\n\nexport interface FunctionImport {\n $: {\n Name: string;\n Function: string;\n EntitySet: string;\n };\n}\n\nexport interface ActionImport {\n $: {\n Name: string;\n Action: string;\n };\n}\n\nexport interface NavigationPropertyBinding {\n $: {\n Path: string;\n Target: string;\n };\n}\n\nexport interface Operation {\n $: {\n Name: string;\n IsBound?: \"true\" | \"false\";\n IsComposable?: \"true\" | \"false\";\n };\n Parameter?: Array<Parameter>;\n ReturnType?: Array<ReturnType>;\n}\n\nexport interface Parameter extends Property {\n Unicode?: boolean;\n}\n"]}
|
|
@@ -72,8 +72,13 @@ export class ImportContainer {
|
|
|
72
72
|
addClientApi(clientApi) {
|
|
73
73
|
const name = ClientApiImports[clientApi];
|
|
74
74
|
const importName = this.importedNameValidator.validateName(LIB_MODULES.clientApi, name);
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
if (clientApi === ClientApiImports.ODataHttpMethods) {
|
|
76
|
+
this.libs.clientApi.regular.set(name, importName);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// complete client api consists only of types
|
|
80
|
+
this.libs.clientApi.typeOnly.set(name, importName);
|
|
81
|
+
}
|
|
77
82
|
return importName;
|
|
78
83
|
}
|
|
79
84
|
addServiceObject(odataVersion, serviceObject) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportContainer.js","sourceRoot":"","sources":["../../src/generator/ImportContainer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,WAAW,EAEX,cAAc,EACd,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAOnE;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IAoB1B,YACY,IAAY,EACZ,QAAgB,EAChB,SAAoB,EACpB,aAAkE,EACzD,qBAA8B,EACvC,aAAwC;QALxC,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAW;QACpB,kBAAa,GAAb,aAAa,CAAqD;QACzD,0BAAqB,GAArB,qBAAqB,CAAS;QACvC,kBAAa,GAAb,aAAa,CAA2B;QAxBpD,uDAAuD;QAC/C,gBAAW,GAAG;YACpB,OAAO,EAAE,IAAI,GAAG,EAA+B;YAC/C,QAAQ,EAAE,IAAI,GAAG,EAA+B;SACjD,CAAC;QACF,iCAAiC;QACzB,oBAAe,GAAG;YACxB,OAAO,EAAE,IAAI,GAAG,EAA+B;YAC/C,QAAQ,EAAE,IAAI,GAAG,EAA+B;SACjD,CAAC;QAEM,SAAI,GAAwB;YAClC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE;YACjD,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE;YACpD,SAAS,EAAE,EAAE,OAAO,EAAE,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CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAClF,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC;IAC5E,CAAC;CACF","sourcesContent":["import path from \"path\";\r\nimport { ODataVersions } from \"@odata2ts/odata-core\";\r\nimport { ImportDeclarationStructure, OptionalKind } from \"ts-morph\";\r\nimport { DataModel } from \"../data-model/DataModel.js\";\r\nimport { ComplexType } from \"../data-model/DataTypeModel.js\";\r\nimport {\r\n ClientApiImports,\r\n CoreImports,\r\n LIB_MODULES,\r\n QueryObjectImports,\r\n ServiceImports,\r\n VERSIONED_CORE_IMPORTS,\r\n VERSIONED_SERVICE_IMPORTS,\r\n} from \"./import/ImportObjects.js\";\r\nimport { ImportedNameValidator } from \"./ImportedNameValidator.js\";\r\n\r\ntype ImportContainerType = Record<\r\n keyof typeof LIB_MODULES,\r\n { regular: Map<string, string>; typeOnly: Map<string, string> }\r\n>;\r\n\r\n/**\r\n * Handles all the import statements for a given file.\r\n *\r\n * Features a renaming mechanism, so that when the import name conflicts with an existing import a new\r\n * name is generated and returned.\r\n *\r\n * Map<string,string>\r\n */\r\nexport class ImportContainer {\r\n private readonly importedNameValidator: ImportedNameValidator;\r\n // mapping of a custom defined type to a primitive type\r\n private customTypes = {\r\n regular: new Map<string, Map<string, string>>(),\r\n typeOnly: new Map<string, Map<string, string>>(),\r\n };\r\n // imports to generated artefacts\r\n private internalImports = {\r\n regular: new Map<string, Map<string, string>>(),\r\n typeOnly: new Map<string, Map<string, string>>(),\r\n };\r\n\r\n private libs: ImportContainerType = {\r\n core: { regular: new Map(), typeOnly: new Map() },\r\n qObject: { regular: new Map(), typeOnly: new Map() },\r\n clientApi: { regular: new Map(), typeOnly: new Map() },\r\n service: { regular: new Map(), typeOnly: new Map() },\r\n };\r\n\r\n constructor(\r\n protected path: string,\r\n protected fileName: string,\r\n protected dataModel: DataModel,\r\n protected mainFileNames: { model: string; qObject: string; service: string },\r\n protected readonly bundledFileGeneration: boolean,\r\n protected reservedNames: Array<string> | undefined,\r\n ) {\r\n this.importedNameValidator = new ImportedNameValidator(reservedNames);\r\n }\r\n\r\n public addCoreLib(odataVersion: ODataVersions, coreLib: CoreImports) {\r\n const isVersioned = VERSIONED_CORE_IMPORTS.includes(coreLib);\r\n const name = CoreImports[coreLib] + (isVersioned ? ODataVersions[odataVersion] : \"\");\r\n const importName = this.importedNameValidator.validateName(LIB_MODULES.core, name);\r\n\r\n // TODO: currently only types are imported, however enums could potentially be imported too\r\n this.libs.core.typeOnly.set(name, importName);\r\n\r\n return importName;\r\n }\r\n\r\n public addFromMainQObject(name: string, isTypeOnly = false) {\r\n return this.addGeneratedImport(\"\", this.mainFileNames.qObject, name, isTypeOnly);\r\n }\r\n\r\n private addFromQObject(name: string, typeOnlyImport = false) {\r\n const importName = this.importedNameValidator.validateName(LIB_MODULES.qObject, name);\r\n\r\n const imports = this.libs.qObject;\r\n if (typeOnlyImport) {\r\n if (!imports.regular.has(name)) {\r\n imports.typeOnly.set(name, importName);\r\n }\r\n } else {\r\n if (imports.typeOnly.has(name)) {\r\n imports.typeOnly.delete(name);\r\n }\r\n imports.regular.set(name, importName);\r\n }\r\n\r\n return importName;\r\n }\r\n\r\n public addQObject(qObject: QueryObjectImports | string) {\r\n return this.addFromQObject(qObject);\r\n }\r\n\r\n public addQObjectType(qObject: string) {\r\n return this.addFromQObject(qObject, true);\r\n }\r\n\r\n public addClientApi(clientApi: ClientApiImports) {\r\n const name = ClientApiImports[clientApi];\r\n const importName = this.importedNameValidator.validateName(LIB_MODULES.clientApi, name);\r\n\r\n // complete client api consists only of types\r\n this.libs.clientApi.typeOnly.set(name, importName);\r\n return importName;\r\n }\r\n\r\n public addServiceObject(odataVersion: ODataVersions, serviceObject: ServiceImports) {\r\n const isVersioned = VERSIONED_SERVICE_IMPORTS.includes(serviceObject);\r\n const name = ServiceImports[serviceObject] + (isVersioned ? ODataVersions[odataVersion] : \"\");\r\n const importName = this.importedNameValidator.validateName(LIB_MODULES.service, name);\r\n\r\n // only regular imports for the service package\r\n this.libs.service.regular.set(name, importName);\r\n return importName;\r\n }\r\n\r\n // TODO: make sure that regular imports win over additional typeOnly imports\r\n public addCustomType(moduleName: string, typeName: string, isTypeOnly: boolean = false) {\r\n const importName = this.importedNameValidator.validateName(moduleName, typeName);\r\n const imports = isTypeOnly ? this.customTypes.typeOnly : this.customTypes.regular;\r\n let importList = imports.get(moduleName);\r\n if (!importList) {\r\n importList = new Map();\r\n imports.set(moduleName, importList);\r\n }\r\n\r\n importList.set(typeName, importName);\r\n return importName;\r\n }\r\n\r\n private pathAndFile(filePath: string, fileName: string) {\r\n return filePath ? `${filePath}/${fileName}` : fileName;\r\n }\r\n\r\n private isDifferentFile(filePath: string, fileName: string) {\r\n return this.pathAndFile(this.path, this.fileName) !== this.pathAndFile(filePath, fileName);\r\n }\r\n\r\n private addGeneratedImport(folderPath: string, fileName: string, name: string, isTypeOnly = false): string {\r\n // imports are only relevant for different files\r\n if (!this.isDifferentFile(folderPath, fileName)) {\r\n return name;\r\n }\r\n\r\n const moduleName = this.pathAndFile(folderPath, fileName);\r\n const importName = this.importedNameValidator.validateName(moduleName, name);\r\n const imports = isTypeOnly ? this.internalImports.typeOnly : this.internalImports.regular;\r\n\r\n if (isTypeOnly && this.internalImports.regular.get(moduleName)?.has(name)) {\r\n return importName;\r\n }\r\n if (!isTypeOnly && this.internalImports.typeOnly.get(moduleName)?.has(name)) {\r\n this.internalImports.typeOnly.get(moduleName)?.delete(name);\r\n }\r\n\r\n const importList = imports.get(moduleName) || new Map<string, string>();\r\n importList.set(name, importName);\r\n imports.set(moduleName, importList);\r\n\r\n return importName;\r\n }\r\n\r\n public addGeneratedModel(fqName: string, name: string, isTypeOnly = true): string {\r\n if (this.bundledFileGeneration) {\r\n return this.addGeneratedImport(\"\", this.mainFileNames.model, name, isTypeOnly);\r\n } else {\r\n const model = this.dataModel.getModel(fqName) as ComplexType | undefined;\r\n if (!model && fqName !== \"\") {\r\n throw new Error(`Cannot find model by its fully qualified name: ${fqName}!`);\r\n }\r\n\r\n const folderPath = model ? model.folderPath : \"\";\r\n const modelName = model ? model.modelName : this.mainFileNames.model;\r\n return this.addGeneratedImport(folderPath, modelName, name, isTypeOnly);\r\n }\r\n }\r\n\r\n public addGeneratedQBaseObject(model: ComplexType, isTypeOnly = false) {\r\n if (!model.qBaseName) {\r\n throw new Error(`Model ${model.fqName} has no base type!`);\r\n }\r\n return this.bundledFileGeneration\r\n ? this.addGeneratedImport(\"\", this.mainFileNames.qObject, model.qBaseName, isTypeOnly)\r\n : this.addGeneratedImport(model.folderPath, model.qBaseName, model.qBaseName, isTypeOnly);\r\n }\r\n\r\n public addGeneratedQObject(fqName: string, name: string, isTypeOnly = false) {\r\n if (this.bundledFileGeneration) {\r\n return this.addGeneratedImport(\"\", this.mainFileNames.qObject, name, isTypeOnly);\r\n } else {\r\n const model = this.dataModel.getModel(fqName) as ComplexType | undefined;\r\n if (!model && fqName !== \"\") {\r\n throw new Error(`Cannot find q-object by its fully qualified name: ${fqName}!`);\r\n }\r\n\r\n const folderPath = model ? model.folderPath : \"\";\r\n const qName = model ? model.qName : this.mainFileNames!.qObject;\r\n return this.addGeneratedImport(folderPath, qName, name, isTypeOnly);\r\n }\r\n }\r\n\r\n public addGeneratedService(fqName: string, name: string) {\r\n if (this.bundledFileGeneration) {\r\n return this.addGeneratedImport(\"\", this.mainFileNames.service, name);\r\n } else {\r\n const model = this.dataModel.getModel(fqName) as ComplexType;\r\n return this.addGeneratedImport(model.folderPath, model.serviceName, name);\r\n }\r\n }\r\n\r\n private createImportDecl(\r\n module: string,\r\n toImport: Map<string, string>,\r\n isTypeOnly = false,\r\n ): OptionalKind<ImportDeclarationStructure> {\r\n return {\r\n namedImports: this.getNamedImports(toImport),\r\n moduleSpecifier: module,\r\n isTypeOnly,\r\n };\r\n }\r\n\r\n public getImportDeclarations(): Array<OptionalKind<ImportDeclarationStructure>> {\r\n return [\r\n ...Object.entries(this.libs).reduce<Array<OptionalKind<ImportDeclarationStructure>>>(\r\n (result, [moduleName, toImport]) => {\r\n const module = LIB_MODULES[moduleName as keyof typeof LIB_MODULES];\r\n if (toImport.typeOnly.size) {\r\n result.push(this.createImportDecl(module, toImport.typeOnly, true));\r\n }\r\n if (toImport.regular.size) {\r\n result.push(this.createImportDecl(module, toImport.regular));\r\n }\r\n return result;\r\n },\r\n [],\r\n ),\r\n ...[...this.customTypes.typeOnly]\r\n .filter(([moduleName, toImport]) => toImport.size > 0)\r\n .map(([moduleName, toImport]) => {\r\n return this.createImportDecl(moduleName, toImport, true);\r\n }),\r\n ...[...this.customTypes.regular]\r\n .filter(([moduleName, toImport]) => toImport.size > 0)\r\n .map(([moduleName, toImport]) => {\r\n return this.createImportDecl(moduleName, toImport);\r\n }),\r\n ...[...this.internalImports.typeOnly]\r\n .filter(([_, toImport]) => toImport.size > 0)\r\n .map(([key, toImport]) => {\r\n const module = this.getModuleSpecifier(key);\r\n return this.createImportDecl(module, toImport, true);\r\n }),\r\n ...[...this.internalImports.regular]\r\n .filter(([_, toImport]) => toImport.size > 0)\r\n .map(([key, toImport]) => {\r\n const module = this.getModuleSpecifier(key);\r\n return this.createImportDecl(module, toImport);\r\n }),\r\n ];\r\n }\r\n\r\n private getNamedImports(toImport: Map<string, string>): Array<{ name: string; alias: string | undefined }> {\r\n return [...toImport.entries()].map(([name, alias]) => ({\r\n name,\r\n alias: alias !== name ? alias : undefined,\r\n }));\r\n }\r\n\r\n private getModuleSpecifier(filePath: string): string {\r\n const relativePath = path.relative(this.path, filePath).replaceAll(path.sep, \"/\");\r\n return !relativePath.startsWith(\".\") ? \"./\" + relativePath : relativePath;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ImportContainer.js","sourceRoot":"","sources":["../../src/generator/ImportContainer.ts"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Y,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAClF,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC;IAC5E,CAAC;CACF","sourcesContent":["import path from \"path\";\nimport { ODataVersions } from \"@odata2ts/odata-core\";\nimport { ImportDeclarationStructure, OptionalKind } from \"ts-morph\";\nimport { DataModel } from \"../data-model/DataModel.js\";\nimport { ComplexType } from \"../data-model/DataTypeModel.js\";\nimport {\n ClientApiImports,\n CoreImports,\n LIB_MODULES,\n QueryObjectImports,\n ServiceImports,\n VERSIONED_CORE_IMPORTS,\n VERSIONED_SERVICE_IMPORTS,\n} from \"./import/ImportObjects.js\";\nimport { ImportedNameValidator } from \"./ImportedNameValidator.js\";\n\ntype ImportContainerType = Record<\n keyof typeof LIB_MODULES,\n { regular: Map<string, string>; typeOnly: Map<string, string> }\n>;\n\n/**\n * Handles all the import statements for a given file.\n *\n * Features a renaming mechanism, so that when the import name conflicts with an existing import a new\n * name is generated and returned.\n *\n * Map<string,string>\n */\nexport class ImportContainer {\n private readonly importedNameValidator: ImportedNameValidator;\n // mapping of a custom defined type to a primitive type\n private customTypes = {\n regular: new Map<string, Map<string, string>>(),\n typeOnly: new Map<string, Map<string, string>>(),\n };\n // imports to generated artefacts\n private internalImports = {\n regular: new Map<string, Map<string, string>>(),\n typeOnly: new Map<string, Map<string, string>>(),\n };\n\n private libs: ImportContainerType = {\n core: { regular: new Map(), typeOnly: new Map() },\n qObject: { regular: new Map(), typeOnly: new Map() },\n clientApi: { regular: new Map(), typeOnly: new Map() },\n service: { regular: new Map(), typeOnly: new Map() },\n };\n\n constructor(\n protected path: string,\n protected fileName: string,\n protected dataModel: DataModel,\n protected mainFileNames: { model: string; qObject: string; service: string },\n protected readonly bundledFileGeneration: boolean,\n protected reservedNames: Array<string> | undefined,\n ) {\n this.importedNameValidator = new ImportedNameValidator(reservedNames);\n }\n\n public addCoreLib(odataVersion: ODataVersions, coreLib: CoreImports) {\n const isVersioned = VERSIONED_CORE_IMPORTS.includes(coreLib);\n const name = CoreImports[coreLib] + (isVersioned ? ODataVersions[odataVersion] : \"\");\n const importName = this.importedNameValidator.validateName(LIB_MODULES.core, name);\n\n // TODO: currently only types are imported, however enums could potentially be imported too\n this.libs.core.typeOnly.set(name, importName);\n\n return importName;\n }\n\n public addFromMainQObject(name: string, isTypeOnly = false) {\n return this.addGeneratedImport(\"\", this.mainFileNames.qObject, name, isTypeOnly);\n }\n\n private addFromQObject(name: string, typeOnlyImport = false) {\n const importName = this.importedNameValidator.validateName(LIB_MODULES.qObject, name);\n\n const imports = this.libs.qObject;\n if (typeOnlyImport) {\n if (!imports.regular.has(name)) {\n imports.typeOnly.set(name, importName);\n }\n } else {\n if (imports.typeOnly.has(name)) {\n imports.typeOnly.delete(name);\n }\n imports.regular.set(name, importName);\n }\n\n return importName;\n }\n\n public addQObject(qObject: QueryObjectImports | string) {\n return this.addFromQObject(qObject);\n }\n\n public addQObjectType(qObject: string) {\n return this.addFromQObject(qObject, true);\n }\n\n public addClientApi(clientApi: ClientApiImports) {\n const name = ClientApiImports[clientApi];\n const importName = this.importedNameValidator.validateName(LIB_MODULES.clientApi, name);\n\n if (clientApi === ClientApiImports.ODataHttpMethods) {\n this.libs.clientApi.regular.set(name, importName);\n } else {\n // complete client api consists only of types\n this.libs.clientApi.typeOnly.set(name, importName);\n }\n return importName;\n }\n\n public addServiceObject(odataVersion: ODataVersions, serviceObject: ServiceImports) {\n const isVersioned = VERSIONED_SERVICE_IMPORTS.includes(serviceObject);\n const name = ServiceImports[serviceObject] + (isVersioned ? ODataVersions[odataVersion] : \"\");\n const importName = this.importedNameValidator.validateName(LIB_MODULES.service, name);\n\n // only regular imports for the service package\n this.libs.service.regular.set(name, importName);\n return importName;\n }\n\n // TODO: make sure that regular imports win over additional typeOnly imports\n public addCustomType(moduleName: string, typeName: string, isTypeOnly: boolean = false) {\n const importName = this.importedNameValidator.validateName(moduleName, typeName);\n const imports = isTypeOnly ? this.customTypes.typeOnly : this.customTypes.regular;\n let importList = imports.get(moduleName);\n if (!importList) {\n importList = new Map();\n imports.set(moduleName, importList);\n }\n\n importList.set(typeName, importName);\n return importName;\n }\n\n private pathAndFile(filePath: string, fileName: string) {\n return filePath ? `${filePath}/${fileName}` : fileName;\n }\n\n private isDifferentFile(filePath: string, fileName: string) {\n return this.pathAndFile(this.path, this.fileName) !== this.pathAndFile(filePath, fileName);\n }\n\n private addGeneratedImport(folderPath: string, fileName: string, name: string, isTypeOnly = false): string {\n // imports are only relevant for different files\n if (!this.isDifferentFile(folderPath, fileName)) {\n return name;\n }\n\n const moduleName = this.pathAndFile(folderPath, fileName);\n const importName = this.importedNameValidator.validateName(moduleName, name);\n const imports = isTypeOnly ? this.internalImports.typeOnly : this.internalImports.regular;\n\n if (isTypeOnly && this.internalImports.regular.get(moduleName)?.has(name)) {\n return importName;\n }\n if (!isTypeOnly && this.internalImports.typeOnly.get(moduleName)?.has(name)) {\n this.internalImports.typeOnly.get(moduleName)?.delete(name);\n }\n\n const importList = imports.get(moduleName) || new Map<string, string>();\n importList.set(name, importName);\n imports.set(moduleName, importList);\n\n return importName;\n }\n\n public addGeneratedModel(fqName: string, name: string, isTypeOnly = true): string {\n if (this.bundledFileGeneration) {\n return this.addGeneratedImport(\"\", this.mainFileNames.model, name, isTypeOnly);\n } else {\n const model = this.dataModel.getModel(fqName) as ComplexType | undefined;\n if (!model && fqName !== \"\") {\n throw new Error(`Cannot find model by its fully qualified name: ${fqName}!`);\n }\n\n const folderPath = model ? model.folderPath : \"\";\n const modelName = model ? model.modelName : this.mainFileNames.model;\n return this.addGeneratedImport(folderPath, modelName, name, isTypeOnly);\n }\n }\n\n public addGeneratedQBaseObject(model: ComplexType, isTypeOnly = false) {\n if (!model.qBaseName) {\n throw new Error(`Model ${model.fqName} has no base type!`);\n }\n return this.bundledFileGeneration\n ? this.addGeneratedImport(\"\", this.mainFileNames.qObject, model.qBaseName, isTypeOnly)\n : this.addGeneratedImport(model.folderPath, model.qBaseName, model.qBaseName, isTypeOnly);\n }\n\n public addGeneratedQObject(fqName: string, name: string, isTypeOnly = false) {\n if (this.bundledFileGeneration) {\n return this.addGeneratedImport(\"\", this.mainFileNames.qObject, name, isTypeOnly);\n } else {\n const model = this.dataModel.getModel(fqName) as ComplexType | undefined;\n if (!model && fqName !== \"\") {\n throw new Error(`Cannot find q-object by its fully qualified name: ${fqName}!`);\n }\n\n const folderPath = model ? model.folderPath : \"\";\n const qName = model ? model.qName : this.mainFileNames!.qObject;\n return this.addGeneratedImport(folderPath, qName, name, isTypeOnly);\n }\n }\n\n public addGeneratedService(fqName: string, name: string) {\n if (this.bundledFileGeneration) {\n return this.addGeneratedImport(\"\", this.mainFileNames.service, name);\n } else {\n const model = this.dataModel.getModel(fqName) as ComplexType;\n return this.addGeneratedImport(model.folderPath, model.serviceName, name);\n }\n }\n\n private createImportDecl(\n module: string,\n toImport: Map<string, string>,\n isTypeOnly = false,\n ): OptionalKind<ImportDeclarationStructure> {\n return {\n namedImports: this.getNamedImports(toImport),\n moduleSpecifier: module,\n isTypeOnly,\n };\n }\n\n public getImportDeclarations(): Array<OptionalKind<ImportDeclarationStructure>> {\n return [\n ...Object.entries(this.libs).reduce<Array<OptionalKind<ImportDeclarationStructure>>>(\n (result, [moduleName, toImport]) => {\n const module = LIB_MODULES[moduleName as keyof typeof LIB_MODULES];\n if (toImport.typeOnly.size) {\n result.push(this.createImportDecl(module, toImport.typeOnly, true));\n }\n if (toImport.regular.size) {\n result.push(this.createImportDecl(module, toImport.regular));\n }\n return result;\n },\n [],\n ),\n ...[...this.customTypes.typeOnly]\n .filter(([moduleName, toImport]) => toImport.size > 0)\n .map(([moduleName, toImport]) => {\n return this.createImportDecl(moduleName, toImport, true);\n }),\n ...[...this.customTypes.regular]\n .filter(([moduleName, toImport]) => toImport.size > 0)\n .map(([moduleName, toImport]) => {\n return this.createImportDecl(moduleName, toImport);\n }),\n ...[...this.internalImports.typeOnly]\n .filter(([_, toImport]) => toImport.size > 0)\n .map(([key, toImport]) => {\n const module = this.getModuleSpecifier(key);\n return this.createImportDecl(module, toImport, true);\n }),\n ...[...this.internalImports.regular]\n .filter(([_, toImport]) => toImport.size > 0)\n .map(([key, toImport]) => {\n const module = this.getModuleSpecifier(key);\n return this.createImportDecl(module, toImport);\n }),\n ];\n }\n\n private getNamedImports(toImport: Map<string, string>): Array<{ name: string; alias: string | undefined }> {\n return [...toImport.entries()].map(([name, alias]) => ({\n name,\n alias: alias !== name ? alias : undefined,\n }));\n }\n\n private getModuleSpecifier(filePath: string): string {\n const relativePath = path.relative(this.path, filePath).replaceAll(path.sep, \"/\");\n return !relativePath.startsWith(\".\") ? \"./\" + relativePath : relativePath;\n }\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import { ODataVersions } from "@odata2ts/odata-core";
|
|
|
3
3
|
import { Scope, VariableDeclarationKind, } from "ts-morph";
|
|
4
4
|
import { firstCharLowerCase } from "xml2js/lib/processors.js";
|
|
5
5
|
import { QueryObjectImports } from "./import/ImportObjects.js";
|
|
6
|
+
import { importMainResponseConverter, importReturnType } from "./import/ImportResponseHelper.js";
|
|
6
7
|
export const generateQueryObjects = (project, dataModel, version, options, namingHelper) => {
|
|
7
8
|
const generator = new QueryObjectGenerator(project, dataModel, version, options, namingHelper);
|
|
8
9
|
return generator.generate();
|
|
@@ -297,42 +298,38 @@ class QueryObjectGenerator {
|
|
|
297
298
|
const hasParams = operation.parameters.length > 0 || ((_a = operation.overrides) === null || _a === void 0 ? void 0 : _a.length);
|
|
298
299
|
const isParamsOptional = !![operation.parameters, ...((_b = operation.overrides) !== null && _b !== void 0 ? _b : [])].find((pSet) => pSet.length === 0);
|
|
299
300
|
// imports
|
|
300
|
-
const qOp = operation.type === "Action" /* OperationTypes.Action */
|
|
301
|
+
const qOp = operation.type === "Action" /* OperationTypes.Action */
|
|
302
|
+
? QueryObjectImports.QAction
|
|
303
|
+
: isV2
|
|
304
|
+
? QueryObjectImports.QFunctionV2
|
|
305
|
+
: QueryObjectImports.QFunctionV4;
|
|
301
306
|
const qOperation = imports.addQObject(qOp);
|
|
302
307
|
const paramModelName = hasParams ? imports.addGeneratedModel(baseFqName, operation.paramsModelName) : undefined;
|
|
308
|
+
const rtType = !returnType
|
|
309
|
+
? undefined
|
|
310
|
+
: returnType.type && returnType.dataType !== "PrimitiveType" /* DataTypes.PrimitiveType */
|
|
311
|
+
? imports.addGeneratedModel(returnType.fqType, returnType.type)
|
|
312
|
+
: returnType.type;
|
|
313
|
+
const responseStructure = returnType ? importReturnType(this.version, imports, returnType) : undefined;
|
|
314
|
+
const completeResponseStructure = responseStructure && rtType ? `${responseStructure}<${rtType}>` : undefined;
|
|
303
315
|
let returnTypeOpStmt = "";
|
|
304
316
|
if (returnType) {
|
|
305
317
|
if (returnType.dataType === "ComplexType" /* DataTypes.ComplexType */ || returnType.dataType === "ModelType" /* DataTypes.ModelType */) {
|
|
318
|
+
// without converter no conversion
|
|
306
319
|
if (returnType.qObject) {
|
|
307
|
-
|
|
308
|
-
const rts = imports.addQObject(QueryObjectImports.ReturnTypes);
|
|
309
|
-
const rType = returnType.isCollection
|
|
310
|
-
? "COLLECTION"
|
|
311
|
-
: returnType.dataType === "ComplexType" /* DataTypes.ComplexType */
|
|
312
|
-
? "COMPLEX"
|
|
313
|
-
: "ENTITY";
|
|
314
|
-
const qComplexParam = imports.addQObject(QueryObjectImports.QComplexParam);
|
|
315
|
-
const returnQName = imports.addGeneratedQObject(returnType.fqType, returnType.qObject);
|
|
316
|
-
returnTypeOpStmt = `new ${opRt}(${rts}.${rType}, new ${qComplexParam}("NONE", new ${returnQName}))`;
|
|
320
|
+
returnTypeOpStmt = `new ${importMainResponseConverter(this.version, imports, returnType)}(new ${imports.addGeneratedQObject(returnType.fqType, returnType.qObject)})`;
|
|
317
321
|
}
|
|
318
322
|
}
|
|
319
|
-
//
|
|
320
|
-
else if (returnType.converters
|
|
321
|
-
|
|
322
|
-
const rtTypes = imports.addQObject(QueryObjectImports.ReturnTypes);
|
|
323
|
-
const rType = returnType.isCollection ? "COLLECTION" : "VALUE";
|
|
324
|
-
const qParam = imports.addQObject(returnType.qParam);
|
|
325
|
-
const rtKind = `${rtTypes}.${rType}`;
|
|
326
|
-
const converterParam = returnType.converters
|
|
327
|
-
? ", " + this.generateConverterStmt(imports, returnType.converters)
|
|
328
|
-
: "";
|
|
329
|
-
returnTypeOpStmt = `new ${rtClass}(${rtKind}, new ${qParam}("NONE", undefined${converterParam}))`;
|
|
323
|
+
// Primitive Types: without converter no conversion
|
|
324
|
+
else if (returnType.converters) {
|
|
325
|
+
returnTypeOpStmt = `new ${importMainResponseConverter(this.version, imports, returnType)}(${this.generateConverterStmt(imports, returnType.converters)})`;
|
|
330
326
|
}
|
|
331
327
|
}
|
|
328
|
+
const classWithGenerics = `${qOperation}<${hasParams ? paramModelName : "undefined"}${returnType ? ", " + completeResponseStructure : ""}>`;
|
|
332
329
|
file.getFile().addClass({
|
|
333
330
|
name: operation.qName,
|
|
334
331
|
isExported: true,
|
|
335
|
-
extends:
|
|
332
|
+
extends: classWithGenerics,
|
|
336
333
|
properties: [
|
|
337
334
|
{
|
|
338
335
|
name: "params",
|
|
@@ -344,9 +341,7 @@ class QueryObjectGenerator {
|
|
|
344
341
|
],
|
|
345
342
|
ctors: [
|
|
346
343
|
{
|
|
347
|
-
statements: [
|
|
348
|
-
`super("${operation.odataName}"${returnTypeOpStmt ? ", " + returnTypeOpStmt : isV2 ? ", undefined" : ""}${isV2 ? ", { v2Mode: true }" : ""})`,
|
|
349
|
-
],
|
|
344
|
+
statements: [`super("${operation.odataName}"${returnTypeOpStmt ? ", " + returnTypeOpStmt : ""})`],
|
|
350
345
|
},
|
|
351
346
|
],
|
|
352
347
|
methods: [
|
|
@@ -1 +1 @@
|
|
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AAU,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\nconst OPTIONS_STATEMENT = \"OPTS\";\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 this.generateOptions();\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 generateOptions() {\n const file = this.project.createOrGetMainQObjectFile();\n\n // for now assume only enableNativeInOperator requires options to be processed\n if (!this.options.enableNativeInOperator) {\n return;\n }\n\n // for now hardcode enableNativeInOperator\n file.getFile().addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: !this.options.bundledFileGeneration,\n declarations: [\n {\n name: OPTIONS_STATEMENT,\n initializer: `{ nativeIn: true }`,\n },\n ],\n });\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 getExtendsClauseForQObjects(model: ComplexType, imports: ImportContainer) {\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 return imports.addGeneratedQBaseObject(baseModel);\n }\n\n return imports.addQObject(QueryObjectImports.QueryObject);\n }\n\n private generateModel(file: FileHandler, model: ComplexType) {\n const imports = file.getImports();\n\n if (!model.qBaseName) {\n file.getFile().addClass({\n name: model.qName,\n isExported: true,\n extends: this.getExtendsClauseForQObjects(model, imports),\n properties: this.generateQueryObjectProps(file.getImports(), model.props),\n });\n } else {\n // base class used for extension needs an own file\n const baseFile = this.project.createOrGetQObjectFile(model.folderPath, model.qBaseName, [model.qBaseName]);\n baseFile.getFile().addClass({\n name: model.qBaseName,\n isExported: true,\n extends: this.getExtendsClauseForQObjects(model, baseFile.getImports()),\n properties: this.generateQueryObjectProps(baseFile.getImports(), model.props),\n });\n this.project.finalizeFile(baseFile);\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 subClassName = imports.addGeneratedQObject(subClass.fqName, subClass.qName);\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 ${subClassName}(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: imports.addGeneratedQBaseObject(model),\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 }\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 const isEnumType = (prop: PropertyModel) => prop.dataType === DataTypes.EnumType;\n const isModelType = (prop: PropertyModel) =>\n prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType;\n const addOptions = this.options.enableNativeInOperator; // limited to hardcoded enableNativeIn for now\n\n if (addOptions && props.some((prop) => !prop.isCollection && !isModelType(prop) && !isEnumType(prop))) {\n importContainer.addFromMainQObject(OPTIONS_STATEMENT);\n }\n\n return props.map((prop) => {\n const { odataName } = prop;\n const name = this.namingHelper.getQPropName(prop.name);\n\n let qPathInit: string;\n\n // factor in collections\n if (prop.isCollection) {\n const qPath = importContainer.addQObject(prop.qPath);\n const qObject = isModelType(prop)\n ? importContainer.addGeneratedQObject(prop.fqType, prop.qObject!)\n : isEnumType(prop)\n ? importContainer.addGeneratedModel(prop.fqType, prop.type, false)\n : importContainer.addQObject(prop.qObject!);\n\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\"), ${isEnumType(prop) ? qObject : `() => ${qObject}`})`;\n } else {\n // add import for data type\n const qPath = importContainer.addQObject(prop.qPath);\n if (isModelType(prop)) {\n const qObject = importContainer.addGeneratedQObject(prop.fqType, prop.qObject!);\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\"), () => ${qObject})`;\n } else if (isEnumType(prop)) {\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 const addConverter = !!converterStmt;\n converterStmt = converterStmt || \"undefined\";\n\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\")${\n addOptions ? `, ${converterStmt}, ${OPTIONS_STATEMENT}` : addConverter ? `, ${converterStmt}` : \"\"\n })`;\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;AAC/D,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGjG,MAAM,CAAC,MAAM,oBAAoB,GAAiC,CAChE,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,YAAY,EACZ,EAAE;IACF,MAAM,SAAS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ACD,+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 { importMainResponseConverter, importReturnType } from \"./import/ImportResponseHelper.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\nconst OPTIONS_STATEMENT = \"OPTS\";\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 this.generateOptions();\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 generateOptions() {\n const file = this.project.createOrGetMainQObjectFile();\n\n // for now assume only enableNativeInOperator requires options to be processed\n if (!this.options.enableNativeInOperator) {\n return;\n }\n\n // for now hardcode enableNativeInOperator\n file.getFile().addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: !this.options.bundledFileGeneration,\n declarations: [\n {\n name: OPTIONS_STATEMENT,\n initializer: `{ nativeIn: true }`,\n },\n ],\n });\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 getExtendsClauseForQObjects(model: ComplexType, imports: ImportContainer) {\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 return imports.addGeneratedQBaseObject(baseModel);\n }\n\n return imports.addQObject(QueryObjectImports.QueryObject);\n }\n\n private generateModel(file: FileHandler, model: ComplexType) {\n const imports = file.getImports();\n\n if (!model.qBaseName) {\n file.getFile().addClass({\n name: model.qName,\n isExported: true,\n extends: this.getExtendsClauseForQObjects(model, imports),\n properties: this.generateQueryObjectProps(file.getImports(), model.props),\n });\n } else {\n // base class used for extension needs an own file\n const baseFile = this.project.createOrGetQObjectFile(model.folderPath, model.qBaseName, [model.qBaseName]);\n baseFile.getFile().addClass({\n name: model.qBaseName,\n isExported: true,\n extends: this.getExtendsClauseForQObjects(model, baseFile.getImports()),\n properties: this.generateQueryObjectProps(baseFile.getImports(), model.props),\n });\n this.project.finalizeFile(baseFile);\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 subClassName = imports.addGeneratedQObject(subClass.fqName, subClass.qName);\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 ${subClassName}(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: imports.addGeneratedQBaseObject(model),\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 }\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 const isEnumType = (prop: PropertyModel) => prop.dataType === DataTypes.EnumType;\n const isModelType = (prop: PropertyModel) =>\n prop.dataType === DataTypes.ModelType || prop.dataType === DataTypes.ComplexType;\n const addOptions = this.options.enableNativeInOperator; // limited to hardcoded enableNativeIn for now\n\n if (addOptions && props.some((prop) => !prop.isCollection && !isModelType(prop) && !isEnumType(prop))) {\n importContainer.addFromMainQObject(OPTIONS_STATEMENT);\n }\n\n return props.map((prop) => {\n const { odataName } = prop;\n const name = this.namingHelper.getQPropName(prop.name);\n\n let qPathInit: string;\n\n // factor in collections\n if (prop.isCollection) {\n const qPath = importContainer.addQObject(prop.qPath);\n const qObject = isModelType(prop)\n ? importContainer.addGeneratedQObject(prop.fqType, prop.qObject!)\n : isEnumType(prop)\n ? importContainer.addGeneratedModel(prop.fqType, prop.type, false)\n : importContainer.addQObject(prop.qObject!);\n\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\"), ${isEnumType(prop) ? qObject : `() => ${qObject}`})`;\n } else {\n // add import for data type\n const qPath = importContainer.addQObject(prop.qPath);\n if (isModelType(prop)) {\n const qObject = importContainer.addGeneratedQObject(prop.fqType, prop.qObject!);\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\"), () => ${qObject})`;\n } else if (isEnumType(prop)) {\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 const addConverter = !!converterStmt;\n converterStmt = converterStmt || \"undefined\";\n\n qPathInit = `new ${qPath}(this.withPrefix(\"${odataName}\")${\n addOptions ? `, ${converterStmt}, ${OPTIONS_STATEMENT}` : addConverter ? `, ${converterStmt}` : \"\"\n })`;\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 =\n operation.type === OperationTypes.Action\n ? QueryObjectImports.QAction\n : isV2\n ? QueryObjectImports.QFunctionV2\n : QueryObjectImports.QFunctionV4;\n const qOperation = imports.addQObject(qOp);\n const paramModelName = hasParams ? imports.addGeneratedModel(baseFqName, operation.paramsModelName) : undefined;\n const rtType = !returnType\n ? undefined\n : returnType.type && returnType.dataType !== DataTypes.PrimitiveType\n ? imports.addGeneratedModel(returnType.fqType, returnType.type)\n : returnType.type;\n const responseStructure = returnType ? importReturnType(this.version, imports, returnType) : undefined;\n const completeResponseStructure = responseStructure && rtType ? `${responseStructure}<${rtType}>` : undefined;\n\n let returnTypeOpStmt: string = \"\";\n if (returnType) {\n if (returnType.dataType === DataTypes.ComplexType || returnType.dataType === DataTypes.ModelType) {\n // without converter no conversion\n if (returnType.qObject) {\n returnTypeOpStmt = `new ${importMainResponseConverter(this.version, imports, returnType)}(new ${imports.addGeneratedQObject(returnType.fqType, returnType.qObject)})`;\n }\n }\n // Primitive Types: without converter no conversion\n else if (returnType.converters) {\n returnTypeOpStmt = `new ${importMainResponseConverter(this.version, imports, returnType)}(${this.generateConverterStmt(imports, returnType.converters)})`;\n }\n }\n\n const classWithGenerics = `${qOperation}<${hasParams ? paramModelName : \"undefined\"}${returnType ? \", \" + completeResponseStructure : \"\"}>`;\n\n file.getFile().addClass({\n name: operation.qName,\n isExported: true,\n extends: classWithGenerics,\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: [`super(\"${operation.odataName}\"${returnTypeOpStmt ? \", \" + returnTypeOpStmt : \"\"})`],\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"]}
|
|
@@ -5,7 +5,8 @@ import { Scope, } from "ts-morph";
|
|
|
5
5
|
import { upperCaseFirst } from "upper-case-first";
|
|
6
6
|
import { firstCharLowerCase } from "xml2js/lib/processors.js";
|
|
7
7
|
import { Modes } from "../OptionModel.js";
|
|
8
|
-
import { ClientApiImports,
|
|
8
|
+
import { ClientApiImports, QueryObjectImports, ServiceImports } from "./import/ImportObjects.js";
|
|
9
|
+
import { importReturnType } from "./import/ImportResponseHelper.js";
|
|
9
10
|
export function generateServices(project, dataModel, version, namingHelper, options) {
|
|
10
11
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11
12
|
const generator = new ServiceGenerator(project, dataModel, version, namingHelper, options);
|
|
@@ -434,10 +435,23 @@ class ServiceGenerator {
|
|
|
434
435
|
const returnType = operation.returnType;
|
|
435
436
|
const hasParams = operation.parameters.length > 0 || ((_a = operation.overrides) === null || _a === void 0 ? void 0 : _a.length);
|
|
436
437
|
const isParamsOptional = !![operation.parameters, ...((_b = operation.overrides) !== null && _b !== void 0 ? _b : [])].find((pSet) => pSet.length === 0);
|
|
438
|
+
const isComposable = operation.composable && returnType && returnType.fqType && returnType.dataType !== "PrimitiveType" /* DataTypes.PrimitiveType */;
|
|
439
|
+
const responseServiceName = !isComposable || !returnType
|
|
440
|
+
? undefined
|
|
441
|
+
: returnType.isCollection
|
|
442
|
+
? this.namingHelper.getCollectionServiceName(returnType.fqType)
|
|
443
|
+
: this.namingHelper.getServiceName(returnType.fqType);
|
|
444
|
+
const useUrlGetCmd = this.version === ODataVersions.V4 && isFunc && !operation.usePost;
|
|
437
445
|
// importing dependencies
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
|
|
446
|
+
const requestCmd = importContainer.addServiceObject(this.version, isComposable
|
|
447
|
+
? ServiceImports.ComposableUrlRequestCmd
|
|
448
|
+
: useUrlGetCmd
|
|
449
|
+
? ServiceImports.UrlGetRequestCmd
|
|
450
|
+
: ServiceImports.UrlRequestCmd);
|
|
451
|
+
const responseStructure = returnType ? importReturnType(this.version, importContainer, returnType) : undefined;
|
|
452
|
+
const responseService = responseServiceName
|
|
453
|
+
? importContainer.addGeneratedService(returnType.fqType, responseServiceName)
|
|
454
|
+
: undefined;
|
|
441
455
|
const qOperationName = importContainer.addGeneratedQObject(baseFqName, operation.qName);
|
|
442
456
|
const rtType = (returnType === null || returnType === void 0 ? void 0 : returnType.type) && returnType.dataType !== "PrimitiveType" /* DataTypes.PrimitiveType */
|
|
443
457
|
? importContainer.addGeneratedModel(returnType.fqType, returnType.type)
|
|
@@ -445,48 +459,43 @@ class ServiceGenerator {
|
|
|
445
459
|
const paramsModelName = hasParams
|
|
446
460
|
? importContainer.addGeneratedModel(baseFqName, operation.paramsModelName)
|
|
447
461
|
: undefined;
|
|
448
|
-
const requestConfigParam = {
|
|
449
|
-
name: "requestConfig",
|
|
450
|
-
hasQuestionToken: true,
|
|
451
|
-
type: `${httpClientConfigModel}<ClientType>`,
|
|
452
|
-
};
|
|
453
462
|
const qOpProp = "this." + this.namingHelper.getPrivatePropName(operation.qName);
|
|
463
|
+
const optionStmt = `{ ` +
|
|
464
|
+
`headers: getDefaultHeaders()` +
|
|
465
|
+
(!isFunc && hasParams ? `, mainRequestConverter: ${qOpProp}.getRequestConverter()` : "") +
|
|
466
|
+
(returnType ? `, mainResponseConverter: ${qOpProp}.getResponseConverter()` : "") +
|
|
467
|
+
`}`;
|
|
468
|
+
const requestCmdStmt = isComposable
|
|
469
|
+
? `return new ${requestCmd}<ClientType, ${responseService}<ClientType>, ${responseStructure}<${rtType}>>(` +
|
|
470
|
+
`client,` +
|
|
471
|
+
`url,` +
|
|
472
|
+
`(finalUrl: string) => new ${responseService}<ClientType>(client, finalUrl, "", options),` +
|
|
473
|
+
optionStmt +
|
|
474
|
+
`);`
|
|
475
|
+
: `return new ${requestCmd}<ClientType, ${responseStructure ? `${responseStructure}<${rtType}>` : "undefined"}${!isFunc && hasParams ? ", " + paramsModelName : ""}>(` +
|
|
476
|
+
`client,` +
|
|
477
|
+
`${useUrlGetCmd ? "" : `${importContainer.addClientApi(ClientApiImports.ODataHttpMethods)}.${!isFunc || operation.usePost ? "Post" : "Get"},`}` +
|
|
478
|
+
`url, ` +
|
|
479
|
+
`${useUrlGetCmd ? "" : !isFunc && hasParams ? "params," : "undefined,"}` +
|
|
480
|
+
optionStmt +
|
|
481
|
+
`);`;
|
|
454
482
|
return {
|
|
455
483
|
scope: Scope.Public,
|
|
456
|
-
isAsync: true,
|
|
457
484
|
name,
|
|
458
485
|
parameters: hasParams
|
|
459
|
-
? [{ name: "params", type: paramsModelName, hasQuestionToken: isParamsOptional }
|
|
460
|
-
:
|
|
461
|
-
returnType: `Promise<${odataResponse}<${responseStructure}<${rtType || "void"}>>>`,
|
|
486
|
+
? [{ name: "params", type: paramsModelName, hasQuestionToken: isParamsOptional }]
|
|
487
|
+
: undefined,
|
|
462
488
|
statements: [
|
|
463
489
|
`if(!${qOpProp}) {`,
|
|
464
490
|
` ${qOpProp} = new ${qOperationName}()`,
|
|
465
491
|
"}",
|
|
466
|
-
`const { addFullPath, client, getDefaultHeaders
|
|
467
|
-
`const url = addFullPath(${qOpProp}.buildUrl(${isFunc
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
`post(url, ${hasParams ? `${qOpProp}.convertUserParams(params)` : "{}"}, ${requestConfigParam.name}, getDefaultHeaders())`
|
|
471
|
-
: operation.usePost
|
|
472
|
-
? // V2 POST => BUT values are still query params, they are not part of the request body
|
|
473
|
-
`post(url, undefined, ${requestConfigParam.name}, getDefaultHeaders())`
|
|
474
|
-
: // functions: since V2
|
|
475
|
-
`get(url, ${requestConfigParam.name}, getDefaultHeaders())`};`,
|
|
476
|
-
returnType ? `return ${qOpProp}.convertResponse(response);` : "",
|
|
492
|
+
`const { addFullPath, client, getDefaultHeaders${isFunc ? `, isUrlNotEncoded${isComposable ? ", options" : ""}` : ""} } = this.__base;`,
|
|
493
|
+
`const url = addFullPath(${qOpProp}.buildUrl(${!isFunc ? "" : hasParams ? "params, isUrlNotEncoded()" : "isUrlNotEncoded()"}));`,
|
|
494
|
+
``,
|
|
495
|
+
requestCmdStmt,
|
|
477
496
|
],
|
|
478
497
|
};
|
|
479
498
|
}
|
|
480
|
-
importReturnType(imports, returnType) {
|
|
481
|
-
const typeToImport = (returnType === null || returnType === void 0 ? void 0 : returnType.isCollection)
|
|
482
|
-
? CoreImports.ODataCollectionResponse
|
|
483
|
-
: (returnType === null || returnType === void 0 ? void 0 : returnType.dataType) === "PrimitiveType" /* DataTypes.PrimitiveType */
|
|
484
|
-
? CoreImports.ODataValueResponse
|
|
485
|
-
: this.version === ODataVersions.V4
|
|
486
|
-
? CoreImports.ODataModelResponseV4
|
|
487
|
-
: CoreImports.ODataEntityModelResponseV2;
|
|
488
|
-
return imports.addCoreLib(this.version, typeToImport);
|
|
489
|
-
}
|
|
490
499
|
generateCastOperations(importContainer, model, isCollection) {
|
|
491
500
|
const result = { properties: [], methods: [] };
|
|
492
501
|
if (this.version === ODataVersions.V4) {
|
|
@@ -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,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,YAA0B,EAC1B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Y,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(prop.qObject)}<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,C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AAC;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 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, QueryObjectImports, ServiceImports } from \"./import/ImportObjects.js\";\nimport { importReturnType } from \"./import/ImportResponseHelper.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(prop.qObject)}<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 const isComposable =\n operation.composable && returnType && returnType.fqType && returnType.dataType !== DataTypes.PrimitiveType;\n const responseServiceName =\n !isComposable || !returnType\n ? undefined\n : returnType.isCollection\n ? this.namingHelper.getCollectionServiceName(returnType.fqType)\n : this.namingHelper.getServiceName(returnType.fqType);\n const useUrlGetCmd = this.version === ODataVersions.V4 && isFunc && !operation.usePost;\n\n // importing dependencies\n const requestCmd = importContainer.addServiceObject(\n this.version,\n isComposable\n ? ServiceImports.ComposableUrlRequestCmd\n : useUrlGetCmd\n ? ServiceImports.UrlGetRequestCmd\n : ServiceImports.UrlRequestCmd,\n );\n const responseStructure = returnType ? importReturnType(this.version, importContainer, returnType) : undefined;\n const responseService = responseServiceName\n ? importContainer.addGeneratedService(returnType!.fqType, responseServiceName)\n : undefined;\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 qOpProp = \"this.\" + this.namingHelper.getPrivatePropName(operation.qName);\n\n const optionStmt =\n `{ ` +\n `headers: getDefaultHeaders()` +\n (!isFunc && hasParams ? `, mainRequestConverter: ${qOpProp}.getRequestConverter()` : \"\") +\n (returnType ? `, mainResponseConverter: ${qOpProp}.getResponseConverter()` : \"\") +\n `}`;\n const requestCmdStmt = isComposable\n ? `return new ${requestCmd}<ClientType, ${responseService}<ClientType>, ${responseStructure}<${rtType}>>(` +\n `client,` +\n `url,` +\n `(finalUrl: string) => new ${responseService}<ClientType>(client, finalUrl, \"\", options),` +\n optionStmt +\n `);`\n : `return new ${requestCmd}<ClientType, ${responseStructure ? `${responseStructure}<${rtType}>` : \"undefined\"}${!isFunc && hasParams ? \", \" + paramsModelName : \"\"}>(` +\n `client,` +\n `${useUrlGetCmd ? \"\" : `${importContainer.addClientApi(ClientApiImports.ODataHttpMethods)}.${!isFunc || operation.usePost ? \"Post\" : \"Get\"},`}` +\n `url, ` +\n `${useUrlGetCmd ? \"\" : !isFunc && hasParams ? \"params,\" : \"undefined,\"}` +\n optionStmt +\n `);`;\n\n return {\n scope: Scope.Public,\n name,\n parameters: hasParams\n ? [{ name: \"params\", type: paramsModelName, hasQuestionToken: isParamsOptional }]\n : undefined,\n statements: [\n `if(!${qOpProp}) {`,\n ` ${qOpProp} = new ${qOperationName}()`,\n \"}\",\n\n `const { addFullPath, client, getDefaultHeaders${isFunc ? `, isUrlNotEncoded${isComposable ? \", options\" : \"\"}` : \"\"} } = this.__base;`,\n `const url = addFullPath(${qOpProp}.buildUrl(${!isFunc ? \"\" : hasParams ? \"params, isUrlNotEncoded()\" : \"isUrlNotEncoded()\"}));`,\n ``,\n requestCmdStmt,\n ],\n };\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"]}
|
|
@@ -32,12 +32,18 @@ export declare enum QueryObjectImports {
|
|
|
32
32
|
QueryObject = "QueryObject",
|
|
33
33
|
ENUMERABLE_PROP_DEFINITION = "ENUMERABLE_PROP_DEFINITION",
|
|
34
34
|
QId = "QId",
|
|
35
|
-
|
|
35
|
+
QFunctionV2 = "QFunctionV2",
|
|
36
|
+
QFunctionV4 = "QFunctionV4",
|
|
36
37
|
QAction = "QAction",
|
|
37
38
|
EnumCollection = "EnumCollection",
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
QComplexParam = "QComplexParam",
|
|
40
|
+
CollectionResponseConverterV4 = "CollectionResponseConverterV4",
|
|
41
|
+
CollectionResponseConverterV2 = "CollectionResponseConverterV2",
|
|
42
|
+
ValueResponseConverterV4 = "ValueResponseConverterV4",
|
|
43
|
+
ValueResponseConverterV2 = "ValueResponseConverterV2",
|
|
44
|
+
ModelResponseConverterV4 = "ModelResponseConverterV4",
|
|
45
|
+
EntityResponseConverterV2 = "EntityResponseConverterV2",
|
|
46
|
+
ComplexResponseConverterV2 = "ComplexResponseConverterV2"
|
|
41
47
|
}
|
|
42
48
|
/**
|
|
43
49
|
* All imports from HTTP client API.
|
|
@@ -45,7 +51,8 @@ export declare enum QueryObjectImports {
|
|
|
45
51
|
export declare enum ClientApiImports {
|
|
46
52
|
ODataHttpClient = 0,
|
|
47
53
|
ODataHttpClientConfig = 1,
|
|
48
|
-
HttpResponseModel = 2
|
|
54
|
+
HttpResponseModel = 2,
|
|
55
|
+
ODataHttpMethods = 3
|
|
49
56
|
}
|
|
50
57
|
/**
|
|
51
58
|
* All imports from service library.
|
|
@@ -59,7 +66,10 @@ export declare enum ServiceImports {
|
|
|
59
66
|
PrimitiveTypeService = 4,
|
|
60
67
|
CollectionService = 5,
|
|
61
68
|
EntitySetService = 6,
|
|
62
|
-
ComplexTypeService = 7
|
|
69
|
+
ComplexTypeService = 7,
|
|
70
|
+
UrlRequestCmd = 8,
|
|
71
|
+
UrlGetRequestCmd = 9,
|
|
72
|
+
ComposableUrlRequestCmd = 10
|
|
63
73
|
}
|
|
64
74
|
/**
|
|
65
75
|
* For all versioned imports two files exist, one for V2, one for V4.
|
|
@@ -34,12 +34,18 @@ export var QueryObjectImports;
|
|
|
34
34
|
QueryObjectImports["QueryObject"] = "QueryObject";
|
|
35
35
|
QueryObjectImports["ENUMERABLE_PROP_DEFINITION"] = "ENUMERABLE_PROP_DEFINITION";
|
|
36
36
|
QueryObjectImports["QId"] = "QId";
|
|
37
|
-
QueryObjectImports["
|
|
37
|
+
QueryObjectImports["QFunctionV2"] = "QFunctionV2";
|
|
38
|
+
QueryObjectImports["QFunctionV4"] = "QFunctionV4";
|
|
38
39
|
QueryObjectImports["QAction"] = "QAction";
|
|
39
40
|
QueryObjectImports["EnumCollection"] = "EnumCollection";
|
|
40
|
-
QueryObjectImports["OperationReturnType"] = "OperationReturnType";
|
|
41
|
-
QueryObjectImports["ReturnTypes"] = "ReturnTypes";
|
|
42
41
|
QueryObjectImports["QComplexParam"] = "QComplexParam";
|
|
42
|
+
QueryObjectImports["CollectionResponseConverterV4"] = "CollectionResponseConverterV4";
|
|
43
|
+
QueryObjectImports["CollectionResponseConverterV2"] = "CollectionResponseConverterV2";
|
|
44
|
+
QueryObjectImports["ValueResponseConverterV4"] = "ValueResponseConverterV4";
|
|
45
|
+
QueryObjectImports["ValueResponseConverterV2"] = "ValueResponseConverterV2";
|
|
46
|
+
QueryObjectImports["ModelResponseConverterV4"] = "ModelResponseConverterV4";
|
|
47
|
+
QueryObjectImports["EntityResponseConverterV2"] = "EntityResponseConverterV2";
|
|
48
|
+
QueryObjectImports["ComplexResponseConverterV2"] = "ComplexResponseConverterV2";
|
|
43
49
|
})(QueryObjectImports || (QueryObjectImports = {}));
|
|
44
50
|
/**
|
|
45
51
|
* All imports from HTTP client API.
|
|
@@ -49,6 +55,7 @@ export var ClientApiImports;
|
|
|
49
55
|
ClientApiImports[ClientApiImports["ODataHttpClient"] = 0] = "ODataHttpClient";
|
|
50
56
|
ClientApiImports[ClientApiImports["ODataHttpClientConfig"] = 1] = "ODataHttpClientConfig";
|
|
51
57
|
ClientApiImports[ClientApiImports["HttpResponseModel"] = 2] = "HttpResponseModel";
|
|
58
|
+
ClientApiImports[ClientApiImports["ODataHttpMethods"] = 3] = "ODataHttpMethods";
|
|
52
59
|
})(ClientApiImports || (ClientApiImports = {}));
|
|
53
60
|
/**
|
|
54
61
|
* All imports from service library.
|
|
@@ -64,6 +71,9 @@ export var ServiceImports;
|
|
|
64
71
|
ServiceImports[ServiceImports["CollectionService"] = 5] = "CollectionService";
|
|
65
72
|
ServiceImports[ServiceImports["EntitySetService"] = 6] = "EntitySetService";
|
|
66
73
|
ServiceImports[ServiceImports["ComplexTypeService"] = 7] = "ComplexTypeService";
|
|
74
|
+
ServiceImports[ServiceImports["UrlRequestCmd"] = 8] = "UrlRequestCmd";
|
|
75
|
+
ServiceImports[ServiceImports["UrlGetRequestCmd"] = 9] = "UrlGetRequestCmd";
|
|
76
|
+
ServiceImports[ServiceImports["ComposableUrlRequestCmd"] = 10] = "ComposableUrlRequestCmd";
|
|
67
77
|
})(ServiceImports || (ServiceImports = {}));
|
|
68
78
|
/**
|
|
69
79
|
* For all versioned imports two files exist, one for V2, one for V4.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportObjects.js","sourceRoot":"","sources":["../../../src/generator/import/ImportObjects.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,+BAA+B;IACxC,SAAS,EAAE,2BAA2B;IACtC,OAAO,EAAE,yBAAyB;CACnC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAN,IAAY,WAOX;AAPD,WAAY,WAAW;IACrB,mEAAe,CAAA;IACf,mFAAuB,CAAA;IACvB,6EAAoB,CAAA;IACpB,yEAAkB,CAAA;IAClB,yFAA0B,CAAA;IAC1B,2FAA2B,CAAA;AAC7B,CAAC,EAPW,WAAW,KAAX,WAAW,QAOtB;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,WAAW,CAAC,uBAAuB,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;AAE5G;;GAEG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"ImportObjects.js","sourceRoot":"","sources":["../../../src/generator/import/ImportObjects.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,+BAA+B;IACxC,SAAS,EAAE,2BAA2B;IACtC,OAAO,EAAE,yBAAyB;CACnC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAN,IAAY,WAOX;AAPD,WAAY,WAAW;IACrB,mEAAe,CAAA;IACf,mFAAuB,CAAA;IACvB,6EAAoB,CAAA;IACpB,yEAAkB,CAAA;IAClB,yFAA0B,CAAA;IAC1B,2FAA2B,CAAA;AAC7B,CAAC,EAPW,WAAW,KAAX,WAAW,QAOtB;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,WAAW,CAAC,uBAAuB,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;AAE5G;;GAEG;AACH,MAAM,CAAN,IAAY,kBAgBX;AAhBD,WAAY,kBAAkB;IAC5B,iDAA2B,CAAA;IAC3B,+EAAyD,CAAA;IACzD,iCAAW,CAAA;IACX,iDAA2B,CAAA;IAC3B,iDAA2B,CAAA;IAC3B,yCAAmB,CAAA;IACnB,uDAAiC,CAAA;IACjC,qDAA+B,CAAA;IAC/B,qFAA+D,CAAA;IAC/D,qFAA+D,CAAA;IAC/D,2EAAqD,CAAA;IACrD,2EAAqD,CAAA;IACrD,2EAAqD,CAAA;IACrD,6EAAuD,CAAA;IACvD,+EAAyD,CAAA;AAC3D,CAAC,EAhBW,kBAAkB,KAAlB,kBAAkB,QAgB7B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,6EAAe,CAAA;IACf,yFAAqB,CAAA;IACrB,iFAAiB,CAAA;IACjB,+EAAgB,CAAA;AAClB,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,cAYX;AAZD,WAAY,cAAc;IACxB,mEAAY,CAAA;IACZ,iFAAmB,CAAA;IACnB,iGAA2B,CAAA;IAC3B,6EAAiB,CAAA;IACjB,mFAAoB,CAAA;IACpB,6EAAiB,CAAA;IACjB,2EAAgB,CAAA;IAChB,+EAAkB,CAAA;IAClB,qEAAa,CAAA;IACb,2EAAgB,CAAA;IAChB,0FAAuB,CAAA;AACzB,CAAC,EAZW,cAAc,KAAd,cAAc,QAYzB;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,cAAc,CAAC,iBAAiB;IAChC,cAAc,CAAC,oBAAoB;IACnC,cAAc,CAAC,iBAAiB;IAChC,cAAc,CAAC,gBAAgB;IAC/B,cAAc,CAAC,kBAAkB;CAClC,CAAC","sourcesContent":["/**\n * All module names of the main dependencies.\n */\nexport const LIB_MODULES = {\n core: \"@odata2ts/odata-core\",\n qObject: \"@odata2ts/odata-query-objects\",\n clientApi: \"@odata2ts/http-client-api\",\n service: \"@odata2ts/odata-service\",\n};\n\n/**\n * All imported entity names from the core API.\n * Includes versioned file names, i.e. according to OData version.\n */\nexport enum CoreImports {\n DeferredContent,\n ODataCollectionResponse, // versioned\n ODataModelResponseV4,\n ODataValueResponse, // versioned\n ODataEntityModelResponseV2,\n ODataComplexModelResponseV2,\n}\n\n/**\n * For all core imports that are versioned two files exist, one for V2, one for V4.\n * ODataCollectionResponse = ODataCollectionResponseV2 + ODataCollectionResponseV4\n *\n */\nexport const VERSIONED_CORE_IMPORTS = [CoreImports.ODataCollectionResponse, CoreImports.ODataValueResponse];\n\n/**\n * Most relevant, but not all imports from query objects library\n */\nexport enum QueryObjectImports {\n QueryObject = \"QueryObject\",\n ENUMERABLE_PROP_DEFINITION = \"ENUMERABLE_PROP_DEFINITION\",\n QId = \"QId\",\n QFunctionV2 = \"QFunctionV2\",\n QFunctionV4 = \"QFunctionV4\",\n QAction = \"QAction\",\n EnumCollection = \"EnumCollection\",\n QComplexParam = \"QComplexParam\",\n CollectionResponseConverterV4 = \"CollectionResponseConverterV4\",\n CollectionResponseConverterV2 = \"CollectionResponseConverterV2\",\n ValueResponseConverterV4 = \"ValueResponseConverterV4\",\n ValueResponseConverterV2 = \"ValueResponseConverterV2\",\n ModelResponseConverterV4 = \"ModelResponseConverterV4\",\n EntityResponseConverterV2 = \"EntityResponseConverterV2\",\n ComplexResponseConverterV2 = \"ComplexResponseConverterV2\",\n}\n\n/**\n * All imports from HTTP client API.\n */\nexport enum ClientApiImports {\n ODataHttpClient,\n ODataHttpClientConfig,\n HttpResponseModel,\n ODataHttpMethods,\n}\n\n/**\n * All imports from service library.\n * Includes versioned file names, i.e. according to OData version.\n */\nexport enum ServiceImports {\n ODataService,\n ODataServiceOptions,\n ODataServiceOptionsInternal,\n EntityTypeService,\n PrimitiveTypeService,\n CollectionService,\n EntitySetService,\n ComplexTypeService,\n UrlRequestCmd,\n UrlGetRequestCmd,\n ComposableUrlRequestCmd,\n}\n\n/**\n * For all versioned imports two files exist, one for V2, one for V4.\n * EntityTypeService = EntityTypeServiceV2 + EntityTypeServiceV4\n */\nexport const VERSIONED_SERVICE_IMPORTS = [\n ServiceImports.EntityTypeService,\n ServiceImports.PrimitiveTypeService,\n ServiceImports.CollectionService,\n ServiceImports.EntitySetService,\n ServiceImports.ComplexTypeService,\n];\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ODataVersions } from "@odata2ts/odata-core";
|
|
2
|
+
import { ReturnTypeModel } from "../../data-model/DataTypeModel.js";
|
|
3
|
+
import { ImportContainer } from "../ImportContainer.js";
|
|
4
|
+
export declare function importReturnType(version: ODataVersions, imports: ImportContainer, returnType: ReturnTypeModel): string;
|
|
5
|
+
export declare function importMainResponseConverter(version: ODataVersions, imports: ImportContainer, returnType: ReturnTypeModel): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ODataVersions } from "@odata2ts/odata-core";
|
|
2
|
+
import { CoreImports, QueryObjectImports } from "./ImportObjects.js";
|
|
3
|
+
export function importReturnType(version, imports, returnType) {
|
|
4
|
+
const typeToImport = returnType.isCollection
|
|
5
|
+
? CoreImports.ODataCollectionResponse
|
|
6
|
+
: returnType.dataType === "PrimitiveType" /* DataTypes.PrimitiveType */
|
|
7
|
+
? CoreImports.ODataValueResponse
|
|
8
|
+
: undefined;
|
|
9
|
+
if (typeToImport) {
|
|
10
|
+
return imports.addCoreLib(version, typeToImport);
|
|
11
|
+
}
|
|
12
|
+
return version === ODataVersions.V2
|
|
13
|
+
? importReturnTypeV2(imports, returnType)
|
|
14
|
+
: importReturnTypeV4(imports, returnType);
|
|
15
|
+
}
|
|
16
|
+
function importReturnTypeV4(imports, returnType) {
|
|
17
|
+
return imports.addCoreLib(ODataVersions.V4, CoreImports.ODataModelResponseV4);
|
|
18
|
+
}
|
|
19
|
+
function importReturnTypeV2(imports, returnType) {
|
|
20
|
+
return imports.addCoreLib(ODataVersions.V2, returnType.dataType === "ComplexType" /* DataTypes.ComplexType */
|
|
21
|
+
? CoreImports.ODataComplexModelResponseV2
|
|
22
|
+
: CoreImports.ODataEntityModelResponseV2);
|
|
23
|
+
}
|
|
24
|
+
export function importMainResponseConverter(version, imports, returnType) {
|
|
25
|
+
return version === ODataVersions.V2
|
|
26
|
+
? importMainResponseConverterV2(imports, returnType)
|
|
27
|
+
: importMainResponseConverterV4(imports, returnType);
|
|
28
|
+
}
|
|
29
|
+
function importMainResponseConverterV4(imports, returnType) {
|
|
30
|
+
const toImport = returnType.isCollection
|
|
31
|
+
? QueryObjectImports.CollectionResponseConverterV4
|
|
32
|
+
: returnType.dataType === "PrimitiveType" /* DataTypes.PrimitiveType */
|
|
33
|
+
? QueryObjectImports.ValueResponseConverterV4
|
|
34
|
+
: QueryObjectImports.ModelResponseConverterV4;
|
|
35
|
+
return imports.addQObject(toImport);
|
|
36
|
+
}
|
|
37
|
+
function importMainResponseConverterV2(imports, returnType) {
|
|
38
|
+
const toImport = returnType.isCollection
|
|
39
|
+
? QueryObjectImports.CollectionResponseConverterV2
|
|
40
|
+
: returnType.dataType === "PrimitiveType" /* DataTypes.PrimitiveType */
|
|
41
|
+
? QueryObjectImports.ValueResponseConverterV2
|
|
42
|
+
: returnType.dataType === "ComplexType" /* DataTypes.ComplexType */
|
|
43
|
+
? QueryObjectImports.ComplexResponseConverterV2
|
|
44
|
+
: QueryObjectImports.EntityResponseConverterV2;
|
|
45
|
+
return imports.addQObject(toImport);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=ImportResponseHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImportResponseHelper.js","sourceRoot":"","sources":["../../../src/generator/import/ImportResponseHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAErE,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,UAAU,CAAC,YAAY;QAC1D,CAAC,CAAC,kBAAkB,CAAC,6BAA6B;QAClD,CAAC,CAAC,UAAU,CAAC,QAAQ,kDAA4B;YAC/C,CAAC,CAAC,kBAAkB,CAAC,wBAAwB;YAC7C,CAAC,CAAC,kBAAkB,CAAC,wBAAwB,CAAC;IAElD,OAAO,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,6BAA6B,CAAC,OAAwB,EAAE,UAA2B;IAC1F,MAAM,QAAQ,GAAuB,UAAU,CAAC,YAAY;QAC1D,CAAC,CAAC,kBAAkB,CAAC,6BAA6B;QAClD,CAAC,CAAC,UAAU,CAAC,QAAQ,kDAA4B;YAC/C,CAAC,CAAC,kBAAkB,CAAC,wBAAwB;YAC7C,CAAC,CAAC,UAAU,CAAC,QAAQ,8CAA0B;gBAC7C,CAAC,CAAC,kBAAkB,CAAC,0BAA0B;gBAC/C,CAAC,CAAC,kBAAkB,CAAC,yBAAyB,CAAC;IAErD,OAAO,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { ODataVersions } from \"@odata2ts/odata-core\";\nimport { DataTypes, ReturnTypeModel } from \"../../data-model/DataTypeModel.js\";\nimport { ImportContainer } from \"../ImportContainer.js\";\nimport { CoreImports, QueryObjectImports } from \"./ImportObjects.js\";\n\nexport function importReturnType(\n version: ODataVersions,\n imports: ImportContainer,\n returnType: ReturnTypeModel,\n): string {\n const typeToImport: CoreImports | undefined = returnType.isCollection\n ? CoreImports.ODataCollectionResponse\n : returnType.dataType === DataTypes.PrimitiveType\n ? CoreImports.ODataValueResponse\n : undefined;\n\n if (typeToImport) {\n return imports.addCoreLib(version, typeToImport);\n }\n\n return version === ODataVersions.V2\n ? importReturnTypeV2(imports, returnType)\n : importReturnTypeV4(imports, returnType);\n}\n\nfunction importReturnTypeV4(imports: ImportContainer, returnType: ReturnTypeModel) {\n return imports.addCoreLib(ODataVersions.V4, CoreImports.ODataModelResponseV4);\n}\n\nfunction importReturnTypeV2(imports: ImportContainer, returnType: ReturnTypeModel) {\n return imports.addCoreLib(\n ODataVersions.V2,\n returnType.dataType === DataTypes.ComplexType\n ? CoreImports.ODataComplexModelResponseV2\n : CoreImports.ODataEntityModelResponseV2,\n );\n}\n\nexport function importMainResponseConverter(\n version: ODataVersions,\n imports: ImportContainer,\n returnType: ReturnTypeModel,\n) {\n return version === ODataVersions.V2\n ? importMainResponseConverterV2(imports, returnType)\n : importMainResponseConverterV4(imports, returnType);\n}\n\nfunction importMainResponseConverterV4(imports: ImportContainer, returnType: ReturnTypeModel): string {\n const toImport: QueryObjectImports = returnType.isCollection\n ? QueryObjectImports.CollectionResponseConverterV4\n : returnType.dataType === DataTypes.PrimitiveType\n ? QueryObjectImports.ValueResponseConverterV4\n : QueryObjectImports.ModelResponseConverterV4;\n\n return imports.addQObject(toImport);\n}\n\nfunction importMainResponseConverterV2(imports: ImportContainer, returnType: ReturnTypeModel): string {\n const toImport: QueryObjectImports = returnType.isCollection\n ? QueryObjectImports.CollectionResponseConverterV2\n : returnType.dataType === DataTypes.PrimitiveType\n ? QueryObjectImports.ValueResponseConverterV2\n : returnType.dataType === DataTypes.ComplexType\n ? QueryObjectImports.ComplexResponseConverterV2\n : QueryObjectImports.EntityResponseConverterV2;\n\n return imports.addQObject(toImport);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odata2ts/odata2ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
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",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"clean-v2": "rimraf build/v2",
|
|
37
37
|
"clean-v4": "rimraf build/v4",
|
|
38
38
|
"compile": "tsc -p tsconfig.compile.json",
|
|
39
|
+
"coverage": "vitest run --dir test --coverage --testTimeout=30000",
|
|
39
40
|
"dev": "yarn generate trippin odata",
|
|
40
41
|
"generate": "npx tsx src/run-cli.ts",
|
|
41
42
|
"int-test": "yarn clean && vitest run --dir int-test",
|
|
@@ -68,14 +69,14 @@
|
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"@odata2ts/converter-v2-to-v4": "^0.5.1",
|
|
71
|
-
"@odata2ts/odata-query-objects": "^0.
|
|
72
|
-
"@odata2ts/odata-service": "^0.
|
|
72
|
+
"@odata2ts/odata-query-objects": "^0.29.0",
|
|
73
|
+
"@odata2ts/odata-service": "^0.24.0",
|
|
73
74
|
"@odata2ts/test-converters": "^0.5.0",
|
|
74
75
|
"@types/node": "^22.4.0"
|
|
75
76
|
},
|
|
76
77
|
"peerDependencies": {
|
|
77
|
-
"@odata2ts/odata-query-objects": "^0.
|
|
78
|
-
"@odata2ts/odata-service": "^0.
|
|
78
|
+
"@odata2ts/odata-query-objects": "^0.29.0",
|
|
79
|
+
"@odata2ts/odata-service": "^0.24.0",
|
|
79
80
|
"typescript": ">= 4.7"
|
|
80
81
|
},
|
|
81
82
|
"publishConfig": {
|