@odata2ts/odata2ts 0.40.1 → 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 +68 -0
- package/lib/FactoryFunctionModel.d.ts +2 -2
- package/lib/FactoryFunctionModel.js.map +1 -1
- package/lib/OptionModel.d.ts +8 -0
- package/lib/OptionModel.js.map +1 -1
- package/lib/data-model/DataModelDigestion.js +23 -5
- package/lib/data-model/DataModelDigestion.js.map +1 -1
- 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/QueryObjectTypes.d.ts +13 -0
- package/lib/data-model/QueryObjectTypes.js +15 -0
- package/lib/data-model/QueryObjectTypes.js.map +1 -0
- package/lib/data-model/edmx/ODataEdmxModelV4.d.ts +1 -0
- package/lib/data-model/edmx/ODataEdmxModelV4.js.map +1 -1
- package/lib/defaultConfig.js +1 -0
- package/lib/defaultConfig.js.map +1 -1
- package/lib/generator/ImportContainer.d.ts +3 -0
- package/lib/generator/ImportContainer.js +18 -2
- package/lib/generator/ImportContainer.js.map +1 -1
- package/lib/generator/QueryObjectGenerator.js +79 -64
- package/lib/generator/QueryObjectGenerator.js.map +1 -1
- package/lib/generator/ServiceGenerator.js +44 -35
- package/lib/generator/ServiceGenerator.js.map +1 -1
- package/lib/generator/import/ImportObjects.d.ts +16 -12
- package/lib/generator/import/ImportObjects.js +13 -9
- 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/lib/project/ProjectManager.js +2 -2
- package/lib/project/ProjectManager.js.map +1 -1
- package/package.json +7 -6
|
@@ -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"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum QueryObjectTypes {
|
|
2
|
+
QEnumCollection = "QEnumCollection",
|
|
3
|
+
QNumericEnumCollection = "QNumericEnumCollection",
|
|
4
|
+
QEnumPath = "QEnumPath",
|
|
5
|
+
QEnumCollectionPath = "QEnumCollectionPath",
|
|
6
|
+
QNumericEnumPath = "QNumericEnumPath",
|
|
7
|
+
QNumericEnumCollectionPath = "QNumericEnumCollectionPath",
|
|
8
|
+
QCollectionPath = "QCollectionPath",
|
|
9
|
+
QComplexPath = "QComplexPath",
|
|
10
|
+
QEntityPath = "QEntityPath",
|
|
11
|
+
QComplexCollectionPath = "QComplexCollectionPath",
|
|
12
|
+
QEntityCollectionPath = "QEntityCollectionPath"
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export var QueryObjectTypes;
|
|
2
|
+
(function (QueryObjectTypes) {
|
|
3
|
+
QueryObjectTypes["QEnumCollection"] = "QEnumCollection";
|
|
4
|
+
QueryObjectTypes["QNumericEnumCollection"] = "QNumericEnumCollection";
|
|
5
|
+
QueryObjectTypes["QEnumPath"] = "QEnumPath";
|
|
6
|
+
QueryObjectTypes["QEnumCollectionPath"] = "QEnumCollectionPath";
|
|
7
|
+
QueryObjectTypes["QNumericEnumPath"] = "QNumericEnumPath";
|
|
8
|
+
QueryObjectTypes["QNumericEnumCollectionPath"] = "QNumericEnumCollectionPath";
|
|
9
|
+
QueryObjectTypes["QCollectionPath"] = "QCollectionPath";
|
|
10
|
+
QueryObjectTypes["QComplexPath"] = "QComplexPath";
|
|
11
|
+
QueryObjectTypes["QEntityPath"] = "QEntityPath";
|
|
12
|
+
QueryObjectTypes["QComplexCollectionPath"] = "QComplexCollectionPath";
|
|
13
|
+
QueryObjectTypes["QEntityCollectionPath"] = "QEntityCollectionPath";
|
|
14
|
+
})(QueryObjectTypes || (QueryObjectTypes = {}));
|
|
15
|
+
//# sourceMappingURL=QueryObjectTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryObjectTypes.js","sourceRoot":"","sources":["../../src/data-model/QueryObjectTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,gBAYX;AAZD,WAAY,gBAAgB;IAC1B,uDAAmC,CAAA;IACnC,qEAAiD,CAAA;IACjD,2CAAuB,CAAA;IACvB,+DAA2C,CAAA;IAC3C,yDAAqC,CAAA;IACrC,6EAAyD,CAAA;IACzD,uDAAmC,CAAA;IACnC,iDAA6B,CAAA;IAC7B,+CAA2B,CAAA;IAC3B,qEAAiD,CAAA;IACjD,mEAA+C,CAAA;AACjD,CAAC,EAZW,gBAAgB,KAAhB,gBAAgB,QAY3B","sourcesContent":["export enum QueryObjectTypes {\n QEnumCollection = \"QEnumCollection\",\n QNumericEnumCollection = \"QNumericEnumCollection\",\n QEnumPath = \"QEnumPath\",\n QEnumCollectionPath = \"QEnumCollectionPath\",\n QNumericEnumPath = \"QNumericEnumPath\",\n QNumericEnumCollectionPath = \"QNumericEnumCollectionPath\",\n QCollectionPath = \"QCollectionPath\",\n QComplexPath = \"QComplexPath\",\n QEntityPath = \"QEntityPath\",\n QComplexCollectionPath = \"QComplexCollectionPath\",\n QEntityCollectionPath = \"QEntityCollectionPath\",\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"]}
|
package/lib/defaultConfig.js
CHANGED
package/lib/defaultConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../src/defaultConfig.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAgB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAc,MAAM,kBAAkB,CAAC;AAGhE;;GAEG;AACH,MAAM,aAAa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AC,MAAM;YAC5C,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM;SAC7C;KACF;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,SAAS,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,EAAE,MAAM,KAAqB,aAAa,EAA7B,WAAW,UAAK,aAAa,EAA1C,UAA0B,CAAgB,CAAC;IACjD,OAAO,SAAS,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import deepmerge from \"deepmerge\";\nimport { NameSettings, NamingStrategies } from \"./NamingModel.js\";\nimport { EmitModes, Modes, RunOptions } from \"./OptionModel.js\";\n\nexport type DefaultConfiguration = Omit<RunOptions, \"sourceUrl\" | \"source\" | \"output\" | \"serviceName\">;\n/**\n * The default configuration.\n */\nconst defaultConfig: DefaultConfiguration = {\n sourceUrlConfig: {},\n refreshFile: false,\n mode: Modes.all,\n emitMode: EmitModes.js_dts,\n debug: false,\n prettier: false,\n tsconfig: \"tsconfig.json\",\n converters: [],\n skipEditableModels: false,\n skipIdModels: false,\n skipOperations: false,\n skipComments: false,\n enablePrimitivePropertyServices: false,\n disableAutoManagedKey: false,\n allowRenaming: false,\n v2ModelsWithExtraResultsWrapping: false,\n v4BigNumberAsString: false,\n disableAutomaticNameClashResolution: false,\n bundledFileGeneration: true,\n enumType: \"string\",\n naming: {\n models: {\n namingStrategy: NamingStrategies.PASCAL_CASE,\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\n editableModels: {\n prefix: \"Editable\",\n suffix: \"\",\n applyModelNaming: true,\n },\n idModels: {\n prefix: \"\",\n suffix: \"Id\",\n applyModelNaming: true,\n },\n operationParamModels: {\n prefix: \"\",\n suffix: \"Params\",\n applyModelNaming: true,\n },\n fileName: {\n namingStrategy: NamingStrategies.PASCAL_CASE,\n prefix: \"\",\n suffix: \"Model\",\n },\n },\n queryObjects: {\n namingStrategy: NamingStrategies.PASCAL_CASE,\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\n prefix: \"Q\",\n suffix: \"\",\n idFunctions: {\n prefix: \"\",\n suffix: \"Id\",\n },\n fileName: {\n namingStrategy: NamingStrategies.PASCAL_CASE,\n prefix: \"Q\",\n suffix: \"\",\n },\n baseType: {\n applyQNaming: true,\n prefix: \"\",\n suffix: \"BaseType\",\n },\n },\n services: {\n prefix: \"\",\n suffix: \"Service\",\n namingStrategy: NamingStrategies.PASCAL_CASE,\n main: {\n applyServiceNaming: true,\n },\n collection: {\n prefix: \"\",\n suffix: \"Collection\",\n applyServiceNaming: true,\n },\n operations: {\n namingStrategy: NamingStrategies.CAMEL_CASE,\n },\n relatedServiceGetter: {\n namingStrategy: NamingStrategies.CAMEL_CASE,\n prefix: \"\",\n suffix: \"\",\n },\n privateProps: {\n namingStrategy: NamingStrategies.CAMEL_CASE,\n prefix: \"_\",\n suffix: \"\",\n },\n },\n },\n propertiesByName: [],\n byTypeAndName: [],\n enableNativeInOperator: false\n};\n\nconst { models, queryObjects, services } = defaultConfig.naming;\nconst minimalNamingConfig: NameSettings = {\n models: {\n fileName: {\n prefix: models.fileName.prefix,\n suffix: models.fileName.suffix,\n },\n idModels: {\n applyModelNaming: true,\n prefix: models.idModels.prefix,\n suffix: models.idModels.suffix,\n },\n editableModels: {\n applyModelNaming: true,\n prefix: models.editableModels.prefix,\n suffix: models.editableModels.suffix,\n },\n operationParamModels: {\n applyModelNaming: true,\n prefix: models.operationParamModels.prefix,\n suffix: models.operationParamModels.suffix,\n },\n },\n queryObjects: {\n prefix: queryObjects.prefix,\n suffix: queryObjects.suffix,\n fileName: {\n prefix: queryObjects.fileName.prefix,\n suffix: queryObjects.fileName.suffix,\n },\n idFunctions: {\n prefix: queryObjects.idFunctions.prefix,\n suffix: queryObjects.idFunctions.suffix,\n },\n baseType: {\n prefix: queryObjects.baseType.prefix,\n suffix: queryObjects.baseType.suffix,\n },\n },\n services: {\n prefix: services.prefix,\n suffix: services.suffix,\n main: {\n applyServiceNaming: true,\n },\n collection: {\n applyServiceNaming: true,\n prefix: services.collection.prefix,\n suffix: services.collection.suffix,\n },\n privateProps: {\n prefix: services.privateProps.prefix,\n suffix: services.privateProps.suffix,\n },\n relatedServiceGetter: {\n prefix: services.relatedServiceGetter.prefix,\n suffix: services.relatedServiceGetter.suffix,\n },\n },\n};\n\n/**\n * Creates a defensive copy of the default config.\n */\nexport function getDefaultConfig(): DefaultConfiguration {\n return deepmerge(defaultConfig, {});\n}\n\n/**\n * Creates a defensive copy of the minimal config: minimal in respect to naming.\n */\nexport function getMinimalConfig(): DefaultConfiguration {\n const { naming, ...passThrough } = defaultConfig;\n return deepmerge(passThrough, { naming: minimalNamingConfig });\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ODataVersions } from "@odata2ts/odata-core";
|
|
2
2
|
import { ImportDeclarationStructure, OptionalKind } from "ts-morph";
|
|
3
3
|
import { DataModel } from "../data-model/DataModel.js";
|
|
4
|
+
import { ComplexType } from "../data-model/DataTypeModel.js";
|
|
4
5
|
import { ClientApiImports, CoreImports, QueryObjectImports, ServiceImports } from "./import/ImportObjects.js";
|
|
5
6
|
/**
|
|
6
7
|
* Handles all the import statements for a given file.
|
|
@@ -31,6 +32,7 @@ export declare class ImportContainer {
|
|
|
31
32
|
service: string;
|
|
32
33
|
}, bundledFileGeneration: boolean, reservedNames: Array<string> | undefined);
|
|
33
34
|
addCoreLib(odataVersion: ODataVersions, coreLib: CoreImports): string;
|
|
35
|
+
addFromMainQObject(name: string, isTypeOnly?: boolean): string;
|
|
34
36
|
private addFromQObject;
|
|
35
37
|
addQObject(qObject: QueryObjectImports | string): string;
|
|
36
38
|
addQObjectType(qObject: string): string;
|
|
@@ -41,6 +43,7 @@ export declare class ImportContainer {
|
|
|
41
43
|
private isDifferentFile;
|
|
42
44
|
private addGeneratedImport;
|
|
43
45
|
addGeneratedModel(fqName: string, name: string, isTypeOnly?: boolean): string;
|
|
46
|
+
addGeneratedQBaseObject(model: ComplexType, isTypeOnly?: boolean): string;
|
|
44
47
|
addGeneratedQObject(fqName: string, name: string, isTypeOnly?: boolean): string;
|
|
45
48
|
addGeneratedService(fqName: string, name: string): string;
|
|
46
49
|
private createImportDecl;
|
|
@@ -44,6 +44,9 @@ export class ImportContainer {
|
|
|
44
44
|
this.libs.core.typeOnly.set(name, importName);
|
|
45
45
|
return importName;
|
|
46
46
|
}
|
|
47
|
+
addFromMainQObject(name, isTypeOnly = false) {
|
|
48
|
+
return this.addGeneratedImport("", this.mainFileNames.qObject, name, isTypeOnly);
|
|
49
|
+
}
|
|
47
50
|
addFromQObject(name, typeOnlyImport = false) {
|
|
48
51
|
const importName = this.importedNameValidator.validateName(LIB_MODULES.qObject, name);
|
|
49
52
|
const imports = this.libs.qObject;
|
|
@@ -69,8 +72,13 @@ export class ImportContainer {
|
|
|
69
72
|
addClientApi(clientApi) {
|
|
70
73
|
const name = ClientApiImports[clientApi];
|
|
71
74
|
const importName = this.importedNameValidator.validateName(LIB_MODULES.clientApi, name);
|
|
72
|
-
|
|
73
|
-
|
|
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
|
+
}
|
|
74
82
|
return importName;
|
|
75
83
|
}
|
|
76
84
|
addServiceObject(odataVersion, serviceObject) {
|
|
@@ -133,6 +141,14 @@ export class ImportContainer {
|
|
|
133
141
|
return this.addGeneratedImport(folderPath, modelName, name, isTypeOnly);
|
|
134
142
|
}
|
|
135
143
|
}
|
|
144
|
+
addGeneratedQBaseObject(model, isTypeOnly = false) {
|
|
145
|
+
if (!model.qBaseName) {
|
|
146
|
+
throw new Error(`Model ${model.fqName} has no base type!`);
|
|
147
|
+
}
|
|
148
|
+
return this.bundledFileGeneration
|
|
149
|
+
? this.addGeneratedImport("", this.mainFileNames.qObject, model.qBaseName, isTypeOnly)
|
|
150
|
+
: this.addGeneratedImport(model.folderPath, model.qBaseName, model.qBaseName, isTypeOnly);
|
|
151
|
+
}
|
|
136
152
|
addGeneratedQObject(fqName, name, isTypeOnly = false) {
|
|
137
153
|
if (this.bundledFileGeneration) {
|
|
138
154
|
return this.addGeneratedImport("", this.mainFileNames.qObject, name, isTypeOnly);
|
|
@@ -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,EAA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AC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;YACvD,CAAC,CAAC;YACJ,GAAG,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;iBACjC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;iBAC5C,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,EAAE;gBACvB,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;gBAC5C,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACjD,CAAC,CAAC;SACL,CAAC;IACJ,CAAC;IAEO,eAAe,CAAC,QAA6B;QACnD,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;YACrD,IAAI;YACJ,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SAC1C,CAAC,CAAC,CAAC;IACN,CAAC;IAEO,kBAAkB,CAAC,QAAgB;QACzC,MAAM,YAAY,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 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 // complete client api consists only of types\n this.libs.clientApi.typeOnly.set(name, importName);\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 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"]}
|
|
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,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ClF,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,10 +3,12 @@ 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();
|
|
9
10
|
};
|
|
11
|
+
const OPTIONS_STATEMENT = "OPTS";
|
|
10
12
|
class QueryObjectGenerator {
|
|
11
13
|
constructor(project, dataModel, version, options, namingHelper) {
|
|
12
14
|
this.project = project;
|
|
@@ -18,6 +20,7 @@ class QueryObjectGenerator {
|
|
|
18
20
|
generate() {
|
|
19
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
22
|
this.project.initQObjects();
|
|
23
|
+
this.generateOptions();
|
|
21
24
|
// process EntityType & ComplexType
|
|
22
25
|
const promises = [...this.generateEntityTypes(), ...this.generateComplexTypes()];
|
|
23
26
|
if (!this.options.skipOperations) {
|
|
@@ -28,6 +31,24 @@ class QueryObjectGenerator {
|
|
|
28
31
|
return this.project.finalizeQObjects();
|
|
29
32
|
});
|
|
30
33
|
}
|
|
34
|
+
generateOptions() {
|
|
35
|
+
const file = this.project.createOrGetMainQObjectFile();
|
|
36
|
+
// for now assume only enableNativeInOperator requires options to be processed
|
|
37
|
+
if (!this.options.enableNativeInOperator) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
// for now hardcode enableNativeInOperator
|
|
41
|
+
file.getFile().addVariableStatement({
|
|
42
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
43
|
+
isExported: !this.options.bundledFileGeneration,
|
|
44
|
+
declarations: [
|
|
45
|
+
{
|
|
46
|
+
name: OPTIONS_STATEMENT,
|
|
47
|
+
initializer: `{ nativeIn: true }`,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
}
|
|
31
52
|
generateEntityTypes() {
|
|
32
53
|
return this.dataModel.getEntityTypes().map((model) => {
|
|
33
54
|
const file = this.project.createOrGetQObjectFile(model.folderPath, model.qName, [
|
|
@@ -63,31 +84,40 @@ class QueryObjectGenerator {
|
|
|
63
84
|
return this.project.finalizeFile(file);
|
|
64
85
|
});
|
|
65
86
|
}
|
|
66
|
-
|
|
67
|
-
const imports = file.getImports();
|
|
68
|
-
const properties = this.generateQueryObjectProps(file.getImports(), model.props);
|
|
69
|
-
let extendsClause;
|
|
87
|
+
getExtendsClauseForQObjects(model, imports) {
|
|
70
88
|
if (model.baseClasses.length) {
|
|
71
89
|
const baseClass = model.baseClasses[0];
|
|
72
90
|
const baseModel = this.dataModel.getModel(baseClass);
|
|
73
91
|
if (!baseModel) {
|
|
74
92
|
throw new Error(`Entity or complex type "${baseClass}" from baseClass attribute not found!`);
|
|
75
93
|
}
|
|
76
|
-
|
|
94
|
+
return imports.addGeneratedQBaseObject(baseModel);
|
|
77
95
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
96
|
+
return imports.addQObject(QueryObjectImports.QueryObject);
|
|
97
|
+
}
|
|
98
|
+
generateModel(file, model) {
|
|
99
|
+
const imports = file.getImports();
|
|
100
|
+
if (!model.qBaseName) {
|
|
83
101
|
file.getFile().addClass({
|
|
102
|
+
name: model.qName,
|
|
103
|
+
isExported: true,
|
|
104
|
+
extends: this.getExtendsClauseForQObjects(model, imports),
|
|
105
|
+
properties: this.generateQueryObjectProps(file.getImports(), model.props),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// base class used for extension needs an own file
|
|
110
|
+
const baseFile = this.project.createOrGetQObjectFile(model.folderPath, model.qBaseName, [model.qBaseName]);
|
|
111
|
+
baseFile.getFile().addClass({
|
|
84
112
|
name: model.qBaseName,
|
|
85
113
|
isExported: true,
|
|
86
|
-
extends:
|
|
87
|
-
properties,
|
|
114
|
+
extends: this.getExtendsClauseForQObjects(model, baseFile.getImports()),
|
|
115
|
+
properties: this.generateQueryObjectProps(baseFile.getImports(), model.props),
|
|
88
116
|
});
|
|
117
|
+
this.project.finalizeFile(baseFile);
|
|
89
118
|
const [props, getAccessors, methods, statements] = Array.from(model.subtypes).reduce((collector, subtype) => {
|
|
90
119
|
const subClass = this.dataModel.getModel(subtype);
|
|
120
|
+
const subClassName = imports.addGeneratedQObject(subClass.fqName, subClass.qName);
|
|
91
121
|
const methodName = `__as${subClass.qName}`;
|
|
92
122
|
const enumerablePropDef = imports.addQObject(QueryObjectImports.ENUMERABLE_PROP_DEFINITION);
|
|
93
123
|
collector[0].push(`"${subClass.fqName}": "${subClass.qName}"`);
|
|
@@ -104,14 +134,14 @@ class QueryObjectGenerator {
|
|
|
104
134
|
collector[2].push({
|
|
105
135
|
name: methodName,
|
|
106
136
|
scope: Scope.Private,
|
|
107
|
-
statements: `return new ${
|
|
137
|
+
statements: `return new ${subClassName}(this.withPrefix("${subClass.fqName}"))`,
|
|
108
138
|
});
|
|
109
139
|
return collector;
|
|
110
140
|
}, [[], [], [], []]);
|
|
111
141
|
file.getFile().addClass({
|
|
112
142
|
name: model.qName,
|
|
113
143
|
isExported: true,
|
|
114
|
-
extends: model
|
|
144
|
+
extends: imports.addGeneratedQBaseObject(model),
|
|
115
145
|
properties: [
|
|
116
146
|
{
|
|
117
147
|
name: "__subtypeMapping",
|
|
@@ -125,14 +155,6 @@ class QueryObjectGenerator {
|
|
|
125
155
|
});
|
|
126
156
|
file.getFile().addStatements(`Object.defineProperties(${model.qName}.prototype, { ${statements.join(",")} });`);
|
|
127
157
|
}
|
|
128
|
-
else {
|
|
129
|
-
file.getFile().addClass({
|
|
130
|
-
name: model.qName,
|
|
131
|
-
isExported: true,
|
|
132
|
-
extends: extendsClause,
|
|
133
|
-
properties: properties,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
158
|
file.getFile().addVariableStatement({
|
|
137
159
|
declarationKind: VariableDeclarationKind.Const,
|
|
138
160
|
isExported: true,
|
|
@@ -145,43 +167,42 @@ class QueryObjectGenerator {
|
|
|
145
167
|
});
|
|
146
168
|
}
|
|
147
169
|
generateQueryObjectProps(importContainer, props) {
|
|
170
|
+
const isEnumType = (prop) => prop.dataType === "EnumType" /* DataTypes.EnumType */;
|
|
171
|
+
const isModelType = (prop) => prop.dataType === "ModelType" /* DataTypes.ModelType */ || prop.dataType === "ComplexType" /* DataTypes.ComplexType */;
|
|
172
|
+
const addOptions = this.options.enableNativeInOperator; // limited to hardcoded enableNativeIn for now
|
|
173
|
+
if (addOptions && props.some((prop) => !prop.isCollection && !isModelType(prop) && !isEnumType(prop))) {
|
|
174
|
+
importContainer.addFromMainQObject(OPTIONS_STATEMENT);
|
|
175
|
+
}
|
|
148
176
|
return props.map((prop) => {
|
|
149
177
|
const { odataName } = prop;
|
|
150
178
|
const name = this.namingHelper.getQPropName(prop.name);
|
|
151
|
-
const isModelType = prop.dataType === "ModelType" /* DataTypes.ModelType */ || prop.dataType === "ComplexType" /* DataTypes.ComplexType */;
|
|
152
|
-
const isEnumType = prop.dataType === "EnumType" /* DataTypes.EnumType */;
|
|
153
|
-
const isNumericEnum = this.options.enumType === "numeric";
|
|
154
179
|
let qPathInit;
|
|
155
180
|
// factor in collections
|
|
156
181
|
if (prop.isCollection) {
|
|
157
|
-
const qPath = importContainer.addQObject(
|
|
158
|
-
|
|
159
|
-
: isEnumType
|
|
160
|
-
? isNumericEnum
|
|
161
|
-
? QueryObjectImports.QNumericEnumCollectionPath
|
|
162
|
-
: QueryObjectImports.QEnumCollectionPath
|
|
163
|
-
: QueryObjectImports.QCollectionPath);
|
|
164
|
-
const qObject = isModelType
|
|
182
|
+
const qPath = importContainer.addQObject(prop.qPath);
|
|
183
|
+
const qObject = isModelType(prop)
|
|
165
184
|
? importContainer.addGeneratedQObject(prop.fqType, prop.qObject)
|
|
166
|
-
: isEnumType
|
|
185
|
+
: isEnumType(prop)
|
|
167
186
|
? importContainer.addGeneratedModel(prop.fqType, prop.type, false)
|
|
168
187
|
: importContainer.addQObject(prop.qObject);
|
|
169
|
-
qPathInit = `new ${qPath}(this.withPrefix("${odataName}"), ${isEnumType ? qObject : `() => ${qObject}`})`;
|
|
188
|
+
qPathInit = `new ${qPath}(this.withPrefix("${odataName}"), ${isEnumType(prop) ? qObject : `() => ${qObject}`})`;
|
|
170
189
|
}
|
|
171
190
|
else {
|
|
172
191
|
// add import for data type
|
|
173
192
|
const qPath = importContainer.addQObject(prop.qPath);
|
|
174
|
-
if (isModelType) {
|
|
193
|
+
if (isModelType(prop)) {
|
|
175
194
|
const qObject = importContainer.addGeneratedQObject(prop.fqType, prop.qObject);
|
|
176
195
|
qPathInit = `new ${qPath}(this.withPrefix("${odataName}"), () => ${qObject})`;
|
|
177
196
|
}
|
|
178
|
-
else if (isEnumType) {
|
|
197
|
+
else if (isEnumType(prop)) {
|
|
179
198
|
const qObject = importContainer.addGeneratedModel(prop.fqType, prop.type, false);
|
|
180
199
|
qPathInit = `new ${qPath}(this.withPrefix("${odataName}"), ${qObject})`;
|
|
181
200
|
}
|
|
182
201
|
else {
|
|
183
202
|
let converterStmt = this.generateConverterStmt(importContainer, prop.converters);
|
|
184
|
-
|
|
203
|
+
const addConverter = !!converterStmt;
|
|
204
|
+
converterStmt = converterStmt || "undefined";
|
|
205
|
+
qPathInit = `new ${qPath}(this.withPrefix("${odataName}")${addOptions ? `, ${converterStmt}, ${OPTIONS_STATEMENT}` : addConverter ? `, ${converterStmt}` : ""})`;
|
|
185
206
|
}
|
|
186
207
|
}
|
|
187
208
|
return {
|
|
@@ -277,42 +298,38 @@ class QueryObjectGenerator {
|
|
|
277
298
|
const hasParams = operation.parameters.length > 0 || ((_a = operation.overrides) === null || _a === void 0 ? void 0 : _a.length);
|
|
278
299
|
const isParamsOptional = !![operation.parameters, ...((_b = operation.overrides) !== null && _b !== void 0 ? _b : [])].find((pSet) => pSet.length === 0);
|
|
279
300
|
// imports
|
|
280
|
-
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;
|
|
281
306
|
const qOperation = imports.addQObject(qOp);
|
|
282
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;
|
|
283
315
|
let returnTypeOpStmt = "";
|
|
284
316
|
if (returnType) {
|
|
285
317
|
if (returnType.dataType === "ComplexType" /* DataTypes.ComplexType */ || returnType.dataType === "ModelType" /* DataTypes.ModelType */) {
|
|
318
|
+
// without converter no conversion
|
|
286
319
|
if (returnType.qObject) {
|
|
287
|
-
|
|
288
|
-
const rts = imports.addQObject(QueryObjectImports.ReturnTypes);
|
|
289
|
-
const rType = returnType.isCollection
|
|
290
|
-
? "COLLECTION"
|
|
291
|
-
: returnType.dataType === "ComplexType" /* DataTypes.ComplexType */
|
|
292
|
-
? "COMPLEX"
|
|
293
|
-
: "ENTITY";
|
|
294
|
-
const qComplexParam = imports.addQObject(QueryObjectImports.QComplexParam);
|
|
295
|
-
const returnQName = imports.addGeneratedQObject(returnType.fqType, returnType.qObject);
|
|
296
|
-
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)})`;
|
|
297
321
|
}
|
|
298
322
|
}
|
|
299
|
-
//
|
|
300
|
-
else if (returnType.converters
|
|
301
|
-
|
|
302
|
-
const rtTypes = imports.addQObject(QueryObjectImports.ReturnTypes);
|
|
303
|
-
const rType = returnType.isCollection ? "COLLECTION" : "VALUE";
|
|
304
|
-
const qParam = imports.addQObject(returnType.qParam);
|
|
305
|
-
const rtKind = `${rtTypes}.${rType}`;
|
|
306
|
-
const converterParam = returnType.converters
|
|
307
|
-
? ", " + this.generateConverterStmt(imports, returnType.converters)
|
|
308
|
-
: "";
|
|
309
|
-
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)})`;
|
|
310
326
|
}
|
|
311
327
|
}
|
|
328
|
+
const classWithGenerics = `${qOperation}<${hasParams ? paramModelName : "undefined"}${returnType ? ", " + completeResponseStructure : ""}>`;
|
|
312
329
|
file.getFile().addClass({
|
|
313
330
|
name: operation.qName,
|
|
314
331
|
isExported: true,
|
|
315
|
-
extends:
|
|
332
|
+
extends: classWithGenerics,
|
|
316
333
|
properties: [
|
|
317
334
|
{
|
|
318
335
|
name: "params",
|
|
@@ -324,9 +341,7 @@ class QueryObjectGenerator {
|
|
|
324
341
|
],
|
|
325
342
|
ctors: [
|
|
326
343
|
{
|
|
327
|
-
statements: [
|
|
328
|
-
`super("${operation.odataName}"${returnTypeOpStmt ? ", " + returnTypeOpStmt : isV2 ? ", undefined" : ""}${isV2 ? ", { v2Mode: true }" : ""})`,
|
|
329
|
-
],
|
|
344
|
+
statements: [`super("${operation.odataName}"${returnTypeOpStmt ? ", " + returnTypeOpStmt : ""})`],
|
|
330
345
|
},
|
|
331
346
|
],
|
|
332
347
|
methods: [
|